Skip to content

Instantly share code, notes, and snippets.

@cklosowski
Last active January 7, 2016 22:38
Show Gist options
  • Save cklosowski/0f0d605942e5372d4a41 to your computer and use it in GitHub Desktop.
Save cklosowski/0f0d605942e5372d4a41 to your computer and use it in GitHub Desktop.
Using EDD 2.5 Setting Tab Subsections
<?php
/**
* Register our settings section
*
* @return array
*/
function ck_edd_settings_section( $sections ) {
// Note the array key here of 'ck-settings'
$sections['ck-settings'] = __( 'Example EDD Extension', 'example-edd-extension' );
return $sections;
}
add_filter( 'edd_settings_sections_extensions', 'ck_edd_settings_section' );
/**
* Register our settings
*
* @return array
*/
function ck_edd_settings( $settings ) {
// Your settings reamain registered as they were in EDD Pre-2.5
$my_settings = array(
array(
'id' => 'my_header',
'name' => '<strong>' . __( 'My Example', 'edd_sl' ) . '</strong>',
'desc' => '',
'type' => 'header',
'size' => 'regular'
),
array(
'id' => 'my_example_setting',
'name' => __( 'Example checkbox', 'example-edd-extensions' ),
'desc' => __( 'Check this to turn on a setting', 'example-edd-extensions' ),
'type' => 'checkbox'
),
array(
'id' => 'my_example_text',
'name' => __( 'Example text', 'example-edd-extensions' ),
'desc' => __( 'A Text setting', 'example-edd-extensions' ),
'type' => 'text',
'std' => __( 'Example default text', 'example-edd-extensions' )
),
);
// If EDD is at version 2.5 or later...
if ( version_compare( EDD_VERSION, 2.5, '>=' ) ) {
// Use the previously noted array key as an array key again and next your settings
$my_settings = array( 'ck-settings' => $my_settings );
}
return array_merge( $settings, $my_settings );
}
add_filter( 'edd_settings_extensions', 'ck_edd_settings' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment