query_vars[ self::$endpoint ] ); if ( $is_endpoint && ! is_admin() && is_main_query() && in_the_loop() && is_account_page() ) { // New page title. $title = __( 'My Custom Endpoint', 'woocommerce' ); remove_filter( 'the_title', array( $this, 'endpoint_title' ) ); } return $title; } /** * Insert the new endpoint into the My Account menu. * * @param array $items * @return array */ public function new_menu_items( $items ) { // Remove the logout menu item. $logout = $items['customer-logout']; unset( $items['customer-logout'] ); // Insert your custom endpoint. $items[ self::$endpoint ] = __( 'My Custom Endpoint', 'woocommerce' ); // Insert back the logout item. $items['customer-logout'] = $logout; return $items; } /** * Endpoint HTML content. */ public function endpoint_content() { echo '

Hello World!

'; // You can load a template here with wc_get_template( 'myaccount/my-custom-endpoint.php' ); } /** * Plugin install action. * Flush rewrite rules to make our custom endpoint available. */ public static function install() { flush_rewrite_rules(); } } new My_Custom_My_Account_Endpoint(); // Flush rewrite rules on plugin activation. register_activation_hook( __FILE__, array( 'My_Custom_My_Account_Endpoint', 'install' ) );