WC_Admin_Permalink_Settings
in package
WC_Admin_Permalink_Settings Class.
Table of Contents
- $permalinks : array<string|int, mixed>
- Permalink settings.
- __construct() : mixed
- Hook in tabs.
- product_attribute_slug_input() : mixed
- Show a slug input box.
- product_category_slug_input() : mixed
- Show a slug input box.
- product_tag_slug_input() : mixed
- Show a slug input box.
- settings() : mixed
- Show the settings.
- settings_init() : mixed
- Init our settings.
- settings_save() : mixed
- Save the settings.
- get_shop_base_slug() : string
- Resolve the Shop page URI that serves as the Shop base, or the default slug.
- get_stored_product_base() : string
- Resolve a posted product permalink choice to the value that gets persisted for it.
Properties
$permalinks
Permalink settings.
private
array<string|int, mixed>
$permalinks
= array()
Methods
__construct()
Hook in tabs.
public
__construct() : mixed
Return values
mixed —product_attribute_slug_input()
Show a slug input box.
public
product_attribute_slug_input() : mixed
Return values
mixed —product_category_slug_input()
Show a slug input box.
public
product_category_slug_input() : mixed
Return values
mixed —product_tag_slug_input()
Show a slug input box.
public
product_tag_slug_input() : mixed
Return values
mixed —settings()
Show the settings.
public
settings() : mixed
Return values
mixed —settings_init()
Init our settings.
public
settings_init() : mixed
Return values
mixed —settings_save()
Save the settings.
public
settings_save() : mixed
Return values
mixed —get_shop_base_slug()
Resolve the Shop page URI that serves as the Shop base, or the default slug.
private
get_shop_base_slug(int $shop_page_id) : string
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.
Parameters
- $shop_page_id : int
-
Shop page ID, as resolved by wc_get_page_id( 'shop' ).
Return values
string — Shop base slug.get_stored_product_base()
Resolve a posted product permalink choice to the value that gets persisted for it.
private
get_stored_product_base(string $posted_base[, string|null $posted_structure = null ]) : string
The render path checks a radio by comparing the stored base against this, and the save path stores what this returns, so both derive the base from one set of rules instead of restating them separately -- which is what made every predefined structure revert to "Custom base". See https://github.com/woocommerce/woocommerce/issues/29050.
Must run inside a wc_switch_to_site_locale() window: the Default base is a translated slug, and an administrator whose profile language differs from the site language would otherwise store one translation and compare against another.
Sharing the rules is not the same as receiving identical input: the save path runs the posted value through sanitize_text_field() first, which strips percent-encoded octets, so a Shop page whose slug carries a literal percent-escape can still resolve differently on the two sides.
Parameters
- $posted_base : string
-
Posted
product_permalinkradio value. - $posted_structure : string|null = null
-
Posted
product_permalink_structurevalue, or null when that field is absent or not a string.
