| @@ -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 | |
| @@ -98,15 +99,16 @@ | ||
| 98 | 99 | /** |
| 99 | 100 | * Enqueue admin styles and scripts. |
| 100 | 101 | */ |
| 101 | 102 | public function enqueue_styles_scripts() { |
| 102 | - $page = sanitize_text_field( wp_unslash( $_GET['page'] ?? '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 103 | 103 | $section = sanitize_text_field( wp_unslash( $_GET['section'] ?? '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 104 | 104 | |
| 105 | 105 | wp_register_script( 'merchant-select2', MERCHANT_URI . 'assets/vendor/select2/select2.full.min.js', array( 'jquery' ), '4.0.13', true ); |
| 106 | 106 | wp_register_style( 'merchant-select2', MERCHANT_URI . 'assets/vendor/select2/select2.min.css', array(), '4.0.13' ); |
| 107 | 107 | |
| 108 | - 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() ) { | |
| 109 | 111 | |
| 110 | 112 | // For settings page only |
| 111 | 113 | if ( $section === 'settings' ) { |
| 112 | 114 | wp_enqueue_code_editor( array( 'type' => 'text/css' ) ); // No need to enqueue again for JS. It'll be handled by JS. |
| @@ -167,24 +169,39 @@ | ||
| 167 | 169 | |
| 168 | 170 | /** |
| 169 | 171 | * Add admin body class. |
| 170 | 172 | */ |
| 171 | - public function add_admin_body_class( $classes ) { | |
| 172 | - $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 | + | |
| 173 | 178 | $module = ( ! empty( $_GET['module'] ) ) ? sanitize_text_field( wp_unslash( $_GET['module'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 174 | 179 | $section = ( ! empty( $_GET['section'] ) ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 175 | 180 | |
| 176 | - if ( ! empty( $page ) && false !== strpos( $page, 'merchant' ) ) { | |
| 177 | - if ( ! empty( $module ) ) { | |
| 178 | - $classes .= ' merchant-admin-page-module'; | |
| 179 | - } else { | |
| 180 | - $section = $section ? 'merchant-admin-page__' . $section : 'merchant-admin-page__dashboard'; | |
| 181 | - $classes .= ' merchant-admin-page ' . $section; | |
| 181 | + if ( ! empty( $module ) ) { | |
| 182 | + return $classes . ' merchant-admin-page-module'; | |
| 183 | + } | |
| 182 | 184 | |
| 183 | - } | |
| 184 | - } | |
| 185 | + $section = $section ? 'merchant-admin-page__' . $section : 'merchant-admin-page__dashboard'; | |
| 185 | 186 | |
| 186 | - 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; | |
| 187 | 204 | } |
| 188 | 205 | } |
| 189 | 206 | |
| 190 | 207 | Merchant_Admin_Loader::instance(); |