/** * Hooks a function or method to a specific filter action. * * Filters are the hooks that WordPress launches to modify text of various types * before adding it to the database or sending it to the browser screen. Plugins * can specify that one or more of its PHP functions is executed to * modify specific types of text at these times, using the Filter API. * * To use the API, the following code should be used to bind a callback to the * filter. * * <code> * function example_hook($example) { echo $example; } * $this->Hook->addFilter('example_filter', 'example_hook'); * </code> * * In WordPress 1.5.1+, hooked functions can take extra arguments that are set * when the matching do_action() or apply_filters() call is run. The * $accepted_args allow for calling functions only when the number of args * match. Hooked functions can take extra arguments that are set when the * matching do_action() or apply_filters() call is run. For example, the action * comment_id_not_found will pass any functions that hook onto it the ID of the * requested comment. * * <strong>Note:</strong> the function will return true no matter if the * function was hooked fails or not. There are no checks for whether the * function exists beforehand and no checks to whether the <tt>$function_to_add * is even a string. It is up to you to take care and this is done for * optimization purposes, so everything is as quick as possible. * * @param string $tag The name of the filter to hook the $function_to_add to. * @param callback $function_to_add The name of the function to be called when the filter is applied. * @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. * @param int $accepted_args optional. The number of arguments the function accept (default 1). * * @return boolean true */ public function addFilter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { return HuradHook::add_filter($tag, $function_to_add, $priority, $accepted_args); }
<?php /** * Default filters * * PHP 5 * * Licensed under The MIT License * For full copyright and license information, please see the LICENSE * Redistributions of files must retain the above copyright notice. * * @copyright Copyright (c) 2012-2014, Hurad (http://hurad.org) * @link http://hurad.org Hurad Project * @since Version 0.1.0 * @license http://opensource.org/licenses/MIT MIT license */ HuradHook::add_filter('the_title', 'trim'); HuradHook::add_filter('commentText', 'HuradFormatting::clickAbleLink', 9); HuradHook::add_filter('commentText', 'HuradFormatting::convertEmoticons', 20); HuradHook::add_filter('editable_slug', 'urldecode'); HuradHook::add_filter('editable_slug', 'HuradSanitize::textarea');