Skip to content

Commit

Permalink
adjust internal variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Arntz committed Dec 15, 2016
1 parent 697d49a commit f9bf14b
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 212 deletions.
40 changes: 20 additions & 20 deletions modules/acceptance.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,47 @@ function cf7bs_add_shortcode_acceptance() {
function cf7bs_acceptance_shortcode_handler( $tag ) {
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';

$tag = new $classname( $tag );
$tag_obj = new $classname( $tag );

if ( empty( $tag->name ) ) {
if ( empty( $tag_obj->name ) ) {
return '';
}

$mode = $status = 'default';

$validation_error = wpcf7_get_validation_error( $tag->name );
$validation_error = wpcf7_get_validation_error( $tag_obj->name );

$class = wpcf7_form_controls_class( $tag->type );
$class = wpcf7_form_controls_class( $tag_obj->type );
if ( $validation_error ) {
$class .= ' wpcf7-not-valid';
$status = 'error';
}
if ( $tag->has_option( 'invert' ) ) {
if ( $tag_obj->has_option( 'invert' ) ) {
$class .= ' wpcf7-invert';
}

$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
'name' => $tag->name,
'id' => $tag->get_option( 'id', 'id', true ),
'class' => $tag->get_class_option( $class ),
'name' => $tag_obj->name,
'id' => $tag_obj->get_option( 'id', 'id', true ),
'class' => $tag_obj->get_class_option( $class ),
'type' => 'checkbox',
'value' => $tag->has_option( 'default:on' ) ? '1' : '0',
'value' => $tag_obj->has_option( 'default:on' ) ? '1' : '0',
'options' => array(
'1' => $tag->content,
'1' => $tag_obj->content,
),
'help_text' => $validation_error,
'size' => cf7bs_get_form_property( 'size', 0, $tag ),
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag ),
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag ),
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag ),
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag ),
'group_layout' => cf7bs_get_form_property( 'group_layout', 0, $tag ),
'size' => cf7bs_get_form_property( 'size', 0, $tag_obj ),
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
'group_layout' => cf7bs_get_form_property( 'group_layout', 0, $tag_obj ),
'mode' => $mode,
'status' => $status,
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
'wrapper_class' => $tag->name,
'label_class' => $tag->get_option( 'label_class', 'class', true ),
), $tag->basetype, $tag->name ) );
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
'wrapper_class' => $tag_obj->name,
'label_class' => $tag_obj->get_option( 'label_class', 'class', true ),
), $tag_obj->basetype, $tag_obj->name ) );

$html = $field->display( false );

