wpr-column-slider.php
3 weeks ago
wpr-custom-css.php
3 weeks ago
wpr-display-conditions.php
3 weeks ago
wpr-equal-height.php
3 weeks ago
wpr-extensions-base.php
3 weeks ago
wpr-parallax.php
3 weeks ago
wpr-particles.php
3 weeks ago
wpr-sticky-section.php
3 weeks ago
wpr-extensions-base.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; // Exit if accessed directly. |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Shared helper for Free extensions that can defer methods to Pro classes. |
| 9 | */ |
| 10 | if ( class_exists( 'Wpr_Extensions_Base', false ) ) { |
| 11 | return; |
| 12 | } |
| 13 | |
| 14 | class Wpr_Extensions_Base { |
| 15 | |
| 16 | /** |
| 17 | * Check if the Pro plugin is active and license is valid. |
| 18 | */ |
| 19 | protected function has_active_pro_license() { |
| 20 | if ( ! defined( 'WPR_ADDONS_PRO_VERSION' ) || ! function_exists( 'wpr_fs' ) ) { |
| 21 | return false; |
| 22 | } |
| 23 | |
| 24 | $wpr_fs = wpr_fs(); |
| 25 | |
| 26 | return is_object( $wpr_fs ) && method_exists( $wpr_fs, 'can_use_premium_code' ) && $wpr_fs->can_use_premium_code(); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Call a Pro class method when available. |
| 31 | * |
| 32 | * @param string $pro_class Fully qualified class name. |
| 33 | * @param string $method Method name. |
| 34 | * @param array $args Arguments to pass. |
| 35 | * @return bool True when the Pro method was called, false otherwise. |
| 36 | */ |
| 37 | protected function maybe_call_pro_method( $pro_class, $method, $args = [] ) { |
| 38 | if ( ! $this->has_active_pro_license() || ! class_exists( $pro_class ) || ! is_callable( [ $pro_class, $method ] ) ) { |
| 39 | return false; |
| 40 | } |
| 41 | |
| 42 | call_user_func_array( [ $pro_class, $method ], $args ); |
| 43 | |
| 44 | return true; |
| 45 | } |
| 46 | } |
| 47 |