html-admin-dashboard-setup.php
1 month ago
html-admin-page-addons-category-nav.php
4 years ago
html-admin-page-product-export.php
1 year ago
html-admin-page-reports.php
2 years ago
html-admin-page-status-logs-db.php
2 years ago
html-admin-page-status-logs.php
2 years ago
html-admin-page-status-report.php
2 months ago
html-admin-page-status-tools.php
1 month ago
html-admin-page-status.php
8 years ago
html-admin-settings.php
1 month ago
html-bulk-edit-product.php
1 year ago
html-email-template-preview.php
1 year ago
html-notice-custom.php
8 years ago
html-notice-update.php
6 months ago
html-notice-updated.php
7 years ago
html-notice-updating.php
6 years ago
html-quick-edit-product.php
1 year ago
html-report-by-date.php
5 years ago
html-admin-settings.php
206 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin View: Settings |
| 4 | * |
| 5 | * This file is included in WC_Admin_Settings::output(). |
| 6 | * |
| 7 | * @package WooCommerce |
| 8 | */ |
| 9 | |
| 10 | // phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment |
| 11 | |
| 12 | use Automattic\WooCommerce\Internal\Admin\Settings\SettingsUIRequestContext; |
| 13 | use Automattic\WooCommerce\Utilities\FeaturesUtil; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * The current WC admin settings tab ID. |
| 21 | * |
| 22 | * @var string $current_tab |
| 23 | */ |
| 24 | |
| 25 | /** |
| 26 | * The current WC admin settings section ID. |
| 27 | * |
| 28 | * @var string $current_section |
| 29 | */ |
| 30 | |
| 31 | $tab_exists = isset( $tabs[ $current_tab ] ) || has_action( 'woocommerce_sections_' . $current_tab ) || has_action( 'woocommerce_settings_' . $current_tab ) || has_action( 'woocommerce_settings_tabs_' . $current_tab ); |
| 32 | $current_tab_label = isset( $tabs[ $current_tab ] ) ? $tabs[ $current_tab ] : ''; |
| 33 | |
| 34 | if ( ! $tab_exists ) { |
| 35 | wp_safe_redirect( admin_url( 'admin.php?page=wc-settings' ) ); |
| 36 | exit; |
| 37 | } |
| 38 | |
| 39 | // Resolve the Settings UI context for this request, falling back to legacy |
| 40 | // rendering when the settings SDK classes are unavailable or stale. The class |
| 41 | // can be missing or outdated mid-update, when this file has been replaced on |
| 42 | // disk but the cached autoloader has not refreshed yet. |
| 43 | $settings_ui_context = null; |
| 44 | $settings_ui_settings_page = null; |
| 45 | $is_rendering_settings_ui_drill_down = false; |
| 46 | try { |
| 47 | if ( class_exists( SettingsUIRequestContext::class ) ) { |
| 48 | $settings_ui_context = SettingsUIRequestContext::get_current(); |
| 49 | } |
| 50 | |
| 51 | if ( $settings_ui_context ) { |
| 52 | $settings_ui_settings_page = $settings_ui_context->get_settings_page(); |
| 53 | $is_rendering_settings_ui_drill_down = $settings_ui_context->is_rendering_enabled() |
| 54 | && $settings_ui_context->is_drill_down() |
| 55 | && ! $settings_ui_context->has_schema_failed() |
| 56 | && ! $settings_ui_context->has_script_handles_failed(); |
| 57 | } |
| 58 | } catch ( \Throwable $e ) { |
| 59 | $settings_ui_context = null; |
| 60 | $settings_ui_settings_page = null; |
| 61 | $is_rendering_settings_ui_drill_down = false; |
| 62 | } |
| 63 | |
| 64 | // Drill-down pages replace the top-level settings tabs with their own header when the shell can render. |
| 65 | $hide_nav = ( 'checkout' === $current_tab && in_array( $current_section, array( 'offline', 'bacs', 'cheque', 'cod' ), true ) ) |
| 66 | || $is_rendering_settings_ui_drill_down; |
| 67 | |
| 68 | $is_settings_ui_page = null !== $settings_ui_settings_page; |
| 69 | |
| 70 | // Drill-down pages replace the section links with header breadcrumbs when the shell can render. |
| 71 | if ( $settings_ui_settings_page instanceof WC_Settings_Page && $is_rendering_settings_ui_drill_down ) { |
| 72 | remove_action( 'woocommerce_sections_' . $current_tab, array( $settings_ui_settings_page, 'output_sections' ) ); |
| 73 | } |
| 74 | |
| 75 | // Move 'Advanced' to the last. |
| 76 | if ( array_key_exists( 'advanced', $tabs ) ) { |
| 77 | $advanced = $tabs['advanced']; |
| 78 | unset( $tabs['advanced'] ); |
| 79 | // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 80 | $tabs['advanced'] = $advanced; |
| 81 | } |
| 82 | |
| 83 | $marketplace_base_url = trailingslashit( |
| 84 | esc_url_raw( apply_filters( 'woo_com_base_url', 'https://woocommerce.com/' ) ) |
| 85 | ) . 'product-category/woocommerce-extensions/'; |
| 86 | |
| 87 | $marketplace_links = array( |
| 88 | 'products' => array( |
| 89 | 'url' => $marketplace_base_url . 'merchandising/', |
| 90 | 'is_external' => true, |
| 91 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 92 | 'message' => __( '%1$sExplore solutions%2$s that help highlight products and drive more sales.', 'woocommerce' ), |
| 93 | ), |
| 94 | 'tax' => array( |
| 95 | 'url' => $marketplace_base_url . 'operations/sales-tax-and-duties/', |
| 96 | 'is_external' => true, |
| 97 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 98 | 'message' => __( '%1$sExplore solutions%2$s that help with tax calculations, compliance, and regional requirements.', 'woocommerce' ), |
| 99 | ), |
| 100 | 'shipping' => array( |
| 101 | 'url' => $marketplace_base_url . 'shipping-delivery-and-fulfillment/', |
| 102 | 'is_external' => true, |
| 103 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 104 | 'message' => __( '%1$sExplore solutions%2$s that enhance shipping, delivery, and fulfillment workflows.', 'woocommerce' ), |
| 105 | ), |
| 106 | 'account' => array( |
| 107 | 'url' => $marketplace_base_url . 'store-content-and-customizations/cart-and-checkout-features/', |
| 108 | 'is_external' => true, |
| 109 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 110 | 'message' => __( '%1$sExplore solutions%2$s that help customize cart and checkout flows.', 'woocommerce' ), |
| 111 | ), |
| 112 | 'email' => array( |
| 113 | 'url' => $marketplace_base_url . 'marketing-extensions/email-marketing-extensions/', |
| 114 | 'is_external' => true, |
| 115 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 116 | 'message' => __( '%1$sExplore solutions%2$s that help automate and improve customer email communication.', 'woocommerce' ), |
| 117 | ), |
| 118 | 'general' => array( |
| 119 | 'url' => admin_url( 'admin.php?page=wc-admin&path=%2Fextensions' ), |
| 120 | 'is_external' => false, |
| 121 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 122 | 'message' => __( '%1$sDiscover additional solutions%2$s to boost your business and expand what your store can do.', 'woocommerce' ), |
| 123 | ), |
| 124 | ); |
| 125 | |
| 126 | ?> |
| 127 | |
| 128 | <div class="wrap woocommerce"> |
| 129 | <?php do_action( 'woocommerce_before_settings_' . $current_tab ); ?> |
| 130 | <form method="<?php echo esc_attr( apply_filters( 'woocommerce_settings_form_method_tab_' . $current_tab, 'post' ) ); ?>" id="mainform" action="" enctype="multipart/form-data"> |
| 131 | <?php if ( ! $hide_nav ) : ?> |
| 132 | <nav class="nav-tab-wrapper woo-nav-tab-wrapper"> |
| 133 | <?php |
| 134 | |
| 135 | foreach ( $tabs as $slug => $label ) { |
| 136 | echo '<a href="' . esc_html( admin_url( 'admin.php?page=wc-settings&tab=' . esc_attr( $slug ) ) ) . '" class="nav-tab ' . ( $current_tab === $slug ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Hook for adding additional settings tabs. |
| 141 | * |
| 142 | * @since 1.0.0 |
| 143 | */ |
| 144 | do_action( 'woocommerce_settings_tabs' ); |
| 145 | |
| 146 | ?> |
| 147 | </nav> |
| 148 | <?php endif; ?> |
| 149 | <h1 class="screen-reader-text"><?php echo esc_html( $current_tab_label ); ?></h1> |
| 150 | <?php |
| 151 | do_action( 'woocommerce_sections_' . $current_tab ); |
| 152 | |
| 153 | WC_Admin_Settings::show_messages(); |
| 154 | |
| 155 | do_action( 'woocommerce_settings_' . $current_tab ); |
| 156 | do_action( 'woocommerce_settings_tabs_' . $current_tab ); |
| 157 | ?> |
| 158 | <p class="submit"> |
| 159 | <?php if ( empty( $GLOBALS['hide_save_button'] ) ) : ?> |
| 160 | <button name="save" disabled class="woocommerce-save-button components-button is-primary" type="submit" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ); ?>"><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button> |
| 161 | <?php endif; ?> |
| 162 | <?php wp_nonce_field( 'woocommerce-settings' ); ?> |
| 163 | </p> |
| 164 | <?php if ( isset( $marketplace_links[ $current_tab ] ) ) : ?> |
| 165 | <?php |
| 166 | $link_config = $marketplace_links[ $current_tab ]; |
| 167 | |
| 168 | if ( $link_config['is_external'] ) { |
| 169 | $utm_source = 'settings_' . $current_tab . ( $current_section ? '_' . $current_section : '' ); |
| 170 | $link_url = add_query_arg( 'utm_source', $utm_source, $link_config['url'] ); |
| 171 | $icon_url = WC()->plugin_url() . '/assets/images/icons/external-link.svg'; |
| 172 | $external_icon = '<img src="' . esc_url( $icon_url ) . '" alt="" />'; |
| 173 | $screen_reader = '<span class="screen-reader-text">' . esc_html__( '(opens in a new tab)', 'woocommerce' ) . '</span>'; |
| 174 | $link_open = '<a href="' . esc_url( $link_url ) . '" target="_blank" rel="noopener noreferrer">' . $external_icon; |
| 175 | $link_close = $screen_reader . '</a>'; |
| 176 | } else { |
| 177 | $link_open = '<a href="' . esc_url( $link_config['url'] ) . '">'; |
| 178 | $link_close = '</a>'; |
| 179 | } |
| 180 | ?> |
| 181 | <p class="wc-settings-marketplace-link" data-settings-tab="<?php echo esc_attr( $current_tab ); ?>"<?php echo $current_section ? ' data-settings-section="' . esc_attr( $current_section ) . '"' : ''; ?>> |
| 182 | <?php |
| 183 | echo wp_kses( |
| 184 | sprintf( $link_config['message'], $link_open, $link_close ), |
| 185 | array( |
| 186 | 'a' => array( |
| 187 | 'href' => array(), |
| 188 | 'target' => array(), |
| 189 | 'rel' => array(), |
| 190 | ), |
| 191 | 'img' => array( |
| 192 | 'src' => array(), |
| 193 | 'alt' => array(), |
| 194 | ), |
| 195 | 'span' => array( |
| 196 | 'class' => array(), |
| 197 | ), |
| 198 | ) |
| 199 | ); |
| 200 | ?> |
| 201 | </p> |
| 202 | <?php endif; ?> |
| 203 | </form> |
| 204 | <?php do_action( 'woocommerce_after_settings_' . $current_tab ); ?> |
| 205 | </div> |
| 206 |