From 4cd2a28da6e2cb2663a1a191b5273d2ba2d9f779 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Wed, 10 Jul 2024 18:15:17 +0300 Subject: [PATCH] feat: add Yoast title & description --- .../helpers/class-rop-post-format-helper.php | 16 ++++++++++++++++ includes/class-rop-i18n.php | 1 + vue/src/vue-elements/post-format.vue | 7 +++++++ 3 files changed, 24 insertions(+) diff --git a/includes/admin/helpers/class-rop-post-format-helper.php b/includes/admin/helpers/class-rop-post-format-helper.php index bc99d775d..11eb7cdf7 100644 --- a/includes/admin/helpers/class-rop-post-format-helper.php +++ b/includes/admin/helpers/class-rop-post-format-helper.php @@ -316,6 +316,22 @@ private function build_base_content( $post_id ) { $content = $post_content; } break; + case 'yoast_seo_title_description': + if ( function_exists( 'YoastSEO' ) ) { + $title = YoastSEO()->meta->for_post( $post_id )->title; + $description = YoastSEO()->meta->for_post( $post_id )->description; + + // This is empty if user doesn't add a custom description + // So lets fall back to post content + if ( empty( $description ) ) { + $description = $post_content; + } + + $content = $title . ' ' . $description; + } else { + $content = $post_title . apply_filters( 'rop_title_content_separator', ' ' ) . $post_content; + } + break; default: $content = $post_title; break; diff --git a/includes/class-rop-i18n.php b/includes/class-rop-i18n.php index b9677cb8b..fd0b5fd56 100644 --- a/includes/class-rop-i18n.php +++ b/includes/class-rop-i18n.php @@ -225,6 +225,7 @@ public static function get_labels( $key = '' ) { 'post_content_option_custom_field' => __( 'Custom Field', 'tweet-old-post' ), 'post_content_option_yoast_seo_title' => __( 'Yoast SEO Title', 'tweet-old-post' ), 'post_content_option_yoast_seo_description' => __( 'Yoast SEO Description', 'tweet-old-post' ), + 'post_content_option_yoast_seo_title_description' => __( 'Yoast SEO Title & Description', 'tweet-old-post' ), 'custom_meta_title' => __( 'Custom Meta Field', 'tweet-old-post' ), 'custom_meta_desc' => __( 'Meta field name from which to get the content.', 'tweet-old-post' ), 'max_char_title' => __( 'Maximum Characters', 'tweet-old-post' ), diff --git a/vue/src/vue-elements/post-format.vue b/vue/src/vue-elements/post-format.vue index efc5fbd4c..344d739d7 100644 --- a/vue/src/vue-elements/post-format.vue +++ b/vue/src/vue-elements/post-format.vue @@ -85,6 +85,13 @@ > {{ labels.post_content_option_yoast_seo_description }} {{ !isPro ? "(Pro)" : '' }} +