elementor
1 year ago
logs
1 month ago
strong-testimonials-beaver-block
1 year ago
submodules
8 months ago
class-strong-gutemberg.php
1 year ago
class-strong-log.php
1 year ago
class-strong-mail.php
1 year ago
class-strong-testimonials-average-shortcode.php
1 year ago
class-strong-testimonials-count-shortcode.php
1 year ago
class-strong-testimonials-defaults.php
1 month ago
class-strong-testimonials-form.php
1 month ago
class-strong-testimonials-order.php
1 year ago
class-strong-testimonials-privacy.php
1 year ago
class-strong-testimonials-render.php
1 month ago
class-strong-testimonials-templates.php
1 year ago
class-strong-testimonials-view-shortcode.php
1 week ago
class-strong-testimonials-view-widget.php
1 year ago
class-strong-view-display.php
1 day ago
class-strong-view-form.php
1 day ago
class-strong-view-slideshow.php
1 day ago
class-strong-view.php
1 day ago
class-walker-strong-category-checklist-front.php
1 year ago
deprecated.php
1 year ago
filters.php
1 month ago
functions-activation.php
1 month ago
functions-content.php
11 months ago
functions-image.php
5 months ago
functions-rating.php
1 year ago
functions-template-form.php
1 week ago
functions-template.php
4 months ago
functions-views.php
1 year ago
functions.php
1 month ago
l10n-polylang.php
1 year ago
l10n-wpml.php
1 year ago
post-types.php
1 week ago
retro.php
1 year ago
scripts.php
1 month ago
class-strong-view-display.php
573 lines
| 1 | <?php |
| 2 | /** |
| 3 | * View Display Mode class. |
| 4 | * |
| 5 | * @since 2.16.0 |
| 6 | */ |
| 7 | |
| 8 | // Exit if accessed directly |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | if ( ! class_exists( 'Strong_View_Display' ) ) : |
| 14 | |
| 15 | class Strong_View_Display extends Strong_View { |
| 16 | |
| 17 | /** |
| 18 | * The number of posts. |
| 19 | * |
| 20 | * @var int |
| 21 | */ |
| 22 | public $post_count; |
| 23 | public $found_posts; |
| 24 | |
| 25 | /** |
| 26 | * The number of pages. |
| 27 | * |
| 28 | * @var int |
| 29 | */ |
| 30 | public $page_count = 1; |
| 31 | |
| 32 | /** |
| 33 | * Strong_View constructor. |
| 34 | * |
| 35 | * @param array $atts |
| 36 | */ |
| 37 | public function __construct( $atts = array() ) { |
| 38 | parent::__construct( $atts ); |
| 39 | add_filter( 'wpmtst_build_query', array( $this, 'query_pagination' ) ); |
| 40 | add_filter( 'wpmtst_build_query', array( $this, 'query_infinitescroll' ) ); |
| 41 | add_action( 'wpmtst_view_processed', array( $this, 'reset_view' ) ); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Reset stuff after view is processed or rendered. |
| 46 | * |
| 47 | * @since 2.31.0 |
| 48 | */ |
| 49 | public function reset_view() { |
| 50 | wp_reset_postdata(); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Adjust query for standard pagination. |
| 55 | * |
| 56 | * @param $args |
| 57 | * |
| 58 | * @return mixed |
| 59 | */ |
| 60 | public function query_pagination( $args ) { |
| 61 | if ( isset( $this->atts['pagination'] ) && isset( $this->atts['pagination_settings'] ) && isset( $this->atts['pagination_settings']['type'] ) ) { |
| 62 | if ( $this->atts['pagination'] && 'standard' === $this->atts['pagination_settings']['type'] ) { |
| 63 | // Limit is not compatible with standard pagination. |
| 64 | $this->atts['count'] = -1; |
| 65 | $args['posts_per_page'] = $this->atts['pagination_settings']['per_page']; |
| 66 | $args['paged'] = wpmtst_get_paged(); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | return $args; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Adjust query for infinite scroll pagination. |
| 75 | * |
| 76 | * @param $args |
| 77 | * |
| 78 | * @return mixed |
| 79 | */ |
| 80 | public function query_infinitescroll( $args ) { |
| 81 | |
| 82 | if ( isset( $this->atts['pagination'] ) && isset( $this->atts['pagination_settings'] ) && isset( $this->atts['pagination_settings']['type'] ) && isset( $this->atts['mode'] ) ) { |
| 83 | if ( $this->atts['pagination'] && in_array( $this->atts['pagination_settings']['type'], array( 'infinitescroll', 'loadmore' ), true ) && 'slideshow' !== $this->atts['mode'] ) { |
| 84 | // Limit is not compatible with standard pagination. |
| 85 | $this->atts['count'] = -1; |
| 86 | $args['posts_per_page'] = $this->atts['pagination_settings']['per_page']; |
| 87 | $args['paged'] = wpmtst_get_paged(); |
| 88 | } elseif ( 'slideshow' === $this->atts['mode'] ) { |
| 89 | $args['posts_per_page'] = $this->atts['count']; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return $args; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Process the view. |
| 98 | * |
| 99 | * Used by main class to load the scripts and styles for this View. |
| 100 | */ |
| 101 | public function process() { |
| 102 | $this->build_query(); |
| 103 | $this->build_classes(); |
| 104 | |
| 105 | $this->find_stylesheet(); |
| 106 | $this->has_stars(); |
| 107 | $this->has_pagination(); |
| 108 | $this->has_layouts(); |
| 109 | $this->has_readmore(); |
| 110 | |
| 111 | $this->load_extra_stylesheets(); |
| 112 | |
| 113 | // If we can preprocess, we can add the inline style in <head>. |
| 114 | add_action( 'wp_enqueue_scripts', array( $this, 'add_custom_style' ), 20 ); |
| 115 | |
| 116 | do_action( 'wpmtst_view_processed' ); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Build the view. |
| 121 | */ |
| 122 | public function build() { |
| 123 | // May need to remove any hooks or filters that were set by other Views on the page. |
| 124 | |
| 125 | do_action( 'wpmtst_view_build_before', $this ); |
| 126 | |
| 127 | $this->build_query(); |
| 128 | $this->build_classes(); |
| 129 | |
| 130 | $this->find_stylesheet(); |
| 131 | $this->has_stars(); |
| 132 | $this->has_pagination(); |
| 133 | $this->has_layouts(); |
| 134 | $this->has_readmore(); |
| 135 | $this->has_lazyload(); |
| 136 | |
| 137 | $this->load_dependent_scripts(); |
| 138 | $this->load_extra_stylesheets(); |
| 139 | |
| 140 | // If we cannot preprocess, add the inline style to the footer. |
| 141 | add_action( 'wp_footer', array( $this, 'add_custom_style' ) ); |
| 142 | |
| 143 | /** |
| 144 | * Add filters. |
| 145 | */ |
| 146 | $this->add_content_filters(); |
| 147 | add_filter( 'get_avatar', 'wpmtst_get_avatar', 10, 3 ); |
| 148 | add_filter( 'embed_defaults', 'wpmtst_embed_size', 10, 2 ); |
| 149 | |
| 150 | /** |
| 151 | * Add actions. |
| 152 | */ |
| 153 | // Standard pagination |
| 154 | if ( isset( $this->atts['pagination'] ) && $this->atts['pagination'] && 'standard' === $this->atts['pagination_settings']['type'] ) { |
| 155 | if ( false !== strpos( $this->atts['pagination_settings']['nav'], 'before' ) ) { |
| 156 | add_action( 'wpmtst_view_header', 'wpmtst_standard_pagination' ); |
| 157 | } |
| 158 | if ( false !== strpos( $this->atts['pagination_settings']['nav'], 'after' ) ) { |
| 159 | add_action( 'wpmtst_view_footer', 'wpmtst_standard_pagination' ); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | // Read more page |
| 164 | if ( isset( $this->atts['more_page_hook'] ) ) { |
| 165 | add_action( $this->atts['more_page_hook'], 'wpmtst_read_more_page' ); |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * Locate template. |
| 170 | */ |
| 171 | $this->template_file = apply_filters( 'wpmtst_view_template_file_display', WPMST()->templates->get_template_attr( $this->atts, 'template' ) ); |
| 172 | |
| 173 | /** |
| 174 | * Allow add-ons to hijack the output generation. |
| 175 | */ |
| 176 | $query = $this->query; |
| 177 | $atts = $this->atts; |
| 178 | $html = ''; |
| 179 | |
| 180 | if ( ! $this->found_posts ) { |
| 181 | if ( current_user_can( 'strong_testimonials_views' ) && 'infinitescroll' !== $this->atts['pagination_settings']['type'] ) { |
| 182 | $html = $this->nothing_found(); |
| 183 | } |
| 184 | } elseif ( has_filter( 'wpmtst_render_view_template' ) ) { |
| 185 | $html = apply_filters( 'wpmtst_render_view_template', '', $this ); |
| 186 | } else { |
| 187 | |
| 188 | /** |
| 189 | * Gutenberg. Yay. |
| 190 | * @since 2.31.9 |
| 191 | */ |
| 192 | global $post; |
| 193 | $post_before = $post; |
| 194 | |
| 195 | ob_start(); |
| 196 | /** @noinspection PhpIncludeInspection */ |
| 197 | include $this->template_file; |
| 198 | $html = ob_get_clean(); |
| 199 | |
| 200 | $post = $post_before; |
| 201 | } |
| 202 | |
| 203 | $html = $this->template_not_found_notice( isset( $this->atts['template'] ) ? $this->atts['template'] : '' ) . $html; |
| 204 | |
| 205 | /** |
| 206 | * Remove filters. |
| 207 | */ |
| 208 | $this->remove_content_filters(); |
| 209 | remove_filter( 'get_avatar', 'wpmtst_get_avatar' ); |
| 210 | remove_filter( 'embed_defaults', 'wpmtst_embed_size' ); |
| 211 | |
| 212 | /** |
| 213 | * Remove actions. |
| 214 | */ |
| 215 | if ( isset( $this->atts['more_page_hook'] ) ) { |
| 216 | remove_action( $this->atts['more_page_hook'], 'wpmtst_read_more_page' ); |
| 217 | } |
| 218 | remove_action( 'wpmtst_view_header', 'wpmtst_standard_pagination' ); |
| 219 | remove_action( 'wpmtst_view_footer', 'wpmtst_standard_pagination' ); |
| 220 | |
| 221 | /** |
| 222 | * Hook to enqueue scripts. |
| 223 | */ |
| 224 | do_action( 'wpmtst_view_rendered', $this->atts ); |
| 225 | |
| 226 | do_action( 'wpmtst_view_processed' ); |
| 227 | |
| 228 | $this->html = apply_filters( 'strong_view_html', $html, $this ); |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Build our query. |
| 233 | */ |
| 234 | public function build_query() { |
| 235 | $ids = isset( $this->atts['id'] ) ? explode( ',', $this->atts['id'] ) : false; |
| 236 | |
| 237 | $args = array( |
| 238 | 'post_type' => 'wpm-testimonial', |
| 239 | 'post_status' => 'publish', |
| 240 | 'posts_per_page' => -1, |
| 241 | 'paged' => null, |
| 242 | ); |
| 243 | $args = apply_filters( 'wpmtst_build_query', $args ); |
| 244 | |
| 245 | // id's override category |
| 246 | if ( isset( $this->atts['id'] ) && $this->atts['id'] ) { |
| 247 | $args['post__in'] = $ids; |
| 248 | } elseif ( isset( $this->atts['category'] ) && $this->atts['category'] ) { |
| 249 | $categories = apply_filters( 'wpmtst_l10n_cats', explode( ',', $this->atts['category'] ) ); |
| 250 | $args['tax_query'] = array( |
| 251 | array( |
| 252 | 'taxonomy' => 'wpm-testimonial-category', |
| 253 | 'field' => 'id', |
| 254 | 'terms' => $categories, |
| 255 | ), |
| 256 | ); |
| 257 | } |
| 258 | |
| 259 | // order by |
| 260 | if ( isset( $this->atts['order'] ) && 'submit_date' === $this->atts['order'] ) { |
| 261 | $args['meta_key'] = 'submit_date'; |
| 262 | $args['orderby'] = 'meta_value'; |
| 263 | $args['order'] = 'DESC'; |
| 264 | $args['meta_type'] = 'DATETIME'; |
| 265 | } elseif ( isset( $this->atts['order'] ) && 'menu_order' === $this->atts['order'] ) { |
| 266 | $args['orderby'] = 'menu_order'; |
| 267 | $args['order'] = 'ASC'; |
| 268 | } else { |
| 269 | $args['orderby'] = 'post_date'; |
| 270 | if ( isset( $this->atts['order'] ) && 'newest' === $this->atts['order'] ) { |
| 271 | $args['order'] = 'DESC'; |
| 272 | } else { |
| 273 | $args['order'] = 'ASC'; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | // For Post Types Order plugin |
| 278 | $args['ignore_custom_sort'] = true; |
| 279 | |
| 280 | if ( isset( $this->atts['pagination'] ) && isset( $this->atts['pagination_settings'] ) && isset( $this->atts['pagination_settings']['type'] ) ) { |
| 281 | if ( $this->atts['pagination'] && in_array( $this->atts['pagination_settings']['type'], array( 'infinitescroll', 'loadmore' ), true ) ) { |
| 282 | if ( empty( $this->atts['paged'] ) ) { |
| 283 | $this->atts['paged'] = 1; |
| 284 | } |
| 285 | $args['paged'] = $this->atts['paged']; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | $query = new WP_Query( apply_filters( 'wpmtst_query_args', $args, $this->atts ) ); |
| 290 | /** |
| 291 | * Shuffle array in PHP instead of SQL. |
| 292 | * |
| 293 | * @since 1.16 |
| 294 | */ |
| 295 | if ( isset( $this->atts['order'] ) && 'random' === $this->atts['order'] ) { |
| 296 | $options = apply_filters( 'wpmtst_compat_options', get_option( 'wpmtst_compat_options', array() ) ); |
| 297 | if ( isset( $options['random_js'] ) && $options['random_js'] ) { |
| 298 | WPMST()->render->add_script( 'wpmtst-random' ); |
| 299 | } else { |
| 300 | shuffle( $query->posts ); |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Extract slice of array, which may be shuffled. |
| 306 | * |
| 307 | * Use lesser value: requested count or actual count. |
| 308 | * Thanks chestozo. |
| 309 | * |
| 310 | * @link https://github.com/cdillon/strong-testimonials/pull/5 |
| 311 | * |
| 312 | * @since 1.16.1 |
| 313 | */ |
| 314 | if ( isset( $this->atts['count'] ) && $this->atts['count'] > 0 ) { |
| 315 | $count = min( $this->atts['count'], count( $query->posts ) ); |
| 316 | $query->posts = array_slice( $query->posts, 0, $count ); |
| 317 | $query->post_count = $count; |
| 318 | $query->found_posts = $count; |
| 319 | } |
| 320 | |
| 321 | $this->post_count = $query->post_count; |
| 322 | $this->found_posts = $query->found_posts; |
| 323 | $this->query = $query; |
| 324 | WPMST()->set_query( $query ); |
| 325 | } |
| 326 | |
| 327 | /** |
| 328 | * Build class list based on view attributes. |
| 329 | * |
| 330 | * This must happen after the query. |
| 331 | * TODO DRY |
| 332 | */ |
| 333 | public function build_classes() { |
| 334 | $container_class_list = isset( $this->atts['view'] ) ? array( 'strong-view-id-' . $this->atts['view'] ) : array(); |
| 335 | $container_class_list = array_merge( $container_class_list, $this->get_template_css_class() ); |
| 336 | |
| 337 | if ( is_rtl() ) { |
| 338 | $container_class_list[] = 'rtl'; |
| 339 | } |
| 340 | |
| 341 | if ( isset( $this->atts['class'] ) && $this->atts['class'] ) { |
| 342 | $container_class_list[] = $this->atts['class']; |
| 343 | } |
| 344 | |
| 345 | $container_data_list = array( |
| 346 | 'count' => $this->post_count, |
| 347 | ); |
| 348 | |
| 349 | $content_class_list = array(); |
| 350 | |
| 351 | $post_class_list = array( 'wpmtst-testimonial testimonial' ); |
| 352 | |
| 353 | if ( isset( $this->atts['content'] ) && 'excerpt' === $this->atts['content'] ) { |
| 354 | $post_class_list[] = 'excerpt'; |
| 355 | } |
| 356 | |
| 357 | if ( $this->is_paginated() && ! $this->is_masonry() ) { |
| 358 | $content_class_list[] = 'strong-paginated'; |
| 359 | $container_class_list[] = 'strong-pager'; |
| 360 | $container_data_list['pager-var'] = $this->pager_signature(); |
| 361 | $container_data_list['state'] = 'idle'; |
| 362 | } |
| 363 | |
| 364 | if ( $this->is_masonry() ) { |
| 365 | $container_data_list['state'] = 'idle'; |
| 366 | } |
| 367 | |
| 368 | if ( $this->is_hybrid() ) { |
| 369 | $container_class_list[] = 'more-in-place'; |
| 370 | } |
| 371 | |
| 372 | // layouts |
| 373 | $content_class_list[] = 'strong-' . ( isset( $this->atts['layout'] ) && $this->atts['layout'] ? $this->atts['layout'] : 'normal' ); |
| 374 | $content_class_list[] = 'columns-' . ( isset( $this->atts['layout'] ) && $this->atts['layout'] ? $this->atts['column_count'] : '1' ); |
| 375 | |
| 376 | /** |
| 377 | * Filter classes. |
| 378 | */ |
| 379 | $this->atts['container_data'] = apply_filters( 'wpmtst_view_container_data', $container_data_list, $this->atts ); |
| 380 | $this->atts['container_class'] = implode( ' ', apply_filters( 'wpmtst_view_container_class', $container_class_list, $this->atts ) ); |
| 381 | $this->atts['content_class'] = implode( ' ', apply_filters( 'wpmtst_view_content_class', $content_class_list, $this->atts ) ); |
| 382 | $this->atts['post_class'] = implode( ' ', apply_filters( 'wpmtst_view_post_class', $post_class_list, $this->atts ) ); |
| 383 | |
| 384 | /** |
| 385 | * Store updated atts. |
| 386 | */ |
| 387 | WPMST()->set_atts( $this->atts ); |
| 388 | } |
| 389 | |
| 390 | /** |
| 391 | * Return true if using simple pagination (JavaScript). |
| 392 | * |
| 393 | * @since 2.28.0 |
| 394 | * |
| 395 | * @return bool |
| 396 | */ |
| 397 | public function is_paginated() { |
| 398 | if ( isset( $this->atts['pagination'] ) && isset( $this->atts['pagination_settings'] ) && isset( $this->atts['pagination_settings']['type'] ) ) { |
| 399 | return ( $this->atts['pagination'] && 'simple' === $this->atts['pagination_settings']['type'] ); |
| 400 | } |
| 401 | return false; |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Return true if using infinitescroll pagination (JavaScript). |
| 406 | * |
| 407 | * @since 2.28.0 |
| 408 | * |
| 409 | * @return bool |
| 410 | */ |
| 411 | public function is_infinitescroll() { |
| 412 | if ( isset( $this->atts['pagination'] ) && isset( $this->atts['pagination_settings'] ) && isset( $this->atts['pagination_settings']['type'] ) ) { |
| 413 | return ( $this->atts['pagination'] && 'infinitescroll' === $this->atts['pagination_settings']['type'] ); |
| 414 | } |
| 415 | return false; |
| 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Return true if using load more button pagination (JavaScript). |
| 420 | * |
| 421 | * @since 2.28.0 |
| 422 | * |
| 423 | * @return bool |
| 424 | */ |
| 425 | public function is_loadmore() { |
| 426 | if ( isset( $this->atts['pagination'] ) && isset( $this->atts['pagination_settings'] ) && isset( $this->atts['pagination_settings']['type'] ) ) { |
| 427 | return ( $this->atts['pagination'] && 'loadmore' === $this->atts['pagination_settings']['type'] ); |
| 428 | } |
| 429 | return false; |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * Return true if using Masonry. |
| 434 | * |
| 435 | * @since 2.28.0 |
| 436 | * |
| 437 | * @return bool |
| 438 | */ |
| 439 | public function is_masonry() { |
| 440 | return ( isset( $this->atts['layout'] ) && 'masonry' === $this->atts['layout'] ); |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * Return true if read-more in place. |
| 445 | * |
| 446 | * @since 2.33.0 |
| 447 | * |
| 448 | * @return bool |
| 449 | */ |
| 450 | public function is_hybrid() { |
| 451 | return ( isset( $this->atts['more_post_in_place'] ) && $this->atts['more_post_in_place'] ); |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Pagination |
| 456 | * |
| 457 | * @since 2.16.0 In Strong_View class. |
| 458 | */ |
| 459 | public function has_pagination() { |
| 460 | if ( $this->is_paginated() ) { |
| 461 | WPMST()->render->add_script( 'wpmtst-pager' ); |
| 462 | WPMST()->render->add_script_var( 'wpmtst-pager', $this->pager_signature(), $this->pager_args() ); |
| 463 | WPMST()->render->add_script( 'wpmtst-controller' ); |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * Create unique pager signature. |
| 469 | * |
| 470 | * @since 2.13.2 |
| 471 | * @since 2.22.3 In this class. |
| 472 | * |
| 473 | * @return string |
| 474 | */ |
| 475 | public function pager_signature() { |
| 476 | return 'strong_pager_id_' . $this->atts['view']; |
| 477 | } |
| 478 | |
| 479 | /** |
| 480 | * Assemble pager settings. |
| 481 | * |
| 482 | * @since 2.13.2 |
| 483 | * @since 2.22.3 In this class. |
| 484 | * |
| 485 | * @return array |
| 486 | */ |
| 487 | public function pager_args() { |
| 488 | $options = get_option( 'wpmtst_options' ); |
| 489 | |
| 490 | $nav = $this->atts['pagination_settings']['nav']; |
| 491 | if ( false !== strpos( $nav, 'before' ) && false !== strpos( $nav, 'after' ) ) { |
| 492 | $nav = 'both'; |
| 493 | } |
| 494 | |
| 495 | $saved_scrolltop = isset( $options['scrolltop'] ) ? (bool) $options['scrolltop'] : true; |
| 496 | $saved_offset = isset( $options['scrolltop_offset'] ) ? (int) $options['scrolltop_offset'] : 0; |
| 497 | $scrolltop = apply_filters( 'wpmtst_scrolltop', array( |
| 498 | 'enabled' => $saved_scrolltop, |
| 499 | 'offset' => $saved_offset, |
| 500 | ) ); |
| 501 | |
| 502 | // Remember: top level is converted to strings! |
| 503 | $args = array( |
| 504 | 'config' => array( |
| 505 | 'pageSize' => $this->atts['pagination_settings']['per_page'], |
| 506 | 'currentPage' => 1, |
| 507 | 'pagerLocation' => $nav, |
| 508 | 'scrollTop' => $scrolltop['enabled'], |
| 509 | 'offset' => $scrolltop['offset'], |
| 510 | 'imagesLoaded' => true, |
| 511 | ), |
| 512 | ); |
| 513 | |
| 514 | return apply_filters( 'wpmtst_view_pagination', $args, $this->atts['view'] ); |
| 515 | } |
| 516 | |
| 517 | /** |
| 518 | * Layouts |
| 519 | * |
| 520 | * @since 2.16.0 In Strong_View class. |
| 521 | */ |
| 522 | public function has_layouts() { |
| 523 | if ( $this->is_masonry() ) { |
| 524 | WPMST()->render->add_script( 'jquery-masonry' ); |
| 525 | WPMST()->render->add_script( 'imagesloaded' ); |
| 526 | |
| 527 | if ( apply_filters( 'wpmtst_load_masonry_style', true ) ) { |
| 528 | WPMST()->render->add_style( 'wpmtst-masonry-style' ); |
| 529 | } |
| 530 | } elseif ( isset( $this->atts['layout'] ) && 'columns' === $this->atts['layout'] ) { |
| 531 | if ( apply_filters( 'wpmtst_load_columns_style', true ) ) { |
| 532 | WPMST()->render->add_style( 'wpmtst-columns-style' ); |
| 533 | } |
| 534 | } elseif ( isset( $this->atts['layout'] ) && 'grid' === $this->atts['layout'] ) { |
| 535 | if ( apply_filters( 'wpmtst_load_grid_style', true ) ) { |
| 536 | WPMST()->render->add_style( 'wpmtst-grid-style' ); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | WPMST()->render->add_script( 'wpmtst-controller' ); |
| 541 | } |
| 542 | |
| 543 | /** |
| 544 | * Read more in place |
| 545 | * |
| 546 | * @since 2.33.0 |
| 547 | */ |
| 548 | public function has_readmore() { |
| 549 | if ( $this->is_hybrid() ) { |
| 550 | WPMST()->render->add_style( 'wpmtst-animate' ); |
| 551 | WPMST()->render->add_script( 'wpmtst-readmore' ); |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | /** |
| 556 | * Lazy Load |
| 557 | * |
| 558 | * @since 2.40.4 |
| 559 | */ |
| 560 | public function has_lazyload() { |
| 561 | if ( ! function_exists( 'wp_lazy_loading_enabled' ) || ! apply_filters( 'wp_lazy_loading_enabled', true, 'img', 'strong_testimonials_has_lazyload' ) ) { |
| 562 | $options = get_option( 'wpmtst_options' ); |
| 563 | if ( isset( $options['lazyload'] ) && $options['lazyload'] ) { |
| 564 | WPMST()->render->add_style( 'wpmtst-lazyload-css' ); |
| 565 | WPMST()->render->add_script( 'wpmtst-lozad' ); |
| 566 | WPMST()->render->add_script( 'wpmtst-lozad-load' ); |
| 567 | } |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | endif; |
| 573 |