| @@ -55,11 +55,9 @@ | ||
| 55 | 55 | |
| 56 | 56 | // If we don't have an avatar URL, but we have an author URL, try to fetch it. |
| 57 | 57 | if ( ! $avatar_url && $author_url ) { |
| 58 | 58 | $author = Http::get_remote_object( $author_url ); |
| 59 | - if ( \is_wp_error( $author ) ) { | |
| 60 | - $author = array(); | |
| 61 | - } else { | |
| 59 | + if ( ! is_wp_error( $author ) ) { | |
| 62 | 60 | $avatar_url = $author['icon']['url'] ?? ''; |
| 63 | 61 | $author_name = empty( $author['name'] ) ? $author_name : $author['name']; |
| 64 | 62 | } |
| 65 | 63 | } |
| @@ -77,9 +75,9 @@ | ||
| 77 | 75 | } |
| 78 | 76 | |
| 79 | 77 | $title = $activity_object['name'] ?? ''; |
| 80 | 78 | $content = $activity_object['content'] ?? ''; |
| 81 | - $published = isset( $activity_object['published'] ) ? \gmdate( \get_option( 'date_format' ) . ', ' . \get_option( 'time_format' ), \strtotime( $activity_object['published'] ) ) : ''; | |
| 79 | + $published = isset( $activity_object['published'] ) ? gmdate( get_option( 'date_format' ) . ', ' . get_option( 'time_format' ), strtotime( $activity_object['published'] ) ) : ''; | |
| 82 | 80 | $boosts = isset( $activity_object['shares']['totalItems'] ) ? (int) $activity_object['shares']['totalItems'] : null; |
| 83 | 81 | $favorites = isset( $activity_object['likes']['totalItems'] ) ? (int) $activity_object['likes']['totalItems'] : null; |
| 84 | 82 | |
| 85 | 83 | $audio = null; |
| @@ -94,9 +92,9 @@ | ||
| 94 | 92 | ), |
| 95 | 93 | ); |
| 96 | 94 | } elseif ( isset( $activity_object['attachment'] ) ) { |
| 97 | 95 | foreach ( $activity_object['attachment'] as $attachment ) { |
| 98 | - $type = isset( $attachment['mediaType'] ) ? \strtok( $attachment['mediaType'], '/' ) : \strtolower( $attachment['type'] ); | |
| 96 | + $type = isset( $attachment['mediaType'] ) ? strtok( $attachment['mediaType'], '/' ) : strtolower( $attachment['type'] ); | |
| 99 | 97 | |
| 100 | 98 | switch ( $type ) { |
| 101 | 99 | case 'image': |
| 102 | 100 | $images[] = $attachment; |
| @@ -111,10 +109,10 @@ | ||
| 111 | 109 | } |
| 112 | 110 | $images = \array_slice( $images, 0, 4 ); |
| 113 | 111 | } |
| 114 | 112 | |
| 115 | - \ob_start(); | |
| 116 | - \load_template( | |
| 113 | + ob_start(); | |
| 114 | + load_template( | |
| 117 | 115 | ACTIVITYPUB_PLUGIN_DIR . 'templates/embed.php', |
| 118 | 116 | false, |
| 119 | 117 | array( |
| 120 | 118 | 'audio' => $audio, |
| @@ -136,13 +134,13 @@ | ||
| 136 | 134 | if ( $inline_css ) { |
| 137 | 135 | // Grab the CSS. |
| 138 | 136 | $css = \file_get_contents( ACTIVITYPUB_PLUGIN_DIR . 'assets/css/activitypub-embed.css' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents |
| 139 | 137 | // We embed CSS directly because this may be in an iframe. |
| 140 | - \printf( '<style>%s</style>', $css ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 138 | + printf( '<style>%s</style>', $css ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 141 | 139 | } |
| 142 | 140 | |
| 143 | 141 | // A little light whitespace cleanup. |
| 144 | - return \preg_replace( '/\s+/', ' ', \ob_get_clean() ); | |
| 142 | + return preg_replace( '/\s+/', ' ', ob_get_clean() ); | |
| 145 | 143 | } |
| 146 | 144 | |
| 147 | 145 | /** |
| 148 | 146 | * Check if a real oEmbed result exists for the given URL. |
| @@ -260,9 +258,9 @@ | ||
| 260 | 258 | if ( '/oembed/1.0/proxy' !== $request->get_route() ) { |
| 261 | 259 | return $response; |
| 262 | 260 | } |
| 263 | 261 | |
| 264 | - if ( ( \is_wp_error( $response ) && 'oembed_invalid_url' === $response->get_error_code() ) || empty( $response->html ) ) { | |
| 262 | + if ( ( is_wp_error( $response ) && 'oembed_invalid_url' === $response->get_error_code() ) || empty( $response->html ) ) { | |
| 265 | 263 | $url = $request->get_param( 'url' ); |
| 266 | 264 | $html = self::get_html( $url ); |
| 267 | 265 | |
| 268 | 266 | if ( $html ) { |
| @@ -273,14 +271,14 @@ | ||
| 273 | 271 | 'scripts' => array(), |
| 274 | 272 | ); |
| 275 | 273 | |
| 276 | 274 | /** This filter is documented in wp-includes/class-wp-oembed.php */ |
| 277 | - $data->html = \apply_filters( 'oembed_result', $data->html, $url, $args ); | |
| 275 | + $data->html = apply_filters( 'oembed_result', $data->html, $url, $args ); | |
| 278 | 276 | |
| 279 | 277 | /** This filter is documented in wp-includes/class-wp-oembed-controller.php */ |
| 280 | - $ttl = \apply_filters( 'rest_oembed_ttl', DAY_IN_SECONDS, $url, $args ); | |
| 278 | + $ttl = apply_filters( 'rest_oembed_ttl', DAY_IN_SECONDS, $url, $args ); | |
| 281 | 279 | |
| 282 | - \set_transient( 'oembed_' . \md5( \serialize( $args ) ), $data, $ttl ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize | |
| 280 | + set_transient( 'oembed_' . md5( serialize( $args ) ), $data, $ttl ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize | |
| 283 | 281 | |
| 284 | 282 | $response = new \WP_REST_Response( $data ); |
| 285 | 283 | } |
| 286 | 284 | } elseif ( ! empty( $request->get_param( 'activitypub' ) ) ) { |