attachments.php
6 years ago
blocks.php
1 month ago
common.php
4 months ago
maxmegamenu.php
1 month ago
meow_gallery.php
3 months ago
metaslider.php
1 month ago
my-calendar.php
1 month ago
woocommerce.php
1 month ago
wpseo.php
3 years ago
attachments.php
26 lines
| 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 | ?> |