Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Added support for "Number" field type. Bumped version to 2.1.2. #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/AdminPage.Menu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPage.Submenu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPage.Themes.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @package Simple Admin Pages
*/

class sapAdminPage_2_1_1 {
class sapAdminPage_2_1_2 {

public $title;
public $menu_title;
Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.Address.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.Editor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.HTML.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.Image.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
44 changes: 44 additions & 0 deletions classes/AdminPageSetting.Number.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* Register, display and save a number field setting in the admin menu
*
* By default, it allows positive and negative numbers. To only allow positive numbers,
* add "sanitize_callback" => "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() {
?>

<input name="<?php echo $this->get_input_name(); ?>" type="number" id="<?php echo $this->get_input_name(); ?>" value="<?php echo $this->value; ?>" class="regular-number" />

<?php

$this->display_description();

}

}
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.OpeningHours.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.Scheduler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.Select.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.SelectPost.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.SelectTaxonomy.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.Text.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.Textarea.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @todo textareas should have an option to swap new lines for <br>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
Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.Toggle.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion classes/AdminPageSetting.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions classes/Library.class.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
if ( !class_exists( 'sapLibrary_2_1_1' ) ) {
if ( !class_exists( 'sapLibrary_2_1_2' ) ) {
/**
* This library class loads and provides access to the correct version of the
* Simple Admin Pages library.
*
* @since 1.0
* @package Simple Admin Pages
*/
class sapLibrary_2_1_1 {
class sapLibrary_2_1_2 {

// Version of the library
private $version = '2.1.1';
private $version = '2.1.2';

// A full URL to the library which is used to correctly link scripts and
// stylesheets.
Expand Down Expand Up @@ -169,6 +169,10 @@ private function get_setting_classname( $type ) {
require_once('AdminPageSetting.Address.class.php');
return $this->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
Expand Down