PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.3.6
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.3.6
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / public / helpers / sp-pc-output.php

sp-pc-output.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 2.3.6, at public/helpers/sp-pc-output.php

132 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The file of html inside the loop.
4 *
5 * @package Smart_Post_Show_Pro
6 * @subpackage public
7 *
8 * @since 2.0.0
9 */
10
11 // If this file is called directly, abort.
12 if ( ! defined( 'WPINC' ) ) {
13 die;
14 }
15 /**
16 * Post output query.
17 *
18 * @since 2.0.0
19 */
20 class SP_PC_Output {
21 /**
22 * Post responsive columns class.
23 *
24 * @param string $layout Layout preset.
25 * @param string $columns Columns number.
26 * @return string
27 */
28 public static function pcp_post_responsive_columns( $layout, $columns ) {
29 $pcp_post_columns = '';
30 if ( 'carousel_layout' === $layout ) {
31 $pcp_post_columns .= ' swiper-slide swiper-lazy';
32 } else {
33 $pcp_post_columns .= " sp-pcp-col-xs-$columns[mobile] sp-pcp-col-sm-$columns[mobile_landscape] sp-pcp-col-md-$columns[tablet] sp-pcp-col-lg-$columns[desktop] sp-pcp-col-xl-$columns[lg_desktop]";
34 }
35 return $pcp_post_columns;
36 }
37 /**
38 * PCP shortcode markup wrapper classes.
39 *
40 * @param string $layout_preset The selected layout name.
41 * @param int $shortcode_id The shortcode ID.
42 */
43 public static function pcp_wrapper_classes( $layout_preset, $shortcode_id ) {
44 $wrapper_class = "sp-pcp-section sp-pcp-container pcp-wrapper-{$shortcode_id}";
45 switch ( $layout_preset ) {
46 case 'carousel_layout':
47 $wrapper_class .= ' pcp-carousel-wrapper';
48 break;
49 }
50 echo esc_attr( $wrapper_class );
51 }
52 /**
53 * Post Loop.
54 *
55 * @param array $options Views options.
56 * @param string $layout Layout preset.
57 * @param array $sorter Post sorting options.
58 * @param int $scode_id Shortcode ID.
59 * @return void
60 */
61 public static function pcp_post_loop( $options, $layout, $sorter, $scode_id ) {
62 global $post;
63 $number_of_columns = SP_PC_Functions::pcp_metabox_value( 'pcp_number_of_columns', $options );
64 ?>
65 <div class="<?php echo esc_attr( self::pcp_post_responsive_columns( $layout, $number_of_columns ) ); ?>">
66 <div class="sp-pcp-post pcp-item-<?php echo esc_attr( $post->ID ); ?>" data-id="<?php echo esc_attr( $post->ID ); ?>">
67 <?php
68 SP_PC_HTML::pcp_post_content_with_thumb( $sorter, $layout, $scode_id, $post, $options );
69 ?>
70 </div>
71 </div>
72 <?php
73 }
74
75 /**
76 * Get all query posts.
77 *
78 * @param array $options Views options.
79 * @param array $layout Layout preset.
80 * @param array $sorter Post sorting options.
81 * @param object $pcp_query post query.
82 * @param int $view_id Shortcode ID.
83 * @return void
84 */
85 public static function pcp_get_posts( $options, $layout, $sorter, $pcp_query, $view_id ) {
86 $pcp_count = 1;
87 while ( $pcp_query->have_posts() ) {
88 $pcp_query->the_post();
89 $without_post_thumbnail = apply_filters( 'sps_without_thumbnail_post_hide', true ) ? true : has_post_thumbnail();
90 if ( $without_post_thumbnail ) {
91 self::pcp_post_loop( $options, $layout, $sorter, $view_id );
92 }
93 $pcp_count++;
94 }
95 wp_reset_postdata();
96 }
97
98 /**
99 * All markup
100 *
101 * @param mixed $view_options shortcode options.
102 * @param mixed $layout all layout based options.
103 * @param mixed $pcp_gl_id shortcode id.
104 * @param mixed $section_title Section title.
105 * @return void
106 */
107 public static function pc_html_show( $view_options, $layout, $pcp_gl_id, $section_title ) {
108 $pcp_settings = get_option( 'sp_post_carousel_settings' );
109 $post_content_sorter = isset( $view_options['post_content_sorter'] ) ? $view_options['post_content_sorter'] : '';
110 $pcp_content_position = isset( $view_options['post_content_orientation'] ) ? $view_options['post_content_orientation'] : '';
111 $margin_between_post = isset( $view_options['margin_between_post']['all'] ) ? $view_options['margin_between_post']['all'] : '';
112 $show_preloader = isset( $view_options['show_preloader'] ) ? $view_options['show_preloader'] : 0;
113 $query_args = SP_PC_QueryInside::get_filtered_content( $view_options, $layout );
114 $pcp_query = new WP_Query( $query_args );
115 $total_post_count = $pcp_query->post_count;
116 // Pagination.
117 $show_pagination = isset( $view_options['show_post_pagination'] ) ? $view_options['show_post_pagination'] : '';
118 $layout_preset = isset( $layout['pcp_layout_preset'] ) ? $layout['pcp_layout_preset'] : '';
119 wp_enqueue_script( 'pcp_script' );
120 $pcp_custom_js = $pcp_settings['pcp_custom_js'];
121 if ( ! empty( $pcp_custom_js ) ) {
122 wp_add_inline_script( 'pcp_script', $pcp_custom_js );
123 }
124
125 if ( 'carousel_layout' === $layout_preset ) {
126 require SP_PC_TEMPLATE_PATH . '/carousel.php';
127 } elseif ( 'grid_layout' === $layout_preset ) {
128 require SP_PC_TEMPLATE_PATH . '/grid.php';
129 }
130 }
131 }
132