module_id = self::MODULE_ID; // WooCommerce only. $this->wc_only = true; // Parent construct. parent::__construct(); // Module section. $this->module_section = 'improve-experience'; // Module default settings. $this->module_default_settings = array( 'global_size_chart' => '', 'text' => __( 'Size Chart', 'merchant' ), 'icon' => 'icon-size-chart' ); // Mount preview url. $preview_url = site_url( '/' ); if ( function_exists( 'wc_get_products' ) ) { $products = wc_get_products( array( 'limit' => 1 ) ); if ( ! empty( $products ) && ! empty( $products[0] ) ) { $preview_url = get_permalink( $products[0]->get_id() ); } } // Module data. $this->module_data = Merchant_Admin_Modules::$modules_data[ self::MODULE_ID ]; $this->module_data['preview_url'] = $preview_url; // Module options path. $this->module_options_path = MERCHANT_DIR . 'inc/modules/' . self::MODULE_ID . '/admin/options.php'; // Is module preview page. if ( is_admin() && parent::is_module_settings_page() ) { self::$is_module_preview = true; // Enqueue admin styles. add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_css' ) ); // Enqueue admin scripts. add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); // Render module essencial instructions before the module page body content. add_action( 'merchant_admin_after_module_page_page_header', array( $this, 'admin_module_essencial_instructions' ) ); // Admin preview box. add_filter( 'merchant_module_preview', array( $this, 'render_admin_preview' ), 10, 2 ); // Custom CSS. // The custom CSS should be added here as well due to ensure preview box works properly. add_filter( 'merchant_custom_css', array( $this, 'admin_custom_css' ) ); } if ( Merchant_Modules::is_module_active( self::MODULE_ID ) && is_admin() ) { // Init translations. $this->init_translations(); } } /** * Init translations. * * @return void */ public function init_translations() { $settings = $this->get_module_settings(); if ( ! empty( $settings['text'] ) ) { Merchant_Translator::register_string( $settings['text'], esc_html__( 'Size chart: label text', 'merchant' ) ); } } /** * Admin enqueue CSS. * * @return void */ public function admin_enqueue_css() { if ( parent::is_module_settings_page() ) { wp_enqueue_style( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/size-chart.min.css', [], MERCHANT_VERSION ); wp_enqueue_style( 'merchant-admin-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/admin/preview.min.css', array(), MERCHANT_VERSION ); } } /** * Admin Enqueue scripts. * * @return void */ public function admin_enqueue_scripts() { // Register and enqueue the main module script. wp_enqueue_script( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/js/modules/' . self::MODULE_ID . '/size-chart.min.js', array(), MERCHANT_VERSION, true ); } /** * Render module essencial instructions. * * @return void */ public function admin_module_essencial_instructions() { ?>

%s', esc_url( admin_url( 'edit.php?post_type=product' ) ), esc_html__( 'View All Products', 'merchant' ) ); ?>

set_html( $content ); // Label Text. $preview->set_text( 'text', '.merchant-product-size-chart-button span' ); // Icon. $preview->set_svg_icon( 'icon', '.size-chart-icon' ); } return $preview; } /** * Admin preview content. * * @return void */ public function admin_preview_content() { $settings = $this->get_module_settings(); ?>
3 35 5
4 36 6
5 37 7
6 38 8
7 39 9

Lorem ipsum dolor sit a met, dont dolor sit a la quat.

get_module_custom_css(); return $css; } } // Initialize the module. add_action( 'init', function () { Merchant_Modules::create_module( new Merchant_Size_Chart() ); } );