From 61d82a42ccd51740b377346a05b1b9cab93231e6 Mon Sep 17 00:00:00 2001
From: Kevin Langley
Date: Sat, 20 Aug 2016 23:27:20 -0400
Subject: [PATCH 1/3] adding multiple checkboxes display callback and sanitize
callback
---
README.mdown | 2 ++
display-callbacks.php | 25 +++++++++++++++++++++++++
sanitize-callbacks.php | 26 ++++++++++++++++++++++++++
3 files changed, 53 insertions(+)
diff --git a/README.mdown b/README.mdown
index f126f4f..8209adf 100644
--- a/README.mdown
+++ b/README.mdown
@@ -96,10 +96,12 @@ Using the ```get_settting()``` method of the ```Voce_Settings_API```, you can re
* ```vs_display_dropdown```
* ```vs_display_textarea```
* ```vs_display_checkbox```
+* ```vs_display_multiple_checkboxes```
### Sanitization Methods
* ```vs_sanitize_text``` *Default*
* ```vs_sanitize_checkbox```
+* ```vs_sanitize_multiple_checkboxes```
* ```vs_sanitize_url```
* ```vs_sanitize_email```
* ```vs_sanitize_dropdown```
diff --git a/display-callbacks.php b/display-callbacks.php
index b3d7d24..7ee6dda 100644
--- a/display-callbacks.php
+++ b/display-callbacks.php
@@ -46,3 +46,28 @@ function vs_display_checkbox($value, $setting, $args) {
An options argument is required in the $args array to use %s
', __FUNCTION__ );
+ return;
+ }
+
+ if( !is_array( $value ) ){
+ $value = array( $value );
+ }
+
+ foreach( $args['options'] as $option_value => $option_text ){
+ printf( '',
+ esc_attr( $setting->get_field_id() ),
+ esc_attr( $setting->get_field_name() . '[]' ),
+ esc_attr( $option_value ),
+ checked( in_array( $option_value, $value ), true, false ),
+ esc_attr( $option_text )
+ );
+ }
+
+ if(!empty($args['description'])){
+ printf( '
%s', wp_kses_post( $args['description'] ) );
+ }
+}
\ No newline at end of file
diff --git a/sanitize-callbacks.php b/sanitize-callbacks.php
index 98f7f5f..053acb3 100644
--- a/sanitize-callbacks.php
+++ b/sanitize-callbacks.php
@@ -72,6 +72,32 @@ function vs_sanitize_int( $value ) {
return intval( $value );
}
+/**
+ *
+ * @param variable $value
+ * @param Voce_Setting $setting
+ * @param array $args
+ * @return variable
+ */
+function vs_sanitize_multiple_checkboxes($values, $setting, $args) {
+ if( !is_array( $values ) || empty( $values ) ){
+ return false;
+ }
+
+ $sanitized_values = [];
+
+ foreach( $values as $value ){
+ $value = sanitize_text_field( $value );
+ if( ! in_array( $value, array_keys( $args['options'] ) ) ){
+ continue;
+ }
+
+ $sanitized_values[] = $value;
+ }
+
+ return $sanitized_values;
+}
+
/* Deprecated Functions */
function vs_santize_checkbox($value, $setting, $args) {
_deprecated_function( __FUNCTION__, '0.2', 'vs_sanitize_checkbox()' );
From 27d65a72eaac416ec636fc8446ee63aa6bb2902e Mon Sep 17 00:00:00 2001
From: Kevin Langley
Date: Sat, 20 Aug 2016 23:30:40 -0400
Subject: [PATCH 2/3] updating to 0.5.4 and removing unneeded devDependencies
from package.json
---
README.mdown | 2 +-
package.json | 5 +----
voce-settings-api.php | 4 ++--
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/README.mdown b/README.mdown
index 8209adf..425fb40 100644
--- a/README.mdown
+++ b/README.mdown
@@ -5,7 +5,7 @@ Contributors: prettyboymp, kevinlangleyjr, banderon, voceplatforms
Tags: settings, api
Requires at least: 3.3
Tested up to: 4.2.2
-Stable tag: 0.5.3
+Stable tag: 0.5.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
diff --git a/package.json b/package.json
index dd13aec..6e4094f 100644
--- a/package.json
+++ b/package.json
@@ -1,15 +1,12 @@
{
"name": "voce-settings-api",
"description": "Voce Settings API",
- "version": "0.5.3",
+ "version": "0.5.4",
"repository": {
"type": "git",
"url": "git@github.com:voceconnect/voce-settings-api.git"
},
"bugs": {
"url": "https://github.com/voceconnect/voce-settings-api/issues"
- },
- "devDependencies": {
- "grunt-voce-plugins": "latest"
}
}
\ No newline at end of file
diff --git a/voce-settings-api.php b/voce-settings-api.php
index 966c8cd..62fc757 100644
--- a/voce-settings-api.php
+++ b/voce-settings-api.php
@@ -2,7 +2,7 @@
/**
* A simplification of the settings API
* @author Michael Pretty (prettyboymp)
- * @version 0.5.3
+ * @version 0.5.4
*/
if(!class_exists('Voce_Settings_API')) {
@@ -14,7 +14,7 @@ class Voce_Settings_API {
private $settings_pages;
- CONST VERSION = '0.5.3';
+ CONST VERSION = '0.5.4';
/**
* Returns singleton instance of api
From 621ac406f4cfc62986c0cedd8cf52789bc373b6e Mon Sep 17 00:00:00 2001
From: Kevin Langley
Date: Wed, 18 Jan 2017 15:23:48 -0500
Subject: [PATCH 3/3] updating version...
---
README.mdown | 4 ++--
package.json | 2 +-
voce-settings-api.php | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.mdown b/README.mdown
index 425fb40..49ba6d2 100644
--- a/README.mdown
+++ b/README.mdown
@@ -4,8 +4,8 @@ Voce Settings API
Contributors: prettyboymp, kevinlangleyjr, banderon, voceplatforms
Tags: settings, api
Requires at least: 3.3
-Tested up to: 4.2.2
-Stable tag: 0.5.4
+Tested up to: 4.7.1
+Stable tag: 0.5.5
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
diff --git a/package.json b/package.json
index 2a0ce33..0f509b5 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "voce-settings-api",
"description": "Voce Settings API",
- "version": "0.5.4",
+ "version": "0.5.5",
"repository": {
"type": "git",
"url": "git@github.com:voceconnect/voce-settings-api.git"
diff --git a/voce-settings-api.php b/voce-settings-api.php
index 62fc757..a82be53 100644
--- a/voce-settings-api.php
+++ b/voce-settings-api.php
@@ -2,7 +2,7 @@
/**
* A simplification of the settings API
* @author Michael Pretty (prettyboymp)
- * @version 0.5.4
+ * @version 0.5.5
*/
if(!class_exists('Voce_Settings_API')) {