updated plugin ActivityPub version 9.1.0
This commit is contained in:
@ -56,7 +56,7 @@ class Embed {
|
||||
// If we don't have an avatar URL, but we have an author URL, try to fetch it.
|
||||
if ( ! $avatar_url && $author_url ) {
|
||||
$author = Http::get_remote_object( $author_url );
|
||||
if ( is_wp_error( $author ) ) {
|
||||
if ( \is_wp_error( $author ) ) {
|
||||
$author = array();
|
||||
} else {
|
||||
$avatar_url = $author['icon']['url'] ?? '';
|
||||
@ -78,7 +78,7 @@ class Embed {
|
||||
|
||||
$title = $activity_object['name'] ?? '';
|
||||
$content = $activity_object['content'] ?? '';
|
||||
$published = isset( $activity_object['published'] ) ? gmdate( get_option( 'date_format' ) . ', ' . get_option( 'time_format' ), strtotime( $activity_object['published'] ) ) : '';
|
||||
$published = isset( $activity_object['published'] ) ? \gmdate( \get_option( 'date_format' ) . ', ' . \get_option( 'time_format' ), \strtotime( $activity_object['published'] ) ) : '';
|
||||
$boosts = isset( $activity_object['shares']['totalItems'] ) ? (int) $activity_object['shares']['totalItems'] : null;
|
||||
$favorites = isset( $activity_object['likes']['totalItems'] ) ? (int) $activity_object['likes']['totalItems'] : null;
|
||||
|
||||
@ -95,7 +95,7 @@ class Embed {
|
||||
);
|
||||
} elseif ( isset( $activity_object['attachment'] ) ) {
|
||||
foreach ( $activity_object['attachment'] as $attachment ) {
|
||||
$type = isset( $attachment['mediaType'] ) ? strtok( $attachment['mediaType'], '/' ) : strtolower( $attachment['type'] );
|
||||
$type = isset( $attachment['mediaType'] ) ? \strtok( $attachment['mediaType'], '/' ) : \strtolower( $attachment['type'] );
|
||||
|
||||
switch ( $type ) {
|
||||
case 'image':
|
||||
@ -112,8 +112,8 @@ class Embed {
|
||||
$images = \array_slice( $images, 0, 4 );
|
||||
}
|
||||
|
||||
ob_start();
|
||||
load_template(
|
||||
\ob_start();
|
||||
\load_template(
|
||||
ACTIVITYPUB_PLUGIN_DIR . 'templates/embed.php',
|
||||
false,
|
||||
array(
|
||||
@ -137,11 +137,11 @@ class Embed {
|
||||
// Grab the CSS.
|
||||
$css = \file_get_contents( ACTIVITYPUB_PLUGIN_DIR . 'assets/css/activitypub-embed.css' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
|
||||
// We embed CSS directly because this may be in an iframe.
|
||||
printf( '<style>%s</style>', $css ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
\printf( '<style>%s</style>', $css ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
||||
// A little light whitespace cleanup.
|
||||
return preg_replace( '/\s+/', ' ', ob_get_clean() );
|
||||
return \preg_replace( '/\s+/', ' ', \ob_get_clean() );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -261,7 +261,7 @@ class Embed {
|
||||
return $response;
|
||||
}
|
||||
|
||||
if ( ( is_wp_error( $response ) && 'oembed_invalid_url' === $response->get_error_code() ) || empty( $response->html ) ) {
|
||||
if ( ( \is_wp_error( $response ) && 'oembed_invalid_url' === $response->get_error_code() ) || empty( $response->html ) ) {
|
||||
$url = $request->get_param( 'url' );
|
||||
$html = self::get_html( $url );
|
||||
|
||||
@ -274,12 +274,12 @@ class Embed {
|
||||
);
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-oembed.php */
|
||||
$data->html = apply_filters( 'oembed_result', $data->html, $url, $args );
|
||||
$data->html = \apply_filters( 'oembed_result', $data->html, $url, $args );
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-oembed-controller.php */
|
||||
$ttl = apply_filters( 'rest_oembed_ttl', DAY_IN_SECONDS, $url, $args );
|
||||
$ttl = \apply_filters( 'rest_oembed_ttl', DAY_IN_SECONDS, $url, $args );
|
||||
|
||||
set_transient( 'oembed_' . md5( serialize( $args ) ), $data, $ttl ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
|
||||
\set_transient( 'oembed_' . \md5( \serialize( $args ) ), $data, $ttl ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
|
||||
|
||||
$response = new \WP_REST_Response( $data );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user