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


PHP doing_action函数代码示例

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


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

示例1: wp_get_nav_menu_items

 public function wp_get_nav_menu_items($items)
 {
     if (doing_action('customize_register')) {
         // needed since WP 4.3, doing_action available since WP 3.9
         return $items;
     }
     // the customizer menus does not sort the items and we need them to be sorted before splitting the language switcher
     usort($items, array($this, 'usort_menu_items'));
     $new_items = array();
     $offset = 0;
     foreach ($items as $key => $item) {
         if ($options = get_post_meta($item->ID, '_pll_menu_item', true)) {
             $i = 0;
             foreach (pll_the_languages(array_merge(array('raw' => 1), $options)) as $lang) {
                 $lang_item = clone $item;
                 $lang_item->ID = $lang_item->ID . '-' . $lang['slug'];
                 // a unique ID
                 $lang_item->title = $options['show_flags'] && $options['show_names'] ? $lang['flag'] . ' ' . esc_html($lang['name']) : ($options['show_flags'] ? $lang['flag'] : esc_html($lang['name']));
                 $lang_item->url = $lang['url'];
                 $lang_item->lang = $lang['slug'];
                 // save this for use in nav_menu_link_attributes
                 $lang_item->classes = $lang['classes'];
                 $lang_item->menu_order += $offset + $i++;
                 $new_items[] = $lang_item;
             }
             $offset += $i - 1;
         } else {
             $item->menu_order += $offset;
             $new_items[] = $item;
         }
     }
     return $new_items;
 }
开发者ID:WordPressArt,项目名称:conisia,代码行数:33,代码来源:frontend-nav-menu.php

示例2: wpcd_get_customizer_setting

 function wpcd_get_customizer_setting($panel_slug, $field_slug, $formatted = false)
 {
     if (doing_action('wpcd') || !did_action('wpcd')) {
         if ('general' === $panel_slug) {
             $setting = get_theme_mod($field_slug, null);
             if (!$setting) {
                 $setting = get_option($field_slug, null);
             }
             return $setting;
         }
         $settings = get_theme_mod($panel_slug, array());
         if (!isset($settings[$field_slug])) {
             $settings = get_option($panel_slug, array());
         }
         return isset($settings[$field_slug]) ? $settings[$field_slug] : null;
     }
     $setting = null;
     $field = \WPDLib\Components\Manager::get($panel_slug . '.*.' . $field_slug, 'WPCD\\Components\\Panel', true);
     if ($field) {
         if ('general' === $panel_slug) {
             $setting = \WPCD\Utility::parse_setting('option' === $field->mode ? get_option($field->slug, null) : get_theme_mod($field->slug, null), $field, $formatted);
         } else {
             if ('option' === $field->mode) {
                 $_options = get_option($panel_slug, array());
                 $setting = \WPCD\Utility::parse_setting(isset($_options[$field->slug]) ? $_options[$field->slug] : null, $field, $formatted);
             } else {
                 $_thememods = get_theme_mod($panel_slug, array());
                 $setting = \WPCD\Utility::parse_setting(isset($_thememods[$field->slug]) ? $_thememods[$field->slug] : null, $field, $formatted);
             }
         }
     }
     return $setting;
 }
开发者ID:felixarntz,项目名称:customizer-definitely,代码行数:33,代码来源:functions.php

示例3: pinterest_embed_handler

function pinterest_embed_handler($matches, $attr, $url)
{
    // Pinterest's JS handles making the embed
    $script_src = '//assets.pinterest.com/js/pinit.js';
    wp_enqueue_script('pinterest-embed', $script_src, array(), false, true);
    $path = parse_url($url, PHP_URL_PATH);
    if (0 === strpos($path, '/pin/')) {
        $embed_type = 'embedPin';
    } elseif (preg_match('#^/([^/]+)/?$#', $path)) {
        $embed_type = 'embedUser';
    } elseif (preg_match('#^/([^/]+)/([^/]+)/?$#', $path)) {
        $embed_type = 'embedBoard';
    } else {
        if (current_user_can('edit_posts')) {
            return __('Sorry, that Pinterest URL was not recognized.', 'jetpack');
        }
        return;
    }
    $return = sprintf('<a data-pin-do="%s" href="%s"></a>', esc_attr($embed_type), esc_url($url));
    // If we're generating an embed view for the WordPress Admin via ajax...
    if (doing_action('wp_ajax_parse-embed')) {
        $return .= sprintf('<script src="%s"></script>', esc_url($script_src));
    }
    return $return;
}
开发者ID:automattic,项目名称:jetpack,代码行数:25,代码来源:pinterest.php

