protected function custom_loop()
 {
     do_action('presscore_before_loop');
     $page_query = presscore_get_filtered_posts(array('post_type' => 'dt_portfolio', 'taxonomy' => 'dt_portfolio_category'));
     if ($page_query->have_posts()) {
         $page_layout = presscore_get_current_layout_type();
         $current_post = $this->input['posts_count'];
         while ($page_query->have_posts()) {
             $page_query->the_post();
             // populate post config
             presscore_populate_portfolio_config();
             // post template
             switch ($page_layout) {
                 case 'masonry':
                     presscore_get_template_part('mod_portfolio', 'masonry/project');
                     break;
                 case 'list':
                     // global posts counter
                     $this->config->set('post.query.var.current_post', ++$current_post);
                     presscore_get_template_part('mod_portfolio', 'list/project');
                     break;
             }
         }
         wp_reset_postdata();
     }
     return $page_query;
 }
 public function archive_post_content($html)
 {
     if (!$html) {
         ob_start();
         presscore_populate_portfolio_config();
         presscore_get_template_part('mod_portfolio', 'masonry/project');
         $html = ob_get_contents();
         ob_end_clean();
     }
     return $html;
 }
Esempio n. 3
0
 public function shortcode($atts, $content = null)
 {
     $attributes = $this->sanitize_attributes($atts);
     // vc inline dummy
     if (presscore_vc_is_inline()) {
         $terms_title = _x('Display categories', 'vc inline dummy', LANGUAGE_ZONE);
         $terms_list = presscore_get_terms_list_by_slug(array('slugs' => $attributes['category'], 'taxonomy' => $this->taxonomy));
         return $this->vc_inline_dummy(array('class' => 'dt_vc-portfolio_jgrid', 'title' => _x('Portfolio justified grid', 'vc inline dummy', LANGUAGE_ZONE), 'fields' => array($terms_title => $terms_list)));
     }
     $output = '';
     $dt_query = $this->get_posts_by_terms(array('orderby' => $attributes['orderby'], 'order' => $attributes['order'], 'number' => $attributes['number'], 'select' => $attributes['select'], 'category' => $attributes['category']));
     if ($dt_query->have_posts()) {
         $this->backup_post_object();
         $this->backup_theme_config();
         $this->setup_config($attributes);
         ob_start();
         do_action('presscore_before_shortcode_loop', $this->shortcode_name, $attributes);
         // fullwidth wrap open
         if ($attributes['full_width']) {
             echo '<div class="full-width-wrap">';
         }
         // masonry container open
         echo '<div ' . presscore_masonry_container_class(array('wf-container', 'dt-portfolio-shortcode')) . presscore_masonry_container_data_atts() . '>';
         while ($dt_query->have_posts()) {
             $dt_query->the_post();
             presscore_populate_portfolio_config();
             dt_get_template_part('portfolio/masonry/portfolio-masonry-post');
         }
         // masonry container close
         echo '</div>';
         // fullwidth wrap close
         if ($attributes['full_width']) {
             echo '</div>';
         }
         do_action('presscore_after_shortcode_loop', $this->shortcode_name, $attributes);
         $output = ob_get_contents();
         ob_end_clean();
         $this->restore_theme_config();
         $this->restore_post_object();
     }
     return $output;
 }
 protected function portfolio_slider()
 {
     $output = '';
     // query
     $dt_query = $this->get_posts_by_terms(array('orderby' => $this->atts['orderby'], 'order' => $this->atts['order'], 'number' => $this->atts['number'], 'select' => $this->atts['select'], 'category' => $this->atts['category']));
     if ($dt_query->have_posts()) {
         // setup
         $this->backup_post_object();
         $this->backup_theme_config();
         $this->setup_config();
         $this->add_hooks();
         ob_start();
         // loop
         while ($dt_query->have_posts()) {
             $dt_query->the_post();
             echo '<li class="fs-entry">';
             presscore_populate_portfolio_config();
             presscore_get_config()->set('post.preview.media.style', 'featured_image');
             dt_get_template_part('portfolio/masonry/portfolio-masonry-post');
             echo '</li>';
         }
         // store loop html
         $posts_html = ob_get_contents();
         ob_end_clean();
         // shape output
         $output = '<div ' . $this->get_container_html_class(array('dt-portfolio-shortcode', 'slider-wrapper')) . ' ' . $this->get_container_data_atts() . '>';
         $output .= '<div class="frame fullwidth-slider"><ul class="clearfix">' . $posts_html . '</ul></div>';
         if ($this->atts['arrows']) {
             $output .= '<div class="prev"><i></i></div><div class="next"><i></i></div>';
         }
         $output .= '</div>';
         // cleanup
         $this->remove_hooks();
         $this->restore_theme_config();
         $this->restore_post_object();
     }
     return $output;
 }
