-
+ 18A811AD2EDE6111E47CC340A0DC31316E9BE3260B15C0C6EEF1BED9DC3884F30EE01C93C39894FD0B6020101EA6B6F2E1797A96634DD914C4DEFAD17B1B84F3
mp-wp/wp-includes/plugin.php
(0 . 0)(1 . 674)
139256 <?php
139257 /**
139258 * The plugin API is located in this file, which allows for creating actions
139259 * and filters and hooking functions, and methods. The functions or methods will
139260 * then be run when the action or filter is called.
139261 *
139262 * The API callback examples reference functions, but can be methods of classes.
139263 * To hook methods, you'll need to pass an array one of two ways.
139264 *
139265 * Any of the syntaxes explained in the PHP documentation for the
139266 * {@link http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback 'callback'}
139267 * type are valid.
139268 *
139269 * Also see the {@link http://codex.wordpress.org/Plugin_API Plugin API} for
139270 * more information and examples on how to use a lot of these functions.
139271 *
139272 * @package WordPress
139273 * @subpackage Plugin
139274 * @since 1.5
139275 */
139276
139277 /**
139278 * Hooks a function or method to a specific filter action.
139279 *
139280 * Filters are the hooks that WordPress launches to modify text of various types
139281 * before adding it to the database or sending it to the browser screen. Plugins
139282 * can specify that one or more of its PHP functions is executed to
139283 * modify specific types of text at these times, using the Filter API.
139284 *
139285 * To use the API, the following code should be used to bind a callback to the
139286 * filter.
139287 *
139288 * <code>
139289 * function example_hook($example) { echo $example; }
139290 * add_filter('example_filter', 'example_hook');
139291 * </code>
139292 *
139293 * In WordPress 1.5.1+, hooked functions can take extra arguments that are set
139294 * when the matching do_action() or apply_filters() call is run. The
139295 * $accepted_args allow for calling functions only when the number of args
139296 * match. Hooked functions can take extra arguments that are set when the
139297 * matching do_action() or apply_filters() call is run. For example, the action
139298 * comment_id_not_found will pass any functions that hook onto it the ID of the
139299 * requested comment.
139300 *
139301 * <strong>Note:</strong> the function will return true no matter if the
139302 * function was hooked fails or not. There are no checks for whether the
139303 * function exists beforehand and no checks to whether the <tt>$function_to_add
139304 * is even a string. It is up to you to take care and this is done for
139305 * optimization purposes, so everything is as quick as possible.
139306 *
139307 * @package WordPress
139308 * @subpackage Plugin
139309 * @since 0.71
139310 * @global array $wp_filter Stores all of the filters added in the form of
139311 * wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]']
139312 * @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.
139313 *
139314 * @param string $tag The name of the filter to hook the $function_to_add to.
139315 * @param callback $function_to_add The name of the function to be called when the filter is applied.
139316 * @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.
139317 * @param int $accepted_args optional. The number of arguments the function accept (default 1).
139318 * @return boolean true
139319 */
139320 function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
139321 global $wp_filter, $merged_filters;
139322
139323 $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority);
139324 $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
139325 unset( $merged_filters[ $tag ] );
139326 return true;
139327 }
139328
139329 /**
139330 * Check if any filter has been registered for a hook.
139331 *
139332 * @package WordPress
139333 * @subpackage Plugin
139334 * @since 2.5
139335 * @global array $wp_filter Stores all of the filters
139336 *
139337 * @param string $tag The name of the filter hook.
139338 * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached.
139339 * @return int|boolean Optionally returns the priority on that hook for the specified function.
139340 */
139341 function has_filter($tag, $function_to_check = false) {
139342 global $wp_filter;
139343
139344 $has = !empty($wp_filter[$tag]);
139345 if ( false === $function_to_check || false == $has )
139346 return $has;
139347
139348 if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false) )
139349 return false;
139350
139351 foreach ( (array) array_keys($wp_filter[$tag]) as $priority ) {
139352 if ( isset($wp_filter[$tag][$priority][$idx]) )
139353 return $priority;
139354 }
139355
139356 return false;
139357 }
139358
139359 /**
139360 * Call the functions added to a filter hook.
139361 *
139362 * The callback functions attached to filter hook $tag are invoked by calling
139363 * this function. This function can be used to create a new filter hook by
139364 * simply calling this function with the name of the new hook specified using
139365 * the $tag parameter.
139366 *
139367 * The function allows for additional arguments to be added and passed to hooks.
139368 * <code>
139369 * function example_hook($string, $arg1, $arg2)
139370 * {
139371 * //Do stuff
139372 * return $string;
139373 * }
139374 * $value = apply_filters('example_filter', 'filter me', 'arg1', 'arg2');
139375 * </code>
139376 *
139377 * @package WordPress
139378 * @subpackage Plugin
139379 * @since 0.71
139380 * @global array $wp_filter Stores all of the filters
139381 * @global array $merged_filters Merges the filter hooks using this function.
139382 * @global array $wp_current_filter stores the list of current filters with the current one last
139383 *
139384 * @param string $tag The name of the filter hook.
139385 * @param mixed $value The value on which the filters hooked to <tt>$tag</tt> are applied on.
139386 * @param mixed $var,... Additional variables passed to the functions hooked to <tt>$tag</tt>.
139387 * @return mixed The filtered value after all hooked functions are applied to it.
139388 */
139389 function apply_filters($tag, $value) {
139390 global $wp_filter, $merged_filters, $wp_current_filter;
139391
139392 $args = array();
139393 $wp_current_filter[] = $tag;
139394
139395 // Do 'all' actions first
139396 if ( isset($wp_filter['all']) ) {
139397 $args = func_get_args();
139398 _wp_call_all_hook($args);
139399 }
139400
139401 if ( !isset($wp_filter[$tag]) ) {
139402 array_pop($wp_current_filter);
139403 return $value;
139404 }
139405
139406 // Sort
139407 if ( !isset( $merged_filters[ $tag ] ) ) {
139408 ksort($wp_filter[$tag]);
139409 $merged_filters[ $tag ] = true;
139410 }
139411
139412 reset( $wp_filter[ $tag ] );
139413
139414 if ( empty($args) )
139415 $args = func_get_args();
139416
139417 do {
139418 foreach( (array) current($wp_filter[$tag]) as $the_ )
139419 if ( !is_null($the_['function']) ){
139420 $args[1] = $value;
139421 $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
139422 }
139423
139424 } while ( next($wp_filter[$tag]) !== false );
139425
139426 array_pop( $wp_current_filter );
139427
139428 return $value;
139429 }
139430
139431 /**
139432 * Removes a function from a specified filter hook.
139433 *
139434 * This function removes a function attached to a specified filter hook. This
139435 * method can be used to remove default functions attached to a specific filter
139436 * hook and possibly replace them with a substitute.
139437 *
139438 * To remove a hook, the $function_to_remove and $priority arguments must match
139439 * when the hook was added. This goes for both filters and actions. No warning
139440 * will be given on removal failure.
139441 *
139442 * @package WordPress
139443 * @subpackage Plugin
139444 * @since 1.2
139445 *
139446 * @param string $tag The filter hook to which the function to be removed is hooked.
139447 * @param callback $function_to_remove The name of the function which should be removed.
139448 * @param int $priority optional. The priority of the function (default: 10).
139449 * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).
139450 * @return boolean Whether the function existed before it was removed.
139451 */
139452 function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
139453 $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority);
139454
139455 $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
139456
139457 if ( true === $r) {
139458 unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
139459 if ( empty($GLOBALS['wp_filter'][$tag][$priority]) )
139460 unset($GLOBALS['wp_filter'][$tag][$priority]);
139461 unset($GLOBALS['merged_filters'][$tag]);
139462 }
139463
139464 return $r;
139465 }
139466
139467 /**
139468 * Remove all of the hooks from a filter.
139469 *
139470 * @since 2.7
139471 *
139472 * @param string $tag The filter to remove hooks from.
139473 * @param int $priority The priority number to remove.
139474 * @return bool True when finished.
139475 */
139476 function remove_all_filters($tag, $priority = false) {
139477 global $wp_filter, $merged_filters;
139478
139479 if( isset($wp_filter[$tag]) ) {
139480 if( false !== $priority && isset($$wp_filter[$tag][$priority]) )
139481 unset($wp_filter[$tag][$priority]);
139482 else
139483 unset($wp_filter[$tag]);
139484 }
139485
139486 if( isset($merged_filters[$tag]) )
139487 unset($merged_filters[$tag]);
139488
139489 return true;
139490 }
139491
139492 /**
139493 * Retrieve the name of the current filter or action.
139494 *
139495 * @package WordPress
139496 * @subpackage Plugin
139497 * @since 2.5
139498 *
139499 * @return string Hook name of the current filter or action.
139500 */
139501 function current_filter() {
139502 global $wp_current_filter;
139503 return end( $wp_current_filter );
139504 }
139505
139506
139507 /**
139508 * Hooks a function on to a specific action.
139509 *
139510 * Actions are the hooks that the WordPress core launches at specific points
139511 * during execution, or when specific events occur. Plugins can specify that
139512 * one or more of its PHP functions are executed at these points, using the
139513 * Action API.
139514 *
139515 * @uses add_filter() Adds an action. Parameter list and functionality are the same.
139516 *
139517 * @package WordPress
139518 * @subpackage Plugin
139519 * @since 1.2
139520 *
139521 * @param string $tag The name of the action to which the $function_to_add is hooked.
139522 * @param callback $function_to_add The name of the function you wish to be called.
139523 * @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.
139524 * @param int $accepted_args optional. The number of arguments the function accept (default 1).
139525 */
139526 function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
139527 return add_filter($tag, $function_to_add, $priority, $accepted_args);
139528 }
139529
139530
139531 /**
139532 * Execute functions hooked on a specific action hook.
139533 *
139534 * This function invokes all functions attached to action hook $tag. It is
139535 * possible to create new action hooks by simply calling this function,
139536 * specifying the name of the new hook using the <tt>$tag</tt> parameter.
139537 *
139538 * You can pass extra arguments to the hooks, much like you can with
139539 * apply_filters().
139540 *
139541 * @see apply_filters() This function works similar with the exception that
139542 * nothing is returned and only the functions or methods are called.
139543 *
139544 * @package WordPress
139545 * @subpackage Plugin
139546 * @since 1.2
139547 * @global array $wp_filter Stores all of the filters
139548 * @global array $wp_actions Increments the amount of times action was triggered.
139549 *
139550 * @param string $tag The name of the action to be executed.
139551 * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action.
139552 * @return null Will return null if $tag does not exist in $wp_filter array
139553 */
139554 function do_action($tag, $arg = '') {
139555 global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
139556
139557 if ( is_array($wp_actions) )
139558 $wp_actions[] = $tag;
139559 else
139560 $wp_actions = array($tag);
139561
139562 $wp_current_filter[] = $tag;
139563
139564 // Do 'all' actions first
139565 if ( isset($wp_filter['all']) ) {
139566 $all_args = func_get_args();
139567 _wp_call_all_hook($all_args);
139568 }
139569
139570 if ( !isset($wp_filter[$tag]) ) {
139571 array_pop($wp_current_filter);
139572 return;
139573 }
139574
139575 $args = array();
139576 if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) // array(&$this)
139577 $args[] =& $arg[0];
139578 else
139579 $args[] = $arg;
139580 for ( $a = 2; $a < func_num_args(); $a++ )
139581 $args[] = func_get_arg($a);
139582
139583 // Sort
139584 if ( !isset( $merged_filters[ $tag ] ) ) {
139585 ksort($wp_filter[$tag]);
139586 $merged_filters[ $tag ] = true;
139587 }
139588
139589 reset( $wp_filter[ $tag ] );
139590
139591 do {
139592 foreach ( (array) current($wp_filter[$tag]) as $the_ )
139593 if ( !is_null($the_['function']) )
139594 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
139595
139596 } while ( next($wp_filter[$tag]) !== false );
139597
139598 array_pop($wp_current_filter);
139599 }
139600
139601 /**
139602 * Retrieve the number times an action is fired.
139603 *
139604 * @package WordPress
139605 * @subpackage Plugin
139606 * @since 2.1
139607 * @global array $wp_actions Increments the amount of times action was triggered.
139608 *
139609 * @param string $tag The name of the action hook.
139610 * @return int The number of times action hook <tt>$tag</tt> is fired
139611 */
139612 function did_action($tag) {
139613 global $wp_actions;
139614
139615 if ( empty($wp_actions) )
139616 return 0;
139617
139618 return count(array_keys($wp_actions, $tag));
139619 }
139620
139621 /**
139622 * Execute functions hooked on a specific action hook, specifying arguments in an array.
139623 *
139624 * @see do_action() This function is identical, but the arguments passed to the
139625 * functions hooked to <tt>$tag</tt> are supplied using an array.
139626 *
139627 * @package WordPress
139628 * @subpackage Plugin
139629 * @since 2.1
139630 * @global array $wp_filter Stores all of the filters
139631 * @global array $wp_actions Increments the amount of times action was triggered.
139632 *
139633 * @param string $tag The name of the action to be executed.
139634 * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>
139635 * @return null Will return null if $tag does not exist in $wp_filter array
139636 */
139637 function do_action_ref_array($tag, $args) {
139638 global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;
139639
139640 if ( !is_array($wp_actions) )
139641 $wp_actions = array($tag);
139642 else
139643 $wp_actions[] = $tag;
139644
139645 $wp_current_filter[] = $tag;
139646
139647 // Do 'all' actions first
139648 if ( isset($wp_filter['all']) ) {
139649 $all_args = func_get_args();
139650 _wp_call_all_hook($all_args);
139651 }
139652
139653 if ( !isset($wp_filter[$tag]) ) {
139654 array_pop($wp_current_filter);
139655 return;
139656 }
139657
139658 // Sort
139659 if ( !isset( $merged_filters[ $tag ] ) ) {
139660 ksort($wp_filter[$tag]);
139661 $merged_filters[ $tag ] = true;
139662 }
139663
139664 reset( $wp_filter[ $tag ] );
139665
139666 do {
139667 foreach( (array) current($wp_filter[$tag]) as $the_ )
139668 if ( !is_null($the_['function']) )
139669 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
139670
139671 } while ( next($wp_filter[$tag]) !== false );
139672
139673 array_pop($wp_current_filter);
139674 }
139675
139676 /**
139677 * Check if any action has been registered for a hook.
139678 *
139679 * @package WordPress
139680 * @subpackage Plugin
139681 * @since 2.5
139682 * @see has_filter() has_action() is an alias of has_filter().
139683 *
139684 * @param string $tag The name of the action hook.
139685 * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached.
139686 * @return int|boolean Optionally returns the priority on that hook for the specified function.
139687 */
139688 function has_action($tag, $function_to_check = false) {
139689 return has_filter($tag, $function_to_check);
139690 }
139691
139692 /**
139693 * Removes a function from a specified action hook.
139694 *
139695 * This function removes a function attached to a specified action hook. This
139696 * method can be used to remove default functions attached to a specific filter
139697 * hook and possibly replace them with a substitute.
139698 *
139699 * @package WordPress
139700 * @subpackage Plugin
139701 * @since 1.2
139702 *
139703 * @param string $tag The action hook to which the function to be removed is hooked.
139704 * @param callback $function_to_remove The name of the function which should be removed.
139705 * @param int $priority optional The priority of the function (default: 10).
139706 * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).
139707 * @return boolean Whether the function is removed.
139708 */
139709 function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
139710 return remove_filter($tag, $function_to_remove, $priority, $accepted_args);
139711 }
139712
139713 /**
139714 * Remove all of the hooks from an action.
139715 *
139716 * @since 2.7
139717 *
139718 * @param string $tag The action to remove hooks from.
139719 * @param int $priority The priority number to remove them from.
139720 * @return bool True when finished.
139721 */
139722 function remove_all_actions($tag, $priority = false) {
139723 return remove_all_filters($tag, $priority);
139724 }
139725
139726 //
139727 // Functions for handling plugins.
139728 //
139729
139730 /**
139731 * Gets the basename of a plugin.
139732 *
139733 * This method extracts the name of a plugin from its filename.
139734 *
139735 * @package WordPress
139736 * @subpackage Plugin
139737 * @since 1.5
139738 *
139739 * @access private
139740 *
139741 * @param string $file The filename of plugin.
139742 * @return string The name of a plugin.
139743 * @uses WP_PLUGIN_DIR
139744 */
139745 function plugin_basename($file) {
139746 $file = str_replace('\\','/',$file); // sanitize for Win32 installs
139747 $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
139748 $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
139749 $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
139750 $file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir
139751 return $file;
139752 }
139753
139754 /**
139755 * Set the activation hook for a plugin.
139756 *
139757 * When a plugin is activated, the action 'activate_PLUGINNAME' hook is
139758 * activated. In the name of this hook, PLUGINNAME is replaced with the name of
139759 * the plugin, including the optional subdirectory. For example, when the plugin
139760 * is located in wp-content/plugin/sampleplugin/sample.php, then the name of
139761 * this hook will become 'activate_sampleplugin/sample.php'. When the plugin
139762 * consists of only one file and is (as by default) located at
139763 * wp-content/plugin/sample.php the name of this hook will be
139764 * 'activate_sample.php'.
139765 *
139766 * @package WordPress
139767 * @subpackage Plugin
139768 * @since 2.0
139769 *
139770 * @access private
139771 *
139772 * @param string $file The filename of the plugin including the path.
139773 * @param callback $function the function hooked to the 'activate_PLUGIN' action.
139774 */
139775 function register_activation_hook($file, $function) {
139776 $file = plugin_basename($file);
139777 add_action('activate_' . $file, $function);
139778 }
139779
139780 /**
139781 * Set the deactivation hook for a plugin.
139782 *
139783 * When a plugin is deactivated, the action 'deactivate_PLUGINNAME' hook is
139784 * deactivated. In the name of this hook, PLUGINNAME is replaced with the name
139785 * of the plugin, including the optional subdirectory. For example, when the
139786 * plugin is located in wp-content/plugin/sampleplugin/sample.php, then
139787 * the name of this hook will become 'activate_sampleplugin/sample.php'.
139788 *
139789 * When the plugin consists of only one file and is (as by default) located at
139790 * wp-content/plugin/sample.php the name of this hook will be
139791 * 'activate_sample.php'.
139792 *
139793 * @package WordPress
139794 * @subpackage Plugin
139795 * @since 2.0
139796 *
139797 * @access private
139798 *
139799 * @param string $file The filename of the plugin including the path.
139800 * @param callback $function the function hooked to the 'activate_PLUGIN' action.
139801 */
139802 function register_deactivation_hook($file, $function) {
139803 $file = plugin_basename($file);
139804 add_action('deactivate_' . $file, $function);
139805 }
139806
139807 /**
139808 * Set the uninstallation hook for a plugin.
139809 *
139810 * Registers the uninstall hook that will be called when the user clicks on the
139811 * uninstall link that calls for the plugin to uninstall itself. The link won't
139812 * be active unless the plugin hooks into the action.
139813 *
139814 * The plugin should not run arbitrary code outside of functions, when
139815 * registering the uninstall hook. In order to run using the hook, the plugin
139816 * will have to be included, which means that any code laying outside of a
139817 * function will be run during the uninstall process. The plugin should not
139818 * hinder the uninstall process.
139819 *
139820 * If the plugin can not be written without running code within the plugin, then
139821 * the plugin should create a file named 'uninstall.php' in the base plugin
139822 * folder. This file will be called, if it exists, during the uninstall process
139823 * bypassing the uninstall hook. The plugin, when using the 'uninstall.php'
139824 * should always check for the 'WP_UNINSTALL_PLUGIN' constant, before
139825 * executing.
139826 *
139827 * @since 2.7
139828 *
139829 * @param string $file
139830 * @param callback $callback The callback to run when the hook is called.
139831 */
139832 function register_uninstall_hook($file, $callback) {
139833 // The option should not be autoloaded, because it is not needed in most
139834 // cases. Emphasis should be put on using the 'uninstall.php' way of
139835 // uninstalling the plugin.
139836 $uninstallable_plugins = (array) get_option('uninstall_plugins');
139837 $uninstallable_plugins[plugin_basename($file)] = $callback;
139838 update_option('uninstall_plugins', $uninstallable_plugins);
139839 }
139840
139841 /**
139842 * Calls the 'all' hook, which will process the functions hooked into it.
139843 *
139844 * The 'all' hook passes all of the arguments or parameters that were used for
139845 * the hook, which this function was called for.
139846 *
139847 * This function is used internally for apply_filters(), do_action(), and
139848 * do_action_ref_array() and is not meant to be used from outside those
139849 * functions. This function does not check for the existence of the all hook, so
139850 * it will fail unless the all hook exists prior to this function call.
139851 *
139852 * @package WordPress
139853 * @subpackage Plugin
139854 * @since 2.5
139855 * @access private
139856 *
139857 * @uses $wp_filter Used to process all of the functions in the 'all' hook
139858 *
139859 * @param array $args The collected parameters from the hook that was called.
139860 * @param string $hook Optional. The hook name that was used to call the 'all' hook.
139861 */
139862 function _wp_call_all_hook($args) {
139863 global $wp_filter;
139864
139865 reset( $wp_filter['all'] );
139866 do {
139867 foreach( (array) current($wp_filter['all']) as $the_ )
139868 if ( !is_null($the_['function']) )
139869 call_user_func_array($the_['function'], $args);
139870
139871 } while ( next($wp_filter['all']) !== false );
139872 }
139873
139874 /**
139875 * Build Unique ID for storage and retrieval.
139876 *
139877 * The old way to serialize the callback caused issues and this function is the
139878 * solution. It works by checking for objects and creating an a new property in
139879 * the class to keep track of the object and new objects of the same class that
139880 * need to be added.
139881 *
139882 * It also allows for the removal of actions and filters for objects after they
139883 * change class properties. It is possible to include the property $wp_filter_id
139884 * in your class and set it to "null" or a number to bypass the workaround.
139885 * However this will prevent you from adding new classes and any new classes
139886 * will overwrite the previous hook by the same class.
139887 *
139888 * Functions and static method callbacks are just returned as strings and
139889 * shouldn't have any speed penalty.
139890 *
139891 * @package WordPress
139892 * @subpackage Plugin
139893 * @access private
139894 * @since 2.2.3
139895 * @link http://trac.wordpress.org/ticket/3875
139896 *
139897 * @global array $wp_filter Storage for all of the filters and actions
139898 * @param string $tag Used in counting how many hooks were applied
139899 * @param string|array $function Used for creating unique id
139900 * @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.
139901 * @param string $type filter or action
139902 * @return string Unique ID for usage as array key
139903 */
139904 function _wp_filter_build_unique_id($tag, $function, $priority) {
139905 global $wp_filter;
139906
139907 // If function then just skip all of the tests and not overwrite the following.
139908 if ( is_string($function) )
139909 return $function;
139910 // Object Class Calling
139911 else if (is_object($function[0]) ) {
139912 $obj_idx = get_class($function[0]).$function[1];
139913 if ( !isset($function[0]->wp_filter_id) ) {
139914 if ( false === $priority )
139915 return false;
139916 $count = isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0;
139917 $function[0]->wp_filter_id = $count;
139918 $obj_idx .= $count;
139919 unset($count);
139920 } else
139921 $obj_idx .= $function[0]->wp_filter_id;
139922 return $obj_idx;
139923 }
139924 // Static Calling
139925 else if ( is_string($function[0]) )
139926 return $function[0].$function[1];
139927 }
139928
139929 ?>