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-attachments.php +12 -12 9.2.08.0.2 View file →
@@ -48,9 +48,9 @@
48 48 public static function import( $attachments, $post_id, $author_id = 0 ) {
49 49 // First, import inline images from the post content.
50 50 $inline_mappings = self::import_inline_images( $post_id, $author_id );
51 51
52 - if ( empty( $attachments ) || ! \is_array( $attachments ) ) {
52 + if ( empty( $attachments ) || ! is_array( $attachments ) ) {
53 53 return array();
54 54 }
55 55
56 56 $attachment_ids = array();
@@ -113,9 +113,9 @@
113 113 return array();
114 114 }
115 115
116 116 // Find all img tags in the content.
117 - \preg_match_all( '/<img[^>]+src=["\']([^"\']+)["\'][^>]*>/i', $post->post_content, $matches );
117 + preg_match_all( '/<img[^>]+src=["\']([^"\']+)["\'][^>]*>/i', $post->post_content, $matches );
118 118
119 119 if ( empty( $matches[1] ) ) {
120 120 return array();
121 121 }
@@ -171,9 +171,9 @@
171 171 if ( \is_object( $attachment ) ) {
172 172 $attachment = \get_object_vars( $attachment );
173 173 }
174 174
175 - if ( ! \is_array( $attachment ) || empty( $attachment['url'] ) ) {
175 + if ( ! is_array( $attachment ) || empty( $attachment['url'] ) ) {
176 176 return false;
177 177 }
178 178
179 179 return array(
@@ -206,9 +206,9 @@
206 206 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
207 207
208 208 $filesystem = new \WP_Filesystem_Direct( null );
209 209
210 - $is_local = ! \preg_match( '#^https?://#i', $attachment_data['url'] );
210 + $is_local = ! preg_match( '#^https?://#i', $attachment_data['url'] );
211 211
212 212 if ( $is_local ) {
213 213 // Validate local path is within allowed directories to prevent file disclosure.
214 214 $allowed = self::is_allowed_local_path( $attachment_data['url'] );
@@ -218,9 +218,9 @@
218 218
219 219 // Read local file from disk.
220 220 if ( ! $filesystem->exists( $attachment_data['url'] ) ) {
221 221 /* translators: %s: file path */
222 - return new \WP_Error( 'file_not_found', \sprintf( \__( 'File not found: %s', 'activitypub' ), $attachment_data['url'] ) );
222 + return new \WP_Error( 'file_not_found', sprintf( \__( 'File not found: %s', 'activitypub' ), $attachment_data['url'] ) );
223 223 }
224 224
225 225 // Copy to temp file so media_handle_sideload doesn't move the original.
226 226 $tmp_file = \wp_tempnam( \basename( $attachment_data['url'] ) );
@@ -278,9 +278,9 @@
278 278
279 279 // Add alt text for images.
280 280 if ( ! empty( $attachment_data['name'] ) ) {
281 281 $original_mime = $attachment_data['mediaType'] ?? '';
282 - if ( 'image' === \strtok( $original_mime, '/' ) ) {
282 + if ( 'image' === strtok( $original_mime, '/' ) ) {
283 283 $post_data['meta_input']['_wp_attachment_image_alt'] = $attachment_data['name'];
284 284 }
285 285 }
286 286
@@ -458,9 +458,9 @@
458 458 return;
459 459 }
460 460
461 461 $media = self::generate_media_markup( $attachment_ids );
462 - $separator = empty( \trim( $post->post_content ) ) ? '' : "\n\n";
462 + $separator = empty( trim( $post->post_content ) ) ? '' : "\n\n";
463 463
464 464 \wp_update_post(
465 465 array(
466 466 'ID' => $post_id,
@@ -497,13 +497,13 @@
497 497 return $custom_markup;
498 498 }
499 499
500 500 // Default to block markup.
501 - $type = \strtok( \get_post_mime_type( $attachment_ids[0] ), '/' );
501 + $type = strtok( \get_post_mime_type( $attachment_ids[0] ), '/' );
502 502
503 503 // Single video or audio file.
504 504 if ( 1 === \count( $attachment_ids ) && ( 'video' === $type || 'audio' === $type ) ) {
505 - return \sprintf(
505 + return sprintf(
506 506 '<!-- wp:%1$s {"id":"%2$s"} --><figure class="wp-block-%1$s"><%1$s controls src="%3$s"></%1$s></figure><!-- /wp:%1$s -->',
507 507 \esc_attr( $type ),
508 508 \esc_attr( $attachment_ids[0] ),
509 509 \esc_url( \wp_get_attachment_url( $attachment_ids[0] ) )
@@ -639,9 +639,9 @@
639 639 return;
640 640 }
641 641
642 642 $media = self::generate_files_markup( $files );
643 - $separator = empty( \trim( $content ) ) ? '' : "\n\n";
643 + $separator = empty( trim( $content ) ) ? '' : "\n\n";
644 644
645 645 self::update_object_content( $object_id, $object_type, $content . $separator . $media );
646 646 }
647 647
@@ -682,13 +682,13 @@
682 682 return $custom_markup;
683 683 }
684 684
685 685 // Default to block markup.
686 - $type = \strtok( $files[0]['mime_type'], '/' );
686 + $type = strtok( $files[0]['mime_type'], '/' );
687 687
688 688 // Single video or audio file.
689 689 if ( 1 === \count( $files ) && ( 'video' === $type || 'audio' === $type ) ) {
690 - return \sprintf(
690 + return sprintf(
691 691 '<!-- wp:%1$s --><figure class="wp-block-%1$s"><%1$s controls src="%2$s"></%1$s></figure><!-- /wp:%1$s -->',
692 692 \esc_attr( $type ),
693 693 \esc_url( $files[0]['url'] )
694 694 );