PluginProbe
ActivityPub / 8.0.2
ActivityPub v8.0.2
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/class-embed.php +15 -16 9.3.08.0.2 View file →
@@ -48,20 +48,19 @@
48 48 *
49 49 * @return string The embed HTML.
50 50 */
51 51 public static function get_html_for_object( $activity_object, $inline_css = true ) {
52 - // `attributedTo` may be a string, an embedded actor object, or a list of references. Normalize it to a URI string before use.
53 - $author_url = object_to_uri( $activity_object['attributedTo'] ?? '' ) ?? '';
54 - $avatar_url = object_to_uri( $activity_object['icon']['url'] ?? '' ) ?? '';
55 - $author_name = $author_url;
52 + $author_name = $activity_object['attributedTo'] ?? '';
53 + $avatar_url = $activity_object['icon']['url'] ?? '';
54 + $author_url = $author_name;
56 55
57 56 // If we don't have an avatar URL, but we have an author URL, try to fetch it.
58 57 if ( ! $avatar_url && $author_url ) {
59 58 $author = Http::get_remote_object( $author_url );
60 - if ( \is_wp_error( $author ) ) {
59 + if ( is_wp_error( $author ) ) {
61 60 $author = array();
62 61 } else {
63 - $avatar_url = object_to_uri( $author['icon']['url'] ?? '' ) ?? '';
62 + $avatar_url = $author['icon']['url'] ?? '';
64 63 $author_name = empty( $author['name'] ) ? $author_name : $author['name'];
65 64 }
66 65 }
67 66
@@ -78,9 +77,9 @@
78 77 }
79 78
80 79 $title = $activity_object['name'] ?? '';
81 80 $content = $activity_object['content'] ?? '';
82 - $published = isset( $activity_object['published'] ) ? \gmdate( \get_option( 'date_format' ) . ', ' . \get_option( 'time_format' ), \strtotime( $activity_object['published'] ) ) : '';
81 + $published = isset( $activity_object['published'] ) ? gmdate( get_option( 'date_format' ) . ', ' . get_option( 'time_format' ), strtotime( $activity_object['published'] ) ) : '';
83 82 $boosts = isset( $activity_object['shares']['totalItems'] ) ? (int) $activity_object['shares']['totalItems'] : null;
84 83 $favorites = isset( $activity_object['likes']['totalItems'] ) ? (int) $activity_object['likes']['totalItems'] : null;
85 84
86 85 $audio = null;
@@ -95,9 +94,9 @@
95 94 ),
96 95 );
97 96 } elseif ( isset( $activity_object['attachment'] ) ) {
98 97 foreach ( $activity_object['attachment'] as $attachment ) {
99 - $type = isset( $attachment['mediaType'] ) ? \strtok( $attachment['mediaType'], '/' ) : \strtolower( $attachment['type'] );
98 + $type = isset( $attachment['mediaType'] ) ? strtok( $attachment['mediaType'], '/' ) : strtolower( $attachment['type'] );
100 99
101 100 switch ( $type ) {
102 101 case 'image':
103 102 $images[] = $attachment;
@@ -112,10 +111,10 @@
112 111 }
113 112 $images = \array_slice( $images, 0, 4 );
114 113 }
115 114
116 - \ob_start();
117 - \load_template(
115 + ob_start();
116 + load_template(
118 117 ACTIVITYPUB_PLUGIN_DIR . 'templates/embed.php',
119 118 false,
120 119 array(
121 120 'audio' => $audio,
@@ -137,13 +136,13 @@
137 136 if ( $inline_css ) {
138 137 // Grab the CSS.
139 138 $css = \file_get_contents( ACTIVITYPUB_PLUGIN_DIR . 'assets/css/activitypub-embed.css' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
140 139 // We embed CSS directly because this may be in an iframe.
141 - \printf( '<style>%s</style>', $css ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
140 + printf( '<style>%s</style>', $css ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
142 141 }
143 142
144 143 // A little light whitespace cleanup.
145 - return \preg_replace( '/\s+/', ' ', \ob_get_clean() );
144 + return preg_replace( '/\s+/', ' ', ob_get_clean() );
146 145 }
147 146
148 147 /**
149 148 * Check if a real oEmbed result exists for the given URL.
@@ -261,9 +260,9 @@
261 260 if ( '/oembed/1.0/proxy' !== $request->get_route() ) {
262 261 return $response;
263 262 }
264 263
265 - if ( ( \is_wp_error( $response ) && 'oembed_invalid_url' === $response->get_error_code() ) || empty( $response->html ) ) {
264 + if ( ( is_wp_error( $response ) && 'oembed_invalid_url' === $response->get_error_code() ) || empty( $response->html ) ) {
266 265 $url = $request->get_param( 'url' );
267 266 $html = self::get_html( $url );
268 267
269 268 if ( $html ) {
@@ -274,14 +273,14 @@
274 273 'scripts' => array(),
275 274 );
276 275
277 276 /** This filter is documented in wp-includes/class-wp-oembed.php */
278 - $data->html = \apply_filters( 'oembed_result', $data->html, $url, $args );
277 + $data->html = apply_filters( 'oembed_result', $data->html, $url, $args );
279 278
280 279 /** This filter is documented in wp-includes/class-wp-oembed-controller.php */
281 - $ttl = \apply_filters( 'rest_oembed_ttl', DAY_IN_SECONDS, $url, $args );
280 + $ttl = apply_filters( 'rest_oembed_ttl', DAY_IN_SECONDS, $url, $args );
282 281
283 - \set_transient( 'oembed_' . \md5( \serialize( $args ) ), $data, $ttl ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
282 + set_transient( 'oembed_' . md5( serialize( $args ) ), $data, $ttl ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
284 283
285 284 $response = new \WP_REST_Response( $data );
286 285 }
287 286 } elseif ( ! empty( $request->get_param( 'activitypub' ) ) ) {