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