more settings

fixes #7 and #6
This commit is contained in:
Matthias Pfefferle 2018-12-28 22:40:57 +01:00
parent 1580b3d4b1
commit 962c95d934
3 changed files with 63 additions and 4 deletions

View file

@ -29,7 +29,26 @@ class Activitypub_Admin {
* Register PubSubHubbub settings
*/
public static function register_settings() {
register_setting( 'activitypub', 'activitypub_feed_use_excerpt' );
register_setting(
'activitypub', 'activitypub_add_summary', array(
'type' => 'boolean',
'description' => __( 'Adds a "summary" to the Activity-Objects', 'activitypub' ),
'show_in_rest' => true,
'default' => 0,
)
);
register_setting(
'activitypub', 'activitypub_object_type', array(
'type' => 'string',
'description' => __( 'The Activity-Object-Type', 'activitypub' ),
'show_in_rest' => array(
'schema' => array(
'enum' => array( 'note', 'article', 'wordpress-post-format' )
),
),
'default' => 'note',
)
);
}
public static function add_help_tab() {

View file

@ -27,7 +27,7 @@ class Activitypub_Post {
'type' => $this->get_object_type(),
'published' => date( 'Y-m-d\TH:i:s\Z', strtotime( $post->post_date ) ),
'attributedTo' => get_author_posts_url( $post->post_author ),
'summary' => apply_filters( 'the_excerpt', activitypub_get_the_excerpt( $post->ID, 400 ) ),
'summary' => get_option( 'activitypub_add_summary', false ) ? apply_filters( 'the_excerpt', activitypub_get_the_excerpt( $post->ID, 400 ) ) : null,
'inReplyTo' => null,
'content' => apply_filters( 'the_content', get_post_field( 'post_content', $post->ID ) ),
'contentMap' => array(
@ -120,7 +120,7 @@ class Activitypub_Post {
$tag = array(
"type" => "Hashtag",
"href" => get_tag_link( $post_tag->term_id ),
"name" => '#' . $post_tag->name,
"name" => '#' . $post_tag->slug,
);
$tags[] = $tag;
}
@ -138,6 +138,10 @@ class Activitypub_Post {
* @return string the object-type
*/
public function get_object_type() {
if ( get_option( 'activitypub_object_type', 'note' ) !== "wordpress-post-format" ) {
return ucfirst( get_option( 'activitypub_object_type', 'note' ) );
}
$post_type = get_post_type( $this->post );
switch ( $post_type ) {
case 'post':

View file

@ -6,6 +6,42 @@
<form method="post" action="options.php">
<?php settings_fields( 'activitypub' ); ?>
<h2><?php esc_html_e( 'Activities', 'activitypub' ); ?></h2>
<p><?php esc_html_e( 'All activity related settings.', 'activitypub' ); ?></p>
<table class="form-table">
<tbody>
<tr>
<th scope="row">
<label for="activitypub_add_summary"><?php esc_html_e( 'Add the Post-Summary', 'activitypub' ); ?></label>
</th>
<td>
<input type="checkbox" name="activitypub_add_summary" id="activitypub_add_summary" value="1" <?php echo checked( true, get_option( 'activitypub_add_summary', false ) ); ?> />
<?php printf( __( 'Adds the Post-Summary to the activity. Be aware, that Mastodon seems to use the "summary" as the "content warning" label.', 'activitypub' ) ); ?>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Activtity-Object-Type', 'activitypub' ); ?>
</th>
<td>
<p>
<label><input type="radio" name="activitypub_object_type" id="activitypub_object_type" value="note" <?php echo checked( 'note', get_option( 'activitypub_object_type', 'note' ) ); ?> /> <?php esc_html_e( 'Note (default)', 'activitypub' ); ?> - <span class="description"><?php esc_html_e( 'Should work with the most plattforms.', 'activitypub' ); ?></span>
</p>
<p>
<label><input type="radio" name="activitypub_object_type" id="activitypub_object_type" value="article" <?php echo checked( 'article', get_option( 'activitypub_object_type', 'note' ) ); ?> /> <?php esc_html_e( 'Article', 'activitypub' ); ?> - <span class="description"><?php esc_html_e( 'The presentation of the "Article" might change on different plattforms. Mastodon for example shows the "Article" type as a simple link.', 'activitypub' ); ?></span>
</p>
<p>
<label><input type="radio" name="activitypub_object_type" id="activitypub_object_type" value="wordpress-post-format" <?php echo checked( 'wordpress-post-format', get_option( 'activitypub_object_type', 'note' ) ); ?> /> <?php esc_html_e( 'WordPress Post-Format', 'activitypub' ); ?> - <span class="description"><?php esc_html_e( 'Maps the WordPress Post-Format to the ActivityPub Object Type.', 'activitypub' ); ?></span>
</p>
</td>
</tr>
</tbody>
</table>
<?php do_settings_fields( 'activitypub', 'activity' ); ?>
<h2><?php esc_html_e( 'Profile', 'activitypub' ); ?></h2>
<p><?php esc_html_e( 'All profile related settings.', 'activitypub' ); ?></p>
@ -55,7 +91,7 @@
<?php do_settings_sections( 'activitypub' ); ?>
<?php // submit_button(); ?>
<?php submit_button(); ?>
</form>
<p>