From d889866e601b7b74bf35d965b5d916cb8087323d Mon Sep 17 00:00:00 2001 From: Kevin Provance Date: Wed, 28 Jul 2021 17:39:54 -0400 Subject: [PATCH] Add term data and callback to select in sample config. Add 'global_variable' entry. Signed-off-by: Kevin Provance --- sample/sample-config.php | 2 +- sample/sections/select-fields/select.php | 42 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/sample/sample-config.php b/sample/sample-config.php index 78fe68087..c3bea5f68 100644 --- a/sample/sample-config.php +++ b/sample/sample-config.php @@ -105,7 +105,7 @@ 'admin_bar_priority' => 50, // Sets a different name for your global variable other than the opt_name. - 'global_variable' => '', + 'global_variable' => $opt_name, // Show the time the page took to load, etc. (forced on while on localhost or when WP_DEBUG is enabled). 'dev_mode' => true, diff --git a/sample/sections/select-fields/select.php b/sample/sections/select-fields/select.php index a46ef11c5..26b567667 100644 --- a/sample/sections/select-fields/select.php +++ b/sample/sections/select-fields/select.php @@ -139,6 +139,23 @@ 'subtitle' => esc_html__( 'No validation can be done on this field type', 'your-textdomain-here' ), 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), ), + array( + 'id' => 'opt-select-terms', + 'type' => 'select', + 'data' => 'terms', + 'title' => esc_html__( 'Terms Select Option', 'your-textdomain-here' ), + 'subtitle' => esc_html__( 'No validation can be done on this field type', 'your-textdomain-here' ), + 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), + ), + array( + 'id' => 'opt-multi-select-terms', + 'type' => 'select', + 'data' => 'terms', + 'multi' => true, + 'title' => esc_html__( 'Terms Multi Select Option', 'your-textdomain-here' ), + 'subtitle' => esc_html__( 'No validation can be done on this field type', 'your-textdomain-here' ), + 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), + ), array( 'id' => 'opt-select-menus', 'type' => 'select', @@ -237,6 +254,31 @@ 'subtitle' => esc_html__( 'No validation can be done on this field type', 'your-textdomain-here' ), 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), ), + array( + 'id' => 'opt-select-callback', + 'type' => 'select', + 'data' => 'callback', + 'args' => 'redux_select_callback', + 'title' => esc_html__( 'Select Option using a Callback', 'your-textdomain-here' ), + 'subtitle' => esc_html__( 'No validation can be done on this field type', 'your-textdomain-here' ), + 'desc' => esc_html__( 'The items in this selcect were added via a callback function.', 'your-textdomain-here' ), + ), ), ) ); + +/** + * Select callback function. + * + * @return array + */ +function redux_select_callback(): array { + $options = array(); + + $options[0] = esc_html__( 'Zero', 'your-textdomain-here' ); + $options[1] = esc_html__( 'One', 'your-textdomain-here' ); + $options[2] = esc_html__( 'Two', 'your-textdomain-here' ); + $options[3] = esc_html__( 'Three', 'your-textdomain-here' ); + + return $options; +}