| @@ -1,111 +1,39 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace RadiusTheme\SB\Modules\QuickView; | |
| 4 | - | |
| 5 | -// Do not allow directly accessing this file. | |
| 6 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 7 | - exit( 'This script cannot be accessed directly.' ); | |
| 8 | -} | |
| 9 | - | |
| 10 | -use RadiusTheme\SB\Helpers\Fns; | |
| 11 | -use RadiusTheme\SB\Modules\Compare\CompareInstaller; | |
| 12 | -use RadiusTheme\SB\Traits\SingletonTrait; | |
| 13 | -use RadiusTheme\SBPRO\Modules\Badges\BadgesFns; | |
| 14 | - | |
| 15 | -final class QuickView { | |
| 16 | - /** | |
| 17 | - * @var array | |
| 18 | - */ | |
| 19 | - private $cache = []; | |
| 20 | - | |
| 21 | - /** | |
| 22 | - * @var array | |
| 23 | - */ | |
| 24 | - public $settings = []; | |
| 25 | - /** | |
| 26 | - * @var array|mixed | |
| 27 | - */ | |
| 28 | - private array $options; | |
| 29 | - /** | |
| 30 | - * Options | |
| 31 | - */ | |
| 32 | - use SingletonTrait; | |
| 33 | - | |
| 34 | - private function __construct() { | |
| 35 | - QuickViewFrontEnd::instance(); | |
| 36 | - $this->options = Fns::get_options( 'modules', 'quick_view' ); | |
| 37 | - add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_public_scripts' ], 99 ); | |
| 38 | - 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 | - } | |
| 111 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace RadiusTheme\SB\Modules\QuickView; | |
| 4 | + | |
| 5 | +// Do not allow directly accessing this file. | |
| 6 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 7 | + exit( 'This script cannot be accessed directly.' ); | |
| 8 | +} | |
| 9 | + | |
| 10 | +use RadiusTheme\SB\Modules\Compare\CompareInstaller; | |
| 11 | +use RadiusTheme\SB\Traits\SingletonTrait; | |
| 12 | + | |
| 13 | +final class QuickView { | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * @var array | |
| 17 | + */ | |
| 18 | + public $settings = []; | |
| 19 | + | |
| 20 | + //protected $module_id = 'quick_view'; | |
| 21 | + | |
| 22 | + use SingletonTrait; | |
| 23 | + | |
| 24 | + function __construct() { | |
| 25 | + | |
| 26 | + QuickViewFrontEnd::instance(); | |
| 27 | + | |
| 28 | + do_action( 'rtsb/module/quick_view/loaded' ); | |
| 29 | + } | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * Do stuff upon plugin activation | |
| 33 | + * | |
| 34 | + * @return void | |
| 35 | + */ | |
| 36 | + public function activate() { | |
| 37 | + ( new CompareInstaller() )->run(); | |
| 38 | + } | |
| 39 | +} | |