コード例 #1
0
function genesis_portfolio_custom_post_class($classes)
{
    if (is_main_query()) {
        $classes[] = 'pro-portfolio';
    }
    return $classes;
}
コード例 #2
0
/**
 * 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);
        }
    }
}
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: functions.php プロジェクト: arkosoft/sitoweb-sadmin
 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;
 }
コード例 #5
0
/**
 * 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;
    }
}
コード例 #6
0
 /**
  * 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;
 }
コード例 #7
0
ファイル: client.php プロジェクト: jsulz/test-rest
function display_in_post($content)
{
    if (is_single() && is_main_query()) {
        $content .= display_baseline_html();
    }
    return $content;
}
コード例 #8
0
ファイル: widgets.php プロジェクト: AthelasPeru/oniros
function example_widget($content)
{
    if (is_home() && is_active_sidebar('example') && is_main_query()) {
        dynamic_sidebar('example');
    }
    return $content;
}
コード例 #9
0
ファイル: extras.php プロジェクト: nitaibezerra/Argent-Neue
/**
 * 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;
}
コード例 #10
0
    /**
     * 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);
        }
    }
コード例 #11
0
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;
}
コード例 #12
0
/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @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);
}
コード例 #13
0
ファイル: functions.php プロジェクト: chsunil/corp
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;
}
コード例 #14
0
 /**
  * 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;
 }
コード例 #15
0
 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'];
     }
 }
コード例 #16
0
/**
 * 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;
}
コード例 #17
0
 /**
  * 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;
 }
コード例 #18
0
/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @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);
}
コード例 #19
0
ファイル: post_name.php プロジェクト: dgordon86/breakbiodark
/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @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);
}
コード例 #20
0
/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @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);
}
コード例 #21
0
ファイル: topic.php プロジェクト: 082net/bbpresskr
 public static function setup_topic_list_table($r)
 {
     if (is_main_query() && !isset(bbpresskr()->topic_list_table)) {
         require_once BBPKR_LIB . '/list-table.php';
         bbpresskr()->topic_list_table = Topic\List_Table::instance($r);
         return bbpresskr()->topic_list_table->_topic_args;
     }
     return $r;
 }
コード例 #22
0
function rbg_gallery_tag($content)
{
    global $post;
    $returnCode = '';
    if (get_post_type() == ROBO_GALLERY_TYPE_POST && is_main_query()) {
        $returnCode = do_shortcode("[robo-gallery id={$post->ID}]");
    }
    return $content . $returnCode;
}
コード例 #23
0
ファイル: enqueue.php プロジェクト: dsopiarz/dsd-ajax-example
 function dsdae_filter_content($content)
 {
     if (is_singular() && is_main_query()) {
         $before_content = '<a class="ajax-link" href="#">click for example</a>';
         $after_content = '<p class="dsdae-example">keep an eye on me!</p>';
         $content = $before_content . $content . $after_content;
     }
     return $content;
 }
コード例 #24
0
ファイル: seo.class.php プロジェクト: dgordon86/breakbiodark
 /**
  * 
  *
  * @package Kopa
  * @subpackage Core
  * @author thethangtran <*****@*****.**>
  * @since 1.0.0
  *      
  */
 public static function get_title()
 {
     $title = '';
     $pattern = '';
     if (is_main_query() && 'true' == KopaOptions::get_option('seo_status', 'true')) {
         $pattern = '[site_name] - [site_desc]';
         if (is_archive()) {
             if (is_tag() || is_category()) {
                 $pattern = KopaOptions::get_option('seo_title_taxonomy', '[term_type] - [term_name] - [pagination_paged] - [site_name]');
             } else {
                 if (is_author()) {
                     $pattern = KopaOptions::get_option('seo_title_author', 'Posts created by [author_name] - [site_name]');
                 }
             }
         } else {
             if (is_search()) {
                 $pattern = KopaOptions::get_option('seo_title_search', 'Search pages: You searched for [search_phrase] return [search_result_count] results - [site_name]');
             } else {
                 if (is_singular()) {
                     if (is_page()) {
                         $pattern = KopaOptions::get_option('seo_title_page', '[page_name] - [site_name]');
                         if (is_front_page()) {
                             $pattern = KopaOptions::get_option('seo_title_front_page', '[site_name] - [site_desc]');
                         }
                     } else {
                         if (is_single()) {
                             $pattern = KopaOptions::get_option('seo_title_post', '[post_name] - Created by [post_author_name] - In category: [post_cats] - Tagged with: [post_tags] - [site_name] - [site_desc]');
                         }
                     }
                 } else {
                     if (is_404()) {
                         $pattern = KopaOptions::get_option('seo_title_404', 'Oops! 404 Page not found - [site_name] - [site_desc]');
                     } else {
                         if (is_home()) {
                             $pattern = KopaOptions::get_option('seo_title_home_page', 'Latest News - [pagination_paged] - [site_name] - [site_desc]');
                         }
                     }
                 }
             }
         }
     }
     if (empty($pattern)) {
         global $page, $paged;
         $title = wp_title('|', FALSE, 'right');
         $title .= get_bloginfo('name');
         $site_description = get_bloginfo('description', 'display');
         if ($site_description && (is_home() || is_front_page())) {
             $title .= " | {$site_description}";
         }
         if ($paged >= 2 || $page >= 2) {
             $title .= ' | ' . sprintf(__('Page %s', kopa_get_domain()), max($paged, $page));
         }
     } else {
         $title = do_shortcode($pattern);
     }
     return apply_filters('kopa_seo_get_title', $title);
 }
