PHPCS: Include all files by default (#930)

* PHPCS: Include all files by default

* simplify menu highlighting

* Update includes/transformer/class-factory.php

Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>

---------

Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>
This commit is contained in:
Konstantin Obenland 2024-10-09 01:57:13 -05:00 committed by GitHub
parent f8cd515b05
commit ef666772ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 250 additions and 164 deletions

View file

@ -42,15 +42,15 @@ class Notification {
/** /**
* Notification constructor. * Notification constructor.
* *
* @param string $type The type of the notification. * @param string $type The type of the notification.
* @param string $actor The actor URL. * @param string $actor The actor URL.
* @param array $object The Activity object. * @param array $activity The Activity object.
* @param int $target The WordPress User-Id. * @param int $target The WordPress User-Id.
*/ */
public function __construct( $type, $actor, $object, $target ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.objectFound public function __construct( $type, $actor, $activity, $target ) {
$this->type = $type; $this->type = $type;
$this->actor = $actor; $this->actor = $actor;
$this->object = $object; $this->object = $activity;
$this->target = $target; $this->target = $target;
} }

View file

@ -221,7 +221,7 @@ class Signature {
$signature = null; $signature = null;
\openssl_sign( $signed_string, $signature, $key, \OPENSSL_ALGO_SHA256 ); \openssl_sign( $signed_string, $signature, $key, \OPENSSL_ALGO_SHA256 );
$signature = \base64_encode( $signature ); // phpcs:ignore $signature = \base64_encode( $signature ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
$key_id = $user->get_url() . '#main-key'; $key_id = $user->get_url() . '#main-key';
@ -345,7 +345,7 @@ class Signature {
); );
} }
if ( isset( $actor['publicKey']['publicKeyPem'] ) ) { if ( isset( $actor['publicKey']['publicKeyPem'] ) ) {
return \rtrim( $actor['publicKey']['publicKeyPem'] ); // phpcs:ignore return \rtrim( $actor['publicKey']['publicKeyPem'] );
} }
return new WP_Error( return new WP_Error(
'activitypub_no_remote_key_found', 'activitypub_no_remote_key_found',
@ -400,7 +400,7 @@ class Signature {
$parsed_header['headers'] = \explode( ' ', trim( $matches[1] ) ); $parsed_header['headers'] = \explode( ' ', trim( $matches[1] ) );
} }
if ( \preg_match( '/signature="(.*?)"/ism', $signature, $matches ) ) { if ( \preg_match( '/signature="(.*?)"/ism', $signature, $matches ) ) {
$parsed_header['signature'] = \base64_decode( preg_replace( '/\s+/', '', trim( $matches[1] ) ) ); // phpcs:ignore $parsed_header['signature'] = \base64_decode( preg_replace( '/\s+/', '', trim( $matches[1] ) ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode
} }
if ( ( $parsed_header['signature'] ) && ( $parsed_header['algorithm'] ) && ( ! $parsed_header['headers'] ) ) { if ( ( $parsed_header['signature'] ) && ( $parsed_header['algorithm'] ) && ( ! $parsed_header['headers'] ) ) {

View file

@ -94,7 +94,7 @@ class Followers {
public static function get_follower( $user_id, $actor ) { public static function get_follower( $user_id, $actor ) {
global $wpdb; global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching // phpcs:ignore WordPress.DB.DirectDatabaseQuery
$post_id = $wpdb->get_var( $post_id = $wpdb->get_var(
$wpdb->prepare( $wpdb->prepare(
"SELECT DISTINCT p.ID FROM $wpdb->posts p INNER JOIN $wpdb->postmeta pm ON p.ID = pm.post_id WHERE p.post_type = %s AND pm.meta_key = 'activitypub_user_id' AND pm.meta_value = %d AND p.guid = %s", "SELECT DISTINCT p.ID FROM $wpdb->posts p INNER JOIN $wpdb->postmeta pm ON p.ID = pm.post_id WHERE p.post_type = %s AND pm.meta_key = 'activitypub_user_id' AND pm.meta_value = %d AND p.guid = %s",
@ -119,12 +119,12 @@ class Followers {
* *
* @param string $actor The Actor URL. * @param string $actor The Actor URL.
* *
* @return Follower|null The Follower object or null. * @return \Activitypub\Activity\Base_Object|WP_Error|null
*/ */
public static function get_follower_by_actor( $actor ) { public static function get_follower_by_actor( $actor ) {
global $wpdb; global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching // phpcs:ignore WordPress.DB.DirectDatabaseQuery
$post_id = $wpdb->get_var( $post_id = $wpdb->get_var(
$wpdb->prepare( $wpdb->prepare(
"SELECT ID FROM $wpdb->posts WHERE guid=%s", "SELECT ID FROM $wpdb->posts WHERE guid=%s",

View file

@ -1012,8 +1012,7 @@ function get_enclosures( $post_id ) {
function get_comment_ancestors( $comment ) { function get_comment_ancestors( $comment ) {
$comment = \get_comment( $comment ); $comment = \get_comment( $comment );
// phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual if ( ! $comment || empty( $comment->comment_parent ) || (int) $comment->comment_parent === (int) $comment->comment_ID ) {
if ( ! $comment || empty( $comment->comment_parent ) || $comment->comment_parent == $comment->comment_ID ) {
return array(); return array();
} }

View file

@ -33,27 +33,25 @@ class Announce {
/** /**
* Handles "Announce" requests. * Handles "Announce" requests.
* *
* @param array $array The activity-object. * @param array $announcement The activity-object.
* @param int $user_id The id of the local blog-user. * @param int $user_id The id of the local blog-user.
* @param \Activitypub\Activity\Activity $activity The activity object. * @param \Activitypub\Activity\Activity $activity The activity object.
*
* @return void
*/ */
public static function handle_announce( $array, $user_id, $activity = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound public static function handle_announce( $announcement, $user_id, $activity = null ) {
// Check if Activity is public or not. // Check if Activity is public or not.
if ( ! is_activity_public( $array ) ) { if ( ! is_activity_public( $announcement ) ) {
// @todo maybe send email // @todo maybe send email
return; return;
} }
if ( ! ACTIVITYPUB_DISABLE_REACTIONS ) { if ( ! ACTIVITYPUB_DISABLE_REACTIONS ) {
self::maybe_save_announce( $array, $user_id, $activity ); self::maybe_save_announce( $announcement, $user_id );
} }
if ( is_string( $array['object'] ) ) { if ( is_string( $announcement['object'] ) ) {
$object = Http::get_remote_object( $array['object'] ); $object = Http::get_remote_object( $announcement['object'] );
} else { } else {
$object = $array['object']; $object = $announcement['object'];
} }
if ( ! $object || is_wp_error( $object ) ) { if ( ! $object || is_wp_error( $object ) ) {
@ -66,21 +64,33 @@ class Announce {
$type = \strtolower( $object['type'] ); $type = \strtolower( $object['type'] );
/**
* Fires after an Announce has been received.
*
* @param array $object The object.
* @param int $user_id The id of the local blog-user.
* @param array $activity The activity object.
*/
\do_action( 'activitypub_inbox', $object, $user_id, $type, $activity ); \do_action( 'activitypub_inbox', $object, $user_id, $type, $activity );
/**
* Fires after an Announce of a specific type has been received.
*
* @param array $object The object.
* @param int $user_id The id of the local blog-user.
* @param array $activity The activity object.
*/
\do_action( "activitypub_inbox_{$type}", $object, $user_id, $activity ); \do_action( "activitypub_inbox_{$type}", $object, $user_id, $activity );
} }
/** /**
* Try to save the Announce. * Try to save the Announce.
* *
* @param array $array The activity-object. * @param array $activity The activity-object.
* @param int $user_id The id of the local blog-user. * @param int $user_id The id of the local blog-user.
* @param \Activitypub\Activity\Activity $activity The activity object.
*
* @return void
*/ */
public static function maybe_save_announce( $array, $user_id, $activity ) { // phpcs:ignore public static function maybe_save_announce( $activity, $user_id ) {
$url = object_to_uri( $array['object'] ); $url = object_to_uri( $activity['object'] );
if ( empty( $url ) ) { if ( empty( $url ) ) {
return; return;
@ -91,13 +101,21 @@ class Announce {
return; return;
} }
$state = Interactions::add_reaction( $array ); $state = Interactions::add_reaction( $activity );
$reaction = null; $reaction = null;
if ( $state && ! is_wp_error( $state ) ) { if ( $state && ! is_wp_error( $state ) ) {
$reaction = get_comment( $state ); $reaction = get_comment( $state );
} }
do_action( 'activitypub_handled_announce', $array, $user_id, $state, $reaction ); /**
* Fires after an Announce has been saved.
*
* @param array $activity The activity-object.
* @param int $user_id The id of the local blog-user.
* @param mixed $state The state of the reaction.
* @param mixed $reaction The reaction.
*/
do_action( 'activitypub_handled_announce', $activity, $user_id, $state, $reaction );
} }
} }

View file

@ -31,18 +31,15 @@ class Like {
/** /**
* Handles "Like" requests. * Handles "Like" requests.
* *
* @param array $array The Activity array. * @param array $like The Activity array.
* @param int $user_id The ID of the local blog user. * @param int $user_id The ID of the local blog user.
* @param \Activitypub\Activity\Activity $activity The Activity object.
*
* @return void
*/ */
public static function handle_like( $array, $user_id, $activity = null ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound,VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable,Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed public static function handle_like( $like, $user_id ) {
if ( ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS ) { if ( ACTIVITYPUB_DISABLE_INCOMING_INTERACTIONS ) {
return; return;
} }
$url = object_to_uri( $array['object'] ); $url = object_to_uri( $like['object'] );
if ( empty( $url ) ) { if ( empty( $url ) ) {
return; return;
@ -53,13 +50,21 @@ class Like {
return; return;
} }
$state = Interactions::add_reaction( $array ); $state = Interactions::add_reaction( $like );
$reaction = null; $reaction = null;
if ( $state && ! is_wp_error( $state ) ) { if ( $state && ! is_wp_error( $state ) ) {
$reaction = get_comment( $state ); $reaction = get_comment( $state );
} }
do_action( 'activitypub_handled_like', $array, $user_id, $state, $reaction ); /**
* Fires after a Like has been handled.
*
* @param array $like The Activity array.
* @param int $user_id The ID of the local blog user.
* @param mixed $state The state of the reaction.
* @param mixed $reaction The reaction object.
*/
do_action( 'activitypub_handled_like', $like, $user_id, $state, $reaction );
} }
} }

View file

@ -149,7 +149,7 @@ class Follower extends Actor {
if ( ! $this->get__id() ) { if ( ! $this->get__id() ) {
global $wpdb; global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching // phpcs:ignore WordPress.DB.DirectDatabaseQuery
$post_id = $wpdb->get_var( $post_id = $wpdb->get_var(
$wpdb->prepare( $wpdb->prepare(
"SELECT ID FROM $wpdb->posts WHERE guid=%s", "SELECT ID FROM $wpdb->posts WHERE guid=%s",

View file

@ -102,7 +102,7 @@ class Outbox {
$json->next = \add_query_arg( 'page', $page + 1, $json->partOf ); $json->next = \add_query_arg( 'page', $page + 1, $json->partOf );
} }
if ( $page && ( $page > 1 ) ) { // phpcs:ignore if ( $page && ( $page > 1 ) ) {
$json->prev = \add_query_arg( 'page', $page - 1, $json->partOf ); $json->prev = \add_query_arg( 'page', $page - 1, $json->partOf );
} }
// phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase // phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase

View file

@ -92,26 +92,22 @@ class Followers extends WP_List_Table {
$args = array(); $args = array();
// phpcs:ignore WordPress.Security.NonceVerification.Recommended // phpcs:disable WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['orderby'] ) ) { if ( isset( $_GET['orderby'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$args['orderby'] = sanitize_text_field( wp_unslash( $_GET['orderby'] ) ); $args['orderby'] = sanitize_text_field( wp_unslash( $_GET['orderby'] ) );
} }
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['order'] ) ) { if ( isset( $_GET['order'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$args['order'] = sanitize_text_field( wp_unslash( $_GET['order'] ) ); $args['order'] = sanitize_text_field( wp_unslash( $_GET['order'] ) );
} }
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['s'] ) && isset( $_REQUEST['_wpnonce'] ) ) { if ( isset( $_GET['s'] ) && isset( $_REQUEST['_wpnonce'] ) ) {
$nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ); $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) );
if ( wp_verify_nonce( $nonce, 'bulk-' . $this->_args['plural'] ) ) { if ( wp_verify_nonce( $nonce, 'bulk-' . $this->_args['plural'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$args['s'] = sanitize_text_field( wp_unslash( $_GET['s'] ) ); $args['s'] = sanitize_text_field( wp_unslash( $_GET['s'] ) );
} }
} }
// phpcs:enable WordPress.Security.NonceVerification.Recommended
$followers_with_count = FollowerCollection::get_followers_with_count( $this->user_id, $per_page, $page_num, $args ); $followers_with_count = FollowerCollection::get_followers_with_count( $this->user_id, $per_page, $page_num, $args );
$followers = $followers_with_count['followers']; $followers = $followers_with_count['followers'];
@ -219,7 +215,7 @@ class Followers extends WP_List_Table {
return; return;
} }
$followers = $_REQUEST['followers']; // phpcs:ignore $followers = $_REQUEST['followers']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
if ( $this->current_action() === 'delete' ) { if ( $this->current_action() === 'delete' ) {
if ( ! is_array( $followers ) ) { if ( ! is_array( $followers ) ) {

View file

@ -10,21 +10,22 @@ namespace Activitypub\Transformer;
use WP_Error; use WP_Error;
/** /**
* Transformer Factory * Transformer Factory.
*/ */
class Factory { class Factory {
/** /**
* Get the transformer for a given object. * Get the transformer for a given object.
* *
* @param mixed $object The object to transform. * @param mixed $data The object to transform.
*
* @return Base|WP_Error The transformer to use, or an error. * @return Base|WP_Error The transformer to use, or an error.
*/ */
public static function get_transformer( $object ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.objectFound public static function get_transformer( $data ) {
if ( ! \is_object( $object ) ) { if ( ! \is_object( $data ) ) {
return new WP_Error( 'invalid_object', __( 'Invalid object', 'activitypub' ) ); return new WP_Error( 'invalid_object', __( 'Invalid object', 'activitypub' ) );
} }
$class = \get_class( $object ); $class = \get_class( $data );
/** /**
* Filter the transformer for a given object. * Filter the transformer for a given object.
@ -50,12 +51,12 @@ class Factory {
* }, 10, 3 ); * }, 10, 3 );
* *
* @param Base $transformer The transformer to use. * @param Base $transformer The transformer to use.
* @param mixed $object The object to transform. * @param mixed $data The object to transform.
* @param string $object_class The class of the object to transform. * @param string $object_class The class of the object to transform.
* *
* @return mixed The transformer to use. * @return mixed The transformer to use.
*/ */
$transformer = \apply_filters( 'activitypub_transformer', null, $object, $class ); $transformer = \apply_filters( 'activitypub_transformer', null, $data, $class );
if ( $transformer ) { if ( $transformer ) {
if ( if (
@ -71,12 +72,12 @@ class Factory {
// Use default transformer. // Use default transformer.
switch ( $class ) { switch ( $class ) {
case 'WP_Post': case 'WP_Post':
if ( 'attachment' === $object->post_type ) { if ( 'attachment' === $data->post_type ) {
return new Attachment( $object ); return new Attachment( $data );
} }
return new Post( $object ); return new Post( $data );
case 'WP_Comment': case 'WP_Comment':
return new Comment( $object ); return new Comment( $data );
default: default:
return null; return null;
} }

View file

@ -868,8 +868,8 @@ class Post extends Base {
$template = "[ap_content]\n\n[ap_permalink type=\"html\"]\n\n[ap_hashtags]"; $template = "[ap_content]\n\n[ap_permalink type=\"html\"]\n\n[ap_hashtags]";
break; break;
default: default:
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found $content = \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT );
$template = \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT ) ?: ACTIVITYPUB_CUSTOM_POST_CONTENT; $template = empty( $content ) ? ACTIVITYPUB_CUSTOM_POST_CONTENT : $content;
break; break;
} }

View file

@ -79,14 +79,13 @@ function plugin_init() {
if ( \defined( 'SSP_VERSION' ) ) { if ( \defined( 'SSP_VERSION' ) ) {
add_filter( add_filter(
'activitypub_transformer', 'activitypub_transformer',
// phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.objectFound function ( $transformer, $data, $object_class ) {
function ( $transformer, $object, $object_class ) {
if ( if (
'WP_Post' === $object_class && 'WP_Post' === $object_class &&
\get_post_meta( $object->ID, 'audio_file', true ) \get_post_meta( $data->ID, 'audio_file', true )
) { ) {
require_once __DIR__ . '/class-seriously-simple-podcasting.php'; require_once __DIR__ . '/class-seriously-simple-podcasting.php';
return new Seriously_Simple_Podcasting( $object ); return new Seriously_Simple_Podcasting( $data );
} }
return $transformer; return $transformer;
}, },

View file

@ -1,14 +1,12 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<ruleset name="WordPress ActivityPub"> <ruleset name="WordPress ActivityPub">
<description>WordPress ActivityPub Standards</description> <description>WordPress ActivityPub Standards</description>
<file>./activitypub.php</file> <file>.</file>
<file>./includes/</file>
<file>./integration/</file>
<file>./build/</file>
<exclude-pattern>*\.(inc|css|js|svg)</exclude-pattern> <exclude-pattern>*\.(inc|css|js|svg)</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern> <exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern> <exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*.asset.php</exclude-pattern> <exclude-pattern>*.asset.php</exclude-pattern>
<arg value="ps"/> <arg value="ps"/>

View file

@ -5,6 +5,16 @@
* @package Activitypub * @package Activitypub
*/ */
/* @var array $args Template arguments. */
$args = wp_parse_args(
$args,
array(
'welcome' => '',
'settings' => '',
'blog-profile' => '',
'followers' => '',
)
);
?> ?>
<div class="activitypub-settings-header"> <div class="activitypub-settings-header">
<div class="activitypub-settings-title-section"> <div class="activitypub-settings-title-section">
@ -12,21 +22,21 @@
</div> </div>
<nav class="activitypub-settings-tabs-wrapper" aria-label="<?php \esc_attr_e( 'Secondary menu', 'activitypub' ); ?>"> <nav class="activitypub-settings-tabs-wrapper" aria-label="<?php \esc_attr_e( 'Secondary menu', 'activitypub' ); ?>">
<a href="<?php echo \esc_url_raw( admin_url( 'options-general.php?page=activitypub' ) ); ?>" class="activitypub-settings-tab <?php echo \esc_attr( $args['welcome'] ); ?>"> <a href="<?php echo \esc_url( admin_url( 'options-general.php?page=activitypub' ) ); ?>" class="activitypub-settings-tab <?php echo \esc_attr( $args['welcome'] ); ?>">
<?php \esc_html_e( 'Welcome', 'activitypub' ); ?> <?php \esc_html_e( 'Welcome', 'activitypub' ); ?>
</a> </a>
<a href="<?php echo \esc_url_raw( admin_url( 'options-general.php?page=activitypub&tab=settings' ) ); ?>" class="activitypub-settings-tab <?php echo \esc_attr( $args['settings'] ); ?>"> <a href="<?php echo \esc_url( admin_url( 'options-general.php?page=activitypub&tab=settings' ) ); ?>" class="activitypub-settings-tab <?php echo \esc_attr( $args['settings'] ); ?>">
<?php \esc_html_e( 'Settings', 'activitypub' ); ?> <?php \esc_html_e( 'Settings', 'activitypub' ); ?>
</a> </a>
<?php if ( ! \Activitypub\is_user_disabled( \Activitypub\Collection\Users::BLOG_USER_ID ) ) : ?> <?php if ( ! \Activitypub\is_user_disabled( \Activitypub\Collection\Users::BLOG_USER_ID ) ) : ?>
<a href="<?php echo \esc_url_raw( admin_url( 'options-general.php?page=activitypub&tab=blog-profile' ) ); ?>" class="activitypub-settings-tab <?php echo \esc_attr( $args['blog-profile'] ); ?>"> <a href="<?php echo \esc_url( admin_url( 'options-general.php?page=activitypub&tab=blog-profile' ) ); ?>" class="activitypub-settings-tab <?php echo \esc_attr( $args['blog-profile'] ); ?>">
<?php \esc_html_e( 'Blog-Profile', 'activitypub' ); ?> <?php \esc_html_e( 'Blog-Profile', 'activitypub' ); ?>
</a> </a>
<a href="<?php echo \esc_url_raw( admin_url( 'options-general.php?page=activitypub&tab=followers' ) ); ?>" class="activitypub-settings-tab <?php echo \esc_attr( $args['followers'] ); ?>"> <a href="<?php echo \esc_url( admin_url( 'options-general.php?page=activitypub&tab=followers' ) ); ?>" class="activitypub-settings-tab <?php echo \esc_attr( $args['followers'] ); ?>">
<?php \esc_html_e( 'Followers', 'activitypub' ); ?> <?php \esc_html_e( 'Followers', 'activitypub' ); ?>
</a> </a>

View file

@ -1,15 +1,19 @@
<?php <?php
/**
* ActivityPub Blog Followers List template.
*
* @package Activitypub
*/
\load_template( \load_template(
__DIR__ . '/admin-header.php', __DIR__ . '/admin-header.php',
true, true,
array( array(
'settings' => '', 'followers' => 'active',
'welcome' => '',
'followers' => 'active',
'blog-profile' => '',
) )
); );
$table = new \Activitypub\Table\Followers();
$table = new \Activitypub\Table\Followers();
$follower_count = $table->get_user_count(); $follower_count = $table->get_user_count();
// translators: The follower count. // translators: The follower count.
$followers_template = _n( 'Your blog profile currently has %s follower.', 'Your blog profile currently has %s followers.', $follower_count, 'activitypub' ); $followers_template = _n( 'Your blog profile currently has %s follower.', 'Your blog profile currently has %s followers.', $follower_count, 'activitypub' );

View file

@ -1,15 +1,21 @@
<?php <?php
/**
* ActivityPub Blog JSON template.
*
* @package Activitypub
*/
$user = new \Activitypub\Model\Blog(); $user = new \Activitypub\Model\Blog();
/* /**
* Action triggerd prior to the ActivityPub profile being created and sent to the client * Action triggered prior to the ActivityPub profile being created and sent to the client
*/ */
\do_action( 'activitypub_json_author_pre', $user->get__id() ); \do_action( 'activitypub_json_author_pre', $user->get__id() );
\header( 'Content-Type: application/activity+json' ); \header( 'Content-Type: application/activity+json' );
echo $user->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $user->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/* /**
* Action triggerd after the ActivityPub profile has been created and sent to the client * Action triggered after the ActivityPub profile has been created and sent to the client
*/ */
\do_action( 'activitypub_json_author_post', $user->get__id() ); \do_action( 'activitypub_json_author_post', $user->get__id() );

View file

@ -1,12 +1,15 @@
<?php <?php
/**
* ActivityPub Blog Settings template.
*
* @package Activitypub
*/
\load_template( \load_template(
__DIR__ . '/admin-header.php', __DIR__ . '/admin-header.php',
true, true,
array( array(
'settings' => '',
'welcome' => '',
'blog-profile' => 'active', 'blog-profile' => 'active',
'followers' => '',
) )
); );
?> ?>
@ -33,7 +36,7 @@
\sprintf( \sprintf(
// translators: %s is a URL. // translators: %s is a URL.
\__( 'The ActivityPub plugin uses the WordPress Site Icon as Avatar for the Blog-Profile, you can change the Site Icon in the "<a href="%s">General Settings</a>" of WordPress.', 'activitypub' ), \__( 'The ActivityPub plugin uses the WordPress Site Icon as Avatar for the Blog-Profile, you can change the Site Icon in the "<a href="%s">General Settings</a>" of WordPress.', 'activitypub' ),
\esc_attr( \admin_url( 'options-general.php' ) ) \esc_url( \admin_url( 'options-general.php' ) )
), ),
'default' 'default'
); );
@ -51,15 +54,15 @@
$classes_for_update_button = 'button'; $classes_for_update_button = 'button';
$classes_for_wrapper = ''; $classes_for_wrapper = '';
if ( (int) get_option( 'activitypub_header_image', 0 ) ) { if ( (int) get_option( 'activitypub_header_image', 0 ) ) :
$classes_for_wrapper .= ' has-header-image'; $classes_for_wrapper .= ' has-header-image';
$classes_for_button = $classes_for_update_button; $classes_for_button = $classes_for_update_button;
$classes_for_button_on_change = $classes_for_upload_button; $classes_for_button_on_change = $classes_for_upload_button;
} else { else :
$classes_for_wrapper .= ' hidden'; $classes_for_wrapper .= ' hidden';
$classes_for_button = $classes_for_upload_button; $classes_for_button = $classes_for_upload_button;
$classes_for_button_on_change = $classes_for_update_button; $classes_for_button_on_change = $classes_for_update_button;
} endif;
?> ?>
<div id="activitypub-header-image-preview-wrapper" class='<?php echo esc_attr( $classes_for_wrapper ); ?>'> <div id="activitypub-header-image-preview-wrapper" class='<?php echo esc_attr( $classes_for_wrapper ); ?>'>
<img id='activitypub-header-image-preview' src='<?php echo esc_url( wp_get_attachment_url( get_option( 'activitypub_header_image' ) ) ); ?>' style="max-width: 100%;" /> <img id='activitypub-header-image-preview' src='<?php echo esc_url( wp_get_attachment_url( get_option( 'activitypub_header_image' ) ) ); ?>' style="max-width: 100%;" />
@ -120,7 +123,7 @@
name="activitypub_blog_description" name="activitypub_blog_description"
id="activitypub_blog_description" id="activitypub_blog_description"
placeholder="<?php echo esc_attr( \get_bloginfo( 'description' ) ); ?>" placeholder="<?php echo esc_attr( \get_bloginfo( 'description' ) ); ?>"
><?php echo \esc_html( \get_option( 'activitypub_blog_description' ) ); ?></textarea> ><?php echo \esc_textarea( \get_option( 'activitypub_blog_description' ) ); ?></textarea>
</label> </label>
<p class="description"> <p class="description">
<?php \esc_html_e( 'By default the ActivityPub plugin uses the WordPress tagline as a description for the blog profile.', 'activitypub' ); ?> <?php \esc_html_e( 'By default the ActivityPub plugin uses the WordPress tagline as a description for the blog profile.', 'activitypub' ); ?>
@ -142,7 +145,7 @@
<?php <?php
$extra_fields = \Activitypub\Collection\Extra_Fields::get_actor_fields( \Activitypub\Collection\Users::BLOG_USER_ID ); $extra_fields = \Activitypub\Collection\Extra_Fields::get_actor_fields( \Activitypub\Collection\Users::BLOG_USER_ID );
if ( empty( $extra_fields ) ) { if ( empty( $extra_fields ) ) :
?> ?>
<tr> <tr>
<td colspan="3"> <td colspan="3">
@ -150,8 +153,9 @@
</td> </td>
</tr> </tr>
<?php <?php
} endif;
foreach ( $extra_fields as $extra_field ) {
foreach ( $extra_fields as $extra_field ) :
?> ?>
<tr> <tr>
<td><?php echo \esc_html( $extra_field->post_title ); ?></td> <td><?php echo \esc_html( $extra_field->post_title ); ?></td>
@ -162,7 +166,7 @@
</a> </a>
</td> </td>
</tr> </tr>
<?php } ?> <?php endforeach; ?>
</table> </table>
<p> <p>

View file

@ -1,5 +1,11 @@
<?php <?php
$comment = \get_comment( \get_query_var( 'c', null ) ); // phpcs:ignore /**
* ActivityPub Comment JSON template.
*
* @package Activitypub
*/
$comment = \get_comment( \get_query_var( 'c', null ) ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$transformer = \Activitypub\Transformer\Factory::get_transformer( $comment ); $transformer = \Activitypub\Transformer\Factory::get_transformer( $comment );
if ( \is_wp_error( $transformer ) ) { if ( \is_wp_error( $transformer ) ) {
@ -9,15 +15,15 @@ if ( \is_wp_error( $transformer ) ) {
); );
} }
/* /**
* Action triggerd prior to the ActivityPub profile being created and sent to the client * Action triggered prior to the ActivityPub profile being created and sent to the client
*/ */
\do_action( 'activitypub_json_comment_pre' ); \do_action( 'activitypub_json_comment_pre' );
\header( 'Content-Type: application/activity+json' ); \header( 'Content-Type: application/activity+json' );
echo $transformer->to_object()->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $transformer->to_object()->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/* /**
* Action triggerd after the ActivityPub profile has been created and sent to the client * Action triggered after the ActivityPub profile has been created and sent to the client
*/ */
\do_action( 'activitypub_json_comment_post' ); \do_action( 'activitypub_json_comment_post' );

View file

@ -1,6 +1,11 @@
<?php <?php
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited /**
$post = \get_post(); * ActivityPub Post JSON template.
*
* @package Activitypub
*/
$post = \get_post(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$transformer = \Activitypub\Transformer\Factory::get_transformer( $post ); $transformer = \Activitypub\Transformer\Factory::get_transformer( $post );
if ( \is_wp_error( $transformer ) ) { if ( \is_wp_error( $transformer ) ) {
@ -11,15 +16,15 @@ if ( \is_wp_error( $transformer ) ) {
} }
/* /**
* Action triggerd prior to the ActivityPub profile being created and sent to the client * Action triggered prior to the ActivityPub profile being created and sent to the client
*/ */
\do_action( 'activitypub_json_post_pre' ); \do_action( 'activitypub_json_post_pre' );
\header( 'Content-Type: application/activity+json' ); \header( 'Content-Type: application/activity+json' );
echo $transformer->to_object()->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $transformer->to_object()->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/* /**
* Action triggerd after the ActivityPub profile has been created and sent to the client * Action triggered after the ActivityPub profile has been created and sent to the client
*/ */
\do_action( 'activitypub_json_post_post' ); \do_action( 'activitypub_json_post_post' );

View file

@ -1,12 +1,15 @@
<?php <?php
/**
* ActivityPub settings template.
*
* @package Activitypub
*/
\load_template( \load_template(
__DIR__ . '/admin-header.php', __DIR__ . '/admin-header.php',
true, true,
array( array(
'settings' => 'active', 'settings' => 'active',
'welcome' => '',
'followers' => '',
'blog-profile' => '',
) )
); );
?> ?>
@ -85,8 +88,7 @@
</td> </td>
</tr> </tr>
<?php // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?> <tr <?php echo 'wordpress-post-format' === \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE ) ? 'style="display: none"' : ''; ?>>
<tr <?php if ( 'wordpress-post-format' === \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE ) ) { echo 'style="display: none"'; } ?>>
<th scope="row"> <th scope="row">
<?php \esc_html_e( 'Post content', 'activitypub' ); ?> <?php \esc_html_e( 'Post content', 'activitypub' ); ?>
</th> </th>
@ -138,12 +140,12 @@
<summary><?php esc_html_e( 'See a list of ActivityPub Template Tags.', 'activitypub' ); ?></summary> <summary><?php esc_html_e( 'See a list of ActivityPub Template Tags.', 'activitypub' ); ?></summary>
<div class="description"> <div class="description">
<ul> <ul>
<li><code>[ap_title]</code> - <?php \esc_html_e( 'The post\'s title.', 'activitypub' ); ?></li> <li><code>[ap_title]</code> - <?php \esc_html_e( 'The post&#8217;s title.', 'activitypub' ); ?></li>
<li><code>[ap_content]</code> - <?php \esc_html_e( 'The post\'s content.', 'activitypub' ); ?></li> <li><code>[ap_content]</code> - <?php \esc_html_e( 'The post&#8217;s content.', 'activitypub' ); ?></li>
<li><code>[ap_excerpt]</code> - <?php \esc_html_e( 'The post\'s excerpt (may be truncated).', 'activitypub' ); ?></li> <li><code>[ap_excerpt]</code> - <?php \esc_html_e( 'The post&#8217;s excerpt (may be truncated).', 'activitypub' ); ?></li>
<li><code>[ap_permalink]</code> - <?php \esc_html_e( 'The post\'s permalink.', 'activitypub' ); ?></li> <li><code>[ap_permalink]</code> - <?php \esc_html_e( 'The post&#8217;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_shortlink]</code> - <?php echo \wp_kses( \__( 'The pos&#8217;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> <li><code>[ap_hashtags]</code> - <?php \esc_html_e( 'The post&#8217;s tags as hashtags.', 'activitypub' ); ?></li>
</ul> </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> <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> </div>
@ -161,7 +163,7 @@
<?php <?php
echo \wp_kses( echo \wp_kses(
\sprintf( \sprintf(
// translators: // translators: %s is a number.
\__( 'The number of media (images, audio, video) to attach to posts. Default: <code>%s</code>', 'activitypub' ), \__( 'The number of media (images, audio, video) to attach to posts. Default: <code>%s</code>', 'activitypub' ),
\esc_html( ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS ) \esc_html( ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS )
), ),
@ -184,19 +186,21 @@
<fieldset> <fieldset>
<?php \esc_html_e( 'Automatically publish items of the selected post types to the fediverse:', 'activitypub' ); ?> <?php \esc_html_e( 'Automatically publish items of the selected post types to the fediverse:', 'activitypub' ); ?>
<?php $post_types = \get_post_types( array( 'public' => true ), 'objects' ); ?>
<?php $support_post_types = \get_option( 'activitypub_support_post_types', array( 'post' ) ) ? \get_option( 'activitypub_support_post_types', array( 'post' ) ) : array(); ?>
<ul> <ul>
<?php // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?> <?php
<?php foreach ( $post_types as $post_type ) { ?> $post_types = \get_post_types( array( 'public' => true ), 'objects' );
$supported_post_types = (array) \get_option( 'activitypub_support_post_types', array( 'post' ) );
foreach ( $post_types as $_post_type ) :
?>
<li> <li>
<input type="checkbox" id="activitypub_support_post_type_<?php echo \esc_attr( $post_type->name ); ?>" name="activitypub_support_post_types[]" value="<?php echo \esc_attr( $post_type->name ); ?>" <?php echo \checked( \in_array( $post_type->name, $support_post_types, true ) ); ?> /> <input type="checkbox" id="activitypub_support_post_type_<?php echo \esc_attr( $_post_type->name ); ?>" name="activitypub_support_post_types[]" value="<?php echo \esc_attr( $_post_type->name ); ?>" <?php echo \checked( \in_array( $_post_type->name, $supported_post_types, true ) ); ?> />
<label for="activitypub_support_post_type_<?php echo \esc_attr( $post_type->name ); ?>"><?php echo \esc_html( $post_type->label ); ?></label> <label for="activitypub_support_post_type_<?php echo \esc_attr( $_post_type->name ); ?>"><?php echo \esc_html( $_post_type->label ); ?></label>
<span class="description"> <span class="description">
<?php echo \esc_html( \Activitypub\get_post_type_description( $post_type ) ); ?> <?php echo \esc_html( \Activitypub\get_post_type_description( $_post_type ) ); ?>
</span> </span>
</li> </li>
<?php } ?> <?php endforeach; ?>
</ul> </ul>
</fieldset> </fieldset>
</td> </td>
@ -242,7 +246,7 @@
\sprintf( \sprintf(
// translators: %s is a URL. // 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' ), \__( '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' ) ) \esc_url( \admin_url( 'options-discussion.php#disallowed_keys' ) )
), ),
'default' 'default'
); );

View file

@ -1,3 +1,12 @@
<?php
/**
* Toolbox template.
*
* @package Activitypub
*/
?>
<div class="card activitypub" id="activitypub"> <div class="card activitypub" id="activitypub">
<h2><?php esc_html_e( '⁂ Fediverse Bookmarklet', 'activitypub' ); ?></h2> <h2><?php esc_html_e( '⁂ Fediverse Bookmarklet', 'activitypub' ); ?></h2>
<p> <p>
@ -7,8 +16,8 @@
<h3><?php esc_html_e( 'Install Bookmarklet', 'activitypub' ); ?></h3> <h3><?php esc_html_e( 'Install Bookmarklet', 'activitypub' ); ?></h3>
<p><?php esc_html_e( 'Drag and drop this button to your browsers bookmark bar or save this bookmarklet to reply to posts on other websites from your blog! When visiting a post on another site, click the bookmarklet to start a reply.', 'activitypub' ); ?></p> <p><?php esc_html_e( 'Drag and drop this button to your browsers bookmark bar or save this bookmarklet to reply to posts on other websites from your blog! When visiting a post on another site, click the bookmarklet to start a reply.', 'activitypub' ); ?></p>
<p class="activitypub-bookmarklet-wrapper"> <p class="activitypub-bookmarklet-wrapper">
<a class="activitypub-bookmarklet button" onclick="return false;" href="<?php echo esc_html( \Activitypub\get_reply_intent_uri() ); ?>" style="cursor: grab;"> <a class="activitypub-bookmarklet button" onclick="return false;" href="<?php echo esc_url( \Activitypub\get_reply_intent_uri() ); ?>" style="cursor: grab;">
<?php // translators: The host (domain) of the Blog ?> <?php // translators: The host (domain) of the Blog. ?>
<?php printf( esc_html__( 'Reply from %s', 'activitypub' ), esc_attr( \wp_parse_url( \home_url(), PHP_URL_HOST ) ) ); ?> <?php printf( esc_html__( 'Reply from %s', 'activitypub' ), esc_attr( \wp_parse_url( \home_url(), PHP_URL_HOST ) ) ); ?>
</a> </a>
</p> </p>
@ -17,7 +26,7 @@
<?php esc_html_e( 'Or copy the following code and create a new bookmark. Paste the code into the new bookmark&#8217;s URL field.', 'activitypub' ); ?> <?php esc_html_e( 'Or copy the following code and create a new bookmark. Paste the code into the new bookmark&#8217;s URL field.', 'activitypub' ); ?>
</p> </p>
<p> <p>
<textarea id="activitypub-bookmarklet-code" class="large-text activitypub-code" rows="5" readonly="readonly" aria-labelledby="activitypub-code-desc"><?php echo esc_html( \Activitypub\get_reply_intent_uri() ); ?></textarea> <textarea id="activitypub-bookmarklet-code" class="large-text activitypub-code" rows="5" readonly="readonly" aria-labelledby="activitypub-code-desc"><?php echo esc_textarea( \Activitypub\get_reply_intent_uri() ); ?></textarea>
</p> </p>
<p><span class="dashicons dashicons-clipboard"></span> <a href="javascript:;" class="copy-activitypub-bookmarklet-code" style="cursor: copy;"><?php esc_html_e( 'Copy to clipboard', 'activitypub' ); ?></a></p> <p><span class="dashicons dashicons-clipboard"></span> <a href="javascript:;" class="copy-activitypub-bookmarklet-code" style="cursor: copy;"><?php esc_html_e( 'Copy to clipboard', 'activitypub' ); ?></a></p>
</div> </div>
@ -25,14 +34,14 @@
jQuery( document ).ready( function( $ ) { jQuery( document ).ready( function( $ ) {
var $copyActivitypubBookmarkletCode = $( '.copy-activitypub-bookmarklet-code' ); var $copyActivitypubBookmarkletCode = $( '.copy-activitypub-bookmarklet-code' );
$copyActivitypubBookmarkletCode.on( 'click', function( event ) { $copyActivitypubBookmarkletCode.on( 'click', function( event ) {
// Get the text field // Get the text field.
var copyText = document.getElementById("activitypub-bookmarklet-code"); var copyText = document.getElementById("activitypub-bookmarklet-code");
// Select the text field // Select the text field.
copyText.select(); copyText.select();
copyText.setSelectionRange(0, 99999); // For mobile devices copyText.setSelectionRange(0, 99999); // For mobile devices.
// Copy the text inside the text field // Copy the text inside the text field.
navigator.clipboard.writeText(copyText.value); navigator.clipboard.writeText(copyText.value);
}); });
}); });

View file

@ -1,4 +1,9 @@
<?php <?php
/**
* ActivityPub User Followers List template.
*
* @package Activitypub
*/
$follower_count = \Activitypub\Collection\Followers::count_followers( \get_current_user_id() ); $follower_count = \Activitypub\Collection\Followers::count_followers( \get_current_user_id() );
// translators: The follower count. // translators: The follower count.

View file

@ -1,15 +1,21 @@
<?php <?php
/**
* ActivityPub User JSON template.
*
* @package Activitypub
*/
$user = \Activitypub\Collection\Users::get_by_id( \get_the_author_meta( 'ID' ) ); $user = \Activitypub\Collection\Users::get_by_id( \get_the_author_meta( 'ID' ) );
/* /**
* Action triggerd prior to the ActivityPub profile being created and sent to the client * Action triggered prior to the ActivityPub profile being created and sent to the client
*/ */
\do_action( 'activitypub_json_author_pre', $user->get__id() ); \do_action( 'activitypub_json_author_pre', $user->get__id() );
\header( 'Content-Type: application/activity+json' ); \header( 'Content-Type: application/activity+json' );
echo $user->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $user->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/* /**
* Action triggerd after the ActivityPub profile has been created and sent to the client * Action triggered after the ActivityPub profile has been created and sent to the client
*/ */
\do_action( 'activitypub_json_author_post', $user->get__id() ); \do_action( 'activitypub_json_author_post', $user->get__id() );

View file

@ -1,5 +1,13 @@
<?php <?php
// phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable /**
* ActivityPub User Settings template.
*
* @package Activitypub
*/
/* @var array $args Template arguments. */
$args = wp_parse_args( $args, array( 'description' => '' ) );
$user = \Activitypub\Collection\Users::get_by_id( \get_current_user_id() ); ?> $user = \Activitypub\Collection\Users::get_by_id( \get_current_user_id() ); ?>
<h2 id="activitypub"><?php \esc_html_e( 'ActivityPub', 'activitypub' ); ?></h2> <h2 id="activitypub"><?php \esc_html_e( 'ActivityPub', 'activitypub' ); ?></h2>
@ -18,7 +26,7 @@ $user = \Activitypub\Collection\Users::get_by_id( \get_current_user_id() ); ?>
<code><?php echo \esc_html( $user->get_webfinger() ); ?></code> or <code><?php echo \esc_html( $user->get_webfinger() ); ?></code> or
<code><?php echo \esc_url( $user->get_url() ); ?></code> <code><?php echo \esc_url( $user->get_url() ); ?></code>
</p> </p>
<?php // translators: the webfinger resource ?> <?php // translators: the webfinger resource. ?>
<p class="description"><?php \printf( \esc_html__( 'Follow "@%s" by searching for it on Mastodon, Friendica, etc.', 'activitypub' ), \esc_html( $user->get_webfinger() ) ); ?></p> <p class="description"><?php \printf( \esc_html__( 'Follow "@%s" by searching for it on Mastodon, Friendica, etc.', 'activitypub' ), \esc_html( $user->get_webfinger() ) ); ?></p>
</td> </td>
</tr> </tr>
@ -27,7 +35,7 @@ $user = \Activitypub\Collection\Users::get_by_id( \get_current_user_id() ); ?>
<label for="activitypub_description"><?php \esc_html_e( 'Biography', 'activitypub' ); ?></label> <label for="activitypub_description"><?php \esc_html_e( 'Biography', 'activitypub' ); ?></label>
</th> </th>
<td> <td>
<textarea name="activitypub_description" id="activitypub_description" rows="5" cols="30" placeholder="<?php echo \esc_html( get_user_meta( \get_current_user_id(), 'description', true ) ); ?>"><?php echo \esc_html( $args['description'] ); ?></textarea> <textarea name="activitypub_description" id="activitypub_description" rows="5" cols="30" placeholder="<?php echo \esc_attr( get_user_meta( \get_current_user_id(), 'description', true ) ); ?>"><?php echo \esc_html( $args['description'] ); ?></textarea>
<p class="description"><?php \esc_html_e( 'If you wish to use different biographical info for the fediverse, enter your alternate bio here.', 'activitypub' ); ?></p> <p class="description"><?php \esc_html_e( 'If you wish to use different biographical info for the fediverse, enter your alternate bio here.', 'activitypub' ); ?></p>
</td> </td>
</tr> </tr>
@ -43,18 +51,18 @@ $user = \Activitypub\Collection\Users::get_by_id( \get_current_user_id() ); ?>
$header_image = \get_user_option( 'activitypub_header_image', \get_current_user_id() ); $header_image = \get_user_option( 'activitypub_header_image', \get_current_user_id() );
if ( (int) $header_image ) { if ( (int) $header_image ) :
$classes_for_wrapper .= ' has-header-image'; $classes_for_wrapper .= ' has-header-image';
$classes_for_button = $classes_for_update_button; $classes_for_button = $classes_for_update_button;
$classes_for_button_on_change = $classes_for_upload_button; $classes_for_button_on_change = $classes_for_upload_button;
} else { else :
$classes_for_wrapper .= ' hidden'; $classes_for_wrapper .= ' hidden';
$classes_for_button = $classes_for_upload_button; $classes_for_button = $classes_for_upload_button;
$classes_for_button_on_change = $classes_for_update_button; $classes_for_button_on_change = $classes_for_update_button;
} endif;
?> ?>
<div id="activitypub-header-image-preview-wrapper" class='<?php echo esc_attr( $classes_for_wrapper ); ?>'> <div id="activitypub-header-image-preview-wrapper" class='<?php echo esc_attr( $classes_for_wrapper ); ?>'>
<img id='activitypub-header-image-preview' src='<?php echo \esc_url( \wp_get_attachment_url( $header_image ) ); ?>' style="max-width: 100%;" /> <img id='activitypub-header-image-preview' src='<?php echo \esc_url( \wp_get_attachment_url( $header_image ) ); ?>' style="max-width: 100%;" alt="" />
</div> </div>
<button <button
type="button" type="button"
@ -67,9 +75,9 @@ $user = \Activitypub\Collection\Users::get_by_id( \get_current_user_id() ); ?>
data-update="<?php \esc_attr_e( 'Set as Header Image', 'activitypub' ); ?>" data-update="<?php \esc_attr_e( 'Set as Header Image', 'activitypub' ); ?>"
<?php <?php
// We only need to constrain the user_id for users who can't edit others' posts. // We only need to constrain the user_id for users who can't edit others' posts.
if ( ! \current_user_can( 'edit_others_posts' ) ) { if ( ! \current_user_can( 'edit_others_posts' ) ) :
printf( 'data-user-id="%s"', esc_attr( \get_current_user_id() ) ); printf( 'data-user-id="%s"', esc_attr( \get_current_user_id() ) );
} endif;
?> ?>
data-state="<?php echo \esc_attr( (int) $header_image ); ?>"> data-state="<?php echo \esc_attr( (int) $header_image ); ?>">
<?php if ( (int) $header_image ) : ?> <?php if ( (int) $header_image ) : ?>
@ -102,7 +110,7 @@ $user = \Activitypub\Collection\Users::get_by_id( \get_current_user_id() ); ?>
<?php <?php
$extra_fields = \Activitypub\Collection\Extra_Fields::get_actor_fields( \get_current_user_id() ); $extra_fields = \Activitypub\Collection\Extra_Fields::get_actor_fields( \get_current_user_id() );
foreach ( $extra_fields as $extra_field ) { foreach ( $extra_fields as $extra_field ) :
?> ?>
<tr> <tr>
<td><?php echo \esc_html( $extra_field->post_title ); ?></td> <td><?php echo \esc_html( $extra_field->post_title ); ?></td>
@ -113,7 +121,7 @@ $user = \Activitypub\Collection\Users::get_by_id( \get_current_user_id() ); ?>
</a> </a>
</td> </td>
</tr> </tr>
<?php } ?> <?php endforeach; ?>
</table> </table>
<p> <p>

View file

@ -1,12 +1,15 @@
<?php <?php
/**
* ActivityPub Welcome template.
*
* @package Activitypub
*/
\load_template( \load_template(
__DIR__ . '/admin-header.php', __DIR__ . '/admin-header.php',
true, true,
array( array(
'settings' => '', 'welcome' => 'active',
'welcome' => 'active',
'blog-profile' => '',
'followers' => '',
) )
); );
?> ?>
@ -28,9 +31,9 @@
/* translators: %s is the domain of this site */ /* translators: %s is the domain of this site */
$reply_from_template = __( 'Reply from %s', 'activitypub' ); $reply_from_template = __( 'Reply from %s', 'activitypub' );
$button = sprintf( $button = sprintf(
'<a href="%s" class="button">%s</a>', '<a href="%s" class="button">%s</a>',
esc_attr( $bookmarklet_url ), // need to escape quotes for the bookmarklet esc_url( $bookmarklet_url ), // Need to escape quotes for the bookmarklet.
sprintf( $reply_from_template, \wp_parse_url( \home_url(), PHP_URL_HOST ) ) sprintf( $reply_from_template, \wp_parse_url( \home_url(), PHP_URL_HOST ) )
); );
/* translators: %s is where the button HTML will be rendered. */ /* translators: %s is where the button HTML will be rendered. */
@ -122,7 +125,7 @@
'If you have problems using this plugin, please check the <a href="%s">Site Health</a> page to ensure that your site is compatible and/or use the "Help" tab (in the top right of the settings pages).', 'If you have problems using this plugin, please check the <a href="%s">Site Health</a> page to ensure that your site is compatible and/or use the "Help" tab (in the top right of the settings pages).',
'activitypub' 'activitypub'
), ),
\esc_url_raw( admin_url( 'site-health.php' ) ) \esc_url( admin_url( 'site-health.php' ) )
), ),
'default' 'default'
); );
@ -146,7 +149,7 @@
</h4> </h4>
<div id="activitypub-settings-accordion-block-friends-plugin" class="activitypub-settings-accordion-panel plugin-card-friends"> <div id="activitypub-settings-accordion-block-friends-plugin" class="activitypub-settings-accordion-panel plugin-card-friends">
<p><?php \esc_html_e( 'To follow people on Mastodon or similar platforms using your own WordPress, you can use the Friends Plugin for WordPress which uses this plugin to receive posts and display them on your own WordPress, thus making your own WordPress a Fediverse instance of its own.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'To follow people on Mastodon or similar platforms using your own WordPress, you can use the Friends Plugin for WordPress which uses this plugin to receive posts and display them on your own WordPress, thus making your own WordPress a Fediverse instance of its own.', 'activitypub' ); ?></p>
<p><a href="<?php echo \esc_url_raw( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=friends&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the Friends Plugin', 'activitypub' ); ?></a></p> <p><a href="<?php echo \esc_url( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=friends&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the Friends Plugin', 'activitypub' ); ?></a></p>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if ( ! \class_exists( 'Hum' ) ) : ?> <?php if ( ! \class_exists( 'Hum' ) ) : ?>
@ -158,7 +161,7 @@
</h4> </h4>
<div id="activitypub-settings-accordion-block-activitypub-hum-plugin" class="activitypub-settings-accordion-panel plugin-card-hum" hidden="hidden"> <div id="activitypub-settings-accordion-block-activitypub-hum-plugin" class="activitypub-settings-accordion-panel plugin-card-hum" hidden="hidden">
<p><?php \esc_html_e( 'Hum is a personal URL shortener for WordPress, designed to provide short URLs to your personal content, both hosted on WordPress and elsewhere.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'Hum is a personal URL shortener for WordPress, designed to provide short URLs to your personal content, both hosted on WordPress and elsewhere.', 'activitypub' ); ?></p>
<p><a href="<?php echo \esc_url_raw( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=hum&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the Hum Plugin', 'activitypub' ); ?></a></p> <p><a href="<?php echo \esc_url( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=hum&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the Hum Plugin', 'activitypub' ); ?></a></p>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if ( ! \class_exists( 'Webfinger' ) ) : ?> <?php if ( ! \class_exists( 'Webfinger' ) ) : ?>
@ -171,7 +174,7 @@
<div id="activitypub-settings-accordion-block-activitypub-webfinger-plugin" class="activitypub-settings-accordion-panel plugin-card-webfinger" hidden="hidden"> <div id="activitypub-settings-accordion-block-activitypub-webfinger-plugin" class="activitypub-settings-accordion-panel plugin-card-webfinger" hidden="hidden">
<p><?php \esc_html_e( 'WebFinger is a protocol that allows for discovery of information about people and things identified by a URI. Information about a person might be discovered via an "acct:" URI, for example, which is a URI that looks like an email address.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'WebFinger is a protocol that allows for discovery of information about people and things identified by a URI. Information about a person might be discovered via an "acct:" URI, for example, which is a URI that looks like an email address.', 'activitypub' ); ?></p>
<p><?php \esc_html_e( 'The ActivityPub plugin comes with basic WebFinger support, if you need more configuration options and compatibility with other Fediverse/IndieWeb plugins, please install the WebFinger plugin.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'The ActivityPub plugin comes with basic WebFinger support, if you need more configuration options and compatibility with other Fediverse/IndieWeb plugins, please install the WebFinger plugin.', 'activitypub' ); ?></p>
<p><a href="<?php echo \esc_url_raw( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=webfinger&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the WebFinger Plugin', 'activitypub' ); ?></a></p> <p><a href="<?php echo \esc_url( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=webfinger&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the WebFinger Plugin', 'activitypub' ); ?></a></p>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if ( ! \function_exists( 'nodeinfo_init' ) ) : ?> <?php if ( ! \function_exists( 'nodeinfo_init' ) ) : ?>
@ -184,7 +187,7 @@
<div id="activitypub-settings-accordion-block-activitypub-nodeinfo-plugin" class="activitypub-settings-accordion-panel plugin-card-nodeinfo" hidden="hidden"> <div id="activitypub-settings-accordion-block-activitypub-nodeinfo-plugin" class="activitypub-settings-accordion-panel plugin-card-nodeinfo" hidden="hidden">
<p><?php \esc_html_e( 'NodeInfo is an effort to create a standardized way of exposing metadata about a server running one of the distributed social networks. The two key goals are being able to get better insights into the user base of distributed social networking and the ability to build tools that allow users to choose the best fitting software and server for their needs.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'NodeInfo is an effort to create a standardized way of exposing metadata about a server running one of the distributed social networks. The two key goals are being able to get better insights into the user base of distributed social networking and the ability to build tools that allow users to choose the best fitting software and server for their needs.', 'activitypub' ); ?></p>
<p><?php \esc_html_e( 'The ActivityPub plugin comes with a simple NodeInfo endpoint. If you need more configuration options and compatibility with other Fediverse plugins, please install the NodeInfo plugin.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'The ActivityPub plugin comes with a simple NodeInfo endpoint. If you need more configuration options and compatibility with other Fediverse plugins, please install the NodeInfo plugin.', 'activitypub' ); ?></p>
<p><a href="<?php echo \esc_url_raw( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=nodeinfo&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the NodeInfo Plugin', 'activitypub' ); ?></a></p> <p><a href="<?php echo \esc_url( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=nodeinfo&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the NodeInfo Plugin', 'activitypub' ); ?></a></p>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>