示例4: filter_notifications_body

 public function filter_notifications_body($message)
 {
     if (doing_action('wpem_new_user_notification_body')) {
         $id = 'wp_new_user_notification';
     } elseif (doing_action('retrieve_password_message')) {
         $id = 'password_reset';
     } elseif (doing_action('wpmu_signup_user_notification_email')) {
         $id = 'wpmu_signup_user_notification';
     } elseif (doing_action('wpmu_signup_blog_notification_email')) {
         $id = 'wpmu_signup_blog_notification';
     } elseif (doing_action('update_welcome_email')) {
         $id = 'wpmu_welcome_notification';
     }
     $notification = $this->get_notification($id);
     if (isset($notification['use_custom'])) {
         remove_filter('wp_mail', 'EM_Mailer::add_default_template');
         $message = str_replace('[' . __('system-message', 'wpem') . ']', $message, $notification['body']);
         if ($notification['mail_format'] == 'html') {
             $style = get_post_meta($notification['template'], 'wpem_css-box-field', true);
             add_filter('wp_mail', 'EM_Mailer::add_html_headers');
             $message = '<html><head><style>' . $style . '</style><meta name="viewport" content="width=device-width"/><title>' . get_bloginfo('name') . '</title></head><body>' . $message . '</body></html>';
         }
     }
     return $message;
 }
开发者ID:etondeengole,项目名称:Store_Application,代码行数:25,代码来源:wpem-notifications-class.php

示例5: affwp_notify_on_approval

/**
 * Send email on affiliate approval
 *
 * @since 1.6
 * @param int $affiliate_id The ID of the registered affiliate
 * @param string $status
 * @param string $old_status
 */
function affwp_notify_on_approval($affiliate_id = 0, $status = '', $old_status = '')
{
    if (empty($affiliate_id)) {
        return;
    }
    /**
     * Only send email if:
     * Affiliate approval is disabled ( $status = active, $old_status = active )
     * Affiliate approval is enabled and the affiliate is accepted ( $status = active, $old_status = pending )
     */
    if (!('active' == $status && 'active' == $old_status || 'active' == $status && 'pending' == $old_status)) {
        return;
    }
    if (doing_action('affwp_add_affiliate') && empty($_POST['welcome_email'])) {
        return;
    }
    $emails = new Affiliate_WP_Emails();
    $emails->__set('affiliate_id', $affiliate_id);
    $email = affwp_get_affiliate_email($affiliate_id);
    $subject = affiliate_wp()->settings->get('accepted_subject', __('Affiliate Application Accepted', 'affiliate-wp'));
    $message = affiliate_wp()->settings->get('accepted_email', '');
    if (empty($message)) {
        $message = sprintf(__('Congratulations %s!', 'affiliate-wp'), affiliate_wp()->affiliates->get_affiliate_name($affiliate_id)) . "\n\n";
        $message .= sprintf(__('Your affiliate application on %s has been accepted!', 'affiliate-wp'), home_url()) . "\n\n";
        $message .= sprintf(__('Log into your affiliate area at %s', 'affiliate-wp'), affiliate_wp()->login->get_login_url()) . "\n\n";
    }
    // $args is setup for backwards compatibility with < 1.6
    $args = array('affiliate_id' => $affiliate_id);
    $subject = apply_filters('affwp_application_accepted_subject', $subject, $args);
    $message = apply_filters('affwp_application_accepted_email', $message, $args);
    $emails->send($email, $subject, $message);
}
开发者ID:kknet,项目名称:AffiliateWP,代码行数:40,代码来源:actions.php

示例6: enlightenment_glyphicons_author_posts_link_args

function enlightenment_glyphicons_author_posts_link_args($args)
{
    if (!is_single() || doing_action('enlightenment_entry_header')) {
        $args['format'] = '<span class="glyphicon glyphicon-user"></span> ' . $args['format'];
    }
    return $args;
}
开发者ID:thano,项目名称:cfpi-theme-2016,代码行数:7,代码来源:glyphicons.php

