← All changes
|
inc/modules/countdown-timer/class-countdown-timer.php
+310
-242
1.8.2
→
2.3.2
View file →
| @@ -1,242 +1,310 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Countdown timer. | |
| 5 | - * | |
| 6 | - * @package Merchant | |
| 7 | - */ | |
| 8 | - | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | - exit; // Exit if accessed directly | |
| 11 | -} | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * Countdown timer class. | |
| 15 | - * | |
| 16 | - */ | |
| 17 | -class Merchant_Countdown_Timer extends Merchant_Add_Module { | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * Module ID. | |
| 21 | - * | |
| 22 | - */ | |
| 23 | - const MODULE_ID = 'countdown-timer'; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * Module template path. | |
| 27 | - */ | |
| 28 | - const MODULE_TEMPLATES = 'modules/' . self::MODULE_ID; | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * Is module preview. | |
| 32 | - * | |
| 33 | - */ | |
| 34 | - public static $is_module_preview = false; | |
| 35 | - | |
| 36 | - /** | |
| 37 | - * Constructor. | |
| 38 | - */ | |
| 39 | - public function __construct() { | |
| 40 | - // Module id. | |
| 41 | - $this->module_id = self::MODULE_ID; | |
| 42 | - | |
| 43 | - // WooCommerce only. | |
| 44 | - $this->wc_only = true; | |
| 45 | - | |
| 46 | - // Parent construct. | |
| 47 | - parent::__construct(); | |
| 48 | - | |
| 49 | - // Module section. | |
| 50 | - $this->module_section = 'convert-more'; | |
| 51 | - | |
| 52 | - // Module default settings. | |
| 53 | - $this->module_default_settings = array( | |
| 54 | - 'discount_products_only' => true, | |
| 55 | - 'sale_ending_text' => esc_html__( 'Sale ends in', 'merchant' ), | |
| 56 | - 'end_date' => 'evergreen', | |
| 57 | - 'cool_off_period' => 15, | |
| 58 | - 'min_expiration_deadline' => 2, | |
| 59 | - 'max_expiration_deadline' => 26, | |
| 60 | - 'sale_ending_alignment' => 'left', | |
| 61 | - ); | |
| 62 | - | |
| 63 | - // Mount preview url. | |
| 64 | - $preview_url = site_url( '/' ); | |
| 65 | - | |
| 66 | - if ( function_exists( 'wc_get_products' ) ) { | |
| 67 | - $products = wc_get_products( array( 'limit' => 1 ) ); | |
| 68 | - | |
| 69 | - if ( ! empty( $products ) && ! empty( $products[0] ) ) { | |
| 70 | - $preview_url = get_permalink( $products[0]->get_id() ); | |
| 71 | - } | |
| 72 | - } | |
| 73 | - | |
| 74 | - // Module data. | |
| 75 | - $this->module_data = Merchant_Admin_Modules::$modules_data[ self::MODULE_ID ]; | |
| 76 | - $this->module_data['preview_url'] = $preview_url; | |
| 77 | - | |
| 78 | - // Module options path. | |
| 79 | - $this->module_options_path = MERCHANT_DIR . 'inc/modules/' . self::MODULE_ID . '/admin/options.php'; | |
| 80 | - | |
| 81 | - // Is module preview page. | |
| 82 | - if ( is_admin() && parent::is_module_settings_page() ) { | |
| 83 | - self::$is_module_preview = true; | |
| 84 | - | |
| 85 | - // Enqueue admin styles. | |
| 86 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_css' ) ); | |
| 87 | - | |
| 88 | - // Enqueue admin scripts. | |
| 89 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); | |
| 90 | - | |
| 91 | - // Admin preview box. | |
| 92 | - add_filter( 'merchant_module_preview', array( $this, 'render_admin_preview' ), 10, 2 ); | |
| 93 | - | |
| 94 | - // Custom CSS. | |
| 95 | - // The custom CSS should be added here as well due to ensure preview box works properly. | |
| 96 | - add_filter( 'merchant_custom_css', array( $this, 'admin_custom_css' ) ); | |
| 97 | - } | |
| 98 | - | |
| 99 | - if ( Merchant_Modules::is_module_active( self::MODULE_ID ) && is_admin() ) { | |
| 100 | - // Init translations. | |
| 101 | - $this->init_translations(); | |
| 102 | - } | |
| 103 | - } | |
| 104 | - | |
| 105 | - /** | |
| 106 | - * Init translations. | |
| 107 | - * | |
| 108 | - * @return void | |
| 109 | - */ | |
| 110 | - public function init_translations() { | |
| 111 | - $settings = $this->get_module_settings(); | |
| 112 | - if ( ! empty( $settings['sale_ending_text'] ) ) { | |
| 113 | - Merchant_Translator::register_string( $settings['sale_ending_text'], esc_html__( 'Countdown Timer: Sale ending message', 'merchant' ) ); | |
| 114 | - } | |
| 115 | - } | |
| 116 | - | |
| 117 | - /** | |
| 118 | - * Admin enqueue CSS. | |
| 119 | - * | |
| 120 | - * @return void | |
| 121 | - */ | |
| 122 | - public function admin_enqueue_css() { | |
| 123 | - if ( $this->is_module_settings_page() ) { | |
| 124 | - wp_enqueue_style( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/countdown-timer.min.css', array(), MERCHANT_VERSION ); | |
| 125 | - wp_enqueue_style( 'merchant-admin-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/admin/preview.min.css', array(), MERCHANT_VERSION ); | |
| 126 | - } | |
| 127 | - } | |
| 128 | - | |
| 129 | - /** | |
| 130 | - * Admin Enqueue scripts. | |
| 131 | - * | |
| 132 | - * @return void | |
| 133 | - */ | |
| 134 | - public function admin_enqueue_scripts() { | |
| 135 | - wp_enqueue_script( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/js/modules/' . self::MODULE_ID . '/countdown-timer.min.js', array(), MERCHANT_VERSION, true ); | |
| 136 | - wp_enqueue_script( 'merchant-admin-' . self::MODULE_ID, MERCHANT_URI . 'assets/js/modules/' . self::MODULE_ID . '/admin/preview.min.js', array(), MERCHANT_VERSION, true ); | |
| 137 | - } | |
| 138 | - | |
| 139 | - /** | |
| 140 | - * Render admin preview | |
| 141 | - * | |
| 142 | - * @param Merchant_Admin_Preview $preview | |
| 143 | - * @param string $module | |
| 144 | - * | |
| 145 | - * @return Merchant_Admin_Preview | |
| 146 | - */ | |
| 147 | - public function render_admin_preview( $preview, $module ) { | |
| 148 | - if ( self::MODULE_ID === $module ) { | |
| 149 | - ob_start(); | |
| 150 | - self::admin_preview_content(); | |
| 151 | - $content = ob_get_clean(); | |
| 152 | - | |
| 153 | - // HTML. | |
| 154 | - $preview->set_html( $content ); | |
| 155 | - | |
| 156 | - // Sale Ending Color | |
| 157 | - $preview->set_css( 'sale_ending_color', '.merchant-countdown-timer-text', '--merchant-sale-ending-color' ); | |
| 158 | - | |
| 159 | - // Digits Color | |
| 160 | - $preview->set_css( 'digits_color', '.merchant-countdown-timer-countdown', '--merchant-digits-color' ); | |
| 161 | - | |
| 162 | - // Icon Color. | |
| 163 | - $preview->set_css( 'icon_color', '.merchant-countdown-timer svg', '--merchant-icon-color' ); | |
| 164 | - | |
| 165 | - // Sale Ending Text. | |
| 166 | - $preview->set_text( 'sale_ending_text', '.merchant-countdown-timer-text' ); | |
| 167 | - } | |
| 168 | - | |
| 169 | - return $preview; | |
| 170 | - } | |
| 171 | - | |
| 172 | - /** | |
| 173 | - * Admin preview content. | |
| 174 | - * | |
| 175 | - * @return void | |
| 176 | - */ | |
| 177 | - public function admin_preview_content() { | |
| 178 | - $settings = $this->get_module_settings(); | |
| 179 | - ?> | |
| 180 | - | |
| 181 | - <div class="mrc-preview-single-product-elements"> | |
| 182 | - <div class="mrc-preview-left-column"> | |
| 183 | - <div class="mrc-preview-product-image-wrapper"> | |
| 184 | - <div class="mrc-preview-product-image"></div> | |
| 185 | - <div class="mrc-preview-product-image-thumbs"> | |
| 186 | - <div class="mrc-preview-product-image-thumb"></div> | |
| 187 | - <div class="mrc-preview-product-image-thumb"></div> | |
| 188 | - <div class="mrc-preview-product-image-thumb"></div> | |
| 189 | - </div> | |
| 190 | - </div> | |
| 191 | - </div> | |
| 192 | - <div class="mrc-preview-right-column"> | |
| 193 | - <div class="mrc-preview-text-placeholder"></div> | |
| 194 | - <div class="mrc-preview-text-placeholder mrc-mw-70"></div> | |
| 195 | - <div class="mrc-preview-text-placeholder mrc-mw-30"></div> | |
| 196 | - <div class="mrc-preview-text-placeholder mrc-mw-40"></div> | |
| 197 | - <?php echo wp_kses( merchant_get_template_part( self::MODULE_TEMPLATES, 'single-product', $settings, true ), merchant_kses_allowed_tags() ); ?> | |
| 198 | - <div class="mrc-preview-addtocart-placeholder"></div> | |
| 199 | - </div> | |
| 200 | - </div> | |
| 201 | - | |
| 202 | - <?php | |
| 203 | - } | |
| 204 | - | |
| 205 | - /** | |
| 206 | - * Custom CSS. | |
| 207 | - * | |
| 208 | - * @return string | |
| 209 | - */ | |
| 210 | - public function get_module_custom_css() { | |
| 211 | - $css = ''; | |
| 212 | - | |
| 213 | - // Sale Ending Color. | |
| 214 | - $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'sale_ending_color', '#626262', '.merchant-countdown-timer-text', '--merchant-sale-ending-color' ); | |
| 215 | - | |
| 216 | - // Digits Color. | |
| 217 | - $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'digits_color', '#444444', '.merchant-countdown-timer-countdown', '--merchant-digits-color' ); | |
| 218 | - | |
| 219 | - // Icon Color. | |
| 220 | - $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'icon_color', '#626262', '.merchant-countdown-timer svg', '--merchant-icon-color' ); | |
| 221 | - | |
| 222 | - return $css; | |
| 223 | - } | |
| 224 | - | |
| 225 | - /** | |
| 226 | - * Admin custom CSS. | |
| 227 | - * | |
| 228 | - * @param string $css The custom CSS. | |
| 229 | - * | |
| 230 | - * @return string $css The custom CSS. | |
| 231 | - */ | |
| 232 | - public function admin_custom_css( $css ) { | |
| 233 | - $css .= $this->get_module_custom_css(); | |
| 234 | - | |
| 235 | - return $css; | |
| 236 | - } | |
| 237 | -} | |
| 238 | - | |
| 239 | -// Initialize the module. | |
| 240 | -add_action( 'init', function () { | |
| 241 | - Merchant_Modules::create_module( new Merchant_Countdown_Timer() ); | |
| 242 | -} ); | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Countdown timer. | |
| 5 | + * | |
| 6 | + * @package Merchant | |
| 7 | + */ | |
| 8 | + | |
| 9 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | + exit; // Exit if accessed directly | |
| 11 | +} | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * Countdown timer class. | |
| 15 | + * | |
| 16 | + */ | |
| 17 | +class Merchant_Countdown_Timer extends Merchant_Add_Module { | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * Module ID. | |
| 21 | + * | |
| 22 | + */ | |
| 23 | + const MODULE_ID = 'countdown-timer'; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * Module template path. | |
| 27 | + */ | |
| 28 | + const MODULE_TEMPLATES = 'modules/' . self::MODULE_ID; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * Is module preview. | |
| 32 | + * | |
| 33 | + */ | |
| 34 | + public static $is_module_preview = false; | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * Initialize the module's option group definitions. | |
| 38 | + * | |
| 39 | + * @return array<int, array<string, mixed>> Array of option group arrays. | |
| 40 | + */ | |
| 41 | + protected function init_option_groups() { | |
| 42 | + return require MERCHANT_DIR . 'inc/modules/' . self::MODULE_ID . '/admin/options.php'; | |
| 43 | + } | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Constructor. | |
| 47 | + */ | |
| 48 | + public function __construct() { | |
| 49 | + // Module id. | |
| 50 | + $this->module_id = self::MODULE_ID; | |
| 51 | + | |
| 52 | + // WooCommerce only. | |
| 53 | + $this->wc_only = true; | |
| 54 | + | |
| 55 | + // Parent construct. | |
| 56 | + parent::__construct(); | |
| 57 | + | |
| 58 | + // Module section. | |
| 59 | + $this->module_section = 'convert-more'; | |
| 60 | + | |
| 61 | + // Module default settings. | |
| 62 | + $this->module_default_settings = array( | |
| 63 | + 'discount_products_only' => true, | |
| 64 | + 'sale_ending_text' => esc_html__( 'Sale ends in', 'merchant' ), | |
| 65 | + 'end_date' => 'evergreen', | |
| 66 | + 'cool_off_period' => 15, | |
| 67 | + 'min_expiration_deadline' => 2, | |
| 68 | + 'max_expiration_deadline' => 26, | |
| 69 | + 'sale_ending_alignment' => 'left', | |
| 70 | + ); | |
| 71 | + | |
| 72 | + // Module data. | |
| 73 | + $this->module_data = Merchant_Admin_Modules::$modules_data[ self::MODULE_ID ]; | |
| 74 | + | |
| 75 | + // AI prompt examples. | |
| 76 | + $this->ai_examples = array( | |
| 77 | + 'blurb' => esc_html__( 'See what AI can do for your countdown timer, from setting when the sale ends to restyling how the timer looks.', 'merchant' ), | |
| 78 | + 'prompts' => array( | |
| 79 | + esc_html__( 'Explore the abilities WPVibe gives you access to, then switch the countdown timer to sale-price dates and set it to end at midnight on November 30 for our Black Friday sale', 'merchant' ), | |
| 80 | + esc_html__( 'Check what abilities you have available through WPVibe, then switch the countdown timer to an evergreen timer that gives each visitor a fresh 24-hour deadline', 'merchant' ), | |
| 81 | + esc_html__( "Look at your available WPVibe abilities, then change the sale ending message above the countdown timer to 'Black Friday ends in' and center it", 'merchant' ), | |
| 82 | + esc_html__( 'See what abilities WPVibe exposes, then switch the countdown timer to the Circles layout with red digits', 'merchant' ), | |
| 83 | + ), | |
| 84 | + ); | |
| 85 | + | |
| 86 | + // Module options path. | |
| 87 | + $this->module_options_path = MERCHANT_DIR . 'inc/modules/' . self::MODULE_ID . '/admin/options.php'; | |
| 88 | + | |
| 89 | + // Is module preview page. | |
| 90 | + if ( is_admin() && parent::is_module_settings_page() ) { | |
| 91 | + self::$is_module_preview = true; | |
| 92 | + | |
| 93 | + // Enqueue admin styles. | |
| 94 | + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_css' ) ); | |
| 95 | + | |
| 96 | + // Enqueue admin scripts. | |
| 97 | + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); | |
| 98 | + | |
| 99 | + // Localize Script. | |
| 100 | + add_filter( 'merchant_admin_localize_script', array( $this, 'localize_script' ) ); | |
| 101 | + | |
| 102 | + // Admin preview box. | |
| 103 | + add_filter( 'merchant_module_preview', array( $this, 'render_admin_preview' ), 10, 2 ); | |
| 104 | + | |
| 105 | + // Custom CSS. | |
| 106 | + // The custom CSS should be added here as well due to ensure preview box works properly. | |
| 107 | + add_filter( 'merchant_custom_css', array( $this, 'admin_custom_css' ) ); | |
| 108 | + } | |
| 109 | + | |
| 110 | + if ( Merchant_Modules::is_module_active( self::MODULE_ID ) && is_admin() ) { | |
| 111 | + // Init translations. | |
| 112 | + $this->init_translations(); | |
| 113 | + } | |
| 114 | + } | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * Init translations. | |
| 118 | + * | |
| 119 | + * @return void | |
| 120 | + */ | |
| 121 | + public function init_translations() { | |
| 122 | + $settings = $this->get_module_settings(); | |
| 123 | + if ( ! empty( $settings['sale_ending_text'] ) ) { | |
| 124 | + Merchant_Translator::register_string( $settings['sale_ending_text'], esc_html__( 'Countdown Timer: Sale ending message', 'merchant' ) ); | |
| 125 | + } | |
| 126 | + } | |
| 127 | + | |
| 128 | + /** | |
| 129 | + * Admin enqueue CSS. | |
| 130 | + * | |
| 131 | + * @return void | |
| 132 | + */ | |
| 133 | + public function admin_enqueue_css() { | |
| 134 | + if ( $this->is_module_settings_page() ) { | |
| 135 | + wp_enqueue_style( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/countdown-timer.min.css', array(), MERCHANT_VERSION ); | |
| 136 | + wp_enqueue_style( 'merchant-admin-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/admin/preview.min.css', array(), MERCHANT_VERSION ); | |
| 137 | + } | |
| 138 | + } | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * Admin Enqueue scripts. | |
| 142 | + * | |
| 143 | + * @return void | |
| 144 | + */ | |
| 145 | + public function admin_enqueue_scripts() { | |
| 146 | + wp_enqueue_script( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/js/modules/' . self::MODULE_ID . '/countdown-timer.min.js', array(), MERCHANT_VERSION, true ); | |
| 147 | + wp_enqueue_script( 'merchant-admin-' . self::MODULE_ID, MERCHANT_URI . 'assets/js/modules/' . self::MODULE_ID . '/admin/preview.min.js', array(), MERCHANT_VERSION, true ); | |
| 148 | + } | |
| 149 | + | |
| 150 | + /** | |
| 151 | + * Localize Script. | |
| 152 | + */ | |
| 153 | + public function localize_script( $data ) { | |
| 154 | + $data['is_admin'] = is_admin(); | |
| 155 | + | |
| 156 | + return $data; | |
| 157 | + } | |
| 158 | + | |
| 159 | + /** | |
| 160 | + * Render admin preview | |
| 161 | + * | |
| 162 | + * @param Merchant_Admin_Preview $preview | |
| 163 | + * @param string $module | |
| 164 | + * | |
| 165 | + * @return Merchant_Admin_Preview | |
| 166 | + */ | |
| 167 | + public function render_admin_preview( $preview, $module ) { | |
| 168 | + if ( self::MODULE_ID === $module ) { | |
| 169 | + ob_start(); | |
| 170 | + self::admin_preview_content(); | |
| 171 | + $content = ob_get_clean(); | |
| 172 | + | |
| 173 | + // HTML. | |
| 174 | + $preview->set_html( $content ); | |
| 175 | + | |
| 176 | + // Font size | |
| 177 | + $preview->set_css( 'digits_font_size', '.merchant-countdown-timer-countdown', '--merchant-digits-font-size', 'px' ); | |
| 178 | + $preview->set_css( 'labels_font_size', '.merchant-countdown-timer-countdown', '--merchant-labels-font-size', 'px' ); | |
| 179 | + | |
| 180 | + // Sale Ending Color | |
| 181 | + $preview->set_css( 'sale_ending_color', '.merchant-countdown-timer-text', '--merchant-sale-ending-color' ); | |
| 182 | + | |
| 183 | + // Digits Color | |
| 184 | + $preview->set_css( 'digits_color', '.merchant-countdown-timer-countdown', '--merchant-digits-color' ); | |
| 185 | + | |
| 186 | + // Digits Background Color | |
| 187 | + $preview->set_css( 'digits_background', '.merchant-countdown-timer-countdown', '--merchant-digits-background' ); | |
| 188 | + | |
| 189 | + // Progress Color | |
| 190 | + $preview->set_css( 'progress_color', '.merchant-countdown-timer-countdown', '--merchant-progress-color' ); | |
| 191 | + | |
| 192 | + // Labels Color | |
| 193 | + $preview->set_css( 'labels_color', '.merchant-countdown-timer-countdown', '--merchant-labels-color' ); | |
| 194 | + | |
| 195 | + // Border Color | |
| 196 | + $preview->set_css( 'digits_border', '.merchant-countdown-timer-countdown', '--merchant-digits-border' ); | |
| 197 | + | |
| 198 | + // Digits width & height | |
| 199 | + $preview->set_css( 'digits_width', '.merchant-countdown-timer-countdown', '--merchant-digits-width', 'px' ); | |
| 200 | + $preview->set_css( 'digits_height', '.merchant-countdown-timer-countdown', '--merchant-digits-height', 'px' ); | |
| 201 | + | |
| 202 | + // Icon Color. | |
| 203 | + $preview->set_css( 'icon_color', '.merchant-countdown-timer svg', '--merchant-icon-color' ); | |
| 204 | + | |
| 205 | + // Sale Ending Text. | |
| 206 | + $preview->set_text( 'sale_ending_text', '.merchant-countdown-timer-text' ); | |
| 207 | + } | |
| 208 | + | |
| 209 | + return $preview; | |
| 210 | + } | |
| 211 | + | |
| 212 | + /** | |
| 213 | + * Admin preview content. | |
| 214 | + * | |
| 215 | + * @return void | |
| 216 | + */ | |
| 217 | + public function admin_preview_content() { | |
| 218 | + $settings = $this->get_module_settings(); | |
| 219 | + ?> | |
| 220 | + | |
| 221 | + <div class="mrc-preview-single-product-elements"> | |
| 222 | + <div class="mrc-preview-left-column"> | |
| 223 | + <div class="mrc-preview-product-image-wrapper"> | |
| 224 | + <div class="mrc-preview-product-image"></div> | |
| 225 | + </div> | |
| 226 | + </div> | |
| 227 | + <div class="mrc-preview-right-column"> | |
| 228 | + <h3 style="margin-top: 0;"><?php echo esc_html__( 'Your Product Name', 'merchant' ); ?></h3> | |
| 229 | + <div class="mrc-preview-rating"> | |
| 230 | + <div class="star-rating merchant-star-rating-style2" role="img" aria-label="Rated 3.00 out of 5"> | |
| 231 | + <span style="width: 80%"></span> | |
| 232 | + </div> | |
| 233 | + <span style="color: #969696;"><?php echo esc_html__( 'reviews', 'merchant' ); ?></span> | |
| 234 | + </div> | |
| 235 | + <h3><?php echo esc_html__( '$49', 'merchant' ); ?></h3> | |
| 236 | + <p><?php echo esc_html__( "An amazing product people can't refuse. What’s the next moment of value-realization when using your product? Tell the biggest use case. Briefly expand your product benefits on how this will help customers.", 'merchant' ); ?></p> | |
| 237 | + <?php echo wp_kses( merchant_get_template_part( self::MODULE_TEMPLATES, 'single-product', $settings, true ), merchant_kses_allowed_tags() ); ?> | |
| 238 | + | |
| 239 | + <div class="merchant-preview-add-to-cart-inner"> | |
| 240 | + <div class="merchant-preview-qty"> | |
| 241 | + <button><?php echo esc_html( '+' ); ?></button> | |
| 242 | + <input type="text" value="<?php echo esc_attr( '1' ); ?>"> | |
| 243 | + <button><?php echo esc_html( '-' ); ?></button> | |
| 244 | + </div> | |
| 245 | + <div class="merchant-preview-add-to-cart"><?php echo esc_html__( 'Add to cart', 'merchant' ); ?></div> | |
| 246 | + </div> | |
| 247 | + </div> | |
| 248 | + </div> | |
| 249 | + | |
| 250 | + <?php | |
| 251 | + } | |
| 252 | + | |
| 253 | + /** | |
| 254 | + * Custom CSS. | |
| 255 | + * | |
| 256 | + * @return string | |
| 257 | + */ | |
| 258 | + public function get_module_custom_css() { | |
| 259 | + $css = ''; | |
| 260 | + | |
| 261 | + // Font sizes | |
| 262 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'digits_font_size', 16, '.merchant-countdown-timer-countdown', '--merchant-digits-font-size', 'px' ); | |
| 263 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'labels_font_size', 16, '.merchant-countdown-timer-countdown', '--merchant-labels-font-size', 'px' ); | |
| 264 | + | |
| 265 | + // Sale Ending Color. | |
| 266 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'sale_ending_color', '#626262', '.merchant-countdown-timer-text', '--merchant-sale-ending-color' ); | |
| 267 | + | |
| 268 | + // Digits Color. | |
| 269 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'digits_color', '#444444', '.merchant-countdown-timer-countdown', '--merchant-digits-color' ); | |
| 270 | + | |
| 271 | + // Digits Background Color. | |
| 272 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'digits_background', '#fff', '.merchant-countdown-timer-countdown', '--merchant-digits-background' ); | |
| 273 | + | |
| 274 | + // Progress Color. | |
| 275 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'progress_color', '#3858E9', 'body', '--merchant-progress-color' ); | |
| 276 | + | |
| 277 | + // Labels Color. | |
| 278 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'labels_color', '#444444', '.merchant-countdown-timer-countdown', '--merchant-labels-color' ); | |
| 279 | + | |
| 280 | + // Border Color. | |
| 281 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'digits_border', '#444444', '.merchant-countdown-timer-countdown', '--merchant-digits-border' ); | |
| 282 | + | |
| 283 | + // Digits width & height | |
| 284 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'digits_width', 80, '.merchant-countdown-timer-countdown', '--merchant-digits-width', 'px' ); | |
| 285 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'digits_height', 80, '.merchant-countdown-timer-countdown', '--merchant-digits-height', 'px' ); | |
| 286 | + | |
| 287 | + // Icon Color. | |
| 288 | + $css .= Merchant_Custom_CSS::get_variable_css( self::MODULE_ID, 'icon_color', '#626262', '.merchant-countdown-timer svg', '--merchant-icon-color' ); | |
| 289 | + | |
| 290 | + return $css; | |
| 291 | + } | |
| 292 | + | |
| 293 | + /** | |
| 294 | + * Admin custom CSS. | |
| 295 | + * | |
| 296 | + * @param string $css The custom CSS. | |
| 297 | + * | |
| 298 | + * @return string $css The custom CSS. | |
| 299 | + */ | |
| 300 | + public function admin_custom_css( $css ) { | |
| 301 | + $css .= $this->get_module_custom_css(); | |
| 302 | + | |
| 303 | + return $css; | |
| 304 | + } | |
| 305 | +} | |
| 306 | + | |
| 307 | +// Initialize the module. | |
| 308 | +add_action( 'init', function () { | |
| 309 | + Merchant_Modules::create_module( new Merchant_Countdown_Timer() ); | |
| 310 | +} ); | |