コード例 #25
0
ファイル: showpage.php プロジェクト: sontv1003/fashionbeans
 function add_page_topbot_content($content)
 {
     if (is_page() && is_main_query()) {
         $jamiesocialcode = "";
         $jamiesocialcode .= '[jamiesocial]';
         $content = $jamiesocialcode . $content . $jamiesocialcode;
     }
     return $content;
 }
コード例 #26
0
ファイル: wc-page-functions.php プロジェクト: ayoayco/upbeat
/**
 * Replace a page title with the endpoint title
 * @param  string $title
 * @return string
 */
function wc_page_endpoint_title($title)
{
    if (is_main_query() && in_the_loop() && is_page() && is_wc_endpoint_url()) {
        $endpoint = WC()->query->get_current_endpoint();
        if ($endpoint_title = WC()->query->get_endpoint_title($endpoint)) {
            $title = $endpoint_title;
        }
    }
    return $title;
}
コード例 #27
0
/**
* Single dportfolio after content filter
*/
function dportfolio_after_single_content($content)
{
    global $post;
    if ($post && $post->post_type == 'dportfolio' && is_singular('dportfolio') && is_main_query()) {
        ob_start();
        do_action('dportfolio_after_content');
        $content .= ob_get_clean();
    }
    return $content;
}
コード例 #28
0
ファイル: test-rest.php プロジェクト: jsulz/test-rest
 public function load_all_scripts()
 {
     if (is_single() && is_main_query()) {
         wp_enqueue_style('test-rest-styles', plugin_dir_url(__FILE__) . 'css/styles.css', array(), '0.11', 'all');
         wp_enqueue_script('javascript', plugin_dir_url(__FILE__) . 'js/ajax.js', array('jquery'), '.11', true);
         global $post;
         $post_id = $post->ID;
         wp_localize_script('javascript', 'postdata', array('json_url' => building_url(), 'post_id' => $post_id));
     }
 }
コード例 #29
0
/**
 * 
 *
 * @package Kopa
 * @subpackage Core
 * @author thethangtran <*****@*****.**>
 * @since 1.0.0
 *      
 */
function kopa_shortcode_post_author_name($atts, $content = null)
{
    $post_author_name = '';
    if (is_main_query() || is_single() || is_page()) {
        $post = get_queried_object();
        $user_id = $post->post_author;
        $post_author_name = get_the_author_meta('display_name', $user_id);
    }
    return apply_filters('kopa_shortcode_post_author_name', $post_author_name);
}
コード例 #30
0
ファイル: OSDSocialShare.php プロジェクト: radscheit/unicorn
 public function filter_the_content()
 {
     if (is_main_query() && is_singular()) {
         global $post;
         $hide = get_post_meta($post->ID, 'osd_remove_sms_icons', true);
         if ($hide != 1 && isset($this->options['post_types']) && count($this->options['post_types']) > 0 && isset($this->options['post_types'][$post->post_type]) && $this->options['post_types'][$post->post_type] == 1) {
             $post->post_content .= "[osd_social_media_sharing]";
         }
     }
 }