translated label. */ public static function get_weekday_choices() { return Merchant_Select2_Choices::get_weekday_choices(); } /** * Get shipping zone choices for Select2. * * @since 2.3.2 * @see Merchant_Select2_Choices::get_shipping_zone_select2_choices() * * @return array Formatted zone choices. */ public static function get_shipping_zone_select2_choices() { return Merchant_Select2_Choices::get_shipping_zone_select2_choices(); } /** * Get registered shipping method choices for Select2. * * @since 2.3.2 * @see Merchant_Select2_Choices::get_shipping_method_select2_choices() * * @return array Formatted method choices. */ public static function get_shipping_method_select2_choices() { return Merchant_Select2_Choices::get_shipping_method_select2_choices(); } /** * Get enabled payment gateway choices for Select2. * * @since 2.3.2 * @see Merchant_Select2_Choices::get_payment_gateway_select2_choices() * * @return array Formatted gateway choices. */ public static function get_payment_gateway_select2_choices() { return Merchant_Select2_Choices::get_payment_gateway_select2_choices(); } /** * Get customer user choices for Select2. * * @since 1.9.3 * @see Merchant_Select2_Choices::get_customers_select2_choices() * * @return array Formatted customer choices. */ public static function get_customers_select2_choices() { return Merchant_Select2_Choices::get_customers_select2_choices(); } // ────────────────────────────────────────────────────── // Admin hooks — small one-off actions. // ────────────────────────────────────────────────────── /** * Delete stale module data from the database. * * Cleans up data for removed modules (e.g., the deprecated * `code-snippets` module). Hooked to `admin_init`. * * @since 1.9.3 * * @return void */ public function delete_module_data() { $options = get_option( 'merchant', array() ); if ( isset( $options['code-snippets'] ) ) { unset( $options['code-snippets'] ); update_option( 'merchant', $options ); } } /** * Activate the Merchant Pro plugin. * * Handles the `merchant_activate_pro` admin action: verifies * nonce and capabilities, activates the Pro plugin, and * redirects back to the originating Merchant page. * * @since 1.0 * * @return void */ public function activate_pro_plugin() { if ( ! isset( $_GET['action'] ) || 'merchant_activate_pro' !== $_GET['action'] ) { return; } if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'merchant_activate_pro' ) ) { return; } if ( ! current_user_can( 'activate_plugins' ) ) { return; } $result = activate_plugin( 'merchant-pro/merchant-pro.php' ); if ( is_wp_error( $result ) ) { wp_die( esc_html( $result->get_error_message() ) ); } wp_safe_redirect( $this->get_safe_merchant_redirect_url() ); exit; } /** * Get a safe redirect URL pointing to a Merchant admin page. * * Validates the HTTP referer is a Merchant page. Falls back * to the main Merchant dashboard if the referer is invalid * or points to a non-Merchant page. * * @since 1.9.3 * * @return string Safe redirect URL. */ private function get_safe_merchant_redirect_url() { $fallback_url = admin_url( 'admin.php?page=merchant' ); $referer = wp_get_referer(); $redirect_to = wp_validate_redirect( $referer, $fallback_url ); if ( $redirect_to === $fallback_url ) { return $fallback_url; } $parsed_url = wp_parse_url( $redirect_to ); $query_params = array(); parse_str( $parsed_url['query'] ?? '', $query_params ); if ( empty( $query_params['page'] ) || strpos( $query_params['page'], 'merchant' ) !== 0 ) { return $fallback_url; } return $redirect_to; } } Merchant_Admin_Options::instance(); }