2022-12-02 20:44:56 +01:00
< ? php
\load_template (
2023-07-20 15:19:19 +02:00
__DIR__ . '/admin-header.php' ,
2022-12-02 20:44:56 +01:00
true ,
array (
2023-05-31 13:47:37 +02:00
'settings' => 'active' ,
'welcome' => '' ,
'followers' => '' ,
2022-12-02 20:44:56 +01:00
)
);
?>
2018-12-20 11:33:08 +01:00
2023-07-21 14:52:18 +02:00
< div class = " activitypub-settings activitypub-settings-page hide-if-no-js " >
2018-12-20 11:33:08 +01:00
< form method = " post " action = " options.php " >
2019-09-27 11:36:52 +02:00
< ? php \settings_fields ( 'activitypub' ); ?>
2018-12-20 11:33:08 +01:00
2023-07-21 14:52:18 +02:00
< div class = " box " >
2023-08-28 14:12:10 +02:00
< h3 >< ? php \esc_html_e ( 'Profiles' , 'activitypub' ); ?> </h3>
2023-07-21 14:52:18 +02:00
< table class = " form-table " >
< tbody >
< tr >
< th scope = " row " >
2023-08-28 14:12:10 +02:00
< ? php \esc_html_e ( 'Enable profiles by type' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ th >
< td >
< p >
< label >
< input type = " checkbox " name = " activitypub_enable_users " id = " activitypub_enable_users " value = " 1 " < ? php echo \checked ( '1' , \get_option ( 'activitypub_enable_users' , '1' ) ); ?> />
2023-08-28 14:12:10 +02:00
< ? php \esc_html_e ( 'Enable authors' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ label >
</ p >
< p class = " description " >
2023-08-28 14:12:10 +02:00
< ? php echo \wp_kses ( \__ ( 'Every author on this blog (with the <code>publish_posts</code> capability) gets their own ActivityPub profile.' , 'activitypub' ), array ( 'code' => array () ) ); ?>
2023-07-21 14:52:18 +02:00
</ p >
< p >
< label >
< input type = " checkbox " name = " activitypub_enable_blog_user " id = " activitypub_enable_blog_user " value = " 1 " < ? php echo \checked ( '1' , \get_option ( 'activitypub_enable_blog_user' , '0' ) ); ?> />
2023-08-28 14:12:10 +02:00
< ? php \esc_html_e ( 'Enable blog' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ label >
</ p >
< p class = " description " >
2023-08-28 14:12:10 +02:00
< ? php \esc_html_e ( 'Your blog becomes an ActivityPub profile.' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ p >
</ td >
</ tr >
< tr >
< th scope = " row " >
2023-08-28 14:12:10 +02:00
< ? php \esc_html_e ( 'Change blog profile ID' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ th >
< td >
< label for = " activitypub_blog_user_identifier " >
< input class = " blog-user-identifier " name = " activitypub_blog_user_identifier " id = " activitypub_blog_user_identifier " type = " text " value = " <?php echo esc_attr( \ get_option( 'activitypub_blog_user_identifier', \ Activitypub \ Model \ Blog_User::get_default_username() ) ); ?> " />
@< ? php echo esc_html ( \wp_parse_url ( \home_url (), PHP_URL_HOST ) ); ?>
2023-07-20 14:21:32 +02:00
</ label >
2023-07-21 14:52:18 +02:00
< p class = " description " >
2023-08-28 14:12:10 +02:00
< ? php \esc_html_e ( 'This profile name will federate all posts written on your blog, regardless of the author who posted it.' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ p >
2023-09-27 11:05:11 +02:00
< p >
< strong >
< ? php \esc_html_e ( 'Please avoid using an existing author’ s name as the blog profile ID. Fediverse platforms might use caching and this could break the functionality completely.' , 'activitypub' ); ?>
</ strong >
</ p >
2023-07-21 14:52:18 +02:00
</ td >
</ tr >
</ tbody >
</ table >
2023-07-20 14:21:32 +02:00
2023-07-21 14:52:18 +02:00
< ? php \do_settings_fields ( 'activitypub' , 'user' ); ?>
</ div >
2023-07-20 14:21:32 +02:00
2023-07-21 14:52:18 +02:00
< div class = " box " >
< h3 >< ? php \esc_html_e ( 'Activities' , 'activitypub' ); ?> </h3>
< table class = " form-table " >
< tbody >
< tr >
< th scope = " row " >
2023-08-28 14:12:10 +02:00
< ? php \esc_html_e ( 'Post content' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ th >
< td >
< p >
< label for = " activitypub_post_content_type_title_link " >
< 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' ); ?>
-
< span class = " description " >
< ? php \esc_html_e ( 'Only the title and a link.' , 'activitypub' ); ?>
</ span >
</ label >
</ p >
< p >
< label for = " activitypub_post_content_type_excerpt " >
< 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' ); ?>
-
< span class = " description " >
2023-11-26 21:18:03 +01:00
< ? php \esc_html_e ( 'A content summary without markup (truncated if no excerpt is provided).' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ span >
</ label >
</ p >
< p >
< label for = " activitypub_post_content_type_content " >
< input type = " radio " name = " activitypub_post_content_type " id = " activitypub_post_content_type_content " value = " content " < ? php echo \checked ( 'content' , \get_option ( 'activitypub_post_content_type' , 'content' ) ); ?> />
< ? php \esc_html_e ( 'Content (default)' , 'activitypub' ); ?>
-
< span class = " description " >
< ? php \esc_html_e ( 'The full content.' , 'activitypub' ); ?>
</ span >
</ label >
</ p >
< p >
< label for = " activitypub_post_content_type_custom " >
< input type = " radio " name = " activitypub_post_content_type " id = " activitypub_post_content_type_custom " value = " custom " < ? php echo \checked ( 'custom' , \get_option ( 'activitypub_post_content_type' , 'content' ) ); ?> />
< ? php \esc_html_e ( 'Custom' , 'activitypub' ); ?>
-
< span class = " description " >
2023-08-28 14:12:10 +02:00
< ? php \esc_html_e ( 'Use the text area below, to customize your activities.' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ span >
</ label >
</ p >
< p >
< textarea name = " activitypub_custom_post_content " id = " activitypub_custom_post_content " rows = " 10 " cols = " 50 " class = " large-text " placeholder = " <?php echo wp_kses( ACTIVITYPUB_CUSTOM_POST_CONTENT, 'post' ); ?> " >< ? php echo wp_kses ( \get_option ( 'activitypub_custom_post_content' , ACTIVITYPUB_CUSTOM_POST_CONTENT ), 'post' ); ?> </textarea>
< details >
< summary >< ? php esc_html_e ( 'See a list of ActivityPub Template Tags.' , 'activitypub' ); ?> </summary>
< div class = " description " >
< ul >
< li >< code > [ ap_title ] </ code > - < ? php \esc_html_e ( 'The post\'s title.' , 'activitypub' ); ?> </li>
< li >< code > [ ap_content ] </ code > - < ? php \esc_html_e ( 'The post\'s content.' , 'activitypub' ); ?> </li>
2023-11-26 21:18:03 +01:00
< li >< code > [ ap_excerpt ] </ code > - < ? php \esc_html_e ( 'The post\'s excerpt (may be truncated).' , 'activitypub' ); ?> </li>
2023-07-21 14:52:18 +02:00
< li >< code > [ ap_permalink ] </ code > - < ? php \esc_html_e ( 'The post\'s permalink.' , 'activitypub' ); ?> </li>
< li >< code > [ ap_shortlink ] </ code > - < ? php echo \wp_kses ( \__ ( 'The post\'s shortlink. I can recommend <a href="https://wordpress.org/plugins/hum/" target="_blank">Hum</a>.' , 'activitypub' ), 'default' ); ?> </li>
< li >< code > [ ap_hashtags ] </ code > - < ? php \esc_html_e ( 'The post\'s tags as hashtags.' , 'activitypub' ); ?> </li>
</ ul >
< p >< ? php \esc_html_e ( 'You can find the full list with all possible attributes in the help section on the top-right of the screen.' , 'activitypub' ); ?> </p>
</ div >
</ details >
</ p >
</ td >
</ tr >
< tr >
< th scope = " row " >
2023-10-27 22:55:44 +02:00
< ? php \esc_html_e ( 'Media attachments' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ th >
< td >
< input value = " <?php echo esc_attr( \ get_option( 'activitypub_max_image_attachments', ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS ) ); ?> " name = " activitypub_max_image_attachments " id = " activitypub_max_image_attachments " type = " number " min = " 0 " />
< p class = " description " >
< ? php
echo \wp_kses (
\sprintf (
// translators:
2023-10-27 22:55:44 +02:00
\__ ( 'The number of media (images, audio, video) to attach to posts. Default: <code>%s</code>' , 'activitypub' ),
2023-07-21 14:52:18 +02:00
\esc_html ( ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS )
),
'default'
);
?>
</ p >
2023-10-27 22:55:44 +02:00
< p class = " description " >
< em >
< ? php
esc_html_e ( 'Note: audio and video attachments are only supported from Block Editor.' , 'activitypub' );
?>
</ em >
</ p >
2023-07-21 14:52:18 +02:00
</ td >
</ tr >
< tr >
< th scope = " row " >
< ? php \esc_html_e ( 'Activity-Object-Type' , 'activitypub' ); ?>
</ th >
< td >
< p >
< label for = " activitypub_object_type_note " >
< input type = " radio " name = " activitypub_object_type " id = " activitypub_object_type_note " 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 most platforms.' , 'activitypub' ); ?>
</ span >
</ label >
</ p >
2023-08-09 11:17:33 +02:00
< p >< strong >< ? php \esc_html_e ( 'Please note that the following "Activity-Object-Type" options may cause your texts to be displayed differently on each platform and/or parts may be completely ignored. Mastodon, for example, displays all content that is not of the "Note" type as links only.' , 'activitypub' ); ?> </strong></p>
2023-07-21 14:52:18 +02:00
< p >
< label for = " activitypub_object_type_article " >
< input type = " radio " name = " activitypub_object_type " id = " activitypub_object_type_article " value = " article " < ? php echo \checked ( 'article' , \get_option ( 'activitypub_object_type' , 'note' ) ); ?> />
< ? php \esc_html_e ( 'Article' , 'activitypub' ); ?>
-
< span class = " description " >
2023-08-09 11:17:33 +02:00
< ? php \esc_html_e ( 'The presentation of the "Article" might change on different platforms.' , 'activitypub' ); ?>
2023-07-21 14:52:18 +02:00
</ span >
</ label >
</ 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 >
</ label >
</ p >
</ td >
</ tr >
< tr >
< th scope = " row " >
< ? php \esc_html_e ( 'Hashtags (beta)' , 'activitypub' ); ?>
</ th >
< td >
< p >
2023-08-28 14:12:10 +02:00
< label >< input type = " checkbox " name = " activitypub_use_hashtags " id = " activitypub_use_hashtags " value = " 1 " < ? php echo \checked ( '1' , \get_option ( 'activitypub_use_hashtags' , '1' ) ); ?> /> <?php echo wp_kses( \__( 'Add hashtags in the content as native tags and replace the <code>#tag</code> with the tag link. <strong>This feature is experimental! Please disable it, if you find any HTML or CSS errors.</strong>', 'activitypub' ), 'default' ); ?></label>
2023-07-21 14:52:18 +02:00
</ p >
</ td >
</ tr >
</ tbody >
</ table >
2019-02-17 21:27:20 +01:00
2023-07-21 14:52:18 +02:00
< ? php \do_settings_fields ( 'activitypub' , 'activity' ); ?>
</ div >
2023-11-22 13:59:39 +01:00
2023-11-20 18:15:54 +01:00
<!-- OUR FORK HERE -->
< div class = " box " >
< h3 >< ? php \esc_html_e ( 'Enable ActivityPub support for post type' , 'activitypub' ); ?> </h3>
< table class = " form-table " >
< tbody >
< tr >
< th scope = " row " >
< ? php \esc_html_e ( 'Mapping' , 'activitypub' ); ?>
</ th >
< td >
< ? php \esc_html_e ( 'Enable ActivityPub support for a certain post type by selecting one of the available ActivityPub transformers.' , 'activitypub' ); ?>
< ? php $all_public_post_types = \get_post_types ( array ( 'public' => true ), 'objects' );
$transformer_mapping = \get_option ( 'activitypub_transformer_mapping' , array ( 'default' => 'note' ) );
$all_public_post_type_names = array_map ( function ( $object ) {
return $object -> name ;
}, $all_public_post_types );
2023-11-30 08:36:05 +01:00
$transformer_manager = \Activitypub\Transformer\Transformer_Factory :: instance ();
2023-11-20 18:15:54 +01:00
$transformers = $transformer_manager -> get_transformers ();
?>
2023-11-22 13:59:39 +01:00
2023-11-20 18:15:54 +01:00
< script >
// TODO Probably we should use checkboxes and not select and make this less buggy and insert the js at the right place.
document . addEventListener ( 'DOMContentLoaded' , function () {
var radioGroups = {};
var radioButtons = document . querySelectorAll ( 'input[type="radio"]' );
2023-11-22 13:59:39 +01:00
2023-11-20 18:15:54 +01:00
radioButtons . forEach ( function ( radioButton ) {
radioButton . addEventListener ( 'click' , function () {
var name = this . name ;
if ( ! radioGroups [ name ]) {
radioGroups [ name ] = this ;
} else {
radioGroups [ name ] . checked = false ;
radioGroups [ name ] = this ;
}
});
});
});
</ script >
< table >
< thead >
< tr >
< th ></ th >
< ? php
// Generate column headers based on transformer objects
foreach ( $transformers as $transformer ) {
echo '<th>' . htmlspecialchars ( $transformer -> get_label ()) . '</th>' ;
}
?>
</ tr >
</ thead >
< tbody >
< ? php
// Generate rows based on post types and transformers
foreach ( $all_public_post_types as $post_type ) {
echo '<tr>' ;
echo '<td><strong>' . htmlspecialchars ( $post_type -> label ) . '</strong></td>' ;
// Generate radio inputs for each transformer, considering support for the post type
foreach ( $transformers as $transformer ) {
$disabled_attribute = $transformer -> supports_post_type ( $post_type -> name ) ? '' : ' disabled' ;
2023-11-22 13:59:39 +01:00
$is_selected = ( is_array ( $transformer_mapping ) && isset ( $transformer_mapping [ $post_type -> name ] ) && $transformer_mapping [ $post_type -> name ] === $transformer -> get_name () ) ? ' checked ' : '' ;
2023-11-20 18:15:54 +01:00
echo '<td><input type="radio" name="activitypub_transformer_mapping[' . $post_type -> name . ']" value="' . $transformer -> get_name () . '"' . $is_selected . $disabled_attribute . '></td>' ;
}
echo '</tr>' ;
}
?>
</ tbody >
</ table >
2023-11-22 13:59:39 +01:00
2023-11-20 18:15:54 +01:00
</ td >
</ tr >
</ tbody >
</ table >
</ div >
<!-- OUR FORK ENDS HERE -->
2020-02-21 11:09:31 +01:00
2023-07-21 14:52:18 +02:00
< div class = " box " >
< h3 >< ? php \esc_html_e ( 'Server' , 'activitypub' ); ?> </h3>
< table class = " form-table " >
< tbody >
< tr >
< th scope = " row " >
< ? php \esc_html_e ( 'Blocklist' , 'activitypub' ); ?>
</ th >
< td >
< p class = " description " >
< ? php
echo \wp_kses (
\sprintf (
// translators: %s is a URL.
\__ ( 'To block servers, add the host of the server to the "<a href="%s">Disallowed Comment Keys</a>" list.' , 'activitypub' ),
\esc_attr ( \admin_url ( 'options-discussion.php#disallowed_keys' ) )
),
'default'
);
?>
</ p >
</ td >
</ tr >
</ tbody >
</ table >
2020-02-21 11:09:31 +01:00
2023-07-21 14:52:18 +02:00
< ? php \do_settings_fields ( 'activitypub' , 'server' ); ?>
</ div >
2019-09-27 11:36:52 +02:00
< ? php \do_settings_sections ( 'activitypub' ); ?>
2018-12-20 11:33:08 +01:00
2019-09-27 11:36:52 +02:00
< ? php \submit_button (); ?>
2018-12-20 11:33:08 +01:00
</ form >
</ div >