示例7: wp_get_nav_menu_items

 /**
  * Splits the one item of backend in several items on frontend
  * take care to menu_order as it is used later in wp_nav_menu
  *
  * @since 1.1.1
  *
  * @param array $items menu items
  * @return array modified items
  */
 public function wp_get_nav_menu_items($items)
 {
     if (doing_action('customize_register')) {
         // needed since WP 4.3, doing_action available since WP 3.9
         return $items;
     }
     // The customizer menus does not sort the items and we need them to be sorted before splitting the language switcher
     usort($items, array($this, 'usort_menu_items'));
     $new_items = array();
     $offset = 0;
     foreach ($items as $key => $item) {
         if ($options = get_post_meta($item->ID, '_pll_menu_item', true)) {
             $i = 0;
             $switcher = new PLL_Switcher();
             $args = array_merge(array('raw' => 1), $options);
             $the_languages = $switcher->the_languages(PLL()->links, $args);
             // parent item for dropdown
             if (!empty($options['dropdown'])) {
                 $item->title = $options['show_flags'] && $options['show_names'] ? $this->curlang->flag . '&nbsp;' . esc_html($this->curlang->name) : ($options['show_flags'] ? $this->curlang->flag : esc_html($this->curlang->name));
                 $item->url = '';
                 $item->classes = array('pll-parent-menu-item');
                 $new_items[] = $item;
                 $offset++;
             }
             foreach ($the_languages as $lang) {
                 $lang_item = clone $item;
                 $lang_item->ID = $lang_item->ID . '-' . $lang['slug'];
                 // A unique ID
                 $lang_item->title = $options['show_flags'] && $options['show_names'] ? $lang['flag'] . '<span style="margin-left:0.3em;">' . esc_html($lang['name']) . '</span>' : ($options['show_flags'] ? $lang['flag'] : esc_html($lang['name']));
                 $lang_item->url = $lang['url'];
                 $lang_item->lang = $lang['locale'];
                 // Save this for use in nav_menu_link_attributes
                 $lang_item->classes = $lang['classes'];
                 $lang_item->menu_order += $offset + $i++;
                 if (!empty($options['dropdown'])) {
                     $lang_item->menu_item_parent = $item->db_id;
                     $lang_item->db_id = 0;
                     // to avoid recursion
                 }
                 $new_items[] = $lang_item;
             }
             $offset += $i - 1;
         } else {
             $item->menu_order += $offset;
             $new_items[] = $item;
         }
     }
     return $new_items;
 }
开发者ID:JoryHogeveen,项目名称:polylang,代码行数:58,代码来源:frontend-nav-menu.php

示例8: wpod_get_option

 /**
  * Returns a single specified option of a tab.
  *
  * This function uses the WordPress core function `get_option()` to get the options array for the tab.
  * If the required field option is not available, this function will automatically return its default value.
  *
  * @since 0.5.0
  * @param string $tab_slug the tab slug to get the option for
  * @param string $field_slug the field slug to get the option for
  * @param boolean $formatted whether to return an automatically formatted value, ready for output (default is false)
  * @return mixed the option
  */
 function wpod_get_option($tab_slug, $field_slug, $formatted = false)
 {
     $_options = get_option($tab_slug, array());
     if (doing_action('wpod') || !did_action('wpod')) {
         if (isset($_options[$field_slug])) {
             return $_options[$field_slug];
         }
         return null;
     }
     $option = null;
     $field = \WPDLib\Components\Manager::get('*.*.' . $tab_slug . '.*.' . $field_slug, 'WPDLib\\Components\\Menu.WPOD\\Components\\Screen', true);
     if ($field) {
         $option = \WPOD\Utility::parse_option(isset($_options[$field->slug]) ? $_options[$field->slug] : null, $field, $formatted);
     }
     return $option;
 }
开发者ID:felixarntz,项目名称:options-definitely,代码行数:28,代码来源:functions.php

示例9: enlightenment_simmulate_post_format

function enlightenment_simmulate_post_format($tab)
{
    global $wp_current_filter, $post, $wp_query;
    if (doing_action('enlightenment_before_page_builder')) {
    } elseif ('post_formats' == $tab) {
        $wp_query = new WP_Query(array('post_format' => 'post-format-' . enlightenment_current_post_format()));
        do_action_ref_array('wp', array(&$wp_query));
        the_post();
        if (current_theme_supports('enlightenment-grid-loop')) {
            if (isset($_GET['format']) && strpos($_GET['format'], '-teaser')) {
                add_filter('enlightenment_is_lead_post', '__return_false');
            } else {
                add_filter('enlightenment_is_lead_post', '__return_true');
            }
        }
        do_action('enlightenment_before_entry');
        // var_dump( get_post_format( $post->ID ) );
    }
}
开发者ID:thano,项目名称:cfpi-theme-2016,代码行数:19,代码来源:post-formats-editor.php

示例10: enlightenment_comments_number_wrap

