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 ); } /** * Show a slug input box. */ public function product_category_slug_input() { $permalinks = get_option( 'woocommerce_permalinks' ); ?> /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%' ) ); ?> 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();