/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
#CodeDescriptions
1<?php
2/**
3 * The plugin API is located in this file, which allows for creating actions
4 * and filters and hooking functions, and methods. The functions or methods will
5 * then be run when the action or filter is called.
6 *
7 * The API callback examples reference functions, but can be methods of classes.
8 * To hook methods, you'll need to pass an array one of two ways.
9 *
10 * Any of the syntaxes explained in the PHP documentation for the
11 * {@link http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback 'callback'}
12 * type are valid.
13 *
14 * Also see the {@link http://codex.wordpress.org/Plugin_API Plugin API} for
15 * more information and examples on how to use a lot of these functions.
16 *
17 * @package WordPress
18 * @subpackage Plugin
19 * @since 1.5
20 */
21
22/**
23 * Hooks a function or method to a specific filter action.
24 *
25 * Filters are the hooks that WordPress launches to modify text of various types
26 * before adding it to the database or sending it to the browser screen. Plugins
27 * can specify that one or more of its PHP functions is executed to
28 * modify specific types of text at these times, using the Filter API.
29 *
30 * To use the API, the following code should be used to bind a callback to the
31 * filter.
32 *
33 * <code>
34 * function example_hook($example) { echo $example; }//Cross Site Scripting
35 * add_filter('example_filter', 'example_hook');
36 * </code>
37 *
38 * In WordPress 1.5.1+, hooked functions can take extra arguments that are set
39 * when the matching do_action() or apply_filters() call is run. The
40 * $accepted_args allow for calling functions only when the number of args
41 * match. Hooked functions can take extra arguments that are set when the
42 * matching do_action() or apply_filters() call is run. For example, the action
43 * comment_id_not_found will pass any functions that hook onto it the ID of the
44 * requested comment.
45 *
46 * <strong>Note:</strong> the function will return true no matter if the
47 * function was hooked fails or not. There are no checks for whether the
48 * function exists beforehand and no checks to whether the <tt>$function_to_add
49 * is even a string. It is up to you to take care and this is done for
50 * optimization purposes, so everything is as quick as possible.
51 *
52 * @package WordPress
53 * @subpackage Plugin
54 * @since 0.71
55 * @global array $wp_filter Stores all of the filters added in the form of
56 * wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)']']
57 * @global array $merged_filters Tracks the tags that need to be merged for later. If the hook is added, it doesn't need to run through that process.
58 *
59 * @param string $tag The name of the filter to hook the $function_to_add to.
60 * @param callback $function_to_add The name of the function to be called when the filter is applied.
61 * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
62 * @param int $accepted_args optional. The number of arguments the function accept (default 1).
63 * @return boolean true
64 */
65function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
66 global $wp_filter, $merged_filters;
67
68 $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority);
69 $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
70 unset( $merged_filters[ $tag ] );
71 return true;
72}
73
74/**
75 * Check if any filter has been registered for a hook.
76 *
77 * @package WordPress
78 * @subpackage Plugin
79 * @since 2.5
80 * @global array $wp_filter Stores all of the filters
81 *
82 * @param string $tag The name of the filter hook.
83 * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached.
84 * @return int|boolean Optionally returns the priority on that hook for the specified function.
85 */
86function has_filter($tag, $function_to_check = false) {
87 global $wp_filter;
88
89 $has = !empty($wp_filter[$tag]);
90 if ( false === $function_to_check || false == $has )
91 return $has;
92
93 if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false) )
94 return false;
95
96 foreach ( (array) array_keys($wp_filter[$tag]) as $priority ) {
97 if ( isset($wp_filter[$tag][$priority][$idx]) )
98 return $priority;
99 }
100
101 return false;
102}
103
104/**
105 * Call the functions added to a filter hook.
106 *
107 * The callback functions attached to filter hook $tag are invoked by calling
108 * this function. This function can be used to create a new filter hook by
109 * simply calling this function with the name of the new hook specified using
110 * the $tag parameter.
111 *
112 * The function allows for additional arguments to be added and passed to hooks.
113 * <code>
114 * function example_hook($string, $arg1, $arg2)
115 * {
116 * //Do stuff
117 * return $string;
118 * }
119 * $value = apply_filters('example_filter', 'filter me', 'arg1', 'arg2');
120 * </code>
121 *
122 * @package WordPress
123 * @subpackage Plugin
124 * @since 0.71
125 * @global array $wp_filter Stores all of the filters
126 * @global array $merged_filters Merges the filter hooks using this function.
127 * @global array $wp_current_filter stores the list of current filters with the current one last
128 *
129 * @param string $tag The name of the filter hook.
130 * @param mixed $value The value on which the filters hooked to <tt>$tag</tt> are applied on.
131 * @param mixed $var,... Additional variables passed to the functions hooked to <tt>$tag</tt>.
132 * @return mixed The filtered value after all hooked functions are applied to it.
133 */
134function apply_filters($tag, $value) {
135 global $wp_filter, $merged_filters, $wp_current_filter;
136
137 $args = array();
138 $wp_current_filter[] = $tag;
139
140 // Do 'all' actions first
141 if ( isset($wp_filter['all']) ) {
142 $args = func_get_args();
143 _wp_call_all_hook($args);
144 }
145
146 if ( !isset($wp_filter[$tag]) ) {
147 array_pop($wp_current_filter);
148 return $value;
149 }
150
151 // Sort
152 if ( !isset( $merged_filters[ $tag ] ) ) {
153 ksort($wp_filter[$tag]);
154 $merged_filters[ $tag ] = true;
155 }
156
157 reset( $wp_filter[ $tag ] );
158
159 if ( empty($args) )
160 $args = func_get_args();
161
162 do {
163 foreach( (array) current($wp_filter[$tag]) as $the_ )
164 if ( !is_null($the_['function']) ){
165 $args[1] = $value;
166 $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
167 }
168
169 } while ( next($wp_filter[$tag]) !== false );
170
171 array_pop( $wp_current_filter );
172
173 return $value;
174}
175
176/**
177 * Execute functions hooked on a specific filter hook, specifying arguments in an array.
178 *
179 * @see apply_filters() This function is identical, but the arguments passed to the
180 * functions hooked to <tt>$tag</tt> are supplied using an array.
181 *
182 * @package WordPress
183 * @subpackage Plugin
184 * @since 3.0.0
185 * @global array $wp_filter Stores all of the filters
186 * @global array $merged_filters Merges the filter hooks using this function.
187 * @global array $wp_current_filter stores the list of current filters with the current one last
188 *
189 * @param string $tag The name of the filter hook.
190 * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
191 * @return mixed The filtered value after all hooked functions are applied to it.
192 */
193function apply_filters_ref_array($tag, $args) {
194 global $wp_filter, $merged_filters, $wp_current_filter;
195
196 $wp_current_filter[] = $tag;
197
198 // Do 'all' actions first
199 if ( isset($wp_filter['all']) ) {
200 $all_args = func_get_args();
201 _wp_call_all_hook($all_args);
202 }
203
204 if ( !isset($wp_filter[$tag]) ) {
205 array_pop($wp_current_filter);
206 return $args[0];
207 }
208
209 // Sort
210 if ( !isset( $merged_filters[ $tag ] ) ) {
211 ksort($wp_filter[$tag]);
212 $merged_filters[ $tag ] = true;
213 }
214
215 reset( $wp_filter[ $tag ] );
216
217 do {
218 foreach( (array) current($wp_filter[$tag]) as $the_ )
219 if ( !is_null($the_['function']) )
220 $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
221
222 } while ( next($wp_filter[$tag]) !== false );
223
224 array_pop( $wp_current_filter );
225
226 return $args[0];
227}
228
229/**
230 * Removes a function from a specified filter hook.
231 *
232 * This function removes a function attached to a specified filter hook. This
233 * method can be used to remove default functions attached to a specific filter
234 * hook and possibly replace them with a substitute.
235 *
236 * To remove a hook, the $function_to_remove and $priority arguments must match
237 * when the hook was added. This goes for both filters and actions. No warning
238 * will be given on removal failure.
239 *
240 * @package WordPress
241 * @subpackage Plugin
242 * @since 1.2
243 *
244 * @param string $tag The filter hook to which the function to be removed is hooked.
245 * @param callback $function_to_remove The name of the function which should be removed.
246 * @param int $priority optional. The priority of the function (default: 10).
247 * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).
248 * @return boolean Whether the function existed before it was removed.
249 */
250function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
251 $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority);
252
253 $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
254
255 if ( true === $r) {
256 unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
257 if ( empty($GLOBALS['wp_filter'][$tag][$priority]) )
258 unset($GLOBALS['wp_filter'][$tag][$priority]);
259 unset($GLOBALS['merged_filters'][$tag]);
260 }
261
262 return $r;
263}
264
265/**
266 * Remove all of the hooks from a filter.
267 *
268 * @since 2.7
269 *
270 * @param string $tag The filter to remove hooks from.
271 * @param int $priority The priority number to remove.
272 * @return bool True when finished.
273 */
274function remove_all_filters($tag, $priority = false) {
275 global $wp_filter, $merged_filters;
276
277 if( isset($wp_filter[$tag]) ) {
278 if( false !== $priority && isset($wp_filter[$tag][$priority]) )
279 unset($wp_filter[$tag][$priority]);
280 else
281 unset($wp_filter[$tag]);
282 }
283
284 if( isset($merged_filters[$tag]) )
285 unset($merged_filters[$tag]);
286
287 return true;
288}
289
290/**
291 * Retrieve the name of the current filter or action.
292 *
293 * @package WordPress
294 * @subpackage Plugin
295 * @since 2.5
296 *
297 * @return string Hook name of the current filter or action.
298 */
299function current_filter() {
300 global $wp_current_filter;
301 return end( $wp_current_filter );
302}
303
304
305/**
306 * Hooks a function on to a specific action.
307 *
308 * Actions are the hooks that the WordPress core launches at specific points
309 * during execution, or when specific events occur. Plugins can specify that
310 * one or more of its PHP functions are executed at these points, using the
311 * Action API.
312 *
313 * @uses add_filter() Adds an action. Parameter list and functionality are the same.
314 *
315 * @package WordPress
316 * @subpackage Plugin
317 * @since 1.2
318 *
319 * @param string $tag The name of the action to which the $function_to_add is hooked.
320 * @param callback $function_to_add The name of the function you wish to be called.
321 * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
322 * @param int $accepted_args optional. The number of arguments the function accept (default 1).
323 */
324function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
325 return add_filter($tag, $function_to_add, $priority, $accepted_args);
326}
327
328
329/**
330 * Execute functions hooked on a specific action hook.
331 *
332 * This function invokes all functions attached to action hook $tag. It is
333 * possible to create new action hooks by simply calling this function,
334 * specifying the name of the new hook using the <tt>$tag</tt> parameter.
335 *
336 * You can pass extra arguments to the hooks, much like you can with
337 * apply_filters().
338 *
339 * @see apply_filters() This function works similar with the exception that
340 * nothing is returned and only the functions or methods are called.
341 *
342 * @package WordPress
343 * @subpackage Plugin
344 * @since 1.2
345 * @global array $wp_filter Stores all of the filters
346 * @global array $wp_actions Increments the amount of times action was triggered.
347 *
348 * @param string $tag The name of the action to be executed.
349 * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action.
350 * @return null Will return null if $tag does not exist in $wp_filter array
351 */
352function do_action($tag, $arg = '') {
353 global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
354
355 if ( ! isset($wp_actions) )
356 $wp_actions = array();
357
358 if ( ! isset($wp_actions[$tag]) )
359 $wp_actions[$tag] = 1;
360 else
361 ++$wp_actions[$tag];
362
363 $wp_current_filter[] = $tag;
364
365 // Do 'all' actions first
366 if ( isset($wp_filter['all']) ) {
367 $all_args = func_get_args();
368 _wp_call_all_hook($all_args);
369 }
370
371 if ( !isset($wp_filter[$tag]) ) {
372 array_pop($wp_current_filter);
373 return;
374 }
375
376 $args = array();
377 if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
378 $args[] =& $arg[0];
379 else
380 $args[] = $arg;
381 for ( $a = 2; $a < func_num_args(); $a++ )
382 $args[] = func_get_arg($a);
383
384 // Sort
385 if ( !isset( $merged_filters[ $tag ] ) ) {
386 ksort($wp_filter[$tag]);
387 $merged_filters[ $tag ] = true;
388 }
389
390 reset( $wp_filter[ $tag ] );
391
392 do {
393 foreach ( (array) current($wp_filter[$tag]) as $the_ )
394 if ( !is_null($the_['function']) )
395 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
396
397 } while ( next($wp_filter[$tag]) !== false );
398
399 array_pop($wp_current_filter);
400}
401
402/**
403 * Retrieve the number times an action is fired.
404 *
405 * @package WordPress
406 * @subpackage Plugin
407 * @since 2.1
408 * @global array $wp_actions Increments the amount of times action was triggered.
409 *
410 * @param string $tag The name of the action hook.
411 * @return int The number of times action hook <tt>$tag</tt> is fired
412 */
413function did_action($tag) {
414 global $wp_actions;
415
416 if ( ! isset( $wp_actions ) || ! isset( $wp_actions[$tag] ) )
417 return 0;
418
419 return $wp_actions[$tag];
420}
421
422/**
423 * Execute functions hooked on a specific action hook, specifying arguments in an array.
424 *
425 * @see do_action() This function is identical, but the arguments passed to the
426 * functions hooked to <tt>$tag</tt> are supplied using an array.
427 *
428 * @package WordPress
429 * @subpackage Plugin
430 * @since 2.1
431 * @global array $wp_filter Stores all of the filters
432 * @global array $wp_actions Increments the amount of times action was triggered.
433 *
434 * @param string $tag The name of the action to be executed.
435 * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
436 * @return null Will return null if $tag does not exist in $wp_filter array
437 */
438function do_action_ref_array($tag, $args) {
439 global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
440
441 if ( ! isset($wp_actions) )
442 $wp_actions = array();
443
444 if ( ! isset($wp_actions[$tag]) )
445 $wp_actions[$tag] = 1;
446 else
447 ++$wp_actions[$tag];
448
449 $wp_current_filter[] = $tag;
450
451 // Do 'all' actions first
452 if ( isset($wp_filter['all']) ) {
453 $all_args = func_get_args();
454 _wp_call_all_hook($all_args);
455 }
456
457 if ( !isset($wp_filter[$tag]) ) {
458 array_pop($wp_current_filter);
459 return;
460 }
461
462 // Sort
463 if ( !isset( $merged_filters[ $tag ] ) ) {
464 ksort($wp_filter[$tag]);
465 $merged_filters[ $tag ] = true;
466 }
467
468 reset( $wp_filter[ $tag ] );
469
470 do {
471 foreach( (array) current($wp_filter[$tag]) as $the_ )
472 if ( !is_null($the_['function']) )
473 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
474
475 } while ( next($wp_filter[$tag]) !== false );
476
477 array_pop($wp_current_filter);
478}
479
480/**
481 * Check if any action has been registered for a hook.
482 *
483 * @package WordPress
484 * @subpackage Plugin
485 * @since 2.5
486 * @see has_filter() has_action() is an alias of has_filter().
487 *
488 * @param string $tag The name of the action hook.
489 * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached.
490 * @return int|boolean Optionally returns the priority on that hook for the specified function.
491 */
492function has_action($tag, $function_to_check = false) {
493 return has_filter($tag, $function_to_check);
494}
495
496/**
497 * Removes a function from a specified action hook.
498 *
499 * This function removes a function attached to a specified action hook. This
500 * method can be used to remove default functions attached to a specific filter
501 * hook and possibly replace them with a substitute.
502 *
503 * @package WordPress
504 * @subpackage Plugin
505 * @since 1.2
506 *
507 * @param string $tag The action hook to which the function to be removed is hooked.
508 * @param callback $function_to_remove The name of the function which should be removed.
509 * @param int $priority optional The priority of the function (default: 10).
510 * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).
511 * @return boolean Whether the function is removed.
512 */
513function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
514 return remove_filter($tag, $function_to_remove, $priority, $accepted_args);
515}
516
517/**
518 * Remove all of the hooks from an action.
519 *
520 * @since 2.7
521 *
522 * @param string $tag The action to remove hooks from.
523 * @param int $priority The priority number to remove them from.
524 * @return bool True when finished.
525 */
526function remove_all_actions($tag, $priority = false) {
527 return remove_all_filters($tag, $priority);
528}
529
530//
531// Functions for handling plugins.
532//
533
534/**
535 * Gets the basename of a plugin.
536 *
537 * This method extracts the name of a plugin from its filename.
538 *
539 * @package WordPress
540 * @subpackage Plugin
541 * @since 1.5
542 *
543 * @access private
544 *
545 * @param string $file The filename of plugin.
546 * @return string The name of a plugin.
547 * @uses WP_PLUGIN_DIR
548 */
549function plugin_basename($file) {
550 $file = str_replace('\\','/',$file); // sanitize for Win32 installs
551 $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
552 $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
553 $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
554 $mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs
555 $mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
556 $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
557 $file = trim($file, '/');
558 return $file;
559}
560
561/**
562 * Gets the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in
563 * @package WordPress
564 * @subpackage Plugin
565 * @since 2.8
566 *
567 * @param string $file The filename of the plugin (__FILE__)
568 * @return string the filesystem path of the directory that contains the plugin
569 */
570function plugin_dir_path( $file ) {
571 return trailingslashit( dirname( $file ) );
572}
573
574/**
575 * Gets the URL directory path (with trailing slash) for the plugin __FILE__ passed in
576 * @package WordPress
577 * @subpackage Plugin
578 * @since 2.8
579 *
580 * @param string $file The filename of the plugin (__FILE__)
581 * @return string the URL path of the directory that contains the plugin
582 */
583function plugin_dir_url( $file ) {
584 return trailingslashit( plugins_url( '', $file ) );
585}
586
587/**
588 * Set the activation hook for a plugin.
589 *
590 * When a plugin is activated, the action 'activate_PLUGINNAME' hook is
591 * activated. In the name of this hook, PLUGINNAME is replaced with the name of
592 * the plugin, including the optional subdirectory. For example, when the plugin
593 * is located in wp-content/plugin/sampleplugin/sample.php, then the name of
594 * this hook will become 'activate_sampleplugin/sample.php'. When the plugin
595 * consists of only one file and is (as by default) located at
596 * wp-content/plugin/sample.php the name of this hook will be
597 * 'activate_sample.php'.
598 *
599 * @package WordPress
600 * @subpackage Plugin
601 * @since 2.0
602 *
603 * @param string $file The filename of the plugin including the path.
604 * @param callback $function the function hooked to the 'activate_PLUGIN' action.
605 */
606function register_activation_hook($file, $function) {
607 $file = plugin_basename($file);
608 add_action('activate_' . $file, $function);//Arbitrary file disclosing
609}
610
611/**
612 * Set the deactivation hook for a plugin.
613 *
614 * When a plugin is deactivated, the action 'deactivate_PLUGINNAME' hook is
615 * deactivated. In the name of this hook, PLUGINNAME is replaced with the name
616 * of the plugin, including the optional subdirectory. For example, when the
617 * plugin is located in wp-content/plugin/sampleplugin/sample.php, then
618 * the name of this hook will become 'activate_sampleplugin/sample.php'.
619 *
620 * When the plugin consists of only one file and is (as by default) located at
621 * wp-content/plugin/sample.php the name of this hook will be
622 * 'activate_sample.php'.
623 *
624 * @package WordPress
625 * @subpackage Plugin
626 * @since 2.0
627 *
628 * @param string $file The filename of the plugin including the path.
629 * @param callback $function the function hooked to the 'activate_PLUGIN' action.
630 */
631function register_deactivation_hook($file, $function) {
632 $file = plugin_basename($file);
633 add_action('deactivate_' . $file, $function);//Arbitrary file disclosing
634}
635
636/**
637 * Set the uninstallation hook for a plugin.
638 *
639 * Registers the uninstall hook that will be called when the user clicks on the
640 * uninstall link that calls for the plugin to uninstall itself. The link won't
641 * be active unless the plugin hooks into the action.
642 *
643 * The plugin should not run arbitrary code outside of functions, when
644 * registering the uninstall hook. In order to run using the hook, the plugin
645 * will have to be included, which means that any code laying outside of a
646 * function will be run during the uninstall process. The plugin should not
647 * hinder the uninstall process.
648 *
649 * If the plugin can not be written without running code within the plugin, then
650 * the plugin should create a file named 'uninstall.php' in the base plugin
651 * folder. This file will be called, if it exists, during the uninstall process
652 * bypassing the uninstall hook. The plugin, when using the 'uninstall.php'
653 * should always check for the 'WP_UNINSTALL_PLUGIN' constant, before
654 * executing.
655 *
656 * @since 2.7
657 *
658 * @param string $file
659 * @param callback $callback The callback to run when the hook is called.
660 */
661function register_uninstall_hook($file, $callback) {
662 // The option should not be autoloaded, because it is not needed in most
663 // cases. Emphasis should be put on using the 'uninstall.php' way of
664 // uninstalling the plugin.
665 $uninstallable_plugins = (array) get_option('uninstall_plugins');
666 $uninstallable_plugins[plugin_basename($file)] = $callback;//Arbitrary file disclosing
667 update_option('uninstall_plugins', $uninstallable_plugins);
668}
669
670/**
671 * Calls the 'all' hook, which will process the functions hooked into it.
672 *
673 * The 'all' hook passes all of the arguments or parameters that were used for
674 * the hook, which this function was called for.
675 *
676 * This function is used internally for apply_filters(), do_action(), and
677 * do_action_ref_array() and is not meant to be used from outside those
678 * functions. This function does not check for the existence of the all hook, so
679 * it will fail unless the all hook exists prior to this function call.
680 *
681 * @package WordPress
682 * @subpackage Plugin
683 * @since 2.5
684 * @access private
685 *
686 * @uses $wp_filter Used to process all of the functions in the 'all' hook
687 *
688 * @param array $args The collected parameters from the hook that was called.
689 * @param string $hook Optional. The hook name that was used to call the 'all' hook.
690 */
691function _wp_call_all_hook($args) {
692 global $wp_filter;
693
694 reset( $wp_filter['all'] );
695 do {
696 foreach( (array) current($wp_filter['all']) as $the_ )
697 if ( !is_null($the_['function']) )
698 call_user_func_array($the_['function'], $args);
699
700 } while ( next($wp_filter['all']) !== false );
701}
702
703/**
704 * Build Unique ID for storage and retrieval.
705 *
706 * The old way to serialize the callback caused issues and this function is the
707 * solution. It works by checking for objects and creating an a new property in
708 * the class to keep track of the object and new objects of the same class that
709 * need to be added.
710 *
711 * It also allows for the removal of actions and filters for objects after they
712 * change class properties. It is possible to include the property $wp_filter_id
713 * in your class and set it to "null" or a number to bypass the workaround.
714 * However this will prevent you from adding new classes and any new classes
715 * will overwrite the previous hook by the same class.
716 *
717 * Functions and static method callbacks are just returned as strings and
718 * shouldn't have any speed penalty.
719 *
720 * @package WordPress
721 * @subpackage Plugin
722 * @access private
723 * @since 2.2.3
724 * @link http://trac.wordpress.org/ticket/3875
725 *
726 * @global array $wp_filter Storage for all of the filters and actions
727 * @param string $tag Used in counting how many hooks were applied
728 * @param callback $function Used for creating unique id
729 * @param int|bool $priority Used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise.
730 * @param string $type filter or action
731 * @return string|bool Unique ID for usage as array key or false if $priority === false and $function is an object reference, and it does not already have a uniqe id.
732 */
733function _wp_filter_build_unique_id($tag, $function, $priority) {
734 global $wp_filter;
735 static $filter_id_count = 0;
736
737 if ( is_string($function) )
738 return $function;
739
740 if ( is_object($function) ) {
741 // Closures are currently implemented as objects
742 $function = array( $function, '' );
743 } else {
744 $function = (array) $function;
745 }
746
747 if (is_object($function[0]) ) {
748 // Object Class Calling
749 if ( function_exists('spl_object_hash') ) {
750 return spl_object_hash($function[0]) . $function[1];
751 } else {
752 $obj_idx = get_class($function[0]).$function[1];
753 if ( !isset($function[0]->wp_filter_id) ) {
754 if ( false === $priority )
755 return false;
756 $obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : $filter_id_count;
757 $function[0]->wp_filter_id = $filter_id_count;
758 ++$filter_id_count;
759 } else {
760 $obj_idx .= $function[0]->wp_filter_id;
761 }
762
763 return $obj_idx;
764 }
765 } else if ( is_string($function[0]) ) {
766 // Static Calling
767 return $function[0].$function[1];
768 }
769}
770
771?>
772
/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
/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