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.0.4 7.0.5 7.0.6 7.0.7
media-cleaner / ui.php
media-cleaner Last commit date
common 6 years ago parsers 6 years ago scripts 6 years ago views 6 years ago admin.php 6 years ago api.php 7 years ago core.php 6 years ago engine.php 6 years ago media-cleaner.php 6 years ago parsers.php 6 years ago readme.txt 6 years ago ui.php 6 years ago
ui.php
156 lines
1 <?php
2
3 class Meow_WPMC_UI {
4
5 private $core = null;
6 private $admin = null;
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 "PAGE BUILDER" => "Found in Page Builder.",
13 "PAGE BUILDER (ID)" => "Found in Page Builder (as an ID).",
14 "PAGE BUILDER (URL)" => "Found in Page Builder (as an URL).",
15 "GALLERY" => "Found in gallery.",
16 "META" => "Found in meta.",
17 "META (ID)" => "Found in meta (as an ID).",
18 "META (URL)" => "Found in meta (as an URL).",
19 "META ACF (ID)" => "Found in meta (as an URL).",
20 "META ACF (URL)" => "Found in meta (as an URL).",
21 "WIDGET" => "Found in widget.",
22 "ACF WIDGET (ID)" => "Found in ACF Widget (as an ID).",
23 "ACF WIDGET (URL)" => "Found in ACF Widget (as an URL).",
24 "ATTACHMENT (ID)" => "Found in Attachment (as an ID).",
25 "METASLIDER (ID)" => "Found in MetaSlider (as an ID).",
26 "MY CALENDAR (URL)" => "Found in My Calendar (as an URL).",
27 "UBERMENU (URL)" => "Found in UberMenu (as an URL).",
28 "MAX MEGA MENU (URL)" => "Found in Max Mega Menu (as an URL).",
29 "SITE ICON" => "Found in Site Icon."
30 );
31
32 function __construct( $core, $admin ) {
33 $this->core = $core;
34 $this->admin = $admin;
35 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
36 add_action( 'admin_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
37 add_action( 'admin_print_scripts', array( $this, 'admin_inline_js' ) );
38 add_action( 'add_meta_boxes', array( $this, 'add_metabox' ) );
39 add_filter( 'media_row_actions', array( $this, 'media_row_actions' ), 10, 2 );
40 }
41
42 /**
43 * Renders a view within the views directory.
44 * @param string $view The name of the view to render
45 * @param array $data
46 * An associative array of variables to bind to the view.
47 * Each key turns into a variable name.
48 * @return string Rendered view
49 */
50 function render_view( $view, $data = null ) {
51 ob_start();
52 if ( is_array( $data ) ) extract( $data );
53 include( __DIR__ . "/views/$view.php" );
54 return ob_get_clean();
55 }
56
57 function admin_menu() {
58 //load_plugin_textdomain( 'media-cleaner', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
59 add_media_page( 'Media Cleaner', 'Cleaner', 'manage_options', 'media-cleaner', array( $this, 'wpmc_screen' ) );
60 }
61
62 function wpmc_screen() {
63 global $wpdb, $wplr;
64 echo $this->render_view( 'menu-screen', array(
65 'wpdb' => $wpdb,
66 'wplr' => $wplr,
67 'ui' => $this,
68 'core' => $this->core,
69 'admin' => $this->admin
70 ) );
71 }
72
73 function wp_enqueue_scripts() {
74 wp_enqueue_style( 'wp-jquery-ui-dialog' );
75 wp_enqueue_script( 'jquery-ui-dialog' );
76 wp_enqueue_style( 'media-cleaner-css', plugins_url( '/scripts/style.css', __FILE__ ) );
77
78 $screen = get_current_screen();
79 global $wpmc_version;
80 switch ( $screen->id ) {
81 case 'media_page_media-cleaner': // Media > Cleaner
82 wp_enqueue_script( 'media-cleaner', plugins_url( '/scripts/dashboard.js', __FILE__ ), array( 'jquery', 'jquery-ui-dialog' ),
83 $wpmc_version, true );
84 break;
85 case 'meow-apps_page_wpmc_settings-menu': // Meow Apps > Media Cleaner (Settings)
86 wp_enqueue_script( 'media-cleaner-settings', plugins_url( '/scripts/settings.js', __FILE__ ), array( 'jquery' ),
87 $wpmc_version, true );
88 break;
89 }
90 }
91
92 /**
93 *
94 * DASHBOARD
95 *
96 */
97
98 function admin_inline_js() {
99 echo "<script type='text/javascript'>\n";
100 echo 'var wpmc_cfg = {
101 timeout: ' . ( (int) $this->core->get_max_execution_time() ) * 1000 . ',
102 delay: ' . get_option( 'wpmc_delay', 100 ) . ',
103 postsBuffer:' . get_option( 'wpmc_posts_buffer', 5 ) . ',
104 mediasBuffer:' . get_option( 'wpmc_medias_buffer', 100 ) . ',
105 analysisBuffer: ' . get_option( 'wpmc_analysis_buffer', 50 ) . ',
106 isPro: ' . ( $this->admin->is_registered() ? '1' : '0') . ',
107 scanFiles: ' . ( ( get_option( 'wpmc_method', 'media' ) == 'files' && $this->admin->is_registered() ) ? '1' : '0' ) . ',
108 scanMedia: ' . ( get_option( 'wpmc_method', 'media' ) == 'media' ? '1' : '0' ) . ' };';
109 echo "\n</script>";
110 }
111
112 /*******************************************************************************
113 * METABOX FOR USAGE
114 ******************************************************************************/
115
116 function add_metabox() {
117 add_meta_box( 'mfrh_media_usage_box', 'Media Cleaner', array( $this, 'display_metabox' ), 'attachment', 'side', 'default' );
118 }
119
120 function display_metabox( $post ) {
121 $this->core->log( "Media Edit > Checking Media #{$post->ID}" );
122 $success = $this->core->check_media( $post->ID, true );
123 $this->core->log( "Success $success\n" );
124 if ( $success ) {
125 if ( array_key_exists( $this->core->last_analysis, $this->foundTypes ) )
126 echo $this->foundTypes[ $this->core->last_analysis ];
127 else
128 echo "It seems to be used as: " . $this->core->last_analysis;
129 }
130 else {
131 echo "Doesn't seem to be used.";
132 }
133 }
134
135 function media_row_actions( $actions, $post ) {
136 global $current_screen;
137 if ( 'upload' != $current_screen->id )
138 return $actions;
139 global $wpdb;
140 $table_name = $wpdb->prefix . "mclean_scan";
141 $res = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE postId = %d", $post->ID ) );
142 if ( !empty( $res ) && isset( $actions['delete'] ) )
143 $actions['delete'] = "<a href='?page=media-cleaner&view=deleted'>" .
144 __( 'Delete with Media Cleaner', 'media-cleaner' ) . "</a>";
145 if ( !empty( $res ) && isset( $actions['trash'] ) )
146 $actions['trash'] = "<a href='?page=media-cleaner'>" .
147 __( 'Trash with Media Cleaner', 'media-cleaner' ) . "</a>";
148 if ( !empty( $res ) && isset( $actions['untrash'] ) ) {
149 $actions['untrash'] = "<a href='?page=media-cleaner&view=deleted'>" .
150 __( 'Restore with Media Cleaner', 'media-cleaner' ) . "</a>";
151 }
152 return $actions;
153 }
154
155 }
156