Changeset 28891
- Timestamp:
- 06/29/2014 09:18:41 AM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/plugin.php (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/plugin.php
r28889 r28891 36 36 37 37 /** 38 * Hook sa function or method to a specific filter action.38 * Hook a function or method to a specific filter action. 39 39 * 40 40 * WordPress offers filter hooks to allow plugins to modify … … 64 64 * so everything is as quick as possible. 65 65 * 66 * @since 0.71 67 * 66 68 * @global array $wp_filter A multidimensional array of all hooks and the callbacks hooked to them. 67 * @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. 68 * 69 * @since 0.71 69 * @global array $merged_filters Tracks the tags that need to be merged for later. If the hook is added, 70 * it doesn't need to run through that process. 70 71 * 71 72 * @param string $tag The name of the filter to hook the $function_to_add callback to. … … 93 94 * @since 2.5.0 94 95 * 95 * @global array $wp_filter Stores all of the filters 96 * @global array $wp_filter Stores all of the filters. 96 97 * 97 98 * @param string $tag The name of the filter hook. 98 99 * @param callback|bool $function_to_check Optional. The callback to check for. Default false. 99 * @return mixed If $function_to_check is omitted, returns boolean for whether the hook has anything registered. 100 * When checking a specific function, the priority of that hook is returned, or false if the function is not attached. 101 * When using the $function_to_check argument, this function may return a non-boolean value that evaluates to false 102 * (e.g.) 0, so use the === operator for testing the return value. 100 * @return bool|int If $function_to_check is omitted, returns boolean for whether the hook has 101 * anything registered. When checking a specific function, the priority of that 102 * hook is returned, or false if the function is not attached. When using the 103 * $function_to_check argument, this function may return a non-boolean value 104 * that evaluates to false (e.g.) 0, so use the === operator for testing the 105 * return value. 103 106 */ 104 107 function has_filter($tag, $function_to_check = false) { … … 145 148 * </code> 146 149 * 150 * @since 0.71 151 * 147 152 * @global array $wp_filter Stores all of the filters. 148 153 * @global array $merged_filters Merges the filter hooks using this function. 149 154 * @global array $wp_current_filter Stores the list of current filters with the current one last. 150 *151 * @since 0.71152 155 * 153 156 * @param string $tag The name of the filter hook. … … 161 164 $args = array(); 162 165 163 // Do 'all' actions first 166 // Do 'all' actions first. 164 167 if ( isset($wp_filter['all']) ) { 165 168 $wp_current_filter[] = $tag; … … 177 180 $wp_current_filter[] = $tag; 178 181 179 // Sort 182 // Sort. 180 183 if ( !isset( $merged_filters[ $tag ] ) ) { 181 184 ksort($wp_filter[$tag]); … … 209 212 * 210 213 * @since 3.0.0 211 * @global array $wp_filter Stores all of the filters 212 * @global array $merged_filters Merges the filter hooks using this function. 213 * @global array $wp_current_filter stores the list of current filters with the current one last 214 * 215 * @global array $wp_filter Stores all of the filters 216 * @global array $merged_filters Merges the filter hooks using this function. 217 * @global array $wp_current_filter Stores the list of current filters with the current one last 214 218 * 215 219 * @param string $tag The name of the filter hook. 216 * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt>.220 * @param array $args The arguments supplied to the functions hooked to $tag. 217 221 * @return mixed The filtered value after all hooked functions are applied to it. 218 222 */ … … 350 354 * The function current_filter() only returns the most recent filter or action 351 355 * being executed. did_action() returns true once the action is initially 352 * processed. This function allows detection for any filter currently being 356 * processed. 357 * 358 * This function allows detection for any filter currently being 353 359 * executed (despite not being the most recent filter to fire, in the case of 354 360 * hooks called from hook callbacks) to be verified. … … 362 368 * @param null|string $filter Optional. Filter to check. Defaults to null, which 363 369 * checks if any filter is currently being run. 364 * @return bool Whether the filter is currently in the stack 370 * @return bool Whether the filter is currently in the stack. 365 371 */ 366 372 function doing_filter( $filter = null ) { … … 397 403 * Action API. 398 404 * 405 * @since 1.2.0 406 * 399 407 * @uses add_filter() Adds an action. Parameter list and functionality are the same. 400 *401 * @since 1.2.0402 408 * 403 409 * @param string $tag The name of the action to which the $function_to_add is hooked. … … 425 431 * apply_filters(). 426 432 * 427 * @see apply_filters() This function works similar with the exception that428 * nothing is returned and only the functions or methods are called.429 *430 433 * @since 1.2.0 431 434 * 432 * @global array $wp_filter Stores all of the filters 435 * @see apply_filters() This function works similar with the exception that nothing 436 * is returned and only the functions or methods are called. 437 * @global array $wp_filter Stores all of the filters 433 438 * @global array $wp_actions Increments the amount of times action was triggered. 434 439 * 435 * @param string $tag The name of the action to be executed. 436 * @param mixed $arg, ... Optional. Additional arguments which are passed on to the functions hooked to the action. 437 * @return null Will return null if $tag does not exist in $wp_filter array 440 * @param string $tag The name of the action to be executed. 441 * @param mixed $arg Optional. Additional arguments which are passed on to the 442 * functions hooked to the action. Default empty. 443 * @return null Will return null if $tag does not exist in $wp_filter array. 438 444 */ 439 445 function do_action($tag, $arg = '') { … … 495 501 * 496 502 * @param string $tag The name of the action hook. 497 * @return int The number of times action hook <tt>$tag</tt> is fired503 * @return int The number of times action hook $tag is fired. 498 504 */ 499 505 function did_action($tag) { … … 509 515 * Execute functions hooked on a specific action hook, specifying arguments in an array. 510 516 * 517 * @since 2.1.0 518 * 511 519 * @see do_action() This function is identical, but the arguments passed to the 512 * functions hooked to <tt>$tag</tt> are supplied using an array. 513 * 514 * @since 2.1.0 515 * 516 * @global array $wp_filter Stores all of the filters 520 * functions hooked to $tag< are supplied using an array. 521 * @global array $wp_filter Stores all of the filters 517 522 * @global array $wp_actions Increments the amount of times action was triggered. 518 523 * … … 572 577 * @param string $tag The name of the action hook. 573 578 * @param callback|bool $function_to_check Optional. The callback to check for. Default false. 574 * @return mixed If $function_to_check is omitted, returns boolean for whether the hook has anything registered. 575 * When checking a specific function, the priority of that hook is returned, or false if the function is not attached. 576 * When using the $function_to_check argument, this function may return a non-boolean value that evaluates to false 577 * (e.g.) 0, so use the === operator for testing the return value. 579 * @return bool|int If $function_to_check is omitted, returns boolean for whether the hook has 580 * anything registered. When checking a specific function, the priority of that 581 * hook is returned, or false if the function is not attached. When using the 582 * $function_to_check argument, this function may return a non-boolean value 583 * that evaluates to false (e.g.) 0, so use the === operator for testing the 584 * return value. 578 585 */ 579 586 function has_action($tag, $function_to_check = false) { … … 623 630 * @since 1.5.0 624 631 * 625 * @ access private632 * @uses WP_PLUGIN_DIR, WPMU_PLUGIN_DIR 626 633 * 627 634 * @param string $file The filename of plugin. 628 635 * @return string The name of a plugin. 629 * @uses WP_PLUGIN_DIR630 636 */ 631 637 function plugin_basename( $file ) { … … 684 690 685 691 /** 686 * Get s the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in692 * Get the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in. 687 693 * 688 694 * @since 2.8.0 689 695 * 690 * @param string $file The filename of the plugin (__FILE__) 691 * @return string the filesystem path of the directory that contains the plugin 696 * @param string $file The filename of the plugin (__FILE__). 697 * @return string the filesystem path of the directory that contains the plugin. 692 698 */ 693 699 function plugin_dir_path( $file ) { … … 696 702 697 703 /** 698 * Get s the URL directory path (with trailing slash) for the plugin __FILE__ passed in704 * Get the URL directory path (with trailing slash) for the plugin __FILE__ passed in. 699 705 * 700 706 * @since 2.8.0 701 707 * 702 * @param string $file The filename of the plugin (__FILE__) 703 * @return string the URL path of the directory that contains the plugin 708 * @param string $file The filename of the plugin (__FILE__). 709 * @return string the URL path of the directory that contains the plugin. 704 710 */ 705 711 function plugin_dir_url( $file ) { … … 722 728 * @since 2.0.0 723 729 * 724 * @param string $fileThe filename of the plugin including the path.725 * @param callback $function the function hooked to the 'activate_PLUGIN' action.730 * @param string $file The filename of the plugin including the path. 731 * @param callback $function The function hooked to the 'activate_PLUGIN' action. 726 732 */ 727 733 function register_activation_hook($file, $function) { … … 745 751 * @since 2.0.0 746 752 * 747 * @param string $fileThe filename of the plugin including the path.748 * @param callback $function the function hooked to the 'deactivate_PLUGIN' action.753 * @param string $file The filename of the plugin including the path. 754 * @param callback $function The function hooked to the 'deactivate_PLUGIN' action. 749 755 */ 750 756 function register_deactivation_hook($file, $function) { … … 775 781 * @since 2.7.0 776 782 * 777 * @param string $file 778 * @param callback $callback The callback to run when the hook is called. Must be a static method or function. 783 * @param string $file Plugin file. 784 * @param callback $callback The callback to run when the hook is called. Must be 785 * a static method or function. 779 786 */ 780 787 function register_uninstall_hook( $file, $callback ) { … … 784 791 } 785 792 786 // The option should not be autoloaded, because it is not needed in most 787 // cases. Emphasis should be put on using the 'uninstall.php' way of 788 // uninstalling the plugin. 793 /* 794 * The option should not be autoloaded, because it is not needed in most 795 * cases. Emphasis should be put on using the 'uninstall.php' way of 796 * uninstalling the plugin. 797 */ 789 798 $uninstallable_plugins = (array) get_option('uninstall_plugins'); 790 799 $uninstallable_plugins[plugin_basename($file)] = $callback; 800 791 801 update_option('uninstall_plugins', $uninstallable_plugins); 792 802 } 793 803 794 804 /** 795 * Call sthe 'all' hook, which will process the functions hooked into it.805 * Call the 'all' hook, which will process the functions hooked into it. 796 806 * 797 807 * The 'all' hook passes all of the arguments or parameters that were used for … … 806 816 * @access private 807 817 * 808 * @uses $wp_filter Used to process all of the functions in the 'all' hook 818 * @uses $wp_filter Used to process all of the functions in the 'all' hook. 809 819 * 810 820 * @param array $args The collected parameters from the hook that was called. … … 839 849 * shouldn't have any speed penalty. 840 850 * 851 * @link http://trac.wordpress.org/ticket/3875 852 * 853 * @since 2.2.3 841 854 * @access private 842 * @since 2.2.3 843 * @link http://trac.wordpress.org/ticket/3875 844 * 845 * @global array $wp_filter Storage for all of the filters and actions 846 * @param string $tag Used in counting how many hooks were applied 855 * 856 * @global array $wp_filter Storage for all of the filters and actions. 857 * 858 * @param string $tag Used in counting how many hooks were applied 847 859 * @param callback $function Used for creating unique id 848 * @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. 849 * @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 unique id. 860 * @param int|bool $priority Used in counting how many hooks were applied. If === false 861 * and $function is an object reference, we return the unique 862 * id only if it already has one, false otherwise. 863 * @return string|bool Unique ID for usage as array key or false if $priority === false 864 * and $function is an object reference, and it does not already have 865 * a unique id. 850 866 */ 851 867 function _wp_filter_build_unique_id($tag, $function, $priority) {
Note: See TracChangeset
for help on using the changeset viewer.