Expand Down
74 changes: 37 additions & 37 deletions modules/checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,28 @@ function cf7bs_add_shortcode_checkbox() {
function cf7bs_checkbox_shortcode_handler( $tag ) {
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';

$tag = new $classname( $tag );
$tag_obj = new $classname( $tag );

if ( empty( $tag->name ) ) {
if ( empty( $tag_obj->name ) ) {
return '';
}

$mode = $status = 'default';

$validation_error = wpcf7_get_validation_error( $tag->name );
$validation_error = wpcf7_get_validation_error( $tag_obj->name );

$class = wpcf7_form_controls_class( $tag->type );
$class = wpcf7_form_controls_class( $tag_obj->type );
if ( $validation_error ) {
$class .= ' wpcf7-not-valid';
$status = 'error';
}

$exclusive = $tag->has_option( 'exclusive' );
$free_text = $tag->has_option( 'free_text' );
$exclusive = $tag_obj->has_option( 'exclusive' );
$free_text = $tag_obj->has_option( 'free_text' );

$multiple = false;

if ( 'checkbox' == $tag->basetype ) {
if ( 'checkbox' == $tag_obj->basetype ) {
$multiple = !$exclusive;
} else {
$exclusive = false;
Expand All @@ -59,14 +59,14 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
$class .= ' wpcf7-exclusive-checkbox';
}

if ( $tag->is_required() ) {
if ( $tag_obj->is_required() ) {
$mode = 'required';
}

$values = (array) $tag->values;
$labels = (array) $tag->labels;
$values = (array) $tag_obj->values;
$labels = (array) $tag_obj->labels;

if ( $data = (array) $tag->get_data_option() ) {
if ( $data = (array) $tag_obj->get_data_option() ) {
if ( $free_text ) {
$values = array_merge( array_slice( $values, 0, -1 ), array_values( $data ), array_slice( $values, -1 ) );
$labels = array_merge( array_slice( $labels, 0, -1 ), array_values( $data ), array_slice( $labels, -1 ) );
Expand All @@ -78,7 +78,7 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {

$defaults = array();

$default_choice = $tag->get_default_option( null, 'multiple=1' );
$default_choice = $tag_obj->get_default_option( null, 'multiple=1' );

foreach ( $default_choice as $value ) {
$key = array_search( $value, $values, true );
Expand All @@ -88,7 +88,7 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
}
}

if ( $matches = $tag->get_first_match_option( '/^default:([0-9_]+)$/' ) ) {
if ( $matches = $tag_obj->get_first_match_option( '/^default:([0-9_]+)$/' ) ) {
$defaults = array_merge( $defaults, explode( '_', $matches[1] ) );
}

Expand All @@ -100,27 +100,27 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
$checked = array();
}

if ( isset( $_POST[ $tag->name ] ) ) {
$post = $_POST[ $tag->name ];
if ( isset( $_POST[ $tag_obj->name ] ) ) {
$post = $_POST[ $tag_obj->name ];
} else {
if ( isset( $_GET[ $tag->name ] ) ) {
if ( isset( $_GET[ $tag_obj->name ] ) ) {
if ( $multiple ) {
$get = cf7bs_array_decode( rawurldecode( $_GET[ $tag->name ] ) );
$get = cf7bs_array_decode( rawurldecode( $_GET[ $tag_obj->name ] ) );
} else {
$get = rawurldecode( $_GET[ $tag->name ] );
$get = rawurldecode( $_GET[ $tag_obj->name ] );
}
}
$post = $multiple ? array() : '';
}
$posted = wpcf7_is_posted();

$count = 0;
$replace_index = count( (array) $tag->values ) - 1;
$replace_index = count( (array) $tag_obj->values ) - 1;

foreach ( (array) $tag->values as $key => $value ) {
foreach ( (array) $tag_obj->values as $key => $value ) {
$options[ $value ] = isset( $labels[ $key ] ) ? $labels[ $key ] : $value;
if ( $free_text && $count == $replace_index ) {
$options[ $value ] .= ' <input type="text" name="' . sprintf( '_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name ) . '" class="wpcf7-free-text">';
$options[ $value ] .= ' <input type="text" name="' . sprintf( '_wpcf7_%1$s_free_text_%2$s', $tag_obj->basetype, $tag_obj->name ) . '" class="wpcf7-free-text">';
}

if ( $posted && ! empty( $post ) ) {
Expand All @@ -147,39 +147,39 @@ function cf7bs_checkbox_shortcode_handler( $tag ) {
$count++;
}

$label = $tag->content;
$label = $tag_obj->content;

if ( count( $options ) < 1 ) {
if ( $free_text ) {
$options = array( 'true' => '<input type="text" name="' . sprintf( '_wpcf7_%1$s_free_text_%2$s', $tag->basetype, $tag->name ) . '" class="wpcf7-free-text">' );
$options = array( 'true' => '<input type="text" name="' . sprintf( '_wpcf7_%1$s_free_text_%2$s', $tag_obj->basetype, $tag_obj->name ) . '" class="wpcf7-free-text">' );
} else {
$options = array( 'true' => $label );
$label = '';
}
}

$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
'name' => $tag->name,
'id' => $tag->get_option( 'id', 'id', true ),
'name' => $tag_obj->name,
'id' => $tag_obj->get_option( 'id', 'id', true ),
'class' => '',
'type' => $tag->basetype,
'type' => $tag_obj->basetype,
'value' => $checked,
'label' => $label,
'options' => $options,
'help_text' => $validation_error,
'size' => cf7bs_get_form_property( 'size', 0, $tag ),
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag ),
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag ),
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag ),
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag ),
'group_layout' => cf7bs_get_form_property( 'group_layout', 0, $tag ),
'group_type' => cf7bs_get_form_property( 'group_type', 0, $tag ),
'size' => cf7bs_get_form_property( 'size', 0, $tag_obj ),
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
'group_layout' => cf7bs_get_form_property( 'group_layout', 0, $tag_obj ),
'group_type' => cf7bs_get_form_property( 'group_type', 0, $tag_obj ),
'mode' => $mode,
'status' => $status,
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
'wrapper_class' => $tag->get_class_option( $class . ' ' . $tag->name ),
'label_class' => $tag->get_option( 'label_class', 'class', true ),
), $tag->basetype, $tag->name ) );
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
'wrapper_class' => $tag_obj->get_class_option( $class . ' ' . $tag_obj->name ),
'label_class' => $tag_obj->get_option( 'label_class', 'class', true ),
), $tag_obj->basetype, $tag_obj->name ) );

$html = $field->display( false );

Expand Down
68 changes: 34 additions & 34 deletions modules/date.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,77 +27,77 @@ function cf7bs_add_shortcode_date() {
function cf7bs_date_shortcode_handler( $tag ) {
$classname = class_exists( 'WPCF7_FormTag' ) ? 'WPCF7_FormTag' : 'WPCF7_Shortcode';

$tag = new $classname( $tag );
$tag_obj = new $classname( $tag );

if ( empty( $tag->name ) ) {
if ( empty( $tag_obj->name ) ) {
return '';
}

$mode = $status = 'default';

$validation_error = wpcf7_get_validation_error( $tag->name );
$validation_error = wpcf7_get_validation_error( $tag_obj->name );

$class = wpcf7_form_controls_class( $tag->type );
$class = wpcf7_form_controls_class( $tag_obj->type );
$class .= ' wpcf7-validates-as-date';
if ( $validation_error ) {
$class .= ' wpcf7-not-valid';
$status = 'error';
}

if ( $tag->is_required() ) {
if ( $tag_obj->is_required() ) {
$mode = 'required';
}

$value = (string) reset( $tag->values );
$value = (string) reset( $tag_obj->values );
$placeholder = '';
if ( $tag->has_option( 'placeholder' ) || $tag->has_option( 'watermark' ) ) {
if ( $tag_obj->has_option( 'placeholder' ) || $tag_obj->has_option( 'watermark' ) ) {
$placeholder = $value;
$value = '';
}

$value = $tag->get_default_option( $value );
$value = $tag_obj->get_default_option( $value );

if ( wpcf7_is_posted() && isset( $_POST[ $tag->name ] ) ) {
$value = stripslashes_deep( $_POST[ $tag->name ] );
} elseif( isset( $_GET ) && array_key_exists( $tag->name, $_GET ) ) {
$value = stripslashes_deep( rawurldecode( $_GET[ $tag->name ] ) );
if ( wpcf7_is_posted() && isset( $_POST[ $tag_obj->name ] ) ) {
$value = stripslashes_deep( $_POST[ $tag_obj->name ] );
} elseif( isset( $_GET ) && array_key_exists( $tag_obj->name, $_GET ) ) {
$value = stripslashes_deep( rawurldecode( $_GET[ $tag_obj->name ] ) );
}

if ( is_callable( array( $tag, 'get_date_option' ) ) ) {
$min = $tag->get_date_option( 'min' );
$max = $tag->get_date_option( 'max' );
if ( is_callable( array( $tag_obj, 'get_date_option' ) ) ) {
$min = $tag_obj->get_date_option( 'min' );
$max = $tag_obj->get_date_option( 'max' );
} else {
$min = $tag->get_option( 'min', 'date', true );
$max = $tag->get_option( 'max', 'date', true );
$min = $tag_obj->get_option( 'min', 'date', true );
$max = $tag_obj->get_option( 'max', 'date', true );
}
$step = $tag->get_option( 'step', 'int', true );
$step = $tag_obj->get_option( 'step', 'int', true );

$field = new CF7BS_Form_Field( cf7bs_apply_field_args_filter( array(
'name' => $tag->name,
'id' => $tag->get_option( 'id', 'id', true ),
'class' => $tag->get_class_option( $class ),
'type' => wpcf7_support_html5() ? $tag->basetype : 'text',
'name' => $tag_obj->name,
'id' => $tag_obj->get_option( 'id', 'id', true ),
'class' => $tag_obj->get_class_option( $class ),
'type' => wpcf7_support_html5() ? $tag_obj->basetype : 'text',
'value' => $value,
'placeholder' => $placeholder,
'label' => $tag->content,
'label' => $tag_obj->content,
'options' => array(
'min' => $min,
'max' => $max,
'step' => $tag->get_option( 'step', 'int', true ),
'step' => $tag_obj->get_option( 'step', 'int', true ),
),
'help_text' => $validation_error,
'size' => cf7bs_get_form_property( 'size', 0, $tag ),
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag ),
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag ),
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag ),
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag ),
'size' => cf7bs_get_form_property( 'size', 0, $tag_obj ),
'grid_columns' => cf7bs_get_form_property( 'grid_columns', 0, $tag_obj ),
'form_layout' => cf7bs_get_form_property( 'layout', 0, $tag_obj ),
'form_label_width' => cf7bs_get_form_property( 'label_width', 0, $tag_obj ),
'form_breakpoint' => cf7bs_get_form_property( 'breakpoint', 0, $tag_obj ),
'mode' => $mode,
'status' => $status,
'readonly' => $tag->has_option( 'readonly' ) ? true : false,
'tabindex' => $tag->get_option( 'tabindex', 'int', true ),
'wrapper_class' => $tag->name,
'label_class' => $tag->get_option( 'label_class', 'class', true ),
), $tag->basetype, $tag->name ) );
'readonly' => $tag_obj->has_option( 'readonly' ) ? true : false,
'tabindex' => $tag_obj->get_option( 'tabindex', 'int', true ),
'wrapper_class' => $tag_obj->name,
'label_class' => $tag_obj->get_option( 'label_class', 'class', true ),
), $tag_obj->basetype, $tag_obj->name ) );

$html = $field->display( false );

Expand Down
Loading

0 comments on commit f9bf14b

Please sign in to comment.