From 459527c974ceca2e7c9127132a4df29636557907 Mon Sep 17 00:00:00 2001 From: Sean Butze Date: Mon, 21 Oct 2013 17:28:30 -0400 Subject: [PATCH] Add support for 'exclude' parameter --- wpas-field.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wpas-field.php b/wpas-field.php index 185b99c..b22f494 100644 --- a/wpas-field.php +++ b/wpas-field.php @@ -12,6 +12,7 @@ private $values; private $selected = ''; private $selected_r = array(); + private $exclude = array(); function __construct($id, $args = array()) { $defaults = array( 'label' => '', @@ -64,6 +65,15 @@ function __construct($id, $args = array()) { $this->selected_r = explode(',',$this->selected); } + // Set excluded values + if (isset($exclude)) { + if (is_array($exclude)) { + $this->exclude = $exclude; + } else { + $this->exclude[] = $exclude; + } + } + } function build_field() { @@ -123,6 +133,7 @@ function select($multi = false) { $output .= '"'.$multiple.'>'; foreach ($this->values as $value => $label) { + if (in_array($value,$this->exclude)) continue; $value = esc_attr($value); $label = esc_attr($label); $output .= '