Skip to content

Commit 962c95d

Browse files
committed
more settings
fixes #7 and #6
1 parent 1580b3d commit 962c95d

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
lines changed

includes/class-activitypub-admin.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,26 @@ public static function settings_page() {
2929
* Register PubSubHubbub settings
3030
*/
3131
public static function register_settings() {
32-
register_setting( 'activitypub', 'activitypub_feed_use_excerpt' );
32+
register_setting(
33+
'activitypub', 'activitypub_add_summary', array(
34+
'type' => 'boolean',
35+
'description' => __( 'Adds a "summary" to the Activity-Objects', 'activitypub' ),
36+
'show_in_rest' => true,
37+
'default' => 0,
38+
)
39+
);
40+
register_setting(
41+
'activitypub', 'activitypub_object_type', array(
42+
'type' => 'string',
43+
'description' => __( 'The Activity-Object-Type', 'activitypub' ),
44+
'show_in_rest' => array(
45+
'schema' => array(
46+
'enum' => array( 'note', 'article', 'wordpress-post-format' )
47+
),
48+
),
49+
'default' => 'note',
50+
)
51+
);
3352
}
3453

3554
public static function add_help_tab() {

includes/class-activitypub-post.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function to_array() {
2727
'type' => $this->get_object_type(),
2828
'published' => date( 'Y-m-d\TH:i:s\Z', strtotime( $post->post_date ) ),
2929
'attributedTo' => get_author_posts_url( $post->post_author ),
30-
'summary' => apply_filters( 'the_excerpt', activitypub_get_the_excerpt( $post->ID, 400 ) ),
30+
'summary' => get_option( 'activitypub_add_summary', false ) ? apply_filters( 'the_excerpt', activitypub_get_the_excerpt( $post->ID, 400 ) ) : null,
3131
'inReplyTo' => null,
3232
'content' => apply_filters( 'the_content', get_post_field( 'post_content', $post->ID ) ),
3333
'contentMap' => array(
@@ -120,7 +120,7 @@ public function get_tags() {
120120
$tag = array(
121121
"type" => "Hashtag",
122122
"href" => get_tag_link( $post_tag->term_id ),
123-
"name" => '#' . $post_tag->name,
123+
"name" => '#' . $post_tag->slug,
124124
);
125125
$tags[] = $tag;
126126
}
@@ -138,6 +138,10 @@ public function get_tags() {
138138
* @return string the object-type
139139
*/
140140
public function get_object_type() {
141+
if ( get_option( 'activitypub_object_type', 'note' ) !== "wordpress-post-format" ) {
142+
return ucfirst( get_option( 'activitypub_object_type', 'note' ) );
143+
}
144+
141145
$post_type = get_post_type( $this->post );
142146
switch ( $post_type ) {
143147
case 'post':

templates/settings-page.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,42 @@
66
<form method="post" action="options.php">
77
<?php settings_fields( 'activitypub' ); ?>
88

9+
<h2><?php esc_html_e( 'Activities', 'activitypub' ); ?></h2>
10+
11+
<p><?php esc_html_e( 'All activity related settings.', 'activitypub' ); ?></p>
12+
13+
<table class="form-table">
14+
<tbody>
15+
<tr>
16+
<th scope="row">
17+
<label for="activitypub_add_summary"><?php esc_html_e( 'Add the Post-Summary', 'activitypub' ); ?></label>
18+
</th>
19+
<td>
20+
<input type="checkbox" name="activitypub_add_summary" id="activitypub_add_summary" value="1" <?php echo checked( true, get_option( 'activitypub_add_summary', false ) ); ?> />
21+
<?php printf( __( 'Adds the Post-Summary to the activity. Be aware, that Mastodon seems to use the "summary" as the "content warning" label.', 'activitypub' ) ); ?>
22+
</td>
23+
</tr>
24+
<tr>
25+
<th scope="row">
26+
<?php esc_html_e( 'Activtity-Object-Type', 'activitypub' ); ?>
27+
</th>
28+
<td>
29+
<p>
30+
<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>
31+
</p>
32+
<p>
33+
<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>
34+
</p>
35+
<p>
36+
<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>
37+
</p>
38+
</td>
39+
</tr>
40+
</tbody>
41+
</table>
42+
43+
<?php do_settings_fields( 'activitypub', 'activity' ); ?>
44+
945
<h2><?php esc_html_e( 'Profile', 'activitypub' ); ?></h2>
1046

1147
<p><?php esc_html_e( 'All profile related settings.', 'activitypub' ); ?></p>
@@ -55,7 +91,7 @@
5591

5692
<?php do_settings_sections( 'activitypub' ); ?>
5793

58-
<?php // submit_button(); ?>
94+
<?php submit_button(); ?>
5995
</form>
6096

6197
<p>

0 commit comments

Comments
 (0)