I am extending an current plugin, and it has a web page with the historical past of lottery orders and their final result, like Participated/Gained/Misplaced. The varied outcomes are distinguished by a param handed to the querystring, like http://localhost/lot/dashboard/?dashboard_menu=participated
, http://localhost/lot/dashboard/?dashboard_menu=received
, http://localhost/lot/dashboard/?dashboard_menu=not_won
…
I needed to maneuver the web page below My account, so I added a rewrite endpoint like this: add_rewrite_endpoint( 'participated-lotteries', EP_PAGES );
, additionally added the suitable menu entry like this:
add_filter( 'woocommerce_account_menu_items', array( __CLASS__, 'account_participated_lotteries_endpoint_menu_item' ) );
public static perform account_participated_lotteries_endpoint_menu_item( $menu_links ) {
return array_merge( array_slice( $menu_links, 0, 2, true ), array( 'participated-lotteries' => __('Participated lotteries', 'lottery-for-woocommerce' ) ), array_slice( $menu_links, 2, null, true ) );
}
and at last hooked the plugin’s output perform to the add_action( 'woocommerce_account_participated-lotteries_endpoint', array( __CLASS__, 'output' ) );
the place woocommerce_account_<endpoint>_endpoint
is the suitable hook level to make use of for circumstances like assigning a template to a menu entry like on this case…
Anyway, what I did works advantageous for the touchdown web page however as quickly because the person clicks on one other tab, like Gained/Misplaced, and the param seems within the querystring, I get a clean web page… Additionally, as a result of all these Participated/Gained/Misplaced variants can deal with pagination, if I add sufficient mockup data to set off pagination, the paginating hyperlinks additionally lead to a clean web page… Usually, my answer cannot deal with the params within the querystring… One way or the other I must outline the base URL for this rewrite. However is there even such a factor? Possibly my complete method is flawed? I really feel I am shut, however sadly cannot determine this out myself but… Possibly I want so as to add a rewrite tag for the param? However it’s not just one param… There’s one param for the variants (Participated/Gained/Misplaced), and one for the pagination (page_no), so ought to I add two possibly?