/** * Hook to content filter to show builder output * @param $content * @return string */ function builder_show_on_front($content) { global $post, $wp_query, $wp_current_filter; // Exclude builder output in admin post list mode excerpt, Dont show builder on product single description if (is_admin() && !defined('DOING_AJAX') || is_post_type_archive() && !is_post_type_archive('product') || in_array('get_the_excerpt', $wp_current_filter) || post_password_required() || isset($wp_query->query_vars['product_cat']) || is_tax('product_tag') || is_singular('product') && 'product' == get_post_type()) { return $content; } if (is_post_type_archive('product') && get_query_var('paged') == 0 && $this->builder_is_plugin_active('woocommerce/woocommerce.php')) { $post = get_post(woocommerce_get_page_id('shop')); } if (!is_object($post)) { return $content; } $display = apply_filters('themify_builder_display', true, $post->ID); if (false === $display) { return $content; } // Infinite-loop prevention if (empty($this->post_ids)) { $this->post_ids[] = $post->ID; } elseif (in_array($post->ID, $this->post_ids)) { // we have already rendered this, go back. return $content; } // Builder display position $display_position = apply_filters('themify_builder_display_position', 'below', $post->ID); $this->post_ids[] = $post->ID; $builder_data = $this->get_builder_data($post->ID); if (!is_array($builder_data) || strpos($content, '#more-')) { $builder_data = array(); } self::$post_id = get_the_ID(); if ($this->in_the_loop) { $builder_output = $this->retrieve_template('builder-output-in-the-loop.php', array('builder_output' => $builder_data, 'builder_id' => $post->ID), '', '', false); } else { $builder_output = $this->retrieve_template('builder-output.php', array('builder_output' => $builder_data, 'builder_id' => $post->ID), '', '', false); } if ('above' == $display_position) { $content = $builder_output . $content; } else { $content .= $builder_output; } $this->post_ids = array_unique($this->post_ids); if (array_shift($this->post_ids) == $post->ID) { // the loop is finished, reset the ID list $this->post_ids = array(); } return $content; }