| @@ -58,24 +58,57 @@ | ||
| 58 | 58 | |
| 59 | 59 | <div class="merchant-module-page-actions-inner"> |
| 60 | 60 | |
| 61 | 61 | <?php |
| 62 | - $merchant_module_enabled = ( Merchant_Modules::is_module_active( $merchant_module ) ) ? ' merchant-enabled' : ''; | |
| 63 | - $merchant_module_is_upsell = ! defined( 'MERCHANT_PRO_VERSION' ) && isset( $merchant_module_info['pro'] ) && true === $merchant_module_info['pro']; | |
| 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 | 64 | ?> |
| 65 | 65 | |
| 66 | 66 | <div class="merchant-module-action<?php echo esc_attr( $merchant_module_enabled ); ?>"> |
| 67 | 67 | |
| 68 | 68 | |
| 69 | - <?php if ( $merchant_module_is_upsell ) : ?> | |
| 70 | - <div class="merchant-module-buy"> | |
| 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'] ); | |
| 71 | 72 | |
| 72 | - <a href="https://athemes.com/merchant-upgrade?utm_source=plugin_dashboard&utm_medium=merchant_dashboard&utm_campaign=Merchant" target="_blank" | |
| 73 | - class="merchant-module-page-button "> | |
| 74 | - <?php esc_html_e( 'Buy Pro', 'merchant' ); ?> | |
| 75 | - </a> | |
| 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"> | |
| 76 | 82 | |
| 77 | - </div> | |
| 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; ?> | |
| 78 | 111 | <?php else : |
| 79 | 112 | /** |
| 80 | 113 | * Hook 'merchant_admin_module_{module_id}_activate_button_class' |
| 81 | 114 | * Filters the class name for the activate button. |
| @@ -179,8 +212,23 @@ | ||
| 179 | 212 | </div> |
| 180 | 213 | |
| 181 | 214 | <div class="merchant-module-page-actions-links"> |
| 182 | 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 | + | |
| 183 | 231 | <?php if ( ! empty( $merchant_module_info['tutorial_url'] ) ) : ?> |
| 184 | 232 | <a href="<?php echo esc_url( $merchant_module_info['tutorial_url'] ); ?>" class="merchant-module-page-link merchant-module-page-link-tutorial" target="_blank"> |
| 185 | 233 | <span><?php echo esc_html__( 'Tutorial', 'merchant' ); ?></span> |
| 186 | 234 | <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| @@ -204,10 +252,11 @@ | ||
| 204 | 252 | /** |
| 205 | 253 | * Hook 'merchant_admin_after_module_page_page_header' |
| 206 | 254 | * |
| 207 | 255 | * @since 1.0 |
| 256 | + * @updated 2.0 added $merchant_module as parameter | |
| 208 | 257 | */ |
| 209 | - do_action( 'merchant_admin_after_module_page_page_header' ); | |
| 258 | + do_action( 'merchant_admin_after_module_page_page_header', $merchant_module ); | |
| 210 | 259 | |
| 211 | 260 | ?> |
| 212 | 261 | |
| 213 | 262 | <div class="merchant-module-page-body <?php echo Merchant_Admin_Preview::has_preview() ? 'has-preview' : ''; ?>"> |
| @@ -229,9 +278,52 @@ | ||
| 229 | 278 | require $merchant_module_file; |
| 230 | 279 | } |
| 231 | 280 | |
| 232 | 281 | ?> |
| 233 | - | |
| 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> | |
| 234 | 326 | </div> |
| 235 | 327 | |
| 236 | 328 | <?php if ( Merchant_Admin_Preview::has_preview() ) : ?> |
| 237 | 329 | |
| @@ -275,10 +367,12 @@ | ||
| 275 | 367 | </div> |
| 276 | 368 | </div> |
| 277 | 369 | |
| 278 | 370 | <div class="merchant-module-footer-text"> |
| 279 | - <?php esc_html_e( 'Copyright © aThemes 2024. All Rights Reserved.', 'merchant' ); ?> | |
| 371 | + <?php esc_html_e( 'Copyright © aThemes ' . gmdate( 'Y' ) . '. All Rights Reserved.', 'merchant' ); ?> | |
| 280 | 372 | </div> |
| 373 | + | |
| 374 | + <?php require MERCHANT_DIR . 'admin/components/ai-prompts-modal.php'; ?> | |
| 281 | 375 | |
| 282 | 376 | <?php else : ?> |
| 283 | 377 | |
| 284 | 378 | <?php wp_safe_redirect( add_query_arg( array( 'page' => 'merchant' ), admin_url( 'admin.php' ) ) ); ?> |