Esempio n. 5
0
 /**
  * Get portfolio posts in masonry layout.
  *
  */
 public static function get_masonry_content($ajax_data = array())
 {
     global $post, $wp_query, $paged, $page;
     extract($ajax_data);
     if (!$nonce || !$post_id || !$post_paged || !$target_page || !wp_verify_nonce($nonce, 'presscore-posts-ajax')) {
         $responce = array('success' => false, 'reason' => 'corrupted data');
     } else {
         ////////////////////
         // theme files //
         ////////////////////
         /**
          * Include AQResizer.
          *
          */
         require_once PRESSCORE_EXTENSIONS_DIR . '/aq_resizer.php';
         /**
          * Include helpers.
          *
          */
         require_once PRESSCORE_DIR . '/helpers.php';
         /**
          * Include template actions and filters.
          *
          */
         require_once PRESSCORE_DIR . '/template-hooks.php';
         /**
          * Include paginator.
          *
          */
         require_once PRESSCORE_EXTENSIONS_DIR . '/dt-pagination.php';
         /**
          * Mobile detection library.
          *
          */
         if (!class_exists('Mobile_Detect')) {
             require_once PRESSCORE_EXTENSIONS_DIR . '/mobile-detect.php';
         }
         // get page
         query_posts(array('post_type' => 'page', 'page_id' => $post_id, 'post_status' => 'publish', 'page' => $target_page));
         $config = Presscore_Config::get_instance();
         $config->set('template', 'portfolio');
         presscore_config_base_init($post_id);
         if ($config->get('justified_grid') && isset($sender) && in_array($sender, array('filter', 'paginator'))) {
             $loaded_items = array();
         }
         presscore_react_on_categorizer();
         $html = '';
         $responce = array('success' => true);
         if (have_posts() && !post_password_required()) {
             while (have_posts()) {
                 the_post();
                 // main loop
                 ob_start();
                 presscore_portfolio_meta_new_controller();
                 do_action('presscore_before_loop');
                 $ppp = $config->get('posts_per_page');
                 $order = $config->get('order');
                 $orderby = $config->get('orderby');
                 $display = $config->get('display');
                 $request_display = $config->get('request_display');
                 // $layout = 'masonry';
                 $all_terms = get_categories(array('type' => 'dt_portfolio', 'hide_empty' => 1, 'hierarchical' => 0, 'taxonomy' => 'dt_portfolio_category', 'pad_counts' => false));
                 $all_terms_array = array();
                 foreach ($all_terms as $term) {
                     $all_terms_array[] = $term->term_id;
                 }
                 $page_args = array('post_type' => 'dt_portfolio', 'post_status' => 'publish', 'paged' => dt_get_paged_var(), 'order' => $order, 'orderby' => 'name' == $orderby ? 'title' : $orderby);
                 if ($ppp) {
                     $page_args['posts_per_page'] = intval($ppp);
                 }
                 if ('all' != $display['select'] && !empty($display['terms_ids'])) {
                     $page_args['tax_query'] = array(array('taxonomy' => 'dt_portfolio_category', 'field' => 'term_id', 'terms' => array_values($display['terms_ids']), 'operator' => 'IN'));
                     if ('except' == $display['select']) {
                         $terms_arr = array_diff($all_terms_array, $display['terms_ids']);
                         sort($terms_arr);
                         if ($terms_arr) {
                             $page_args['tax_query']['relation'] = 'OR';
                             $page_args['tax_query'][1] = $page_args['tax_query'][0];
                             $page_args['tax_query'][0]['terms'] = $terms_arr;
                             $page_args['tax_query'][1]['operator'] = 'NOT IN';
                         }
                         add_filter('posts_clauses', 'dt_core_join_left_filter');
                     }
                 }
                 // filter
                 if ($request_display) {
                     // except
                     if (0 == current($request_display['terms_ids'])) {
                         // ninjaaaa
                         $request_display['terms_ids'] = $all_terms_array;
                     }
                     $page_args['tax_query'] = array(array('taxonomy' => 'dt_portfolio_category', 'field' => 'term_id', 'terms' => array_values($request_display['terms_ids']), 'operator' => 'IN'));
                     if ('except' == $request_display['select']) {
                         $page_args['tax_query'][0]['operator'] = 'NOT IN';
                     }
                 }
                 $page_query = new WP_Query($page_args);
                 remove_filter('posts_clauses', 'dt_core_join_left_filter');
                 if ($page_query->have_posts()) {
                     while ($page_query->have_posts()) {
                         $page_query->the_post();
                         // check if current post already loaded
                         $key_in_loaded = array_search($post->ID, $loaded_items);
                         if (false !== $key_in_loaded) {
                             unset($loaded_items[$key_in_loaded]);
                             continue;
                         }
                         // populate post config
                         presscore_populate_portfolio_config();
                         // post template
                         dt_get_template_part('portfolio/masonry/portfolio-masonry-post');
                     }
                     wp_reset_postdata();
                 }
                 $html .= ob_get_clean();
             }
             ///////////////////
             // pagination //
             ///////////////////
             $next_page_link = dt_get_next_posts_url($page_query->max_num_pages);
             if ($next_page_link) {
                 $responce['nextPage'] = dt_get_paged_var() + 1;
             } else {
                 $responce['nextPage'] = 0;
             }
             $load_style = $config->get('load_style');
             // pagination style
             if (presscore_is_load_more_pagination()) {
                 $pagination = dt_get_next_page_button($page_query->max_num_pages, 'paginator paginator-more-button with-ajax');
                 if ($pagination) {
                     $responce['currentPage'] = dt_get_paged_var();
                     $responce['paginationHtml'] = $pagination;
                 } else {
                     $responce['currentPage'] = $post_paged;
                 }
                 $responce['paginationType'] = 'more';
             } else {
                 if ('ajax_pagination' == $load_style) {
                     ob_start();
                     dt_paginator($page_query, array('class' => 'paginator with-ajax', 'ajaxing' => true));
                     $pagination = ob_get_clean();
                     if ($pagination) {
                         $responce['paginationHtml'] = $pagination;
                     }
                     $responce['paginationType'] = 'paginator';
                 }
             }
             /////////////////
             // response //
             /////////////////
             $responce['itemsToDelete'] = array_values($loaded_items);
             // $responce['query'] = $page_query->query;
             $responce['order'] = strtolower($page_query->query['order']);
             $responce['orderby'] = strtolower($page_query->query['orderby']);
         }
         // main loop
         $responce['html'] = $html;
     }
     return $responce;
 }
