I made the following modifications to Media Cleaner’s scan.php to make Media Cleaner handle the Attachments plugin. I hope you will consider adding this to the standard Media Cleaner plugin.
*** Added to the end of the __construct function in scan.php:
if ( class_exists( 'Attachments' ) )
add_action( 'wpmc_scan_postmeta', array( $this, 'scan_postmeta_attachments' ) );
*** Added to the end of scan.php:
public function scan_postmeta_attachments($id) {
$postmeta_images_ids=array();
$attachments_json=get_post_meta($id,'attachments',true); // meta_key=='attachments'
$attachments_decoded=is_string($attachments_json) ? json_decode($attachments_json) : false;
if (!empty($attachments_decoded )) {
foreach ($attachments_decoded as $AttachmentData => $TheAttachment) {
foreach($TheAttachment as $AttachmentData => $attachment) {
array_push($postmeta_images_ids,$attachment->id);
}
}
}
if (!empty($postmeta_images_ids)) {
$this->core->add_reference_id($postmeta_images_ids, 'META (ID)' );
}
}
*** An example of the format of the JSON string stored in the Meta_Value of Meta_Key==’attachments’ row for the post to which media items are attached
/*
Example of Attachments plugin list of attachments to one Page/Post:
id = Post_ID of Media Library item
title = Title to be displayed when web page is composed.
$attachments_json='{"attachments":[{"id":"27316","fields":{"title":"BOS June 20 2018 Regular Meeting Minutes"}},{"id":"27314","fields":{"title":"BOS June 20 2018 Public Hearing Minutes"}},{"id":"27302","fields":{"title":"BOS June 20 2018 Special Meeting Minutes"}},{"id":"27251","fields":{"title":"BOS June 6 2018 Regular Meeting Minutes"}},{"id":"27227","fields":{"title":"BOS June 6 2018 Public Hearing Minutes"}},{"id":"27069","fields":{"title":"BOS May 16 2018 Minutes"}},{"id":"26678","fields":{"title":"BOS April 18 2018 Minutes"}},{"id":"26608","fields":{"title":"BOS April 4 2018 Minutes"}},{"id":"26403","fields":{"title":"BOS March 7 2018 Regular Meeting Minutes"}},{"id":"26350","fields":{"title":"BOS March 7 2018 Special Budget Review Meeting"}},{"id":"26062","fields":{"title":"BOS February 21 2018 Regular Meeting Minutes"}},{"id":"26027","fields":{"title":"BOS February 21 2018 Public Hearing Minutes"}},{"id":"26002","fields":{"title":"BOS February 15 2018 Special Meeting Minutes"}},{"id":"25911","fields":{"title":"BOS February 7 2018 Minutes"}},{"id":"25812","fields":{"title":"BOS February 7 2018 Executive Session Minutes"}},{"id":"25802","fields":{"title":"BOS February 7 2018 Special Meeting Minutes"}},{"id":"25548","fields":{"title":"BOS January 17 2018 Minutes"}},{"id":"25458","fields":{"title":"BOS January 3 2018 Minutes"}}]}';
*/
-
This reply was modified 7 years, 1 month ago by
Mike Meinz.