add support for custom post content

fix #97 #91
This commit is contained in:
Matthias Pfefferle 2020-07-21 09:23:35 +02:00
parent 2a1cc45124
commit d260d7c276
11 changed files with 461 additions and 168 deletions

View file

@ -20,18 +20,19 @@ namespace Activitypub;
*/
function init() {
\defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || \define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|^)#(\w*[A-Za-z_]+\w*)' );
\defined( 'ACTIVITYPUB_ALLOWED_HTML' ) || \define( 'ACTIVITYPUB_ALLOWED_HTML', '<strong><a><p><ul><ol><li><code><blockquote><pre><img>' );
\defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "<p><strong>%title%</strong></p>\n\n%content%\n\n<p>%hashtags%</p>\n\n<p>%shortlink%</p>" );
require_once \dirname( __FILE__ ) . '/includes/table/followers-list.php';
require_once \dirname( __FILE__ ) . '/includes/class-signature.php';
require_once \dirname( __FILE__ ) . '/includes/peer/class-followers.php';
require_once \dirname( __FILE__ ) . '/includes/functions.php';
require_once \dirname( __FILE__ ) . '/includes/class-activity-dispatcher.php';
\Activitypub\Activity_Dispatcher::init();
require_once \dirname( __FILE__ ) . '/includes/model/class-activity.php';
require_once \dirname( __FILE__ ) . '/includes/model/class-post.php';
\Activitypub\Model\Post::init();
require_once \dirname( __FILE__ ) . '/includes/class-activity-dispatcher.php';
\Activitypub\Activity_Dispatcher::init();
require_once \dirname( __FILE__ ) . '/includes/class-activitypub.php';
\Activitypub\Activitypub::init();
@ -53,7 +54,7 @@ function init() {
\Activitypub\Rest\Webfinger::init();
// load NodeInfo endpoints only if blog is public
if ( 1 === get_option( 'blog_public', 1 ) ) {
if ( 1 === \get_option( 'blog_public', 1 ) ) {
require_once \dirname( __FILE__ ) . '/includes/rest/class-nodeinfo.php';
\Activitypub\Rest\NodeInfo::init();
}

View file

@ -56,7 +56,7 @@ class Admin {
\register_setting(
'activitypub', 'activitypub_post_content_type', array(
'type' => 'string',
'description' => \__( 'Use title and link, summary or full content', 'activitypub' ),
'description' => \__( 'Use title and link, summary, full or custom content', 'activitypub' ),
'show_in_rest' => array(
'schema' => array(
'enum' => array( 'title', 'excerpt', 'content' ),
@ -65,6 +65,14 @@ class Admin {
'default' => 'content',
)
);
\register_setting(
'activitypub', 'activitypub_custom_post_content', array(
'type' => 'string',
'description' => \__( 'Define your own custom post template', 'activitypub' ),
'show_in_rest' => true,
'default' => ACTIVITYPUB_CUSTOM_POST_CONTENT,
)
);
\register_setting(
'activitypub', 'activitypub_object_type', array(
'type' => 'string',
@ -77,13 +85,6 @@ class Admin {
'default' => 'note',
)
);
\register_setting(
'activitypub', 'activitypub_use_shortlink', array(
'type' => 'boolean',
'description' => \__( 'Use the Shortlink instead of the permalink', 'activitypub' ),
'default' => 0,
)
);
\register_setting(
'activitypub', 'activitypub_use_hashtags', array(
'type' => 'boolean',
@ -92,10 +93,10 @@ class Admin {
)
);
\register_setting(
'activitypub', 'activitypub_add_tags_as_hashtags', array(
'type' => 'boolean',
'description' => \__( 'Add all tags as hashtags at the end of each activity', 'activitypub' ),
'default' => 0,
'activitypub', 'activitypub_allowed_html', array(
'type' => 'string',
'description' => \__( 'List of HTML elements that are allowed in activities.', 'activitypub' ),
'default' => ACTIVITYPUB_ALLOWED_HTML,
)
);
\register_setting(

View file

@ -15,10 +15,6 @@ class Hashtag {
\add_filter( 'wp_insert_post', array( '\Activitypub\Hashtag', 'insert_post' ), 99, 2 );
\add_filter( 'the_content', array( '\Activitypub\Hashtag', 'the_content' ), 99, 2 );
}
if ( '1' === \get_option( 'activitypub_add_tags_as_hashtags', '0' ) ) {
\add_filter( 'activitypub_the_summary', array( '\Activitypub\Hashtag', 'add_hashtags_to_content' ), 10, 2 );
\add_filter( 'activitypub_the_content', array( '\Activitypub\Hashtag', 'add_hashtags_to_content' ), 10, 2 );
}
}
/**
@ -69,28 +65,4 @@ class Hashtag {
return '#' . $tag;
}
/**
* Adds all tags as hashtags to the post/summary content
*
* @param string $content
* @param WP_Post $post
*
* @return string
*/
public static function add_hashtags_to_content( $content, $post ) {
$tags = \get_the_tags( $post->ID );
if ( ! $tags ) {
return $content;
}
$hash_tags = array();
foreach ( $tags as $tag ) {
$hash_tags[] = \sprintf( '<a rel="tag" class="u-tag u-category" href="%s">#%s</a>', \get_tag_link( $tag ), $tag->slug );
}
return $content . '<p>' . \implode( ' ', $hash_tags ) . '</p>';
}
}

View file

@ -8,5 +8,76 @@ namespace Activitypub;
*/
class Health_Check {
public static function init() {
\add_filter( 'site_status_tests', array( '\Activitypub\Health_Check', 'add_tests' ) );
}
public static function add_tests( $tests ) {
$tests['direct']['activitypub_test_profile_url'] = array(
'label' => \__( 'Profile URL test', 'activitypub' ),
'test' => array( '\Activitypub\Health_Check', 'test_profile_url' ),
);
//$tests['direct']['activitypub_test_profile_url2'] = array(
// 'label' => __( 'Profile URL Test', 'activitypub' ),
// 'test' => array( '\Activitypub\Health_Check', 'test_profile_url' ),
//);
return $tests;
}
public static function test_profile_url() {
$result = array(
'label' => \__( 'Profile URL accessible', 'activitypub' ),
'status' => 'good',
'badge' => array(
'label' => \__( 'ActivityPub', 'activitypub' ),
'color' => 'green',
),
'description' => \sprintf(
'<p>%s</p>',
\__( 'Your profile URL is accessible and do not redirect to the home page.', 'activitypub' )
),
'actions' => '',
'test' => 'test_profile_url',
);
$enum = self::is_profile_url_accessible();
if ( true !== $enum ) {
$result['status'] = 'critical';
$result['label'] = \__( 'Profile URL is not accessible', 'activitypub' );
$result['description'] = \sprintf(
'<p>%s</p>',
\__( 'Authorization Headers are being blocked by your hosting provider. This will cause IndieAuth to fail.', 'activitypub' )
);
}
return $result;
}
public static function is_profile_url_accessible() {
$user = \wp_get_current_user();
$author_url = \get_author_posts_url( $user->ID );
// check for "author" in URL
if ( false === \strpos( $author_url, 'author' ) ) {
return false;
}
// try to access author URL
$response = \wp_remote_get( $author_url, array( 'headers' => array( 'Accept' => 'application/activity+json' ) ) );
if ( \is_wp_error( $response ) ) {
return false;
}
// check if response is JSON
$body = \wp_remote_retrieve_body( $response );
if ( ! \is_string( $body ) || ! \is_array( \json_decode( $body, true ) ) ) {
return false;
}
return true;
}
}

View file

@ -64,6 +64,14 @@ class Activity {
}
public function to_comment() {
}
public function from_remote_array( $array ) {
}
public function to_array() {
$array = \get_object_vars( $this );
@ -76,6 +84,11 @@ class Activity {
return $array;
}
/**
* Convert to JSON
*
* @return void
*/
public function to_json() {
return \wp_json_encode( $this->to_array(), \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_QUOT );
}

View file

@ -9,26 +9,18 @@ namespace Activitypub\Model;
class Post {
private $post;
private $post_author;
private $permalink;
private $id;
private $summary;
private $content;
private $attachments;
private $tags;
private $object_type;
/**
* Initialize the class, registering WordPress hooks
*/
public static function init() {
\add_filter( 'activitypub_the_summary', array( '\Activitypub\Model\Post', 'add_backlink_to_content' ), 15, 2 );
\add_filter( 'activitypub_the_content', array( '\Activitypub\Model\Post', 'add_backlink_to_content' ), 15, 2 );
}
public function __construct( $post = null ) {
$this->post = \get_post( $post );
$this->post_author = $this->post->post_author;
$this->permalink = $this->generate_permalink();
$this->id = $this->generate_id();
$this->summary = $this->generate_the_title();
$this->content = $this->generate_the_content();
$this->attachments = $this->generate_attachments();
@ -52,7 +44,7 @@ class Post {
$post = $this->post;
$array = array(
'id' => $this->permalink,
'id' => $this->id,
'type' => $this->object_type,
'published' => \date( 'Y-m-d\TH:i:s\Z', \strtotime( $post->post_date ) ),
'attributedTo' => \get_author_posts_url( $post->post_author ),
@ -75,7 +67,7 @@ class Post {
return \wp_json_encode( $this->to_array(), \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_QUOT );
}
public function generate_permalink() {
public function generate_id() {
$post = $this->post;
$permalink = \get_permalink( $post );
@ -227,25 +219,44 @@ class Post {
}
public function generate_the_content() {
$post = $this->post;
$content = $this->get_post_content_template();
$content = \str_replace( '%title%', \get_the_title( $post->ID ), $content );
$content = \str_replace( '%excerpt%', $this->get_the_post_excerpt(), $content );
$content = \str_replace( '%content%', $this->get_the_post_content(), $content );
$content = \str_replace( '%permalink%', $this->get_the_post_link( 'permalink' ), $content );
$content = \str_replace( '%shortlink%', $this->get_the_post_link( 'shortlink' ), $content );
$content = \str_replace( '%tags%', $this->get_the_post_hashtags(), $content );
$content = \trim( \preg_replace( '/[\r\n]{2,}/', '', $content ) );
$filtered_content = \apply_filters( 'activitypub_the_content', $content, $this->post );
$decoded_content = \html_entity_decode( $filtered_content, \ENT_QUOTES, 'UTF-8' );
$allowed_html = \apply_filters( 'activitypub_allowed_html', \get_option( 'activitypub_allowed_html', ACTIVITYPUB_ALLOWED_HTML ) );
if ( $allowed_html ) {
return \strip_tags( $decoded_content, $allowed_html );
}
return $decoded_content;
}
public function get_post_content_template() {
if ( 'excerpt' === \get_option( 'activitypub_post_content_type', 'content' ) ) {
return $this->generate_the_post_summary();
return "%excerpt%\n\n<p>%permalink%</p>";
}
if ( 'title' === \get_option( 'activitypub_post_content_type', 'content' ) ) {
return $this->generate_the_title();
return "<p><strong>%title%</strong></p>\n\n<p>%permalink%</p>";
}
return $this->generate_the_post_content();
}
public function generate_the_title() {
if ( 'Article' === $this->generate_object_type() ) {
$title = \generate_the_title( $this->post );
return \html_entity_decode( $title, \ENT_QUOTES, 'UTF-8' );
if ( 'content' === \get_option( 'activitypub_post_content_type', 'content' ) ) {
return "%content%\n\n<p>%tags%</p>\n\n<p>%permalink%</p>";
}
return null;
return \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT );
}
/**
@ -255,7 +266,7 @@ class Post {
*
* @return string The excerpt.
*/
public function generate_the_post_excerpt( $excerpt_length = 400 ) {
public function get_the_post_excerpt( $excerpt_length = 400 ) {
$post = $this->post;
$excerpt = \get_post_field( 'post_excerpt', $post );
@ -282,7 +293,7 @@ class Post {
}
}
return $excerpt;
return \apply_filters( 'the_excerpt', $excerpt );
}
/**
@ -290,39 +301,12 @@ class Post {
*
* @return string The content.
*/
public function generate_the_post_content() {
public function get_the_post_content() {
$post = $this->post;
$content = \get_post_field( 'post_content', $post );
$filtered_content = \apply_filters( 'the_content', $content );
$filtered_content = \apply_filters( 'activitypub_the_content', $filtered_content, $this->post );
$decoded_content = \html_entity_decode( $filtered_content, \ENT_QUOTES, 'UTF-8' );
$allowed_html = \apply_filters( 'activitypub_allowed_html', '<a><p><ul><ol><li><code><blockquote><pre><img>' );
return \trim( \preg_replace( '/[\r\n]{2,}/', '', \strip_tags( $decoded_content, $allowed_html ) ) );
}
/**
* Get the excerpt for a post for use outside of the loop.
*
* @param int Optional excerpt length.
*
* @return string The excerpt.
*/
public function generate_the_post_summary( $summary_length = 400 ) {
$summary = $this->generate_the_post_excerpt( $summary_length );
$filtered_summary = \apply_filters( 'the_excerpt', $summary );
$filtered_summary = \apply_filters( 'activitypub_the_summary', $filtered_summary, $this->post );
$decoded_summary = \html_entity_decode( $filtered_summary, \ENT_QUOTES, 'UTF-8' );
$allowed_html = \apply_filters( 'activitypub_allowed_html', '<a><p>' );
return \trim( \preg_replace( '/[\r\n]{2,}/', '', \strip_tags( $decoded_summary, $allowed_html ) ) );
return \apply_filters( 'the_content', $content );
}
/**
@ -333,15 +317,42 @@ class Post {
*
* @return string
*/
public static function add_backlink_to_content( $content, $post ) {
$link = '';
public function get_the_post_link( $type = 'permalink' ) {
$post = $this->post;
if ( \get_option( 'activitypub_use_shortlink', 0 ) ) {
if ( 'shortlink' === $type ) {
$link = \esc_url( \wp_get_shortlink( $post->ID ) );
} else {
} elseif ( 'permalink' === $type ) {
$link = \esc_url( \get_permalink( $post->ID ) );
} else {
return '';
}
return $content . '<p><a href="' . $link . '">' . $link . '</a></p>';
return \sprintf( '<a href="%1$s">%1$s</a>', $link );
}
/**
* Adds all tags as hashtags to the post/summary content
*
* @param string $content
* @param WP_Post $post
*
* @return string
*/
public function get_the_post_hashtags() {
$post = $this->post;
$tags = \get_the_tags( $post->ID );
if ( ! $tags ) {
return '';
}
$hash_tags = array();
foreach ( $tags as $tag ) {
$hash_tags[] = \sprintf( '<a rel="tag" class="u-tag u-category" href="%s">#%s</a>', \get_tag_link( $tag ), $tag->slug );
}
return \implode( ' ', $hash_tags );
}
}

View file

@ -0,0 +1,67 @@
<?php
namespace Activitypub\Peer;
/**
* ActivityPub Users DB-Class
*
* @author Matthias Pfefferle
*/
class Users {
/**
* Undocumented function
*
* @return void
*/
public static function get_user_by_various( $data ) {
}
/**
* Examine a url and try to determine the author ID it represents.
*
* Checks are supposedly from the hosted site blog.
*
* @param string $url Permalink to check.
*
* @return int User ID, or 0 on failure.
*/
public static function url_to_authorid( $url ) {
global $wp_rewrite;
// check if url hase the same host
if ( \wp_parse_url( \site_url(), \PHP_URL_HOST ) !== \wp_parse_url( $url, \PHP_URL_HOST ) ) {
return 0;
}
// first, check to see if there is a 'author=N' to match against
if ( \preg_match( '/[?&]author=(\d+)/i', $url, $values ) ) {
$id = \absint( $values[1] );
if ( $id ) {
return $id;
}
}
// check to see if we are using rewrite rules
$rewrite = $wp_rewrite->wp_rewrite_rules();
// not using rewrite rules, and 'author=N' method failed, so we're out of options
if ( empty( $rewrite ) ) {
return 0;
}
// generate rewrite rule for the author url
$author_rewrite = $wp_rewrite->get_author_permastruct();
$author_regexp = \str_replace( '%author%', '', $author_rewrite );
// match the rewrite rule with the passed url
if ( \preg_match( '/https?:\/\/(.+)' . \preg_quote( $author_regexp, '/' ) . '([^\/]+)/i', $url, $match ) ) {
$user = \get_user_by( 'slug', $match[2] );
if ( $user ) {
return $user->ID;
}
}
return 0;
}
}

View file

@ -31,6 +31,7 @@ class Inbox {
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => array( '\Activitypub\Rest\Inbox', 'shared_inbox' ),
'args' => self::shared_inbox_request_parameters(),
),
)
);
@ -40,7 +41,7 @@ class Inbox {
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => array( '\Activitypub\Rest\Inbox', 'user_inbox' ),
'args' => self::request_parameters(),
'args' => self::user_inbox_request_parameters(),
),
)
);
@ -97,12 +98,20 @@ class Inbox {
/**
* The shared inbox
*
* @param [type] $request [description]
* @param WP_REST_Request $request
*
* @return WP_Error not yet implemented
* @return WP_REST_Response
*/
public static function shared_inbox( $request ) {
$data = $request->get_params();
$type = strtoloer( $request->get_param( 'type' ) );
foreach ( $users as $user ) {
\do_action( 'activitypub_inbox', $data, $user_id, $type );
\do_action( "activitypub_inbox_{$type}", $data, $user_id );
}
return new \WP_REST_Response( array(), 202 );
}
/**
@ -110,7 +119,7 @@ class Inbox {
*
* @return array list of parameters
*/
public static function request_parameters() {
public static function user_inbox_request_parameters() {
$params = array();
$params['page'] = array(
@ -122,6 +131,58 @@ class Inbox {
'type' => 'integer',
);
$params['id'] = array(
'required' => true,
'validate_callback' => function( $param, $request, $key ) {
if ( ! \is_string( $param ) ) {
$param = $param['id'];
}
return ! \Activitypub\is_blacklisted( $param );
},
'sanitize_callback' => 'esc_url_raw',
);
$params['actor'] = array(
'required' => true,
'validate_callback' => function( $param, $request, $key ) {
if ( ! \is_string( $param ) ) {
$param = $param['id'];
}
return ! \Activitypub\is_blacklisted( $param );
},
'sanitize_callback' => function( $param, $request, $key ) {
if ( ! \is_string( $param ) ) {
$param = $param['id'];
}
return \esc_url_raw( $param );
},
);
$params['type'] = array(
'required' => true,
//'type' => 'enum',
//'enum' => array( 'Create' ),
);
$params['object'] = array(
'required' => true,
);
return $params;
}
/**
* The supported parameters
*
* @return array list of parameters
*/
public static function shared_inbox_request_parameters() {
$params = array();
$params['page'] = array(
'type' => 'integer',
);
$params['id'] = array(
'required' => true,
'type' => 'string',
@ -155,9 +216,6 @@ class Inbox {
'required' => true,
//'type' => 'enum',
//'enum' => array( 'Create' ),
'sanitize_callback' => function( $param, $request, $key ) {
return \strtolower( $param );
},
);
$params['object'] = array(
@ -165,6 +223,37 @@ class Inbox {
//'type' => 'object',
);
$params['to'] = array(
'required' => true,
'sanitize_callback' => function( $param, $request, $key ) {
if ( \is_string( $param ) ) {
$param = array( $param );
}
return $param;
},
);
$params['cc'] = array(
'sanitize_callback' => function( $param, $request, $key ) {
if ( \is_string( $param ) ) {
$param = array( $param );
}
return $param;
},
);
$params['bcc'] = array(
'sanitize_callback' => function( $param, $request, $key ) {
if ( \is_string( $param ) ) {
$param = array( $param );
}
return $param;
},
);
return $params;
}
@ -186,7 +275,7 @@ class Inbox {
$activity->set_object( $object );
$activity->set_actor( \get_author_posts_url( $user_id ) );
$activity->set_to( $object['actor'] );
$activity->set_id( \get_author_posts_url( $user_id ) . '#follow' . \preg_replace( '~^https?://~', '', $object['actor'] ) );
$activity->set_id( \get_author_posts_url( $user_id ) . '#follow-' . \preg_replace( '~^https?://~', '', $object['actor'] ) );
$activity = $activity->to_simple_json();

View file

@ -18,6 +18,10 @@ class Server extends \WP_REST_Server {
public function dispatch( $request ) {
$content_type = $request->get_content_type();
if ( ! $content_type ) {
return parent::dispatch( $request );
}
// check for content-sub-types like 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
if ( \preg_match( '/application\/([a-zA-Z+_-]+\+)json/', $content_type['value'] ) ) {
$request->set_header( 'Content-Type', 'application/json' );

View file

@ -5,7 +5,7 @@ msgstr ""
"Project-Id-Version: ActivityPub 0.10.1\n"
"Report-Msgid-Bugs-To: "
"https://wordpress.org/support/plugin/wordpress-activitypub\n"
"POT-Creation-Date: 2020-05-03 22:06:03+00:00\n"
"POT-Creation-Date: 2020-06-03 10:11:18+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@ -23,40 +23,40 @@ msgid "Followers (Fediverse)"
msgstr ""
#: includes/class-admin.php:59
msgid "Use title and link, summary or full content"
msgid "Use title and link, summary, full or custom content"
msgstr ""
#: includes/class-admin.php:71
msgid "Define your own custom post template"
msgstr ""
#: includes/class-admin.php:79
msgid "The Activity-Object-Type"
msgstr ""
#: includes/class-admin.php:83 templates/settings.php:36
msgid "Use the Shortlink instead of the permalink"
msgstr ""
#: includes/class-admin.php:90
#: includes/class-admin.php:91
msgid ""
"Add hashtags in the content as native tags and replace the #tag with the "
"tag-link"
msgstr ""
#: includes/class-admin.php:97
msgid "Add all tags as hashtags at the end of each activity"
#: includes/class-admin.php:98
msgid "List of HTML elements that are allowed in activities."
msgstr ""
#: includes/class-admin.php:104
#: includes/class-admin.php:105
msgid "Enable ActivityPub support for post types"
msgstr ""
#: includes/class-admin.php:112
#: includes/class-admin.php:113
msgid "Block fediverse instances"
msgstr ""
#: includes/class-admin.php:123
#: includes/class-admin.php:124
msgid "Overview"
msgstr ""
#: includes/class-admin.php:125
#: includes/class-admin.php:126
msgid ""
"ActivityPub is a decentralized social networking protocol based on the "
"ActivityStreams 2.0 data format. ActivityPub is an official W3C recommended "
@ -66,32 +66,58 @@ msgid ""
"subscribing to content."
msgstr ""
#: includes/class-admin.php:130
#: includes/class-admin.php:131
msgid "For more information:"
msgstr ""
#: includes/class-admin.php:131
#: includes/class-admin.php:132
msgid "<a href=\"https://activitypub.rocks/\">Test Suite</a>"
msgstr ""
#: includes/class-admin.php:132
#: includes/class-admin.php:133
msgid "<a href=\"https://www.w3.org/TR/activitypub/\">W3C Spec</a>"
msgstr ""
#: includes/class-admin.php:133
#: includes/class-admin.php:134
msgid ""
"<a href=\"https://github.com/pfefferle/wordpress-activitypub/issues\">Give "
"us feedback</a>"
msgstr ""
#: includes/class-admin.php:135
#: includes/class-admin.php:136
msgid "<a href=\"https://notiz.blog/donate\">Donate</a>"
msgstr ""
#: includes/class-admin.php:145
#: includes/class-admin.php:146
msgid "Fediverse"
msgstr ""
#: includes/class-health-check.php:16
msgid "Profile URL test"
msgstr ""
#: includes/class-health-check.php:30
msgid "Profile URL accessible"
msgstr ""
#. Plugin Name of the plugin/theme
msgid "ActivityPub"
msgstr ""
#: includes/class-health-check.php:38
msgid "Your profile URL is accessible and do not redirect to the home page."
msgstr ""
#: includes/class-health-check.php:48
msgid "Profile URL is not accessible"
msgstr ""
#: includes/class-health-check.php:51
msgid ""
"Authorization Headers are being blocked by your hosting provider. This will "
"cause IndieAuth to fail."
msgstr ""
#: includes/functions.php:110
msgid "The \"actor\" is no valid URL"
msgstr ""
@ -203,91 +229,115 @@ msgstr ""
msgid "The full content."
msgstr ""
#: templates/settings.php:33
msgid "Backlink"
#: templates/settings.php:30
msgid "Custom"
msgstr ""
#: templates/settings.php:42
#: templates/settings.php:30
msgid "Use the text-area below, to customize your activities."
msgstr ""
#: templates/settings.php:36
msgid "The Post-Title."
msgstr ""
#: templates/settings.php:37
msgid "The Post-Content."
msgstr ""
#: templates/settings.php:38
msgid "The Post-Excerpt (default 400 Chars)."
msgstr ""
#: templates/settings.php:39
msgid "The Post-Permalink."
msgstr ""
#: templates/settings.php:41
msgid "The Tags as Hashtags."
msgstr ""
#: templates/settings.php:43
msgid "%sLet me know%s if you miss a template placeholder."
msgstr ""
#: templates/settings.php:50
msgid "Activity-Object-Type"
msgstr ""
#: templates/settings.php:46
#: templates/settings.php:54
msgid "Note (default)"
msgstr ""
#: templates/settings.php:46
#: templates/settings.php:54
msgid "Should work with most platforms."
msgstr ""
#: templates/settings.php:49
#: templates/settings.php:57
msgid "Article"
msgstr ""
#: templates/settings.php:49
#: templates/settings.php:57
msgid ""
"The presentation of the \"Article\" might change on different platforms. "
"Mastodon for example shows the \"Article\" type as a simple link."
msgstr ""
#: templates/settings.php:52
#: templates/settings.php:60
msgid "WordPress Post-Format"
msgstr ""
#: templates/settings.php:52
#: templates/settings.php:60
msgid "Maps the WordPress Post-Format to the ActivityPub Object Type."
msgstr ""
#: templates/settings.php:57
#: templates/settings.php:65
msgid "Supported post types"
msgstr ""
#: templates/settings.php:60
#: templates/settings.php:68
msgid "Enable ActivityPub support for the following post types:"
msgstr ""
#: templates/settings.php:77
#: templates/settings.php:85
msgid "Hashtags"
msgstr ""
#: templates/settings.php:81
#: templates/settings.php:89
msgid ""
"Add hashtags in the content as native tags and replace the "
"<code>#tag</code> with the tag-link."
msgstr ""
#: templates/settings.php:84
msgid "Add all tags as hashtags to the end of each activity."
#: templates/settings.php:95
msgid "HTML Whitelist"
msgstr ""
#: templates/settings.php:93
#: templates/settings.php:107
msgid "Server"
msgstr ""
#: templates/settings.php:95
#: templates/settings.php:109
msgid "Server related settings."
msgstr ""
#: templates/settings.php:106
#: templates/settings.php:120
msgid "Blacklist"
msgstr ""
#: templates/settings.php:110
#: templates/settings.php:124
msgid ""
"A list of hosts, you want to block, one host per line. Please use only the "
"host/domain of the server you want to block, without <code>http://</code> "
"and without <code>www.</code>. For example <code>example.com</code>."
msgstr ""
#: templates/settings.php:124
#: templates/settings.php:138
msgid ""
"If you like this plugin, what about a small <a "
"href=\"https://notiz.blog/donate\">donation</a>?"
msgstr ""
#. Plugin Name of the plugin/theme
msgid "ActivityPub"
msgstr ""
#. Plugin URI of the plugin/theme
msgid "https://github.com/pfefferle/wordpress-activitypub/"
msgstr ""

View file

@ -19,22 +19,30 @@
<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>
</p>
<p>
<label><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' ); ?></label> - <span class="description"><?php \esc_html_e( 'The full content.', 'activitypub' ); ?></span>
</p>
</td>
</tr>
<tr>
<th scope="row">
<?php \esc_html_e( 'Backlink', 'activitypub' ); ?>
</th>
<td>
<p><label><input type="checkbox" name="activitypub_use_shortlink" id="activitypub_use_shortlink" value="1" <?php echo \checked( '1', \get_option( 'activitypub_use_shortlink', '0' ) ); ?> /> <?php \esc_html_e( 'Use the Shortlink instead of the permalink', 'activitypub' ); ?></label></p>
<p class="description"><?php \printf( \esc_html( 'I can recommend %sHum%s, to prettify the Shortlinks', 'activitypub' ), '<a href="https://wordpress.org/plugins/hum/" target="_blank">', '</a>' ); ?></p>
<p>
<label><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' ); ?></label> - <span class="description"><?php \esc_html_e( 'Use the text-area below, to customize your activities.', 'activitypub' ); ?></span>
</p>
<p>
<textarea name="activitypub_custom_post_content" id="activitypub_custom_post_content" rows="10" cols="50" class="large-text" placeholder="<?php echo ACTIVITYPUB_CUSTOM_POST_CONTENT; ?>"><?php echo \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT ); ?></textarea>
<div class="description">
<ul>
<li><code>%title%</code> - <?php \esc_html_e( 'The Post-Title.', 'activitypub' ); ?></li>
<li><code>%content%</code> - <?php \esc_html_e( 'The Post-Content.', 'activitypub' ); ?></li>
<li><code>%excerpt%</code> - <?php \esc_html_e( 'The Post-Excerpt (default 400 Chars).', 'activitypub' ); ?></li>
<li><code>%permalink%</code> - <?php \esc_html_e( 'The Post-Permalink.', 'activitypub' ); ?></li>
<li><code>%shortlink%</code> - <?php \printf( \esc_html( 'The Post-Shortlink. I can recommend %sHum%s, to prettify the Shortlinks', 'activitypub' ), '<a href="https://wordpress.org/plugins/hum/" target="_blank">', '</a>' ); ?></li>
<li><code>%hashtags%</code> - <?php \esc_html_e( 'The Tags as Hashtags.', 'activitypub' ); ?></li>
</ul>
<?php printf( \__( '%sLet me know%s if you miss a template placeholder.', 'activitypub' ), '<a href="https://github.com/pfefferle/wordpress-activitypub/issues/new" target="_blank">', '</a>' ); ?>
</div>
</p>
</td>
</tr>
<tr>
@ -80,9 +88,15 @@
<p>
<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 \_e( 'Add hashtags in the content as native tags and replace the <code>#tag</code> with the tag-link.', 'activitypub' ); ?></label>
</p>
<p>
<label><input type="checkbox" name="activitypub_add_tags_as_hashtags" id="activitypub_add_tags_as_hashtags" value="1" <?php echo \checked( '1', \get_option( 'activitypub_add_tags_as_hashtags', '0' ) ); ?> /> <?php \_e( 'Add all tags as hashtags to the end of each activity.', 'activitypub' ); ?></label>
</p>
</td>
</tr>
<tr>
<th scope="row">
<?php \esc_html_e( 'HTML Whitelist', 'activitypub' ); ?>
</th>
<td>
<textarea name="activitypub_allowed_html" id="activitypub_allowed_html" rows="3" cols="50" class="large-text"><?php echo \get_option( 'activitypub_allowed_html', ACTIVITYPUB_ALLOWED_HTML ); ?></textarea>
<p class="description"><?php \_e( \sprintf( 'A list of HTML elements, you want to whitelist for your activities. <strong>Leave list empty to support all HTML elements.</strong> Default: <code>%s</code>.', \esc_html( ACTIVITYPUB_ALLOWED_HTML ) ), 'activitypub' ); ?></p>
</td>
</tr>
</tbody>