function frontend_render_cell_content($target)
 {
     global $WPV_templates;
     $content = '';
     $cell_content = $this->get_content();
     if ($cell_content['page'] == 'current_page') {
         do_action('ddl-layouts-render-start-post-content');
     }
     if (isset($WPV_templates) && isset($cell_content['ddl_view_template_id']) && $cell_content['ddl_view_template_id'] != 'None') {
         $content_template_id = $cell_content['ddl_view_template_id'];
         if ($cell_content['page'] == 'current_page') {
             global $post;
             $content = render_view_template($content_template_id, $post);
         } elseif ($cell_content['page'] == 'this_page') {
             $get_post_query = new WP_Query(array('p' => $cell_content['selected_post'], 'post_type' => 'any'));
             while ($get_post_query->have_posts()) {
                 $get_post_query->the_post();
                 $content = render_view_template($content_template_id);
             }
             wp_reset_postdata();
         }
         $content = do_shortcode(apply_filters('ddl-content-template-cell-do_shortcode', $content, $this));
     } else {
         $content = WPDDL_Messages::views_missing_message();
     }
     $target->cell_content_callback($content, $this);
     if ($cell_content['page'] == 'current_page') {
         do_action('ddl-layouts-render-end-post-content');
     }
 }
 /**
  * Method for falling back to use Content Templates if Layouts plugin is activated but no Layouts has been assigned to products
  * @access public
  * @return string
  */
 public function wc_views_fallback_to_ct($content, $object_passed, $layout, $args)
 {
     global $wpddlayout, $post;
     $is_product = is_product();
     $settings_wrapper_woocommerce = get_option('woocommerce_views_wrap_the_content');
     if (is_object($wpddlayout) && $is_product) {
         //Layouts plugin activated and this is product
         //Access Layouts post type object
         $layout_posttype_object = $wpddlayout->post_types_manager;
         if (method_exists($layout_posttype_object, 'get_layout_to_type_object')) {
             //Check if product post type has been assigned with Layouts
             $result = $layout_posttype_object->get_layout_to_type_object('product');
             if ($result) {
                 //Layouts assigned, do nothing...
             } else {
                 //Products has not been assigned with Layouts
                 //Let's checked if a Content Template has been assigned instead.
                 $has_ct = $this->check_if_content_template_has_assigned_to_products_wcviews();
                 if ($has_ct) {
                     //Has content template assigned
                     $content = '';
                     $content_template_options = get_option('wpv_options');
                     if (isset($content_template_options)) {
                         if (!empty($content_template_options)) {
                             if (isset($content_template_options['views_template_for_product'])) {
                                 //Product content template is set
                                 //Check if its not null
                                 $null_check = $content_template_options['views_template_for_product'];
                                 $null_check = intval($null_check);
                                 if ($null_check > 0) {
                                     //Sensible id for CT, use it
                                     if (is_object($post)) {
                                         $content = render_view_template($null_check, $post);
                                         if ('yes' == $settings_wrapper_woocommerce) {
                                             //WooCommerce Classes wrapping
                                             if (isset($post->ID)) {
                                                 $post_id = $post->ID;
                                                 $post_classes = get_post_class('clearfix', $post_id);
                                                 global $post_classes_wc_added;
                                                 if (!$post_classes_wc_added) {
                                                     $post_classes_wc_added = TRUE;
                                                     $content = '<div class="' . implode(' ', $post_classes) . '">' . $content . '</div>';
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $content;
 }
 function frontend_render_cell_content($target)
 {
     global $WPV_templates, $post, $id, $authordata;
     $cell_content = $this->get_content();
     if ($cell_content['page'] == 'current_page') {
         do_action('ddl-layouts-render-start-post-content');
     }
     // View template support is only here for backwards support before 0.9.2.
     // It's not used for post content cells for 0.9.2 and later.
     if (isset($WPV_templates) && isset($cell_content['ddl_view_template_id']) && $cell_content['ddl_view_template_id'] != 'None') {
         $content_template_id = $cell_content['ddl_view_template_id'];
         if ($cell_content['page'] == 'current_page') {
             global $post;
             $content = render_view_template($content_template_id, $post);
         } elseif ($cell_content['page'] == 'this_page') {
             $post = get_post($cell_content['selected_post']);
             $content = render_view_template($content_template_id, $post);
         }
     } else {
         if (isset($WPV_templates)) {
             remove_filter('the_content', array($WPV_templates, 'the_content'), 1, 1);
         }
         $content = '';
         if ($target->is_layout_argument_set('post-content-callback') && function_exists($target->get_layout_arguments('post-content-callback'))) {
             global $wp_query;
             // in case of issue uncomment this line
             //$wp_query->current_post = -1;
             // prevent any other override to bother
             remove_all_actions('loop_start');
             remove_all_actions('loop_end');
             if ($cell_content['page'] == 'this_page') {
                 // need to switch the post.
                 $original_query = isset($wp_query) ? clone $wp_query : null;
                 $original_post = isset($post) ? clone $post : null;
                 $original_authordata = isset($authordata) ? clone $authordata : null;
                 $original_id = $id;
                 $wp_query = new WP_Query(array('post_type' => 'any', 'ignore_sticky_posts' => true, 'post__in' => array($cell_content['selected_post'])));
             }
             ob_start();
             call_user_func($target->get_layout_arguments('post-content-callback'));
             $content = ob_get_clean();
             if ($cell_content['page'] == 'this_page') {
                 // restore the global wp_query.
                 $wp_query = isset($original_query) ? clone $original_query : null;
                 $post = isset($original_post) ? clone $original_post : null;
                 $authordata = isset($original_authordata) ? clone $original_authordata : null;
                 $id = $original_id;
             }
         } else {
             if ($cell_content['page'] == 'current_page' && is_object($post) && property_exists($post, 'post_content')) {
                 $content = apply_filters('the_content', $post->post_content);
             } elseif ($cell_content['page'] == 'this_page') {
                 $other_post = get_post($cell_content['selected_post']);
                 if (is_object($other_post) && property_exists($other_post, 'post_content')) {
                     $content = apply_filters('the_content', $other_post->post_content);
                 }
             }
         }
         if (isset($WPV_templates)) {
             add_filter('the_content', array($WPV_templates, 'the_content'), 1, 1);
         }
     }
     $target->cell_content_callback($content, $this);
     if ($cell_content['page'] == 'current_page') {
         do_action('ddl-layouts-render-end-post-content');
     }
 }
Пример #4
0
 /**
  * Renders the view
  *
  * @param $view
  */
 function render_view($view)
 {
     $rendered = false;
     try {
         render_view_template($view);
         $rendered = true;
     } catch (Exception $e) {
     }
     if (!$rendered) {
         header('HTTP/1.0 404 Not Found');
         echo '<h1>404 - not found</h1>';
     }
 }
 /**
  * Output the post content using a specified Content Template
  * @param $p object the Post object
  * @since 0.6
  */
 function do_view_template($p = null)
 {
     if (empty($p)) {
         return;
     }
     global $post;
     setup_postdata($p);
     $rt = render_view_template($this->shortcode_atts['view_template'], $p);
     wp_reset_postdata();
     return $rt;
 }