diff --git a/wph-widget-class.php b/wph-widget-class.php index eb51874..a84fe75 100644 --- a/wph-widget-class.php +++ b/wph-widget-class.php @@ -1,9 +1,7 @@ '', 'description' => '', + 'width' => array(), + 'height' => array(), 'fields' => array(), - 'options' => array(), + 'options' => array(), ); - // parse and merge args with defaults - $args = wp_parse_args( $args, $defaults ); + // parse and merge args with defaults $args = wp_parse_args( $args, $defaults ); // extract each arg to its own variable - extract( $args, EXTR_SKIP ); + extract( $args, EXTR_SKIP ); // set the widget vars $this->slug = sanitize_title( $label ); $this->fields = $fields; // check options - $this->options = array( 'classname' => $this->slug, 'description' => $description ); + $this->options = array( 'classname' => $this->slug, 'description' => $description ); + if ( ! empty( $options ) ) $this->options = array_merge( $this->options, $options ); // call WP_Widget to create the widget parent::__construct( $this->slug, $label, $this->options ); - + } @@ -88,7 +89,7 @@ function form( $instance ) { * @since 1.0 */ - function update( $new_instance, $old_instance ) { + function update( $new_instance, $old_instance ){ $instance = $old_instance; $this->before_update_fields(); @@ -392,13 +393,98 @@ function create_field( $key, $out = "" ) { /* Prefix method */ $field_method = 'create_field_' . str_replace( '-', '_', $key['type'] ); + /* Check for
Class - rie added*/ + //hide the hidden field + if ( $field_method != 'create_field_hidden'): + $divstart = ( isset( $key['class-div'] ) ) ? '
' : '
'; + else : + $divstart = '
'; + endif; + /* Check for

Class */ $p = ( isset( $key['class-p'] ) ) ? '

' : '

'; + if ( $field_method != 'create_field_group_start') { + $divend = '

'; + } + else + { + $divend = ''; + } + + /* Run method */ - if ( method_exists( $this, $field_method ) ) - return $p.$this->$field_method( $key ).'

'; + /* + * Riesurya Note : make sure that grouping doesnt break the layout - 19082013-15:15PM - running out coffee make me little ugly + */ + if ( method_exists( $this, $field_method ) ) + { + if ( $field_method != 'create_field_group_end' ) + { + return $divstart . $this->$field_method( $key ) . $divend ; + } + else + { + return $this->$field_method( $key ); + } + } + } + + + /** + * Field Info start ( grouping ) + * + * @access private + * @param array + * @param string + * @return string + * @since 1.6 + */ + + function create_field_group_start( $key, $out = "" ) { + + $out .= '
'; + + $out .= $this->create_field_label( $key['name'], $key['_id'] ); + + if ( isset( $key['desc'] ) ) + $out .= '

' . esc_html( $key['desc'] ) . '

'; + + $out .= '
'; + + return $out; + } + + /** + * Field Info end ( grouping ) + * + * @access private + * @param array + * @param string + * @return string + * @since 1.6 + */ + + function create_field_group_end( $key, $out = "" ) { + $out .= '
'; + return $out; + } + + + /** + * Field Credit + * + * @access private + * @param array + * @param string + * @return string + */ + + function create_field_credit( $key, $out = "" ) { + $out .= '

' . $key['name']. '

'; + + return $out; } @@ -411,10 +497,12 @@ function create_field( $key, $out = "" ) { * @return string * @since 1.5 */ - - function create_field_text( $key, $out = "" ) - { - $out .= $this->create_field_label( $key['name'], $key['_id'] ) . '
'; + + function create_field_text( $key, $out = "" ) { + + $out .= $this->create_field_label( $key['name'], $key['_id'] ); + + $out .= '
'; $out .= ''; + $out .= '

' . esc_html( $key['desc'] ) . '

'; return $out; } @@ -447,9 +537,8 @@ function create_field_text( $key, $out = "" ) * @since 1.5 */ - function create_field_textarea( $key, $out = "" ) - { - $out .= $this->create_field_label( $key['name'], $key['_id'] ) . '
'; + function create_field_textarea( $key, $out = "" ) { + $out .= '

' . $this->create_field_label( $key['name'], $key['_id'] ) . '

'; $out .= '