modified file w3-total-cache

This commit is contained in:
2024-03-28 09:40:10 +00:00
committed by Gitium
parent 218272bbcb
commit 34dbbce9b4
3707 changed files with 392891 additions and 166170 deletions

View File

@ -94,7 +94,7 @@ class Followers {
// phpcs:ignore
$json->orderedItems = array_map(
function( $item ) use ( $context ) {
function ( $item ) use ( $context ) {
if ( 'full' === $context ) {
return $item->to_array();
}

View File

@ -8,6 +8,7 @@ use Activitypub\Activity\Activity;
use Activitypub\Collection\Users as User_Collection;
use function Activitypub\get_context;
use function Activitypub\object_to_uri;
use function Activitypub\url_to_authorid;
use function Activitypub\get_rest_url_by_path;
use function Activitypub\get_remote_metadata_by_actor;
@ -93,11 +94,8 @@ class Inbox {
$json->generator = 'http://wordpress.org/?v=' . \get_bloginfo_rss( 'version' );
$json->type = 'OrderedCollectionPage';
$json->partOf = get_rest_url_by_path( sprintf( 'users/%d/inbox', $user->get__id() ) ); // phpcs:ignore
$json->totalItems = 0; // phpcs:ignore
$json->orderedItems = array(); // phpcs:ignore
$json->first = $json->partOf; // phpcs:ignore
// filter output
@ -154,37 +152,10 @@ class Inbox {
$data = $request->get_json_params();
$activity = Activity::init_from_array( $data );
$type = $request->get_param( 'type' );
$users = self::get_recipients( $data );
$type = \strtolower( $type );
if ( ! $users ) {
return new WP_Error(
'rest_invalid_param',
\__( 'No recipients found', 'activitypub' ),
array(
'status' => 400,
'params' => array(
'to' => \__( 'Please check/validate "to" field', 'activitypub' ),
'bto' => \__( 'Please check/validate "bto" field', 'activitypub' ),
'cc' => \__( 'Please check/validate "cc" field', 'activitypub' ),
'bcc' => \__( 'Please check/validate "bcc" field', 'activitypub' ),
'audience' => \__( 'Please check/validate "audience" field', 'activitypub' ),
),
)
);
}
foreach ( $users as $user ) {
$user = User_Collection::get_by_various( $user );
if ( is_wp_error( $user ) ) {
continue;
}
$type = \strtolower( $type );
\do_action( 'activitypub_inbox', $data, $user->ID, $type, $activity );
\do_action( "activitypub_inbox_{$type}", $data, $user->ID, $activity );
}
\do_action( 'activitypub_inbox', $data, null, $type, $activity );
\do_action( "activitypub_inbox_{$type}", $data, null, $activity );
$rest_response = new WP_REST_Response( array(), 202 );
$rest_response->header( 'Content-Type', 'application/activity+json; charset=' . get_option( 'blog_charset' ) );
@ -236,15 +207,8 @@ class Inbox {
$params['actor'] = array(
'required' => true,
'sanitize_callback' => function( $param, $request, $key ) {
if ( \is_array( $param ) ) {
if ( isset( $param['id'] ) ) {
$param = $param['id'];
} else {
$param = $param['url'];
}
}
return \esc_url_raw( $param );
'sanitize_callback' => function ( $param, $request, $key ) {
return object_to_uri( $param );
},
);
@ -252,7 +216,7 @@ class Inbox {
'required' => true,
//'type' => 'enum',
//'enum' => array( 'Create' ),
//'sanitize_callback' => function( $param, $request, $key ) {
//'sanitize_callback' => function ( $param, $request, $key ) {
// return \strtolower( $param );
//},
);
@ -285,11 +249,8 @@ class Inbox {
$params['actor'] = array(
'required' => true,
//'type' => array( 'object', 'string' ),
'sanitize_callback' => function( $param, $request, $key ) {
if ( ! \is_string( $param ) ) {
$param = $param['id'];
}
return \esc_url_raw( $param );
'sanitize_callback' => function ( $param, $request, $key ) {
return object_to_uri( $param );
},
);
@ -297,7 +258,7 @@ class Inbox {
'required' => true,
//'type' => 'enum',
//'enum' => array( 'Create' ),
//'sanitize_callback' => function( $param, $request, $key ) {
//'sanitize_callback' => function ( $param, $request, $key ) {
// return \strtolower( $param );
//},
);
@ -309,7 +270,7 @@ class Inbox {
$params['to'] = array(
'required' => false,
'sanitize_callback' => function( $param, $request, $key ) {
'sanitize_callback' => function ( $param, $request, $key ) {
if ( \is_string( $param ) ) {
$param = array( $param );
}
@ -319,7 +280,7 @@ class Inbox {
);
$params['cc'] = array(
'sanitize_callback' => function( $param, $request, $key ) {
'sanitize_callback' => function ( $param, $request, $key ) {
if ( \is_string( $param ) ) {
$param = array( $param );
}
@ -329,7 +290,7 @@ class Inbox {
);
$params['bcc'] = array(
'sanitize_callback' => function( $param, $request, $key ) {
'sanitize_callback' => function ( $param, $request, $key ) {
if ( \is_string( $param ) ) {
$param = array( $param );
}

View File

@ -105,6 +105,12 @@ class Nodeinfo {
'outbound' => array(),
);
$nodeinfo['metadata'] = array(
'nodeName' => \get_bloginfo( 'name' ),
'nodeDescription' => \get_bloginfo( 'description' ),
'nodeIcon' => \get_site_icon_url(),
);
return new WP_REST_Response( $nodeinfo, 200 );
}
@ -169,6 +175,10 @@ class Nodeinfo {
'rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
'href' => get_rest_url_by_path( 'nodeinfo' ),
),
array(
'rel' => 'https://www.w3.org/ns/activitystreams#Application',
'href' => get_rest_url_by_path( 'application' ),
),
);
return new \WP_REST_Response( $discovery, 200 );

View File

@ -50,14 +50,13 @@ class Users {
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( self::class, 'remote_follow_get' ),
'permission_callback' => '__return_true',
'args' => array(
'resource' => array(
'required' => true,
'sanitize_callback' => 'sanitize_text_field',
),
),
'permission_callback' => '__return_true',
),
)
);
@ -124,7 +123,7 @@ class Users {
return $template;
}
$resource = $user->get_resource();
$resource = $user->get_webfinger();
$url = str_replace( '{uri}', $resource, $template );
return new WP_REST_Response(

View File

@ -72,7 +72,7 @@ class Webfinger {
$params['resource'] = array(
'required' => true,
'type' => 'string',
'pattern' => '^acct:(.+)@(.+)$',
'pattern' => '^(acct:)|^(https?://)(.+)$',
);
return $params;
@ -94,10 +94,13 @@ class Webfinger {
$aliases = array(
$user->get_url(),
$user->get_alternate_url(),
);
$aliases = array_unique( $aliases );
$profile = array(
'subject' => $resource,
'subject' => sprintf( 'acct:%s', $user->get_webfinger() ),
'aliases' => array_values( array_unique( $aliases ) ),
'links' => array(
array(
@ -113,9 +116,9 @@ class Webfinger {
),
);
if ( 'Group' === $user->get_type() ) {
if ( 'Person' !== $user->get_type() ) {
$profile['links'][0]['properties'] = array(
'https://www.w3.org/ns/activitystreams#type' => 'Group',
'https://www.w3.org/ns/activitystreams#type' => $user->get_type(),
);
}