Merge pull request #85 from bgcarlisle/dev-new-content-type

Added new post type: "title and link only"
This commit is contained in:
Matthias Pfefferle 2020-02-11 10:07:34 +01:00 committed by GitHub
commit 5e3a71fa1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View file

@ -56,10 +56,10 @@ class Admin {
\register_setting( \register_setting(
'activitypub', 'activitypub_post_content_type', array( 'activitypub', 'activitypub_post_content_type', array(
'type' => 'string', 'type' => 'string',
'description' => \__( 'Use summary or full content', 'activitypub' ), 'description' => \__( 'Use title and link, summary or full content', 'activitypub' ),
'show_in_rest' => array( 'show_in_rest' => array(
'schema' => array( 'schema' => array(
'enum' => array( 'excerpt', 'content' ), 'enum' => array( 'title', 'excerpt', 'content' ),
), ),
), ),
'default' => 'content', 'default' => 'content',

View file

@ -204,6 +204,10 @@ class Post {
return $this->get_the_post_summary(); return $this->get_the_post_summary();
} }
if ( 'title' === \get_option( 'activitypub_post_content_type', 'content' ) ) {
return $this->get_the_title();
}
return $this->get_the_post_content(); return $this->get_the_post_content();
} }

View file

@ -17,6 +17,9 @@
<?php esc_html_e( 'Post-Content', 'activitypub' ); ?> <?php esc_html_e( 'Post-Content', 'activitypub' ); ?>
</th> </th>
<td> <td>
<p>
<label><input type="radio" name="activitypub_post_content_type" id="activitypub_post_content_type_title_link" value="title" <?php echo \checked( 'title', \get_option( 'activitypub_post_content_type', 'content' ) ); ?> /> <?php \esc_html_e( 'Title and link', 'activitypub' ); ?></label> - <span class="description"><?php \esc_html_e( 'Only the title and a link.', 'activitypub' ); ?></span>
</p>
<p> <p>
<label><input type="radio" name="activitypub_post_content_type" id="activitypub_post_content_type_excerpt" value="excerpt" <?php echo \checked( 'excerpt', \get_option( 'activitypub_post_content_type', 'content' ) ); ?> /> <?php \esc_html_e( 'Excerpt', 'activitypub' ); ?></label> - <span class="description"><?php \esc_html_e( 'A content summary, shortened to 400 characters and without markup.', 'activitypub' ); ?></span> <label><input type="radio" name="activitypub_post_content_type" id="activitypub_post_content_type_excerpt" value="excerpt" <?php echo \checked( 'excerpt', \get_option( 'activitypub_post_content_type', 'content' ) ); ?> /> <?php \esc_html_e( 'Excerpt', 'activitypub' ); ?></label> - <span class="description"><?php \esc_html_e( 'A content summary, shortened to 400 characters and without markup.', 'activitypub' ); ?></span>
</p> </p>