function enlightenment_comments_number_wrap($output, $number)
{
    $args = array('container' => 'h3', 'container_class' => 'comments-title', 'container_id' => '', 'format' => __('%1$s for &ldquo;%2$s&rdquo;', 'enlightenment'), 'zero' => __('No Comments', 'enlightenment'), 'one' => __('1 Comment', 'enlightenment'), 'more' => __('% Comments', 'enlightenment'));
    $args = apply_filters('enlightenment_comments_number_wrap_args', $args);
    if ($number > 1) {
        $comments_number = str_replace('%', number_format_i18n($number), $args['more']);
    } elseif ($number == 0) {
        $comments_number = $args['zero'];
    } else {
        // must be one
        $comments_number = $args['one'];
    }
    if (doing_action('enlightenment_before_comments_list')) {
        $output = enlightenment_open_tag($args['container'], $args['container_class'], $args['container_id']);
        $output .= sprintf($args['format'], $comments_number, get_the_title());
        $output .= enlightenment_close_tag($args['container']);
        return $output;
    }
    return $comments_number;
}
开发者ID:brittbec13,项目名称:citizenmodern,代码行数:20,代码来源:comments.php

示例11: save_ajax_attachment_taxonomies

 /**
  * Sets terms for attachment taxonomies through the `save_attachment` AJAX action.
  *
  * This is a workaround to handle terms through this AJAX action as it normally does not support
  * terms.
  *
  * This method is hooked into the `add_attachment` and `edit_attachment` actions.
  *
  * @since 1.0.0
  * @access public
  *
  * @param integer $attachment_id The attachment ID.
  */
 public function save_ajax_attachment_taxonomies($attachment_id)
 {
     if (!doing_action('wp_ajax_save-attachment')) {
         return;
     }
     if (!isset($_REQUEST['changes'])) {
         return;
     }
     foreach (Attachment_Taxonomies_Core::instance()->get_taxonomies('objects') as $taxonomy) {
         if (!isset($_REQUEST['changes']['taxonomy-' . $taxonomy->name . '-terms'])) {
             continue;
         }
         $terms = $_REQUEST['changes']['taxonomy-' . $taxonomy->name . '-terms'];
         if ($taxonomy->hierarchical) {
             $terms = array_filter(array_map('trim', explode(',', $terms)));
         }
         if (current_user_can($taxonomy->cap->assign_terms)) {
             wp_set_post_terms($attachment_id, $terms, $taxonomy->name);
         }
     }
 }
开发者ID:felixarntz,项目名称:attachment-taxonomies,代码行数:34,代码来源:Taxonomy_Edit.php

示例12: wp_get_nav_menu_items

 public function wp_get_nav_menu_items($items)
 {
     if (function_exists('doing_action') && doing_action('customize_register') || is_admin()) {
         // needed since WP 4.3, doing_action available since WP 3.9
         return $items;
     }
     foreach ($items as $key => $item) {
         if ($options = get_post_meta($item->ID, '_off_canvas_control_menu_item', true)) {
             $item->url = '';
             if (isset($this->general_settings['sidebars'][$options['off-canvas-control']]) && 1 == $this->general_settings['sidebars'][$options['off-canvas-control']]['enable']) {
                 //$item->title = $options['show_flags'] && $options['show_names'] ? $lang['flag'].'&nbsp;'.esc_html($lang['name']) : ($options['show_flags'] ? $lang['flag'] : esc_html($lang['name']));
                 $link_classes = $this->link_classes;
                 if (!is_array($link_classes)) {
                     $link_classes = explode(' ', $link_classes);
                 }
                 if (!empty($options['off-canvas-control'])) {
                     $link_classes[] = $this->general_settings['css_prefix'] . '-toggle-' . $options['off-canvas-control'];
                 }
                 if (!is_array($item->classes)) {
                     $item->classes = explode(' ', $item->classes);
                 }
                 $item->classes = array_merge($item->classes, $link_classes);
             }
         }
     }
     return $items;
 }
开发者ID:JoryHogeveen,项目名称:off-canvas-sidebars,代码行数:27,代码来源:off-canvas-sidebars-menu-meta-box.class.php

