From 0805e07fbb6b14b4455c483f4ddc1fff524274eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Erkkil=C3=A4?= Date: Mon, 11 Sep 2023 08:46:47 +0300 Subject: [PATCH 1/5] TMS-970: Add image caption text to call-to-action and content-columns blocks. --- CHANGELOG.MD | 2 ++ lib/ACF/Fields/CallToActionFields.php | 34 +++++++++++++----- lib/ACF/Fields/ContentColumnsFields.php | 36 ++++++++++++++------ partials/layouts/layout-call-to-action.dust | 4 +++ partials/layouts/layout-content-columns.dust | 6 +++- partials/ui/image/image-caption.dust | 8 +++++ partials/ui/image/image-meta-minimal.dust | 2 +- 7 files changed, 71 insertions(+), 21 deletions(-) create mode 100644 partials/ui/image/image-caption.dust diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 9b81e1ed..ccffa0eb 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +- TMS-970: Add image caption text to call-to-action and content-columns blocks. + ## [1.47.0] - 2023-09-04 - TMS-964-2: Update translation and format pricing. 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..d1454d8c 100644 --- a/partials/layouts/layout-call-to-action.dust +++ b/partials/layouts/layout-call-to-action.dust @@ -10,6 +10,10 @@ {@image id=image.id size="large" class="objectfit-image" /} + {@isset key1=display_caption key2=image.caption method="and" } + {>"ui/image/image-caption" /} + {/isset} + {?display_artist} {>"ui/image/image-meta-minimal" /} {/display_artist} diff --git a/partials/layouts/layout-content-columns.dust b/partials/layouts/layout-content-columns.dust index 1dc19c1c..40909737 100644 --- a/partials/layouts/layout-content-columns.dust +++ b/partials/layouts/layout-content-columns.dust @@ -8,8 +8,12 @@ {@image id=image.id size="large" class="objectfit-image" /} + {@isset key1=display_caption key2=image.caption method="AND" } + {>"ui/image/image-caption" /} + {/isset} + {?display_artist} - {>"ui/image/image-meta-minimal" /} + {>"ui/image/image-meta-minimal" /} {/display_artist} {/image} diff --git a/partials/ui/image/image-caption.dust b/partials/ui/image/image-caption.dust new file mode 100644 index 00000000..e6edb891 --- /dev/null +++ b/partials/ui/image/image-caption.dust @@ -0,0 +1,8 @@ +
+
+ + {image.caption|kses} + +
+
diff --git a/partials/ui/image/image-meta-minimal.dust b/partials/ui/image/image-meta-minimal.dust index f5460ebb..7d64e7a5 100644 --- a/partials/ui/image/image-meta-minimal.dust +++ b/partials/ui/image/image-meta-minimal.dust @@ -1,5 +1,5 @@ {@isset key1=author_name key2=image_title_and_artist method="OR" } -
+
{?image_title_and_artist} From 451447bb0008b7f89c74c72473773734a1a1723b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Erkkil=C3=A4?= Date: Mon, 11 Sep 2023 08:49:14 +0300 Subject: [PATCH 2/5] Revert image-meta-minimal.dust. --- partials/ui/image/image-meta-minimal.dust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partials/ui/image/image-meta-minimal.dust b/partials/ui/image/image-meta-minimal.dust index 7d64e7a5..f5460ebb 100644 --- a/partials/ui/image/image-meta-minimal.dust +++ b/partials/ui/image/image-meta-minimal.dust @@ -1,5 +1,5 @@ {@isset key1=author_name key2=image_title_and_artist method="OR" } -
+
{?image_title_and_artist} From 7f15b8bd021417a05f3afc47aecf0770d85e0861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20V=C3=A4nttinen?= Date: Mon, 16 Oct 2023 11:58:28 +0300 Subject: [PATCH 3/5] TMS-970: Fix template escaping --- partials/layouts/layout-call-to-action.dust | 12 ++++++------ partials/layouts/layout-content-columns.dust | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/partials/layouts/layout-call-to-action.dust b/partials/layouts/layout-call-to-action.dust index d1454d8c..0f284f12 100644 --- a/partials/layouts/layout-call-to-action.dust +++ b/partials/layouts/layout-call-to-action.dust @@ -1,12 +1,12 @@ -
+
{>"shared/layout-before-main-content" /} {#rows} -
+
{?image}
-
+
{@image id=image.id size="large" class="objectfit-image" /}
@@ -20,16 +20,16 @@
{/image} -
+
{?title}

- {title|s} + {title|html}

{/title} {?description}
- {description|s} + {description|kses}
{/description} diff --git a/partials/layouts/layout-content-columns.dust b/partials/layouts/layout-content-columns.dust index 40909737..fef23f15 100644 --- a/partials/layouts/layout-content-columns.dust +++ b/partials/layouts/layout-content-columns.dust @@ -1,9 +1,9 @@ -
+
{#rows} -
+
{?image} -
+
{@image id=image.id size="large" class="objectfit-image" /}
@@ -18,16 +18,16 @@
{/image} -
+
{?title}

- {title|s} + {title|html}

{/title} {?description}
- {description|s} + {description|kses}
{/description}
From 2d1d249127b7106a63651d49677245193b7090d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20V=C3=A4nttinen?= Date: Mon, 16 Oct 2023 13:57:39 +0300 Subject: [PATCH 4/5] Update changelog --- CHANGELOG.MD | 4 ++++ style.css | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index d06adde0..2a710f8b 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [1.52.0] - 2023-10-16 + +### Added + - TMS-970: Add image caption text to call-to-action and content-columns blocks. ## [1.51.0] - 2023-10-12 diff --git a/style.css b/style.css index 0a9ebc30..cc8d46c3 100644 --- a/style.css +++ b/style.css @@ -2,7 +2,7 @@ * Theme Name: TMS Theme Base * Description: Tampere Multisite Base Theme * Domain Path: /lang - * Version: 1.51.0 + * Version: 1.52.0 * Author: Geniem * Author URI: https://geniem.fi * Text Domain: tms-theme-base From 5c23fa598eec6dde327ff407e1bbc9d15205d3b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20V=C3=A4nttinen?= Date: Mon, 23 Oct 2023 11:44:04 +0300 Subject: [PATCH 5/5] 1.52.0 --- CHANGELOG.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 2a710f8b..8ccbce0d 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] -## [1.52.0] - 2023-10-16 +## [1.52.0] - 2023-10-23 ### Added