Skip to content

Commit

Permalink
Merge branch 'release/1.40.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Misplon committed Aug 30, 2022
2 parents 02d575c + a2e04dc commit d9a8d28
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
5 changes: 5 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ The Widgets Bundle global interface is available at Plugins > SiteOrigin Widgets

== Changelog ==

= 1.40.1 - 30 August 2022 =
* Contact Form: Added a new Dropdown Select setting `Allow multiple selections`.
* Blog: Added a `Sticky` indicator to post meta.
* Blog: Factored numbers into the Excerpt Length count.

= 1.40.0 - 20 August 2022 =
* Blog: Added `Excerpt Length` setting. The excerpt length can also be set using `siteorigin_widgets_blog_excerpt_length`.
* Blog: Resolved a Portfolio template column sizing issue.
Expand Down
8 changes: 7 additions & 1 deletion widgets/blog/blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,12 @@ public function get_template_variables( $instance, $args ) {
}

static public function post_meta( $settings ) {
if ( is_sticky() ) {
?>
<span class="sow-featured-post"><?php echo esc_html__( 'Sticky', 'so-widgets-bundle' ); ?></span>
<?php
}

if ( $settings['date'] ) :
$date_format = isset( $settings['date_format'] ) ? $settings['date_format'] : null;
?>
Expand Down Expand Up @@ -1028,7 +1034,7 @@ static public function generate_excerpt( $settings ) {

$length = get_query_var( 'siteorigin_blog_excerpt_length' );
$excerpt = get_the_excerpt();
$excerpt_add_read_more = str_word_count( $excerpt ) >= $length;
$excerpt_add_read_more = str_word_count( $excerpt, 0, '0..9' ) >= $length;
if ( ! has_excerpt() ) {
$excerpt = wp_trim_words( $excerpt, $length, '...' );
}
Expand Down
31 changes: 23 additions & 8 deletions widgets/contact/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ function get_widget_form() {
)
),

'multiple_select' => array(
'type' => 'checkbox',
'label' => __( 'Allow multiple selections', 'so-widgets-bundle' ),
'state_handler' => array(
'field_type_{$repeater}[select]' => array( 'show' ),
'_else[field_type_{$repeater}]' => array( 'hide' ),
),
),

// This are for select, radio, and checkboxes
'options' => array(
'type' => 'repeater',
Expand Down Expand Up @@ -1282,7 +1291,16 @@ function contact_form_action( $instance, $storage_hash ) {
$email_fields[ $field['type'] ] = $value;
}
break;
case 'select':
if ( ! empty( $field['multiple_select'] ) && is_array( $value ) ) {
$value = implode( ', ', $value );
}

$email_fields['message'][] = array(
'label' => $field['label'],
'value' => $value,
);
break;
default:
$email_fields['message'][] = array(
'label' => $field['label'],
Expand Down Expand Up @@ -1483,14 +1501,11 @@ function send_mail( $email_fields, $instance ) {
}
$body .= "\n\n";
}

if ( ! empty( $email_fields['message'] ) ) {
foreach ( $email_fields['message'] as $m ) {
$body .= '<strong>' . $m['label'] . ':</strong>';
$body .= "\n";
$body .= htmlspecialchars( $m['value'] );
$body .= "\n\n";
}
foreach ( $email_fields['message'] as $m ) {
$body .= '<strong>' . $m['label'] . ':</strong>';
$body .= "\n";
$body .= htmlspecialchars( $m['value'] );
$body .= "\n\n";
}
$body = wpautop( trim( $body ) );

Expand Down
8 changes: 5 additions & 3 deletions widgets/contact/fields/select.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ class SiteOrigin_Widget_ContactForm_Field_Select extends SiteOrigin_Widget_Conta
public function render_field( $options ) {
?>
<select
name="<?php echo esc_attr( $options['field_name'] ); ?>"
name="<?php echo esc_attr( $options['field_name'] ); ?><?php echo ! empty( $options['field']['multiple_select'] ) ? '[]' : ''; ?>"
id="<?php echo esc_attr( $options['field_id'] ); ?>"
<?php self::add_custom_attrs( 'select' ); ?>
<?php echo ! empty( $options['field']['multiple_select'] ) ? 'multiple' : ''; ?>
>
<?php
if ( $options['show_placeholder'] ) {
Expand All @@ -23,10 +24,11 @@ public function render_field( $options ) {
<?php
}

foreach ( $options['field']['options'] as $option ) {
foreach ( $options['field']['options'] as $i => $option ) {
$value = ! empty( $options['field']['multiple_select'] ) && is_array( $options['value'] ) ? $options['value'][ $i ] : $options['value'];
?>
<option
value="<?php echo esc_attr( $option['value'] ) ?>"<?php echo selected( $option['value'], $options['value'], false ); ?>>
value="<?php echo esc_attr( $option['value'] ) ?>"<?php echo selected( $option['value'], $value, false ); ?>>
<?php echo esc_html( $option['value'] ); ?>
</option>
<?php
Expand Down

0 comments on commit d9a8d28

Please sign in to comment.