WC_Admin_Permalink_Settings::get_shop_base_slug
Resolve the Shop page URI that serves as the Shop base, or the default slug.
Shared by the render and the save paths so both resolve the base the same way.
wc_get_page_id() returns -1 when no page is set, so the ID is tested against zero rather than for truthiness -- and the page it names can still be gone, which get_post() catches.
Method of the class: WC_Admin_Permalink_Settings{}
No Hooks.
Returns
string. Shop base slug.
Usage
// private - for code of main (parent) class only $result = $this->get_shop_base_slug( $shop_page_id ): string;
- $shop_page_id(int) (required)
- Shop page ID, as resolved by wc_get_page_id(
'shop').
WC_Admin_Permalink_Settings::get_shop_base_slug() WC Admin Permalink Settings::get shop base slug code WC 11.2.1
private function get_shop_base_slug( int $shop_page_id ): string {
return (string) ( ( $shop_page_id > 0 && get_post( $shop_page_id ) ) ? get_page_uri( $shop_page_id ) : _x( 'shop', 'default-slug', 'woocommerce' ) );
}