当前位置: 首页>>代码示例>>PHP>>正文


PHP _wp_filter_build_unique_id函数代码示例

本文整理汇总了PHP中_wp_filter_build_unique_id函数的典型用法代码示例。如果您正苦于以下问题:PHP _wp_filter_build_unique_id函数的具体用法?PHP _wp_filter_build_unique_id怎么用?PHP _wp_filter_build_unique_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_wp_filter_build_unique_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_filter

function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1)
{
    global $wp_filter, $merged_filters;
    $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority);
    $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
    unset($merged_filters[$tag]);
    return true;
}
开发者ID:gokuale,项目名称:server-command,代码行数:8,代码来源:router-lib.php

示例2: test_not_has_filter_with_directly_removed_callback

 public function test_not_has_filter_with_directly_removed_callback()
 {
     $callback = '__return_null';
     $hook = new WP_Hook();
     $tag = __FUNCTION__;
     $priority = rand(1, 100);
     $accepted_args = rand(1, 100);
     $hook->add_filter($tag, $callback, $priority, $accepted_args);
     $function_key = _wp_filter_build_unique_id($tag, $callback, $priority);
     unset($hook->callbacks[$priority][$function_key]);
     $this->assertFalse($hook->has_filters());
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:12,代码来源:has_filters.php

示例3: test_add_filter_with_static_method

 public function test_add_filter_with_static_method()
 {
     $callback = array('MockAction', 'action');
     $hook = new WP_Hook();
     $tag = rand_str();
     $priority = rand(1, 100);
     $accepted_args = rand(1, 100);
     $hook->add_filter($tag, $callback, $priority, $accepted_args);
     $function_index = _wp_filter_build_unique_id($tag, $callback, $priority);
     $this->assertEquals($callback, $hook->callbacks[$priority][$function_index]['function']);
     $this->assertEquals($accepted_args, $hook->callbacks[$priority][$function_index]['accepted_args']);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:12,代码来源:add_filter.php

示例4: blog_template_ensure_last_place

/**
 * Ensure we're the last thing to run on blog creation.
 */
function blog_template_ensure_last_place()
{
    global $wp_filter, $blog_templates;
    if (!$wp_filter || !$blog_templates) {
        return false;
    }
    $tag = 'wpmu_new_blog';
    $method = 'set_blog_defaults';
    $action_order = false;
    $bt_callback = array($blog_templates, $method);
    if (!is_callable($bt_callback)) {
        return false;
    }
    if (has_action($tag, $bt_callback)) {
        // This is all provided it's even bound
        $actions = !empty($wp_filter[$tag]) ? $wp_filter[$tag] : false;
        if (!$actions) {
            return false;
        }
        $highest = max(array_keys($actions));
        if (!($idx = _wp_filter_build_unique_id($tag, $bt_callback, false))) {
            return false;
        }
        // Taken from core (`has_filter()`)
        foreach ($actions as $priority => $callbacks) {
            if (!isset($actions[$priority][$idx])) {
                continue;
            }
            $action_order = $priority;
            break;
        }
        if ($action_order >= $highest) {
            return true;
        }
        // We're the on the bottom, all good.
        // If we reached here, this is not good - we need to re-bind to highest position
        remove_action($tag, $bt_callback, $action_order, 6);
        $action_order = $highest + 10;
    } else {
        // No action bound, let's do our thing
        $action_order = defined('NBT_APPLY_TEMPLATE_ACTION_ORDER') && NBT_APPLY_TEMPLATE_ACTION_ORDER ? NBT_APPLY_TEMPLATE_ACTION_ORDER : 9999;
        $action_order = apply_filters('blog_templates-actions-action_order', $action_order);
    }
    add_action($tag, $bt_callback, $action_order, 6);
    return true;
}
开发者ID:hscale,项目名称:webento,代码行数:49,代码来源:filters.php

示例5: has_filter

 /**
  * Checks if a specific action has been registered for this hook.
  *
  * @since 4.7.0
  * @access public
  *
  * @param callable|bool $function_to_check Optional. The callback to check for. Default false.
  * @param string        $tag               Optional. The name of the filter hook. Used for building
  *                                         the callback ID when SPL is not available. Default empty.
  * @return bool|int The priority of that hook is returned, or false if the function is not attached.
  */
 public function has_filter($tag = '', $function_to_check = false)
 {
     if (false === $function_to_check) {
         return $this->has_filters();
     }
     $function_key = _wp_filter_build_unique_id($tag, $function_to_check, false);
     if (!$function_key) {
         return false;
     }
     foreach ($this->callbacks as $priority => $callbacks) {
         if (isset($callbacks[$function_key])) {
             return $priority;
         }
     }
     return false;
 }
开发者ID:kucrut,项目名称:wordpress,代码行数:27,代码来源:class-wp-hook.php

示例6: getListenerPriority

 public function getListenerPriority($eventName, $listener)
 {
     if (!isset($GLOBALS['wp_filter']) || !isset($GLOBALS['wp_filter'][$eventName])) {
         return null;
     }
     foreach ($GLOBALS['wp_filter'][$eventName] as $priority => $functions) {
         $function = _wp_filter_build_unique_id($eventName, $listener, $priority);
         if (isset($functions[$function])) {
             return $priority;
         }
     }
     return null;
 }
开发者ID:devaloka,项目名称:devaloka,代码行数:13,代码来源:EventDispatcher.php

示例7: has_filter

 /**
  *
  * Check if any filter has been registered for a hook.
  *
  * @param string        $tag               The name of the filter hook.
  * @param callback|bool $function_to_check Optional. The callback to check for. Default false.
  *
  * @return false|int If $function_to_check is omitted, returns boolean for whether the hook has
  *                   anything registered. When checking a specific function, the priority of that
  *                   hook is returned, or false if the function is not attached. When using the
  *                   $function_to_check argument, this function may return a non-boolean value
  *                   that evaluates to false (e.g.) 0, so use the === operator for testing the
  *                   return value.
  */
 public function has_filter($tag, $function_to_check = false)
 {
     // Don't reset the internal array pointer
     $filter = $this->filter;
     $has = !empty($filter[$tag]);
     // Make sure at least one priority has a filter callback
     if ($has) {
         $exists = false;
         foreach ($filter[$tag] as $callbacks) {
             if (!empty($callbacks)) {
                 $exists = true;
                 break;
             }
         }
         if (!$exists) {
             $has = false;
         }
     }
     if (false === $function_to_check || false === $has) {
         return $has;
     }
     if (!($idx = _wp_filter_build_unique_id($tag, $function_to_check, false))) {
         return false;
     }
     foreach ((array) array_keys($filter[$tag]) as $priority) {
         if (isset($filter[$tag][$priority][$idx])) {
             return $priority;
         }
     }
     return false;
 }
开发者ID:puresolcom,项目名称:polyether,代码行数:45,代码来源:PluginAPI.php

示例8: the_content_filter

 function the_content_filter($content)
 {
     global $post, $tempPost, $wp_filter, $save_wp_filter;
     // check the temporary $post reassignment for context specific $post data
     $the_post = isset($tempPost) ? $tempPost : $post;
     if (isset($save_wp_filter)) {
         $wp_filter['the_content'] = $save_wp_filter;
     } else {
         $save_wp_filter = $wp_filter['the_content'];
     }
     // active filters
     $the_content_filters = $wp_filter['the_content'];
     // get block options
     $disable = unserialize(get_theme_var('options,disable_wp_content'));
     if (isset($disable[$the_post->post_type])) {
         $disable = $disable[$the_post->post_type];
         if (count($disable)) {
             foreach ($disable as $filter) {
                 // check filter type (function or object)
                 if (preg_match("/->/", $filter)) {
                     // get class to block then generate current block id
                     // and unset filter from apply list
                     $filter = explode("->", $filter);
                     $class = $filter[0];
                     $method = $filter[1];
                     foreach ($the_content_filters as $level => $_filters) {
                         foreach ($_filters as $_filter_name => $_filter) {
                             if (is_object($_filter['function'][0])) {
                                 if ($class == get_class($_filter['function'][0]) && $method == $_filter['function'][1]) {
                                     $object_filter = _wp_filter_build_unique_id('', array(&$_filter["function"][0], $method), 10);
                                     foreach ($wp_filter['the_content'] as $key => $val) {
                                         unset($wp_filter['the_content'][$key][$object_filter]);
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     // unset function filter
                     remove_filter('the_content', $filter);
                 }
             }
         }
     }
     return $content;
 }
开发者ID:perusoa,项目名称:anthony-peruso-website,代码行数:46,代码来源:filters-and-actions.php

示例9: add_filter

 function add_filter($filter, $function = '', $priority = 10, $accepted_args = 1)
 {
     add_filter($filter, array(&$this, $function == '' ? $filter : $function), $priority, $accepted_args);
     $this->idx[$filter] = _wp_filter_build_unique_id($filter, array(&$this, $function == '' ? $filter : $function), $priority);
     /* unique id of this filter from object fixed 1.0.1 */
 }
开发者ID:ergov2015,项目名称:rideflag.dev,代码行数:6,代码来源:xili-language.php

示例10: remove_filter

/**
 * Removes a function from a specified filter hook. 
 * 
 * This function removes a function attached to a specified filter hook. This 
 * method can be used to remove default functions attached to a specific filter 
 * hook and possibly replace them with a substitute.
 * @param string $tag The filter hook to which the function to be removed is hooked.
 * @param callback $function_to_remove The name of the function which should be removed.
 * @param int $priority optional. The priority of the function (default: 10).
 * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).
 * @return boolean Whether the function is removed.
 */
function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
	global $wp_filter, $merged_filters;
	
	unset($GLOBALS['wp_filter'][$tag][$priority][_wp_filter_build_unique_id($tag, $function_to_remove, $priority)]);
	unset( $merged_filters[ $tag ] );

	return true;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:20,代码来源:plugin.php

示例11: getObserverKey

 /**
  * put your comment there...
  * 
  * @param mixed $name
  * @param mixed $callback
  * @param mixed $priority
  */
 public static function getObserverKey($name, $callback, $priority = self::PRIORITY)
 {
     return _wp_filter_build_unique_id($name, $callback, $priority);
 }
开发者ID:JSreactor,项目名称:MarketCrater.com,代码行数:11,代码来源:wordpress-hook.observer.php

示例12: remove_filter

/**
 * Removes a function from a specified filter hook.
 *
 * This function removes a function attached to a specified filter hook. This
 * method can be used to remove default functions attached to a specific filter
 * hook and possibly replace them with a substitute.
 * @param string $tag The filter hook to which the function to be removed is hooked.
 * @param callback $function_to_remove The name of the function which should be removed.
 * @param int $priority optional. The priority of the function (default: 10).
 * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).
 * @return boolean Whether the function is removed.
 */
function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1)
{
    $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority);
    $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
    unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
    unset($GLOBALS['merged_filters'][$tag]);
    return $r;
}
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:20,代码来源:plugin.php

示例13: tf_add_filter_once

/**
 * Performs an add_filter only once. Helpful for factory constructors where an action only
 * needs to be added once. Because of this, there will be no need to do a static variable that
 * will be set to true after the first run, ala $firstLoad
 *
 * @since 1.9
 *
 * @param string   $tag             The name of the filter to hook the $function_to_add callback to.
 * @param callback $function_to_add The callback to be run 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 accepts. Default 1.
 *
 * @return true
 */
function tf_add_filter_once($tag, $function_to_add, $priority = 10, $accepted_args = 1)
{
    global $_gambitFiltersRan;
    if (!isset($_gambitFiltersRan)) {
        $_gambitFiltersRan = array();
    }
    // Since references to $this produces a unique id, just use the class for identification purposes
    $idxFunc = $function_to_add;
    if (is_array($function_to_add)) {
        if (!is_string($function_to_add[0])) {
            $idxFunc[0] = get_class($function_to_add[0]);
        }
    }
    $idx = $tag . ':' . _wp_filter_build_unique_id($tag, $idxFunc, $priority);
    if (!in_array($idx, $_gambitFiltersRan)) {
        add_filter($tag, $function_to_add, $priority, $accepted_args);
    }
    $_gambitFiltersRan[] = $idx;
    return true;
}
开发者ID:gambitph,项目名称:titan-framework,代码行数:38,代码来源:functions-utils.php

示例14: get_wp_filter_id

 /**
  * Get a unique ID for a hook based on the internal method, hook, and priority.
  *
  * @param  string $hook
  * @param  string $method
  * @param  int    $priority
  * @return bool|string
  */
 protected function get_wp_filter_id($hook, $method, $priority)
 {
     return _wp_filter_build_unique_id($hook, [$this, $method], $priority);
 }
开发者ID:cedaro,项目名称:wp-plugin,代码行数:12,代码来源:HooksTrait.php

示例15: post_notification_admin_sub


//.........这里部分代码省略.........
	</tr>
	<tr class="alternate">
		<td />
		<td>
			<?php 
    _e('Try using database locking if you are geting duplicate messages.', 'post_notification');
    echo ' ' . '<a href="http://php.net/manual/function.flock.php">' . __('More information.', 'post_notification') . '</a>';
    ?>
		</td>
	</tr>
	
	
	
	
	<tr class="alternate">

		<th style="text-align:right;padding-right:10px;"><?php 
    _e('Filters to exclude from filtering "the_content":', 'post_notification');
    ?>
</th>

		<td>
			<?php 
    global $wp_filter;
    $rem_filters = get_option('post_notification_the_content_exclude');
    if (is_string($rem_filters) && strlen($rem_filters)) {
        $rem_filters = unserialize($rem_filters);
    }
    if (!is_array($rem_filters)) {
        $rem_filters = array();
    }
    foreach ($wp_filter['the_content'] as $filter_level => $filters_in_level) {
        foreach ($filters_in_level as $filter) {
            if (function_exists('_wp_filter_build_unique_id')) {
                // If a function is passed the unique_id will return the function name.
                // Therefore there should be no problem with backward compatibilty
                // priority may/must be false as all functions should get an Id when being registered
                // As prio = false, $tag is not needed at all!
                $fn_name = _wp_filter_build_unique_id('the_content', $filter['function'], $filter_level);
            } else {
                $fn_name = $filter['function'];
            }
            if (!($fn_name === false)) {
                echo '<input type="checkbox"  name="the_content[]" value="' . $fn_name . '" ';
                if (in_array($fn_name, $rem_filters)) {
                    echo ' checked="checked" ';
                }
                echo '>' . $fn_name . '</input><br />';
            }
        }
    }
    ?>
		</td>	
	</tr>
	
	<tr class="alternate">
		<td />
		<td>
			<?php 
    _e('Some plugins use filters to modify the content of a post. You might not want some of them modifying your mails. Finding the right filters might need some playing around.', 'post_notification');
    ?>
		</td>
	</tr>
	
	
	</tr>
开发者ID:jrep20,项目名称:samcozen,代码行数:67,代码来源:admin_settings.php


注:本文中的_wp_filter_build_unique_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。