以下是为Woocommerce我的帐户页面创建,定义和重命名/重新排序自定义端点的代码。一切都很好,直到我更新了Woocommerce和Avada。现在,在单击新菜单项时,会显示ERROR 404页面,URL为:
http://pplkonyv.hu/my-account/my-custom-endpoint
我应该修改什么?
function my_custom_endpoints() {
add_rewrite_endpoint( 'my-custom-endpoint', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'my_custom_endpoints' );
/**
* Add new query var.
*
* @param array $vars
* @return array
*/
function my_custom_query_vars( $vars ) {
$vars[] = 'my-custom-endpoint';
return $vars;
}
add_filter( 'query_vars', 'my_custom_query_vars', 0 );
/**
* Flush rewrite rules on theme activation.
*/
function my_custom_flush_rewrite_rules() {
add_rewrite_endpoint( 'my-custom-endpoint', EP_ROOT | EP_PAGES );
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_custom_flush_rewrite_rules' );
/**
* Insert the new endpoint into the My Account menu.
*
* @param array $items
* @return array
*/
function my_custom_my_account_menu_items( $items ) {
// Insert your custom endpoint.
$items['my-custom-endpoint'] = __( 'My Custom Endpoint', 'woocommerce' );
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );
/**
* Endpoint HTML content.
*/
function my_custom_endpoint_content() {
echo ( '<h2>Előfizetések</h2>' );
echo do_shortcode( '[ld_profile]' );
}
add_action( 'woocommerce_account_my-custom-endpoint_endpoint', 'my_custom_endpoint_content' );
function wpb_woo_my_account_order() {
$myorder = array(
'edit-account' => __( 'Felhasználónév és jelszó', 'woocommerce' ),
'edit-address' => __( 'Címek', 'woocommerce' ),
'orders' => __( 'Megrendelések', 'woocommerce' ),
'my-custom-endpoint' => __( 'Előfizetések', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' ),
);
return $myorder;
}
add_filter ( 'woocommerce_account_menu_items', 'wpb_woo_my_account_order' );