• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP is_main_query函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: genesis_portfolio_custom_post_class

function genesis_portfolio_custom_post_class($classes)
{
    if (is_main_query()) {
        $classes[] = 'pro-portfolio';
    }
    return $classes;
}
开发者ID:toddejones,项目名称:genesis-portfolio-pro,代码行数:7,代码来源:functions.php


示例2: postscript_enqueue_script_urls

/**
 * Enqueues script and style URLs entered in the meta box text fields.
 *
 * URLs load after registered files above (larger action priority param).
 *
 * get_post_meta( $post_id, 'postscript_meta', true ) returns:
 * Array
 * (
 *     [url_style] => http://example.com/my-post-style.css
 *     [url_script] => http://example.com/my-post-script.js
 *     [url_script_2] => http://example.com/my-post-script-2.js
 *     [class_body] => my-post-body-class
 *     [class_post] => my-post-class
 * )
 *
 * @uses postscript_get_options()   Safely gets option from database.
 */
function postscript_enqueue_script_urls()
{
    if (is_singular() && is_main_query()) {
        $post_id = get_the_id();
        $postscript_meta = get_post_meta($post_id, 'postscript_meta', true);
        $options = postscript_get_options();
        $url_style = isset($postscript_meta['url_style']) ? $postscript_meta['url_style'] : null;
        $url_script = isset($postscript_meta['url_script']) ? $postscript_meta['url_script'] : null;
        $url_script_2 = isset($postscript_meta['url_script_2']) ? $postscript_meta['url_script_2'] : null;
        $css = array('css');
        $js = array('js');
        // If the post has a Style/Script URL value,
        // and the URL hostname/extension is in whitelist,
        // and the user-settings allow enqueue by URL.
        if ($url_style && postscript_check_url($url_style, $css) && $options['allow']['urls_style']) {
            // Style/script handles made from string: "postscript-style-{$post_id}".
            wp_enqueue_style("postscript-style-{$post_id}", esc_url_raw($postscript_meta['url_style']), array());
        }
        if ($url_script && postscript_check_url($url_script, $js) && $options['allow']['urls_script']) {
            wp_enqueue_script("postscript-script-{$post_id}", esc_url_raw($postscript_meta['url_script']), array(), false, true);
        }
        if ($url_script_2 && postscript_check_url($url_script_2, $js) && $options['allow']['urls_script'] == '2') {
            // Load second JS last (via dependency param).
            $dep = isset($postscript_meta['url_script_2']) ? "postscript-script-{$post_id}" : '';
            wp_enqueue_script("postscript-script-2-{$post_id}", esc_url_raw($postscript_meta['url_script_2']), array($dep), false, true);
        }
    }
}
开发者ID:hearvox,项目名称:postscript,代码行数:45,代码来源:enqueue-scripts.php


示例3: filter_content

 public function filter_content($content)
 {
     // Get Templates
     $templates = self::get_option('rwp_templates');
     $terms = wp_get_object_terms(get_the_ID(), array_keys(get_taxonomies()));
     $terms_keys = array();
     foreach ($terms as $term) {
         $terms_keys[$term->taxonomy][] = $term->term_id;
     }
     //self::pretty_print( $terms_keys );
     foreach ($templates as $template) {
         if (isset($template['template_auto_reviews']) && !empty($template['template_auto_reviews'])) {
             if (is_singular($template['template_auto_reviews']) && is_main_query()) {
                 if (isset($template['template_exclude_terms'])) {
                     $to_exclude = false;
                     foreach ($template['template_exclude_terms'] as $id) {
                         $i = explode('-', $id);
                         if (in_array($i[1], $terms_keys[$i[0]])) {
                             $to_exclude = true;
                             break;
                         }
                     }
                     if ($to_exclude) {
                         continue;
                     }
                 }
                 $new_content = '[rwp-review id="-1" template="' . $template['template_id'] . '"]';
                 $content .= $new_content;
             }
         }
     }
     return $content;
 }
开发者ID:jprdev,项目名称:S.J-Enterprise,代码行数:33,代码来源:class-reviewer.php


示例4: mh_posts_pagination

 function mh_posts_pagination($content)
 {
     if (is_singular() && is_main_query()) {
         $content .= wp_link_pages(array('before' => '<div class="pagination">', 'after' => '</div>', 'link_before' => '<span class="pagelink">', 'link_after' => '</span>', 'nextpagelink' => __('&raquo;', 'mh'), 'previouspagelink' => __('&laquo;', 'mh'), 'pagelink' => '%', 'echo' => 0));
     }
     return $content;
 }
开发者ID:arkosoft,项目名称:sitoweb-sadmin,代码行数:7,代码来源:functions.php


示例5: create_list_jsondata

