> Array of option group arrays. */ protected function init_option_groups() { return require MERCHANT_DIR . 'inc/modules/' . self::MODULE_ID . '/admin/options.php'; } /** * Constructor. * */ public function __construct() { // Module id. $this->module_id = self::MODULE_ID; // WooCommerce only. $this->wc_only = true; // Parent construct. parent::__construct(); // Module section. $this->module_section = 'build-trust'; // Module default settings. $this->module_default_settings = array( 'badges' => '', 'align' => 'center', 'title' => __( 'Product Quality Guaranteed!', 'merchant' ), ); // Module data. $this->module_data = Merchant_Admin_Modules::$modules_data[ self::MODULE_ID ]; // AI prompt examples. $this->ai_examples = array( 'blurb' => esc_html__( 'See what AI can do for your trust badges, from choosing which ones appear on your product pages to restyling the heading and how the badges line up.', 'merchant' ), 'prompts' => array( esc_html__( 'Explore the abilities WPVibe gives you access to, then show all three built-in trust badges on my product pages', 'merchant' ), esc_html__( "Check what abilities you have available through WPVibe, then change the text above the trust badges from 'Product Quality Guaranteed!' to 'Shop With Confidence'", 'merchant' ), esc_html__( 'Look at your available WPVibe abilities, then left-align the trust badges and set the heading font size to 18px', 'merchant' ), esc_html__( 'See what abilities WPVibe exposes, then cap the trust badge images at 60px wide and 60px tall', 'merchant' ), ), ); // 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' ) ); // 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(); } if ( ! Merchant_Modules::is_module_active( self::MODULE_ID ) ) { return; } // Return early if it's on admin but not in the respective module settings page. if ( is_admin() && ! wp_doing_ajax() && ! parent::is_module_settings_page() ) { return; } // Enqueue styles. add_action( 'merchant_enqueue_before_main_css_js', array( $this, 'enqueue_css' ) ); // Add trust badges after add to cart form on single product pages. add_action( 'woocommerce_single_product_summary', array( $this, 'trust_badges_output' ), 30 ); /** * Add trust badges inside the Quick View modal. * * @since 2.3.0 */ add_action( 'merchant_quick_view_product_summary', array( $this, 'trust_badges_output' ), 30 ); // Custom CSS. add_filter( 'merchant_custom_css', array( $this, 'frontend_custom_css' ) ); $this->backward_compatibility(); } /** * Print shortcode content. * * @return string */ public function shortcode_handler() { // Check if module is active. if ( ! Merchant_Modules::is_module_active( $this->module_id ) ) { return ''; } // Check if shortcode is enabled. if ( ! $this->is_shortcode_enabled() ) { return ''; } // Check if we are on a single product page. if ( ! is_singular( 'product' ) ) { // If user is admin, show error message. if ( current_user_can( 'manage_options' ) ) { return $this->shortcode_placement_error(); } return ''; } ob_start(); $settings = $this->get_module_settings(); $default_badges = ! empty( $settings['default_badges'] ) ? $settings['default_badges'] : array(); $badges = $this->get_badges( $settings['badges'] ); if ( ! empty( $default_badges ) || ! empty( $badges ) ) { ?>
module_id, get_the_ID() ); } /** * Init translations. * * @return void */ public function init_translations() { $settings = $this->get_module_settings(); if ( ! empty( $settings['title'] ) ) { Merchant_Translator::register_string( $settings['title'], esc_html__( 'Trust badges text above logos', 'merchant' ) ); } } /** * Admin enqueue CSS. * * @return void */ public function admin_enqueue_css() { $page = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( 'merchant' === $page && self::MODULE_ID === $module ) { wp_enqueue_style( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/trust-badges.min.css', array(), 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 ); } } /** * Enqueue CSS. * * @return void */ public function enqueue_css() { if ( ! is_singular( 'product' ) && ! Merchant_Modules::is_module_active( 'quick-view' ) ) { return; } // Specific module styles. wp_enqueue_style( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/trust-badges.min.css', array(), MERCHANT_VERSION ); } /** * Render admin preview * * @param Merchant_Admin_Preview $preview * @param string $module * * @return Merchant_Admin_Preview */ public function render_admin_preview( $preview, $module ) { if ( self::MODULE_ID === $module ) { ob_start(); self::admin_preview_content(); $content = ob_get_clean(); // HTML. $preview->set_html( $content ); // Text Above the Logos. $preview->set_text( 'title', '.merchant-trust-badges-title' ); } return $preview; } /** * Admin preview content. * * @return void */ public function admin_preview_content() { ?>