/**
  * Renders a layout with the provided post ID and enqueues the 
  * necessary styles and scripts.
  *
  * @since 1.7
  * @param array $attrs The shortcode attributes.
  * @return string
  */
 public static function insert_layout($attrs)
 {
     $builder_active = in_the_loop() && FLBuilderModel::is_builder_active();
     $post_type = isset($attrs['type']) ? $attrs['type'] : get_post_types();
     $args = array('post_type' => $post_type, 'posts_per_page' => -1);
     // Build the args array.
     if (isset($attrs['id'])) {
         $args['orderby'] = 'post__in';
         if (is_numeric($attrs['id'])) {
             $args['post__in'] = array($attrs['id']);
         } else {
             $args['post__in'] = explode(',', $attrs['id']);
         }
     } else {
         if (isset($attrs['slug'])) {
             $args['orderby'] = 'name';
             $args['name'] = $attrs['slug'];
         } else {
             return;
         }
     }
     // Render and return the layout.
     ob_start();
     if ($builder_active) {
         echo '<div class="fl-builder-shortcode-mask-wrap"><div class="fl-builder-shortcode-mask"></div>';
     }
     FLBuilder::render_query($args);
     if ($builder_active) {
         echo '</div>';
     }
     return ob_get_clean();
 }
    /**
     * 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);
        }
    }
function spine_section_meta($attribute = 'slug', $sectional = 'subsection')
{
    if (!is_singular() && !in_the_loop()) {
        return '';
    }
    if (empty($sectional)) {
        $sectional = 'subsection';
    }
    if (empty($attribute) || 'slug' == $attribute) {
        $attribute = 'post_name';
    }
    if ('title' == $attribute) {
        $attribute = 'post_title';
    }
    $subsections = get_post_ancestors(get_the_ID());
    if (!empty($subsections)) {
        $subsection = get_post($subsections[0]);
        $sections = array_reverse($subsections);
        $section = get_post($sections[0]);
        if (isset($sectional) && in_array($sectional, array('section', 'top'))) {
            return $section->{$attribute};
        } else {
            return $subsection->{$attribute};
        }
    }
    return null;
}
Example #4
0
 function mm_in_the_loop_contact_button($class = '', $text = '', $subject = '', $ouput = true)
 {
     if (!in_the_loop()) {
         return;
     }
     //this is in the loop, we can get author
     $username = get_the_author();
     $user = null;
     if (!empty($username)) {
         $user = get_user_by('login', $username);
     }
     if (!$user instanceof WP_User) {
         return;
     }
     $shortcode = "[pm_user ";
     $shortcode .= sprintf('user_id="%s" ', $user->ID);
     if (!empty($class)) {
         $shortcode .= sprintf('class="%s" ', $class);
     }
     if (!empty($text)) {
         $shortcode .= sprintf('text="%s" ', $text);
     }
     if (!empty($subject)) {
         $shortcode .= sprintf('subject="%s" ', $subject);
     }
     $shortcode .= "]";
     if ($ouput) {
         echo do_shortcode($shortcode);
     } else {
         return do_shortcode($shortcode);
     }
 }
Example #5
0
 /**
  * image()
  *
  * @param array $anchor
  * @return anchor $anchor
  **/
 function image($anchor)
 {
     if (!preg_match("/^\\s*<\\s*img\\s.+?>\\s*\$/is", $anchor['body'])) {
         return $anchor;
     }
     if (!$anchor['attr']['class']) {
         $anchor['attr']['class'][] = 'thickbox';
         $anchor['attr']['class'][] = 'no_icon';
     } else {
         if (!in_array('thickbox', $anchor['attr']['class']) && !in_array('nothickbox', $anchor['attr']['class']) && !in_array('no_thickbox', $anchor['attr']['class'])) {
             $anchor['attr']['class'][] = 'thickbox';
         }
         if (!in_array('no_icon', $anchor['attr']['class']) && !in_array('noicon', $anchor['attr']['class'])) {
             $anchor['attr']['class'][] = 'no_icon';
         }
     }
     if (in_the_loop() && !$anchor['attr']['rel']) {
         $anchor['attr']['rel'][] = 'gallery-' . get_the_ID();
     }
     if (empty($anchor['attr']['title'])) {
         if (preg_match("/\\b(?:alt|title)\\s*=\\s*('|\")(.*?)\\1/i", $anchor['body'], $title)) {
             $anchor['attr']['title'] = end($title);
         }
     }
     return $anchor;
 }
