From d7a2b9a23712c1c227f4d19976e8aa94037d847d Mon Sep 17 00:00:00 2001 From: bgcarlisle Date: Wed, 22 Jan 2020 15:57:01 +0100 Subject: [PATCH] Added new post type: "title and link only" --- includes/class-admin.php | 4 ++-- includes/model/class-post.php | 4 ++++ templates/settings.php | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/includes/class-admin.php b/includes/class-admin.php index fbdf85d..658c861 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -56,10 +56,10 @@ class Admin { \register_setting( 'activitypub', 'activitypub_post_content_type', array( 'type' => 'string', - 'description' => \__( 'Use summary or full content', 'activitypub' ), + 'description' => \__( 'Use title and link, summary or full content', 'activitypub' ), 'show_in_rest' => array( 'schema' => array( - 'enum' => array( 'excerpt', 'content' ), + 'enum' => array( 'titlelink', 'excerpt', 'content' ), ), ), 'default' => 'content', diff --git a/includes/model/class-post.php b/includes/model/class-post.php index f27e3d1..e196ae5 100644 --- a/includes/model/class-post.php +++ b/includes/model/class-post.php @@ -204,6 +204,10 @@ class Post { return $this->get_the_post_summary(); } + if ( 'titlelink' === \get_option( 'activitypub_post_content_type', 'content' ) ) { + return $this->get_the_title(); + } + return $this->get_the_post_content(); } diff --git a/templates/settings.php b/templates/settings.php index e4e9532..3e34051 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -17,7 +17,10 @@ -

+

+ - +

+

-