Skip to content

Commit

Permalink
Merge pull request #990 from Codeinwp/feat/yoast-full
Browse files Browse the repository at this point in the history
feat: add Yoast title & description
  • Loading branch information
selul authored Jul 11, 2024
2 parents c49e9ba + 4cd2a28 commit f3925a7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions includes/admin/helpers/class-rop-post-format-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions includes/class-rop-i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down
7 changes: 7 additions & 0 deletions vue/src/vue-elements/post-format.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@
>
{{ labels.post_content_option_yoast_seo_description }} {{ !isPro ? "(Pro)" : '' }}
</option>
<option
v-if="yoast_seo_active_status"
value="yoast_seo_title_description"
:disabled="!isPro"
>
{{ labels.post_content_option_yoast_seo_title_description }} {{ !isPro ? "(Pro)" : '' }}
</option>
</select>
</div>
</div>
Expand Down

0 comments on commit f3925a7

Please sign in to comment.