PluginProbe
Media Cleaner: Clean your WordPress! / 7.2.6
Media Cleaner: Clean your WordPress! v7.2.6
7.2.7 7.2.6 7.2.5 7.2.4 7.2.3 7.2.2 7.2.1 7.2.0 7.1.1 7.1.0 7.0.9 7.0.8 trunk 3.6.8 3.6.9 3.7.0 3.8.0 3.9.0 4.0.0 4.0.2 4.0.4 4.0.6 4.0.7 4.1.0 4.2.0 All 171 releases
media-cleaner / classes / parsers / attachments.php
attachments.php
26 lines 899 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Attachment (https://wordpress.org/plugins/attachments/)
4 // Added by Mike Meinz
5 // Discussion: https://wordpress.org/support/topic/attachments-plugin/
6
7 add_action( 'wpmc_scan_postmeta', 'wpmc_scan_postmeta_attachments' );
8
9 function wpmc_scan_postmeta_attachments($id) {
10 global $wpmc;
11 $postmeta_images_ids = array();
12 $attachments_json = get_post_meta( $id, 'attachments', true ); // meta_key=='attachments'
13 $attachments_decoded = is_string( $attachments_json ) ? json_decode( $attachments_json ) : false;
14 if ( !empty( $attachments_decoded )) {
15 foreach ( $attachments_decoded as $AttachmentData => $TheAttachment ) {
16 foreach( $TheAttachment as $AttachmentData => $attachment ) {
17 array_push( $postmeta_images_ids, $attachment->id );
18 }
19 }
20 }
21 if ( !empty( $postmeta_images_ids ) ) {
22 $wpmc->add_reference_id( $postmeta_images_ids, 'ATTACHMENT (ID)' ); // mm change
23 }
24 }
25
26 ?>