| @@ -1,124 +1,39 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Quick View Module Class. | |
| 4 | - * | |
| 5 | - * @package RadiusTheme\SB | |
| 6 | - */ | |
| 7 | - | |
| 8 | -namespace RadiusTheme\SB\Modules\QuickView; | |
| 9 | - | |
| 10 | -// Do not allow directly accessing this file. | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 12 | - exit( 'This script cannot be accessed directly.' ); | |
| 13 | -} | |
| 14 | - | |
| 15 | -use RadiusTheme\SB\Helpers\Fns; | |
| 16 | -use RadiusTheme\SB\Traits\SingletonTrait; | |
| 17 | - | |
| 18 | -/** | |
| 19 | - * Quick View Module Class. | |
| 20 | - */ | |
| 21 | -final class QuickView { | |
| 22 | - /** | |
| 23 | - * @var array | |
| 24 | - */ | |
| 25 | - private $cache = []; | |
| 26 | - | |
| 27 | - /** | |
| 28 | - * @var array | |
| 29 | - */ | |
| 30 | - public $settings = []; | |
| 31 | - /** | |
| 32 | - * @var array|mixed | |
| 33 | - */ | |
| 34 | - private array $options; | |
| 35 | - /** | |
| 36 | - * Options | |
| 37 | - */ | |
| 38 | - use SingletonTrait; | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * Class constructor. | |
| 42 | - * | |
| 43 | - * @return void | |
| 44 | - */ | |
| 45 | - private function __construct() { | |
| 46 | - QuickViewFrontEnd::instance(); | |
| 47 | - $this->options = Fns::get_options( 'modules', 'quick_view' ); | |
| 48 | - add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_public_scripts' ], 99 ); | |
| 49 | - do_action( 'rtsb/module/quick_view/loaded' ); | |
| 50 | - } | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * @return void | |
| 54 | - */ | |
| 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 | - } | |
| 123 | - } | |
| 124 | -} | |
| 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 | +} | |