/**
 * Create listing json for map script.
 *
 * @since 1.0.0
 *
 * @global object $wpdb WordPress Database object.
 * @global array $list_map_json Listing map data in json format.
 * @global bool $add_post_in_marker_array Displays posts in marker array when the value is true.
 */
function create_list_jsondata($post)
{
    global $wpdb, $list_map_json, $add_post_in_marker_array;
    if ((is_main_query() || $add_post_in_marker_array) && isset($post->marker_json) && $post->marker_json != '') {
        $list_map_json[] = $post->marker_json;
    }
}
开发者ID:jefferose,项目名称:geodirectory,代码行数:16,代码来源:listing_map_widget.php


示例6: run

 /**
  * the_content filter that will add linked posts to the bottom of the main post content
  *
  * @param $content
  *
  * @return string
  */
 public function run($content)
 {
     /**
      * Wow, what's going on here?! Well, setup_postdata() sets a lot of variables but does not change the $post variable.
      * All checks return the main queried ID but we want to check if this specific filter call is the for the 'main' content.
      * The method setup_postdata() does global and set the $id variable, so we're checking that.
      */
     global $id;
     // Only run on single
     if (!is_singular() || !is_main_query() || $id != get_queried_object_id()) {
         return $content;
     }
     // Allow disabling content filter
     if (false === apply_filters('rp4wp_append_content', true)) {
         return $content;
     }
     // The Post Type
     $post_type = get_post_type($id);
     // The Post Type Manager
     $pt_manager = new RP4WP_Post_Type_Manager();
     // Check if this Post Type is installed
     if ($pt_manager->is_post_type_installed($post_type) && isset(RP4WP()->settings['general_' . $post_type])) {
         // Related Post Manager
         $related_post_manager = new RP4WP_Related_Post_Manager();
         // The Output
         $output = $related_post_manager->generate_related_posts_list($id);
         // Add output if there is any
         if ('' != $output) {
             $content .= $output;
         }
     }
     // Return the content
     return $content;
 }
开发者ID:amprog,项目名称:relatedpostsforwp,代码行数:41,代码来源:class-filter-after-post.php


示例7: display_in_post

function display_in_post($content)
{
    if (is_single() && is_main_query()) {
        $content .= display_baseline_html();
    }
    return $content;
}
开发者ID:jsulz,项目名称:test-rest,代码行数:7,代码来源:client.php


示例8: example_widget

function example_widget($content)
{
    if (is_home() && is_active_sidebar('example') && is_main_query()) {
        dynamic_sidebar('example');
    }
    return $content;
}
开发者ID:AthelasPeru,项目名称:oniros,代码行数:7,代码来源:widgets.php


示例9: argent_custom_link_pages

/**
 * Display page-links for paginated posts before Jetpack share buttons and related posts.
 */
