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


PHP is_main_query函数代码示例

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


在下文中一共展示了is_main_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 <tranthethang@gmail.com>
 * @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


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