Plugin Directory

Changeset 774772


Ignore:
Timestamp:
09/18/2013 04:36:46 PM (12 years ago)
Author:
jascott
Message:

Still updating inline docs

Location:
wordbench/trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • wordbench/trunk/includes/class-checkbox-element.php

    r774694 r774772  
    11<?php
    22
    3 class WB_Checkbox_Element extends WB_Form_Element {
     3class WB_Checkbox_Element extends WB_Enum_Element {
    44    public function __construct( $args = array() ) {
    55        parent::__construct( $args );
    66       
    7         $this->_params['opts'] = array( 'on', 'off' );
     7        $this->_opts    = array( 'on', 'off' );
     8        $this->_default = 'off';
    89    }
    910   
    10     public function element( $args = array() ) {
     11    public function element( $instance = array() ) {
    1112        $defaults = array(
    1213            'prefix' => '',
     
    1415        );
    1516       
    16         extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
    17         extract( $this->_params, EXTR_SKIP );
     17        extract( wp_parse_args( $instance, $defaults ), EXTR_SKIP );
    1818       
    1919        $id   = $this->_get_id( $prefix );
     
    2727        echo $this->_html_input( 'checkbox', $name, 'on', $attr );
    2828       
    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 );
    3730    }
    3831}
  • wordbench/trunk/includes/class-form-element.php

    r774694 r774772  
    66 */
    77class WB_Form_Element {
    8     protected $_params;
     8    protected $_title;
     9    protected $_name;
    910   
    1011    /**
     
    1819        $defaults = array(
    1920            'title' => null,
    20             'name'  => null,
    21             'opts'  => array()
     21            'name'  => null
    2222        );
    2323       
    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'];
    2528    }
    2629   
     
    3942     * Renders the form element. Child classes MUST extend this method.
    4043     *
    41      * @param array $args Instance data for this specific field.
     44     * @param array $instance Instance data for this specific field.
    4245     */
    43     public function element( $args = array() ) {
     46    public function element( $instance = array() ) {
    4447        die( __CLASS__ . ' must override WB_Form_Element::element()' );
    4548    }
  • wordbench/trunk/includes/class-radio-element.php

    r774694 r774772  
    11<?php
    22
    3 class WB_Radio_Element extends WB_Form_Element {
    4     public function element( $args = array() ) {
     3class WB_Radio_Element extends WB_Enum_Element {
     4    public function element( $instance = array() ) {
    55        $defaults = array(
    66            'prefix' => '',
     
    88        );
    99       
    10         extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
    11         extract( $this->_params, EXTR_SKIP );
     10        extract( wp_parse_args( $instance, $defaults ), EXTR_SKIP );
    1211       
    1312        $html = '';
    1413       
    15         foreach ( $opts as $opt ) {
     14        foreach ( $this->_opts as $opt ) {
    1615            $key = wordbench_sanitize( $opt );
    1716           
     
    3433        ) );
    3534    }
    36    
    37     public function validate( $value ) {
    38         if ( ! in_array( $value, $this->_params['opts'] ) )
    39             $value = '';
    40        
    41         return $value;
    42     }
    4335}
    4436
  • wordbench/trunk/includes/class-select-element.php

    r774694 r774772  
    11<?php
    22
    3 class WB_Select_Element extends WB_Form_Element {
    4     public function element( $args = array() ) {
     3class WB_Select_Element extends WB_Enum_Element {
     4    public function element( $instance = array() ) {
    55        $defaults = array(
    66            'show_label' => true,
     
    99        );
    1010       
    11         extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
    12         extract( $this->_params, EXTR_SKIP );
     11        extract( wp_parse_args( $instance, $defaults ), EXTR_SKIP );
    1312       
    1413        $id   = $this->_get_id( $prefix );
     
    1817       
    1918        if ( $show_label )
    20             echo $this->_html_label( $title, $id );
     19            echo $this->_html_label( $this->_title, $id );
    2120       
    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 );
    3022    }
    3123   
  • wordbench/trunk/includes/class-text-element.php

    r774694 r774772  
    22
    33class WB_Text_Element extends WB_Form_Element {
    4     public function element( $args = array() ) {
     4    public function element( $instance = array() ) {
    55        $defaults = array(
    66            'show_label' => true,
     
    99        );
    1010       
    11         extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
    12         extract( $this->_params, EXTR_SKIP );
     11        extract( wp_parse_args( $instance, $defaults ), EXTR_SKIP );
    1312       
    1413        $id   = $this->_get_id( $prefix );
     
    1615       
    1716        if ( $show_label )
    18             echo $this->_html_label( $title, $id );
     17            echo $this->_html_label( $this->_title, $id );
    1918       
    2019        echo $this->_html_input( 'text', $name, $value, array(
  • wordbench/trunk/includes/class-textarea-element.php

    r774694 r774772  
    22
    33class WB_Textarea_Element extends WB_Form_Element {
    4     public function element( $args = array() ) {
     4    public function element( $instance = array() ) {
    55        $defaults = array(
    66            'show_label' => true,
     
    99        );
    1010       
    11         extract( wp_parse_args( $args, $defaults ), EXTR_SKIP );
    12         extract( $this->_params, EXTR_SKIP );
     11        extract( wp_parse_args( $instance, $defaults ), EXTR_SKIP );
    1312       
    1413        $id   = $this->_get_id( $prefix );
     
    1615       
    1716        if ( $show_label )
    18             echo $this->_html_label( $title, $id );
     17            echo $this->_html_label( $this->_title, $id );
    1918       
    2019        echo $this->_html_textarea( $name, $value, array(
  • wordbench/trunk/includes/form-element.php

    r774694 r774772  
    1717   
    1818    require_once WORDBENCH_INC . 'class-form-element.php';
     19    require_once WORDBENCH_INC . 'class-enum-element.php';
    1920   
    2021    $file  = WORDBENCH_INC . 'class-' . $type . '-element.php';
  • wordbench/trunk/wordbench.php

    r685366 r774772  
    2323Author: J Andrew Scott
    2424Author URI: http://rubberchickenfarm.com/
    25 Description: WordBench provides admin user interfaces for managing post types, post formats, taxonomies, and roles/capabilities.
     25Description: WordBench provides admin user interfaces for managing post types,
     26    post formats, taxonomies, and roles/capabilities.
    2627Version: 0.9
    2728License: GPLv2 or later
     
    3940require_once WORDBENCH_INC . 'taxonomy.php';
    4041require_once WORDBENCH_INC . 'capabilities.php';
    41 require_once WORDBENCH_INC . 'form-elements.php';
     42require_once WORDBENCH_INC . 'form-element.php';
    4243
    4344require_once WORDBENCH_INC . 'class-post-type.php';
Note: See TracChangeset for help on using the changeset viewer.