2020-04-07 13:03:04 +00:00
|
|
|
<?php
|
|
|
|
namespace Activitypub;
|
|
|
|
|
2023-12-08 23:23:11 +00:00
|
|
|
use Exception;
|
2023-10-22 22:20:53 +00:00
|
|
|
use Activitypub\Signature;
|
|
|
|
use Activitypub\Collection\Users;
|
2023-12-08 23:23:11 +00:00
|
|
|
use Activitypub\Collection\Followers;
|
|
|
|
|
2024-02-08 12:31:25 +00:00
|
|
|
use function Activitypub\is_comment;
|
2024-03-28 09:39:50 +00:00
|
|
|
use function Activitypub\sanitize_url;
|
|
|
|
use function Activitypub\is_local_comment;
|
2024-02-08 12:31:25 +00:00
|
|
|
use function Activitypub\is_activitypub_request;
|
2024-03-28 09:39:50 +00:00
|
|
|
use function Activitypub\should_comment_be_federated;
|
2023-10-22 22:20:53 +00:00
|
|
|
|
2020-04-07 13:03:04 +00:00
|
|
|
/**
|
|
|
|
* ActivityPub Class
|
|
|
|
*
|
|
|
|
* @author Matthias Pfefferle
|
|
|
|
*/
|
|
|
|
class Activitypub {
|
|
|
|
/**
|
2020-12-25 19:23:08 +00:00
|
|
|
* Initialize the class, registering WordPress hooks.
|
2020-04-07 13:03:04 +00:00
|
|
|
*/
|
|
|
|
public static function init() {
|
2023-10-22 22:20:53 +00:00
|
|
|
\add_filter( 'template_include', array( self::class, 'render_json_template' ), 99 );
|
2024-02-08 12:31:25 +00:00
|
|
|
\add_action( 'template_redirect', array( self::class, 'template_redirect' ) );
|
2023-10-22 22:20:53 +00:00
|
|
|
\add_filter( 'query_vars', array( self::class, 'add_query_vars' ) );
|
|
|
|
\add_filter( 'pre_get_avatar_data', array( self::class, 'pre_get_avatar_data' ), 11, 2 );
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
// Add support for ActivityPub to custom post types
|
2024-03-28 09:39:50 +00:00
|
|
|
$post_types = \get_option( 'activitypub_support_post_types', array( 'post' ) ) ? \get_option( 'activitypub_support_post_types', array( 'post' ) ) : array();
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
foreach ( $post_types as $post_type ) {
|
|
|
|
\add_post_type_support( $post_type, 'activitypub' );
|
|
|
|
}
|
|
|
|
|
2023-10-22 22:20:53 +00:00
|
|
|
\add_action( 'wp_trash_post', array( self::class, 'trash_post' ), 1 );
|
|
|
|
\add_action( 'untrash_post', array( self::class, 'untrash_post' ), 1 );
|
|
|
|
|
|
|
|
\add_action( 'init', array( self::class, 'add_rewrite_rules' ), 11 );
|
2024-04-19 10:49:31 +00:00
|
|
|
\add_action( 'init', array( self::class, 'theme_compat' ), 11 );
|
2023-10-22 22:20:53 +00:00
|
|
|
|
2024-04-19 10:49:31 +00:00
|
|
|
\add_action( 'user_register', array( self::class, 'user_register' ) );
|
2023-10-22 22:20:53 +00:00
|
|
|
|
|
|
|
\add_action( 'in_plugin_update_message-' . ACTIVITYPUB_PLUGIN_BASENAME, array( self::class, 'plugin_update_message' ) );
|
2023-12-08 23:23:11 +00:00
|
|
|
|
|
|
|
// register several post_types
|
|
|
|
self::register_post_types();
|
2023-10-22 22:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Activation Hook
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function activate() {
|
|
|
|
self::flush_rewrite_rules();
|
|
|
|
Scheduler::register_schedules();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deactivation Hook
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function deactivate() {
|
|
|
|
self::flush_rewrite_rules();
|
|
|
|
Scheduler::deregister_schedules();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Uninstall Hook
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function uninstall() {
|
|
|
|
Scheduler::deregister_schedules();
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-12-25 19:23:08 +00:00
|
|
|
* Return a AS2 JSON version of an author, post or page.
|
2020-04-07 13:03:04 +00:00
|
|
|
*
|
2020-12-25 19:23:08 +00:00
|
|
|
* @param string $template The path to the template object.
|
2020-04-07 13:03:04 +00:00
|
|
|
*
|
2020-12-25 19:23:08 +00:00
|
|
|
* @return string The new path to the JSON template.
|
2020-04-07 13:03:04 +00:00
|
|
|
*/
|
|
|
|
public static function render_json_template( $template ) {
|
2023-10-22 22:20:53 +00:00
|
|
|
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
|
|
|
|
return $template;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! is_activitypub_request() ) {
|
2020-04-07 13:03:04 +00:00
|
|
|
return $template;
|
|
|
|
}
|
|
|
|
|
2023-10-22 22:20:53 +00:00
|
|
|
$json_template = false;
|
|
|
|
|
2023-01-18 16:39:54 +00:00
|
|
|
// check if user can publish posts
|
2023-10-22 22:20:53 +00:00
|
|
|
if ( \is_author() && is_wp_error( Users::get_by_id( \get_the_author_meta( 'ID' ) ) ) ) {
|
2023-01-18 16:39:54 +00:00
|
|
|
return $template;
|
|
|
|
}
|
|
|
|
|
2024-03-28 09:39:50 +00:00
|
|
|
// check if blog-user is enabled
|
|
|
|
if ( \is_home() && is_wp_error( Users::get_by_id( Users::BLOG_USER_ID ) ) ) {
|
|
|
|
return $template;
|
|
|
|
}
|
|
|
|
|
2020-04-07 13:03:04 +00:00
|
|
|
if ( \is_author() ) {
|
2023-03-17 22:33:51 +00:00
|
|
|
$json_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/author-json.php';
|
2024-02-08 12:31:25 +00:00
|
|
|
} elseif ( is_comment() ) {
|
|
|
|
$json_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/comment-json.php';
|
2020-04-07 13:03:04 +00:00
|
|
|
} elseif ( \is_singular() ) {
|
2023-03-17 22:33:51 +00:00
|
|
|
$json_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/post-json.php';
|
2021-07-25 23:24:56 +00:00
|
|
|
} elseif ( \is_home() ) {
|
2023-03-17 22:33:51 +00:00
|
|
|
$json_template = ACTIVITYPUB_PLUGIN_DIR . '/templates/blog-json.php';
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
|
2023-10-22 22:20:53 +00:00
|
|
|
if ( ACTIVITYPUB_AUTHORIZED_FETCH ) {
|
|
|
|
$verification = Signature::verify_http_signature( $_SERVER );
|
|
|
|
if ( \is_wp_error( $verification ) ) {
|
|
|
|
// fallback as template_loader can't return http headers
|
|
|
|
return $template;
|
|
|
|
}
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
|
2023-10-22 22:20:53 +00:00
|
|
|
return $json_template;
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
|
2024-02-08 12:31:25 +00:00
|
|
|
/**
|
|
|
|
* Custom redirects for ActivityPub requests.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function template_redirect() {
|
|
|
|
$comment_id = get_query_var( 'c', null );
|
|
|
|
|
|
|
|
// check if it seems to be a comment
|
|
|
|
if ( ! $comment_id ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$comment = get_comment( $comment_id );
|
|
|
|
|
|
|
|
// load a 404 page if `c` is set but not valid
|
|
|
|
if ( ! $comment ) {
|
|
|
|
global $wp_query;
|
|
|
|
$wp_query->set_404();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// stop if it's not an ActivityPub comment
|
2024-03-28 09:39:50 +00:00
|
|
|
if ( is_activitypub_request() && ! is_local_comment( $comment ) ) {
|
2024-02-08 12:31:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wp_safe_redirect( get_comment_link( $comment ) );
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2020-04-07 13:03:04 +00:00
|
|
|
/**
|
2020-12-25 19:23:08 +00:00
|
|
|
* Add the 'activitypub' query variable so WordPress won't mangle it.
|
2020-04-07 13:03:04 +00:00
|
|
|
*/
|
|
|
|
public static function add_query_vars( $vars ) {
|
|
|
|
$vars[] = 'activitypub';
|
2024-02-08 12:31:25 +00:00
|
|
|
$vars[] = 'c';
|
|
|
|
$vars[] = 'p';
|
2020-04-07 13:03:04 +00:00
|
|
|
|
|
|
|
return $vars;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-12-25 19:23:08 +00:00
|
|
|
* Replaces the default avatar.
|
2020-04-07 13:03:04 +00:00
|
|
|
*
|
2020-12-25 19:23:08 +00:00
|
|
|
* @param array $args Arguments passed to get_avatar_data(), after processing.
|
|
|
|
* @param int|string|object $id_or_email A user ID, email address, or comment object.
|
2020-04-07 13:03:04 +00:00
|
|
|
*
|
|
|
|
* @return array $args
|
|
|
|
*/
|
|
|
|
public static function pre_get_avatar_data( $args, $id_or_email ) {
|
|
|
|
if (
|
|
|
|
! $id_or_email instanceof \WP_Comment ||
|
|
|
|
! isset( $id_or_email->comment_type ) ||
|
|
|
|
$id_or_email->user_id
|
|
|
|
) {
|
|
|
|
return $args;
|
|
|
|
}
|
|
|
|
|
|
|
|
$allowed_comment_types = \apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
|
2023-10-22 22:20:53 +00:00
|
|
|
if (
|
|
|
|
! empty( $id_or_email->comment_type ) &&
|
|
|
|
! \in_array(
|
|
|
|
$id_or_email->comment_type,
|
|
|
|
(array) $allowed_comment_types,
|
|
|
|
true
|
|
|
|
)
|
|
|
|
) {
|
2020-04-07 13:03:04 +00:00
|
|
|
$args['url'] = false;
|
|
|
|
/** This filter is documented in wp-includes/link-template.php */
|
|
|
|
return \apply_filters( 'get_avatar_data', $args, $id_or_email );
|
|
|
|
}
|
|
|
|
|
2020-12-25 19:23:08 +00:00
|
|
|
// Check if comment has an avatar.
|
2020-04-07 13:03:04 +00:00
|
|
|
$avatar = self::get_avatar_url( $id_or_email->comment_ID );
|
|
|
|
|
|
|
|
if ( $avatar ) {
|
2024-04-19 10:49:31 +00:00
|
|
|
if ( empty( $args['class'] ) ) {
|
|
|
|
$args['class'] = array();
|
|
|
|
} elseif ( \is_string( $args['class'] ) ) {
|
|
|
|
$args['class'] = \explode( ' ', $args['class'] );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
2024-04-19 10:49:31 +00:00
|
|
|
|
2020-04-07 13:03:04 +00:00
|
|
|
$args['url'] = $avatar;
|
|
|
|
$args['class'][] = 'avatar-activitypub';
|
2024-04-19 10:49:31 +00:00
|
|
|
$args['class'][] = 'u-photo';
|
|
|
|
$args['class'] = \array_unique( $args['class'] );
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $args;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-12-25 19:23:08 +00:00
|
|
|
* Function to retrieve Avatar URL if stored in meta.
|
2020-04-07 13:03:04 +00:00
|
|
|
*
|
|
|
|
* @param int|WP_Comment $comment
|
|
|
|
*
|
|
|
|
* @return string $url
|
|
|
|
*/
|
|
|
|
public static function get_avatar_url( $comment ) {
|
|
|
|
if ( \is_numeric( $comment ) ) {
|
|
|
|
$comment = \get_comment( $comment );
|
|
|
|
}
|
|
|
|
return \get_comment_meta( $comment->comment_ID, 'avatar_url', true );
|
|
|
|
}
|
2023-01-18 16:39:54 +00:00
|
|
|
|
2023-10-22 22:20:53 +00:00
|
|
|
/**
|
|
|
|
* Store permalink in meta, to send delete Activity.
|
|
|
|
*
|
|
|
|
* @param string $post_id The Post ID.
|
2023-01-18 16:39:54 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function trash_post( $post_id ) {
|
2023-10-22 22:20:53 +00:00
|
|
|
\add_post_meta(
|
|
|
|
$post_id,
|
|
|
|
'activitypub_canonical_url',
|
|
|
|
\get_permalink( $post_id ),
|
|
|
|
true
|
|
|
|
);
|
2023-01-18 16:39:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete permalink from meta
|
|
|
|
*
|
|
|
|
* @param string $post_id The Post ID
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function untrash_post( $post_id ) {
|
|
|
|
\delete_post_meta( $post_id, 'activitypub_canonical_url' );
|
|
|
|
}
|
2023-10-22 22:20:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add rewrite rules
|
|
|
|
*/
|
|
|
|
public static function add_rewrite_rules() {
|
|
|
|
// If another system needs to take precedence over the ActivityPub rewrite rules,
|
|
|
|
// they can define their own and will manually call the appropriate functions as required.
|
|
|
|
if ( ACTIVITYPUB_DISABLE_REWRITES ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! \class_exists( 'Webfinger' ) ) {
|
|
|
|
\add_rewrite_rule(
|
|
|
|
'^.well-known/webfinger',
|
|
|
|
'index.php?rest_route=/' . ACTIVITYPUB_REST_NAMESPACE . '/webfinger',
|
|
|
|
'top'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! \class_exists( 'Nodeinfo_Endpoint' ) && true === (bool) \get_option( 'blog_public', 1 ) ) {
|
|
|
|
\add_rewrite_rule(
|
|
|
|
'^.well-known/nodeinfo',
|
|
|
|
'index.php?rest_route=/' . ACTIVITYPUB_REST_NAMESPACE . '/nodeinfo/discovery',
|
|
|
|
'top'
|
|
|
|
);
|
|
|
|
\add_rewrite_rule(
|
|
|
|
'^.well-known/x-nodeinfo2',
|
|
|
|
'index.php?rest_route=/' . ACTIVITYPUB_REST_NAMESPACE . '/nodeinfo2',
|
|
|
|
'top'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
\add_rewrite_rule(
|
|
|
|
'^@([\w\-\.]+)',
|
|
|
|
'index.php?rest_route=/' . ACTIVITYPUB_REST_NAMESPACE . '/users/$matches[1]',
|
|
|
|
'top'
|
|
|
|
);
|
|
|
|
|
|
|
|
\add_rewrite_endpoint( 'activitypub', EP_AUTHORS | EP_PERMALINK | EP_PAGES );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flush rewrite rules;
|
|
|
|
*/
|
|
|
|
public static function flush_rewrite_rules() {
|
|
|
|
self::add_rewrite_rules();
|
|
|
|
\flush_rewrite_rules();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Theme compatibility stuff
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function theme_compat() {
|
|
|
|
$site_icon = get_theme_support( 'custom-logo' );
|
|
|
|
|
|
|
|
if ( ! $site_icon ) {
|
|
|
|
// custom logo support
|
|
|
|
add_theme_support(
|
|
|
|
'custom-logo',
|
|
|
|
array(
|
|
|
|
'height' => 80,
|
|
|
|
'width' => 80,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$custom_header = get_theme_support( 'custom-header' );
|
|
|
|
|
|
|
|
if ( ! $custom_header ) {
|
|
|
|
// This theme supports a custom header
|
|
|
|
$custom_header_args = array(
|
|
|
|
'width' => 1250,
|
|
|
|
'height' => 600,
|
|
|
|
'header-text' => true,
|
|
|
|
);
|
|
|
|
add_theme_support( 'custom-header', $custom_header_args );
|
|
|
|
}
|
2024-04-19 10:49:31 +00:00
|
|
|
|
|
|
|
// We assume that you want to use Post-Formats when enabling the setting
|
|
|
|
if ( 'wordpress-post-format' === \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE ) ) {
|
|
|
|
if ( ! get_theme_support( 'post-formats' ) ) {
|
|
|
|
// Add support for the Aside, Gallery Post Formats...
|
|
|
|
add_theme_support(
|
|
|
|
'post-formats',
|
|
|
|
array(
|
|
|
|
'gallery',
|
|
|
|
'status',
|
|
|
|
'image',
|
|
|
|
'video',
|
|
|
|
'audio',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2023-10-22 22:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display plugin upgrade notice to users
|
|
|
|
*
|
|
|
|
* @param array $data The plugin data
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function plugin_update_message( $data ) {
|
|
|
|
if ( ! isset( $data['upgrade_notice'] ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(
|
|
|
|
'<div class="update-message">%s</div>',
|
|
|
|
wp_kses(
|
|
|
|
wpautop( $data['upgrade_notice '] ),
|
|
|
|
array(
|
|
|
|
'p' => array(),
|
|
|
|
'a' => array( 'href', 'title' ),
|
|
|
|
'strong' => array(),
|
|
|
|
'em' => array(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2023-12-08 23:23:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the "Followers" Taxonomy
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private static function register_post_types() {
|
2024-02-08 12:31:25 +00:00
|
|
|
\register_post_type(
|
2023-12-08 23:23:11 +00:00
|
|
|
Followers::POST_TYPE,
|
|
|
|
array(
|
|
|
|
'labels' => array(
|
|
|
|
'name' => _x( 'Followers', 'post_type plural name', 'activitypub' ),
|
|
|
|
'singular_name' => _x( 'Follower', 'post_type single name', 'activitypub' ),
|
|
|
|
),
|
|
|
|
'public' => false,
|
|
|
|
'hierarchical' => false,
|
|
|
|
'rewrite' => false,
|
|
|
|
'query_var' => false,
|
|
|
|
'delete_with_user' => false,
|
|
|
|
'can_export' => true,
|
|
|
|
'supports' => array(),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2024-02-08 12:31:25 +00:00
|
|
|
\register_post_meta(
|
2023-12-08 23:23:11 +00:00
|
|
|
Followers::POST_TYPE,
|
|
|
|
'activitypub_inbox',
|
|
|
|
array(
|
|
|
|
'type' => 'string',
|
|
|
|
'single' => true,
|
|
|
|
'sanitize_callback' => 'sanitize_url',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2024-02-08 12:31:25 +00:00
|
|
|
\register_post_meta(
|
2023-12-08 23:23:11 +00:00
|
|
|
Followers::POST_TYPE,
|
|
|
|
'activitypub_errors',
|
|
|
|
array(
|
|
|
|
'type' => 'string',
|
|
|
|
'single' => false,
|
2024-02-08 12:31:25 +00:00
|
|
|
'sanitize_callback' => function ( $value ) {
|
2023-12-08 23:23:11 +00:00
|
|
|
if ( ! is_string( $value ) ) {
|
|
|
|
throw new Exception( 'Error message is no valid string' );
|
|
|
|
}
|
|
|
|
|
|
|
|
return esc_sql( $value );
|
|
|
|
},
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2024-02-08 12:31:25 +00:00
|
|
|
\register_post_meta(
|
2023-12-08 23:23:11 +00:00
|
|
|
Followers::POST_TYPE,
|
|
|
|
'activitypub_user_id',
|
|
|
|
array(
|
|
|
|
'type' => 'string',
|
|
|
|
'single' => false,
|
2024-02-08 12:31:25 +00:00
|
|
|
'sanitize_callback' => function ( $value ) {
|
2023-12-08 23:23:11 +00:00
|
|
|
return esc_sql( $value );
|
|
|
|
},
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2024-02-08 12:31:25 +00:00
|
|
|
\register_post_meta(
|
2023-12-08 23:23:11 +00:00
|
|
|
Followers::POST_TYPE,
|
|
|
|
'activitypub_actor_json',
|
|
|
|
array(
|
|
|
|
'type' => 'string',
|
|
|
|
'single' => true,
|
2024-02-08 12:31:25 +00:00
|
|
|
'sanitize_callback' => function ( $value ) {
|
2023-12-08 23:23:11 +00:00
|
|
|
return sanitize_text_field( $value );
|
|
|
|
},
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2024-02-08 12:31:25 +00:00
|
|
|
\do_action( 'activitypub_after_register_post_type' );
|
|
|
|
}
|
2024-04-19 10:49:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the 'activitypub' query variable so WordPress won't mangle it.
|
|
|
|
*
|
|
|
|
* @param int $user_id User ID.
|
|
|
|
* @param array $userdata The raw array of data passed to wp_insert_user().
|
|
|
|
*/
|
|
|
|
public static function user_register( $user_id ) {
|
|
|
|
if ( \user_can( $user_id, 'publish_posts' ) ) {
|
|
|
|
$user = \get_user_by( 'id', $user_id );
|
|
|
|
$user->add_cap( 'activitypub' );
|
|
|
|
}
|
|
|
|
}
|
2020-04-07 13:03:04 +00:00
|
|
|
}
|