PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.2.8
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.2.8
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / inc / modules / product-audio / class-product-audio.php

class-product-audio.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.2.8, at inc/modules/product-audio/class-product-audio.php

146 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Product Audio
5 *
6 * @package Merchant
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly
11 }
12
13 /**
14 * Product audio class.
15 *
16 */
17 class Merchant_Product_Audio extends Merchant_Add_Module {
18
19 /**
20 * Module ID.
21 *
22 */
23 const MODULE_ID = 'product-audio';
24
25 /**
26 * Is module preview.
27 *
28 */
29 public static $is_module_preview = false;
30
31 /**
32 * Constructor.
33 *
34 */
35 public function __construct() {
36
37 // Module id.
38 $this->module_id = self::MODULE_ID;
39
40 // WooCommerce only.
41 $this->wc_only = true;
42
43 // Parent construct.
44 parent::__construct();
45
46 // Module section.
47 $this->module_section = 'improve-experience';
48
49 // Module data.
50 $this->module_data = Merchant_Admin_Modules::$modules_data[ self::MODULE_ID ];
51
52 // Module options path.
53 $this->module_options_path = MERCHANT_DIR . 'inc/modules/product-audio/admin/options.php';
54
55 // Is module preview page.
56 if ( is_admin() && parent::is_module_settings_page() ) {
57 self::$is_module_preview = true;
58
59 // Enqueue admin styles.
60 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_css' ) );
61
62 // Render module essencial instructions before the module page body content.
63 add_action( 'merchant_admin_after_module_page_page_header', array( $this, 'admin_module_essencial_instructions' ) );
64
65 // Admin preview box.
66 add_filter( 'merchant_module_preview', array( $this, 'render_admin_preview' ), 10, 2 );
67 }
68 }
69
70 /**
71 * Admin enqueue CSS.
72 *
73 * @return void
74 */
75 public function admin_enqueue_css() {
76 if ( parent::is_module_settings_page()) {
77 wp_enqueue_style( 'merchant-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/product-audio.min.css', array(), MERCHANT_VERSION );
78 wp_enqueue_style( 'merchant-admin-' . self::MODULE_ID, MERCHANT_URI . 'assets/css/modules/' . self::MODULE_ID . '/admin/preview.min.css', array(), MERCHANT_VERSION );
79 }
80 }
81
82 /**
83 * Render module essencial instructions.
84 *
85 * @return void
86 */
87 public function admin_module_essencial_instructions() { ?>
88 <div class="merchant-module-page-settings">
89 <div class="merchant-module-page-setting-box merchant-module-page-setting-box-style-2">
90 <div class="merchant-module-page-setting-fields">
91 <div class="merchant-module-page-setting-field merchant-module-page-setting-field-content">
92 <div class="merchant-module-page-setting-field-inner">
93 <div class="merchant-tag-pre-orders">
94 <i class="dashicons dashicons-info"></i>
95 <p><?php echo esc_html__( 'Once this module is enabled new options to upload audio files will appear under the admin product edit page. This means you have to edit and upload the audio file for each product in your store.', 'merchant' ); ?> <?php printf( '<a href="%s" target="_blank">%s</a>', esc_url( admin_url( 'edit.php?post_type=product' ) ), esc_html__( 'View All Products', 'merchant' ) ); ?></p>
96 </div>
97 </div>
98 </div>
99 </div>
100 </div>
101 </div>
102
103 <?php
104 }
105
106 /**
107 * Render admin preview
108 *
109 * @param Merchant_Admin_Preview $preview
110 * @param string $module
111 *
112 * @return Merchant_Admin_Preview
113 */
114 public function render_admin_preview( $preview, $module ) {
115 if ( self::MODULE_ID === $module ) {
116 ob_start();
117 self::admin_preview_content();
118 $content = ob_get_clean();
119
120 // HTML.
121 $preview->set_html( $content );
122 }
123
124 return $preview;
125 }
126
127 /**
128 * Admin preview content.
129 *
130 * @return void
131 */
132 public function admin_preview_content() { ?>
133
134 <div class="mrc-product-audio-preview">
135 <img alt="product audio" src="<?php echo esc_url( MERCHANT_URI . 'inc/modules/product-audio/admin/images/preview-product-audio.png' ); ?>" />
136 </div>
137
138 <?php
139 }
140 }
141
142 // Initialize the module.
143 add_action( 'init', function() {
144 Merchant_Modules::create_module(new Merchant_Product_Audio());
145 } );
146