本文整理汇总了PHP中has_action函数的典型用法代码示例。如果您正苦于以下问题:PHP has_action函数的具体用法?PHP has_action怎么用?PHP has_action使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_action函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWL_Metabox_constructor
function testWL_Metabox_constructor()
{
$metabox = new WL_Metabox();
// Verify the object has hooked correctly (default priority for hooks is 10)
$this->assertEquals(10, has_action('add_meta_boxes', array($metabox, 'add_main_metabox')));
$this->assertEquals(10, has_action('wl_linked_data_save_post', array($metabox, 'save_form_data')));
}
示例2: __construct
/**
* Constructor
*
* @access public
* @since 1.0.0
*/
public function __construct($version)
{
$this->options = $this->_initOptions();
$this->version = $version;
//Actions
add_action('init', array($this, 'init'));
add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_scripts'));
add_filter('plugin_action_links_' . plugin_basename(dirname(__FILE__) . '/init.php'), array($this, 'action_links'));
add_action('woocommerce_settings_tabs_yith_wcas', array($this, 'print_plugin_options'));
add_action('woocommerce_update_options_yith_wcas', array($this, 'update_options'));
add_action('woocommerce_admin_field_banner', array($this, 'admin_fields_banner'));
if (!has_action('woocommerce_admin_field_slider')) {
add_action('woocommerce_admin_field_slider', array($this, 'admin_fields_slider'));
}
if (!has_action('woocommerce_admin_field_picker')) {
add_action('woocommerce_admin_field_picker', array($this, 'admin_fields_picker'));
}
add_action('woocommerce_update_option_slider', array($this, 'admin_update_option'));
add_action('woocommerce_update_option_picker', array($this, 'admin_update_option'));
//Filters
add_filter('woocommerce_settings_tabs_array', array($this, 'add_tab_woocommerce'), 30);
//add_filter( 'woocommerce_catalog_settings', array( $this, 'add_catalog_image_size' ) );
//Apply filters
$this->banner_url = apply_filters('yith_wcas_banner_url', $this->banner_url);
// YITH WCAS Loaded
do_action('yith_wcas_loaded');
}
示例3: set_theme_option
/**
* Sets option defaults
*
* @since 1.7.0
*/
function set_theme_option()
{
// Load settings
$optionsframework_settings = get_option('optionsframework');
// Updates the unique option id in the database if it has changed
if (function_exists('optionsframework_option_name')) {
optionsframework_option_name();
} elseif (has_action('optionsframework_option_name')) {
do_action('optionsframework_option_name');
} else {
$default_themename = get_option('stylesheet');
$default_themename = preg_replace("/\\W/", "_", strtolower($default_themename));
$default_themename = 'optionsframework_' . $default_themename;
if (isset($optionsframework_settings['id'])) {
if ($optionsframework_settings['id'] == $default_themename) {
// All good, using default theme id
} else {
$optionsframework_settings['id'] = $default_themename;
update_option('optionsframework', $optionsframework_settings);
}
} else {
$optionsframework_settings['id'] = $default_themename;
update_option('optionsframework', $optionsframework_settings);
}
}
}
示例4: __construct
/**
* Build The Layout
*/
function __construct($args = array(), PL_Platform $platform)
{
$this->platform = $platform;
$defaults = array('title' => '', 'callback' => false, 'page_slug' => '', 'config' => array(), 'render' => 'settings');
$this->set = wp_parse_args($args, $defaults);
/** Gets the control array */
$this->config = isset($this->set['callback']) && $this->set['callback'] ? call_user_func($this->set['callback']) : $this->set['config'];
$this->current_tab_slug = isset($_GET['sel_tab']) ? $_GET['sel_tab'] : 'default';
$this->settings_tab_slug = isset($_GET['settings_tab']) ? $_GET['settings_tab'] : 'default';
$tab_default = array('title' => '', 'groups' => false, 'mode' => 'banner');
$current_tab_info = isset($this->config[$this->current_tab_slug]) ? $this->config[$this->current_tab_slug] : current($this->config);
$this->current_tab_config = wp_parse_args($current_tab_info, $tab_default);
$this->current_page = $this->platform->tab();
// Draw the thing
$this->build_header();
// if not logged in and user is a super admin.. show banner to connect account
if ('account' == $this->current_page && !$this->platform->oauth->is_connected() && is_super_admin()) {
$this->platform_banner();
} elseif (has_action('pl_ui_build_body')) {
do_action('pl_ui_build_body', $this);
} else {
$this->build_body();
}
$this->build_footer();
}
示例5: render_admin_page_contents
public function render_admin_page_contents()
{
$tab = $this->get_active_tab();
switch ($tab) {
case 'general':
$this->render_general_tab();
break;
case 'csv-importer':
$this->render_csv_tab();
break;
default:
include Tribe__Events__Importer__Plugin::path('src/io/csv/admin-views/header.php');
if (has_action('tribe-import-render-tab-' . $tab)) {
/**
* Remove this Action on 4.3
* @deprecated
*/
_doing_it_wrong('tribe-import-render-tab-' . $tab, sprintf(esc_html__('This Action has been deprecated, to comply with WordPress Standards we are now using Underscores (_) instead of Dashes (-). From: "%s" To: "%s"', 'the-events-calendar'), 'tribe-import-render-tab-' . $tab, 'tribe_import_render_tab_' . $tab), '4.0');
do_action('tribe-import-render-tab-' . $tab);
}
do_action('tribe_import_render_tab_' . $tab);
include Tribe__Events__Importer__Plugin::path('src/io/csv/admin-views/footer.php');
break;
}
}
示例6: __construct
/**
* Constructor.
*
* Supplied $args override class property defaults.
*
* If $args['fields'] is not defined, use the $id as the field ID.
*
* @since 3.4.0
*
* @param WP_Customize_Manager $manager
* @param string $id
* @param array $args
*/
public function __construct($manager, $id, $args = array())
{
$this->manager = $manager;
$this->object_name = $this->manager->get_customizer_object_name();
// Backwards compatibility for old property names
foreach ($this->property_map as $backcompat_arg => $actual_arg) {
if (isset($args[$backcompat_arg])) {
$args[$actual_arg] = $args[$backcompat_arg];
unset($args[$backcompat_arg]);
}
}
parent::__construct($this->object_type, $id, $args);
if (empty($this->active_callback)) {
$this->active_callback = array($this, 'active_callback');
}
if (!has_action('fields_render_control_' . $this->object_type, array('WP_Customize_Control', 'customize_render_control'))) {
add_action('fields_render_control_' . $this->object_type, array('WP_Customize_Control', 'customize_render_control'));
}
if (!has_filter('fields_control_active_' . $this->object_type, array('WP_Customize_Control', 'customize_control_active'))) {
add_filter('fields_control_active_' . $this->object_type, array('WP_Customize_Control', 'customize_control_active'), 10, 2);
}
if ('' !== $this->id) {
add_action('fields_render_control_' . $this->object_type . '_' . $this->object_name . '_' . $this->id, array('WP_Customize_Control', 'customize_render_control_id'));
}
}
示例7: handle_deprecation
public static function handle_deprecation($data)
{
// determine the current filter
$current_filter = current_filter();
// figure out if the current filter is actually in our map list
if (isset(self::$map[$current_filter])) {
// get a list of this function call's args, for use when calling deprecated filters
$args = func_get_args();
array_unshift($args, null);
// get the list of all the potential old filters
$old_filters = (array) self::$map[$current_filter];
// for each matching old filter we have..
foreach ($old_filters as $old_filter_info) {
list($old_filter, $deprecation_version) = $old_filter_info;
// if there is a register function on that old filter
if (has_action($old_filter)) {
// then call those register functions
$args[0] = $old_filter;
$data = call_user_func_array('apply_filters', $args);
// pop the deprecation message
_deprecated_function(sprintf(__('The "%s" filter', 'opentickets-community-edition'), $old_filter), $deprecation_version, sprintf(__('The "%s" filter', 'opentickets-community-edition'), $current_filter));
}
}
}
return $data;
}
示例8: save_schemes_into_option
/**
* Save schemes to option allow front-end query
*/
function save_schemes_into_option()
{
global $_wp_admin_css_colors;
if (count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker')) {
update_option('wp_admin_color_schemes', $_wp_admin_css_colors);
}
}
示例9: __construct
public function __construct()
{
//load conf data into stack
$this->_get_conf();
if (is_admin()) {
// update notices
$this->readme_URL = 'http://plugins.trac.wordpress.org/browser/fv-wordpress-flowplayer/trunk/readme.txt?format=txt';
if (!has_action('in_plugin_update_message-fv-wordpress-flowplayer/flowplayer.php')) {
add_action('in_plugin_update_message-fv-wordpress-flowplayer/flowplayer.php', array(&$this, 'plugin_update_message'));
}
// pointer boxes
parent::__construct();
}
// define needed constants
if (!defined('FV_FP_RELATIVE_PATH')) {
define('FV_FP_RELATIVE_PATH', flowplayer::get_plugin_url());
$vid = 'http://' . $_SERVER['SERVER_NAME'];
if (dirname($_SERVER['PHP_SELF']) != '/') {
$vid .= dirname($_SERVER['PHP_SELF']);
}
define('VIDEO_DIR', '/videos/');
define('VIDEO_PATH', $vid . VIDEO_DIR);
}
add_filter('fv_flowplayer_caption', array($this, 'get_duration_playlist'), 10, 3);
add_filter('fv_flowplayer_inner_html', array($this, 'get_duration_video'), 10, 2);
add_filter('fv_flowplayer_video_src', array($this, 'get_amazon_secure'), 10, 2);
add_filter('fv_flowplayer_css_writeout', array($this, 'css_writeout_option'));
add_action('wp_enqueue_scripts', array($this, 'css_enqueue'));
add_action('admin_enqueue_scripts', array($this, 'css_enqueue'));
add_filter('post_rewrite_rules', array($this, 'rewrite_embed'));
add_filter('page_rewrite_rules', array($this, 'rewrite_embed'));
add_filter('query_vars', array($this, 'rewrite_vars'));
add_filter('init', array($this, 'rewrite_check'));
add_action('template_redirect', array($this, 'template_embed'));
}
示例10: __invoke
function __invoke()
{
$args = func_get_args();
$message_name = $this->get_message_name();
$event_before = $message_name . '_before';
if (has_action($event_before)) {
do_action_ref_array($event_before, $args);
}
$event_pre = $message_name . '_args';
if (has_filter($event_pre)) {
$args = apply_filters_ref_array($event_pre, $args);
}
$result = null;
$fn = $this->find_real_function($args);
if (is_callable($fn)) {
$result = call_user_func_array($fn, $args);
}
if (has_filter($message_name)) {
$new_args = array_merge(array($result), $args);
$result = apply_filters_ref_array($message_name, $new_args);
}
$event_after = $message_name . '_after';
if (has_action($event_after)) {
do_action_ref_array($event_after, array_merge($args, array($result)));
}
return $result;
}
示例11: init
/**
* Bootstraps the class and hooks required actions & filters.
*
* @since 2.0
*/
public static function init()
{
self::$paypal_settings = self::get_options();
// wc-api handler for express checkout transactions
if (!has_action('woocommerce_api_wcs_paypal')) {
add_action('woocommerce_api_wcs_paypal', __CLASS__ . '::handle_wc_api');
}
// When necessary, set the PayPal args to be for a subscription instead of shopping cart
add_action('woocommerce_update_options_payment_gateways_paypal', __CLASS__ . '::reload_options', 100);
// When necessary, set the PayPal args to be for a subscription instead of shopping cart
add_action('woocommerce_update_options_payment_gateways_paypal', __CLASS__ . '::are_reference_transactions_enabled', 100);
// When necessary, set the PayPal args to be for a subscription instead of shopping cart
add_filter('woocommerce_paypal_args', __CLASS__ . '::get_paypal_args', 10, 2);
// Check a valid PayPal IPN request to see if it's a subscription *before* WCS_Gateway_Paypal::successful_request()
add_action('valid-paypal-standard-ipn-request', __CLASS__ . '::process_ipn_request', 0);
add_action('woocommerce_scheduled_subscription_payment_paypal', __CLASS__ . '::process_subscription_payment', 10, 2);
// Don't copy over PayPal details to Resubscribe Orders
add_filter('wcs_resubscribe_order_created', __CLASS__ . '::remove_resubscribe_order_meta', 10, 2);
// Triggered by WCS_SV_API_Base::broadcast_request() whenever an API request is made
add_action('wc_paypal_api_request_performed', __CLASS__ . '::log_api_requests', 10, 2);
add_filter('woocommerce_subscriptions_admin_meta_boxes_script_parameters', __CLASS__ . '::maybe_add_change_payment_method_warning');
WCS_PayPal_Supports::init();
WCS_PayPal_Status_Manager::init();
WCS_PayPal_Standard_Switcher::init();
if (is_admin()) {
WCS_PayPal_Admin::init();
WCS_PayPal_Change_Payment_Method_Admin::init();
}
}
示例12: __construct
function __construct($theme)
{
$this->theme = $theme;
// Don't bother doing this stuff if the current user lacks permissions
if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
return;
}
// Add only in Rich Editor mode
if (get_user_option('rich_editing') == 'true') {
add_filter('mce_external_plugins', array($this, 'oxy_add_mce_shortcode_plugin'));
add_filter('mce_buttons', array(&$this, 'oxy_add_mce_shortcode_button'));
}
// enqueue scripts & styles
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
// add tinyMCE shortcode plugin
add_action('admin_init', array(&$this, 'oxy_add_mce_shortcode'));
// add action for loading shortcode page
add_action('wp_ajax_oxy_shortcodes', array(&$this, 'oxy_load_mce_shortcode_page'));
// add action for loading shortcode page
add_action('wp_ajax_oxy_shortcode_preview', array(&$this, 'oxy_load_mce_shortcode_preview'));
// add action for loading menu data
add_action('wp_ajax_oxy_shortcodes_menu', array(&$this, 'oxy_load_mce_shortcode_menu'));
// remove wordpress 3.6 action that is undocumented and throws notices.
if (has_action('admin_enqueue_scripts', 'wp_auth_check_load')) {
remove_action('admin_enqueue_scripts', 'wp_auth_check_load');
}
}
示例13: wc_do_deprecated_action
/**
* Runs a deprecated action with notice only if used.
*
* @since 2.7.0
* @param string $action
* @param array $args
* @param string $deprecated_in
* @param string $replacement
*/
function wc_do_deprecated_action($action, $args, $deprecated_in, $replacement)
{
if (has_action($action)) {
wc_deprecated_function('Action: ' . $action, $deprecated_in, $replacement);
do_action_ref_array($action, $args);
}
}
示例14: maybe_show_admin_notices
/**
* Display an assortment of notices to administrators to encourage them to get PayPal setup right.
*
* @since 2.0
*/
public static function maybe_show_admin_notices()
{
self::maybe_disable_invalid_profile_notice();
self::maybe_update_credentials_error_flag();
if (!in_array(get_woocommerce_currency(), apply_filters('woocommerce_paypal_supported_currencies', array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB')))) {
$valid_for_use = false;
} else {
$valid_for_use = true;
}
$payment_gateway_tab_url = admin_url('admin.php?page=wc-settings&tab=checkout§ion=wc_gateway_paypal');
$notices = array();
if ($valid_for_use && 'yes' == WCS_PayPal::get_option('enabled') && !has_action('admin_notices', 'WC_Subscriptions_Admin::admin_installed_notice') && current_user_can('manage_options')) {
if (!WCS_PayPal::are_credentials_set()) {
$notices[] = array('type' => 'warning', 'text' => sprintf(esc_html__('PayPal is inactive for subscription transactions. Please %1$sset up the PayPal IPN%2$s and %3$senter your API credentials%4$s to enable PayPal for Subscriptions.', 'woocommerce-subscriptions'), '<a href="http://docs.woothemes.com/document/subscriptions/store-manager-guide/#section-4" target="_blank">', '</a>', '<a href="' . esc_url($payment_gateway_tab_url) . '">', '</a>'));
} elseif ('woocommerce_page_wc-settings' === get_current_screen()->base && isset($_GET['tab']) && in_array($_GET['tab'], array('subscriptions', 'checkout')) && !WCS_PayPal::are_reference_transactions_enabled()) {
$notices[] = array('type' => 'warning', 'text' => sprintf(esc_html__('%1$sPayPal Reference Transactions are not enabled on your account%2$s, some subscription management features are not enabled. Please contact PayPal and request they %3$senable PayPal Reference Transactions%4$s on your account. %5$sCheck PayPal Account%6$s %7$sLearn more %8$s', 'woocommerce-subscriptions'), '<strong>', '</strong>', '<a href="http://docs.woothemes.com/document/subscriptions/store-manager-guide/#section-4" target="_blank">', '</a>', '</p><p><a class="button" href="' . esc_url(wp_nonce_url(add_query_arg('wcs_paypal', 'check_reference_transaction_support'), __CLASS__)) . '">', '</a>', '<a class="button button-primary" href="http://docs.woothemes.com/document/subscriptions/store-manager-guide/#section-4" target="_blank">', '»</a>'));
}
if (isset($_GET['wcs_paypal']) && 'rt_enabled' === $_GET['wcs_paypal']) {
$notices[] = array('type' => 'confirmation', 'text' => sprintf(esc_html__('%1$sPayPal Reference Transactions are enabled on your account%2$s. All subscription management features are now enabled. Happy selling!', 'woocommerce-subscriptions'), '<strong>', '</strong>'));
}
if (false !== get_option('wcs_paypal_credentials_error')) {
$notices[] = array('type' => 'error', 'text' => sprintf(esc_html__('There is a problem with PayPal. Your API credentials may be incorrect. Please update your %1$sAPI credentials%2$s. %3$sLearn more%4$s.', 'woocommerce-subscriptions'), '<a href="' . esc_url($payment_gateway_tab_url) . '">', '</a>', '<a href="https://support.woothemes.com/hc/en-us/articles/202882473#paypal-credentials" target="_blank">', '</a>'));
}
if ('yes' == get_option('wcs_paypal_invalid_profile_id')) {
$notices[] = array('type' => 'error', 'text' => sprintf(esc_html__('There is a problem with PayPal. Your PayPal account is issuing out-of-date subscription IDs. %1$sLearn more%2$s. %3$sDismiss%4$s.', 'woocommerce-subscriptions'), '<a href="https://support.woothemes.com/hc/en-us/articles/202882473#old-paypal-account" target="_blank">', '</a>', '<a href="' . esc_url(add_query_arg('wcs_disable_paypal_invalid_profile_id_notice', 'true')) . '">', '</a>'));
}
}
if (!empty($notices)) {
include_once dirname(__FILE__) . '/../templates/admin-notices.php';
}
}
示例15: test_file_hooks
/**
* Test if all the file hooks are working.
*
* @since 1.0
*/
public function test_file_hooks()
{
$this->assertNotFalse(has_action('wp_enqueue_scripts', 'give_load_scripts'));
$this->assertNotFalse(has_action('wp_enqueue_scripts', 'give_register_styles'));
$this->assertNotFalse(has_action('admin_enqueue_scripts', 'give_load_admin_scripts'));
$this->assertNotFalse(has_action('admin_head', 'give_admin_icon'));
}