Skip to content

Commit

Permalink
Hotfix/#368 scheduled block (#369)
Browse files Browse the repository at this point in the history
* move expired check further down the line

* fix php warning by checking for `none`
  • Loading branch information
gregrickaby authored May 23, 2018
1 parent 929d288 commit 5bdd402
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
30 changes: 17 additions & 13 deletions inc/acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,27 @@ function _s_acf_flexible_content_layout_title( $title, $field, $layout, $i ) {
$other_options = get_sub_field( 'other_options' ) ? get_sub_field( 'other_options' ) : get_field( 'other_options' )['other_options'];

// Get Background Type.
$background = get_sub_field( 'background_options' )['background_type']['value'];
$background_repeater = get_sub_field( 'hero_slides' )[0]['background_options']['background_type']['value'];
$background_type = $background ? $background : $background_repeater;
$background = get_sub_field( 'background_options' )['background_type']['value'];

$type = _s_return_flexible_content_layout_value( $background_type );
// If there's no background, just move along...
if ( ! 'none' === $background ) {
$background_repeater = get_sub_field( 'hero_slides' )[0]['background_options']['background_type']['value'];
$background_type = $background ? $background : $background_repeater;

// Load image from non-repeater sub field background image, if it exists else Load image from repeater sub field background image, if it exists — Hero.
if ( 'image' === $background_type ) {
$title .= '<img src="' . esc_url( $type['sizes']['thumbnail'] ) . '" height="30" width="30" class="acf-flexible-title-image" />';
}
$type = _s_return_flexible_content_layout_value( $background_type );

if ( 'color' === $background_type ) {
$title .= '<div style="background-color: ' . esc_attr( $type ) . '; height: 30px; width: 30px;" class="acf-flexible-title-image"><span class="screen-reader-text">' . esc_html( $type ) . '</span></div>';
}
// Load image from non-repeater sub field background image, if it exists else Load image from repeater sub field background image, if it exists — Hero.
if ( 'image' === $background_type ) {
$title .= '<img src="' . esc_url( $type['sizes']['thumbnail'] ) . '" height="30" width="30" class="acf-flexible-title-image" />';
}

if ( 'video' === $background_type ) {
$title .= '<div style="font-size: 30px; height: 26px; width: 30px;" class="dashicons dashicons-format-video acf-flexible-title-image"><span class="screen-reader-text">' . esc_html__( 'Video', '_s' ) . '</span></div>';
if ( 'color' === $background_type ) {
$title .= '<div style="background-color: ' . esc_attr( $type ) . '; height: 30px; width: 30px;" class="acf-flexible-title-image"><span class="screen-reader-text">' . esc_html( $type ) . '</span></div>';
}

if ( 'video' === $background_type ) {
$title .= '<div style="font-size: 30px; height: 26px; width: 30px;" class="dashicons dashicons-format-video acf-flexible-title-image"><span class="screen-reader-text">' . esc_html__( 'Video', '_s' ) . '</span></div>';
}
}

// Set default field title. Don't want to lose this.
Expand Down
9 changes: 9 additions & 0 deletions template-parts/content-blocks/block-hero.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
$button_text = get_sub_field( 'button_text' );
$button_url = get_sub_field( 'button_url' );
$animation_class = _s_get_animation_class();
$other_options = get_sub_field( 'other_options' ) ? get_sub_field( 'other_options' ) : get_field( 'other_options' )['other_options'];

// If the block has expired, then bail!
if ( _s_has_block_expired( array(
'start_date' => $other_options['start_date'],
'end_date' => $other_options['end_date'],
) ) ) {
return false;
}

// Start a <container> with possible block options.
_s_display_block_options( array(
Expand Down

0 comments on commit 5bdd402

Please sign in to comment.