PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / trunk
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant vtrunk
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 1.9.12 All 59 releases
merchant / admin / pages / page-module.php

page-module.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant trunk, at admin/pages/page-module.php

381 lines 23.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 $merchant_module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
8 $merchant_module_info = Merchant_Admin_Modules::get_module_info( $merchant_module );
9
10 Merchant_Admin_Preview::set_preview( $merchant_module );
11
12 ?>
13
14 <?php if ( ! empty( $merchant_module_info ) ) : ?>
15
16 <div class="merchant-module-page">
17
18 <div class="merchant-module-page-content">
19
20 <form method="post" action="" class="merchant-module-page-ajax-form" autocomplete="off">
21
22 <input type="hidden" name="merchant_nonce" value="<?php echo esc_attr( wp_create_nonce( 'merchant_nonce' ) ); ?>"/>
23
24 <div class="merchant-module-page-ajax-header">
25 <div class="merchant-module-page-ajax-notice"><?php esc_html_e( 'Your settings have been modified. Save?', 'merchant' ); ?></div>
26 <div class="merchant-module-page-ajax-buttons">
27 <a href="<?php echo esc_url( add_query_arg( array( 'page' => 'merchant', 'module' => $merchant_module ), 'admin.php' ) ); ?>"
28 class="merchant-module-discard-button"><?php esc_html_e( 'Discard', 'merchant' ); ?></a>
29 <button type="submit" name="merchant_save" value="save" class="merchant-module-save-button"><span class="merchant-module-save-button-label"><?php esc_html_e( 'Save',
30 'merchant' ); ?></span><i class="dashicons dashicons-update-alt"></i></button>
31 </div>
32 </div>
33
34 <div class="merchant-module-page-header">
35
36 <div class="merchant-module-page-header-content">
37
38 <div class="merchant-module-page-back">
39 <a href="<?php echo esc_url( add_query_arg( array( 'page' => 'merchant' ), 'admin.php' ) ); ?>">
40 <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
41 <rect width="16" height="16" rx="2" fill="white"/>
42 <path d="M13.3329 7.20013H4.46628L7.19961 4.20013L6.46628 3.4668L2.59961 7.6668L6.46628 11.5335L7.19961 10.8001L4.53294 8.20013H13.3329V7.20013Z" fill="#1D2327"/>
43 </svg>
44 <span><?php echo esc_html__( 'Go Back', 'merchant' ); ?></span>
45 </a>
46 </div>
47
48 <div class="merchant-module-page-heading">
49 <div class="merchant-module-page-info">
50 <div class="merchant-module-page-title">
51 <?php echo esc_html( $merchant_module_info['title'] ); ?>
52 </div>
53 <div class="merchant-module-page-desc"><?php echo esc_html( $merchant_module_info['desc'] ); ?></div>
54 </div>
55 </div>
56
57 <div class="merchant-module-page-actions">
58
59 <div class="merchant-module-page-actions-inner">
60
61 <?php
62 $merchant_module_is_upsell = ! defined( 'MERCHANT_PRO_VERSION' ) && isset( $merchant_module_info['pro'] ) && true === $merchant_module_info['pro'];
63 $merchant_module_enabled = ( Merchant_Modules::is_module_active( $merchant_module ) && ! $merchant_module_is_upsell ) ? ' merchant-enabled' : '';
64 ?>
65
66 <div class="merchant-module-action<?php echo esc_attr( $merchant_module_enabled ); ?>">
67
68
69 <?php if ( $merchant_module_is_upsell ) :
70 $installed_plugins = Merchant_Admin_Menu::get_installed_plugins();
71 $is_pro_installed = isset( $installed_plugins['merchant-pro/merchant-pro.php'] );
72
73 if ( $is_pro_installed && ! is_plugin_active( 'merchant-pro/merchant-pro.php' ) ) :
74 $url = add_query_arg( array(
75 'page' => 'merchant',
76 'module' => $merchant_module,
77 'action' => 'merchant_activate_pro',
78 'nonce' => wp_create_nonce( 'merchant_activate_pro' ),
79 ), admin_url( 'admin.php' ) );
80 ?>
81 <div class="merchant-module-buy">
82
83 <a href="<?php echo esc_url( $url ); ?>"
84 class="merchant-module-page-button merchant-module-activate">
85 <?php esc_html_e( 'Activate Merchant Pro', 'merchant' ); ?>
86 </a>
87
88 </div>
89 <?php
90 else :
91 $url = merchant_admin_upgrade_link(
92 'https://athemes.com/merchant-upgrade',
93 array(
94 'utm_source' => 'module_inner_settings',
95 'utm_content' => $merchant_module,
96 'utm_medium' => 'merchant_dashboard',
97 'utm_campaign' => 'Merchant',
98 ),
99 'module-inner-settings-upgrade-link'
100 );
101 ?>
102 <div class="merchant-module-buy">
103
104 <a href="<?php echo esc_url( $url ); ?>" target="_blank"
105 class="merchant-module-page-button ">
106 <?php esc_html_e( 'Buy Pro', 'merchant' ); ?>
107 </a>
108
109 </div>
110 <?php endif; ?>
111 <?php else :
112 /**
113 * Hook 'merchant_admin_module_{module_id}_activate_button_class'
114 * Filters the class name for the activate button.
115 *
116 * @param string $button_activate_class The class name for the activate button.
117 * @since 1.0
118 */
119 $button_activate_class = apply_filters( "merchant_admin_module_{$merchant_module}_activate_button_class", 'merchant-module-page-button merchant-module-activate merchant-module-page-button-action-activate' );
120 ?>
121
122 <div data-module="<?php echo esc_attr( $merchant_module ); ?>"
123 class="<?php echo esc_attr( $button_activate_class ); ?>">
124 <?php esc_html_e( 'Enable', 'merchant' ); ?>
125 </div>
126 <div class="merchant-module-deactivate">
127
128 <div class="merchant-module-page-button merchant-module-page-button-deactivate">
129 <?php esc_html_e( 'Enabled', 'merchant' ); ?>
130 <svg width="8" height="5" viewBox="0 0 8 5" fill="none" xmlns="http://www.w3.org/2000/svg">
131 <path d="M7.09832 3.98009e-07L0.901685 -1.43717e-07C0.15069 -2.09371e-07 -0.269991 0.75351 0.193991 1.2676L3.29231 4.70055C3.65265 5.09982 4.34735 5.09982 4.70769 4.70055L7.80601 1.2676C8.26999 0.753511 7.84931 4.63664e-07 7.09832 3.98009e-07Z"
132 fill="#3858E9"/>
133 </svg>
134 </div>
135
136 <div class="merchant-module-deactivate-dropdown">
137 <div data-module="<?php echo esc_attr( $merchant_module ); ?>" class="merchant-module-page-button-action-deactivate">
138 <?php echo esc_html__( 'Disable', 'merchant' ) . ' ' . esc_html( $merchant_module_info['title'] ); ?>
139 </div>
140 </div>
141
142 </div>
143 <?php endif ?>
144
145
146 <div class="merchant-module-dropdown merchant-module-question-list-dropdown">
147 <div class="merchant-module-question-title">
148 <?php esc_html_e( 'Did something go wrong?', 'merchant' ); ?><i class="dashicons dashicons-no-alt merchant-module-dropdown-close"></i>
149 </div>
150 <ul>
151 <li data-answer-target="bug">
152 <span><?php esc_html_e( 'Submit a bug: the module doesn’t work as expected', 'merchant' ); ?></span>
153 </li>
154 <li data-answer-target="missing">
155 <span><?php esc_html_e( 'Some options are missing', 'merchant' ); ?></span>
156 </li>
157 <li data-answer-target="conflict">
158 <span><?php esc_html_e( 'It conflicts with another feature', 'merchant' ); ?></span>
159 </li>
160 <li data-answer-target="thank-you">
161 <span><?php esc_html_e( 'I don’t need it anymore.', 'merchant' ); ?></span>
162 </li>
163 <li data-answer-target="other">
164 <span><?php esc_html_e( 'Other', 'merchant' ); ?></span>
165 </li>
166 </ul>
167 </div>
168
169 <div class="merchant-module-dropdown merchant-module-question-answer-dropdown">
170
171 <div class="merchant-module-question-answer">
172
173 <div class="merchant-module-question-answer-title" data-answer-title="bug">
174 <?php esc_html_e( 'Please tell us why, and we’ll look into it.', 'merchant' ); ?><i
175 class="dashicons dashicons-no-alt merchant-module-dropdown-close"></i>
176 </div>
177
178 <div class="merchant-module-question-answer-title" data-answer-title="missing">
179 <?php esc_html_e( 'What feature are you looking for?', 'merchant' ); ?><i class="dashicons dashicons-no-alt merchant-module-dropdown-close"></i>
180 </div>
181
182 <div class="merchant-module-question-answer-title" data-answer-title="conflict">
183 <?php esc_html_e( 'Please tell us what plugin/theme it conflicts with.', 'merchant' ); ?><i
184 class="dashicons dashicons-no-alt merchant-module-dropdown-close"></i>
185 </div>
186
187 <div class="merchant-module-question-answer-title" data-answer-title="other">
188 <?php esc_html_e( 'Would you mind telling us why?', 'merchant' ); ?><i class="dashicons dashicons-no-alt merchant-module-dropdown-close"></i>
189 </div>
190
191 </div>
192
193 <div class="merchant-module-question-answer-form">
194 <textarea class="merchant-module-question-answer-textarea" data-subject=""></textarea>
195 <button class="merchant-module-page-button merchant-module-question-answer-button" disabled><?php esc_html_e( 'Submit', 'merchant' ); ?></button>
196 </div>
197
198 </div>
199
200 <div class="merchant-module-dropdown merchant-module-question-thank-you-dropdown">
201
202 <div class="merchant-module-question-answer-title">
203 <?php esc_html_e( 'Thank you', 'merchant' ); ?><i class="dashicons dashicons-no-alt merchant-module-dropdown-close"></i>
204 </div>
205
206 <div class="merchant-module-question-answer-thank-you-text">
207 <?php esc_html_e( 'Your feedback helps us improve Merchant.', 'merchant' ); ?>
208 </div>
209
210 </div>
211
212 </div>
213
214 <div class="merchant-module-page-actions-links">
215
216 <?php if ( ! empty( $merchant_module_info['ai_examples']['blurb'] ) ) : ?>
217 <button
218 type="button"
219 class="merchant-module-page-link merchant-module-page-link-ai merchant-ai-badge"
220 data-ai-title="<?php echo esc_attr( $merchant_module_info['title'] ); ?>"
221 data-ai-blurb="<?php echo esc_attr( $merchant_module_info['ai_examples']['blurb'] ); ?>"
222 data-ai-prompts="<?php echo esc_attr( wp_json_encode( $merchant_module_info['ai_examples']['prompts'] ?? array() ) ); ?>"
223 >
224 <svg width="14" height="14" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
225 <path d="M8 1L10.5 5.5L15 8L10.5 10.5L8 15L5.5 10.5L1 8L5.5 5.5Z" fill="currentColor"/>
226 </svg>
227 <span><?php esc_html_e( 'Try with AI', 'merchant' ); ?></span>
228 </button>
229 <?php endif; ?>
230
231 <?php if ( ! empty( $merchant_module_info['tutorial_url'] ) ) : ?>
232 <a href="<?php echo esc_url( $merchant_module_info['tutorial_url'] ); ?>" class="merchant-module-page-link merchant-module-page-link-tutorial" target="_blank">
233 <span><?php echo esc_html__( 'Tutorial', 'merchant' ); ?></span>
234 <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
235 <path d="M11.4375 0H8.25C7.94531 0 7.66406 0.1875 7.54688 0.492188C7.42969 0.773438 7.5 1.10156 7.71094 1.3125L8.67188 2.27344L4.14844 6.79688C3.84375 7.07812 3.84375 7.57031 4.14844 7.85156C4.28906 7.99219 4.47656 8.0625 4.6875 8.0625C4.875 8.0625 5.0625 7.99219 5.20312 7.85156L9.72656 3.32812L10.6875 4.28906C10.8281 4.42969 11.0156 4.5 11.2266 4.5C11.3203 4.5 11.4141 4.5 11.5078 4.45312C11.8125 4.33594 12 4.05469 12 3.75V0.5625C12 0.257812 11.7422 0 11.4375 0ZM9.1875 7.5C8.85938 7.5 8.625 7.75781 8.625 8.0625V10.6875C8.625 10.8047 8.53125 10.875 8.4375 10.875H1.3125C1.19531 10.875 1.125 10.8047 1.125 10.6875V3.5625C1.125 3.46875 1.19531 3.375 1.3125 3.375H3.9375C4.24219 3.375 4.5 3.14062 4.5 2.8125C4.5 2.50781 4.24219 2.25 3.9375 2.25H1.3125C0.585938 2.25 0 2.85938 0 3.5625V10.6875C0 11.4141 0.585938 12 1.3125 12H8.4375C9.14062 12 9.75 11.4141 9.75 10.6875V8.0625C9.75 7.75781 9.49219 7.5 9.1875 7.5Z"
236 fill="#3858E9"/>
237 </svg>
238 </a>
239 <?php endif; ?>
240
241 </div>
242
243 </div>
244
245 </div>
246
247 </div>
248
249 </div>
250
251 <?php
252 /**
253 * Hook 'merchant_admin_after_module_page_page_header'
254 *
255 * @since 1.0
256 * @updated 2.0 added $merchant_module as parameter
257 */
258 do_action( 'merchant_admin_after_module_page_page_header', $merchant_module );
259
260 ?>
261
262 <div class="merchant-module-page-body <?php echo Merchant_Admin_Preview::has_preview() ? 'has-preview' : ''; ?>">
263
264 <div class="merchant-module-page-content">
265
266 <?php
267
268 /**
269 * Hook: merchant_module_file_path
270 *
271 * @since 1.0
272 */
273 $merchant_module_file = apply_filters( 'merchant_module_file_path',
274 MERCHANT_DIR . 'admin/modules/' . $merchant_module . '/admin-page-' . $merchant_module . '.php',
275 $merchant_module );
276
277 if ( file_exists( $merchant_module_file ) ) {
278 require $merchant_module_file;
279 }
280
281 ?>
282 <div class="merchant-module-page-settings backup-restore-section">
283 <div class="merchant-module-page-setting-box">
284 <div class="merchant-module-page-setting-title">
285 <?php esc_html_e( 'Backup & Restore', 'merchant' ); ?>
286 </div>
287 <div class="merchant-module-page-setting-fields">
288 <section class="backup-section">
289 <h3><?php esc_html_e( 'Backup Module Settings', 'merchant' ); ?></h3>
290 <p><?php esc_html_e( 'Download a backup of your currently saved module settings as a JSON file. To capture the most up-to-date configuration, remember to save your settings before downloading the backup. You can then use this file to restore your settings later.', 'merchant' ); ?></p>
291 <div class="form-field">
292 <button type="button" data-module-id="<?php echo esc_attr($merchant_module)?>" id="download-backup-button"><?php esc_html_e( 'Download', 'merchant' ); ?></button>
293 <span class="merchant-backup-status"></span>
294 <span class="merchant-loading-spinner"></span>
295 </div>
296 </section>
297 <section class="restore-section">
298 <h3><?php esc_html_e( 'Restore Module Settings', 'merchant' ); ?></h3>
299 <p><?php esc_html_e( 'Restore the module settings by uploading a previously saved backup file. Please be aware that restoring settings will overwrite your current module configurations.', 'merchant' ); ?></p>
300 <div class="form-field">
301 <div class="merchant-dropzone" id="merchant-restore-dropzone" data-module-id="<?php echo esc_attr( $merchant_module )?>">
302 <div class="merchant-dropzone__content">
303 <span class="dashicons dashicons-upload"></span>
304 <p><?php esc_html_e( 'Drag & drop a JSON backup file here, or', 'merchant' ); ?></p>
305 <button type="button" class="merchant-dropzone__browse"><?php esc_html_e( 'Browse', 'merchant' ); ?></button>
306 </div>
307 <input type="file" id="merchant-backup-file" class="merchant-backup-file" name="backup-file" accept=".json">
308 <div class="merchant-dropzone__loading">
309 <span class="merchant-loading-spinner"></span>
310 <p><?php esc_html_e( 'Restoring...', 'merchant' ); ?></p>
311 </div>
312 <div class="merchant-dropzone__success">
313 <span class="dashicons dashicons-yes-alt"></span>
314 <p><?php esc_html_e( 'Settings restored successfully!', 'merchant' ); ?></p>
315 </div>
316 <div class="merchant-dropzone__error">
317 <span class="dashicons dashicons-warning"></span>
318 <p></p>
319 </div>
320 </div>
321 </div>
322 </section>
323 </div>
324 </div>
325 </div>
326 </div>
327
328 <?php if ( Merchant_Admin_Preview::has_preview() ) : ?>
329
330 <div class="merchant-module-page-preview">
331 <div class="merchant-module-page-preview-box">
332 <div class="merchant-module-page-preview-title">
333 <?php esc_html_e( 'Preview', 'merchant' ); ?>
334 </div>
335 <div class="merchant-module-page-preview-browser">
336 <div class="merchant-module-page-preview-browser-top">
337 <span class="merchant-module-page-preview-browser-top-circle"></span>
338 <span class="merchant-module-page-preview-browser-top-circle"></span>
339 <span class="merchant-module-page-preview-browser-top-circle"></span>
340 </div>
341 <div class="merchant-module-page-preview-browser-inner">
342 <?php echo wp_kses( Merchant_Admin_Preview::get_html(), merchant_kses_allowed_tags( array( 'all' ) ) ); ?>
343 </div>
344 </div>
345 </div>
346 </div>
347
348 <?php endif; ?>
349
350 </div>
351
352 </form>
353
354 </div>
355
356 </div>
357
358 <div class="merchant-module-alert">
359 <div class="merchant-module-alert-overlay"></div>
360 <div class="merchant-module-alert-wrapper">
361 <div class="merchant-module-alert-header"><strong><?php esc_html_e( 'Important info!', 'merchant' ); ?></strong><a href="#" class="merchant-module-alert-close"><i
362 class="dashicons dashicons-no-alt"></i></a></div>
363 <div class="merchant-module-alert-content">
364 <figure><img src="<?php echo esc_url( MERCHANT_URI . 'assets/images/enable-module.png' ); ?>"/></figure>
365 <p><?php esc_html_e( 'This module is currently disabled. Please enable the module to see it in your store.', 'merchant' ); ?></p>
366 </div>
367 </div>
368 </div>
369
370 <div class="merchant-module-footer-text">
371 <?php esc_html_e( 'Copyright © aThemes ' . gmdate( 'Y' ) . '. All Rights Reserved.', 'merchant' ); ?>
372 </div>
373
374 <?php require MERCHANT_DIR . 'admin/components/ai-prompts-modal.php'; ?>
375
376 <?php else : ?>
377
378 <?php wp_safe_redirect( add_query_arg( array( 'page' => 'merchant' ), admin_url( 'admin.php' ) ) ); ?>
379
380 <?php endif; ?>
381