| 1 |
<?php |
| 2 |
/** |
| 3 |
* Themify Compatibility Code |
| 4 |
* |
| 5 |
* @package Themify |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Strong Testimonials |
| 10 |
* |
| 11 |
* @link https://strongtestimonials.com/ |
| 12 |
* |
| 13 |
* Ultra (and other Themify themes) can interfere with Strong Testimonials' |
| 14 |
* secondary WP_Query so only get_option( 'posts_per_page' ) items show |
| 15 |
* (often 6). Force nopaging / posts_per_page when the View quantity is "all". |
| 16 |
*/ |
| 17 |
class Themify_Compat_strongTestimonials { |
| 18 |
|
| 19 |
public static function init(): void { |
| 20 |
add_filter( 'wpmtst_query_args', array( __CLASS__, 'query_args' ), 9999, 2 ); |
| 21 |
add_filter( 'themify_defer_js_exclude', array( __CLASS__, 'defer_js_exclude' ) ); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Keep Strong Testimonials queries from inheriting the theme/Reading posts_per_page limit. |
| 26 |
* |
| 27 |
* @param array $args Query args. |
| 28 |
* @param array $atts View attributes. |
| 29 |
* @return array |
| 30 |
*/ |
| 31 |
public static function query_args( $args, $atts = array() ): array { |
| 32 |
$count = isset( $atts['count'] ) ? (int) $atts['count'] : -1; |
| 33 |
|
| 34 |
if ( $count < 1 ) { |
| 35 |
$args['posts_per_page'] = -1; |
| 36 |
$args['nopaging'] = true; |
| 37 |
} else { |
| 38 |
$args['posts_per_page'] = $count; |
| 39 |
} |
| 40 |
|
| 41 |
return $args; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Do not defer Strong Testimonials scripts (pager / controller need reliable load order with deferred jQuery). |
| 46 |
* |
| 47 |
* @param array $exclude Script handles. |
| 48 |
* @return array |
| 49 |
*/ |
| 50 |
public static function defer_js_exclude( $exclude ): array { |
| 51 |
$exclude[] = 'wpmtst-controller'; |
| 52 |
$exclude[] = 'wpmtst-pager'; |
| 53 |
$exclude[] = 'wpmtst-slider'; |
| 54 |
$exclude[] = 'wpmtst-form'; |
| 55 |
|
| 56 |
return $exclude; |
| 57 |
} |
| 58 |
} |
| 59 |
|