function argent_custom_link_pages($content)
{
    if (is_singular() && is_main_query()) {
        $content .= wp_link_pages(array('before' => '<div class="page-links"><span class="page-links-title">' . esc_html__('Pages:', 'argent') . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>', 'echo' => 0));
    }
    return $content;
}
开发者ID:nitaibezerra,项目名称:Argent-Neue,代码行数:10,代码来源:extras.php


示例10: tc_fp_block_display

    /**
     * The template displaying the front page featured page block.
     *
     *
     * @package FPC
     * @since FPC 1.3
     */
    function tc_fp_block_display()
    {
        $hook = esc_attr(tc__f('__get_fpc_option', 'tc_fp_position'));
        //if the hook is loop start, we don't want to display fp in all queries.
        if ('loop_start' == $hook && (!is_main_query() || !in_the_loop())) {
            return;
        }
        //gets display options
        $tc_show_featured_pages = esc_attr(tc__f('__get_fpc_option', 'tc_show_fp'));
        if (!apply_filters('tc_show_fp', 0 != $tc_show_featured_pages && tc__f('__is_home'))) {
            return;
        }
        //gets the featured pages array and sets the fp layout
        $fp_ids = apply_filters('fpc_featured_pages_ids', TC_fpc::$instance->fpc_ids);
        $fp_nb = count($fp_ids);
        list($span_value, $fp_per_row) = $this->tc_get_layout();
        //save $args for filter
        $args = array($fp_ids, $fp_nb, $fp_per_row, $span_value);
        ?>

        <?php 
        ob_start();
        ?>

          <div class="fpc-container fpc-marketing">
            <?php 
        do_action('__before_fp');
        $j = 1;
        for ($i = 1; $i <= $fp_nb; $i++) {
            printf('%1$s<div class="fpc-span%2$s fp-%3$s">%4$s</div>%5$s', 1 == $j ? '<div class="fpc-row-fluid fpc-widget-area" role="complementary">' : '', $span_value, $fp_ids[$i - 1], $this->tc_fp_single_display($fp_ids[$i - 1]), $j == $fp_per_row || $i == $fp_nb ? '</div>' : '');
            //set $j back to start value if reach $fp_per_row
            $j++;
            $j = $j == $fp_per_row + 1 ? 1 : $j;
        }
        do_action('__after_fp');
        //display edit link for logged in users with edit posts capabilities
        if (apply_filters('tc_show_fp_edit_link', is_user_logged_in()) && !TC_utils_fpc::$instance->is_customizing) {
            printf('<a class="fpc-edit-link fpc-btn fpc-btn-inverse" href="%1$s" title="%2$s" target="_blank">%2$s</a>', admin_url() . 'customize.php', __('Edit Featured Pages', $this->plug_lang));
        }
        //end edit attachment condition
        ?>
          </div><!-- .fpc-container -->

        <?php 
        echo !tc__f('__is_home_empty') ? apply_filters('fpc_after_fp_separator', '<hr class="featurette-divider ' . current_filter() . '">') : '';
        ?>

       <?php 
        $html = ob_get_contents();
        if ($html) {
            ob_end_clean();
        }
        //Return or echo
        $hook = esc_attr(tc__f('__get_fpc_option', 'tc_fp_position'));
        if ('wp_nav_menu' != $hook) {
            echo apply_filters('fpc_block_display', $html, $args);
        } else {
            return apply_filters('fpc_block_display', $html, $args);
        }
    }
开发者ID:Atem18,项目名称:featured-pages-customizer,代码行数:67,代码来源:class_front_fpc.php


示例11: themeist_books_add_after_post_content

function themeist_books_add_after_post_content($content)
{
    if (!is_feed() && !is_home() && is_singular() && is_main_query()) {
        $content .= themeist_books_get_details();
    }
    return $content;
}
开发者ID:hchouhan,项目名称:books-by-themeist,代码行数:7,代码来源:includes.php


示例12: kopa_shortcode_search_phrase

/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <[email protected]>
 * @since 1.0.0
 *      
 */
function kopa_shortcode_search_phrase($atts, $content = null)
{
    $search_phrase = '';
    if (is_main_query() || is_search()) {
        $search_phrase = '"' . get_search_query() . '"';
    }
    return apply_filters('kopa_shortcode_search_phrase', $search_phrase);
}
开发者ID:dgordon86,项目名称:breakbiodark,代码行数:17,代码来源:search_phrase.php


示例13: tags_after_single_post_content

function tags_after_single_post_content($content)
{
    if (is_singular('post') && is_main_query()) {
        $tags = the_tags('<div class="entry-meta">Tagged with: ', '.', '</div><br />');
        $content .= $content . $tags;
    }
    return $content;
}
开发者ID:chsunil,项目名称:corp,代码行数:8,代码来源:functions.php


示例14: endpoint_page_titles

 /**
  * Handle endpoint page title
  * @param  string $title
  * @return string
  */
 public function endpoint_page_titles($title)
 {
     if (is_main_query() && in_the_loop() && is_page() && is_checkout() && $this->has_active_session()) {
         $title = __('Confirm your PayPal order', 'woocommerce-gateway-paypal-express-checkout');
         remove_filter('the_title', array($this, 'endpoint_page_titles'));
     }
     return $title;
 }
开发者ID:ksan5835,项目名称:maadithottam,代码行数:13,代码来源:class-wc-gateway-ppec-checkout-handler.php


示例15: action_wp_loaded

 public static function action_wp_loaded()
 {
     if (WPSOLR_Query_Parameters::is_wp_search() && !is_admin() && is_main_query() && WPSOLR_Global::getOption()->get_search_is_replace_default_wp_search()) {
         // Override global $wp_query with wpsolr_query
         $GLOBALS['wp_the_query'] = WPSOLR_Global::getQuery();
         $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
     }
 }
开发者ID:zelle7,项目名称:wpsolr-search-engine,代码行数:8,代码来源:WPSOLR_Global.php


示例16: ed_campaigns_use_page_template

/**
 * Instead of using the Post template for campaigns, use the Page template as a fallback.
 *
 * @param   string $template
 * @return  string $template
 */
function ed_campaigns_use_page_template($template)
{
    global $wp_query;
    if (is_main_query() && is_singular('campaign') && !isset($wp_query->query_vars['widget'])) {
        $template = locate_template(array('single-campaign.php', 'page.php', 'index.php'));
    }
    return $template;
}
开发者ID:Charitable,项目名称:library,代码行数:14,代码来源:use-page-template-for-campaigns.php


示例17: show_payment_details

 /**
  * Function to show the payment details after the purchase
  *
  * @since 2.0.0
  */
 public static function show_payment_details($content)
 {
     $details_placement = isset($_GET['details_placement']) ? $_GET['details_placement'] : 'above';
     // Since this is a GET query arg I reset it here in case someone tries to submit it again with their own string written in the URL.
     // This helps ensure it can only be set to below or above.
     $details_placement = $details_placement == 'below' ? 'below' : 'above';
     $is_above = $details_placement == 'below' ? 0 : 1;
     $charge_response = null;
     if (in_the_loop() && is_main_query()) {
         global $sc_options;
         $html = '';
         $test_mode = isset($_GET['test_mode']) ? 'true' : 'false';
         parent::set_key($test_mode);
         // PRO ONLY: Check for error code.
         if (isset($_GET['error_code'])) {
             if (isset($_GET['charge'])) {
                 $charge = esc_html($_GET['charge']);
             } else {
                 $charge = '';
             }
             if ($is_above) {
                 $content = apply_filters('sc_payment_details_error', $html, $charge) . $content;
             } else {
                 $content = $content . apply_filters('sc_payment_details_error', $html, $charge);
             }
         }
         // Successful charge output.
         if (isset($_GET['charge']) && !isset($_GET['charge_failed'])) {
             $charge_id = esc_html($_GET['charge']);
             // https://stripe.com/docs/api/php#charges
             $charge_response = \Stripe\Charge::retrieve($charge_id);
             if (null === $sc_options->get_setting_value('disable_success_message')) {
                 $html = '<div class="sc-payment-details-wrap">' . "\n";
                 $html .= '<p>' . __('Congratulations. Your payment went through!', 'stripe') . '</p>' . "\n";
                 $html .= '<p>' . "\n";
                 if (!empty($charge_response->description)) {
                     $html .= __("Here's what you purchased:", 'stripe') . '<br/>' . "\n";
                     $html .= esc_html($charge_response->description) . '<br/>' . "\n";
                 }
                 if (isset($_GET['store_name']) && !empty($_GET['store_name'])) {
                     $html .= __('From: ', 'stripe') . esc_html($_GET['store_name']) . '<br/>' . "\n";
                 }
                 $html .= '<br/>' . "\n";
                 $html .= '<strong>' . __('Total Paid: ', 'stripe') . Stripe_Checkout_Misc::to_formatted_amount($charge_response->amount, $charge_response->currency) . ' ' . strtoupper($charge_response->currency) . '</strong>' . "\n";
                 $html .= '</p>' . "\n";
                 $html .= '<p>' . sprintf(__('Your transaction ID is: %s', 'stripe'), $charge_response->id) . '</p>' . "\n";
                 $html .= '</div>' . "\n";
                 if ($is_above) {
                     $content = apply_filters('sc_payment_details', $html, $charge_response) . $content;
                 } else {
                     $content = $content . apply_filters('sc_payment_details', $html, $charge_response);
                 }
             }
             do_action('sc_after_charge', $charge_response);
         }
     }
     return $content;
 }
开发者ID:freeformpdx,项目名称:kffp-website,代码行数:63,代码来源:class-stripe-checkout-pro-functions.php


示例18: kopa_shortcode_author_name

/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <[email protected]>
 * @since 1.0.0
 *      
 */
function kopa_shortcode_author_name($atts, $content = null)
{
    $author_name = '';
    if (is_main_query() || is_author()) {
        $author = get_queried_object();
        $author_name = $author->display_name;
    }
    return apply_filters('kopa_shortcode_author_name', $author_name);
}
开发者ID:dgordon86,项目名称:breakbiodark,代码行数:18,代码来源:author_name.php


示例19: kopa_shortcode_post_name

/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <[email protected]>
 * @since 1.0.0
 *      
 */
function kopa_shortcode_post_name($atts, $content = null)
{
    $post_name = '';
    if (is_main_query() || is_page() || is_single()) {
        $page_id = get_queried_object_id();
        $post_name = get_the_title($page_id);
    }
    return apply_filters('kopa_shortcode_post_name', $post_name);
}
开发者ID:dgordon86,项目名称:breakbiodark,代码行数:18,代码来源:post_name.php


示例20: kopa_shortcode_search_result_count

/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <[email protected]>
 * @since 1.0.0
 *      
 */
function kopa_shortcode_search_result_count($atts, $content = null)
{
    $search_result_count = '';
    if (is_main_query() || is_search()) {
        global $wp_query;
        $search_result_count = $wp_query->found_posts;
    }
    return apply_filters('kopa_shortcode_search_phrase', $search_result_count);
}
开发者ID:dgordon86,项目名称:breakbiodark,代码行数:18,代码来源:search_result_count.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP is_main_site函数代码示例发布时间:2022-05-15
下一篇:
PHP is_main_network函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap