| @@ -6,106 +6,22 @@ | ||
| 6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | 7 | exit( 'This script cannot be accessed directly.' ); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | -use RadiusTheme\SB\Helpers\Fns; | |
| 11 | 10 | use RadiusTheme\SB\Modules\Compare\CompareInstaller; |
| 12 | 11 | use RadiusTheme\SB\Traits\SingletonTrait; |
| 13 | -use RadiusTheme\SBPRO\Modules\Badges\BadgesFns; | |
| 14 | 12 | |
| 15 | 13 | final class QuickView { |
| 16 | - /** | |
| 17 | - * @var array | |
| 18 | - */ | |
| 19 | - private $cache = []; | |
| 20 | 14 | |
| 21 | 15 | /** |
| 22 | 16 | * @var array |
| 23 | 17 | */ |
| 24 | 18 | public $settings = []; |
| 25 | - /** | |
| 26 | - * @var array|mixed | |
| 27 | - */ | |
| 28 | - private array $options; | |
| 29 | - /** | |
| 30 | - * Options | |
| 31 | - */ | |
| 19 | + | |
| 32 | 20 | use SingletonTrait; |
| 33 | 21 | |
| 34 | - private function __construct() { | |
| 22 | + function __construct() { | |
| 35 | 23 | QuickViewFrontEnd::instance(); |
| 36 | - $this->options = Fns::get_options( 'modules', 'quick_view' ); | |
| 37 | - add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_public_scripts' ], 99 ); | |
| 24 | + | |
| 38 | 25 | do_action( 'rtsb/module/quick_view/loaded' ); |
| 39 | - } | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * @return void | |
| 43 | - */ | |
| 44 | - public function enqueue_public_scripts() { | |
| 45 | - $cache_key = 'quick_view_style_cache'; | |
| 46 | - $width = ! empty( $this->options['modal_width'] ) ? $this->options['modal_width'] : '950'; | |
| 47 | - wp_localize_script( | |
| 48 | - 'rtsb-public', | |
| 49 | - 'QvModalParams', | |
| 50 | - [ | |
| 51 | - 'modal_width' => absint( $width ), | |
| 52 | - ] | |
| 53 | - ); | |
| 54 | - | |
| 55 | - if ( isset( $this->cache[ $cache_key ] ) && ! empty( $this->cache[ $cache_key ] ) ) { | |
| 56 | - wp_add_inline_style( 'rtsb-frontend', $this->cache[ $cache_key ] ); | |
| 57 | - return; | |
| 58 | - } | |
| 59 | - | |
| 60 | - $height = $this->options['modal_height'] ?? false; | |
| 61 | - $wrapper_padding = $this->options['modal_wrapper_padding'] ?? '0'; | |
| 62 | - $bg_color = $this->options['modal_bg_color'] ?? false; | |
| 63 | - $box_shadow = $this->options['modal_box_shadow_color'] ?? false; | |
| 64 | - $overly_color = $this->options['modal_overly_color'] ?? false; | |
| 65 | - | |
| 66 | - ob_start(); | |
| 67 | - | |
| 68 | - if ( $height ) { ?> | |
| 69 | - .rtsb-ui-modal .rtsb-modal-content{ | |
| 70 | - height: <?php echo esc_attr( $height ); ?>; | |
| 71 | - } | |
| 72 | - <?php | |
| 73 | - } | |
| 74 | - | |
| 75 | - if ( '' !== $wrapper_padding ) { | |
| 76 | - ?> | |
| 77 | - .rtsb-ui-modal .rtsb-modal-wrapper.quick-view-modal .rtsb-modal-content .rtsb-modal-body{ | |
| 78 | - padding: <?php echo esc_attr( $wrapper_padding ); ?>; | |
| 79 | - } | |
| 80 | - <?php | |
| 81 | - } | |
| 82 | - if ( $bg_color ) { | |
| 83 | - ?> | |
| 84 | - .rtsb-ui-modal .rtsb-modal-wrapper .rtsb-modal-content{ | |
| 85 | - background-color: <?php echo esc_attr( $bg_color ); ?>; | |
| 86 | - } | |
| 87 | - <?php | |
| 88 | - } | |
| 89 | - if ( $box_shadow ) { | |
| 90 | - ?> | |
| 91 | - .rtsb-ui-modal .rtsb-modal-content{ | |
| 92 | - box-shadow: 0 0 10px <?php echo esc_attr( $box_shadow ); ?>; | |
| 93 | - } | |
| 94 | - <?php | |
| 95 | - } | |
| 96 | - | |
| 97 | - if ( $overly_color ) { | |
| 98 | - ?> | |
| 99 | - .rtsb-ui-modal .rtsb-mask-wrapper{ | |
| 100 | - background-color: <?php echo esc_attr( $overly_color ); ?>; | |
| 101 | - } | |
| 102 | - <?php | |
| 103 | - } | |
| 104 | - | |
| 105 | - $dynamic_css = ob_get_clean(); | |
| 106 | - $this->cache[ $cache_key ] = $dynamic_css; | |
| 107 | - if ( ! empty( $dynamic_css ) ) { | |
| 108 | - wp_add_inline_style( 'rtsb-frontend', $dynamic_css ); | |
| 109 | - } | |
| 110 | 26 | } |
| 111 | 27 | } |