function wpv_filter_meta_html($atts) { extract(shortcode_atts(array(), $atts)); global $WP_Views; $view_settings = $WP_Views->get_view_settings(); if (isset($view_settings['filter_meta_html'])) { $content = wpml_content_fix_links_to_translated_content($view_settings['filter_meta_html']); return wpv_do_shortcode($content); } else { return ''; } }
/** * apply the filter to the content/body of a post. * Checks to see if a view-template is set for the post * and renders using the view_template if on exists */ function the_content($content) { global $id, $post, $wpdb, $WP_Views, $wp_query, $wplogger; if (post_password_required($post)) { return $content; } // core functions that we except calls from. static $the_content_core = array('the_content', 'wpv_shortcode_wpv_post_body'); // known theme functions that we except calls from. static $the_content_themes = array('wptouch_the_content'); $db = debug_backtrace(); if (!isset($db[3]['function'])) { return $content; } $function_ok = false; if ($db[1]['function'] == 'the_excerpt_for_archives') { $function_ok = true; } if (!$function_ok) { if (in_array($db[3]['function'], $the_content_core)) { $function_ok = true; } } if (!$function_ok) { if (in_array($db[3]['function'], $the_content_themes)) { $function_ok = true; } } if (!$function_ok) { $options = $WP_Views->get_options(); if (isset($options['wpv-theme-function'])) { if (in_array($db[3]['function'], explode(',', str_replace(', ', ',', $options['wpv-theme-function'])))) { $function_ok = true; } } if (!$function_ok) { // We don't except calls from the calling function. if (current_user_can('administrator')) { if (isset($options['wpv-theme-function-debug']) && $options['wpv-theme-function-debug']) { $content = sprintf(__('<strong>View template debug: </strong>Calling function is <strong>%s</strong>', 'wpv-views'), $db[3]['function']) . '<br />' . $content; } } return $content; } } // If it's in progress then just return the un-filtered content // to avoid recursion static $in_progress = array(); if (in_array($id, array_keys($in_progress))) { return $content; } $in_progress[$id] = true; static $view_options = null; static $taxonomy_loop = null; static $archive_loop = null; if (!$view_options) { $view_options = $WP_Views->get_options(); if (is_archive()) { /* Taxonomy archives. */ if (is_tax() || is_category() || is_tag()) { $term = $wp_query->get_queried_object(); $taxonomy_loop = 'views_template_loop_' . $term->taxonomy; } else { if (is_post_type_archive($post->post_type)) { $archive_loop = 'views_template_archive_for_' . $post->post_type; } else { if ('post' == $post->post_type) { $archive_loop = 'views_template_archive_for_post'; } } } } } $template_selected = 0; if (isset($_GET['view-template']) && $_GET['view-template'] != '') { if (!isset($post->view_template_override_get)) { $template_selected = $this->get_template_id($_GET['view-template']); $post->view_template_override_get = true; } } else { if (isset($post->view_template_override)) { if (strtolower($post->view_template_override) == 'none') { $template_selected = 0; } else { $template_selected = $this->get_template_id($post->view_template_override); } } else { if ($taxonomy_loop) { if (isset($view_options[$taxonomy_loop]) && $view_options[$taxonomy_loop] > 0) { if (!isset($post->view_template_override_loop_setting)) { $template_selected = $view_options[$taxonomy_loop]; $post->view_template_override_loop_setting = true; } } } else { if ($archive_loop) { if (isset($view_options[$archive_loop]) && $view_options[$archive_loop] > 0) { if (!isset($post->view_template_override_loop_setting)) { $template_selected = $view_options[$archive_loop]; $post->view_template_override_loop_setting = true; } } } else { $template_selected = get_post_meta($id, '_views_template', true); } } } } if ($template_selected) { if (function_exists('icl_object_id')) { $template_selected = icl_object_id($template_selected, 'view-template', true); } $this->view_template_used_ids[] = $template_selected; $wplogger->log('Using view template: ' . $template_selected . ' on post: ' . $post->ID); $content = $this->get_template_content($template_selected); $output_mode = get_post_meta($template_selected, '_wpv_view_template_mode', true); if ($output_mode == 'raw_mode') { $this->remove_wpautop(); } } unset($in_progress[$id]); $content = wpml_content_fix_links_to_translated_content($content); return $content; }
/** * Render the view and loops through the found posts * */ function render_view($view_id, $hash) { global $post; global $wplogger; static $processed_views = array(); // increment the view count. if (!isset($this->view_count[$this->view_depth])) { $this->view_count[$this->view_depth] = 0; } $this->view_count[$this->view_depth]++; $view = get_post($view_id); $this->view_used_ids[] = $view_id; $out = ''; /* $css = get_post_meta($view_id, '_wpv_css', true); if ($css) { $out .= "<style type='text/css'>\n"; $out .= $css; $out .= "\n</style>"; } */ $view_caller_id = isset($post) && isset($post->ID) ? get_the_ID() : 0; // post or widget if (!isset($processed_views[$view_caller_id][$hash]) || 0 === $view_caller_id) { //$processed_views[$view_caller_id][$hash] = true; // mark view as processed for this post if (!empty($view)) { $post_content = $view->post_content; // apply the layout meta html if we have some. $view_layout_settings = $this->get_view_layout_settings(); if (isset($view_layout_settings['layout_meta_html'])) { $post_content = str_replace('[wpv-layout-meta-html]', $view_layout_settings['layout_meta_html'], $post_content); } $post_content = wpml_content_fix_links_to_translated_content($post_content); $view_settings = $this->get_view_settings(); // find the loop if (preg_match('#\\<wpv-loop(.*?)\\>(.*)</wpv-loop>#is', $post_content, $matches)) { // get the loop arguments. $args = $matches[1]; $exp = array_map('trim', explode(' ', $args)); $args = array(); foreach ($exp as $e) { $kv = explode('=', $e); if (sizeof($kv) == 2) { $args[$kv[0]] = trim($kv[1], '\'"'); } } if (isset($args['wrap'])) { $args['wrap'] = intval($args['wrap']); } if (isset($args['pad'])) { $args['pad'] = $args['pad'] == 'true'; } else { $args['pad'] = false; } $tmpl = $matches[2]; $item_indexes = $this->_get_item_indexes($tmpl); if ($view_settings['query_type'][0] == 'posts') { // get the posts using the query settings for this view. $archive_query = null; if ($view_settings['view-query-mode'] == 'archive') { // check for an archive loop global $WPV_view_archive_loop; if (isset($WPV_view_archive_loop)) { $archive_query = $WPV_view_archive_loop->get_archive_loop_query(); } } if ($archive_query) { $this->post_query = $archive_query; } else { $this->post_query = wpv_filter_get_posts($view_id); } $items = $this->post_query->posts; $wplogger->log('Found ' . count($items) . ' posts'); if ($wplogger->isMsgVisible(WPLOG_DEBUG)) { // simplify the output $out_items = array(); foreach ($items as $item) { $out_items[] = array('ID' => $item->ID, 'post_title' => $item->post_title); } $wplogger->log($out_items, WPLOG_DEBUG); } } // save original post global $post, $authordata, $id; $tmp_post = isset($post) ? clone $post : null; if ($authordata) { $tmp_authordata = clone $authordata; } else { $tmp_authordata = null; } $tmp_id = $id; if ($view_settings['query_type'][0] == 'taxonomy') { $items = $this->taxonomy_query($view_settings); $wplogger->log($items, WPLOG_DEBUG); // taxonomy views can be recursive so remove from // the processed array //unset($processed_views[$view_caller_id][$hash]); } $loop = ''; for ($i = 0; $i < count($items); $i++) { $index = $i; if (isset($args['wrap'])) { $index %= $args['wrap']; } $index++; // [wpv-item index=xx] uses base 1 $index = strval($index); if ($view_settings['query_type'][0] == 'posts') { $post = clone $items[$i]; $authordata = new WP_User($post->post_author); $id = $post->ID; $temp_variables = $this->variables; $this->variables = array(); do_action('wpv-before-display-post', $post, $view_id); } if ($view_settings['query_type'][0] == 'taxonomy') { $this->taxonomy_data['term'] = $items[$i]; } // first output the "all" index. $loop .= wpv_do_shortcode($item_indexes['all']); // Output each index we find // otherwise output 'other' if (isset($item_indexes[$index])) { $loop .= wpv_do_shortcode($item_indexes[$index]); } elseif (isset($item_indexes['other'])) { $loop .= wpv_do_shortcode($item_indexes['other']); } if ($view_settings['query_type'][0] == 'posts') { do_action('wpv-after-display-post', $post, $view_id); $this->variables = $temp_variables; } } // see if we should pad the remaining items. if (isset($args['wrap']) && isset($args['pad'])) { while ($i % $args['wrap'] && $args['pad']) { $index = $i; $index %= $args['wrap']; if ($index == $args['wrap'] - 1) { $loop .= wpv_do_shortcode($item_indexes['pad-last']); } else { $loop .= wpv_do_shortcode($item_indexes['pad']); } $i++; } } $out .= str_replace($matches[0], $loop, $post_content); $post = isset($tmp_post) ? clone $tmp_post : null; // restore original $post if ($tmp_authordata) { $authordata = clone $tmp_authordata; } else { $authordata = null; } $id = $tmp_id; } } else { $out .= sprintf('<!- %s ->', __('View not found', 'wpv-views')); } } else { if ($processed_views[$view_caller_id][$hash] !== true) { $out .= $processed_views[$view_caller_id][$hash]; // use output from cache } } return $out; }
/** * Render the view and loops through the found posts */ function render_view($view_id, $hash) { global $post, $WPVDebug, $wplogger; static $processed_views = array(); // increment the view count. // TODO this code is duplicated, maybe create function for it? if (!isset($this->view_count[$this->view_depth])) { $this->view_count[$this->view_depth] = 0; } $this->view_count[$this->view_depth]++; $view = get_post($view_id); $this->view_used_ids[] = $view_id; $out = ''; $view_caller_id = isset($post) && isset($post->ID) ? get_the_ID() : 0; // post or widget if (!isset($processed_views[$view_caller_id][$hash]) || 0 === $view_caller_id) { //$processed_views[$view_caller_id][$hash] = true; // mark view as processed for this post $status = get_post_status($view_id); // Views should be 'publish'ed to be allowed to produce an output // FIXME: Check also that user has permissions to render this view if (!empty($view) && $status == 'publish') { $post_content = $view->post_content; // apply the layout meta html if we have some. $view_layout_settings = $this->get_view_layout_settings(); if (isset($view_layout_settings['layout_meta_html'])) { $post_content = str_replace('[wpv-layout-meta-html]', $view_layout_settings['layout_meta_html'], $post_content); } $post_content = wpml_content_fix_links_to_translated_content($post_content); $view_settings = $this->get_view_settings(); // find the loop if (preg_match('#\\<wpv-loop(.*?)\\>(.*)</wpv-loop>#is', $post_content, $matches)) { // get the loop arguments. $args = $matches[1]; $exp = array_map('trim', explode(' ', $args)); $args = array(); foreach ($exp as $e) { $kv = explode('=', $e); if (sizeof($kv) == 2) { $args[$kv[0]] = trim($kv[1], '\'"'); } } if (isset($args['wrap'])) { $args['wrap'] = intval($args['wrap']); } if (isset($args['pad'])) { $args['pad'] = $args['pad'] == 'true'; } else { $args['pad'] = false; } // Get templates for items (differentiated by their indices, see [wpv-item] documentation). $tmpl = $matches[2]; $item_indexes = $this->_get_item_indexes($tmpl); if ($view_settings['query_type'][0] == 'posts') { // get the posts using the query settings for this view. $archive_query = null; if ($view_settings['view-query-mode'] == 'archive') { // check for an archive loop global $WPV_view_archive_loop; if (isset($WPV_view_archive_loop)) { $archive_query = $WPV_view_archive_loop->get_archive_loop_query(); } } else { if ($view_settings['view-query-mode'] == 'layouts-loop') { global $wp_query; $archive_query = isset($wp_query) && $wp_query instanceof WP_Query ? clone $wp_query : null; } } if ($archive_query) { $this->post_query = $archive_query; } else { $this->post_query = wpv_filter_get_posts($view_id); } $items = $this->post_query->posts; $wplogger->log('Found ' . count($items) . ' posts'); if ($wplogger->isMsgVisible(WPLOG_DEBUG)) { // simplify the output $out_items = array(); foreach ($items as $item) { $out_items[] = array('ID' => $item->ID, 'post_title' => $item->post_title); } $wplogger->log($out_items, WPLOG_DEBUG); } } // save original post global $post, $authordata, $id; $tmp_post = isset($post) && $post instanceof WP_Post ? clone $post : null; $tmp_authordata = isset($authordata) && is_object($authordata) ? clone $authordata : null; $tmp_id = $id; if ($view_settings['query_type'][0] == 'taxonomy') { $items = $this->taxonomy_query($view_settings); $wplogger->log($items, WPLOG_DEBUG); // taxonomy views can be recursive so remove from the processed array //unset($processed_views[$view_caller_id][$hash]); } else { if ($view_settings['query_type'][0] == 'users') { $items = $this->users_query($view_settings); $wplogger->log($items, WPLOG_DEBUG); } } global $WPV_settings; if (isset($WPV_settings->wpv_debug_mode) && !empty($WPV_settings->wpv_debug_mode)) { $WPVDebug->add_log('items_count', count($items)); } // The actual loop - render all items $loop = ''; for ($i = 0; $i < count($items); $i++) { $WPVDebug->set_index(); $index = $i; if (isset($args['wrap'])) { $index %= $args['wrap']; } // [wpv-item index=xx] uses base 1 $index++; $index = strval($index); if ($view_settings['query_type'][0] == 'posts') { $post = clone $items[$i]; $authordata = new WP_User($post->post_author); $id = $post->ID; $temp_variables = $this->variables; $this->variables = array(); do_action('wpv-before-display-post', $post, $view_id); } elseif ($view_settings['query_type'][0] == 'taxonomy') { $this->taxonomy_data['term'] = $items[$i]; do_action('wpv-before-display-taxonomy', $items[$i], $view_id); } elseif ($view_settings['query_type'][0] == 'users') { $user_id = $items[$i]->ID; $user_meta = get_user_meta($user_id); $items[$i]->meta = $user_meta; $this->users_data['term'] = $items[$i]; do_action('wpv-before-display-user', $items[$i], $view_id); } $WPVDebug->add_log($view_settings['query_type'][0], $items[$i]); // first output the "all" index. $shortcodes_output = wpv_do_shortcode($item_indexes['all']); $loop .= $shortcodes_output; $WPVDebug->add_log_item('shortcodes', $item_indexes['all']); $WPVDebug->add_log_item('output', $shortcodes_output); /* Select a template for this item based on it's index. * Note: It is possible that we won't be rendering this item's content if the index 'other' * isn't set and there is no other match. */ $selected_index = null; if (isset($item_indexes[$index])) { $selected_index = $index; } elseif (isset($item_indexes['odd']) && $index % 2 == 1) { $selected_index = 'odd'; } elseif (isset($item_indexes['even']) && $index % 2 == 0) { $selected_index = 'even'; } elseif (isset($item_indexes['other'])) { $selected_index = 'other'; } // Output the item with appropriate template (if we found one) if (null !== $selected_index) { $shortcodes_output = wpv_do_shortcode($item_indexes[$selected_index]); $loop .= $shortcodes_output; $WPVDebug->add_log_item('shortcodes', $item_indexes[$selected_index]); $WPVDebug->add_log_item('output', $shortcodes_output); } // Do wpv-after-display-* action after displaying the item if ($view_settings['query_type'][0] == 'posts') { do_action('wpv-after-display-post', $post, $view_id); $this->variables = $temp_variables; } elseif ($view_settings['query_type'][0] == 'taxonomy') { do_action('wpv-after-display-taxonomy', $items[$i], $view_id); } elseif ($view_settings['query_type'][0] == 'users') { do_action('wpv-after-display-user', $items[$i], $view_id); } } // see if we should pad the remaining items. if (isset($args['wrap']) && isset($args['pad'])) { while ($i % $args['wrap'] && $args['pad']) { $index = $i; $index %= $args['wrap']; if ($index == $args['wrap'] - 1) { $loop .= wpv_do_shortcode($item_indexes['pad-last']); } else { $loop .= wpv_do_shortcode($item_indexes['pad']); } $i++; } } $WPVDebug->clean_index(); $out .= str_replace($matches[0], $loop, $post_content); // restore original $post $post = isset($tmp_post) && $tmp_post instanceof WP_Post ? clone $tmp_post : null; $authordata = isset($tmp_authordata) && is_object($tmp_authordata) ? clone $tmp_authordata : null; $id = $tmp_id; } } else { $out .= sprintf('<!- %s ->', __('View not found', 'wpv-views')); } } else { if ($processed_views[$view_caller_id][$hash] !== true) { // use output from cache $out .= $processed_views[$view_caller_id][$hash]; } } return $out; }
/** * render_view_template * * Returns the content of a Content Template applied to a Post * * @param $view_template_id (integer) ID of the relevant Content Template * @param $post_in (post object) post to apply the Content Template to * @param $current_user_in (optional) (user object) sets the global $current_user * * @usage <?php echo render_view_template(80, $mypost)); ?> * * @note we need to set the global $authordata to the right user * * @since unknown */ function render_view_template($view_template_id, $post_in = null, $current_user_in = null) { global $WPV_templates, $post, $current_user, $authordata; // Save current globals to restore them later $post_old = $post; $current_user_old = $current_user; $authordata_old = $authordata; if ($post_in) { $post = $post_in; $authordata = new WP_User($post->post_author); } if ($current_user_in) { $current_user = $current_user_in; } // Adjust for WPML support $view_template_id = apply_filters('translate_object_id', $view_template_id, 'view-template', true, null); $content = $WPV_templates->get_template_content($view_template_id); // If this function returns null, $view_template_id does not exist or is not a Content Template or its status is different from 'publish' if (is_null($content)) { $content = ''; } else { $WPV_templates->view_template_used_ids[] = $view_template_id; $output_mode = get_post_meta($view_template_id, '_wpv_view_template_mode', true); if ($output_mode == 'raw_mode') { $WPV_templates->remove_wpautop(); } $content = wpml_content_fix_links_to_translated_content($content); $content = apply_filters('the_content', $content); } // Restore current globals $post = $post_old; $current_user = $current_user_old; $authordata = $authordata_old; return $content; }
/** * render_view_template * * Returns the content of a Content Template applied to a Post * * @param integer $view_template_id ID of the relevant Content Template * @param object $post_in Post to apply the Content Template to * @param object $current_user_in Sets the global $current_user * @param array $args Extra arguments to be used * * @usage <?php echo render_view_template(80, $mypost)); ?> * * @note we need to set the global $authordata to the right user * * @since unknown */ function render_view_template( $view_template_id, $post_in = null, $current_user_in = null, $args = array() ) { $ct_post = get_post( $view_template_id ); if ( ! $ct_post || $ct_post->post_status != 'publish' || $ct_post->post_type != 'view-template' ) { return ''; } global $WPV_templates, $post, $current_user, $authordata; // Save current globals to restore them later $post_old = $post; $current_user_old = $current_user; $authordata_old = $authordata; if ( $post_in ) { $post = $post_in; $authordata = new WP_User( $post->post_author ); } if ( $current_user_in ) { $current_user = $current_user_in; } // Adjust for WPML support $view_template_id = apply_filters( 'translate_object_id', $view_template_id, 'view-template', true, null ); $content = $WPV_templates->get_template_content( $view_template_id ); // If this function returns null, $view_template_id does not exist or is not a Content Template or its status is different from 'publish' if ( is_null( $content ) ) { $content = ''; } else { $WPV_templates->view_template_used_ids[] = $view_template_id; $output_mode = get_post_meta( $view_template_id, '_wpv_view_template_mode', true ); if ( $output_mode == 'raw_mode' ) { $WPV_templates->remove_wpautop(); } $content = wpml_content_fix_links_to_translated_content( $content ); if ( /** * wpv_filter_wpv_render_view_template_force_suppress_filters * * Force the use of the restricted wpv_filter_wpv_the_content_suppressed filter instead of the the_content one. * * @param bool Defaults to false * @param object $ct_post The Content Template post object * @param object $post_in Post object to overwrote the global $post * @param object $current_user_in User object that overwrote the global $current_user * @param array $args Extra arguments passed to the function * * Since 1.10 */ apply_filters( 'wpv_filter_wpv_render_view_template_force_suppress_filters', false, $ct_post, $post_in, $current_user_in, $args ) || ( isset( $args['suppress_filters'] ) && $args['suppress_filters'] ) ) { $content = apply_filters( 'wpv_filter_wpv_the_content_suppressed', $content ); } else { $content = apply_filters( 'the_content', $content ); } } // Restore current globals $post = $post_old; $current_user = $current_user_old; $authordata = $authordata_old; return $content; }
/** * apply the filter to the content/body of a post. * Checks to see if a view-template is set for the post * and renders using the view_template if on exists */ function the_content($content) { global $id, $post, $wpdb, $WP_Views, $wp_query, $wplogger, $WPVDebug; if (post_password_required($post)) { return $content; } // core functions that we except calls from. static $the_content_core = array('the_content', 'wpv_shortcode_wpv_post_body'); // known theme functions that we except calls from. static $the_content_themes = array('wptouch_the_content'); $db = debug_backtrace(); if (!isset($db[3]['function'])) { return $content; } $function_ok = false; if ($db[1]['function'] == 'the_excerpt_for_archives') { $function_ok = true; } if (!$function_ok) { if (in_array($db[3]['function'], $the_content_core)) { $function_ok = true; } } if (!$function_ok) { if (in_array($db[3]['function'], $the_content_themes)) { $function_ok = true; } } if (!$function_ok) { $options = $WP_Views->get_options(); if (isset($options['wpv-theme-function'])) { if (in_array($db[3]['function'], explode(',', str_replace(', ', ',', $options['wpv-theme-function'])))) { $function_ok = true; } } if (!$function_ok) { // We don't except calls from the calling function. if (current_user_can('administrator')) { if (isset($options['wpv-theme-function-debug']) && $options['wpv-theme-function-debug']) { $content = sprintf(__('<strong>Content template debug: </strong>Calling function is <strong>%s</strong>', 'wpv-views'), $db[3]['function']) . '<br />' . $content; } } return $content; } } // If it's in progress then just return the un-filtered content // to avoid recursion static $in_progress = array(); if (in_array($id, array_keys($in_progress))) { return $content; } // Here we will store what kind of place this template is being used on: single-{post-type}, singular, archive-{post-type}, archive-{taxonomy}, archive, listing-{post-type} $kind = ''; if (is_singular()) { $current_page = $WP_Views->get_top_current_page(); if (is_null($current_page) || !isset($current_page->ID)) { $current_id = 0; } else { $current_id = $current_page->ID; } if (isset($post->post_type)) { if ($current_id == $post->ID) { $kind = 'single-' . $post->post_type; } else { $kind = 'listing-' . $post->post_type; } } else { $kind = 'singular'; } } $in_progress[$id] = true; static $view_options = null; static $taxonomy_loop = null; static $archive_loop = null; if (!$view_options) { $view_options = $WP_Views->get_options(); if (is_archive()) { /* Taxonomy archives. */ if (is_tax() || is_category() || is_tag()) { $term = $wp_query->get_queried_object(); $taxonomy_loop = 'views_template_loop_' . $term->taxonomy; $kind = 'archive-' . $term->taxonomy; } else { if (is_post_type_archive($post->post_type)) { $archive_loop = 'views_template_archive_for_' . $post->post_type; $kind = 'archive-' . $post->post_type; } else { if ('post' == $post->post_type) { $archive_loop = 'views_template_archive_for_post'; $kind = 'archive-post'; } else { // if on an archive page but not a tax one and not on the archive for the displayed $post, then it's a generic archive $kind = 'archive'; } } } } } $template_selected = 0; $template_apply_filter = true; if (isset($_GET['view-template']) && $_GET['view-template'] != '') { if (!isset($post->view_template_override_get)) { $template_selected = $this->get_template_id($_GET['view-template']); $post->view_template_override_get = true; } } else { if (isset($_GET['cred-edit-form']) && $_GET['cred-edit-form'] != '') { // special case when displaying CRED forms if (isset($post->view_template_override) && strtolower($post->view_template_override) != 'none') { // if displaying CRED form and this template is inside the form in a wpv-post-body shortcode, apply it $template_selected = $this->get_template_id($post->view_template_override); } else { // if this template is being used for the post type being edited by a CRED form, do not apply it $template_selected = 0; $template_apply_filter = false; } } else { if (isset($post->view_template_override)) { if (strtolower($post->view_template_override) == 'none') { $template_selected = 0; } else { $template_selected = $this->get_template_id($post->view_template_override); } } else { if ($taxonomy_loop) { if (isset($view_options[$taxonomy_loop]) && $view_options[$taxonomy_loop] > 0) { if (!isset($post->view_template_override_loop_setting)) { $template_selected = $view_options[$taxonomy_loop]; $post->view_template_override_loop_setting = true; } } } else { if ($archive_loop) { if (isset($view_options[$archive_loop]) && $view_options[$archive_loop] > 0) { if (!isset($post->view_template_override_loop_setting)) { $template_selected = $view_options[$archive_loop]; $post->view_template_override_loop_setting = true; } } } else { $template_selected = get_post_meta($id, '_views_template', true); } } } } } if ($template_apply_filter) { /** * Filter wpv_filter_force_template * * @param $template_selected the template ID we want to overwrite * @param $id the post the template is being applied to * @param $kind the kind of place where this template is being used: single-{post-type}, singular, archive-{post-type}, archive-{taxonomy}, archive, listing-{post-type} * * @return $template_selected * * Since 1.4 * */ $old_template_selected = $template_selected; $template_selected = apply_filters('wpv_filter_force_template', $template_selected, $id, $kind); // $WPVDebug->add_log( 'info' , "wpv_filter_force_template\n" . __('ID: ', 'wpv-views') . $id . "\n" . __('Content Template: from ', 'wpv-views') . $old_template_selected . __(' to ', 'wpv-views') . $template_selected, 'filters', 'Filter: wpv_filter_force_template' ); // The debug is not being added, I will need a better way to show this } $WPVDebug->update_template_id($template_selected); if ($template_selected) { if (function_exists('icl_object_id')) { $template_selected = icl_object_id($template_selected, 'view-template', true); } $this->view_template_used_ids[] = $template_selected; $wplogger->log('Using Content Template: ' . $template_selected . ' on post: ' . $post->ID); $content = $this->get_template_content($template_selected); $output_mode = get_post_meta($template_selected, '_wpv_view_template_mode', true); if ($output_mode == 'raw_mode') { $this->remove_wpautop(); } } $content = wpml_content_fix_links_to_translated_content($content); $WPVDebug->add_log_item('shortcodes', $content); /** * Filter wpv_filter_content_template_output * * @param $content the content to be displayed, whether it's the real post content or the one coming from a Content Template * @param $template_selected the template ID being applied, can be 0 when there is none * @param $id the post the template is being applied to * @param $kind the kind of place where this template is being used: single-{post-type}, singular, archive-{post-type}, archive-{taxonomy}, archive, listing-{post-type} * * @return $content * * Since 1.5.1 * */ $content = apply_filters('wpv_filter_content_template_output', $content, $template_selected, $id, $kind); unset($in_progress[$id]); return $content; }