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 7.0.5 7.0.6 7.0.7
media-cleaner / classes / ui.php
media-cleaner / classes Last commit date
parsers 1 month ago admin.php 7 months ago core.php 1 month ago engine.php 1 month ago init.php 7 months ago parsers.php 10 months ago rest.php 1 month ago support.php 1 month ago ui.php 3 years ago
ui.php
131 lines
1 <?php
2
3 class Meow_WPMC_UI {
4
5 private $core = null;
6
7 private $foundTypes = array(
8 "CONTENT" => "Found in content.",
9 "CONTENT (ID)" => "Found in content (as an ID).",
10 "CONTENT (URL)" => "Found in content (as an URL).",
11 "THEME" => "Found in theme.",
12 "THEME (ID)" => "Found in theme (as an ID).",
13 "THEME (URL)" => "Found in theme (as an URL).",
14 "PAGE BUILDER" => "Found in Page Builder.",
15 "PAGE BUILDER (ID)" => "Found in Page Builder (as an ID).",
16 "PAGE BUILDER (URL)" => "Found in Page Builder (as an URL).",
17 "GALLERY" => "Found in gallery.",
18 "PORTFOLIO (ID)" => "Found in a portfolio (as an ID).",
19 "PORTFOLIO (URL)" => "Found in a portfolio (as an URL).",
20 "META" => "Found in meta.",
21 "META (ID)" => "Found in meta (as an ID).",
22 "META (URL)" => "Found in meta (as an URL).",
23 "META ACF (ID)" => "Found in meta (as an URL).",
24 "META ACF (URL)" => "Found in meta (as an URL).",
25 "WIDGET" => "Found in widget.",
26 "ACF WIDGET (ID)" => "Found in ACF Widget (as an ID).",
27 "ACF WIDGET (URL)" => "Found in ACF Widget (as an URL).",
28 "ATTACHMENT (ID)" => "Found in Attachment (as an ID).",
29 "SLIDER (ID)" => "Found in slider (as an ID).",
30 "SLIDER (URL)" => "Found in slider (as an URL).",
31 "CALENDAR (URL)" => "Found in calendar (as an URL).",
32 "MENU (URL)" => "Found in menu (as an URL).",
33 "SITE ICON" => "Found as a Site Icon."
34 );
35
36 function __construct( $core ) {
37 $this->core = $core;
38 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
39 add_action( 'add_meta_boxes', array( $this, 'add_metabox' ) );
40 add_filter( 'media_row_actions', array( $this, 'media_row_actions' ), 10, 2 );
41 }
42
43 function admin_menu() {
44 if ( !$this->core->can_access_features() ) {
45 return;
46 }
47 add_media_page( 'Media Cleaner Dashboard', __( 'Cleaner', 'media-file-renamer' ), 'read',
48 'wpmc_dashboard', array( $this, 'cleaner_dashboard' ), 1 );
49 }
50
51 public function cleaner_dashboard() {
52 wpmc_check_database();
53 echo '<div id="wpmc-dashboard"></div>';
54 }
55
56 /*******************************************************************************
57 * METABOX FOR USAGE
58 ******************************************************************************/
59
60 function add_metabox() {
61 add_meta_box( 'mfrh_media_usage_box', 'Media Cleaner', array( $this, 'display_metabox' ), 'attachment', 'side', 'default' );
62 }
63
64 function display_metabox( $post ) {
65 // Search the references to the ID
66 $originType = $this->core->reference_exists( null, $post->ID );
67
68 // Search the references to the files
69 if ( !$originType ) {
70 $originType = "";
71 $paths = $this->core->get_paths_from_attachment( $post->ID );
72 foreach ( $paths as $path ) {
73 $originType = $this->core->reference_exists( $path, null );
74 if ( $originType ) {
75 break;
76 }
77 }
78 }
79
80 if ( $originType ) {
81 $id = $originType;
82 $originType = preg_replace( '/\s*\[.*\]/', '', $originType );
83 $id = str_replace( $originType, '', $id );
84 $id = trim( $id, '[' );
85 echo "Used as: " . $originType . "<br />";
86 if ( array_key_exists( $originType, $this->foundTypes ) ) {
87 echo "Meaning: " . $this->foundTypes[ $originType ] . "<br />";
88 }
89 if ( !empty( $id ) ) {
90 $id = trim( $id, ' []' );
91 $post = get_post( $id );
92 if ( $post ) {
93 echo "Used in: <a href='" . get_permalink( $id ) . "' target='_blank'>" . $post->post_title . "</a>";
94 echo " (<a href='" . get_edit_post_link( $id ) . "'>edit</a>)";
95 }
96 }
97 return;
98 }
99
100 $issue = $this->core->get_issue_for_postId( $post->ID );
101 if ( $issue ) {
102 $this->core->echo_issue( $issue->issue );
103 return;
104 }
105
106 echo "There is no information about this media in the Cleaner DB. It is either not in use, or the scan hasn't been ran.";
107 }
108
109 function media_row_actions( $actions, $post ) {
110 wpmc_check_database();
111 global $current_screen;
112 if ( 'upload' != $current_screen->id )
113 return $actions;
114 global $wpdb;
115 $table_name = $wpdb->prefix . "mclean_scan";
116 $res = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE postId = %d", $post->ID ) );
117 if ( !empty( $res ) && isset( $actions['delete'] ) )
118 $actions['delete'] = "<a href='?page=wpmc_dashboard'>" .
119 __( 'Delete with Media Cleaner', 'media-cleaner' ) . "</a>";
120 if ( !empty( $res ) && isset( $actions['trash'] ) )
121 $actions['trash'] = "<a href='?page=wpmc_dashboard'>" .
122 __( 'Trash with Media Cleaner', 'media-cleaner' ) . "</a>";
123 if ( !empty( $res ) && isset( $actions['untrash'] ) ) {
124 $actions['untrash'] = "<a href='?page=wpmc_dashboard>" .
125 __( 'Restore with Media Cleaner', 'media-cleaner' ) . "</a>";
126 }
127 return $actions;
128 }
129
130 }
131