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 permalink base', '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 ); } /** * Show a slug input box. */ public function product_category_slug_input() { $permalinks = get_option( 'woocommerce_permalinks' ); ?> /attribute-name/attribute/ not using "default" permalinks above.', 'woocommerce' ) ); $permalinks = get_option( 'woocommerce_permalinks' ); $product_permalink = $permalinks['product_base']; // Get shop page $shop_page_id = wc_get_page_id( 'shop' ); $base_slug = urldecode( ( $shop_page_id > 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( $product_base ), 2 => '/' . trailingslashit( $base_slug ), 3 => '/' . 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' ); ?>
0 && get_post( $shop_page_id ) ) ? get_page_uri( $shop_page_id ) : _x( 'shop', 'default-slug', 'woocommerce' ); if ( $shop_page_id && trim( $permalinks['product_base'], '/' ) === $shop_permalink ) { $permalinks['use_verbose_page_rules'] = true; } update_option( 'woocommerce_permalinks', $permalinks ); } } } endif; return new WC_Admin_Permalink_Settings();