├── README.md ├── .gitignore └── index.php /README.md: -------------------------------------------------------------------------------- 1 | # media-cleaner-pro-ssi-addon -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .DS_Store? 3 | ._* 4 | .Spotlight-V100 5 | .Trashes 6 | ehthumbs.db 7 | Thumbs.db 8 | _notes 9 | *.LCK 10 | /__assets 11 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | postmeta.' WHERE meta_value = "'.$media_id.'" LIMIT 1'; 38 | $results = $wpdb->get_results($query, 'ARRAY_A'); 39 | //print_r($results); 40 | if (!empty($results)) { 41 | $in_use = true; 42 | } 43 | 44 | if (!$in_use) { 45 | $query = 'SELECT * FROM '.$wpdb->options.' WHERE option_value = "'.$media_id.'" LIMIT 1'; 46 | $results = $wpdb->get_results($query, 'ARRAY_A'); 47 | //print_r($results); 48 | if (!empty($results)) { 49 | $in_use = true; 50 | } 51 | } 52 | if (!$in_use) { 53 | $query = 'SELECT * FROM '.$wpdb->termmeta.' WHERE meta_value = "'.$media_id.'" LIMIT 1'; 54 | $results = $wpdb->get_results($query, 'ARRAY_A'); 55 | //print_r($results); 56 | if (!empty($results)) { 57 | $in_use = true; 58 | } 59 | } 60 | if (!$in_use) { 61 | $query = 'SELECT * FROM '.$wpdb->usermeta.' WHERE meta_value = "'.$media_id.'" LIMIT 1'; 62 | $results = $wpdb->get_results($query, 'ARRAY_A'); 63 | //print_r($results); 64 | if (!empty($results)) { 65 | $in_use = true; 66 | } 67 | } 68 | 69 | 70 | 71 | // added for CM Gallery Fields 72 | //implode(",", $gallery_fields); 73 | if ($in_use) { 74 | $gallery_fields = array( 75 | 'tile_pattern_layouts_and_designs_slider', 76 | 'mood_sourcing_slider', 77 | 'product_sourcing_slider', 78 | 'gallery' 79 | ); 80 | $query = 'SELECT * FROM '.$wpdb->postmeta.' 81 | WHERE meta_key IN ("'.implode(",", $gallery_fields).'") AND 82 | meta_value LIKE "%\"'.$media_id.'\"%" LIMIT 1'; 83 | $results = $wpdb->get_results($query, 'ARRAY_A'); 84 | //print_r($results); 85 | if (!empty($results)) { 86 | $in_use = true; 87 | } 88 | } 89 | 90 | 91 | //$this->write_to_file(ob_get_clean()); 92 | 93 | return $in_use; 94 | } // end public function check_media 95 | 96 | 97 | private function write_to_file($value, $comment='') { 98 | // this function for testing & debuggin only 99 | $file = dirname(__FILE__).'/-data-'.date('Y-m-d-h-i').'.txt'; 100 | $handle = fopen($file, 'a'); 101 | ob_start(); 102 | if ($comment) { 103 | echo $comment.":\r\n"; 104 | } 105 | if (is_array($value) || is_object($value)) { 106 | print_r($value); 107 | } elseif (is_bool($value)) { 108 | var_dump($value); 109 | } else { 110 | echo $value; 111 | } 112 | echo "\r\n\r\n"; 113 | fwrite($handle, ob_get_clean()); 114 | fclose($handle); 115 | } // end private function write_to_file 116 | 117 | } // end class ssi_addon_for_media_cleaner_pro 118 | 119 | --------------------------------------------------------------------------------