Esempio n. 6
0
 // masonry container open
 echo '<div ' . presscore_masonry_container_class(array('wf-container')) . presscore_masonry_container_data_atts() . '>';
 while (have_posts()) {
     the_post();
     switch (get_post_type()) {
         case 'post':
             $config->set('show_details', false);
             // populate config with current post settings
             presscore_populate_post_config();
             dt_get_template_part('blog/masonry/blog-masonry-post');
             // restore config
             $config->reset($config_backup);
             break;
         case 'dt_portfolio':
             // populate post config
             presscore_populate_portfolio_config();
             dt_get_template_part('portfolio/masonry/portfolio-masonry-post');
             // restore config
             $config->reset($config_backup);
             break;
         case 'dt_gallery':
             add_filter('presscore_get_images_gallery_hoovered-title_img_args', 'presscore_gallery_post_exclude_featured_image_from_gallery', 15, 3);
             // populate post config
             presscore_populate_album_post_config();
             // get_template_part( 'content', 'gallery' );
             dt_get_template_part('albums/masonry/albums-masonry-post');
             remove_filter('presscore_get_images_gallery_hoovered-title_img_args', 'presscore_gallery_post_exclude_featured_image_from_gallery', 15, 3);
             // restore config
             $config->reset($config_backup);
             break;
         default:
 protected function post_template()
 {
     presscore_populate_portfolio_config();
     presscore_get_template_part('mod_portfolio', 'masonry/project');
 }
Esempio n. 8
0
 protected function post_template()
 {
     presscore_populate_portfolio_config();
     dt_get_template_part('portfolio/masonry/portfolio-masonry-post');
 }
 protected function render_slide()
 {
     presscore_populate_portfolio_config();
     presscore_get_config()->set('post.preview.media.style', 'featured_image');
     dt_get_template_part('portfolio/masonry/portfolio-masonry-post');
 }
Esempio n. 10
0
 /**
  * Portfolio masonry.
  *
  */
 public function portfolio_masonry()
 {
     global $post;
     $post_backup = $post;
     $dt_query = $this->get_posts_by_terms($this->atts);
     $output = '';
     if ($dt_query->have_posts()) {
         $config = Presscore_Config::get_instance();
         // backup and reset config
         $config_backup = $config->get();
         $this->setup_config();
         $details_already_hidden = false;
         if (!$config->get('show_details') && !has_filter('presscore_post_details_link', 'presscore_return_empty_string')) {
             add_filter('presscore_post_details_link', 'presscore_return_empty_string');
             $details_already_hidden = true;
         }
         $before_post_hook_added = false;
         $after_post_hook_added = false;
         // add masonry wrap
         if (!has_filter('presscore_before_post', 'presscore_before_post_masonry')) {
             add_action('presscore_before_post', 'presscore_before_post_masonry', 15);
             $before_post_hook_added = true;
         }
         if (!has_filter('presscore_after_post', 'presscore_after_post_masonry')) {
             add_action('presscore_after_post', 'presscore_after_post_masonry', 15);
             $after_post_hook_added = true;
         }
         // remove proportions filter
         remove_filter('dt_portfolio_thumbnail_args', 'presscore_add_thumbnail_class_for_masonry', 15);
         // add image height filter
         add_filter('dt_portfolio_thumbnail_args', array($this, 'portfolio_image_filter'), 15);
         // loop
         while ($dt_query->have_posts()) {
             $dt_query->the_post();
             // populate post config
             presscore_populate_portfolio_config();
             ob_start();
             dt_get_template_part('portfolio/masonry/portfolio-masonry-post');
             $output .= ob_get_contents();
             ob_end_clean();
         }
         // remove image height filter
         remove_filter('dt_portfolio_thumbnail_args', array($this, 'portfolio_image_filter'), 15);
         // add proportions filter
         add_filter('dt_portfolio_thumbnail_args', 'presscore_add_thumbnail_class_for_masonry', 15);
         // remove masonry wrap
         if ($before_post_hook_added) {
             remove_action('presscore_before_post', 'presscore_before_post_masonry', 15);
         }
         if ($after_post_hook_added) {
             remove_action('presscore_after_post', 'presscore_after_post_masonry', 15);
         }
         if ($details_already_hidden) {
             // remove details filter
             remove_filter('presscore_post_details_link', 'presscore_return_empty_string');
         }
         $output = '<div ' . presscore_masonry_container_class(array('wf-container', 'dt-portfolio-shortcode')) . presscore_masonry_container_data_atts() . '>' . $output . '</div>';
         if ($this->atts['full_width']) {
             $output = '<div class="full-width-wrap">' . $output . '</div>';
         }
         // restore original $post
         $post = $post_backup;
         setup_postdata($post);
         // restore config
         $config->reset($config_backup);
     }
     // if have posts
     return $output;
 }