settings_init();
$this->settings_save();
}
/**
* Init our settings.
*/
public function settings_init() {
// Add a section to the permalinks page
add_settings_section( 'woocommerce-permalink', __( 'Product permalinks', 'woocommerce' ), array( $this, 'settings' ), 'permalink' );
// Add our settings
add_settings_field(
'woocommerce_product_category_slug', // id
__( 'Product category base', 'woocommerce' ), // setting title
array( $this, 'product_category_slug_input' ), // display callback
'permalink', // settings page
'optional' // settings section
);
add_settings_field(
'woocommerce_product_tag_slug', // id
__( 'Product tag base', 'woocommerce' ), // setting title
array( $this, 'product_tag_slug_input' ), // display callback
'permalink', // settings page
'optional' // settings section
);
add_settings_field(
'woocommerce_product_attribute_slug', // id
__( 'Product attribute base', 'woocommerce' ), // setting title
array( $this, 'product_attribute_slug_input' ), // display callback
'permalink', // settings page
'optional' // settings section
);
$this->permalinks = wc_get_permalink_structure();
}
/**
* Show a slug input box.
*/
public function product_category_slug_input() {
?>
/attribute-name/attribute/
0 && get_post( $shop_page_id ) ) ? get_page_uri( $shop_page_id ) : _x( 'shop', 'default-slug', 'woocommerce' ) );
$product_base = _x( 'product', 'default-slug', 'woocommerce' );
$structures = array(
0 => '',
1 => '/' . trailingslashit( $base_slug ),
2 => '/' . trailingslashit( $base_slug ) . trailingslashit( '%product_cat%' ),
);
?>
/?product=sample-product //sample-product/ |
|
//sample-product/ |
|
//product-category/sample-product/ |
|
must be set or WordPress will use default instead.', 'woocommerce' ); ?> |