run:R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
23.8 KB
2026-03-11 16:18:51
R W Run
7.8 KB
2026-03-11 16:18:52
R W Run
36.1 KB
2026-03-11 16:18:51
R W Run
11.9 KB
2026-03-11 16:18:52
R W Run
18.94 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:52
R W Run
28.6 KB
2026-03-11 16:18:51
R W Run
316 By
2026-03-11 16:18:51
R W Run
12.9 KB
2026-03-11 16:18:51
R W Run
61.02 KB
2026-03-11 16:18:52
R W Run
15 KB
2026-03-11 16:18:51
R W Run
112.05 KB
2026-03-11 16:18:51
R W Run
12.47 KB
2026-03-11 16:18:51
R W Run
15.07 KB
2026-03-11 16:18:52
R W Run
9.84 KB
2026-03-11 16:18:52
R W Run
13.17 KB
2026-03-11 16:18:52
R W Run
33.83 KB
2026-03-11 16:18:51
R W Run
42.63 KB
2026-03-11 16:18:51
R W Run
55.71 KB
2026-03-11 16:18:52
R W Run
12.53 KB
2026-03-11 16:18:51
R W Run
2.55 KB
2026-03-11 16:18:52
R W Run
28.92 KB
2026-03-11 16:18:52
R W Run
539 By
2026-03-11 16:18:51
R W Run
367 By
2026-03-11 16:18:52
R W Run
42.65 KB
2026-03-11 16:18:51
R W Run
401 By
2026-03-11 16:18:51
R W Run
6.61 KB
2026-03-11 16:18:51
R W Run
664 By
2026-03-11 16:18:52
R W Run
20.63 KB
2026-03-11 16:18:51
R W Run
2.18 KB
2026-03-11 16:18:52
R W Run
453 By
2026-03-11 16:18:52
R W Run
457 By
2026-03-11 16:18:51
R W Run
36.83 KB
2026-03-11 16:18:52
R W Run
2.41 KB
2026-03-11 16:18:52
R W Run
8.28 KB
2026-03-11 16:18:51
R W Run
13.89 KB
2026-03-11 16:18:51
R W Run
11.76 KB
2026-03-11 16:18:51
R W Run
2.65 KB
2026-03-11 16:18:51
R W Run
7.43 KB
2026-03-11 16:18:51
R W Run
17.46 KB
2026-03-11 16:18:51
R W Run
5.14 KB
2026-03-11 16:18:52
R W Run
16.7 KB
2026-03-11 16:18:51
R W Run
8.28 KB
2026-03-11 16:18:52
R W Run
2.92 KB
2026-03-11 16:18:52
R W Run
1.32 KB
2026-03-11 16:18:51
R W Run
4.6 KB
2026-03-11 16:18:52
R W Run
11.62 KB
2026-03-11 16:18:52
R W Run
2.5 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
11.25 KB
2026-03-11 16:18:52
R W Run
5.32 KB
2026-03-11 16:18:51
R W Run
10.99 KB
2026-03-11 16:18:52
R W Run
68.32 KB
2026-03-11 16:18:51
R W Run
6.34 KB
2026-03-11 16:18:51
R W Run
5.49 KB
2026-03-11 16:18:51
R W Run
1.99 KB
2026-03-11 16:18:52
R W Run
7.02 KB
2026-03-11 16:18:51
R W Run
4.91 KB
2026-03-11 16:18:52
R W Run
16.86 KB
2026-03-11 16:18:51
R W Run
24.23 KB
2026-03-11 16:18:51
R W Run
3.97 KB
2026-03-11 16:18:51
R W Run
47.66 KB
2026-03-11 16:18:51
R W Run
9.22 KB
2026-03-11 16:18:51
R W Run
25.51 KB
2026-03-11 16:18:51
R W Run
198.38 KB
2026-03-11 16:18:52
R W Run
56.65 KB
2026-03-11 16:18:51
R W Run
10.46 KB
2026-03-11 16:18:51
R W Run
10.95 KB
2026-03-11 16:18:52
R W Run
29.26 KB
2026-03-11 16:18:51
R W Run
70.91 KB
2026-03-11 16:18:52
R W Run
35.3 KB
2026-03-11 16:18:52
R W Run
16.61 KB
2026-03-11 16:18:52
R W Run
2.57 KB
2026-03-11 16:18:52
R W Run
39.83 KB
2026-03-11 16:18:51
R W Run
70.64 KB
2026-03-11 16:18:51
R W Run
15.56 KB
2026-03-11 16:18:52
R W Run
7.33 KB
2026-03-11 16:18:52
R W Run
253 By
2026-03-11 16:18:51
R W Run
7.96 KB
2026-03-11 16:18:52
R W Run
3.23 KB
2026-03-11 16:18:52
R W Run
969 By
2026-03-11 16:18:52
R W Run
16.28 KB
2026-03-11 16:18:51
R W Run
7.22 KB
2026-03-11 16:18:51
R W Run
12.95 KB
2026-03-11 16:18:51
R W Run
6.53 KB
2026-03-11 16:18:51
R W Run
3.42 KB
2026-03-11 16:18:52
R W Run
5.84 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
4.3 KB
2026-03-11 16:18:52
R W Run
2.91 KB
2026-03-11 16:18:51
R W Run
16.46 KB
2026-03-11 16:18:52
R W Run
40.6 KB
2026-03-11 16:18:51
R W Run
20.22 KB
2026-03-11 16:18:51
R W Run
36.11 KB
2026-03-11 16:18:52
R W Run
17.01 KB
2026-03-11 16:18:51
R W Run
7.27 KB
2026-03-11 16:18:52
R W Run
6.62 KB
2026-03-11 16:18:52
R W Run
16.49 KB
2026-03-11 16:18:52
R W Run
1.79 KB
2026-03-11 16:18:52
R W Run
29.82 KB
2026-03-11 16:18:51
R W Run
6.67 KB
2026-03-11 16:18:52
R W Run
8.98 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:51
R W Run
12.01 KB
2026-03-11 16:18:51
R W Run
17.11 KB
2026-03-11 16:18:51
R W Run
6.74 KB
2026-03-11 16:18:52
R W Run
30.93 KB
2026-03-11 16:18:51
R W Run
4.99 KB
2026-03-11 16:18:51
R W Run
4.25 KB
2026-03-11 16:18:51
R W Run
24.72 KB
2026-03-11 16:18:51
R W Run
29.96 KB
2026-03-11 16:18:52
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
160 KB
2026-03-11 16:18:51
R W Run
6.72 KB
2026-03-11 16:18:52
R W Run
10.92 KB
2026-03-11 16:18:51
R W Run
4.77 KB
2026-03-11 16:18:51
R W Run
3.38 KB
2026-03-11 16:18:51
R W Run
11.18 KB
2026-03-11 16:18:51
R W Run
62.19 KB
2026-03-11 16:18:51
R W Run
2.46 KB
2026-03-11 16:18:51
R W Run
9.17 KB
2026-03-11 16:18:51
R W Run
32.15 KB
2026-03-11 16:18:51
R W Run
34.05 KB
2026-03-11 16:18:52
R W Run
7.15 KB
2026-03-11 16:18:51
R W Run
3.47 KB
2026-03-11 16:18:52
R W Run
1.87 KB
2026-03-11 16:18:52
R W Run
30.91 KB
2026-03-11 16:18:51
R W Run
7.29 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:51
R W Run
12.54 KB
2026-03-11 16:18:51
R W Run
19.12 KB
2026-03-11 16:18:51
R W Run
18.12 KB
2026-03-11 16:18:52
R W Run
39.99 KB
2026-03-11 16:18:52
R W Run
5.17 KB
2026-03-11 16:18:52
R W Run
979 By
2026-03-11 16:18:51
R W Run
18.44 KB
2026-03-11 16:18:52
R W Run
10.24 KB
2026-03-11 16:18:51
R W Run
1.77 KB
2026-03-11 16:18:52
R W Run
34.9 KB
2026-03-11 16:18:51
R W Run
7.19 KB
2026-03-11 16:18:52
R W Run
160.5 KB
2026-03-11 16:18:51
R W Run
64.27 KB
2026-03-11 16:18:51
R W Run
27.95 KB
2026-03-11 16:18:51
R W Run
4.69 KB
2026-03-11 16:18:51
R W Run
2.94 KB
2026-03-11 16:18:51
R W Run
43.13 KB
2026-03-11 16:18:52
R W Run
2.25 KB
2026-03-11 16:18:52
R W Run
22.5 KB
2026-03-11 16:18:51
R W Run
13.01 KB
2026-03-11 16:18:52
R W Run
3.27 KB
2026-03-11 16:18:51
R W Run
18 KB
2026-03-11 16:18:51
R W Run
210.4 KB
2026-03-11 16:18:52
R W Run
25.86 KB
2026-03-11 16:18:52
R W Run
115.85 KB
2026-03-11 16:18:51
R W Run
373 By
2026-03-11 16:18:52
R W Run
343 By
2026-03-11 16:18:52
R W Run
338 By
2026-03-11 16:18:51
R W Run
100.73 KB
2026-03-11 16:18:52
R W Run
130.93 KB
2026-03-11 16:18:51
R W Run
19.1 KB
2026-03-11 16:18:51
R W Run
17.41 KB
2026-03-11 16:18:52
R W Run
41.98 KB
2026-03-11 16:18:52
R W Run
400 By
2026-03-11 16:18:52
R W Run
11.1 KB
2026-03-11 16:18:52
R W Run
37.02 KB
2026-03-11 16:18:51
R W Run
2.24 KB
2026-03-11 16:18:51
R W Run
188.13 KB
2026-03-11 16:18:51
R W Run
338 By
2026-03-11 16:18:51
R W Run
38 KB
2026-03-11 16:18:51
R W Run
4.02 KB
2026-03-11 16:18:52
R W Run
5.38 KB
2026-03-11 16:18:51
R W Run
3.05 KB
2026-03-11 16:18:52
R W Run
2.61 KB
2026-03-11 16:18:51
R W Run
1.16 KB
2026-03-11 16:18:52
R W Run
4.04 KB
2026-03-11 16:18:51
R W Run
3.71 KB
2026-03-11 16:18:51
R W Run
24.6 KB
2026-03-11 16:18:51
R W Run
9.56 KB
2026-03-11 16:18:51
R W Run
346.43 KB
2026-03-11 16:18:52
R W Run
281.84 KB
2026-03-11 16:18:52
R W Run
14.95 KB
2026-03-11 16:18:51
R W Run
8.44 KB
2026-03-11 16:18:52
R W Run
168.95 KB
2026-03-11 16:18:52
R W Run
20.71 KB
2026-03-11 16:18:52
R W Run
25.27 KB
2026-03-11 16:18:51
R W Run
5.72 KB
2026-03-11 16:18:51
R W Run
4.63 KB
2026-03-11 16:18:52
R W Run
81.73 KB
2026-03-11 16:18:51
R W Run
67.18 KB
2026-03-11 16:18:51
R W Run
156.36 KB
2026-03-11 16:18:52
R W Run
55.19 KB
2026-03-11 16:18:51
R W Run
162 By
2026-03-11 16:18:51
R W Run
61.72 KB
2026-03-11 16:18:51
R W Run
216.06 KB
2026-03-11 16:18:52
R W Run
65.09 KB
2026-03-11 16:18:51
R W Run
25.24 KB
2026-03-11 16:18:52
R W Run
4.81 KB
2026-03-11 16:18:51
R W Run
6.48 KB
2026-03-11 16:18:52
R W Run
21.25 KB
2026-03-11 16:18:51
R W Run
2.79 KB
2026-03-11 16:18:52
R W Run
89.69 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:52
R W Run
3.69 KB
2026-03-11 16:18:52
R W Run
4.11 KB
2026-03-11 16:18:51
R W Run
40.74 KB
2026-03-11 16:18:51
R W Run
25.38 KB
2026-03-11 16:18:51
R W Run
43.31 KB
2026-03-11 16:18:52
R W Run
102.57 KB
2026-03-11 16:18:52
R W Run
6.18 KB
2026-03-11 16:18:51
R W Run
124.47 KB
2026-03-11 16:18:52
R W Run
35.65 KB
2026-03-11 16:18:52
R W Run
6.94 KB
2026-03-11 16:18:52
R W Run
67.04 KB
2026-03-11 16:18:52
R W Run
10.62 KB
2026-03-11 16:18:51
R W Run
289.35 KB
2026-03-11 16:18:52
R W Run
36.23 KB
2026-03-11 16:18:51
R W Run
200 By
2026-03-11 16:18:52
R W Run
200 By
2026-03-11 16:18:52
R W Run
98.29 KB
2026-03-11 16:18:52
R W Run
30.02 KB
2026-03-11 16:18:52
R W Run
19.03 KB
2026-03-11 16:18:52
R W Run
5.06 KB
2026-03-11 16:18:52
R W Run
255 By
2026-03-11 16:18:51
R W Run
22.66 KB
2026-03-11 16:18:52
R W Run
154.63 KB
2026-03-11 16:18:51
R W Run
9.68 KB
2026-03-11 16:18:51
R W Run
258 By
2026-03-11 16:18:51
R W Run
23.49 KB
2026-03-11 16:18:51
R W Run
3.16 KB
2026-03-11 16:18:51
R W Run
8.4 KB
2026-03-11 16:18:52
R W Run
441 By
2026-03-11 16:18:51
R W Run
7.39 KB
2026-03-11 16:18:51
R W Run
173 KB
2026-03-11 16:18:52
R W Run
544 By
2026-03-11 16:18:52
R W Run
4.17 KB
2026-03-11 16:18:51
R W Run
35.97 KB
2026-03-11 16:18:52
R W Run
1.69 KB
2026-03-11 16:18:51
R W Run
2.84 KB
2026-03-11 16:18:52
R W Run
6.09 KB
2026-03-11 16:18:51
R W Run
8.71 KB
2026-03-11 16:18:51
R W Run
131.84 KB
2026-03-11 16:18:51
R W Run
37.45 KB
2026-03-11 16:18:51
R W Run
173.89 KB
2026-03-11 16:18:51
R W Run
7.09 KB
2026-03-11 16:18:51
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
1.08 KB
2026-03-11 16:18:51
R W Run
69.46 KB
2026-03-11 16:18:52
R W Run
445 By
2026-03-11 16:18:51
R W Run
799 By
2026-03-11 16:18:52
R W Run
error_log
📄category.php
1<?php
2/**
3 * Taxonomy API: Core category-specific functionality
4 *
5 * @package WordPress
6 * @subpackage Taxonomy
7 */
8
9/**
10 * Retrieves a list of category objects.
11 *
12 * If you set the 'taxonomy' argument to 'link_category', the link categories
13 * will be returned instead.
14 *
15 * @since 2.1.0
16 *
17 * @see get_terms() Type of arguments that can be changed.
18 *
19 * @param string|array $args {
20 * Optional. Arguments to retrieve categories. See get_terms() for additional options.
21 *
22 * @type string $taxonomy Taxonomy to retrieve terms for. Default 'category'.
23 * }
24 * @return array List of category objects.
25 */
26function get_categories( $args = '' ) {
27 $defaults = array( 'taxonomy' => 'category' );
28 $args = wp_parse_args( $args, $defaults );
29
30 /**
31 * Filters the taxonomy used to retrieve terms when calling get_categories().
32 *
33 * @since 2.7.0
34 *
35 * @param string $taxonomy Taxonomy to retrieve terms from.
36 * @param array $args An array of arguments. See get_terms().
37 */
38 $args['taxonomy'] = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args );
39
40 // Back compat.
41 if ( isset( $args['type'] ) && 'link' === $args['type'] ) {
42 _deprecated_argument(
43 __FUNCTION__,
44 '3.0.0',
45 sprintf(
46 /* translators: 1: "type => link", 2: "taxonomy => link_category" */
47 __( '%1$s is deprecated. Use %2$s instead.' ),
48 '<code>type => link</code>',
49 '<code>taxonomy => link_category</code>'
50 )
51 );
52 $args['taxonomy'] = 'link_category';
53 }
54
55 $categories = get_terms( $args );
56
57 if ( is_wp_error( $categories ) ) {
58 $categories = array();
59 } else {
60 $categories = (array) $categories;
61 foreach ( array_keys( $categories ) as $k ) {
62 _make_cat_compat( $categories[ $k ] );
63 }
64 }
65
66 return $categories;
67}
68
69/**
70 * Retrieves category data given a category ID or category object.
71 *
72 * If you pass the $category parameter an object, which is assumed to be the
73 * category row object retrieved the database. It will cache the category data.
74 *
75 * If you pass $category an integer of the category ID, then that category will
76 * be retrieved from the database, if it isn't already cached, and pass it back.
77 *
78 * If you look at get_term(), then both types will be passed through several
79 * filters and finally sanitized based on the $filter parameter value.
80 *
81 * @since 1.5.1
82 *
83 * @param int|object $category Category ID or category row object.
84 * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
85 * correspond to a WP_Term object, an associative array, or a numeric array,
86 * respectively. Default OBJECT.
87 * @param string $filter Optional. How to sanitize category fields. Default 'raw'.
88 * @return WP_Term|array|WP_Error|null Category data in type defined by $output parameter.
89 * Returns a WP_Term object with backwards compatible property aliases filled in.
90 * WP_Error if $category is empty, null if it does not exist.
91 */
92function get_category( $category, $output = OBJECT, $filter = 'raw' ) {
93 $category = get_term( $category, 'category', $output, $filter );
94
95 if ( is_wp_error( $category ) ) {
96 return $category;
97 }
98
99 _make_cat_compat( $category );
100
101 return $category;
102}
103
104/**
105 * Retrieves a category based on URL containing the category slug.
106 *
107 * Breaks the $category_path parameter up to get the category slug.
108 *
109 * Tries to find the child path and will return it. If it doesn't find a
110 * match, then it will return the first category matching slug, if $full_match,
111 * is set to false. If it does not, then it will return null.
112 *
113 * It is also possible that it will return a WP_Error object on failure. Check
114 * for it when using this function.
115 *
116 * @since 2.1.0
117 *
118 * @param string $category_path URL containing category slugs.
119 * @param bool $full_match Optional. Whether full path should be matched.
120 * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
121 * correspond to a WP_Term object, an associative array, or a numeric array,
122 * respectively. Default OBJECT.
123 * @return WP_Term|array|WP_Error|null Type is based on $output value.
124 */
125function get_category_by_path( $category_path, $full_match = true, $output = OBJECT ) {
126 $category_path = rawurlencode( urldecode( $category_path ) );
127 $category_path = str_replace( '%2F', '/', $category_path );
128 $category_path = str_replace( '%20', ' ', $category_path );
129 $category_paths = '/' . trim( $category_path, '/' );
130 $leaf_path = sanitize_title( basename( $category_paths ) );
131 $category_paths = explode( '/', $category_paths );
132 $full_path = '';
133
134 foreach ( (array) $category_paths as $pathdir ) {
135 $full_path .= ( '' !== $pathdir ? '/' : '' ) . sanitize_title( $pathdir );
136 }
137
138 $categories = get_terms(
139 array(
140 'taxonomy' => 'category',
141 'get' => 'all',
142 'slug' => $leaf_path,
143 )
144 );
145
146 if ( empty( $categories ) ) {
147 return;
148 }
149
150 foreach ( $categories as $category ) {
151 $path = '/' . $leaf_path;
152 $curcategory = $category;
153
154 while ( ( 0 !== $curcategory->parent ) && ( $curcategory->parent !== $curcategory->term_id ) ) {
155 $curcategory = get_term( $curcategory->parent, 'category' );
156
157 if ( is_wp_error( $curcategory ) ) {
158 return $curcategory;
159 }
160
161 $path = '/' . $curcategory->slug . $path;
162 }
163
164 if ( $path === $full_path ) {
165 $category = get_term( $category->term_id, 'category', $output );
166 _make_cat_compat( $category );
167
168 return $category;
169 }
170 }
171
172 // If full matching is not required, return the first cat that matches the leaf.
173 if ( ! $full_match ) {
174 $category = get_term( reset( $categories )->term_id, 'category', $output );
175 _make_cat_compat( $category );
176
177 return $category;
178 }
179}
180
181/**
182 * Retrieves a category object by category slug.
183 *
184 * @since 2.3.0
185 *
186 * @param string $slug The category slug.
187 * @return object|false Category data object on success, false if not found.
188 */
189function get_category_by_slug( $slug ) {
190 $category = get_term_by( 'slug', $slug, 'category' );
191
192 if ( $category ) {
193 _make_cat_compat( $category );
194 }
195
196 return $category;
197}
198
199/**
200 * Retrieves the ID of a category from its name.
201 *
202 * @since 1.0.0
203 *
204 * @param string $cat_name Category name.
205 * @return int Category ID on success, 0 if the category doesn't exist.
206 */
207function get_cat_ID( $cat_name ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
208 $cat = get_term_by( 'name', $cat_name, 'category' );
209
210 if ( $cat ) {
211 return $cat->term_id;
212 }
213
214 return 0;
215}
216
217/**
218 * Retrieves the name of a category from its ID.
219 *
220 * @since 1.0.0
221 *
222 * @param int $cat_id Category ID.
223 * @return string Category name, or an empty string if the category doesn't exist.
224 */
225function get_cat_name( $cat_id ) {
226 $cat_id = (int) $cat_id;
227 $category = get_term( $cat_id, 'category' );
228
229 if ( ! $category || is_wp_error( $category ) ) {
230 return '';
231 }
232
233 return $category->name;
234}
235
236/**
237 * Checks if a category is an ancestor of another category.
238 *
239 * You can use either an ID or the category object for both parameters.
240 * If you use an integer, the category will be retrieved.
241 *
242 * @since 2.1.0
243 *
244 * @param int|object $cat1 ID or object to check if this is the parent category.
245 * @param int|object $cat2 The child category.
246 * @return bool Whether $cat2 is child of $cat1.
247 */
248function cat_is_ancestor_of( $cat1, $cat2 ) {
249 return term_is_ancestor_of( $cat1, $cat2, 'category' );
250}
251
252/**
253 * Sanitizes category data based on context.
254 *
255 * @since 2.3.0
256 *
257 * @param object|array $category Category data.
258 * @param string $context Optional. Default 'display'.
259 * @return object|array Same type as $category with sanitized data for safe use.
260 */
261function sanitize_category( $category, $context = 'display' ) {
262 return sanitize_term( $category, 'category', $context );
263}
264
265/**
266 * Sanitizes data in single category key field.
267 *
268 * @since 2.3.0
269 *
270 * @param string $field Category key to sanitize.
271 * @param mixed $value Category value to sanitize.
272 * @param int $cat_id Category ID.
273 * @param string $context What filter to use, 'raw', 'display', etc.
274 * @return mixed Value after $value has been sanitized.
275 */
276function sanitize_category_field( $field, $value, $cat_id, $context ) {
277 return sanitize_term_field( $field, $value, $cat_id, 'category', $context );
278}
279
280/* Tags */
281
282/**
283 * Retrieves all post tags.
284 *
285 * @since 2.3.0
286 *
287 * @param string|array $args {
288 * Optional. Arguments to retrieve tags. See get_terms() for additional options.
289 *
290 * @type string $taxonomy Taxonomy to retrieve terms for. Default 'post_tag'.
291 * }
292 * @return WP_Term[]|int|WP_Error Array of 'post_tag' term objects, a count thereof,
293 * or WP_Error if any of the taxonomies do not exist.
294 */
295function get_tags( $args = '' ) {
296 $defaults = array( 'taxonomy' => 'post_tag' );
297 $args = wp_parse_args( $args, $defaults );
298
299 $tags = get_terms( $args );
300
301 if ( empty( $tags ) ) {
302 $tags = array();
303 } else {
304 /**
305 * Filters the array of term objects returned for the 'post_tag' taxonomy.
306 *
307 * @since 2.3.0
308 *
309 * @param WP_Term[]|int|WP_Error $tags Array of 'post_tag' term objects, a count thereof,
310 * or WP_Error if any of the taxonomies do not exist.
311 * @param array $args An array of arguments. See {@see get_terms()}.
312 */
313 $tags = apply_filters( 'get_tags', $tags, $args );
314 }
315
316 return $tags;
317}
318
319/**
320 * Retrieves a post tag by tag ID or tag object.
321 *
322 * If you pass the $tag parameter an object, which is assumed to be the tag row
323 * object retrieved from the database, it will cache the tag data.
324 *
325 * If you pass $tag an integer of the tag ID, then that tag will be retrieved
326 * from the database, if it isn't already cached, and passed back.
327 *
328 * If you look at get_term(), both types will be passed through several filters
329 * and finally sanitized based on the $filter parameter value.
330 *
331 * @since 2.3.0
332 *
333 * @param int|WP_Term|object $tag A tag ID or object.
334 * @param string $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which
335 * correspond to a WP_Term object, an associative array, or a numeric array,
336 * respectively. Default OBJECT.
337 * @param string $filter Optional. How to sanitize tag fields. Default 'raw'.
338 * @return WP_Term|array|WP_Error|null Tag data in type defined by $output parameter.
339 * WP_Error if $tag is empty, null if it does not exist.
340 */
341function get_tag( $tag, $output = OBJECT, $filter = 'raw' ) {
342 return get_term( $tag, 'post_tag', $output, $filter );
343}
344
345/* Cache */
346
347/**
348 * Removes the category cache data based on ID.
349 *
350 * @since 2.1.0
351 *
352 * @param int $id Category ID
353 */
354function clean_category_cache( $id ) {
355 clean_term_cache( $id, 'category' );
356}
357
358/**
359 * Updates category structure to old pre-2.3 from new taxonomy structure.
360 *
361 * This function was added for the taxonomy support to update the new category
362 * structure with the old category one. This will maintain compatibility with
363 * plugins and themes which depend on the old key or property names.
364 *
365 * The parameter should only be passed a variable and not create the array or
366 * object inline to the parameter. The reason for this is that parameter is
367 * passed by reference and PHP will fail unless it has the variable.
368 *
369 * There is no return value, because everything is updated on the variable you
370 * pass to it. This is one of the features with using pass by reference in PHP.
371 *
372 * @since 2.3.0
373 * @since 4.4.0 The `$category` parameter now also accepts a WP_Term object.
374 * @access private
375 *
376 * @param array|object|WP_Term $category Category row object or array.
377 */
378function _make_cat_compat( &$category ) {
379 if ( is_object( $category ) && ! is_wp_error( $category ) ) {
380 $category->cat_ID = $category->term_id;
381 $category->category_count = $category->count;
382 $category->category_description = $category->description;
383 $category->cat_name = $category->name;
384 $category->category_nicename = $category->slug;
385 $category->category_parent = $category->parent;
386 } elseif ( is_array( $category ) && isset( $category['term_id'] ) ) {
387 $category['cat_ID'] = &$category['term_id'];
388 $category['category_count'] = &$category['count'];
389 $category['category_description'] = &$category['description'];
390 $category['cat_name'] = &$category['name'];
391 $category['category_nicename'] = &$category['slug'];
392 $category['category_parent'] = &$category['parent'];
393 }
394}
395
Ui Ux Design – Teachers Night Out

Get in Touch

© 2024 Teachers Night Out. All Rights Reserved.