Skip to content

Instantly share code, notes, and snippets.

@guilhermealveslopes
Created September 19, 2017 11:55
Show Gist options
  • Save guilhermealveslopes/af0b28f69004e5c6e94d940626b44552 to your computer and use it in GitHub Desktop.
Save guilhermealveslopes/af0b28f69004e5c6e94d940626b44552 to your computer and use it in GitHub Desktop.
Custom Endpoint Woocommerce
/* Endpoints */
/* pedidosantigos */
function endChamados() {
add_rewrite_endpoint( 'chamados', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'endChamados' );
function varChamados( $vars ) {
$vars[] = 'chamados';
return $vars;
}
add_filter( 'query_vars', 'varChamados', 0 );
function my_custom_flush_rewrite_rules() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_custom_flush_rewrite_rules' );
function contaChamados( $items ) {
$items = array(
'dashboard' => __( 'Dashboard', 'woocommerce' ),
'orders' => __( 'Orders', 'woocommerce' ),
//'downloads' => __( 'Downloads', 'woocommerce' ),
//'edit-address' => __( 'Addresses', 'woocommerce' ),
//'payment-methods' => __( 'Payment Methods', 'woocommerce' ),
'edit-account' => __( 'Edit Account', 'woocommerce' ),
'chamados' => 'Chamados',
'customer-logout' => __( 'Logout', 'woocommerce' ),
);
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'contaChamados' );
function conteudoChamados() {
include 'woocommerce/myaccount/chamados.php';
}
add_action( 'woocommerce_account_chamados_endpoint', 'conteudoChamados' );
?>
// Chama link na página interna
<?php
printf(
__( '<a class="perfil-dados" href="%1$s">chamados</a>', 'woocommerce' ),
esc_url( wc_get_endpoint_url( 'chamados' ) )
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment