helper
1 year ago
importers
1 year ago
list-tables
1 year ago
marketplace-suggestions
1 year ago
meta-boxes
1 year ago
notes
1 year ago
plugin-updates
1 year ago
reports
1 year ago
settings
1 year ago
views
1 year ago
class-wc-admin-addons.php
1 year ago
class-wc-admin-api-keys-table-list.php
1 year ago
class-wc-admin-api-keys.php
1 year ago
class-wc-admin-assets.php
1 year ago
class-wc-admin-attributes.php
1 year ago
class-wc-admin-customize.php
1 year ago
class-wc-admin-dashboard-setup.php
1 year ago
class-wc-admin-dashboard.php
1 year ago
class-wc-admin-duplicate-product.php
1 year ago
class-wc-admin-exporters.php
1 year ago
class-wc-admin-help.php
1 year ago
class-wc-admin-importers.php
1 year ago
class-wc-admin-log-table-list.php
1 year ago
class-wc-admin-marketplace-promotions.php
1 year ago
class-wc-admin-menus.php
1 year ago
class-wc-admin-meta-boxes.php
1 year ago
class-wc-admin-notices.php
1 year ago
class-wc-admin-permalink-settings.php
1 year ago
class-wc-admin-pointers.php
1 year ago
class-wc-admin-post-types.php
1 year ago
class-wc-admin-profile.php
1 year ago
class-wc-admin-reports.php
1 year ago
class-wc-admin-settings.php
1 year ago
class-wc-admin-setup-wizard.php
1 year ago
class-wc-admin-status.php
1 year ago
class-wc-admin-taxonomies.php
1 year ago
class-wc-admin-upload-downloadable-product.php
1 year ago
class-wc-admin-webhooks-table-list.php
1 year ago
class-wc-admin-webhooks.php
1 year ago
class-wc-admin.php
1 year ago
wc-admin-functions.php
1 year ago
wc-meta-box-functions.php
1 year ago
class-wc-admin-customize.php
97 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Setup customize items. |
| 4 | * |
| 5 | * @package WooCommerce\Admin\Customize |
| 6 | * @version 3.1.0 |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | if ( ! class_exists( 'WC_Admin_Customize', false ) ) : |
| 14 | |
| 15 | /** |
| 16 | * WC_Admin_Customize Class. |
| 17 | */ |
| 18 | class WC_Admin_Customize { |
| 19 | |
| 20 | /** |
| 21 | * Initialize customize actions. |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | // Include custom items to customizer nav menu settings. |
| 25 | add_filter( 'customize_nav_menu_available_item_types', array( $this, 'register_customize_nav_menu_item_types' ) ); |
| 26 | add_filter( 'customize_nav_menu_available_items', array( $this, 'register_customize_nav_menu_items' ), 10, 4 ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Register customize new nav menu item types. |
| 31 | * This will register WooCommerce account endpoints as a nav menu item type. |
| 32 | * |
| 33 | * @since 3.1.0 |
| 34 | * @param array $item_types Menu item types. |
| 35 | * @return array |
| 36 | */ |
| 37 | public function register_customize_nav_menu_item_types( $item_types ) { |
| 38 | $item_types[] = array( |
| 39 | 'title' => __( 'WooCommerce Endpoints', 'woocommerce' ), |
| 40 | 'type_label' => __( 'WooCommerce Endpoint', 'woocommerce' ), |
| 41 | 'type' => 'woocommerce_nav', |
| 42 | 'object' => 'woocommerce_endpoint', |
| 43 | ); |
| 44 | |
| 45 | return $item_types; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Register account endpoints to customize nav menu items. |
| 50 | * |
| 51 | * @since 3.1.0 |
| 52 | * @param array $items List of nav menu items. |
| 53 | * @param string $type Nav menu type. |
| 54 | * @param string $object Nav menu object. |
| 55 | * @param integer $page Page number. |
| 56 | * @return array |
| 57 | */ |
| 58 | public function register_customize_nav_menu_items( $items = array(), $type = '', $object = '', $page = 0 ) { |
| 59 | if ( 'woocommerce_endpoint' !== $object ) { |
| 60 | return $items; |
| 61 | } |
| 62 | |
| 63 | // Don't allow pagination since all items are loaded at once. |
| 64 | if ( 0 < $page ) { |
| 65 | return $items; |
| 66 | } |
| 67 | |
| 68 | // Get items from account menu. |
| 69 | $endpoints = wc_get_account_menu_items(); |
| 70 | |
| 71 | // Remove dashboard item. |
| 72 | if ( isset( $endpoints['dashboard'] ) ) { |
| 73 | unset( $endpoints['dashboard'] ); |
| 74 | } |
| 75 | |
| 76 | // Include missing lost password. |
| 77 | $endpoints['lost-password'] = __( 'Lost password', 'woocommerce' ); |
| 78 | |
| 79 | $endpoints = apply_filters( 'woocommerce_custom_nav_menu_items', $endpoints ); |
| 80 | |
| 81 | foreach ( $endpoints as $endpoint => $title ) { |
| 82 | $items[] = array( |
| 83 | 'id' => $endpoint, |
| 84 | 'title' => $title, |
| 85 | 'type_label' => __( 'Custom Link', 'woocommerce' ), |
| 86 | 'url' => esc_url_raw( wc_get_account_endpoint_url( $endpoint ) ), |
| 87 | ); |
| 88 | } |
| 89 | |
| 90 | return $items; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | endif; |
| 95 | |
| 96 | return new WC_Admin_Customize(); |
| 97 |