示例13: __construct

 /**
  * Hook into queries, admin screens, and more!
  *
  * @since 0.1.0
  */
 public function __construct($file = '')
 {
     // Setup plugin
     $this->file = $file;
     $this->url = plugin_dir_url($this->file);
     $this->path = plugin_dir_path($this->file);
     $this->basename = plugin_basename($this->file);
     $this->fancy = apply_filters("wp_fancy_term_{$this->meta_key}", true);
     // Only look for taxonomies if not already set
     if (empty($this->taxonomies)) {
         $this->taxonomies = $this->get_taxonomies();
     }
     // Maybe build db version key
     if (empty($this->db_version_key)) {
         $this->db_version_key = "wpdb_term_{$this->meta_key}_version";
     }
     // Register Meta
     $this->register_meta();
     // Queries
     add_action('create_term', array($this, 'save_meta'), 10, 2);
     add_action('edit_term', array($this, 'save_meta'), 10, 2);
     // Term meta orderby
     add_filter('terms_clauses', array($this, 'terms_clauses'), 10, 3);
     add_filter('get_terms_orderby', array($this, 'get_terms_orderby'), 10, 1);
     // Always hook these in, for ajax actions
     foreach ($this->taxonomies as $value) {
         // Has column?
         if (true === $this->has_column) {
             add_filter("manage_edit-{$value}_columns", array($this, 'add_column_header'));
             add_filter("manage_{$value}_custom_column", array($this, 'add_column_value'), 10, 3);
             add_filter("manage_edit-{$value}_sortable_columns", array($this, 'sortable_columns'));
         }
         // Has fields?
         if (true === $this->has_fields) {
             add_action("{$value}_add_form_fields", array($this, 'add_form_field'));
             add_action("{$value}_edit_form_fields", array($this, 'edit_form_field'));
         }
     }
     // ajax actions
     add_action("wp_ajax_{$this->meta_key}_terms", array($this, 'ajax_update'));
     // Only blog admin screens
     if (is_blog_admin() || doing_action('wp_ajax_inline_save_tax')) {
         // Every admin page
         add_action('admin_init', array($this, 'admin_init'));
         // Bail if taxonomy does not include colors
         if (!empty($_REQUEST['taxonomy']) && in_array($_REQUEST['taxonomy'], $this->taxonomies, true)) {
             add_action('load-edit-tags.php', array($this, 'edit_tags_page'));
             add_action('load-term.php', array($this, 'term_page'));
         }
     }
     // Pass ths object into an action
     do_action("wp_term_meta_{$this->meta_key}_init", $this);
 }
开发者ID:stuttter,项目名称:wp-term-colors,代码行数:58,代码来源:class-wp-term-meta-ui.php

示例14: test_doing_action

 /**
  * @ticket 14994
  */
 function test_doing_action()
 {
     global $wp_current_filter;
     $wp_current_filter = array();
     // Set to an empty array first
     $this->assertFalse(doing_action());
     // No action is passed in, and no filter is being processed
     $this->assertFalse(doing_action('testing'));
     // Action is passed in but not being processed
     $wp_current_filter[] = 'testing';
     $this->assertTrue(doing_action());
     // No action is passed in, and a filter is being processed
     $this->assertTrue(doing_action('testing'));
     // Action is passed in and is being processed
     $this->assertFalse(doing_action('something_else'));
     // Action is passed in but not being processed
     $wp_current_filter = array();
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:21,代码来源:actions.php

示例15: enqueue_static

 /**
  * Enqueue option type scripts and styles
  *
  * All parameters are optional and will be populated with defaults
  * @param string $id
  * @param array $option
  * @param array $data
  * @return bool
  */
 public final function enqueue_static($id = '', $option = array(), $data = array())
 {
     if (!doing_action('admin_enqueue_scripts') && !did_action('admin_enqueue_scripts')) {
         /**
          * Do not wp_enqueue/register_...() because at this point not all handles has been registered
          * and maybe they are used in dependencies in handles that are going to be enqueued.
          * So as a result some handles will not be equeued because of not registered dependecies.
          */
         return;
     }
     static $option_types_static_enqueued = false;
     if (!$option_types_static_enqueued) {
         wp_enqueue_style('fw-option-types', fw_get_framework_directory_uri('/static/css/option-types.css'), array('fw', 'qtip'), fw()->manifest->get_version());
         wp_enqueue_script('fw-option-types', fw_get_framework_directory_uri('/static/js/option-types.js'), array('fw-events', 'qtip'), fw()->manifest->get_version(), true);
         $option_types_static_enqueued = true;
     }
     if ($this->static_enqueued) {
         return false;
     }
     $this->prepare($id, $option, $data);
     $call_next_time = $this->_enqueue_static($id, $option, $data);
     $this->static_enqueued = !$call_next_time;
     return $call_next_time;
 }
开发者ID:rawcreative,项目名称:Unyson,代码行数:33,代码来源:class-fw-option-type.php


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