/var/www/wordpress/wp-admin/includes/admin.php
/var/www/wordpress/wp-admin/includes/bookmark.php
/var/www/wordpress/wp-admin/includes/class-ftp-pure.php
/var/www/wordpress/wp-admin/includes/class-ftp-sockets.php
/var/www/wordpress/wp-admin/includes/class-ftp.php
/var/www/wordpress/wp-admin/includes/class-pclzip.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-base.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-direct.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php
/var/www/wordpress/wp-admin/includes/class-wp-importer.php
/var/www/wordpress/wp-admin/includes/class-wp-upgrader.php
/var/www/wordpress/wp-admin/includes/comment.php
/var/www/wordpress/wp-admin/includes/continents-cities.php
/var/www/wordpress/wp-admin/includes/dashboard.php
/var/www/wordpress/wp-admin/includes/deprecated.php
/var/www/wordpress/wp-admin/includes/export.php
/var/www/wordpress/wp-admin/includes/file.php
/var/www/wordpress/wp-admin/includes/image-edit.php
/var/www/wordpress/wp-admin/includes/image.php
/var/www/wordpress/wp-admin/includes/import.php
/var/www/wordpress/wp-admin/includes/manifest.php
/var/www/wordpress/wp-admin/includes/media.php
/var/www/wordpress/wp-admin/includes/meta-boxes.php
/var/www/wordpress/wp-admin/includes/misc.php
/var/www/wordpress/wp-admin/includes/ms-deprecated.php
/var/www/wordpress/wp-admin/includes/ms.php
/var/www/wordpress/wp-admin/includes/nav-menu.php
/var/www/wordpress/wp-admin/includes/plugin-install.php
/var/www/wordpress/wp-admin/includes/plugin.php
/var/www/wordpress/wp-admin/includes/post.php
/var/www/wordpress/wp-admin/includes/schema.php
/var/www/wordpress/wp-admin/includes/taxonomy.php
/var/www/wordpress/wp-admin/includes/template.php
/var/www/wordpress/wp-admin/includes/theme-install.php
/var/www/wordpress/wp-admin/includes/theme.php
/var/www/wordpress/wp-admin/includes/update-core.php
/var/www/wordpress/wp-admin/includes/update.php
/var/www/wordpress/wp-admin/includes/upgrade.php
/var/www/wordpress/wp-admin/includes/user.php
/var/www/wordpress/wp-admin/includes/widgets.php
/var/www/wordpress/wp-admin/js/revisions-js.php
/var/www/wordpress/wp-admin/maint/repair.php
/var/www/wordpress/wp-admin/admin-ajax.php
/var/www/wordpress/wp-admin/admin-footer.php
/var/www/wordpress/wp-admin/admin-functions.php
/var/www/wordpress/wp-admin/admin-header.php
/var/www/wordpress/wp-admin/admin-post.php
/var/www/wordpress/wp-admin/admin.php
/var/www/wordpress/wp-admin/async-upload.php
/var/www/wordpress/wp-admin/comment.php
/var/www/wordpress/wp-admin/custom-background.php
/var/www/wordpress/wp-admin/custom-header.php
/var/www/wordpress/wp-admin/edit-attachment-rows.php
/var/www/wordpress/wp-admin/edit-comments.php
/var/www/wordpress/wp-admin/edit-form-advanced.php
/var/www/wordpress/wp-admin/edit-form-comment.php
/var/www/wordpress/wp-admin/edit-link-categories.php
/var/www/wordpress/wp-admin/edit-link-category-form.php
/var/www/wordpress/wp-admin/edit-link-form.php
/var/www/wordpress/wp-admin/edit-post-rows.php
/var/www/wordpress/wp-admin/edit-tag-form.php
/var/www/wordpress/wp-admin/edit-tags.php
/var/www/wordpress/wp-admin/edit.php
/var/www/wordpress/wp-admin/export.php
/var/www/wordpress/wp-admin/gears-manifest.php
/var/www/wordpress/wp-admin/import.php
/var/www/wordpress/wp-admin/index-extra.php
/var/www/wordpress/wp-admin/index.php
/var/www/wordpress/wp-admin/install-helper.php
/var/www/wordpress/wp-admin/install.php
/var/www/wordpress/wp-admin/link-add.php
/var/www/wordpress/wp-admin/link-category.php
/var/www/wordpress/wp-admin/link-manager.php
/var/www/wordpress/wp-admin/link-parse-opml.php
/var/www/wordpress/wp-admin/link.php
/var/www/wordpress/wp-admin/load-scripts.php
/var/www/wordpress/wp-admin/load-styles.php
/var/www/wordpress/wp-admin/media-new.php
/var/www/wordpress/wp-admin/media-upload.php
/var/www/wordpress/wp-admin/media.php
/var/www/wordpress/wp-admin/menu-header.php
/var/www/wordpress/wp-admin/menu.php
/var/www/wordpress/wp-admin/moderation.php
/var/www/wordpress/wp-admin/ms-admin.php
/var/www/wordpress/wp-admin/ms-delete-site.php
/var/www/wordpress/wp-admin/ms-edit.php
/var/www/wordpress/wp-admin/ms-options.php
/var/www/wordpress/wp-admin/ms-sites.php
/var/www/wordpress/wp-admin/ms-themes.php
/var/www/wordpress/wp-admin/ms-upgrade-network.php
/var/www/wordpress/wp-admin/ms-users.php
/var/www/wordpress/wp-admin/my-sites.php
/var/www/wordpress/wp-admin/nav-menus.php
/var/www/wordpress/wp-admin/network.php
/var/www/wordpress/wp-admin/options-discussion.php
/var/www/wordpress/wp-admin/options-general.php
/var/www/wordpress/wp-admin/options-head.php
/var/www/wordpress/wp-admin/options-media.php
/var/www/wordpress/wp-admin/options-permalink.php
/var/www/wordpress/wp-admin/options-privacy.php
/var/www/wordpress/wp-admin/options-reading.php
/var/www/wordpress/wp-admin/options-writing.php
/var/www/wordpress/wp-admin/options.php
/var/www/wordpress/wp-admin/plugin-editor.php
/var/www/wordpress/wp-admin/plugin-install.php
/var/www/wordpress/wp-admin/plugins.php
/var/www/wordpress/wp-admin/post-new.php
/var/www/wordpress/wp-admin/post.php
/var/www/wordpress/wp-admin/press-this.php
/var/www/wordpress/wp-admin/profile.php
/var/www/wordpress/wp-admin/revision.php
/var/www/wordpress/wp-admin/setup-config.php
/var/www/wordpress/wp-admin/sidebar.php
/var/www/wordpress/wp-admin/theme-editor.php
/var/www/wordpress/wp-admin/theme-install.php
/var/www/wordpress/wp-admin/themes.php
/var/www/wordpress/wp-admin/tools.php
/var/www/wordpress/wp-admin/update-core.php
/var/www/wordpress/wp-admin/update.php
/var/www/wordpress/wp-admin/upgrade-functions.php
/var/www/wordpress/wp-admin/upgrade.php
/var/www/wordpress/wp-admin/upload.php
/var/www/wordpress/wp-admin/user-edit.php
/var/www/wordpress/wp-admin/user-new.php
/var/www/wordpress/wp-admin/users.php
/var/www/wordpress/wp-admin/widgets.php
/var/www/wordpress/wp-content/languages/ru_RU.php
/var/www/wordpress/wp-content/plugins/akismet/akismet.php
/var/www/wordpress/wp-content/plugins/rh/rh.php
/var/www/wordpress/wp-content/plugins/hello.php
/var/www/wordpress/wp-content/plugins/index.php
/var/www/wordpress/wp-content/themes/twentyten/404.php
/var/www/wordpress/wp-content/themes/twentyten/archive.php
/var/www/wordpress/wp-content/themes/twentyten/attachment.php
/var/www/wordpress/wp-content/themes/twentyten/author.php
/var/www/wordpress/wp-content/themes/twentyten/category.php
/var/www/wordpress/wp-content/themes/twentyten/comments.php
/var/www/wordpress/wp-content/themes/twentyten/footer.php
/var/www/wordpress/wp-content/themes/twentyten/functions.php
/var/www/wordpress/wp-content/themes/twentyten/header.php
/var/www/wordpress/wp-content/themes/twentyten/index.php
/var/www/wordpress/wp-content/themes/twentyten/loop.php
/var/www/wordpress/wp-content/themes/twentyten/onecolumn-page.php
/var/www/wordpress/wp-content/themes/twentyten/page.php
/var/www/wordpress/wp-content/themes/twentyten/search.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar-footer.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar.php
/var/www/wordpress/wp-content/themes/twentyten/single.php
/var/www/wordpress/wp-content/themes/twentyten/tag.php
/var/www/wordpress/wp-content/themes/index.php
/var/www/wordpress/wp-content/index.php
/var/www/wordpress/wp-includes/js/tinymce/langs/wp-langs.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/EnchantSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/config.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/rpc.php
/var/www/wordpress/wp-includes/js/tinymce/wp-mce-help.php
/var/www/wordpress/wp-includes/js/tinymce/wp-tinymce.php
/var/www/wordpress/wp-includes/pomo/entry.php
/var/www/wordpress/wp-includes/pomo/mo.php
/var/www/wordpress/wp-includes/pomo/po.php
/var/www/wordpress/wp-includes/pomo/streams.php
/var/www/wordpress/wp-includes/pomo/translations.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/native.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/shell.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/string.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/xdiff.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer/inline.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer.php
/var/www/wordpress/wp-includes/Text/Diff.php
/var/www/wordpress/wp-includes/theme-compat/comments-popup.php
/var/www/wordpress/wp-includes/theme-compat/comments.php
/var/www/wordpress/wp-includes/theme-compat/footer.php
/var/www/wordpress/wp-includes/theme-compat/header.php
/var/www/wordpress/wp-includes/theme-compat/sidebar.php
/var/www/wordpress/wp-includes/atomlib.php
/var/www/wordpress/wp-includes/author-template.php
/var/www/wordpress/wp-includes/bookmark-template.php
/var/www/wordpress/wp-includes/bookmark.php
/var/www/wordpress/wp-includes/cache.php
/var/www/wordpress/wp-includes/canonical.php
/var/www/wordpress/wp-includes/capabilities.php
/var/www/wordpress/wp-includes/category-template.php
/var/www/wordpress/wp-includes/category.php
/var/www/wordpress/wp-includes/class-feed.php
/var/www/wordpress/wp-includes/class-http.php
/var/www/wordpress/wp-includes/class-IXR.php
/var/www/wordpress/wp-includes/class-json.php
/var/www/wordpress/wp-includes/class-oembed.php
/var/www/wordpress/wp-includes/class-phpass.php
/var/www/wordpress/wp-includes/class-phpmailer.php
/var/www/wordpress/wp-includes/class-pop3.php
/var/www/wordpress/wp-includes/class-simplepie.php
/var/www/wordpress/wp-includes/class-smtp.php
/var/www/wordpress/wp-includes/class-snoopy.php
/var/www/wordpress/wp-includes/class.wp-dependencies.php
/var/www/wordpress/wp-includes/class.wp-scripts.php
/var/www/wordpress/wp-includes/class.wp-styles.php
/var/www/wordpress/wp-includes/classes.php
/var/www/wordpress/wp-includes/comment-template.php
/var/www/wordpress/wp-includes/comment.php
/var/www/wordpress/wp-includes/compat.php
/var/www/wordpress/wp-includes/cron.php
/var/www/wordpress/wp-includes/default-constants.php
/var/www/wordpress/wp-includes/default-embeds.php
/var/www/wordpress/wp-includes/default-filters.php
/var/www/wordpress/wp-includes/default-widgets.php
/var/www/wordpress/wp-includes/deprecated.php
/var/www/wordpress/wp-includes/feed-atom-comments.php
/var/www/wordpress/wp-includes/feed-atom.php
/var/www/wordpress/wp-includes/feed-rdf.php
/var/www/wordpress/wp-includes/feed-rss.php
/var/www/wordpress/wp-includes/feed-rss2-comments.php
/var/www/wordpress/wp-includes/feed-rss2.php
/var/www/wordpress/wp-includes/feed.php
/var/www/wordpress/wp-includes/formatting.php
/var/www/wordpress/wp-includes/functions.php
/var/www/wordpress/wp-includes/functions.wp-scripts.php
/var/www/wordpress/wp-includes/functions.wp-styles.php
/var/www/wordpress/wp-includes/general-template.php
/var/www/wordpress/wp-includes/http.php
/var/www/wordpress/wp-includes/kses.php
/var/www/wordpress/wp-includes/l10n.php
/var/www/wordpress/wp-includes/link-template.php
/var/www/wordpress/wp-includes/load.php
/var/www/wordpress/wp-includes/locale.php
/var/www/wordpress/wp-includes/media.php
/var/www/wordpress/wp-includes/meta.php
/var/www/wordpress/wp-includes/ms-blogs.php
/var/www/wordpress/wp-includes/ms-default-constants.php
/var/www/wordpress/wp-includes/ms-default-filters.php
/var/www/wordpress/wp-includes/ms-deprecated.php
/var/www/wordpress/wp-includes/ms-files.php
/var/www/wordpress/wp-includes/ms-functions.php
/var/www/wordpress/wp-includes/ms-load.php
/var/www/wordpress/wp-includes/ms-settings.php
/var/www/wordpress/wp-includes/nav-menu-template.php
/var/www/wordpress/wp-includes/nav-menu.php
/var/www/wordpress/wp-includes/pluggable-deprecated.php
/var/www/wordpress/wp-includes/pluggable.php
/var/www/wordpress/wp-includes/plugin.php
/var/www/wordpress/wp-includes/post-template.php
/var/www/wordpress/wp-includes/post-thumbnail-template.php
/var/www/wordpress/wp-includes/post.php
/var/www/wordpress/wp-includes/query.php
/var/www/wordpress/wp-includes/registration-functions.php
/var/www/wordpress/wp-includes/registration.php
/var/www/wordpress/wp-includes/rewrite.php
/var/www/wordpress/wp-includes/rss-functions.php
/var/www/wordpress/wp-includes/rss.php
/var/www/wordpress/wp-includes/script-loader.php
/var/www/wordpress/wp-includes/shortcodes.php
/var/www/wordpress/wp-includes/taxonomy.php
#CodeDescriptions
1<?php
2/**
3 * Taxonomy API
4 *
5 * @package WordPress
6 * @subpackage Taxonomy
7 * @since 2.3.0
8 */
9
10//
11// Taxonomy Registration
12//
13
14/**
15 * Creates the initial taxonomies when 'init' action is fired.
16 */
17function create_initial_taxonomies() {
18 register_taxonomy( 'category', 'post', array(
19 'hierarchical' => true,
20 'update_count_callback' => '_update_post_term_count',
21 'query_var' => false,
22 'rewrite' => false,
23 'public' => true,
24 'show_ui' => true,
25 '_builtin' => true,
26 ) ) ;
27
28 register_taxonomy( 'post_tag', 'post', array(
29 'hierarchical' => false,
30 'update_count_callback' => '_update_post_term_count',
31 'query_var' => false,
32 'rewrite' => false,
33 'public' => true,
34 'show_ui' => true,
35 '_builtin' => true,
36 ) );
37
38 register_taxonomy( 'nav_menu', 'nav_menu_item', array(
39 'hierarchical' => false,
40 'labels' => array(
41 'name' => __( 'Navigation Menus' ),
42 'singular_name' => __( 'Navigation Menu' ),
43 ),
44 'query_var' => false,
45 'rewrite' => false,
46 'show_ui' => false,
47 '_builtin' => true,
48 'show_in_nav_menus' => false,
49 ) ) ;
50
51 register_taxonomy( 'link_category', 'link', array(
52 'hierarchical' => false,
53 'labels' => array(
54 'name' => __( 'Categories' ),
55 'singular_name' => __( 'Category' ),
56 'update_item' => __( 'Update Category' ),
57 ),
58 'query_var' => false,
59 'rewrite' => false,
60 'public' => false,
61 'show_ui' => false,
62 '_builtin' => true,
63 ) ) ;
64}
65add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority
66
67/**
68 * Get a list of registered taxonomy objects.
69 *
70 * @package WordPress
71 * @subpackage Taxonomy
72 * @since 3.0.0
73 * @uses $wp_taxonomies
74 * @see register_taxonomy
75 *
76 * @param array $args An array of key => value arguments to match against the taxonomy objects.
77 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
78 * @param string $operator The logical operation to perform. 'or' means only one element
79 * from the array needs to match; 'and' means all elements must match. The default is 'and'.
80 * @return array A list of taxonomy names or objects
81 */
82function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' ) {
83 global $wp_taxonomies;
84
85 $field = ('names' == $output) ? 'name' : false;
86
87 return wp_filter_object_list($wp_taxonomies, $args, $operator, $field);
88}
89
90
91/**
92 * Return all of the taxonomy names that are of $object_type.
93 *
94 * It appears that this function can be used to find all of the names inside of
95 * $wp_taxonomies global variable.
96 *
97 * <code><?php $taxonomies = get_object_taxonomies('post'); ?></code> Should
98 * result in <code>Array('category', 'post_tag')</code>
99 *
100 * @package WordPress
101 * @subpackage Taxonomy
102 * @since 2.3.0
103 *
104 * @uses $wp_taxonomies
105 *
106 * @param array|string|object $object Name of the type of taxonomy object, or an object (row from posts)
107 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
108 * @return array The names of all taxonomy of $object_type.
109 */
110function get_object_taxonomies($object, $output = 'names') {
111 global $wp_taxonomies;
112
113 if ( is_object($object) ) {
114 if ( $object->post_type == 'attachment' )
115 return get_attachment_taxonomies($object);
116 $object = $object->post_type;
117 }
118
119 $object = (array) $object;
120
121 $taxonomies = array();
122 foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) {
123 if ( array_intersect($object, (array) $tax_obj->object_type) ) {
124 if ( 'names' == $output )
125 $taxonomies[] = $tax_name;
126 else
127 $taxonomies[ $tax_name ] = $tax_obj;
128 }
129 }
130
131 return $taxonomies;
132}
133
134/**
135 * Retrieves the taxonomy object of $taxonomy.
136 *
137 * The get_taxonomy function will first check that the parameter string given
138 * is a taxonomy object and if it is, it will return it.
139 *
140 * @package WordPress
141 * @subpackage Taxonomy
142 * @since 2.3.0
143 *
144 * @uses $wp_taxonomies
145 * @uses taxonomy_exists() Checks whether taxonomy exists
146 *
147 * @param string $taxonomy Name of taxonomy object to return
148 * @return object|bool The Taxonomy Object or false if $taxonomy doesn't exist
149 */
150function get_taxonomy( $taxonomy ) {
151 global $wp_taxonomies;
152
153 if ( ! taxonomy_exists( $taxonomy ) )
154 return false;
155
156 return $wp_taxonomies[$taxonomy];
157}
158
159/**
160 * Checks that the taxonomy name exists.
161 *
162 * Formerly is_taxonomy(), introduced in 2.3.0.
163 *
164 * @package WordPress
165 * @subpackage Taxonomy
166 * @since 3.0.0
167 *
168 * @uses $wp_taxonomies
169 *
170 * @param string $taxonomy Name of taxonomy object
171 * @return bool Whether the taxonomy exists.
172 */
173function taxonomy_exists( $taxonomy ) {
174 global $wp_taxonomies;
175
176 return isset( $wp_taxonomies[$taxonomy] );
177}
178
179/**
180 * Whether the taxonomy object is hierarchical.
181 *
182 * Checks to make sure that the taxonomy is an object first. Then Gets the
183 * object, and finally returns the hierarchical value in the object.
184 *
185 * A false return value might also mean that the taxonomy does not exist.
186 *
187 * @package WordPress
188 * @subpackage Taxonomy
189 * @since 2.3.0
190 *
191 * @uses taxonomy_exists() Checks whether taxonomy exists
192 * @uses get_taxonomy() Used to get the taxonomy object
193 *
194 * @param string $taxonomy Name of taxonomy object
195 * @return bool Whether the taxonomy is hierarchical
196 */
197function is_taxonomy_hierarchical($taxonomy) {
198 if ( ! taxonomy_exists($taxonomy) )
199 return false;
200
201 $taxonomy = get_taxonomy($taxonomy);
202 return $taxonomy->hierarchical;
203}
204
205/**
206 * Create or modify a taxonomy object. Do not use before init.
207 *
208 * A simple function for creating or modifying a taxonomy object based on the
209 * parameters given. The function will accept an array (third optional
210 * parameter), along with strings for the taxonomy name and another string for
211 * the object type.
212 *
213 * Nothing is returned, so expect error maybe or use taxonomy_exists() to check
214 * whether taxonomy exists.
215 *
216 * Optional $args contents:
217 *
218 * label - Name of the taxonomy shown in the menu. Usually plural. If not set, labels['name'] will be used.
219 *
220 * hierarchical - has some defined purpose at other parts of the API and is a
221 * boolean value.
222 *
223 * update_count_callback - works much like a hook, in that it will be called
224 * when the count is updated.
225 *
226 * rewrite - false to prevent rewrite, or array('slug'=>$slug) to customize
227 * permastruct; default will use $taxonomy as slug.
228 *
229 * query_var - false to prevent queries, or string to customize query var
230 * (?$query_var=$term); default will use $taxonomy as query var.
231 *
232 * public - If the taxonomy should be publically queryable; //@TODO not implemented.
233 * defaults to true.
234 *
235 * show_ui - If the WordPress UI admin tags UI should apply to this taxonomy;
236 * defaults to public.
237 *
238 * show_in_nav_menus - true makes this taxonomy available for selection in navigation menus.
239 * Defaults to public.
240 *
241 * show_tagcloud - false to prevent the taxonomy being listed in the Tag Cloud Widget;
242 * defaults to show_ui which defalts to public.
243 *
244 * labels - An array of labels for this taxonomy. You can see accepted values in {@link get_taxonomy_labels()}. By default tag labels are used for non-hierarchical types and category labels for hierarchical ones.
245 *
246 * @package WordPress
247 * @subpackage Taxonomy
248 * @since 2.3.0
249 * @uses $wp_taxonomies Inserts new taxonomy object into the list
250 * @uses $wp_rewrite Adds rewrite tags and permastructs
251 * @uses $wp Adds query vars
252 *
253 * @param string $taxonomy Name of taxonomy object
254 * @param array|string $object_type Name of the object type for the taxonomy object.
255 * @param array|string $args See above description for the two keys values.
256 */
257function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
258 global $wp_taxonomies, $wp_rewrite, $wp;
259
260 if ( ! is_array($wp_taxonomies) )
261 $wp_taxonomies = array();
262
263 $defaults = array( 'hierarchical' => false,
264 'update_count_callback' => '',
265 'rewrite' => true,
266 'query_var' => $taxonomy,
267 'public' => true,
268 'show_ui' => null,
269 'show_tagcloud' => null,
270 '_builtin' => false,
271 'labels' => array(),
272 'capabilities' => array(),
273 'show_in_nav_menus' => null,
274 );
275 $args = wp_parse_args($args, $defaults);
276
277 if ( false !== $args['query_var'] && !empty($wp) ) {
278 if ( true === $args['query_var'] )
279 $args['query_var'] = $taxonomy;
280 $args['query_var'] = sanitize_title_with_dashes($args['query_var']);
281 $wp->add_query_var($args['query_var']);
282 }
283
284 if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) {
285 $args['rewrite'] = wp_parse_args($args['rewrite'], array(
286 'slug' => sanitize_title_with_dashes($taxonomy),
287 'with_front' => true,
288 ));
289 $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=");
290 $wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']);
291 }
292
293 if ( is_null($args['show_ui']) )
294 $args['show_ui'] = $args['public'];
295
296 // Whether to show this type in nav-menus.php. Defaults to the setting for public.
297 if ( null === $args['show_in_nav_menus'] )
298 $args['show_in_nav_menus'] = $args['public'];
299
300 if ( is_null($args['show_tagcloud']) )
301 $args['show_tagcloud'] = $args['show_ui'];
302
303 $default_caps = array(
304 'manage_terms' => 'manage_categories',
305 'edit_terms' => 'manage_categories',
306 'delete_terms' => 'manage_categories',
307 'assign_terms' => 'edit_posts',
308 );
309 $args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] );
310 unset( $args['capabilities'] );
311
312 $args['name'] = $taxonomy;
313 $args['object_type'] = (array) $object_type;
314
315 $args['labels'] = get_taxonomy_labels( (object) $args );
316 $args['label'] = $args['labels']->name;
317
318 $wp_taxonomies[$taxonomy] = (object) $args;
319
320 // register callback handling for metabox
321 add_filter('wp_ajax_add-'.$taxonomy, '_wp_ajax_add_hierarchical_term');
322}
323
324/**
325 * Builds an object with all taxonomy labels out of a taxonomy object
326 *
327 * Accepted keys of the label array in the taxonomy object:
328 * - name - general name for the taxonomy, usually plural. The same as and overriden by $tax->label. Default is Post Tags/Categories
329 * - singular_name - name for one object of this taxonomy. Default is Post Tag/Category
330 * - search_items - Default is Search Tags/Search Categories
331 * - popular_items - This string isn't used on hierarchical taxonomies. Default is Popular Tags
332 * - all_items - Default is All Tags/All Categories
333 * - parent_item - This string isn't used on non-hierarchical taxonomies. In hierarchical ones the default is Parent Category
334 * - parent_item_colon - The same as <code>parent_item</code>, but with colon <code>:</code> in the end
335 * - edit_item - Default is Edit Tag/Edit Category
336 * - update_item - Default is Update Tag/Update Category
337 * - add_new_item - Default is Add New Tag/Add New Category
338 * - new_item_name - Default is New Tag Name/New Category Name
339 * - separate_items_with_commas - This string isn't used on hierarchical taxonomies. Default is "Separate tags with commas," used in the meta box.
340 * - add_or_remove_items - This string isn't used on hierarchical taxonomies. Default is "Add or remove tags," used in the meta box when JavaScript is disabled.
341 * - choose_from_most_used - This string isn't used on hierarchical taxonomies. Default is "Choose from the most used tags," used in the meta box.
342 *
343 * Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories.)
344 *
345 * @since 3.0.0
346 * @param object $tax Taxonomy object
347 * @return object object with all the labels as member variables
348 */
349
350function get_taxonomy_labels( $tax ) {
351 if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) )
352 $tax->labels['separate_items_with_commas'] = $tax->helps;
353
354 $nohier_vs_hier_defaults = array(
355 'name' => array( _x( 'Post Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
356 'singular_name' => array( _x( 'Post Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
357 'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
358 'popular_items' => array( __( 'Popular Tags' ), null ),
359 'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ),
360 'parent_item' => array( null, __( 'Parent Category' ) ),
361 'parent_item_colon' => array( null, __( 'Parent Category:' ) ),
362 'edit_item' => array( __( 'Edit Tag' ), __( 'Edit Category' ) ),
363 'update_item' => array( __( 'Update Tag' ), __( 'Update Category' ) ),
364 'add_new_item' => array( __( 'Add New Tag' ), __( 'Add New Category' ) ),
365 'new_item_name' => array( __( 'New Tag Name' ), __( 'New Category Name' ) ),
366 'separate_items_with_commas' => array( __( 'Separate tags with commas' ), null ),
367 'add_or_remove_items' => array( __( 'Add or remove tags' ), null ),
368 'choose_from_most_used' => array( __( 'Choose from the most used tags' ), null ),
369 );
370
371 return _get_custom_object_labels( $tax, $nohier_vs_hier_defaults );
372}
373
374/**
375 * Add an already registered taxonomy to an object type.
376 *
377 * @package WordPress
378 * @subpackage Taxonomy
379 * @since 3.0.0
380 * @uses $wp_taxonomies Modifies taxonomy object
381 *
382 * @param string $taxonomy Name of taxonomy object
383 * @param array|string $object_type Name of the object type
384 * @return bool True if successful, false if not
385 */
386function register_taxonomy_for_object_type( $taxonomy, $object_type) {
387 global $wp_taxonomies;
388
389 if ( !isset($wp_taxonomies[$taxonomy]) )
390 return false;
391
392 if ( ! get_post_type_object($object_type) )
393 return false;
394
395 $wp_taxonomies[$taxonomy]->object_type[] = $object_type;
396
397 return true;
398}
399
400//
401// Term API
402//
403
404/**
405 * Retrieve object_ids of valid taxonomy and term.
406 *
407 * The strings of $taxonomies must exist before this function will continue. On
408 * failure of finding a valid taxonomy, it will return an WP_Error class, kind
409 * of like Exceptions in PHP 5, except you can't catch them. Even so, you can
410 * still test for the WP_Error class and get the error message.
411 *
412 * The $terms aren't checked the same as $taxonomies, but still need to exist
413 * for $object_ids to be returned.
414 *
415 * It is possible to change the order that object_ids is returned by either
416 * using PHP sort family functions or using the database by using $args with
417 * either ASC or DESC array. The value should be in the key named 'order'.
418 *
419 * @package WordPress
420 * @subpackage Taxonomy
421 * @since 2.3.0
422 *
423 * @uses $wpdb
424 * @uses wp_parse_args() Creates an array from string $args.
425 *
426 * @param int|array $term_ids Term id or array of term ids of terms that will be used
427 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
428 * @param array|string $args Change the order of the object_ids, either ASC or DESC
429 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success
430 * the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
431 */
432function get_objects_in_term( $term_ids, $taxonomies, $args = array() ) {
433 global $wpdb;
434
435 if ( ! is_array( $term_ids ) )
436 $term_ids = array( $term_ids );
437
438 if ( ! is_array( $taxonomies ) )
439 $taxonomies = array( $taxonomies );
440
441 foreach ( (array) $taxonomies as $taxonomy ) {
442 if ( ! taxonomy_exists( $taxonomy ) )
443 return new WP_Error( 'invalid_taxonomy', __( 'Invalid Taxonomy' ) );
444 }
445
446 $defaults = array( 'order' => 'ASC' );
447 $args = wp_parse_args( $args, $defaults );
448 extract( $args, EXTR_SKIP );//Possible Control Flow
449
450 $order = ( 'desc' == strtolower( $order ) ) ? 'DESC' : 'ASC';
451
452 $term_ids = array_map('intval', $term_ids );
453
454 $taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
455 $term_ids = "'" . implode( "', '", $term_ids ) . "'";
456
457 $object_ids = $wpdb->get_col("SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tt.term_id IN ($term_ids) ORDER BY tr.object_id $order");
458
459 if ( ! $object_ids )
460 return array();
461
462 return $object_ids;
463}
464
465/**
466 * Get all Term data from database by Term ID.
467 *
468 * The usage of the get_term function is to apply filters to a term object. It
469 * is possible to get a term object from the database before applying the
470 * filters.
471 *
472 * $term ID must be part of $taxonomy, to get from the database. Failure, might
473 * be able to be captured by the hooks. Failure would be the same value as $wpdb
474 * returns for the get_row method.
475 *
476 * There are two hooks, one is specifically for each term, named 'get_term', and
477 * the second is for the taxonomy name, 'term_$taxonomy'. Both hooks gets the
478 * term object, and the taxonomy name as parameters. Both hooks are expected to
479 * return a Term object.
480 *
481 * 'get_term' hook - Takes two parameters the term Object and the taxonomy name.
482 * Must return term object. Used in get_term() as a catch-all filter for every
483 * $term.
484 *
485 * 'get_$taxonomy' hook - Takes two parameters the term Object and the taxonomy
486 * name. Must return term object. $taxonomy will be the taxonomy name, so for
487 * example, if 'category', it would be 'get_category' as the filter name. Useful
488 * for custom taxonomies or plugging into default taxonomies.
489 *
490 * @package WordPress
491 * @subpackage Taxonomy
492 * @since 2.3.0
493 *
494 * @uses $wpdb
495 * @uses sanitize_term() Cleanses the term based on $filter context before returning.
496 * @see sanitize_term_field() The $context param lists the available values for get_term_by() $filter param.
497 *
498 * @param int|object $term If integer, will get from database. If object will apply filters and return $term.
499 * @param string $taxonomy Taxonomy name that $term is part of.
500 * @param string $output Constant OBJECT, ARRAY_A, or ARRAY_N
501 * @param string $filter Optional, default is raw or no WordPress defined filter will applied.
502 * @return mixed|null|WP_Error Term Row from database. Will return null if $term is empty. If taxonomy does not
503 * exist then WP_Error will be returned.
504 */
505function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
506 global $wpdb;
507 $null = null;
508
509 if ( empty($term) ) {
510 $error = new WP_Error('invalid_term', __('Empty Term'));
511 return $error;
512 }
513
514 if ( ! taxonomy_exists($taxonomy) ) {
515 $error = new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
516 return $error;
517 }
518
519 if ( is_object($term) && empty($term->filter) ) {
520 wp_cache_add($term->term_id, $term, $taxonomy);
521 $_term = $term;
522 } else {
523 if ( is_object($term) )
524 $term = $term->term_id;
525 $term = (int) $term;
526 if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
527 $_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term) );
528 if ( ! $_term )
529 return $null;
530 wp_cache_add($term, $_term, $taxonomy);
531 }
532 }
533
534 $_term = apply_filters('get_term', $_term, $taxonomy);
535 $_term = apply_filters("get_$taxonomy", $_term, $taxonomy);
536 $_term = sanitize_term($_term, $taxonomy, $filter);
537
538 if ( $output == OBJECT ) {
539 return $_term;
540 } elseif ( $output == ARRAY_A ) {
541 $__term = get_object_vars($_term);
542 return $__term;
543 } elseif ( $output == ARRAY_N ) {
544 $__term = array_values(get_object_vars($_term));
545 return $__term;
546 } else {
547 return $_term;
548 }
549}
550
551/**
552 * Get all Term data from database by Term field and data.
553 *
554 * Warning: $value is not escaped for 'name' $field. You must do it yourself, if
555 * required.
556 *
557 * The default $field is 'id', therefore it is possible to also use null for
558 * field, but not recommended that you do so.
559 *
560 * If $value does not exist, the return value will be false. If $taxonomy exists
561 * and $field and $value combinations exist, the Term will be returned.
562 *
563 * @package WordPress
564 * @subpackage Taxonomy
565 * @since 2.3.0
566 *
567 * @uses $wpdb
568 * @uses sanitize_term() Cleanses the term based on $filter context before returning.
569 * @see sanitize_term_field() The $context param lists the available values for get_term_by() $filter param.
570 *
571 * @param string $field Either 'slug', 'name', or 'id'
572 * @param string|int $value Search for this term value
573 * @param string $taxonomy Taxonomy Name
574 * @param string $output Constant OBJECT, ARRAY_A, or ARRAY_N
575 * @param string $filter Optional, default is raw or no WordPress defined filter will applied.
576 * @return mixed Term Row from database. Will return false if $taxonomy does not exist or $term was not found.
577 */
578function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw') {
579 global $wpdb;
580
581 if ( ! taxonomy_exists($taxonomy) )
582 return false;
583
584 if ( 'slug' == $field ) {
585 $field = 't.slug';
586 $value = sanitize_title($value);
587 if ( empty($value) )
588 return false;
589 } else if ( 'name' == $field ) {
590 // Assume already escaped
591 $value = stripslashes($value);
592 $field = 't.name';
593 } else {
594 return get_term( (int) $value, $taxonomy, $output, $filter);
595 }
596
597 $term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND $field = %s LIMIT 1", $taxonomy, $value) );
598 if ( !$term )
599 return false;
600
601 wp_cache_add($term->term_id, $term, $taxonomy);
602
603 $term = apply_filters('get_term', $term, $taxonomy);
604 $term = apply_filters("get_$taxonomy", $term, $taxonomy);
605 $term = sanitize_term($term, $taxonomy, $filter);
606
607 if ( $output == OBJECT ) {
608 return $term;
609 } elseif ( $output == ARRAY_A ) {
610 return get_object_vars($term);
611 } elseif ( $output == ARRAY_N ) {
612 return array_values(get_object_vars($term));
613 } else {
614 return $term;
615 }
616}
617
618/**
619 * Merge all term children into a single array of their IDs.
620 *
621 * This recursive function will merge all of the children of $term into the same
622 * array of term IDs. Only useful for taxonomies which are hierarchical.
623 *
624 * Will return an empty array if $term does not exist in $taxonomy.
625 *
626 * @package WordPress
627 * @subpackage Taxonomy
628 * @since 2.3.0
629 *
630 * @uses $wpdb
631 * @uses _get_term_hierarchy()
632 * @uses get_term_children() Used to get the children of both $taxonomy and the parent $term
633 *
634 * @param string $term ID of Term to get children
635 * @param string $taxonomy Taxonomy Name
636 * @return array|WP_Error List of Term Objects. WP_Error returned if $taxonomy does not exist
637 */
638function get_term_children( $term_id, $taxonomy ) {
639 if ( ! taxonomy_exists($taxonomy) )
640 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
641
642 $term_id = intval( $term_id );
643
644 $terms = _get_term_hierarchy($taxonomy);
645
646 if ( ! isset($terms[$term_id]) )
647 return array();
648
649 $children = $terms[$term_id];
650
651 foreach ( (array) $terms[$term_id] as $child ) {
652 if ( isset($terms[$child]) )
653 $children = array_merge($children, get_term_children($child, $taxonomy));
654 }
655
656 return $children;
657}
658
659/**
660 * Get sanitized Term field.
661 *
662 * Does checks for $term, based on the $taxonomy. The function is for contextual
663 * reasons and for simplicity of usage. See sanitize_term_field() for more
664 * information.
665 *
666 * @package WordPress
667 * @subpackage Taxonomy
668 * @since 2.3.0
669 *
670 * @uses sanitize_term_field() Passes the return value in sanitize_term_field on success.
671 *
672 * @param string $field Term field to fetch
673 * @param int $term Term ID
674 * @param string $taxonomy Taxonomy Name
675 * @param string $context Optional, default is display. Look at sanitize_term_field() for available options.
676 * @return mixed Will return an empty string if $term is not an object or if $field is not set in $term.
677 */
678function get_term_field( $field, $term, $taxonomy, $context = 'display' ) {
679 $term = (int) $term;
680 $term = get_term( $term, $taxonomy );
681 if ( is_wp_error($term) )
682 return $term;
683
684 if ( !is_object($term) )
685 return '';
686
687 if ( !isset($term->$field) )
688 return '';
689
690 return sanitize_term_field($field, $term->$field, $term->term_id, $taxonomy, $context);
691}
692
693/**
694 * Sanitizes Term for editing.
695 *
696 * Return value is sanitize_term() and usage is for sanitizing the term for
697 * editing. Function is for contextual and simplicity.
698 *
699 * @package WordPress
700 * @subpackage Taxonomy
701 * @since 2.3.0
702 *
703 * @uses sanitize_term() Passes the return value on success
704 *
705 * @param int|object $id Term ID or Object
706 * @param string $taxonomy Taxonomy Name
707 * @return mixed|null|WP_Error Will return empty string if $term is not an object.
708 */
709function get_term_to_edit( $id, $taxonomy ) {
710 $term = get_term( $id, $taxonomy );
711
712 if ( is_wp_error($term) )
713 return $term;
714
715 if ( !is_object($term) )
716 return '';
717
718 return sanitize_term($term, $taxonomy, 'edit');
719}
720
721/**
722 * Retrieve the terms in a given taxonomy or list of taxonomies.
723 *
724 * You can fully inject any customizations to the query before it is sent, as
725 * well as control the output with a filter.
726 *
727 * The 'get_terms' filter will be called when the cache has the term and will
728 * pass the found term along with the array of $taxonomies and array of $args.
729 * This filter is also called before the array of terms is passed and will pass
730 * the array of terms, along with the $taxonomies and $args.
731 *
732 * The 'list_terms_exclusions' filter passes the compiled exclusions along with
733 * the $args.
734 *
735 * The 'get_terms_orderby' filter passes the ORDER BY clause for the query
736 * along with the $args array.
737 *
738 * The 'get_terms_fields' filter passes the fields for the SELECT query
739 * along with the $args array.
740 *
741 * The list of arguments that $args can contain, which will overwrite the defaults:
742 *
743 * orderby - Default is 'name'. Can be name, count, term_group, slug or nothing
744 * (will use term_id), Passing a custom value other than these will cause it to
745 * order based on the custom value.
746 *
747 * order - Default is ASC. Can use DESC.
748 *
749 * hide_empty - Default is true. Will not return empty terms, which means
750 * terms whose count is 0 according to the given taxonomy.
751 *
752 * exclude - Default is an empty array. An array, comma- or space-delimited string
753 * of term ids to exclude from the return array. If 'include' is non-empty,
754 * 'exclude' is ignored.
755 *
756 * exclude_tree - Default is an empty array. An array, comma- or space-delimited
757 * string of term ids to exclude from the return array, along with all of their
758 * descendant terms according to the primary taxonomy. If 'include' is non-empty,
759 * 'exclude_tree' is ignored.
760 *
761 * include - Default is an empty array. An array, comma- or space-delimited string
762 * of term ids to include in the return array.
763 *
764 * number - The maximum number of terms to return. Default is to return them all.
765 *
766 * offset - The number by which to offset the terms query.
767 *
768 * fields - Default is 'all', which returns an array of term objects.
769 * If 'fields' is 'ids' or 'names', returns an array of
770 * integers or strings, respectively.
771 *
772 * slug - Returns terms whose "slug" matches this value. Default is empty string.
773 *
774 * hierarchical - Whether to include terms that have non-empty descendants
775 * (even if 'hide_empty' is set to true).
776 *
777 * search - Returned terms' names will contain the value of 'search',
778 * case-insensitive. Default is an empty string.
779 *
780 * name__like - Returned terms' names will begin with the value of 'name__like',
781 * case-insensitive. Default is empty string.
782 *
783 * The argument 'pad_counts', if set to true will include the quantity of a term's
784 * children in the quantity of each term's "count" object variable.
785 *
786 * The 'get' argument, if set to 'all' instead of its default empty string,
787 * returns terms regardless of ancestry or whether the terms are empty.
788 *
789 * The 'child_of' argument, when used, should be set to the integer of a term ID. Its default
790 * is 0. If set to a non-zero value, all returned terms will be descendants
791 * of that term according to the given taxonomy. Hence 'child_of' is set to 0
792 * if more than one taxonomy is passed in $taxonomies, because multiple taxonomies
793 * make term ancestry ambiguous.
794 *
795 * The 'parent' argument, when used, should be set to the integer of a term ID. Its default is
796 * the empty string '', which has a different meaning from the integer 0.
797 * If set to an integer value, all returned terms will have as an immediate
798 * ancestor the term whose ID is specified by that integer according to the given taxonomy.
799 * The 'parent' argument is different from 'child_of' in that a term X is considered a 'parent'
800 * of term Y only if term X is the father of term Y, not its grandfather or great-grandfather, etc.
801 *
802 * @package WordPress
803 * @subpackage Taxonomy
804 * @since 2.3.0
805 *
806 * @uses $wpdb
807 * @uses wp_parse_args() Merges the defaults with those defined by $args and allows for strings.
808 *
809 * @param string|array Taxonomy name or list of Taxonomy names
810 * @param string|array $args The values of what to search for when returning terms
811 * @return array|WP_Error List of Term Objects and their children. Will return WP_Error, if any of $taxonomies do not exist.
812 */
813function &get_terms($taxonomies, $args = '') {
814 global $wpdb;
815 $empty_array = array();
816
817 $single_taxonomy = false;
818 if ( !is_array($taxonomies) ) {
819 $single_taxonomy = true;
820 $taxonomies = array($taxonomies);
821 }
822
823 foreach ( (array) $taxonomies as $taxonomy ) {
824 if ( ! taxonomy_exists($taxonomy) ) {
825 $error = & new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
826 return $error;
827 }
828 }
829
830 $in_taxonomies = "'" . implode("', '", $taxonomies) . "'";
831
832 $defaults = array('orderby' => 'name', 'order' => 'ASC',
833 'hide_empty' => true, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(),
834 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
835 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
836 'pad_counts' => false, 'offset' => '', 'search' => '');
837 $args = wp_parse_args( $args, $defaults );
838 $args['number'] = absint( $args['number'] );
839 $args['offset'] = absint( $args['offset'] );
840 if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) ||
841 '' !== $args['parent'] ) {
842 $args['child_of'] = 0;
843 $args['hierarchical'] = false;
844 $args['pad_counts'] = false;
845 }
846
847 if ( 'all' == $args['get'] ) {
848 $args['child_of'] = 0;
849 $args['hide_empty'] = 0;
850 $args['hierarchical'] = false;
851 $args['pad_counts'] = false;
852 }
853 extract($args, EXTR_SKIP);//Possible Control Flow
854
855 if ( $child_of ) {
856 $hierarchy = _get_term_hierarchy($taxonomies[0]);
857 if ( !isset($hierarchy[$child_of]) )
858 return $empty_array;
859 }
860
861 if ( $parent ) {
862 $hierarchy = _get_term_hierarchy($taxonomies[0]);
863 if ( !isset($hierarchy[$parent]) )
864 return $empty_array;
865 }
866
867 // $args can be whatever, only use the args defined in defaults to compute the key
868 $filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';
869 $key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
870 $last_changed = wp_cache_get('last_changed', 'terms');
871 if ( !$last_changed ) {
872 $last_changed = time();
873 wp_cache_set('last_changed', $last_changed, 'terms');
874 }
875 $cache_key = "get_terms:$key:$last_changed";
876 $cache = wp_cache_get( $cache_key, 'terms' );
877 if ( false !== $cache ) {
878 $cache = apply_filters('get_terms', $cache, $taxonomies, $args);
879 return $cache;
880 }
881
882 $_orderby = strtolower($orderby);
883 if ( 'count' == $_orderby )
884 $orderby = 'tt.count';
885 else if ( 'name' == $_orderby )
886 $orderby = 't.name';
887 else if ( 'slug' == $_orderby )
888 $orderby = 't.slug';
889 else if ( 'term_group' == $_orderby )
890 $orderby = 't.term_group';
891 else if ( 'none' == $_orderby )
892 $orderby = '';
893 elseif ( empty($_orderby) || 'id' == $_orderby )
894 $orderby = 't.term_id';
895
896 $orderby = apply_filters( 'get_terms_orderby', $orderby, $args );
897
898 if ( !empty($orderby) )
899 $orderby = "ORDER BY $orderby";
900 else
901 $order = '';
902
903 $where = '';
904 $inclusions = '';
905 if ( !empty($include) ) {
906 $exclude = '';
907 $exclude_tree = '';
908 $interms = wp_parse_id_list($include);
909 foreach ( $interms as $interm ) {
910 if ( empty($inclusions) )
911 $inclusions = ' AND ( t.term_id = ' . intval($interm) . ' ';
912 else
913 $inclusions .= ' OR t.term_id = ' . intval($interm) . ' ';
914 }
915 }
916
917 if ( !empty($inclusions) )
918 $inclusions .= ')';
919 $where .= $inclusions;
920
921 $exclusions = '';
922 if ( !empty( $exclude_tree ) ) {
923 $excluded_trunks = wp_parse_id_list($exclude_tree);
924 foreach ( $excluded_trunks as $extrunk ) {
925 $excluded_children = (array) get_terms($taxonomies[0], array('child_of' => intval($extrunk), 'fields' => 'ids'));
926 $excluded_children[] = $extrunk;
927 foreach( $excluded_children as $exterm ) {
928 if ( empty($exclusions) )
929 $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
930 else
931 $exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' ';
932 }
933 }
934 }
935
936 if ( !empty($exclude) ) {
937 $exterms = wp_parse_id_list($exclude);
938 foreach ( $exterms as $exterm ) {
939 if ( empty($exclusions) )
940 $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' ';
941 else
942 $exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' ';
943 }
944 }
945
946 if ( !empty($exclusions) )
947 $exclusions .= ')';
948 $exclusions = apply_filters('list_terms_exclusions', $exclusions, $args );
949 $where .= $exclusions;
950
951 if ( !empty($slug) ) {
952 $slug = sanitize_title($slug);
953 $where .= " AND t.slug = '$slug'";
954 }
955
956 if ( !empty($name__like) )
957 $where .= " AND t.name LIKE '{$name__like}%'";
958
959 if ( '' !== $parent ) {
960 $parent = (int) $parent;
961 $where .= " AND tt.parent = '$parent'";
962 }
963
964 if ( $hide_empty && !$hierarchical )
965 $where .= ' AND tt.count > 0';
966
967 // don't limit the query results when we have to descend the family tree
968 if ( ! empty($number) && ! $hierarchical && empty( $child_of ) && '' === $parent ) {
969 if ( $offset )
970 $limit = 'LIMIT ' . $offset . ',' . $number;
971 else
972 $limit = 'LIMIT ' . $number;
973 } else {
974 $limit = '';
975 }
976
977 if ( !empty($search) ) {
978 $search = like_escape($search);
979 $where .= " AND (t.name LIKE '%$search%')";
980 }
981
982 $selects = array();
983 switch ( $fields ) {
984 case 'all':
985 $selects = array('t.*', 'tt.*');
986 break;
987 case 'ids':
988 case 'id=>parent':
989 $selects = array('t.term_id', 'tt.parent', 'tt.count');
990 break;
991 case 'names':
992 $selects = array('t.term_id', 'tt.parent', 'tt.count', 't.name');
993 break;
994 case 'count':
995 $orderby = '';
996 $order = '';
997 $selects = array('COUNT(*)');
998 }
999 $select_this = implode(', ', apply_filters( 'get_terms_fields', $selects, $args ));
1000
/var/www/wordpress/wp-includes/template-loader.php
/var/www/wordpress/wp-includes/theme.php
/var/www/wordpress/wp-includes/update.php
/var/www/wordpress/wp-includes/user.php
/var/www/wordpress/wp-includes/vars.php
/var/www/wordpress/wp-includes/version.php
/var/www/wordpress/wp-includes/widgets.php
/var/www/wordpress/wp-includes/wp-db.php
/var/www/wordpress/wp-includes/wp-diff.php
/var/www/wordpress/index.php
/var/www/wordpress/wp-activate.php
/var/www/wordpress/wp-app.php
/var/www/wordpress/wp-atom.php
/var/www/wordpress/wp-blog-header.php
/var/www/wordpress/wp-comments-post.php
/var/www/wordpress/wp-commentsrss2.php
/var/www/wordpress/wp-config-sample.php
/var/www/wordpress/wp-cron.php
/var/www/wordpress/wp-feed.php
/var/www/wordpress/wp-links-opml.php
/var/www/wordpress/wp-load.php
/var/www/wordpress/wp-login.php
/var/www/wordpress/wp-mail.php
/var/www/wordpress/wp-pass.php
/var/www/wordpress/wp-rdf.php
/var/www/wordpress/wp-register.php
/var/www/wordpress/wp-rss.php
/var/www/wordpress/wp-rss2.php
/var/www/wordpress/wp-settings.php
/var/www/wordpress/wp-signup.php
/var/www/wordpress/wp-trackback.php
/var/www/wordpress/xmlrpc.php