本文整理汇总了PHP中did_action函数的典型用法代码示例。如果您正苦于以下问题:PHP did_action函数的具体用法?PHP did_action怎么用?PHP did_action使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了did_action函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* register method for setting up model extensions
*
* @param string $model_id unique id for the extensions being setup
* @param array $config {
* @throws EE_Error
* @type array $ model_extension_paths array of folders containing DB model extensions, where each file follows the models naming convention, which is: EEME_{your_plugin_slug}_model_name_extended}.model_ext.php. Where your_plugin_slug} is really anything you want (but something having to do with your addon, like 'Calendar' or '3D_View') and model_name_extended} is the model extended. The class contained in teh file should extend EEME_Base_{model_name_extended}.model_ext.php. Where {your_plugin_slug} is really anything you want (but something having to do with your addon, like 'Calendar' or '3D_View') and {model_name_extended} is the model extended. The class contained in teh file should extend EEME_Base
* @type array $ class_extension_paths array of folders containing DB class extensions, where each file follows the model class extension naming convention, which is: EEE_{your_plugin_slug}_model_name_extended}.class_ext.php. Where your_plugin_slug} is something like 'Calendar','MailChimp',etc, and model_name_extended} is the name of the model extended, eg 'Attendee','Event',etc. The class contained in the file should extend EEE_Base_Class._{model_name_extended}.class_ext.php. Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, and {model_name_extended} is the name of the model extended, eg 'Attendee','Event',etc. The class contained in the file should extend EEE_Base_Class.
* }
*
* @return void
*/
public static function register($model_id = NULL, $config = array())
{
//required fields MUST be present, so let's make sure they are.
if (empty($model_id) || !is_array($config) || empty($config['model_extension_paths']) && empty($config['class_extension_paths'])) {
throw new EE_Error(__('In order to register Model extensions with EE_Register_Model_Extensions::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_extension_paths" (an array of full server paths to folders that contain model extensions), and "class_extension_paths" (an array of full server paths to folders that contain class extensions)', 'event_espresso'));
}
//check correct loading
if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
EE_Error::doing_it_wrong(__METHOD__, sprintf(__('An attempt was made to register "%s" as a group models has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.', 'event_espresso'), $model_id), '4.3');
}
self::$_registry[$model_id] = $config;
EE_Registry::instance()->load_helper('File');
if (isset($config['model_extension_paths'])) {
require_once EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php';
$class_to_filepath_map = EEH_File::get_contents_of_folders($config['model_extension_paths']);
EEH_Autoloader::register_autoloader($class_to_filepath_map);
foreach (array_keys($class_to_filepath_map) as $classname) {
new $classname();
}
unset($config['model_extension_paths']);
}
if (isset($config['class_extension_paths'])) {
require_once EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php';
$class_to_filepath_map = EEH_File::get_contents_of_folders($config['class_extension_paths']);
EEH_Autoloader::register_autoloader($class_to_filepath_map);
foreach (array_keys($class_to_filepath_map) as $classname) {
new $classname();
}
unset($config['class_extension_paths']);
}
foreach ($config as $unknown_key => $unknown_config) {
throw new EE_Error(sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key));
}
}
示例2: registerAction
public static function registerAction($sActionHook, $oCallable)
{
if (did_action($sActionHook)) {
return call_user_func_array($oCallable, array());
}
add_action($sActionHook, $oCallable);
}
示例3: wptuts_screen_help
function wptuts_screen_help($contextual_help, $screen_id, $screen)
{
// The add_help_tab function for screen was introduced in WordPress 3.3.
if (!method_exists($screen, 'add_help_tab')) {
return $contextual_help;
}
global $hook_suffix;
// List screen properties
$variables = '<ul style="width:50%;float:left;"> <strong>Screen variables </strong>' . sprintf('<li> Screen id : %s</li>', $screen_id) . sprintf('<li> Screen base : %s</li>', $screen->base) . sprintf('<li>Parent base : %s</li>', $screen->parent_base) . sprintf('<li> Parent file : %s</li>', $screen->parent_file) . sprintf('<li> Hook suffix : %s</li>', $hook_suffix) . '</ul>';
// Append global $hook_suffix to the hook stems
$hooks = array("load-{$hook_suffix}", "admin_print_styles-{$hook_suffix}", "admin_print_scripts-{$hook_suffix}", "admin_head-{$hook_suffix}", "admin_footer-{$hook_suffix}");
// If add_meta_boxes or add_meta_boxes_{screen_id} is used, list these too
if (did_action('add_meta_boxes_' . $screen_id)) {
$hooks[] = 'add_meta_boxes_' . $screen_id;
}
if (did_action('add_meta_boxes')) {
$hooks[] = 'add_meta_boxes';
}
// Get List HTML for the hooks
$hooks = '<ul style="width:50%;float:left;"> <strong>Hooks </strong> <li>' . implode('</li><li>', $hooks) . '</li></ul>';
// Combine $variables list with $hooks list.
$help_content = $variables . $hooks;
// Add help panel
$screen->add_help_tab(array('id' => 'wptuts-screen-help', 'title' => 'Screen Information', 'content' => $help_content));
return $contextual_help;
}
示例4: run_preflight
/**
* Perform preflight checks for Mercator
*
* Checks that we can actually run Mercator, then attaches the relevant actions
* and filters to make it useful.
*/
function run_preflight()
{
// Are we installing? Bail if so.
if (defined('WP_INSTALLING')) {
return;
}
// Are we still in sunrise stage?
if (did_action('muplugins_loaded')) {
warn_with_message('Mercator must be loaded in your <code>sunrise.php</code>. Check out the <a href="https://github.com/humanmade/Mercator/wiki/Installation">installation instructions</a>.');
return;
}
// Are we actually on multisite?
if (!is_multisite()) {
warn_with_message('Mercator requires WordPress to be in <a href="http://codex.wordpress.org/Create_A_Network">multisite mode</a>.');
return;
}
// Are we running a good version of WP?
if (!function_exists('get_site_by_path')) {
warn_with_message('Mercator requires <a href="https://wordpress.org/download/">WordPress 3.9</a> or newer. Update now.');
return;
}
// Check for COOKIE_DOMAIN definition
//
// Note that this can't be an admin notice, as you'd never be able to log in
// to see it.
if (defined('COOKIE_DOMAIN')) {
status_header(500);
header('X-Mercator: COOKIE_DOMAIN');
wp_die('The constant <code>COOKIE_DOMAIN</code> is defined (probably in <code>wp-config.php</code>). Please remove or comment out that <code>define()</code> line.');
}
// M: We have clearance, Clarence.
// O: Roger, Roger. What's our Vector Victor?
startup();
}
示例5: automobile_theme_options_scripts
/**
* Include scripts to the options page only
*/
function automobile_theme_options_scripts()
{
if (!did_action('wp_enqueue_media')) {
wp_enqueue_media();
}
wp_enqueue_script('automobile_upload', plugins_url('/js/upload.js', __FILE__));
}
示例6: run_preflight
/**
* Perform preflight checks for Mercator
*
* Checks that we can actually run Mercator, then attaches the relevant actions
* and filters to make it useful.
*/
function run_preflight()
{
// Are we installing? Bail if so.
if (defined('WP_INSTALLING')) {
return;
}
// Are we still in sunrise stage?
if (did_action('muplugins_loaded')) {
warn_with_message('Mercator must be loaded in your <code>sunrise.php</code>. Check out the <a href="https://github.com/humanmade/Mercator/wiki/Installation">installation instructions</a>.');
return;
}
// Are we actually on multisite?
if (!is_multisite()) {
warn_with_message('Mercator requires WordPress to be in <a href="http://codex.wordpress.org/Create_A_Network">multisite mode</a>.');
return;
}
// Are we running a good version of WP?
if (!function_exists('get_site_by_path')) {
warn_with_message('Mercator requires <a href="https://wordpress.org/download/">WordPress 3.9</a> or newer. Update now.');
return;
}
// M: We have clearance, Clarence.
// O: Roger, Roger. What's our Vector Victor?
startup();
}
示例7: __construct
public function __construct($sPluginFilePath, $sPluginHookPrefix = '', $sSetUpHook = 'plugins_loaded', $iPriority = 10)
{
if ($this->_hasLoaded()) {
return;
}
$this->sFilePath = $sPluginFilePath;
$this->bIsAdmin = is_admin();
$this->sHookPrefix = $sPluginHookPrefix;
$this->sSetUpHook = $sSetUpHook;
$this->iPriority = $iPriority;
$_bValid = $this->start();
if (false === $_bValid) {
return;
}
$this->setConstants();
$this->setGlobals();
$this->_registerClasses();
register_activation_hook($this->sFilePath, array($this, 'replyToPluginActivation'));
register_deactivation_hook($this->sFilePath, array($this, 'replyToPluginDeactivation'));
if (!$this->sSetUpHook || did_action($this->sSetUpHook)) {
$this->_replyToLoadPluginComponents();
} else {
add_action($this->sSetUpHook, array($this, '_replyToLoadPluginComponents'), $this->iPriority);
}
add_action('init', array($this, 'setLocalization'));
$this->construct();
}
示例8: register
/**
* Method for registering new EE_PMT_Base children
*
* @since 4.5.0
* @param string $payment_method_id a unique identifier for this set of modules Required.
* @param array $setup_args an array of arguments provided for registering modules Required.{
* @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class
* (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains the files
* EE_PMT_Payomatic.pm.php)
* }
* @throws EE_Error
* @internal param string payment_method_paths an array of full server paths to folders containing any EE_PMT_Base children, or to the EED_Module files themselves
* @return void
*/
public static function register($payment_method_id = NULL, $setup_args = array())
{
//required fields MUST be present, so let's make sure they are.
if (empty($payment_method_id) || !is_array($setup_args) || empty($setup_args['payment_method_paths'])) {
throw new EE_Error(__('In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', 'event_espresso'));
}
//make sure we don't register twice
if (isset(self::$_settings[$payment_method_id])) {
return;
}
//make sure this was called in the right place!
if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')) {
EE_Error::doing_it_wrong(__METHOD__, __('An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', 'event_espresso'), '4.3.0');
}
//setup $_settings array from incoming values.
self::$_settings[$payment_method_id] = array('payment_method_paths' => isset($setup_args['payment_method_paths']) ? (array) $setup_args['payment_method_paths'] : array());
// add to list of modules to be registered
add_filter('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', array('EE_Register_Payment_Method', 'add_payment_methods'));
/**
* If EE_Payment_Method_Manager::register_payment_methods has already been called, we need it to be called again
* (because it's missing the paymetn method we JUST registered here). We are assuming EE_Register_payment_method::register()
* will be called only once per payment method from an addon, so going with that assumption we should always do this.
* If that assumption is false, we should verify this newly-registered paymetn method isn't on the EE_Payment_Method_Manager::_payment_method_types array before calling this (this code should be changed to improve performance)
*/
if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) {
EE_Registry::instance()->load_lib('Payment_Method_Manager');
EE_Payment_Method_Manager::instance()->maybe_register_payment_methods(TRUE);
}
}
示例9: init
/**
* Initialize the plugin, registering WordPress hooks.
*/
public static function init()
{
if (did_action('plugins_loaded')) {
self::plugin_textdomain();
} else {
add_action('plugins_loaded', array('SemanticLinkbacksPlugin', 'plugin_textdomain'), 99);
}
// hook into linkback functions to add more semantics
// FIXME temporarily removed because it does not support updates
// add_action( 'comment_post', array( 'SemanticLinkbacksPlugin', 'linkback_fix' ), 9 );
add_action('pingback_post', array('SemanticLinkbacksPlugin', 'linkback_fix'), 9);
// FIXME temporarily added because the `comment_post` does not support updates
add_action('trackback_post', array('SemanticLinkbacksPlugin', 'linkback_fix'), 9);
add_action('webmention_post', array('SemanticLinkbacksPlugin', 'linkback_fix'), 9);
add_filter('pre_get_avatar_data', array('SemanticLinkbacksPlugin', 'pre_get_avatar_data'), 11, 5);
// To extend or to override the default behavior, just use the `comment_text` filter with a lower
// priority (so that it's called after this one) or remove the filters completely in
// your code: `remove_filter('comment_text', array('SemanticLinkbacksPlugin', 'comment_text_add_cite'), 11);`
add_filter('comment_text', array('SemanticLinkbacksPlugin', 'comment_text_add_cite'), 11, 3);
add_filter('comment_text', array('SemanticLinkbacksPlugin', 'comment_text_excerpt'), 12, 3);
add_filter('comment_excerpt', array('SemanticLinkbacksPlugin', 'comment_text_excerpt'), 5, 2);
add_filter('get_comment_link', array('SemanticLinkbacksPlugin', 'get_comment_link'), 99, 3);
add_filter('get_comment_author_url', array('SemanticLinkbacksPlugin', 'get_comment_author_url'), 99, 3);
add_filter('get_avatar_comment_types', array('SemanticLinkbacksPlugin', 'get_avatar_comment_types'));
add_filter('comment_class', array('SemanticLinkbacksPlugin', 'comment_class'), 10, 4);
}
示例10: test__transition_post_status__ignore_when_locked
public function test__transition_post_status__ignore_when_locked()
{
// The first update sets the lock so the action should only fire once when updating twice
\wp_transition_post_status('publish', 'publish', $this->post);
\wp_transition_post_status('publish', 'publish', $this->post);
$this->assertEquals(1, did_action('wpcom_vip_bump_lastpostmodified'));
}
示例11: register
/**
* Used to register capability items with EE core.
*
* @since 4.5.0
*
* @param string $cap_reference usually will be a class name that references capability related items setup for something.
* @param array $setup_args {
* An array of items related to registering capabilities.
* @type array $capabilities An array mapping capability strings to core WP Role. Something like array( 'administrator' => array( 'read_cap', 'edit_cap', 'delete_cap'), 'author' => array( 'read_cap' ) ).
* @type array $capability_maps EE_Meta_Capability_Map[] @see EE_Capabilities.php for php docs on these objects. Should be indexed by the classname for the capability map and values representing the arguments for the map.
* }
* @throws EE_Error
* @return void
*/
public static function register($cap_reference = NULL, $setup_args = array())
{
//required fields MUST be present, so let's make sure they are.
if (!isset($cap_reference) || !is_array($setup_args) || empty($setup_args['capabilities'])) {
throw new EE_Error(__('In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', 'event_espresso'));
}
//make sure we don't register twice
if (isset(self::$_registry[$cap_reference])) {
return;
}
//make sure this is not registered too late or too early.
if (!did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
EE_Error::doing_it_wrong(__METHOD__, sprintf(__('%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', 'event_espresso'), $cap_reference), '4.5.0');
}
//some preliminary sanitization and setting to the $_registry property
self::$_registry[$cap_reference] = array('caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) ? $setup_args['capabilities'] : array(), 'cap_maps' => isset($setup_args['capability_maps']) ? $setup_args['capability_maps'] : array());
//set initial caps (note that EE_Capabilities takes care of making sure that the caps get added donly once)
add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array('EE_Register_Capabilities', 'register_capabilities'), 10);
//add filter for cap maps
add_filter('FHEE__EE_Capabilities___set_meta_caps__meta_caps', array('EE_Register_Capabilities', 'register_cap_maps'), 10);
//init_role_caps to register new capabilities
if (is_admin()) {
EE_Registry::instance()->load('Capabilities');
EE_Capabilities::instance()->init_caps();
}
}
示例12: display
function display($args = array())
{
/* Use the generic_content action if it's set. See http://core.trac.wordpress.org/ticket/20509 */
if ($this->get_setting('mode', 'default') == 'default' && has_action('generic_content') && !did_action('generic_content')) {
return do_action('generic_content');
}
/* Since it's impossible to get the $wp_query in its correct form when loading the content from admin-ajax.php, we will display this notice. */
if (headway_get('ve-live-content-query', $this->block, false) && $this->get_setting('mode', 'default') == 'default') {
echo '<div class="alert alert-yellow" style="margin: 5px;"><p><strong>Please note:</strong> What\'s being displayed here in the Content Block may not be correct. When viewing the site outside of the Visual Editor, you will see the correct content.</p></div>';
}
/* If LoopBuddy is activated, we'll strictly rely on it for the query setup and how the content is displayed. */
if (class_exists('pluginbuddy_loopbuddy')) {
global $pluginbuddy_loopbuddy;
$loopbuddy_query = $this->get_setting('loopbuddy-query', -1);
$loopbuddy_layout = $this->get_setting('loopbuddy-layout', -1);
if (isset($pluginbuddy_loopbuddy) && $loopbuddy_query !== -1) {
echo $pluginbuddy_loopbuddy->render_loop($loopbuddy_query, $loopbuddy_layout);
$this->remove_hooks();
return;
}
}
/* Display the 404 text if it's a 404 (has to be default behavior) */
if (is_404() && $this->get_setting('mode', 'default') == 'default' && !headway_get('ve-live-content-query', $this->block, false)) {
$this->remove_hooks();
return $this->display_404();
}
/* Display loop like normal if nothing else fires first */
$this->loop($args);
$this->remove_hooks();
wp_reset_query();
}
示例13: test_get_answer
/**
* Test for the get_answer() method.
*
* @covers HookOracle::get_answer()
*
* @return void
*/
public function test_get_answer()
{
$testee = new HookOracle();
$this->assertSame('42', $testee->get_answer(), 'get_answer() should return the expected answer.');
$this->assertSame(1, did_action('give_answer'));
$this->assertTrue(Monkey::filters()->applied('the_answer') > 0);
}
示例14: output_filters
public function output_filters()
{
global $listify_facetwp;
if (did_action('listify_output_results') && 'side' == $this->position()) {
return;
}
if ('side' == $this->position()) {
$after = $before = '';
} else {
$before = '<div class="row">';
$after = '</div>';
}
$facets = $listify_facetwp->get_facets();
$count = count($facets);
$count = floor(12 / ($count == 0 ? 1 : $count));
$columns = 'col-lg-' . $count . ' col-md-6 col-sm-12';
$class = '';
if ('side' == $this->position()) {
$columns = null;
$class = 'widget';
}
echo '<a href="#" data-toggle=".job_filters" class="js-toggle-area-trigger">' . __('Toggle Filters', 'listify') . '</a>';
echo '<div class="job_filters content-box ' . $this->position() . '">';
echo $before;
echo $this->output_facets();
echo $after;
echo '</div>';
}
示例15: construct
/**
* Constructor
*/
public static function construct()
{
/**
* The auto-switch should always work
*/
self::_load_plugin_list();
self::_setup_automatic_switch();
/**
* The rest relies on user privileges, and therefore must wait until necessary WP functions are loaded
*/
if (!did_action('plugins_loaded')) {
_doing_it_wrong(__METHOD__, __('Must call in of after the "plugins_loaded" action.', 'redux-framework'), '14.03.19');
return;
}
/**
* Low-level users won't see anything
*/
if (!current_user_can(TIVWP_DM::MIN_CAPABILITY)) {
return;
}
/**
* The main actions happen in the admin area
*/
if (is_admin()) {
self::_setup_i18n();
self::_setup_plugin_composer();
self::_setup_admin_interface();
}
}