grid-hover-layout-archive.php
3 years ago
grid-hover-layout.php
3 years ago
grid-layout-archive.php
3 years ago
grid-layout.php
3 years ago
list-layout-archive.php
3 years ago
list-layout.php
3 years ago
related-post.php
3 years ago
slider-layout-archive.php
3 years ago
slider-layout.php
3 years ago
slider-layout-archive.php
400 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Slider Layout Archive Class |
| 4 | * |
| 5 | * @package RT_TPG |
| 6 | */ |
| 7 | |
| 8 | use RT\ThePostGrid\Helpers\Fns; |
| 9 | |
| 10 | // Do not allow directly accessing this file. |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit( 'This script cannot be accessed directly.' ); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Slider Layout Archive Class |
| 17 | */ |
| 18 | class TPGSliderLayoutArchive extends Custom_Widget_Base { |
| 19 | |
| 20 | /** |
| 21 | * GridLayout constructor. |
| 22 | * |
| 23 | * @param array $data |
| 24 | * @param null $args |
| 25 | * |
| 26 | * @throws \Exception |
| 27 | */ |
| 28 | |
| 29 | public function __construct( $data = [], $args = null ) { |
| 30 | parent::__construct( $data, $args ); |
| 31 | $this->prefix = 'slider'; |
| 32 | $this->tpg_name = esc_html__( 'TPG - Slider Layout Archive', 'the-post-grid' ); |
| 33 | $this->tpg_base = 'tpg-slider-layout-archive'; |
| 34 | $this->tpg_icon = 'eicon-post-slider tpg-grid-icon'; // .tpg-grid-icon class for just style |
| 35 | $this->tpg_category = $this->tpg_archive_category; |
| 36 | } |
| 37 | |
| 38 | public function get_script_depends() { |
| 39 | $scripts = []; |
| 40 | |
| 41 | array_push( $scripts, 'imagesloaded' ); |
| 42 | array_push( $scripts, 'swiper' ); |
| 43 | array_push( $scripts, 'rt-tpg' ); |
| 44 | array_push( $scripts, 'rttpg-block-pro' ); |
| 45 | |
| 46 | return $scripts; |
| 47 | } |
| 48 | |
| 49 | public function get_style_depends() { |
| 50 | $settings = get_option( rtTPG()->options['settings'] ); |
| 51 | $style = []; |
| 52 | |
| 53 | if ( isset( $settings['tpg_load_script'] ) ) { |
| 54 | array_push( $style, 'rt-fontawsome' ); |
| 55 | array_push( $style, 'rt-flaticon' ); |
| 56 | array_push( $style, 'rt-tpg-block' ); |
| 57 | array_push( $style, 'swiper' ); |
| 58 | |
| 59 | } |
| 60 | |
| 61 | return $style; |
| 62 | } |
| 63 | |
| 64 | protected function register_controls() { |
| 65 | /** |
| 66 | * Content Tabs |
| 67 | * ============= |
| 68 | */ |
| 69 | |
| 70 | // Layout. |
| 71 | rtTPGElementorHelper::grid_layouts( $this, 'archive' ); |
| 72 | |
| 73 | // Query. |
| 74 | rtTPGElementorHelper::query_builder( $this ); |
| 75 | |
| 76 | // Links. |
| 77 | rtTPGElementorHelper::links( $this ); |
| 78 | |
| 79 | /** |
| 80 | * Settings Tabs |
| 81 | * ============= |
| 82 | */ |
| 83 | |
| 84 | // Field Selection. |
| 85 | rtTPGElementorHelper::field_selection( $this ); |
| 86 | |
| 87 | // Section Title Settings. |
| 88 | rtTPGElementorHelper::section_title_settings( $this, 'archive' ); |
| 89 | |
| 90 | // Title Settings. |
| 91 | rtTPGElementorHelper::post_title_settings( $this ); |
| 92 | |
| 93 | // Thumbnail Settings. |
| 94 | rtTPGElementorHelper::post_thumbnail_settings( $this ); |
| 95 | |
| 96 | // Excerpt Settings. |
| 97 | rtTPGElementorHelper::post_excerpt_settings( $this ); |
| 98 | |
| 99 | // Meta Settings. |
| 100 | rtTPGElementorHelper::post_meta_settings( $this ); |
| 101 | |
| 102 | // Advanced Custom Field ACF Settings. |
| 103 | rtTPGElementorHelper::tpg_acf_settings( $this ); |
| 104 | |
| 105 | // Readmore Settings. |
| 106 | rtTPGElementorHelper::post_readmore_settings( $this ); |
| 107 | |
| 108 | // Slider Settings. |
| 109 | rtTPGElementorHelper::slider_settings( $this ); |
| 110 | |
| 111 | /** |
| 112 | * Style Tabs |
| 113 | * ============= |
| 114 | */ |
| 115 | |
| 116 | // Section Title. |
| 117 | rtTPGElementorHelper::sectionTitle( $this, 'archive' ); |
| 118 | |
| 119 | // Title Style. |
| 120 | rtTPGElementorHelper::titleStyle( $this ); |
| 121 | |
| 122 | // Thumbnail Style. |
| 123 | rtTPGElementorHelper::thumbnailStyle( $this ); |
| 124 | |
| 125 | // Content Style. |
| 126 | rtTPGElementorHelper::contentStyle( $this ); |
| 127 | |
| 128 | // Meta Info Style. |
| 129 | rtTPGElementorHelper::metaInfoStyle( $this ); |
| 130 | |
| 131 | // Social Style. |
| 132 | rtTPGElementorHelper::socialShareStyle( $this ); |
| 133 | |
| 134 | // ACF Style. |
| 135 | rtTPGElementorHelper::tpg_acf_style( $this ); |
| 136 | |
| 137 | // Read more style. |
| 138 | rtTPGElementorHelper::readmoreStyle( $this ); |
| 139 | |
| 140 | // Link Style. |
| 141 | rtTPGElementorHelper::linkStyle( $this ); |
| 142 | |
| 143 | // Slider Style. |
| 144 | rtTPGElementorHelper::slider_style( $this ); |
| 145 | rtTPGElementorHelper::slider_thumb_style( $this ); |
| 146 | |
| 147 | // Box Settings. |
| 148 | rtTPGElementorHelper::articlBoxSettings( $this ); |
| 149 | |
| 150 | // Promotions. |
| 151 | rtTPGElementorHelper::promotions( $this ); |
| 152 | } |
| 153 | |
| 154 | protected function render() { |
| 155 | $data = $this->get_settings(); |
| 156 | $_prefix = $this->prefix; |
| 157 | $data['post_type'] = 'post'; |
| 158 | |
| 159 | if ( ! rtTPG()->hasPro() ) { ?> |
| 160 | <h3 style="text-align: center"><?php echo esc_html__( 'Please upgrade to pro for slider layout!', 'the-post-grid' ); ?></h3> |
| 161 | <?php |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | if ( rtTPG()->hasPro() && ( 'popup' == $data['post_link_type'] || 'multi_popup' == $data['post_link_type'] ) ) { |
| 166 | wp_enqueue_style( 'rt-magnific-popup' ); |
| 167 | wp_enqueue_script( 'rt-scrollbar' ); |
| 168 | wp_enqueue_script( 'rt-magnific-popup' ); |
| 169 | add_action( 'wp_footer', [ Fns::class, 'get_modal_markup' ], 1 ); |
| 170 | } |
| 171 | |
| 172 | // Query. |
| 173 | $query_args = rtTPGElementorQuery::post_query_builder( $data, $_prefix ); |
| 174 | $query = new WP_Query( $query_args ); |
| 175 | $rand = mt_rand(); |
| 176 | $layoutID = 'rt-tpg-container-' . $rand; |
| 177 | $posts_per_page = $data['post_limit']; |
| 178 | |
| 179 | /** |
| 180 | * TODO: Get Post Data for render post |
| 181 | */ |
| 182 | $post_data = Fns::get_render_data_set( $data, $query->max_num_pages, $posts_per_page, $_prefix ); |
| 183 | $_layout = $data[ $_prefix . '_layout' ]; |
| 184 | |
| 185 | $post_data['lazy_load'] = $data['lazyLoad']; |
| 186 | |
| 187 | /** |
| 188 | * Post type render |
| 189 | */ |
| 190 | $post_types = Fns::get_post_types(); |
| 191 | foreach ( $post_types as $post_type => $label ) { |
| 192 | $_taxonomies = get_object_taxonomies( $post_type, 'object' ); |
| 193 | |
| 194 | if ( empty( $_taxonomies ) ) { |
| 195 | continue; |
| 196 | } |
| 197 | |
| 198 | $post_data[ $data['post_type'] . '_taxonomy' ] = isset( $data[ $data['post_type'] . '_taxonomy' ] ) ? $data[ $data['post_type'] . '_taxonomy' ] : ''; |
| 199 | $post_data[ $data['post_type'] . '_tags' ] = isset( $data[ $data['post_type'] . '_tags' ] ) ? $data[ $data['post_type'] . '_tags' ] : ''; |
| 200 | } |
| 201 | |
| 202 | $post_data['enable_2_rows'] = $data['enable_2_rows']; |
| 203 | |
| 204 | $default_grid_column_desktop = '3'; |
| 205 | $default_grid_column_tab = '2'; |
| 206 | $default_grid_column_mobile = '1'; |
| 207 | |
| 208 | if ( $_layout == 'slider-layout13' ) { |
| 209 | $default_grid_column_desktop = '1'; |
| 210 | $default_grid_column_tab = '1'; |
| 211 | $default_grid_column_mobile = '1'; |
| 212 | } |
| 213 | |
| 214 | $grid_column_desktop = '0' !== $post_data['grid_column'] ? $post_data['grid_column'] : $default_grid_column_desktop; |
| 215 | $grid_column_tab = '0' !== $post_data['grid_column_tablet'] ? $post_data['grid_column_tablet'] : $default_grid_column_tab; |
| 216 | $grid_column_mobile = '0' !== $post_data['grid_column_mobile'] ? $post_data['grid_column_mobile'] : $default_grid_column_mobile; |
| 217 | |
| 218 | if ( in_array( $_layout, [ 'slider-layout10', 'slider-layout11' ] ) ) { |
| 219 | $grid_column_desktop = $grid_column_tab = $grid_column_mobile = '1'; |
| 220 | } |
| 221 | |
| 222 | ?> |
| 223 | <div class="rt-container-fluid rt-tpg-container tpg-el-main-wrapper slider-layout-main loading <?php echo esc_attr( $_layout . '-main' ); ?>" |
| 224 | id="<?php echo esc_attr( $layoutID ); ?>" |
| 225 | data-layout="<?php echo esc_attr( $data[ $_prefix . '_layout' ] ); ?>" |
| 226 | data-grid-style="" |
| 227 | data-desktop-col="<?php echo esc_attr( $grid_column_desktop ); ?>" |
| 228 | data-tab-col="<?php echo esc_attr( $grid_column_tab ); ?>" |
| 229 | data-mobile-col="<?php echo esc_attr( $grid_column_mobile ); ?>" |
| 230 | data-sc-id="elementor" |
| 231 | data-el-query='' |
| 232 | > |
| 233 | <?php |
| 234 | |
| 235 | $settings = get_option( rtTPG()->options['settings'] ); |
| 236 | if ( isset( $settings['tpg_load_script'] ) && isset( $settings['tpg_enable_preloader'] ) ) { |
| 237 | ?> |
| 238 | <div id="bottom-script-loader" class="bottom-script-loader"> |
| 239 | <div class="rt-ball-clip-rotate"> |
| 240 | <div></div> |
| 241 | </div> |
| 242 | </div> |
| 243 | <?php |
| 244 | } |
| 245 | |
| 246 | $wrapper_class = []; |
| 247 | $wrapper_class[] = 'rt-content-loader grid-behaviour'; |
| 248 | |
| 249 | if ( $_layout == 'slider-layout1' ) { |
| 250 | $wrapper_class[] = 'grid-layout1 '; |
| 251 | } elseif ( $_layout == 'slider-layout2' ) { |
| 252 | $wrapper_class[] = 'grid-layout3'; |
| 253 | } elseif ( $_layout == 'slider-layout3' ) { |
| 254 | $wrapper_class[] = 'grid-layout4'; |
| 255 | } elseif ( $_layout == 'slider-layout4' ) { |
| 256 | $wrapper_class[] = 'grid-layout7'; |
| 257 | } elseif ( $_layout == 'slider-layout5' ) { |
| 258 | $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout1 grid_hover_layout_wrapper'; |
| 259 | } elseif ( $_layout == 'slider-layout6' ) { |
| 260 | $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout3 grid_hover_layout_wrapper'; |
| 261 | } elseif ( $_layout == 'slider-layout7' ) { |
| 262 | $wrapper_class[] = 'grid_hover-layout5 grid_hover_layout_wrapper'; |
| 263 | } elseif ( $_layout == 'slider-layout8' ) { |
| 264 | $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout10 grid_hover_layout_wrapper'; |
| 265 | } elseif ( $_layout == 'slider-layout9' ) { |
| 266 | $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout11 grid_hover_layout_wrapper'; |
| 267 | } elseif ( $_layout == 'slider-layout10' ) { |
| 268 | $wrapper_class[] = 'grid_hover-layout5 grid_hover-layout7 grid_hover_layout_wrapper'; |
| 269 | } elseif ( $_layout == 'slider-layout11' ) { |
| 270 | $wrapper_class[] = ' grid_hover-layout5 slider-layout'; |
| 271 | } elseif ( $_layout == 'slider-layout12' ) { |
| 272 | $wrapper_class[] = ' grid_hover-layout5 slider-layout'; |
| 273 | } |
| 274 | |
| 275 | $wrapper_class[] = $_prefix . '_layout_wrapper'; |
| 276 | |
| 277 | //section title settings |
| 278 | Fns::get_section_title( $data ); |
| 279 | |
| 280 | $slider_data = [ |
| 281 | 'speed' => $data['speed'], |
| 282 | 'autoPlayTimeOut' => $data['autoplaySpeed'], |
| 283 | 'autoPlay' => $data['autoplay'] == 'yes' ? true : false, |
| 284 | 'stopOnHover' => $data['stopOnHover'] == 'yes' ? true : false, |
| 285 | 'nav' => $data['arrows'] == 'yes' ? true : false, |
| 286 | 'dots' => $data['dots'] == 'yes' ? true : false, |
| 287 | 'loop' => $data['infinite'] == 'yes' ? true : false, |
| 288 | 'lazyLoad' => $data['lazyLoad'] == 'yes' ? true : false, |
| 289 | 'autoHeight' => $data['autoHeight'] == 'yes' ? true : false, |
| 290 | 'dynamic_dots' => $data['dynamic_dots'] == 'yes' ? true : false, |
| 291 | 'grabCursor' => $data['grabCursor'] == 'yes' ? true : false, |
| 292 | ]; |
| 293 | |
| 294 | if ( $data['enable_2_rows'] == 'yes' ) { |
| 295 | $slider_data['autoHeight'] = false; |
| 296 | } |
| 297 | ?> |
| 298 | |
| 299 | <div class="slider-main-wrapper <?php echo esc_attr( $_layout ); ?>"> |
| 300 | <div class="rt-swiper-holder swiper" |
| 301 | data-rtowl-options='<?php echo wp_json_encode( $slider_data ); ?>' |
| 302 | dir="<?php echo esc_attr( $data['slider_direction'] ); ?>"> |
| 303 | <div class="swiper-wrapper <?php echo esc_attr( implode( ' ', $wrapper_class ) ); ?>"> |
| 304 | <?php |
| 305 | if ( $query->have_posts() ) { |
| 306 | $pCount = 1; |
| 307 | |
| 308 | while ( $query->have_posts() ) { |
| 309 | $query->the_post(); |
| 310 | set_query_var( 'tpg_post_count', $pCount ); |
| 311 | set_query_var( 'tpg_total_posts', $query->post_count ); |
| 312 | Fns::tpg_template( $post_data ); |
| 313 | |
| 314 | if ( $_layout == 'slider-layout10' && $pCount == 5 ) { |
| 315 | $pCount = 0; |
| 316 | } |
| 317 | $pCount ++; |
| 318 | } |
| 319 | } else { |
| 320 | if ( $data['no_posts_found_text'] ) { |
| 321 | printf( "<div class='no_posts_found_text'>%s</div>", esc_html( $data['no_posts_found_text'] ) ); |
| 322 | } else { |
| 323 | printf( "<div class='no_posts_found_text'>%s</div>", esc_html__( 'No post found', 'the-post-grid' ) ); |
| 324 | } |
| 325 | } |
| 326 | wp_reset_postdata(); |
| 327 | ?> |
| 328 | </div> |
| 329 | |
| 330 | </div> |
| 331 | |
| 332 | |
| 333 | <?php if ( ! in_array( $_layout, [ 'slider-layout11', 'slider-layout12' ] ) ) : ?> |
| 334 | <!--swiper-pagination-horizontal--> |
| 335 | <?php if ( $data['dots'] == 'yes' ) : ?> |
| 336 | <div class="swiper-pagination"></div> |
| 337 | <?php endif; ?> |
| 338 | |
| 339 | <?php if ( $data['arrows'] == 'yes' ) : ?> |
| 340 | <div class="swiper-navigation"> |
| 341 | <div class="slider-btn swiper-button-prev"></div> |
| 342 | <div class="slider-btn swiper-button-next"></div> |
| 343 | </div> |
| 344 | <?php endif; ?> |
| 345 | <?php endif; ?> |
| 346 | |
| 347 | <?php if ( in_array( $_layout, [ 'slider-layout11', 'slider-layout12' ] ) ) : ?> |
| 348 | <div class="slider-thumb-main-wrapper"> |
| 349 | <div class="swiper-thumb-wrapper gallery-thumbs swiper"> |
| 350 | <div class="swiper-wrapper"> |
| 351 | <?php |
| 352 | if ( $query->have_posts() ) { |
| 353 | $pCount = 1; |
| 354 | |
| 355 | while ( $query->have_posts() ) { |
| 356 | $query->the_post(); |
| 357 | set_query_var( 'tpg_post_count', $pCount ); |
| 358 | set_query_var( 'tpg_total_posts', $query->post_count ); |
| 359 | ?> |
| 360 | <div class="swiper-slide"> |
| 361 | <div class="post-thumbnail-wrap"> |
| 362 | <div class="p-thumbnail"> |
| 363 | <?php echo get_the_post_thumbnail( get_the_ID(), 'thumbnail' ); ?> |
| 364 | </div> |
| 365 | <div class="p-content"> |
| 366 | <div class="post-taxonomy"> |
| 367 | <?php |
| 368 | $_cat_id = $data['post_type'] . '_taxonomy'; |
| 369 | echo get_the_term_list( get_the_ID(), $data[ $_cat_id ], null, '<span class="rt-separator">,</span>' ); |
| 370 | ?> |
| 371 | </div> |
| 372 | <h3 class="thumb-title"><?php echo get_the_title(); ?></h3> |
| 373 | <span class="thumb-date"><?php echo get_the_date(); ?></span> |
| 374 | </div> |
| 375 | </div> |
| 376 | </div> |
| 377 | <?php |
| 378 | $pCount ++; |
| 379 | } |
| 380 | } else { |
| 381 | if ( $data['no_posts_found_text'] ) { |
| 382 | printf( "<div class='no_posts_found_text'>%s</div>", esc_html( $data['no_posts_found_text'] ) ); |
| 383 | } else { |
| 384 | printf( "<div class='no_posts_found_text'>%s</div>", esc_html__( 'No post found', 'the-post-grid' ) ); |
| 385 | } |
| 386 | } |
| 387 | wp_reset_postdata(); |
| 388 | ?> |
| 389 | </div> |
| 390 | <div class="swiper-thumb-pagination"></div> |
| 391 | </div> |
| 392 | </div> |
| 393 | <?php endif; ?> |
| 394 | </div> |
| 395 | </div> |
| 396 | <?php |
| 397 | do_action( 'tpg_elementor_script' ); |
| 398 | } |
| 399 | } |
| 400 |