From c8527468c557c72edf1aa587cd79789764cbbafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonino=20Scarf=C3=AC?= Date: Mon, 30 May 2016 15:16:26 +0200 Subject: [PATCH] Use hook to include navigation.php template --- includes/wc-template-functions.php | 10 ++++++++++ includes/wc-template-hooks.php | 1 + templates/myaccount/downloads.php | 9 +++++++-- templates/myaccount/form-add-payment-method.php | 7 ++++++- templates/myaccount/form-edit-account.php | 7 ++++++- templates/myaccount/form-edit-address.php | 7 ++++++- templates/myaccount/my-account.php | 9 +++++++-- templates/myaccount/orders.php | 8 +++++++- templates/myaccount/payment-methods.php | 10 ++++++++-- templates/myaccount/view-order.php | 9 +++++++-- 10 files changed, 65 insertions(+), 12 deletions(-) diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index fbb2435de09..f8541532a8f 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -2091,6 +2091,16 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) { } } +if ( ! function_exists( 'woocommerce_account_navigation' ) ) { + + /** + * My Account navigation template. + */ + function woocommerce_account_navigation() { + wc_get_template( 'myaccount/navigation.php' ); + } +} + if ( ! function_exists( 'woocommerce_account_orders' ) ) { /** diff --git a/includes/wc-template-hooks.php b/includes/wc-template-hooks.php index 96a27981a04..790b7b7b512 100644 --- a/includes/wc-template-hooks.php +++ b/includes/wc-template-hooks.php @@ -256,6 +256,7 @@ add_filter( 'jetpack_comment_form_enabled_for_product', '__return_false' ); /** * My Account. */ +add_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' ); add_action( 'woocommerce_account_orders_endpoint', 'woocommerce_account_orders' ); add_action( 'woocommerce_account_view-order_endpoint', 'woocommerce_account_view_order' ); add_action( 'woocommerce_account_downloads_endpoint', 'woocommerce_account_downloads' ); diff --git a/templates/myaccount/downloads.php b/templates/myaccount/downloads.php index a48f34e450c..84c1dbd2abe 100644 --- a/templates/myaccount/downloads.php +++ b/templates/myaccount/downloads.php @@ -25,9 +25,14 @@ if ( ! defined( 'ABSPATH' ) ) { $downloads = WC()->customer->get_downloadable_products(); $has_downloads = (bool) $downloads; -wc_print_notices(); ?> +wc_print_notices(); - +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>
diff --git a/templates/myaccount/form-add-payment-method.php b/templates/myaccount/form-add-payment-method.php index 968d824fd49..809dda5ed98 100644 --- a/templates/myaccount/form-add-payment-method.php +++ b/templates/myaccount/form-add-payment-method.php @@ -20,7 +20,12 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -wc_get_template( 'myaccount/navigation.php' ); ?> +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>
payment_gateways->get_available_payment_gateways() ) : ?> diff --git a/templates/myaccount/form-edit-account.php b/templates/myaccount/form-edit-account.php index c4f1e17bb63..6b4eb155e23 100644 --- a/templates/myaccount/form-edit-account.php +++ b/templates/myaccount/form-edit-account.php @@ -22,7 +22,12 @@ if ( ! defined( 'ABSPATH' ) ) { wc_print_notices(); -wc_get_template( 'myaccount/navigation.php' ); ?> +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>
diff --git a/templates/myaccount/form-edit-address.php b/templates/myaccount/form-edit-address.php index aa82c0c3444..f0a124a7937 100644 --- a/templates/myaccount/form-edit-address.php +++ b/templates/myaccount/form-edit-address.php @@ -24,7 +24,12 @@ $page_title = ( $load_address === 'billing' ) ? __( 'Billing Address', 'woocomme wc_print_notices(); -wc_get_template( 'myaccount/navigation.php' ); ?> +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>
diff --git a/templates/myaccount/my-account.php b/templates/myaccount/my-account.php index ed478c68fa1..4c87cebdd7c 100644 --- a/templates/myaccount/my-account.php +++ b/templates/myaccount/my-account.php @@ -20,9 +20,14 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -wc_print_notices(); ?> +wc_print_notices(); - +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>

diff --git a/templates/myaccount/orders.php b/templates/myaccount/orders.php index 356cbe28465..5ef4a45ac8d 100644 --- a/templates/myaccount/orders.php +++ b/templates/myaccount/orders.php @@ -23,7 +23,13 @@ if ( ! defined( 'ABSPATH' ) ) { } wc_print_notices(); -wc_get_template( 'myaccount/navigation.php' ); ?> + +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>

diff --git a/templates/myaccount/payment-methods.php b/templates/myaccount/payment-methods.php index 8cecf017fad..38029c55718 100644 --- a/templates/myaccount/payment-methods.php +++ b/templates/myaccount/payment-methods.php @@ -25,9 +25,15 @@ if ( ! defined( 'ABSPATH' ) ) { $saved_methods = wc_get_customer_saved_methods_list( get_current_user_id() ); $has_methods = (bool) $saved_methods; $types = wc_get_account_payment_methods_types(); -wc_print_notices(); ?> - +wc_print_notices(); + +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>
diff --git a/templates/myaccount/view-order.php b/templates/myaccount/view-order.php index 79baaa97233..b3d2410257a 100644 --- a/templates/myaccount/view-order.php +++ b/templates/myaccount/view-order.php @@ -22,9 +22,14 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -wc_print_notices(); ?> +wc_print_notices(); - +/** + * My Account navigation. + * + * @since 2.6.0 + */ +do_action( 'woocommerce_account_navigation' ); ?>