Changeset 774772
- Timestamp:
- 09/18/2013 04:36:46 PM (12 years ago)
- Location:
- wordbench/trunk
- Files:
-
- 1 added
- 8 edited
-
includes/class-checkbox-element.php (modified) (3 diffs)
-
includes/class-enum-element.php (added)
-
includes/class-form-element.php (modified) (3 diffs)
-
includes/class-radio-element.php (modified) (3 diffs)
-
includes/class-select-element.php (modified) (3 diffs)
-
includes/class-text-element.php (modified) (3 diffs)
-
includes/class-textarea-element.php (modified) (3 diffs)
-
includes/form-element.php (modified) (1 diff)
-
wordbench.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wordbench/trunk/includes/class-checkbox-element.php
r774694 r774772 1 1 <?php 2 2 3 class WB_Checkbox_Element extends WB_ Form_Element {3 class WB_Checkbox_Element extends WB_Enum_Element { 4 4 public function __construct( $args = array() ) { 5 5 parent::__construct( $args ); 6 6 7 $this->_params['opts'] = array( 'on', 'off' ); 7 $this->_opts = array( 'on', 'off' ); 8 $this->_default = 'off'; 8 9 } 9 10 10 public function element( $ args= array() ) {11 public function element( $instance = array() ) { 11 12 $defaults = array( 12 13 'prefix' => '', … … 14 15 ); 15 16 16 extract( wp_parse_args( $args, $defaults ), EXTR_SKIP ); 17 extract( $this->_params, EXTR_SKIP ); 17 extract( wp_parse_args( $instance, $defaults ), EXTR_SKIP ); 18 18 19 19 $id = $this->_get_id( $prefix ); … … 27 27 echo $this->_html_input( 'checkbox', $name, 'on', $attr ); 28 28 29 echo $this->_html_label( $title, $id ); 30 } 31 32 public function validate( $value ) { 33 if ( ! in_array( $value, $this->_params['opts'] ) ) 34 $value = 'off'; 35 36 return $value; 29 echo $this->_html_label( $this->_title, $id ); 37 30 } 38 31 } -
wordbench/trunk/includes/class-form-element.php
r774694 r774772 6 6 */ 7 7 class WB_Form_Element { 8 protected $_params; 8 protected $_title; 9 protected $_name; 9 10 10 11 /** … … 18 19 $defaults = array( 19 20 'title' => null, 20 'name' => null, 21 'opts' => array() 21 'name' => null 22 22 ); 23 23 24 $this->_params = wp_parse_args( $args, $defaults ); 24 $args = wp_parse_args( $args, $defaults ); 25 26 $this->_title = $args['title']; 27 $this->_name = $args['name']; 25 28 } 26 29 … … 39 42 * Renders the form element. Child classes MUST extend this method. 40 43 * 41 * @param array $ argsInstance data for this specific field.44 * @param array $instance Instance data for this specific field. 42 45 */ 43 public function element( $ args= array() ) {46 public function element( $instance = array() ) { 44 47 die( __CLASS__ . ' must override WB_Form_Element::element()' ); 45 48 } -
wordbench/trunk/includes/class-radio-element.php
r774694 r774772 1 1 <?php 2 2 3 class WB_Radio_Element extends WB_ Form_Element {4 public function element( $ args= array() ) {3 class WB_Radio_Element extends WB_Enum_Element { 4 public function element( $instance = array() ) { 5 5 $defaults = array( 6 6 'prefix' => '', … … 8 8 ); 9 9 10 extract( wp_parse_args( $args, $defaults ), EXTR_SKIP ); 11 extract( $this->_params, EXTR_SKIP ); 10 extract( wp_parse_args( $instance, $defaults ), EXTR_SKIP ); 12 11 13 12 $html = ''; 14 13 15 foreach ( $ opts as $opt ) {14 foreach ( $this->_opts as $opt ) { 16 15 $key = wordbench_sanitize( $opt ); 17 16 … … 34 33 ) ); 35 34 } 36 37 public function validate( $value ) {38 if ( ! in_array( $value, $this->_params['opts'] ) )39 $value = '';40 41 return $value;42 }43 35 } 44 36 -
wordbench/trunk/includes/class-select-element.php
r774694 r774772 1 1 <?php 2 2 3 class WB_Select_Element extends WB_ Form_Element {4 public function element( $ args= array() ) {3 class WB_Select_Element extends WB_Enum_Element { 4 public function element( $instance = array() ) { 5 5 $defaults = array( 6 6 'show_label' => true, … … 9 9 ); 10 10 11 extract( wp_parse_args( $args, $defaults ), EXTR_SKIP ); 12 extract( $this->_params, EXTR_SKIP ); 11 extract( wp_parse_args( $instance, $defaults ), EXTR_SKIP ); 13 12 14 13 $id = $this->_get_id( $prefix ); … … 18 17 19 18 if ( $show_label ) 20 echo $this->_html_label( $t itle, $id );19 echo $this->_html_label( $this->_title, $id ); 21 20 22 echo $this->_html_select( $name, $value, $opts, $attr ); 23 } 24 25 public function validate( $value ) { 26 if ( ! in_array( $value, $this->_params['opts'] ) ) 27 $value = null; 28 29 return $value; 21 echo $this->_html_select( $name, $value, $this->_opts, $attr ); 30 22 } 31 23 -
wordbench/trunk/includes/class-text-element.php
r774694 r774772 2 2 3 3 class WB_Text_Element extends WB_Form_Element { 4 public function element( $ args= array() ) {4 public function element( $instance = array() ) { 5 5 $defaults = array( 6 6 'show_label' => true, … … 9 9 ); 10 10 11 extract( wp_parse_args( $args, $defaults ), EXTR_SKIP ); 12 extract( $this->_params, EXTR_SKIP ); 11 extract( wp_parse_args( $instance, $defaults ), EXTR_SKIP ); 13 12 14 13 $id = $this->_get_id( $prefix ); … … 16 15 17 16 if ( $show_label ) 18 echo $this->_html_label( $t itle, $id );17 echo $this->_html_label( $this->_title, $id ); 19 18 20 19 echo $this->_html_input( 'text', $name, $value, array( -
wordbench/trunk/includes/class-textarea-element.php
r774694 r774772 2 2 3 3 class WB_Textarea_Element extends WB_Form_Element { 4 public function element( $ args= array() ) {4 public function element( $instance = array() ) { 5 5 $defaults = array( 6 6 'show_label' => true, … … 9 9 ); 10 10 11 extract( wp_parse_args( $args, $defaults ), EXTR_SKIP ); 12 extract( $this->_params, EXTR_SKIP ); 11 extract( wp_parse_args( $instance, $defaults ), EXTR_SKIP ); 13 12 14 13 $id = $this->_get_id( $prefix ); … … 16 15 17 16 if ( $show_label ) 18 echo $this->_html_label( $t itle, $id );17 echo $this->_html_label( $this->_title, $id ); 19 18 20 19 echo $this->_html_textarea( $name, $value, array( -
wordbench/trunk/includes/form-element.php
r774694 r774772 17 17 18 18 require_once WORDBENCH_INC . 'class-form-element.php'; 19 require_once WORDBENCH_INC . 'class-enum-element.php'; 19 20 20 21 $file = WORDBENCH_INC . 'class-' . $type . '-element.php'; -
wordbench/trunk/wordbench.php
r685366 r774772 23 23 Author: J Andrew Scott 24 24 Author URI: http://rubberchickenfarm.com/ 25 Description: WordBench provides admin user interfaces for managing post types, post formats, taxonomies, and roles/capabilities. 25 Description: WordBench provides admin user interfaces for managing post types, 26 post formats, taxonomies, and roles/capabilities. 26 27 Version: 0.9 27 28 License: GPLv2 or later … … 39 40 require_once WORDBENCH_INC . 'taxonomy.php'; 40 41 require_once WORDBENCH_INC . 'capabilities.php'; 41 require_once WORDBENCH_INC . 'form-element s.php';42 require_once WORDBENCH_INC . 'form-element.php'; 42 43 43 44 require_once WORDBENCH_INC . 'class-post-type.php';
Note: See TracChangeset
for help on using the changeset viewer.