From 70bc40badabca61d19e387a73882d5994c803310 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Fri, 18 Jan 2019 15:27:09 -0200 Subject: [PATCH] Added support for "Number" field type. Bumped version to 2.1.2. --- classes/AdminPage.Menu.class.php | 2 +- classes/AdminPage.Submenu.class.php | 2 +- classes/AdminPage.Themes.class.php | 2 +- classes/AdminPage.class.php | 2 +- classes/AdminPageSection.class.php | 2 +- classes/AdminPageSetting.Address.class.php | 2 +- classes/AdminPageSetting.Editor.class.php | 2 +- classes/AdminPageSetting.HTML.class.php | 2 +- classes/AdminPageSetting.Image.class.php | 2 +- classes/AdminPageSetting.Number.class.php | 44 +++++++++++++++++++ .../AdminPageSetting.OpeningHours.class.php | 2 +- classes/AdminPageSetting.Scheduler.class.php | 2 +- classes/AdminPageSetting.Select.class.php | 2 +- classes/AdminPageSetting.SelectPost.class.php | 2 +- .../AdminPageSetting.SelectTaxonomy.class.php | 2 +- classes/AdminPageSetting.Text.class.php | 2 +- classes/AdminPageSetting.Textarea.class.php | 2 +- classes/AdminPageSetting.Toggle.class.php | 2 +- classes/AdminPageSetting.class.php | 2 +- classes/Library.class.php | 10 +++-- 20 files changed, 69 insertions(+), 21 deletions(-) create mode 100644 classes/AdminPageSetting.Number.class.php diff --git a/classes/AdminPage.Menu.class.php b/classes/AdminPage.Menu.class.php index ab0b6d9..df04e11 100644 --- a/classes/AdminPage.Menu.class.php +++ b/classes/AdminPage.Menu.class.php @@ -8,7 +8,7 @@ * @package Simple Admin Pages */ -class sapAdminPageMenu_2_1_1 extends sapAdminPage_2_1_1 { +class sapAdminPageMenu_2_1_2 extends sapAdminPage_2_1_2 { public $setup_function = 'add_menu_page'; // WP function to register the page diff --git a/classes/AdminPage.Submenu.class.php b/classes/AdminPage.Submenu.class.php index d9f3fac..b74e1ae 100644 --- a/classes/AdminPage.Submenu.class.php +++ b/classes/AdminPage.Submenu.class.php @@ -8,7 +8,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSubmenu_2_1_1 extends sapAdminPage_2_1_1 { +class sapAdminPageSubmenu_2_1_2 extends sapAdminPage_2_1_2 { public $setup_function = 'add_submenu_page'; // WP function to register the page diff --git a/classes/AdminPage.Themes.class.php b/classes/AdminPage.Themes.class.php index 8f7c7a6..9ecf313 100644 --- a/classes/AdminPage.Themes.class.php +++ b/classes/AdminPage.Themes.class.php @@ -8,7 +8,7 @@ * @package Simple Admin Pages */ -class sapAdminPageThemes_2_1_1 extends sapAdminPage_2_1_1 { +class sapAdminPageThemes_2_1_2 extends sapAdminPage_2_1_2 { public $setup_function = 'add_theme_page'; // WP function to register the page diff --git a/classes/AdminPage.class.php b/classes/AdminPage.class.php index 52ef3ae..e55aaab 100644 --- a/classes/AdminPage.class.php +++ b/classes/AdminPage.class.php @@ -7,7 +7,7 @@ * @package Simple Admin Pages */ -class sapAdminPage_2_1_1 { +class sapAdminPage_2_1_2 { public $title; public $menu_title; diff --git a/classes/AdminPageSection.class.php b/classes/AdminPageSection.class.php index 76446d6..575f345 100644 --- a/classes/AdminPageSection.class.php +++ b/classes/AdminPageSection.class.php @@ -7,7 +7,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSection_2_1_1 { +class sapAdminPageSection_2_1_2 { // Page defaults public $id; // unique id for this section diff --git a/classes/AdminPageSetting.Address.class.php b/classes/AdminPageSetting.Address.class.php index 79c8d0d..37aac47 100644 --- a/classes/AdminPageSetting.Address.class.php +++ b/classes/AdminPageSetting.Address.class.php @@ -7,7 +7,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingAddress_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingAddress_2_1_2 extends sapAdminPageSetting_2_1_2 { /* * Size of this textarea diff --git a/classes/AdminPageSetting.Editor.class.php b/classes/AdminPageSetting.Editor.class.php index 11b3620..f3e284f 100644 --- a/classes/AdminPageSetting.Editor.class.php +++ b/classes/AdminPageSetting.Editor.class.php @@ -7,7 +7,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingEditor_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingEditor_2_1_2 extends sapAdminPageSetting_2_1_2 { public $sanitize_callback = 'wp_kses_post'; diff --git a/classes/AdminPageSetting.HTML.class.php b/classes/AdminPageSetting.HTML.class.php index 0fa34b1..b2fbe58 100644 --- a/classes/AdminPageSetting.HTML.class.php +++ b/classes/AdminPageSetting.HTML.class.php @@ -14,7 +14,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingHTML_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingHTML_2_1_2 extends sapAdminPageSetting_2_1_2 { public $sanitize_callback = 'sanitize_text_field'; diff --git a/classes/AdminPageSetting.Image.class.php b/classes/AdminPageSetting.Image.class.php index d38ac02..7d096e2 100644 --- a/classes/AdminPageSetting.Image.class.php +++ b/classes/AdminPageSetting.Image.class.php @@ -7,7 +7,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingImage_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingImage_2_1_2 extends sapAdminPageSetting_2_1_2 { public $sanitize_callback = 'absint'; diff --git a/classes/AdminPageSetting.Number.class.php b/classes/AdminPageSetting.Number.class.php new file mode 100644 index 0000000..8e659ac --- /dev/null +++ b/classes/AdminPageSetting.Number.class.php @@ -0,0 +1,44 @@ + "absint" to your add_setting() $args array. + * + * Example: + * $sap->add_setting( + * 'page-id', + * 'section-id', + * 'number', + * [ + * 'id' => 'field-id', + * 'title' => __( 'Some number:', '' ), + * 'sanitize_callback' => 'absint', // Add this if you want to allow only positive numbers. + * ] + *); + * + * @since 2.1.2 + * @package Simple Admin Pages + */ + +class sapAdminPageSettingNumber_2_1_2 extends sapAdminPageSetting_2_1_2 { + + public $sanitize_callback = 'intval'; + + /** + * Display this setting + * @since 1.0 + */ + public function display_setting() { + ?> + + + + display_description(); + + } + +} diff --git a/classes/AdminPageSetting.OpeningHours.class.php b/classes/AdminPageSetting.OpeningHours.class.php index bef40e6..ea66247 100644 --- a/classes/AdminPageSetting.OpeningHours.class.php +++ b/classes/AdminPageSetting.OpeningHours.class.php @@ -25,7 +25,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingOpeningHours_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingOpeningHours_2_1_2 extends sapAdminPageSetting_2_1_2 { public $sanitize_callback = 'sanitize_text_field'; diff --git a/classes/AdminPageSetting.Scheduler.class.php b/classes/AdminPageSetting.Scheduler.class.php index 645ff13..77bdb0b 100644 --- a/classes/AdminPageSetting.Scheduler.class.php +++ b/classes/AdminPageSetting.Scheduler.class.php @@ -10,7 +10,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingScheduler_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingScheduler_2_1_2 extends sapAdminPageSetting_2_1_2 { public $sanitize_callback = 'sanitize_text_field'; diff --git a/classes/AdminPageSetting.Select.class.php b/classes/AdminPageSetting.Select.class.php index 3d77c7e..36bd5c0 100644 --- a/classes/AdminPageSetting.Select.class.php +++ b/classes/AdminPageSetting.Select.class.php @@ -21,7 +21,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingSelect_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingSelect_2_1_2 extends sapAdminPageSetting_2_1_2 { public $sanitize_callback = 'sanitize_text_field'; diff --git a/classes/AdminPageSetting.SelectPost.class.php b/classes/AdminPageSetting.SelectPost.class.php index 785ae8e..0555b41 100644 --- a/classes/AdminPageSetting.SelectPost.class.php +++ b/classes/AdminPageSetting.SelectPost.class.php @@ -17,7 +17,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingSelectPost_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingSelectPost_2_1_2 extends sapAdminPageSetting_2_1_2 { public $sanitize_callback = 'intval'; diff --git a/classes/AdminPageSetting.SelectTaxonomy.class.php b/classes/AdminPageSetting.SelectTaxonomy.class.php index 81837d6..6723f07 100644 --- a/classes/AdminPageSetting.SelectTaxonomy.class.php +++ b/classes/AdminPageSetting.SelectTaxonomy.class.php @@ -19,7 +19,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingSelectTaxonomy_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingSelectTaxonomy_2_1_2 extends sapAdminPageSetting_2_1_2 { public $sanitize_callback = 'intval'; diff --git a/classes/AdminPageSetting.Text.class.php b/classes/AdminPageSetting.Text.class.php index 5acfc81..ad88536 100644 --- a/classes/AdminPageSetting.Text.class.php +++ b/classes/AdminPageSetting.Text.class.php @@ -7,7 +7,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingText_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingText_2_1_2 extends sapAdminPageSetting_2_1_2 { public $sanitize_callback = 'sanitize_text_field'; diff --git a/classes/AdminPageSetting.Textarea.class.php b/classes/AdminPageSetting.Textarea.class.php index d14a8af..9499f65 100644 --- a/classes/AdminPageSetting.Textarea.class.php +++ b/classes/AdminPageSetting.Textarea.class.php @@ -9,7 +9,7 @@ * @todo textareas should have an option to swap new lines for
s */ -class sapAdminPageSettingTextarea_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingTextarea_2_1_2 extends sapAdminPageSetting_2_1_2 { /* * Size of this textarea diff --git a/classes/AdminPageSetting.Toggle.class.php b/classes/AdminPageSetting.Toggle.class.php index ec8dc18..098c39b 100644 --- a/classes/AdminPageSetting.Toggle.class.php +++ b/classes/AdminPageSetting.Toggle.class.php @@ -17,7 +17,7 @@ * @package Simple Admin Pages */ -class sapAdminPageSettingToggle_2_1_1 extends sapAdminPageSetting_2_1_1 { +class sapAdminPageSettingToggle_2_1_2 extends sapAdminPageSetting_2_1_2 { public $sanitize_callback = 'sanitize_text_field'; diff --git a/classes/AdminPageSetting.class.php b/classes/AdminPageSetting.class.php index 40bab96..bc132b8 100644 --- a/classes/AdminPageSetting.class.php +++ b/classes/AdminPageSetting.class.php @@ -16,7 +16,7 @@ * @package Simple Admin Pages */ -abstract class sapAdminPageSetting_2_1_1 { +abstract class sapAdminPageSetting_2_1_2 { // Page defaults public $id; // used in form fields and database to track and store setting diff --git a/classes/Library.class.php b/classes/Library.class.php index b1ef5dd..f66ed53 100644 --- a/classes/Library.class.php +++ b/classes/Library.class.php @@ -1,5 +1,5 @@ get_versioned_classname( 'sapAdminPageSettingAddress' ); + case 'number' : + require_once('AdminPageSetting.Number.class.php'); + return $this->get_versioned_classname( 'sapAdminPageSettingNumber' ); + default : // Exit early if a custom type is declared without providing the