| @@ -68,8 +68,9 @@ | ||
| 68 | 68 | require_once MERCHANT_DIR . 'admin/notices/class-merchant-notice.php'; |
| 69 | 69 | require_once MERCHANT_DIR . 'admin/notices/class-merchant-notice-review.php'; |
| 70 | 70 | require_once MERCHANT_DIR . 'admin/notices/class-merchant-notice-upsell.php'; |
| 71 | 71 | require_once MERCHANT_DIR . 'admin/notices/class-merchant-notice-campaign.php'; |
| 72 | + require_once MERCHANT_DIR . 'admin/notices/class-merchant-patcher-eol-notice.php'; | |
| 72 | 73 | |
| 73 | 74 | // Admin classes. |
| 74 | 75 | require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-menu.php'; |
| 75 | 76 | |
| @@ -89,8 +90,11 @@ | ||
| 89 | 90 | require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-utils.php'; |
| 90 | 91 | require_once MERCHANT_DIR . 'admin/classes/class-merchant-admin-preview.php'; |
| 91 | 92 | // Plugin installer. |
| 92 | 93 | require_once MERCHANT_DIR . 'admin/classes/class-merchant-plugin-installer.php'; |
| 94 | + | |
| 95 | + // White Label settings section. | |
| 96 | + require_once MERCHANT_DIR . 'admin/classes/class-merchant-white-label-settings.php'; | |
| 93 | 97 | } |
| 94 | 98 | |
| 95 | 99 | /** |
| 96 | 100 | * Enqueue admin styles and scripts. |
| @@ -95,15 +99,16 @@ | ||
| 95 | 99 | /** |
| 96 | 100 | * Enqueue admin styles and scripts. |
| 97 | 101 | */ |
| 98 | 102 | public function enqueue_styles_scripts() { |
| 99 | - $page = sanitize_text_field( wp_unslash( $_GET['page'] ?? '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 100 | 103 | $section = sanitize_text_field( wp_unslash( $_GET['section'] ?? '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 101 | 104 | |
| 102 | 105 | wp_register_script( 'merchant-select2', MERCHANT_URI . 'assets/vendor/select2/select2.full.min.js', array( 'jquery' ), '4.0.13', true ); |
| 103 | 106 | wp_register_style( 'merchant-select2', MERCHANT_URI . 'assets/vendor/select2/select2.min.css', array(), '4.0.13' ); |
| 104 | 107 | |
| 105 | - if ( ! empty( $page ) && false !== strpos( $page, 'merchant' ) ) { | |
| 108 | + // Registering stays unconditional so other screens can enqueue the handles; the | |
| 109 | + // enqueues below are for Merchant's own screens only. | |
| 110 | + if ( $this->is_merchant_screen() ) { | |
| 106 | 111 | |
| 107 | 112 | // For settings page only |
| 108 | 113 | if ( $section === 'settings' ) { |
| 109 | 114 | wp_enqueue_code_editor( array( 'type' => 'text/css' ) ); // No need to enqueue again for JS. It'll be handled by JS. |
| @@ -124,10 +129,12 @@ | ||
| 124 | 129 | |
| 125 | 130 | wp_enqueue_script( 'merchant-admin', MERCHANT_URI . 'assets/js/admin/admin.min.js', array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-core', 'jquery-ui-accordion', 'wp-util' ), MERCHANT_VERSION, true ); |
| 126 | 131 | |
| 127 | 132 | $localized_data = array( |
| 128 | - 'nonce' => wp_create_nonce( 'merchant' ), | |
| 129 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 133 | + 'nonce' => wp_create_nonce( 'merchant' ), | |
| 134 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 135 | + 'ai_prompt_copy_hint' => esc_html__( 'Click to copy', 'merchant' ), | |
| 136 | + 'ai_prompt_copied_label' => esc_html__( 'Copied!', 'merchant' ), | |
| 130 | 137 | ); |
| 131 | 138 | |
| 132 | 139 | /** |
| 133 | 140 | * Hook 'merchant_admin_localize_script' |
| @@ -162,24 +169,39 @@ | ||
| 162 | 169 | |
| 163 | 170 | /** |
| 164 | 171 | * Add admin body class. |
| 165 | 172 | */ |
| 166 | - public function add_admin_body_class( $classes ) { | |
| 167 | - $page = ( ! empty( $_GET['page'] ) ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 173 | + public function add_admin_body_class( $classes ) { | |
| 174 | + if ( ! $this->is_merchant_screen() ) { | |
| 175 | + return $classes; | |
| 176 | + } | |
| 177 | + | |
| 168 | 178 | $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 169 | 179 | $section = ( ! empty( $_GET['section'] ) ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 170 | 180 | |
| 171 | - if ( ! empty( $page ) && false !== strpos( $page, 'merchant' ) ) { | |
| 172 | - if ( ! empty( $module ) ) { | |
| 173 | - $classes .= ' merchant-admin-page-module'; | |
| 174 | - } else { | |
| 175 | - $section = $section ? 'merchant-admin-page__' . $section : 'merchant-admin-page__dashboard'; | |
| 176 | - $classes .= ' merchant-admin-page ' . $section; | |
| 181 | + if ( ! empty( $module ) ) { | |
| 182 | + return $classes . ' merchant-admin-page-module'; | |
| 183 | + } | |
| 177 | 184 | |
| 178 | - } | |
| 179 | - } | |
| 185 | + $section = $section ? 'merchant-admin-page__' . $section : 'merchant-admin-page__dashboard'; | |
| 180 | 186 | |
| 181 | - return $classes; | |
| 187 | + return $classes . ' merchant-admin-page ' . $section; | |
| 188 | + } | |
| 189 | + | |
| 190 | + /** | |
| 191 | + * Whether the screen being rendered is one of Merchant's own. | |
| 192 | + * | |
| 193 | + * Exact match, not a substring one: every Merchant screen arrives as | |
| 194 | + * `page=merchant`, and a substring match leaked the admin bundle onto foreign | |
| 195 | + * screens such as `page=merchant-delivery-calendar`, where it hid admin notices. | |
| 196 | + * | |
| 197 | + * @return bool | |
| 198 | + */ | |
| 199 | + private function is_merchant_screen() { | |
| 200 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 201 | + $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; | |
| 202 | + | |
| 203 | + return 'merchant' === $page; | |
| 182 | 204 | } |
| 183 | 205 | } |
| 184 | 206 | |
| 185 | 207 | Merchant_Admin_Loader::instance(); |