Example #6
0
 /**
  * Displays a help block about images smartload for single posts prepended to the content
  * hook : the_content
  * @since Customizr 3.4+
  */
 function tc_maybe_display_img_smartload_help($the_content)
 {
     if (!($this->tc_page_display_controller() && in_the_loop() && TC_placeholders::tc_is_img_smartload_help_on($the_content))) {
         return $the_content;
     }
     return TC_placeholders::tc_print_smartload_help_block() . $the_content;
 }
Example #7
0
function get_author_avatar()
{
    global $default;
    $avatar = '';
    if (class_exists('author_image')) {
        $avatar = author_image::get();
    }
    if ($avatar == '') {
        if (in_the_loop()) {
            $author_id = get_the_author_ID();
        } elseif (is_singular()) {
            global $wp_the_query;
            $author_id = $wp_the_query->posts[0]->post_author;
        } elseif (is_author()) {
            global $wp_the_query;
            $author_id = $wp_the_query->get_queried_object_id();
        }
        $author = get_userdata($author_id);
        if (!empty($author)) {
            $avatar = get_avatar($author->user_email, 64, $default, $author->display_name);
        } else {
            $avatar = '<img src="' . esc_url($default) . '" alt="' . $author->display_name . '" />';
        }
    }
    return $avatar;
}
 /**
  * Inject vehicle singular content into singular page
  *
  * @param string $content
  *
  * @return string
  */
 public function inject_singular_content($content)
 {
     global $post;
     // check if we need to inject
     if (!is_singular(Vehicle\PostType::VEHICLE) || !in_the_loop()) {
         return $content;
     }
     // remove filter to prevent crazy loops
     remove_filter('the_content', array($this, 'inject_singular_content'));
     // check if vehicle actually the post type that's being looped
     if (Vehicle\PostType::VEHICLE === $post->post_type) {
         // create vehicle object
         $vehicle = wp_car_manager()->service('vehicle_factory')->make($post->ID);
         ob_start();
         /**
          * wpcm_before_main_content hook
          */
         do_action('wpcm_before_single_content', $vehicle);
         // load content-single-vehicle
         $this->get_template_part('content', 'single-vehicle', array('vehicle' => $vehicle));
         /**
          * wpcm_after_main_content hook
          */
         do_action('wpcm_after_single_content', $vehicle);
         // set new content
         $content = ob_get_clean();
     }
     // add filter back in place
     add_filter('the_content', array($this, 'inject_singular_content'));
     // return content
     return apply_filters('wpcm_content_single_vehicle', $content, $post);
 }
