diff --git a/CHANGELOG.MD b/CHANGELOG.MD index ef3f47fc..8ccbce0d 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [1.52.0] - 2023-10-23 + +### Added + +- TMS-970: Add image caption text to call-to-action and content-columns blocks. + ## [1.51.0] - 2023-10-12 ### Fixed diff --git a/lib/ACF/Fields/CallToActionFields.php b/lib/ACF/Fields/CallToActionFields.php index fa86de71..07bf3478 100644 --- a/lib/ACF/Fields/CallToActionFields.php +++ b/lib/ACF/Fields/CallToActionFields.php @@ -73,12 +73,18 @@ protected function sub_fields() : array { 'on' => 'Näytetään', 'off' => 'Ei näytetä', ], + 'display_caption' => [ + 'label' => 'Kuvateksti', + 'instructions' => 'Näytetäänkö kuvan alla kuvateksti?', + 'on' => 'Näytetään', + 'off' => 'Ei näytetä', + ], ]; $key = $this->get_key(); $rows_field = ( new Field\Repeater( $strings['rows']['label'] ) ) - ->set_key( "${key}_rows" ) + ->set_key( "{$key}_rows" ) ->set_name( 'rows' ) ->set_min( 1 ) ->set_max( 6 ) @@ -87,19 +93,19 @@ protected function sub_fields() : array { ->set_instructions( $strings['rows']['instructions'] ); $image_field = ( new Field\Image( $strings['image']['label'] ) ) - ->set_key( "${key}_numbers" ) + ->set_key( "{$key}_numbers" ) ->set_name( 'image' ) ->set_wrapper_width( 50 ) ->set_instructions( $strings['image']['instructions'] ); $title_field = ( new Field\Text( $strings['title']['label'] ) ) - ->set_key( "${key}_title" ) + ->set_key( "{$key}_title" ) ->set_name( 'title' ) ->set_wrapper_width( 50 ) ->set_instructions( $strings['title']['instructions'] ); $description_field = ( new Field\Textarea( $strings['description']['label'] ) ) - ->set_key( "${key}_description" ) + ->set_key( "{$key}_description" ) ->set_name( 'description' ) ->set_rows( 4 ) ->set_new_lines( 'wpautop' ) @@ -107,30 +113,39 @@ protected function sub_fields() : array { ->set_instructions( $strings['description']['instructions'] ); $link_field = ( new Field\Link( $strings['link']['label'] ) ) - ->set_key( "${key}_link" ) + ->set_key( "{$key}_link" ) ->set_name( 'link' ) ->set_wrapper_width( 50 ) ->set_instructions( $strings['link']['instructions'] ); $layout_field = ( new Field\Radio( $strings['layout']['label'] ) ) - ->set_key( "${key}_layout" ) + ->set_key( "{$key}_layout" ) ->set_name( 'layout' ) ->set_choices( [ 'is-image-first' => 'Kuva ensin', 'is-text-first' => 'Teksti ensin', ] ) - ->set_wrapper_width( 50 ) + ->set_wrapper_width( 33 ) ->set_instructions( $strings['layout']['instructions'] ); $display_artist_field = ( new Field\TrueFalse( $strings['display_artist']['label'] ) ) - ->set_key( "${key}_display_artist" ) + ->set_key( "{$key}_display_artist" ) ->set_name( 'display_artist' ) - ->set_wrapper_width( 50 ) + ->set_wrapper_width( 33 ) ->use_ui() ->set_ui_off_text( $strings['display_artist']['off'] ) ->set_ui_on_text( $strings['display_artist']['on'] ) ->set_instructions( $strings['display_artist']['instructions'] ); + $display_caption_field = ( new Field\TrueFalse( $strings['display_caption']['label'] ) ) + ->set_key( "{$key}_display_caption" ) + ->set_name( 'display_caption' ) + ->set_wrapper_width( 33 ) + ->use_ui() + ->set_ui_off_text( $strings['display_caption']['off'] ) + ->set_ui_on_text( $strings['display_caption']['on'] ) + ->set_instructions( $strings['display_caption']['instructions'] ); + $rows_field->add_fields( [ $image_field, $title_field, @@ -138,6 +153,7 @@ protected function sub_fields() : array { $link_field, $layout_field, $display_artist_field, + $display_caption_field, ] ); return [ diff --git a/lib/ACF/Fields/ContentColumnsFields.php b/lib/ACF/Fields/ContentColumnsFields.php index d53c317e..0c3d7b5f 100644 --- a/lib/ACF/Fields/ContentColumnsFields.php +++ b/lib/ACF/Fields/ContentColumnsFields.php @@ -73,12 +73,18 @@ protected function sub_fields() : array { 'on' => 'Näytetään', 'off' => 'Ei näytetä', ], + 'display_caption' => [ + 'label' => 'Kuvateksti', + 'instructions' => 'Näytetäänkö kuvan alla kuvateksti?', + 'on' => 'Näytetään', + 'off' => 'Ei näytetä', + ], ]; $key = $this->get_key(); $rows_field = ( new Field\Repeater( $strings['rows']['label'] ) ) - ->set_key( "${key}_rows" ) + ->set_key( "{$key}_rows" ) ->set_name( 'rows' ) ->set_min( 1 ) ->set_max( 6 ) @@ -87,19 +93,19 @@ protected function sub_fields() : array { ->set_instructions( $strings['rows']['instructions'] ); $title_field = ( new Field\Text( $strings['title']['label'] ) ) - ->set_key( "${key}_title" ) + ->set_key( "{$key}_title" ) ->set_name( 'title' ) ->set_wrapper_width( 100 ) ->set_instructions( $strings['title']['instructions'] ); $image_field = ( new Field\Image( $strings['image']['label'] ) ) - ->set_key( "${key}_image" ) + ->set_key( "{$key}_image" ) ->set_name( 'image' ) ->set_wrapper_width( 45 ) ->set_instructions( $strings['image']['instructions'] ); $description_field = ( new Field\Textarea( $strings['description']['label'] ) ) - ->set_key( "${key}_description" ) + ->set_key( "{$key}_description" ) ->set_name( 'description' ) ->set_rows( 4 ) ->set_new_lines( 'wpautop' ) @@ -107,35 +113,44 @@ protected function sub_fields() : array { ->set_instructions( $strings['description']['instructions'] ); $layout_field = ( new Field\Radio( $strings['layout']['label'] ) ) - ->set_key( "${key}_layout" ) + ->set_key( "{$key}_layout" ) ->set_name( 'layout' ) ->set_choices( [ 'is-image-first' => 'Kuva ensin', 'is-text-first' => 'Teksti ensin', ] ) - ->set_wrapper_width( 33 ) + ->set_wrapper_width( 25 ) ->set_instructions( $strings['layout']['instructions'] ); $aspect_ratio_field = ( new Field\Radio( $strings['aspect_ratio']['label'] ) ) - ->set_key( "${key}_aspect_ratio" ) + ->set_key( "{$key}_aspect_ratio" ) ->set_name( 'aspect_ratio' ) ->set_choices( [ '50-50' => '50/50', '30-70' => '30/70', '70-30' => '70/30', ] ) - ->set_wrapper_width( 33 ) + ->set_wrapper_width( 25 ) ->set_instructions( $strings['aspect_ratio']['instructions'] ); $display_artist_field = ( new Field\TrueFalse( $strings['display_artist']['label'] ) ) - ->set_key( "${key}_display_artist" ) + ->set_key( "{$key}_display_artist" ) ->set_name( 'display_artist' ) - ->set_wrapper_width( 33 ) + ->set_wrapper_width( 25 ) ->use_ui() ->set_ui_off_text( $strings['display_artist']['off'] ) ->set_ui_on_text( $strings['display_artist']['on'] ) ->set_instructions( $strings['display_artist']['instructions'] ); + $display_caption_field = ( new Field\TrueFalse( $strings['display_caption']['label'] ) ) + ->set_key( "{$key}_display_caption" ) + ->set_name( 'display_caption' ) + ->set_wrapper_width( 25 ) + ->use_ui() + ->set_ui_off_text( $strings['display_caption']['off'] ) + ->set_ui_on_text( $strings['display_caption']['on'] ) + ->set_instructions( $strings['display_caption']['instructions'] ); + $rows_field->add_fields( [ $title_field, $image_field, @@ -143,6 +158,7 @@ protected function sub_fields() : array { $layout_field, $aspect_ratio_field, $display_artist_field, + $display_caption_field, ] ); return [ diff --git a/partials/layouts/layout-call-to-action.dust b/partials/layouts/layout-call-to-action.dust index abb791bb..0f284f12 100644 --- a/partials/layouts/layout-call-to-action.dust +++ b/partials/layouts/layout-call-to-action.dust @@ -1,31 +1,35 @@ -