From 349e2bf7f761ee4e9ccf87031fe5defab39e72cf Mon Sep 17 00:00:00 2001 From: Alexander Bigga Date: Wed, 10 Jul 2024 20:36:16 +0200 Subject: [PATCH 1/3] Add WhatsApp sharer button --- .editorconfig | 2 +- .../block-patterns/elemente/person-2.html | 90 +++++++++++++++++-- .../block-patterns/elemente/person-3.html | 18 +++- ...class-sunflowersocialmediasettingspage.php | 10 +++ inc/template-tags.php | 34 +++---- src/meta-data/edit.js | 4 + 6 files changed, 134 insertions(+), 24 deletions(-) diff --git a/.editorconfig b/.editorconfig index c0d8aad3..ddb5ba53 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,7 @@ root = true [*] -# WordPress Coding Style uses TABs for PHP, JS and CSS files +# WordPress Coding Style uses TABs for PHP, JS, HTML and CSS files # https://developer.wordpress.org/coding-standards/wordpress-coding-standards/ indent_style = tab indent_size = 4 diff --git a/functions/block-patterns/elemente/person-2.html b/functions/block-patterns/elemente/person-2.html index 10be6c95..1bb03fdb 100644 --- a/functions/block-patterns/elemente/person-2.html +++ b/functions/block-patterns/elemente/person-2.html @@ -15,13 +15,93 @@ - -
- + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + +
+
+ + + + +
+
Sunflower Flower Summer Blossom  - Bru-nO / Pixabay
+ +

Vorname Nachname

+ + + +

Kurze Beschreibung, Amt, Mandat und/oder Zitat.

+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/functions/block-patterns/elemente/person-3.html b/functions/block-patterns/elemente/person-3.html index 0bb44953..661246bf 100644 --- a/functions/block-patterns/elemente/person-3.html +++ b/functions/block-patterns/elemente/person-3.html @@ -28,8 +28,12 @@ + + + + - + @@ -82,8 +86,12 @@ + + + + - + @@ -136,8 +144,12 @@ + + + + - + diff --git a/functions/options/class-sunflowersocialmediasettingspage.php b/functions/options/class-sunflowersocialmediasettingspage.php index 28424ebe..5a5306df 100644 --- a/functions/options/class-sunflowersocialmediasettingspage.php +++ b/functions/options/class-sunflowersocialmediasettingspage.php @@ -118,6 +118,15 @@ public function sunflower_social_media_page_init(): void { array( 'sunflower_sharer_facebook', __( 'Facebook', 'sunflower' ) ) ); + add_settings_field( + 'sunflower_sharer_whatsapp', + __( 'WhatsApp', 'sunflower' ), + $this->sunflower_checkbox_callback( ... ), + 'sunflower-setting-social-media-options', + 'sunflower_social_media_sharers', + array( 'sunflower_sharer_whatsapp', __( 'WhatsApp', 'sunflower' ) ) + ); + add_settings_field( 'sunflower_sharer_mail', __( 'mail', 'sunflower' ), @@ -193,6 +202,7 @@ public function social_media_profiles_callback(): void { $default[] = 'fab fa-twitter;Twitter;'; $default[] = 'fab fa-bluesky;Bluesky;'; $default[] = 'fab fa-facebook-f;Facebook;'; + $default[] = 'fab fa-whatsapp;WhatsApp;'; $default[] = 'fab fa-threads;Threads;'; $default[] = 'fab fa-tiktok;TikTok;'; $default[] = 'fab fa-linkedin;LinkedIn;'; diff --git a/inc/template-tags.php b/inc/template-tags.php index 703a39cb..bd993ecf 100755 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -101,29 +101,35 @@ function sunflower_entry_footer( $show_sharers = false ) { * Make the Sunflower social sharers. */ function sunflower_the_social_media_sharers() { - $twitter = false; - $facebook = false; - $mail = false; + + $sharer = []; if ( sunflower_get_setting( 'sunflower_sharer_twitter' ) || sunflower_get_setting( 'sunflower_sharer_x_twitter' ) ) { - $twitter = sprintf( - '', + $sharer[] = sprintf( + '', rawurlencode( (string) get_the_title() ), get_permalink(), - false, __( 'Share on X (Twitter) ', 'sunflower' ) ); } if ( sunflower_get_setting( 'sunflower_sharer_facebook' ) ) { - $facebook = sprintf( - "", - get_permalink(), + $sharer[] = sprintf( + '', + rawurlencode( (string) get_the_title() ), __( 'Share on Facebook ', 'sunflower' ) ); } + if ( sunflower_get_setting( 'sunflower_sharer_whatsapp' ) ) { + $sharer[] = sprintf( + '', + rawurlencode( (string) get_the_title() ), + __( 'Share on WhatsApp ', 'sunflower' ) + ); + } + if ( sunflower_get_setting( 'sunflower_sharer_mail' ) ) { - $mail = sprintf( + $sharer[] = sprintf( '', rawurlencode( (string) get_the_title() ), get_permalink(), @@ -131,12 +137,10 @@ function sunflower_the_social_media_sharers() { ); } - if ( $twitter || $facebook || $mail ) { + if ( count($sharer) > 0 ) { printf( - '', - wp_kses_post( $twitter ), - wp_kses_post( $facebook ), - wp_kses_post( $mail ) + '', + implode(' ', $sharer) ); } } diff --git a/src/meta-data/edit.js b/src/meta-data/edit.js index 059ee96b..67123872 100644 --- a/src/meta-data/edit.js +++ b/src/meta-data/edit.js @@ -119,6 +119,10 @@ export default function Edit( { attributes, setAttributes } ) { value: 'fab fa-facebook-f', label: 'Facebook', }, + { + value: 'fab fa-whatsapp', + label: 'WhatsApp', + }, { value: 'fab fa-threads', label: 'Threads', From 3be4dd1c0f3defa2c63ac95a95eada3364f4967a Mon Sep 17 00:00:00 2001 From: Alexander Bigga Date: Wed, 10 Jul 2024 20:48:55 +0200 Subject: [PATCH 2/3] Extend GitHub workflow for all dev branches --- .github/workflows/build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index a54abfb4..d39a8116 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -8,7 +8,7 @@ on: - main pull_request: branches: - - dev + - dev* - main env: From 717a0dc3f5be3c74d21dbe55baa09a2bc3a8a979 Mon Sep 17 00:00:00 2001 From: Alexander Bigga Date: Thu, 11 Jul 2024 11:36:24 +0200 Subject: [PATCH 3/3] Fix coding standard for new sharer --- inc/template-tags.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/template-tags.php b/inc/template-tags.php index bd993ecf..f9ad2602 100755 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -102,7 +102,7 @@ function sunflower_entry_footer( $show_sharers = false ) { */ function sunflower_the_social_media_sharers() { - $sharer = []; + $sharer = array(); if ( sunflower_get_setting( 'sunflower_sharer_twitter' ) || sunflower_get_setting( 'sunflower_sharer_x_twitter' ) ) { $sharer[] = sprintf( '', @@ -137,10 +137,10 @@ function sunflower_the_social_media_sharers() { ); } - if ( count($sharer) > 0 ) { + if ( count( $sharer ) > 0 ) { printf( '', - implode(' ', $sharer) + wp_kses_post( implode( ' ', $sharer ) ) ); } }