html-admin-dashboard-setup.php
5 months 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
4 weeks ago
html-admin-page-status-tools.php
2 years ago
html-admin-page-status.php
8 years ago
html-admin-settings.php
4 weeks ago
html-bulk-edit-product.php
1 year ago
html-email-template-preview.php
1 year ago
html-notice-base-table-missing.php
3 years ago
html-notice-custom.php
8 years ago
html-notice-download-dir-sync-complete.php
2 years ago
html-notice-install.php
5 years ago
html-notice-legacy-shipping.php
11 months ago
html-notice-maxmind-license-key.php
6 years ago
html-notice-no-shipping-methods.php
2 years ago
html-notice-redirect-only-download.php
4 years ago
html-notice-regenerating-lookup-table.php
5 years ago
html-notice-regenerating-thumbnails.php
8 years ago
html-notice-secure-connection.php
2 years ago
html-notice-sync-on-read-disabled.php
3 months ago
html-notice-template-check.php
2 years ago
html-notice-update.php
4 months ago
html-notice-updated.php
7 years ago
html-notice-updating.php
6 years ago
html-notice-uploads-directory-is-unprotected.php
2 years ago
html-notice-wp-php-minimum-requirements.php
2 years ago
html-quick-edit-product.php
1 year ago
html-report-by-date.php
5 years ago
html-admin-settings.php
191 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\Admin\Features\Features; |
| 13 | use Automattic\WooCommerce\Admin\Settings\SettingsUIPageInterface; |
| 14 | use Automattic\WooCommerce\Utilities\FeaturesUtil; |
| 15 | |
| 16 | if ( ! defined( 'ABSPATH' ) ) { |
| 17 | exit; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * The current WC admin settings tab ID. |
| 22 | * |
| 23 | * @var string $current_tab |
| 24 | */ |
| 25 | |
| 26 | /** |
| 27 | * The current WC admin settings section ID. |
| 28 | * |
| 29 | * @var string $current_section |
| 30 | */ |
| 31 | |
| 32 | $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 ); |
| 33 | $current_tab_label = isset( $tabs[ $current_tab ] ) ? $tabs[ $current_tab ] : ''; |
| 34 | |
| 35 | if ( ! $tab_exists ) { |
| 36 | wp_safe_redirect( admin_url( 'admin.php?page=wc-settings' ) ); |
| 37 | exit; |
| 38 | } |
| 39 | |
| 40 | $hide_nav = 'checkout' === $current_tab && in_array( $current_section, array( 'offline', 'bacs', 'cheque', 'cod' ), true ); |
| 41 | $is_settings_ui_page = false; |
| 42 | $settings_ui_settings_page = null; |
| 43 | |
| 44 | if ( Features::is_enabled( 'settings-ui' ) ) { |
| 45 | foreach ( WC_Admin_Settings::get_settings_pages() as $settings_page ) { |
| 46 | if ( ! $settings_page instanceof WC_Settings_Page || $settings_page->get_id() !== $current_tab ) { |
| 47 | continue; |
| 48 | } |
| 49 | |
| 50 | $is_settings_ui_page = $settings_page->get_settings_ui_page() instanceof SettingsUIPageInterface; |
| 51 | $settings_ui_settings_page = $is_settings_ui_page ? $settings_page : null; |
| 52 | break; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | if ( $settings_ui_settings_page instanceof WC_Settings_Page ) { |
| 57 | remove_action( 'woocommerce_sections_' . $current_tab, array( $settings_ui_settings_page, 'output_sections' ) ); |
| 58 | } |
| 59 | |
| 60 | // Move 'Advanced' to the last. |
| 61 | if ( array_key_exists( 'advanced', $tabs ) ) { |
| 62 | $advanced = $tabs['advanced']; |
| 63 | unset( $tabs['advanced'] ); |
| 64 | // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 65 | $tabs['advanced'] = $advanced; |
| 66 | } |
| 67 | |
| 68 | $marketplace_base_url = trailingslashit( |
| 69 | esc_url_raw( apply_filters( 'woo_com_base_url', 'https://woocommerce.com/' ) ) |
| 70 | ) . 'product-category/woocommerce-extensions/'; |
| 71 | |
| 72 | $marketplace_links = array( |
| 73 | 'products' => array( |
| 74 | 'url' => $marketplace_base_url . 'merchandising/', |
| 75 | 'is_external' => true, |
| 76 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 77 | 'message' => __( '%1$sExplore solutions%2$s that help highlight products and drive more sales.', 'woocommerce' ), |
| 78 | ), |
| 79 | 'tax' => array( |
| 80 | 'url' => $marketplace_base_url . 'operations/sales-tax-and-duties/', |
| 81 | 'is_external' => true, |
| 82 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 83 | 'message' => __( '%1$sExplore solutions%2$s that help with tax calculations, compliance, and regional requirements.', 'woocommerce' ), |
| 84 | ), |
| 85 | 'shipping' => array( |
| 86 | 'url' => $marketplace_base_url . 'shipping-delivery-and-fulfillment/', |
| 87 | 'is_external' => true, |
| 88 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 89 | 'message' => __( '%1$sExplore solutions%2$s that enhance shipping, delivery, and fulfillment workflows.', 'woocommerce' ), |
| 90 | ), |
| 91 | 'account' => array( |
| 92 | 'url' => $marketplace_base_url . 'store-content-and-customizations/cart-and-checkout-features/', |
| 93 | 'is_external' => true, |
| 94 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 95 | 'message' => __( '%1$sExplore solutions%2$s that help customize cart and checkout flows.', 'woocommerce' ), |
| 96 | ), |
| 97 | 'email' => array( |
| 98 | 'url' => $marketplace_base_url . 'marketing-extensions/email-marketing-extensions/', |
| 99 | 'is_external' => true, |
| 100 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 101 | 'message' => __( '%1$sExplore solutions%2$s that help automate and improve customer email communication.', 'woocommerce' ), |
| 102 | ), |
| 103 | 'general' => array( |
| 104 | 'url' => admin_url( 'admin.php?page=wc-admin&path=%2Fextensions' ), |
| 105 | 'is_external' => false, |
| 106 | /* translators: %1$s: opening link tag, %2$s: closing link tag */ |
| 107 | 'message' => __( '%1$sDiscover additional solutions%2$s to boost your business and expand what your store can do.', 'woocommerce' ), |
| 108 | ), |
| 109 | ); |
| 110 | |
| 111 | ?> |
| 112 | |
| 113 | <div class="wrap woocommerce"> |
| 114 | <?php do_action( 'woocommerce_before_settings_' . $current_tab ); ?> |
| 115 | <form method="<?php echo esc_attr( apply_filters( 'woocommerce_settings_form_method_tab_' . $current_tab, 'post' ) ); ?>" id="mainform" action="" enctype="multipart/form-data"> |
| 116 | <?php if ( ! $hide_nav ) : ?> |
| 117 | <nav class="nav-tab-wrapper woo-nav-tab-wrapper"> |
| 118 | <?php |
| 119 | |
| 120 | foreach ( $tabs as $slug => $label ) { |
| 121 | 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>'; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Hook for adding additional settings tabs. |
| 126 | * |
| 127 | * @since 1.0.0 |
| 128 | */ |
| 129 | do_action( 'woocommerce_settings_tabs' ); |
| 130 | |
| 131 | ?> |
| 132 | </nav> |
| 133 | <?php endif; ?> |
| 134 | <h1 class="screen-reader-text"><?php echo esc_html( $current_tab_label ); ?></h1> |
| 135 | <?php |
| 136 | do_action( 'woocommerce_sections_' . $current_tab ); |
| 137 | |
| 138 | WC_Admin_Settings::show_messages(); |
| 139 | |
| 140 | do_action( 'woocommerce_settings_' . $current_tab ); |
| 141 | do_action( 'woocommerce_settings_tabs_' . $current_tab ); |
| 142 | ?> |
| 143 | <p class="submit"> |
| 144 | <?php if ( empty( $GLOBALS['hide_save_button'] ) ) : ?> |
| 145 | <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> |
| 146 | <?php endif; ?> |
| 147 | <?php wp_nonce_field( 'woocommerce-settings' ); ?> |
| 148 | </p> |
| 149 | <?php if ( isset( $marketplace_links[ $current_tab ] ) ) : ?> |
| 150 | <?php |
| 151 | $link_config = $marketplace_links[ $current_tab ]; |
| 152 | |
| 153 | if ( $link_config['is_external'] ) { |
| 154 | $utm_source = 'settings_' . $current_tab . ( $current_section ? '_' . $current_section : '' ); |
| 155 | $link_url = add_query_arg( 'utm_source', $utm_source, $link_config['url'] ); |
| 156 | $icon_url = WC()->plugin_url() . '/assets/images/icons/external-link.svg'; |
| 157 | $external_icon = '<img src="' . esc_url( $icon_url ) . '" alt="" />'; |
| 158 | $screen_reader = '<span class="screen-reader-text">' . esc_html__( '(opens in a new tab)', 'woocommerce' ) . '</span>'; |
| 159 | $link_open = '<a href="' . esc_url( $link_url ) . '" target="_blank" rel="noopener noreferrer">' . $external_icon; |
| 160 | $link_close = $screen_reader . '</a>'; |
| 161 | } else { |
| 162 | $link_open = '<a href="' . esc_url( $link_config['url'] ) . '">'; |
| 163 | $link_close = '</a>'; |
| 164 | } |
| 165 | ?> |
| 166 | <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 ) . '"' : ''; ?>> |
| 167 | <?php |
| 168 | echo wp_kses( |
| 169 | sprintf( $link_config['message'], $link_open, $link_close ), |
| 170 | array( |
| 171 | 'a' => array( |
| 172 | 'href' => array(), |
| 173 | 'target' => array(), |
| 174 | 'rel' => array(), |
| 175 | ), |
| 176 | 'img' => array( |
| 177 | 'src' => array(), |
| 178 | 'alt' => array(), |
| 179 | ), |
| 180 | 'span' => array( |
| 181 | 'class' => array(), |
| 182 | ), |
| 183 | ) |
| 184 | ); |
| 185 | ?> |
| 186 | </p> |
| 187 | <?php endif; ?> |
| 188 | </form> |
| 189 | <?php do_action( 'woocommerce_after_settings_' . $current_tab ); ?> |
| 190 | </div> |
| 191 |