Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/1269 #1274

Merged
merged 5 commits into from
Nov 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions includes/forms/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1684,8 +1684,19 @@ function give_show_goal_progress( $form_id, $args ) {
function give_get_form_content_placement( $form_id, $args ) {
$show_content = '';

if( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) {
$show_content = ( 'none' !== $args['show_content'] ? $args['show_content'] : '' );
if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) {
// Content positions.
$content_placement = array(
'above' => 'give_pre_form',
'below' => 'give_post_form',
);

// Check if content position already decoded.
if ( in_array( $args['show_content'], $content_placement ) ) {
return $args['show_content'];
}

$show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' );
} elseif ( give_is_setting_enabled( get_post_meta( $form_id, '_give_display_content', true ) ) ) {
$show_content = get_post_meta( $form_id, '_give_content_placement', true );
}
Expand Down
20 changes: 12 additions & 8 deletions includes/forms/widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ public function widget( $args, $instance ){
$title = !empty( $instance['title'] ) ? $instance['title'] : '';
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );


// If user set float labels to global then check global float label setting and update donation form widget accordingly.
if( ( 'global' === $instance['float_labels'] ) ) {
$instance['float_labels'] = give_get_option( 'floatlabels', 'disabled' );
}

echo $args['before_widget'];

/**
Expand Down Expand Up @@ -125,6 +119,7 @@ public function form( $instance ){
'id' => '',
'float_labels' => 'global',
'display_style' => 'modal',
'show_content' => 'none',
);

$instance = wp_parse_args( (array) $instance, $defaults );
Expand Down Expand Up @@ -164,7 +159,7 @@ public function form( $instance ){

<?php // Widget: Display Style ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display style:', 'give' ); ?></label><br>
<label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display Style:', 'give' ); ?></label><br>
<label for="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-onpage" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label>
&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-reveal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label>
&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'display_style' ); ?>-modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'display_style' ); ?>-modal" name="<?php echo $this->get_field_name( 'display_style' ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label><br>
Expand All @@ -187,7 +182,16 @@ public function form( $instance ){
esc_url( 'https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels' )
);
?></small>
</p><?php
</p>

<?php // Widget: Display Content ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>"><?php esc_html_e( 'Display Content (optional):', 'give' ); ?></label><br>
<label for="<?php echo $this->get_field_id( 'show_content' ); ?>-none"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-none" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="none" <?php checked( $instance['show_content'], 'none' ); ?>> <?php echo esc_html__( 'None', 'give' ); ?></label>
&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'show_content' ); ?>-above"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-above" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="above" <?php checked( $instance['show_content'], 'above' ); ?>> <?php echo esc_html__( 'Above', 'give' ); ?></label>
&nbsp;&nbsp;<label for="<?php echo $this->get_field_id( 'show_content' ); ?>-below"><input type="radio" class="widefat" id="<?php echo $this->get_field_id( 'show_content' ); ?>-below" name="<?php echo $this->get_field_name( 'show_content' ); ?>" value="below" <?php checked( $instance['show_content'], 'below' ); ?>> <?php echo esc_html__( 'Below', 'give' ); ?></label><br>
<small class="give-field-description"><?php esc_html_e( 'Override the display content setting for this Give form.', 'give' ); ?></small>
<?php
}

/**
Expand Down
30 changes: 3 additions & 27 deletions includes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,9 @@ function give_form_shortcode( $atts ) {
'display_style' => '',
), $atts, 'give_form' );

foreach ( $atts as $key => $value ) {
//convert shortcode_atts values to booleans
if ( $key == 'show_title' ) {
$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
} elseif ( $key == 'show_goal' ) {
$atts[ $key ] = filter_var( $atts[ $key ], FILTER_VALIDATE_BOOLEAN );
}

//validate show_content value
if ( $key == 'show_content' ) {
if ( ! in_array( $value, array( 'none', 'above', 'below' ) ) ) {
$atts[ $key ] = '';
} else if ( $value == 'above' ) {
$atts[ $key ] = 'give_pre_form';
} else if ( $value == 'below' ) {
$atts[ $key ] = 'give_post_form';
}
}

//validate display_style and float_labels value
if ( ( $key == 'display_style' && ! in_array( $value, array( 'onpage', 'reveal', 'modal' ) ) )
|| ( $key == 'float_labels' && ! in_array( $value, array( 'enabled', 'disabled' ) ) )
) {

$atts[ $key ] = '';
}
}
// Convert string to bool.
$atts['show_title'] = (bool) $atts['show_title'];
$atts['show_goal'] = (bool) $atts['show_goal'];

//get the Give Form
ob_start();
Expand Down