Example #9
0
function zippo_thumbnail_url($post_id = null, $size = 'post-thumbnail', $attr = '')
{
    $url = array();
    $post_id = null === $post_id ? get_the_ID() : $post_id;
    $post_thumbnail_id = get_post_thumbnail_id($post_id);
    /**
     * Filter the post thumbnail size.
     *
     * @since 2.9.0
     *
     * @param string $size The post thumbnail size.
     */
    $size = apply_filters('post_thumbnail_size', $size);
    if ($post_thumbnail_id) {
        /**
         * Fires before fetching the post thumbnail HTML.
         *
         * Provides "just in time" filtering of all filters in wp_get_attachment_image().
         *
         * @since 2.9.0
         *
         * @param string $post_id The post ID.
         * @param string $post_thumbnail_id The post thumbnail ID.
         * @param string $size The post thumbnail size.
         */
        do_action('begin_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size);
        if (in_the_loop()) {
            update_post_thumbnail_cache();
        }
        $url = wp_get_attachment_image_src($post_thumbnail_id, $size, false, $attr);
    }
    return reset($url);
}
 public function page_content($content)
 {
     global $wtd_plugin, $post, $wp_query;
     if (!is_singular('page') || !in_the_loop()) {
         return $content;
     }
     $res_id = get_post_meta($post->ID, 'res_id', true);
     $wtd_pages = get_option('wtd_pages');
     $page_type = get_post_meta($post->ID, 'wtd_page', true);
     if (!empty($wtd_pages['activities_pages'][$res_id]) || $page_type == 'activity_page') {
         if (in_array($post->ID, $wtd_pages['activities_pages'])) {
             remove_filter('the_content', 'theme_formatter', 99);
             remove_filter('the_content', 'wpautop');
             ob_start();
             if (empty($wp_query->query['wtdc']) && empty($_GET['wtdc'])) {
                 $this->matrix();
             } elseif (!empty($wp_query->query['wtdc']) || !empty($_GET['wtdc'])) {
                 switch ($wtd_plugin['act_page_type']) {
                     case 2:
                         $this->results();
                         break;
                     case 3:
                     default:
                         $this->results();
                         break;
                 }
             }
             $content = ob_get_contents();
             ob_end_clean();
         }
     }
     return $content;
 }
 function pm_user($atts)
 {
     $this->button_id = uniqid();
     $a = shortcode_atts(array('user_id' => '', 'user_name' => '', 'text' => __('Message me', mmg()->domain), 'class' => 'btn btn-sm btn-primary', 'subject' => __('You have new message!', mmg()->domain), 'in_the_loop' => false), $atts);
     if (!empty($a['user_id'])) {
         $user = get_user_by('id', $a['user_id']);
     } elseif (!empty($a['user_name'])) {
         $user = get_user_by('login', $a['user_name']);
     } elseif ($a['in_the_loop'] == true && in_the_loop()) {
         //this is in the loop, we can get author
         $username = get_the_author_meta('user_login');
         if (!empty($username)) {
             $user = get_user_by('login', $username);
         }
     }
     if (!isset($user) || !is_object($user)) {
         return '';
     }
     if (!is_user_logged_in()) {
         mmg()->load_script('login');
     }
     //add modal in footer,only if user logged in
     add_action('wp_footer', array(&$this, 'message_me_modal'));
     return $this->render('message_me/buttons', array('a' => $a, 'user' => $user), false);
 }
 public static function replace_page_content($content)
 {
     if (in_the_loop()) {
         $content = self::get_content();
     }
     return $content;
 }
Example #13
0
 /**
  * Link to a site's Twitter profile using rel me
  *
  * Adds via attribution to Twitter widgets on the page
  *
  * @link http://microformats.org/wiki/rel-me XFN rel me
  *
  * @return void
  */
 public static function relMe()
 {
     $site_username = \Twitter\WordPress\Site\Username::getViaAttribution(in_the_loop() ? get_the_ID() : null);
     if ($site_username) {
         echo '<link rel="me" href="' . esc_url(\Twitter\Helpers\TwitterURL::profile($site_username), array('https', 'http')) . '"' . \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement() . '>';
     }
 }
 public static function replace_page_title($title, $id)
 {
     if ($id == self::$_options['property_details_page_id'] && in_the_loop() && DispletRetsIdxUtilities::is_referral_function('the_title')) {
         return self::get_page_title();
     }
     return $title;
 }
function display_pagetitle_icon($title)
{
    global $post;
    /* get values from post meta*/
    $value = get_post_meta($post->ID, '_wpptwi_icon', true);
    $icon_color = get_post_meta($post->ID, '_wpptwi_icon_color', true);
    $icon_size = get_post_meta($post->ID, '_wpptwi_icon_size', true);
    /* escapes html entities*/
    $icon = esc_attr($value);
    $icon_color = esc_attr($icon_color);
    $icon_size = esc_attr($icon_size);
    /* checks if the icon is empty, title is in the loop*/
    if (!empty($icon) && in_the_loop()) {
        /* check if this is the current page */
        if (is_page($post->ID) && $title == $post->post_title) {
            return '<i class="fa ' . $icon . '" style="color:' . $icon_color . '; font-size:' . $icon_size . 'px"></i>  ' . $title;
        } else {
            if (is_single($post->ID) && $title == $post->post_title) {
                return '<i class="fa ' . $icon . '" style="color:' . $icon_color . '; font-size:' . $icon_size . 'px"></i>  ' . $title;
            } else {
                return $title;
            }
        }
    } else {
        return $title;
    }
}
 public function auto_add_tag($title, $post_id)
 {
     global $post;
     $result = '';
     $add_tags = '';
     $i = 0;
     if (in_the_loop()) {
         $p = get_post($post_id);
         $cur_title = $p->post_title;
         $post_tags = get_the_tags($post_id);
         if ($post_tags) {
             foreach ($post_tags as $tag) {
                 //get the first post tag
                 if ($i == 0) {
                     $add_tags .= '&lsqb;' . $tag->name . '&rsqb;&nbsp;';
                 }
                 $i++;
             }
         }
         $result = $add_tags . $cur_title;
     } else {
         $result = $title;
     }
     return $result;
 }
 /**
  * Filter the raw post content and replace any images that are "local" with cloudinary images
  */
 static function convert_the_content_images_to_cloudinary_pull_request($content)
 {
     if (!in_the_loop()) {
         return $content;
     }
     //setup account name for use with get_cdn_prefix()
     $account = static::get_option_value('cloud_name');
     //if there is no account set, do not continue
     if (empty($account)) {
         return $content;
     }
     //prepare new values for use in string replacements
     $cdn_fetch_prefix_no_protocal = static::get_cdn_prefix($account);
     $site_url = get_bloginfo('url');
     $site_url_no_protocal = preg_replace('/http[s]?:\\/\\//', '', $site_url);
     $cdn_content = $content;
     //prepare for multisite, switch location of images to actual source
     if (is_multisite()) {
         global $blog_id;
         //fix rewrite urls to go directly to the file within the multisite subfolder
         $cdn_content = str_replace($site_url . '/files/', $site_url . '/wp-content/blogs.dir/' . $blog_id . '/files/', $cdn_content);
     }
     //move any images that match the site source to pull them from the cdn
     $cdn_fetch_options = static::get_cdn_options();
     $cdn_content = preg_replace_callback("/<img(.*)src=\"(http:|https:)?\\/\\/(" . $site_url_no_protocal . ")(\\/.*\\/)((.*-(\\d{3})x(\\d{3}))|.*)?(\\.[a-zA-Z]{3,4}\")([^>]+>)/im", array(get_called_class(), 'callback_convert_image_source_to_cdn_url'), $cdn_content);
     //if preg replace function worked correctly, use the new CDN content
     if (!empty($cdn_content)) {
         return $cdn_content;
     }
     //otherwise return the regular content
     return $content;
 }
 function build_content($content)
 {
     $return = $content;
     if (is_single() && in_the_loop() || is_page() && in_the_loop()) {
         global $post, $authordata, $wpautbox_lite;
         $this->post = $post;
         $this->authordata = $authordata;
         $this->settings = $wpautbox_lite;
         $this->allowed_post_types();
         //initialize return element
         if (isset($this->show_in[$this->post->post_type]) && 'no' != $this->show_in[$this->post->post_type]) {
             switch ($this->show_in[$this->post->post_type]) {
                 case 'above':
                     $return = $this->construct_authorbox('above', $this->authordata->ID);
                     $return .= $content;
                     break;
                 case 'below':
                     $return = $content;
                     $return .= $this->construct_authorbox('below', $this->authordata->ID);
                     break;
                 case 'both':
                     $return = $this->construct_authorbox('above', $this->authordata->ID);
                     $return .= $content;
                     $return .= $this->construct_authorbox('below', $this->authordata->ID);
                     break;
                 default:
                     $return = $content;
                     break;
             }
         }
     }
     return $return;
 }
Example #19
0
function cart_title($title)
{
    if (get_the_ID() == get_option('cart_page_id') and is_singular() and in_the_loop()) {
        $title = get_cart_title();
    }
    return $title;
}
Example #20
0
/**
 * The WordPress.org theme review requires that a link be provided to the single post page for untitled 
 * posts.  This is a filter on 'the_title' so that an '(Untitled)' title appears in that scenario, allowing 
 * for the normal method to work.
 *
 * @since  1.6.0
 * @access public
 * @param  string  $title
 * @return string
 */
function hybrid_untitled_post($title)
{
    if (empty($title) && !is_singular() && in_the_loop() && !is_admin()) {
        $title = __('(Untitled)', 'hybrid-core');
    }
    return $title;
}
function ubik_terms_popular($id = '', $taxonomies = 'post_tag', $threshold = 1)
{
    // Attempt to retrieve the ID
    if (empty($id)) {
        if (in_the_loop()) {
            global $post;
            $id = $post->ID;
        } else {
            return false;
        }
    }
    // Attempt to get the terms
    $terms = get_the_terms($id, $taxonomies);
    if (is_wp_error($terms)) {
        return $terms;
    }
    if (empty($terms)) {
        return false;
    }
    // PHP 5.3 version commented out below...
    // Remove any terms with a count at or below $threshold
    //$terms = array_filter( $terms, function( $a ) use ( $threshold ) { return $a->count > $threshold; } );
    // Sort terms by count
    //usort( $terms, function( $a, $b ) { return $b->count - $a->count; } );
    // Remove any terms with a count below 2
    $terms_filtered = array_filter($terms, "ubik_terms_popular_threshold");
    // If we stripped away all terms abort and restore the list
    if (empty($terms_filtered)) {
        $terms_filtered = $terms;
    }
    // Sort terms by count
    usort($terms_filtered, "ubik_terms_popular_sort");
    return $terms_filtered;
}
Example #22
0
/**
 * The WordPress.org theme review requires that a link be provided to the single post page for untitled 
 * posts.  This is a filter on 'the_title' so that an '(Untitled)' title appears in that scenario, allowing 
 * for the normal method to work.
 *
 * @since  0.9.0
 * @access public
 * @param  string  $title
 * @return string
 */
function omega_untitled_post($title)
{
    if (empty($title) && !is_singular() && in_the_loop() && !is_admin()) {
        $title = __('(Untitled)', 'omega');
    }
    return $title;
}
 public function add_content($content, $template, $position = 10)
 {
     if (!defined('ABSPATH')) {
         exit;
     }
     // Exit if accessed directly
     if (!in_the_loop()) {
         return;
     }
     // Return if not in main loop
     $content = '<div class="sp-post-content">' . $content . '</div>';
     ob_start();
     if ($position <= 0) {
         echo $content;
     }
     do_action('sportspress_before_single_' . $template);
     if (post_password_required()) {
         echo get_the_password_form();
         return;
     }
     if ($position > 0 && $position <= 5) {
         echo $content;
     }
     do_action('sportspress_single_' . $template . '_content');
     if ($position > 5 && $position <= 10) {
         echo $content;
     }
     do_action('sportspress_after_single_' . $template);
     if ($position > 10) {
         echo $content;
     }
     return ob_get_clean();
 }
Example #24
0
function jhp_portfolio_time($time)
{
    if (!in_the_loop()) {
        return $time;
    }
    return '';
}
 /**
  * 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;
 }
Example #26
0
 /**
  * Add cteated date ti the page, post title
  *
  * @param $title
  *
  * @return string
  */
 public function nozhka_the_title_add_date($title)
 {
     if (!in_the_loop()) {
         return $title;
     }
     global $post;
     return $title . ' <em>(' . get_the_date('', $post) . ')</em>';
 }
 /**
  * Changes page title on view subscription page
  *
  * @param  string $title original title
  * @return string        changed title
  */
 public function change_endpoint_title($title)
 {
     global $wp;
     if ($this->is_query('view-subscription') && in_the_loop()) {
         $title = $this->get_endpoint_title('view-subscription');
     }
     return $title;
 }
Example #28
0
/**
 * The WordPress.org theme review requires that a link be provided to the single post page for untitled
 * posts.  This is a filter on 'the_title' so that an '(Untitled)' title appears in that scenario, allowing
 * for the normal method to work.
 *
 * @since  1.6.0
 * @access public
 * @param  string  $title
 * @return string
 */
function hybrid_untitled_post($title)
{
    // Translators: Used as a placeholder for untitled posts on non-singular views.
    if (!$title && !is_singular() && in_the_loop() && !is_admin()) {
        $title = esc_html__('(Untitled)', 'hybrid-core');
    }
    return $title;
}
 public function run_filter_check($content)
 {
     $run_filter = true;
     if (in_the_loop() && 'true' == get_post_meta(get_the_ID(), '_bj_lazy_load_skip_post', true)) {
         $run_filter = false;
     }
     return $run_filter;
 }
Example #30
0
/**
 * Removes sharing markup from post content if we're not in the loop and it's a
 * formatted post.
 *
 * @param bool $show Whether to show sharing options.
 * @param WP_Post $post The post to share.
 * @return bool
 */
function twentyfourteen_mute_content_filters($show, $post)
{
    $formats = get_theme_support('post-formats');
    if (!in_the_loop() && has_post_format($formats[0], $post)) {
        $show = false;
    }
    return $show;
}