/** * Render main shortcode. * * @since 1.0.0 * @access public * @param array $atts * @param string $content * @return string */ public function render_shortcode($atts, $content = null) { $atts = shortcode_atts(array('image_size' => 'blank', 'image_width' => '', 'image_height' => ''), $atts, $this->shortcode); // must add the third params $this->shortcode, for builder shortcode rendering if (!TF_Model::is_template_page()) { $output = ''; $image_size = 'blank' != $atts['image_size'] ? $atts['image_size'] : 'large'; if (has_post_thumbnail(get_the_ID())) { $post_thumbnail = get_post_thumbnail_id(get_the_ID()); $post_thumbnail_object = get_post($post_thumbnail); $thumbnail_title = is_object($post_thumbnail_object) ? $post_thumbnail_object->post_title : ''; $image_attribute = wp_get_attachment_image_src($post_thumbnail, $image_size); $post_image = sprintf('<img src="%s" alt="%s" width="%s" height="%s" />', esc_url($image_attribute[0]), esc_attr($thumbnail_title), esc_attr($atts['image_width']), esc_attr($atts['image_height'])); $output = '<figure class="tf_page_featured_image">' . $post_image . '</figure>'; } } else { if (!$atts['image_width']) { $atts['image_width'] = '350'; } if (!$atts['image_height']) { $atts['image_height'] = '150'; } $output = '<figure class="tf_page_featured_image"><img width="' . $atts['image_width'] . '" height="' . $atts['image_height'] . '" src="http://placehold.it/' . $atts['image_width'] . 'x' . $atts['image_height'] . '" /></figure>'; } return apply_filters('tf_shortcode_element_render', $output, $this->slug, $atts, $content); }
/** * Render main shortcode. * * @since 1.0.0 * @access public * @param array $atts * @param string $content * @return string */ public function render_shortcode($atts, $content = null) { $args = shortcode_atts(array('comments_per_page' => get_option('comments_per_page'), 'avatar_size' => 64), array_filter($atts), $this->shortcode); if (TF_Model::is_template_page()) { global $post; $old_post = $post; $post_with_comment = get_posts(array('posts_per_page' => 1, 'orderby' => 'comment_count', 'order' => 'DESC')); if (!empty($post_with_comment)) { $post = current($post_with_comment); } } $this->comments_args = $args; add_filter('wp_list_comments_args', array($this, 'wp_list_comments_args')); add_filter('pre_option_comments_per_page', array($this, 'pre_option_comments_per_page')); add_filter('pre_option_page_comments', array($this, 'pre_option_page_comments')); ob_start(); ?> <?php comments_template(); ?> <?php $output = ob_get_clean(); remove_filter('wp_list_comments_args', array($this, 'wp_list_comments_args')); remove_filter('pre_option_comments_per_page', array($this, 'pre_option_comments_per_page')); remove_filter('pre_option_page_comments', array($this, 'pre_option_page_comments')); if (isset($old_post)) { wp_reset_postdata(); $post = $old_post; } return $output; }
/** * Retrieve the archive title based on the queried object. * * @return string Archive title. */ function get_the_archive_title($before = '', $after = '') { if (!TF_Model::is_template_page()) { if (is_category()) { $title = single_cat_title('', false); } elseif (is_tag()) { $title = single_tag_title('', false); } elseif (is_author()) { $title = sprintf(__('Author: %s', 'themify-flow'), '<span class="vcard">' . get_the_author() . '</span>'); } elseif (is_year()) { $title = sprintf(__('Year: %s', 'themify-flow'), get_the_date(_x('Y', 'yearly archives date format', 'themify-flow'))); } elseif (is_month()) { $title = sprintf(__('Month: %s', 'themify-flow'), get_the_date(_x('F Y', 'monthly archives date format', 'themify-flow'))); } elseif (is_day()) { $title = sprintf(__('Day: %s', 'themify-flow'), get_the_date(_x('F j, Y', 'daily archives date format', 'themify-flow'))); } elseif (is_tax('post_format')) { if (is_tax('post_format', 'post-format-aside')) { $title = _x('Asides', 'post format archive title', 'themify-flow'); } elseif (is_tax('post_format', 'post-format-gallery')) { $title = _x('Galleries', 'post format archive title', 'themify-flow'); } elseif (is_tax('post_format', 'post-format-image')) { $title = _x('Images', 'post format archive title', 'themify-flow'); } elseif (is_tax('post_format', 'post-format-video')) { $title = _x('Videos', 'post format archive title', 'themify-flow'); } elseif (is_tax('post_format', 'post-format-quote')) { $title = _x('Quotes', 'post format archive title', 'themify-flow'); } elseif (is_tax('post_format', 'post-format-link')) { $title = _x('Links', 'post format archive title', 'themify-flow'); } elseif (is_tax('post_format', 'post-format-status')) { $title = _x('Statuses', 'post format archive title', 'themify-flow'); } elseif (is_tax('post_format', 'post-format-audio')) { $title = _x('Audio', 'post format archive title', 'themify-flow'); } elseif (is_tax('post_format', 'post-format-chat')) { $title = _x('Chats', 'post format archive title', 'themify-flow'); } } elseif (is_post_type_archive()) { $title = sprintf(__('%s', 'themify-flow'), post_type_archive_title('', false)); } elseif (is_tax()) { $tax = get_taxonomy(get_queried_object()->taxonomy); /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */ $title = sprintf(__('%1$s: %2$s', 'themify-flow'), $tax->labels->singular_name, single_term_title('', false)); } else { $title = ''; } /** * Filter the archive title. * * @param string $title Archive title to be displayed. */ $title = apply_filters('get_the_archive_title', $title); if (!empty($title)) { $title = $before . $title . $after; } } else { $title = sprintf('<p>%s</p>', __('<strong>Category Title</strong>', 'themify-flow')); } return $title; }
/** * Render main shortcode. * * @since 1.0.0 * @access public * @param array $atts * @param string $content * @return string */ public function render_shortcode($atts, $content = null) { $atts = shortcode_atts(array('title_tag' => ''), $atts, $this->shortcode); // must add the third params $this->shortcode, for builder shortcode rendering if (!TF_Model::is_template_page()) { /** We can separate the module markup in separated template file later */ $output = sprintf('<%1$s class="tf_page_title">%2$s</%1$s>', $atts['title_tag'], get_the_title()); } else { $output = sprintf('<p>%s</p>', __('<strong>Page Title</strong>', 'themify-flow')); } return $output; }
/** * Render main shortcode. * * @since 1.0.0 * @access public * @param array $atts * @param string $content * @return string */ public function render_shortcode($atts, $content = null) { $atts = shortcode_atts(array(), $atts, $this->shortcode); // must add the third params $this->shortcode, for builder shortcode rendering global $query_string, $TF; $output = ''; $build_query = array('post_type' => 'post'); if (TF_Model::is_template_page()) { query_posts(build_query($build_query)); } else { query_posts($query_string); } if (have_posts()) { $TF->in_archive_loop = true; the_post(); ob_start(); ?> <?php do_action('tf_single_loop_before_post'); ?> <article <?php echo tf_get_attr('post', $original_atts); ?> > <?php do_action('tf_single_loop_start_post'); ?> <?php echo do_shortcode($content); ?> <?php do_action('tf_single_loop_end_post'); ?> </article> <?php do_action('tf_single_loop_after_post'); ?> <?php $output .= ob_get_contents(); ob_get_clean(); $TF->in_archive_loop = false; } wp_reset_query(); return $output; }
/** * Render main shortcode. * * @since 1.0.0 * @access public * @param array $atts * @param string $content * @return string */ public function render_shortcode($atts, $content = null) { /** Use condition here to prevent infinite loop issue that cause memory limit error */ /** If viewing template page (view/frontend editor) echo preview text since the actual the_content is the builder data in a bunch of shortcodes */ $output = ''; if (!TF_Model::is_template_page()) { // make sure $post exist global $post; if (is_object($post) && !is_admin()) { $output = apply_filters('the_content', $post->post_content); $output = str_replace(']]>', ']]>', $output); } } else { $output = sprintf('<p>%s</p>', __('<strong>This is only preview text.</strong> The text content here will be replaced with actual page content when viewing the real page.', 'themify-flow')); } return '<div class="tf_page_content">' . $output . '</div>'; }
/** * Render main shortcode. * * @since 1.0.0 * @access public * @param array $atts * @param string $content * @return string */ public function render_shortcode($atts, $content = null) { extract(shortcode_atts(array('first_page_only' => 'yes'), $atts, $this->shortcode)); if (!TF_Model::is_template_page()) { if ('yes' == $first_page_only && is_paged()) { return ''; } ob_start(); ?> <?php the_archive_description('<div class="tf_category_description">', '</div>'); ?> <?php $output = ob_get_clean(); } else { $output = sprintf('<p>%s</p>', __('<strong>This is only preview text.</strong> The text content here will be replaced with actual category description when viewing the real page.', 'themify-flow')); } return $output; }
/** * Render main shortcode. * * @since 1.0.0 * @access public * @param array $atts * @param string $content * @return string */ public function render_shortcode($original_atts, $content = null) { global $wp_query, $query_string, $TF; $atts = shortcode_atts(array('layout' => 'post-list', 'order' => 'DESC', 'orderby' => 'date', 'pagination' => 'yes'), $original_atts, $this->shortcode); $output = ''; $build_query = array('posts_per_page' => get_option('posts_per_page'), 'order' => $atts['order'], 'orderby' => $atts['orderby']); if (TF_Model::is_template_page()) { query_posts(build_query($build_query)); } else { //query_posts( array_merge( $wp_query->query_vars, $build_query ) ); // Fix Product archive page (site.com/shop) doesn't query product post_type, somehow using $query_string works. query_posts($query_string . '&' . build_query($build_query)); } if (have_posts()) { ob_start(); ?> <!-- loopswrapper --> <div class="tf_loops_wrapper clearfix <?php echo esc_attr($atts['layout']); ?> "> <?php $TF->in_archive_loop = true; while (have_posts()) { the_post(); ?> <?php do_action('tf_archive_loop_before_post'); ?> <article <?php echo tf_get_attr('post', $original_atts); ?> > <?php do_action('tf_archive_loop_start_post'); ?> <?php echo do_shortcode($content); ?> <?php do_action('tf_archive_loop_end_post'); ?> </article> <?php do_action('tf_archive_loop_after_post'); ?> <?php } $TF->in_archive_loop = false; ?> </div><!-- /tf_loops_wrapper --> <?php // Pagination links if ('yes' == $atts['pagination']) { get_template_part('includes/pagination', $wp_query->query_vars['post_type']); } $output = ob_get_contents(); ob_get_clean(); } wp_reset_query(); wp_reset_postdata(); return $output; }
public function shortcode_handler($atts, $content, $code) { global $TF; if ($TF->in_template_part && !TF_Model::is_template_page()) { if (is_array($this->category)) { $cat = array_intersect($this->category, array('archive', 'page', 'single')); if (!empty($cat)) { $cat = current($cat); } } else { $cat = $this->category; } if (in_array($cat, array('archive', 'page', 'single')) && !is_admin()) { if ($cat == 'page' && !is_page()) { return FALSE; } elseif ($cat == 'single' && !is_single()) { return FALSE; } elseif ($cat == 'archive' && !is_search() && !is_tax() && !is_archive() && !is_post_type_archive()) { return FALSE; } } } $atts = apply_filters('tf_shortcode_atts', $atts, $code, $this); /** * Put module wrapper markup here directly instead using apply_filters() * since this wrapper markup is required for each modules. */ if (!isset($atts['sc_id'])) { $atts['sc_id'] = TF_Model::generate_block_id(); } $classes = apply_filters('tf_module_classes', array('tf_module_wrapper', 'tf_module_block', 'tf_module_' . $this->slug, 'tf_module_block_' . $atts['sc_id']), $atts); $wrapper_atts = apply_filters('tf_module_wrapper_atts', array('class' => $classes), $atts, $content, $this); $wrapper_atts['class'] = implode(' ', $wrapper_atts['class']); $atts_output = ''; foreach ($wrapper_atts as $key => $value) { $atts_output .= sprintf(' %s="%s"', $key, esc_attr($value)); } $pre = sprintf('<div %s>', $atts_output); $after = '</div>'; $output = $pre . $this->render_shortcode($atts, $content) . $after; return apply_filters('tf_shortcode_module_render', $output, $this->slug, $atts, $content); }
<?php if (!defined('ABSPATH')) { exit; } // Exit if accessed directly /** * Builder Frontend Panel HTML */ global $TF_Layout, $post; if (!TF_Model::is_tf_styling_active() && (TF_Model::is_template_page() || TF_Model::is_content_builder_page())) { $module_groups = TF_Model::get_module_group_by_category(); if (is_object($post) && !is_singular(array('tf_template', 'tf_template_part'))) { $current_template_type = 'content'; } else { $current_template_type = empty($TF_Layout->type) ? 'global' : $TF_Layout->type; } $tabs_exclude = array('archive' => array('single', 'page'), 'single' => array('archive', 'page'), 'page' => array('archive', 'single'), 'global' => array('archive', 'single', 'page'), 'content' => array('archive', 'single', 'page', 'global')); ?> <div class="tf_front_panel tf_interface"> <div id="tf_module_panel" class="tf_module_panel clearfix"> <a class="tf_slide_builder_module_panel" href="#"><?php _e('Slide', 'themify-flow'); ?> </a> <div class="tf_slide_builder_module_wrapper"> <div class="tf_module_tabs">
/** * Render main shortcode. * * @since 1.0.0 * @access public * @param array $atts * @param string $content * @return string */ public function render_shortcode($atts, $content = null) { $atts = shortcode_atts(array('image_size' => 'blank', 'image_width' => '', 'image_height' => ''), $atts, $this->shortcode); // must add the third params $this->shortcode, for builder shortcode rendering if (!TF_Model::is_template_page()) { $output = ''; $cat = get_query_var('cat'); if ($cat) { $categories = get_option('tf-categories-image'); if (isset($categories[$cat]) && $categories[$cat]) { $category = get_category($cat); $thumbnail_title = $category->name; $post_image = sprintf('<img src="%s" alt="%s" width="%s" height="%s" />', esc_url($categories[$cat]), esc_attr($thumbnail_title), esc_attr($atts['image_width']), esc_attr($atts['image_height'])); $output = '<figure class="tf_category_image">' . $post_image . '</figure>'; } } } else { if (!$atts['image_width']) { $atts['image_width'] = '350'; } if (!$atts['image_height']) { $atts['image_height'] = '150'; } $output = '<figure class="tf_category_image"><img width="' . $atts['image_width'] . '" height="' . $atts['image_height'] . '" src="http://placehold.it/' . $atts['image_width'] . 'x' . $atts['image_height'] . '" /></figure>'; } return apply_filters('tf_shortcode_element_render', $output, $this->slug, $atts, $content); }