Last active
July 5, 2023 22:16
-
-
Save woogists/4038b83900508806c57a193a2534b845 to your computer and use it in GitHub Desktop.
[Extending][Adding a Section to a Settings Tab] How to add settings to a section
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add settings to the specific section we created before | |
*/ | |
add_filter( 'woocommerce_get_settings_products', 'wcslider_all_settings', 10, 2 ); | |
function wcslider_all_settings( $settings, $current_section ) { | |
/** | |
* Check the current section is what we want | |
**/ | |
if ( $current_section == 'wcslider' ) { | |
$settings_slider = array(); | |
// Add Title to the Settings | |
$settings_slider[] = array( 'name' => __( 'WC Slider Settings', 'text-domain' ), 'type' => 'title', 'desc' => __( 'The following options are used to configure WC Slider', 'text-domain' ), 'id' => 'wcslider' ); | |
// Add first checkbox option | |
$settings_slider[] = array( | |
'name' => __( 'Auto-insert into single product page', 'text-domain' ), | |
'desc_tip' => __( 'This will automatically insert your slider into the single product page', 'text-domain' ), | |
'id' => 'wcslider_auto_insert', | |
'type' => 'checkbox', | |
'css' => 'min-width:300px;', | |
'desc' => __( 'Enable Auto-Insert', 'text-domain' ), | |
); | |
// Add second text field option | |
$settings_slider[] = array( | |
'name' => __( 'Slider Title', 'text-domain' ), | |
'desc_tip' => __( 'This will add a title to your slider', 'text-domain' ), | |
'id' => 'wcslider_title', | |
'type' => 'text', | |
'desc' => __( 'Any title you want can be added to your slider with this option!', 'text-domain' ), | |
); | |
$settings_slider[] = array( 'type' => 'sectionend', 'id' => 'wcslider' ); | |
return $settings_slider; | |
/** | |
* If not, return the standard settings | |
**/ | |
} else { | |
return $settings; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment