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.0.4 7.0.5 7.0.6 7.0.7
media-cleaner / common / admin.php
media-cleaner / common Last commit date
img 8 years ago admin.css 8 years ago admin.php 8 years ago
admin.php
432 lines
1 <?php
2
3 if ( !class_exists( 'MeowApps_Admin' ) ) {
4
5 class MeowApps_Admin {
6
7 public static $loaded = false;
8 public static $admin_version = "1.4";
9
10 public $prefix; // prefix used for actions, filters (mfrh)
11 public $mainfile; // plugin main file (media-file-renamer.php)
12 public $domain; // domain used for translation (media-file-renamer)
13
14 public function __construct( $prefix, $mainfile, $domain, $disableReview = false ) {
15
16 // Core Admin (used by all Meow Apps plugins)
17 if ( !MeowApps_Admin::$loaded ) {
18 if ( is_admin() ) {
19 add_action( 'admin_menu', array( $this, 'admin_menu_start' ) );
20 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
21 add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
22 add_filter( 'updraftplus_com_link', array( $this, 'updraftplus_com_link' ) );
23 }
24 MeowApps_Admin::$loaded = true;
25 }
26
27 // Variables for this plugin
28 $this->prefix = $prefix;
29 $this->mainfile = $mainfile;
30 $this->domain = $domain;
31
32 register_activation_hook( $mainfile, array( $this, 'show_meowapps_create_rating_date' ) );
33
34 if ( is_admin() ) {
35 $license = get_option( $this->prefix . '_license', "" );
36 if ( ( !empty( $license ) ) && !file_exists( plugin_dir_path( $this->mainfile ) . 'common/meowapps/admin.php' ) ) {
37 add_action( 'admin_notices', array( $this, 'admin_notices_licensed_free' ) );
38 }
39 if ( !$disableReview ) {
40 $rating_date = $this->create_rating_date();
41 if ( time() > $rating_date ) {
42 add_action( 'admin_notices', array( $this, 'admin_notices_rating' ) );
43 }
44 }
45 }
46 }
47
48 function updraftplus_com_link( $url ) {
49 $url = $url . "?afref=460";
50 return $url;
51 }
52
53 function show_meowapps_create_rating_date() {
54 delete_option( 'meowapps_hide_meowapps' );
55 $this->create_rating_date();
56 }
57
58 function create_rating_date() {
59 $rating_date = get_option( $this->prefix . '_rating_date' );
60 if ( empty( $rating_date ) ) {
61 $two_months = strtotime( '+2 months' );
62 $six_months = strtotime( '+4 months' );
63 $rating_date = mt_rand( $two_months, $six_months );
64 update_option( $this->prefix . '_rating_date', $rating_date, false );
65 }
66 return $rating_date;
67 }
68
69 function admin_notices_rating() {
70 if ( isset( $_POST[$this->prefix . '_remind_me'] ) ) {
71 $two_weeks = strtotime( '+2 weeks' );
72 $six_weeks = strtotime( '+6 weeks' );
73 $future_date = mt_rand( $two_weeks, $six_weeks );
74 update_option( $this->prefix . '_rating_date', $future_date, false );
75 return;
76 }
77 else if ( isset( $_POST[$this->prefix . '_never_remind_me'] ) ) {
78 $twenty_years = strtotime( '+5 years' );
79 update_option( $this->prefix . '_rating_date', $twenty_years, false );
80 return;
81 }
82 else if ( isset( $_POST[$this->prefix . '_did_it'] ) ) {
83 $twenty_years = strtotime( '+10 years' );
84 update_option( $this->prefix . '_rating_date', $twenty_years, false );
85 return;
86 }
87 $rating_date = get_option( $this->prefix . '_rating_date' );
88 echo '<div class="notice notice-success" data-rating-date="' . date( 'Y-m-d', $rating_date ) . '">';
89 echo '<p style="font-size: 100%;">You have been using <b>' . $this->nice_name_from_file( $this->mainfile ) . '</b> for some time now. Thank you! Could you kindly share your opinion with me, along with, maybe, features you would like to see implemented? Then, please <a style="font-weight: bold; color: #b926ff;" target="_blank" href="https://wordpress.org/support/plugin/' . $this->nice_short_url_from_file( $this->mainfile ) . '/reviews/?rate=5#new-post">write a little review</a>. That will also bring me joy and motivation, and I will get back to you :) <u>In the case you already have written a review</u>, please check again. Many reviews got removed from WordPress recently.';
90 echo '<p>
91 <form method="post" action="" style="float: right;">
92 <input type="hidden" name="' . $this->prefix . '_never_remind_me" value="true">
93 <input type="submit" name="submit" id="submit" class="button button-red" value="Never remind me!">
94 </form>
95 <form method="post" action="" style="float: right; margin-right: 10px;">
96 <input type="hidden" name="' . $this->prefix . '_remind_me" value="true">
97 <input type="submit" name="submit" id="submit" class="button button-primary" value="Remind me in a few weeks...">
98 </form>
99 <form method="post" action="" style="float: right; margin-right: 10px;">
100 <input type="hidden" name="' . $this->prefix . '_did_it" value="true">
101 <input type="submit" name="submit" id="submit" class="button button-primary" value="Yes, I did it!">
102 </form>
103 <div style="clear: both;"></div>
104 </p>
105 ';
106 echo '</div>';
107 }
108
109 function nice_short_url_from_file( $file ) {
110 $info = pathinfo( $file );
111 if ( !empty( $info ) ) {
112 $info['filename'] = str_replace( '-pro', '', $info['filename'] );
113 return $info['filename'];
114 }
115 return "";
116 }
117
118 function nice_name_from_file( $file ) {
119 $info = pathinfo( $file );
120 if ( !empty( $info ) ) {
121 if ( $info['filename'] == 'wplr-sync' ) {
122 return "WP/LR Sync";
123 }
124 $info['filename'] = str_replace( '-', ' ', $info['filename'] );
125 $file = ucwords( $info['filename'] );
126 }
127 return $file;
128 }
129
130 function admin_notices_licensed_free() {
131 if ( isset( $_POST[$this->prefix . '_reset_sub'] ) ) {
132 delete_option( $this->prefix . '_pro_serial' );
133 delete_option( $this->prefix . '_license' );
134 return;
135 }
136 echo '<div class="error">';
137 echo '<p>It looks like you are using the free version of the plugin (<b>' . $this->nice_name_from_file( $this->mainfile ) . '</b>) but a license for the Pro version was also found. The Pro version might have been replaced by the Free version during an update (might be caused by a temporarily issue). If it is the case, <b>please download it again</b> from the <a target="_blank" href="https://store.meowapps.com">Meow Store</a>. If you wish to continue using the free version and clear this message, click on this button.';
138 echo '<p>
139 <form method="post" action="">
140 <input type="hidden" name="' . $this->prefix . '_reset_sub" value="true">
141 <input type="submit" name="submit" id="submit" class="button" value="Remove the license">
142 </form>
143 </p>
144 ';
145 echo '</div>';
146 }
147
148 function display_ads() {
149 return !get_option( 'meowapps_hide_ads', false );
150 }
151
152 function display_title( $title = "Meow Apps",
153 $author = "By <a style='text-decoration: none;' href='https://meowapps.com' target='_blank'>Jordy Meow</a>" ) {
154 if ( !empty( $this->prefix ) )
155 $title = apply_filters( $this->prefix . '_plugin_title', $title );
156 if ( $this->display_ads() ) {
157 echo '<a class="meow-header-ad" target="_blank" href="http://www.shareasale.com/r.cfm?b=906810&u=767054&m=41388&urllink=&afftrack="">
158 <img src="' . $this->common_url( 'img/wpengine.png' ) . '" height="60" border="0" /></a>';
159 }
160 ?>
161 <h1 style="line-height: 16px;">
162 <img width="36" style="margin-right: 10px; float: left; position: relative; top: -5px;"
163 src="<?php echo $this->meowapps_logo_url(); ?>"><?php echo $title; ?><br />
164 <span style="font-size: 12px"><?php echo $author; ?></span>
165 </h1>
166 <div style="clear: both;"></div>
167 <?php
168 }
169
170 function admin_enqueue_scripts() {
171 wp_register_style( 'meowapps-core-css', $this->common_url( 'admin.css' ) );
172 wp_enqueue_style( 'meowapps-core-css' );
173 }
174
175 function admin_menu_start() {
176 if ( get_option( 'meowapps_hide_meowapps', false ) ) {
177 register_setting( 'general', 'meowapps_hide_meowapps' );
178 add_settings_field( 'meowapps_hide_ads', 'Meow Apps Menu', array( $this, 'meowapps_hide_dashboard_callback' ), 'general' );
179 return;
180 }
181
182 // Creates standard menu if it does NOT exist
183 global $submenu;
184 if ( !isset( $submenu[ 'meowapps-main-menu' ] ) ) {
185 add_menu_page( 'Meow Apps', 'Meow Apps', 'manage_options', 'meowapps-main-menu',
186 array( $this, 'admin_meow_apps' ), 'dashicons-camera', 82 );
187 add_submenu_page( 'meowapps-main-menu', __( 'Dashboard', 'meowapps' ),
188 __( 'Dashboard', 'meowapps' ), 'manage_options',
189 'meowapps-main-menu', array( $this, 'admin_meow_apps' ) );
190 }
191
192 add_settings_section( 'meowapps_common_settings', null, null, 'meowapps_common_settings-menu' );
193 add_settings_field( 'meowapps_hide_meowapps', "Main Menu",
194 array( $this, 'meowapps_hide_dashboard_callback' ),
195 'meowapps_common_settings-menu', 'meowapps_common_settings' );
196 add_settings_field( 'meowapps_force_sslverify', "SSL Verify",
197 array( $this, 'meowapps_force_sslverify_callback' ),
198 'meowapps_common_settings-menu', 'meowapps_common_settings' );
199 add_settings_field( 'meowapps_hide_ads', "Ads",
200 array( $this, 'meowapps_hide_ads_callback' ),
201 'meowapps_common_settings-menu', 'meowapps_common_settings' );
202 register_setting( 'meowapps_common_settings', 'force_sslverify' );
203 register_setting( 'meowapps_common_settings', 'meowapps_hide_meowapps' );
204 register_setting( 'meowapps_common_settings', 'meowapps_hide_ads' );
205 }
206
207 function meowapps_hide_ads_callback() {
208 $value = get_option( 'meowapps_hide_ads', null );
209 $html = '<input type="checkbox" id="meowapps_hide_ads" name="meowapps_hide_ads" value="1" ' .
210 checked( 1, get_option( 'meowapps_hide_ads' ), false ) . '/>';
211 $html .= __( '<label>Hide</label><br /><small>Doesn\'t display the ads.</small>', 'meowapps' );
212 echo $html;
213 }
214
215 function meowapps_hide_dashboard_callback() {
216 $value = get_option( 'meowapps_hide_meowapps', null );
217 $html = '<input type="checkbox" id="meowapps_hide_meowapps" name="meowapps_hide_meowapps" value="1" ' .
218 checked( 1, get_option( 'meowapps_hide_meowapps' ), false ) . '/>';
219 $html .= __( '<label>Hide <b>Meow Apps</b> Menu</label><br /><small>Hide Meow Apps menu and all its components, for a cleaner admin. This option will be reset if a new Meow Apps plugin is installed. <b>Once activated, an option will be added in your General settings to display it again.</b></small>', 'meowapps' );
220 echo $html;
221 }
222
223 function meowapps_force_sslverify_callback() {
224 $value = get_option( 'force_sslverify', null );
225 $html = '<input type="checkbox" id="force_sslverify" name="force_sslverify" value="1" ' .
226 checked( 1, get_option( 'force_sslverify' ), false ) . '/>';
227 $html .= __( '<label>Force</label><br /><small>Updates and licenses checks are usually made without checking SSL certificates and it is actually fine this way. But if you are intransigent when it comes to SSL matters, this option will force it.</small>', 'meowapps' );
228 echo $html;
229 }
230
231 function display_serialkey_box( $url = "https://meowapps.com/" ) {
232 $html = '<div class="meow-box">';
233 $html .= '<h3 class="' . ( $this->is_registered( $this->prefix ) ? 'meow-bk-blue' : 'meow-bk-red' ) . '">Pro Version ' .
234 ( $this->is_registered( $this->prefix ) ? '(enabled)' : '(disabled)' ) . '</h3>';
235 $html .= '<div class="inside">';
236 echo $html;
237 $html = apply_filters( $this->prefix . '_meowapps_license_input', ( 'More information about the Pro version here:
238 <a target="_blank" href="' . $url . '">' . $url . '</a>. If you actually bought the Pro version already, please remove the current plugin and download the Pro version from your account at the <a target="_blank" href="https://store.meowapps.com/account/downloads/">Meow Apps Store</a>.' ), $url );
239 $html .= '</div>';
240 $html .= '</div>';
241 echo $html;
242 }
243
244 function is_registered() {
245 return apply_filters( $this->prefix . '_meowapps_is_registered', false, $this->prefix );
246 }
247
248 function check_install( $plugin ) {
249 $pro = false;
250
251 $pluginpath = trailingslashit( plugin_dir_path( __FILE__ ) ) . '../../' . $plugin . '-pro';
252 if ( !file_exists( $pluginpath ) ) {
253 $pluginpath = trailingslashit( plugin_dir_path( __FILE__ ) ) . '../../' . $plugin;
254 if ( !file_exists( $pluginpath ) ) {
255 $url = wp_nonce_url( "update.php?action=install-plugin&plugin=$plugin", "install-plugin_$plugin" );
256 return "<a href='$url'><small><span class='' style='float: right;'>install</span></small></a>";
257 }
258 }
259 else {
260 $pro = true;
261 $plugin = $plugin . "-pro";
262 }
263
264 $plugin_file = $plugin . '/' . $plugin . '.php';
265 if ( is_plugin_active( $plugin_file ) ) {
266 if ( $plugin == 'wplr-sync' )
267 $pro = true;
268 if ( $pro )
269 return "<small><span style='float: right;'><span class='dashicons dashicons-heart' style='color: rgba(255, 63, 0, 1); font-size: 30px !important; margin-right: 10px;'></span></span></small>";
270 else
271 return "<small><span style='float: right;'><span class='dashicons dashicons-yes' style='color: #00b4ff; font-size: 30px !important; margin-right: 10px;'></span></span></small>";
272 }
273 else {
274 $url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $plugin_file ),
275 'activate-plugin_' . $plugin_file );
276 return '<small><span style="color: black; float: right;">off
277 (<a style="color: rgba(30,140,190,1); text-decoration: none;" href="' .
278 $url . '">enable</a>)</span></small>';
279 }
280 }
281
282 function common_url( $file ) {
283 die( "Meow Apps: The function common_url( \$file ) needs to be overriden." );
284 // Normally, this should be used:
285 // return plugin_dir_url( __FILE__ ) . ( '\/common\/' . $file );
286 }
287
288 function meowapps_logo_url() {
289 return $this->common_url( 'img/meowapps.png' );
290 }
291
292 function plugins_loaded() {
293 if ( isset( $_GET[ 'tool' ] ) && $_GET[ 'tool' ] == 'error_log' ) {
294 $sec = "5";
295 header("Refresh: $sec;");
296 }
297 }
298
299 function admin_meow_apps() {
300
301 echo '<div class="wrap meow-dashboard">';
302 if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'phpinfo' ) {
303 echo "<a href=\"javascript:history.go(-1)\">< Go back</a><br /><br />";
304 echo '<div id="phpinfo">';
305 ob_start();
306 phpinfo();
307 $pinfo = ob_get_contents();
308 ob_end_clean();
309 $pinfo = preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $pinfo );
310 echo $pinfo;
311 echo "</div>";
312 }
313 else if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'error_log' ) {
314 $errorpath = ini_get( 'error_log' );
315 echo "<a href=\"javascript:history.go(-1)\">< Go back</a><br /><br />";
316 echo '<div id="error_log">';
317 if ( file_exists( $errorpath ) ) {
318 echo "Now (auto-reload every 5 seconds):<br />[" . date( "d-M-Y H:i:s", time() ) . " UTC]<br /<br /><br />Errors (order by latest):";
319 $errors = file_get_contents( $errorpath );
320 $errors = explode( "\n", $errors );
321 $errors = array_reverse( $errors );
322 $errors = implode( "<br />", $errors );
323 echo $errors;
324 }
325 else {
326 echo "The PHP Error Logs cannot be found. Please ask your hosting service for it.";
327 }
328 echo "</div>";
329
330 }
331 else {
332
333 ?>
334 <?php $this->display_title(); ?>
335 <p>
336 <?php _e( 'Meow Apps is run by Jordy Meow, a photographer and software developer living in Japan (and taking <a target="_blank" href="http://offbeatjapan.org">a lot of photos</a>). Meow Apps is a suite of plugins focusing on photography, imaging, optimization and it teams up with the best players in the community (other themes and plugins developers). For more information, please check <a href="http://meowapps.com" target="_blank">Meow Apps</a>.', 'meowapps' )
337 ?>
338 </p>
339 <div class="meow-row">
340 <div class="meow-box meow-col meow-span_1_of_2 ">
341 <h3 class=""><span class="dashicons dashicons-camera"></span> UI Plugins </h3>
342 <ul class="">
343 <li><b>WP/LR Sync</b> <?php echo $this->check_install( 'wplr-sync' ) ?><br />
344 Synchronize photos (folders, collections, keywords) from Lightroom to WordPress.</li>
345 <li><b>Meow Lightbox</b> <?php echo $this->check_install( 'meow-lightbox' ) ?><br />
346 Light but powerful lightbox that can also display photo information (EXIF).</li>
347 <li><b>Meow Gallery</b> <?php echo $this->check_install( 'meow-gallery' ) ?><br />
348 Gallery (using the built-in WP gallery) that makes your website look better.</li>
349 <!-- <li><b>Audio Story for Images</b> <?php echo $this->check_install( 'audio-story-images' ) ?><br />
350 Add audio (music, explanation, ambiance) to your images.</li> -->
351 </ul>
352 </div>
353 <div class="meow-box meow-col meow-span_1_of_2">
354 <h3 class=""><span class="dashicons dashicons-admin-tools"></span> System Plugins</h3>
355 <ul class="">
356 <li><b>Media File Renamer</b> <?php echo $this->check_install( 'media-file-renamer' ) ?><br />
357 For nicer filenames and better SEO.</li>
358 <li><b>Media Cleaner</b> <?php echo $this->check_install( 'media-cleaner' ) ?><br />
359 Detect the files which are not in use.</li>
360 <li><b>WP Retina 2x</b> <?php echo $this->check_install( 'wp-retina-2x' ) ?><br />
361 The famous plugin that adds Retina support.</li>
362 </ul>
363 </div>
364 </div>
365
366 <div class="meow-row">
367 <div class="meow-box meow-col meow-span_2_of_3">
368 <h3><span class="dashicons dashicons-admin-tools"></span> Common</h3>
369 <div class="inside">
370 <form method="post" action="options.php">
371 <?php settings_fields( 'meowapps_common_settings' ); ?>
372 <?php do_settings_sections( 'meowapps_common_settings-menu' ); ?>
373 <?php submit_button(); ?>
374 </form>
375 </div>
376 </div>
377
378 <div class="meow-box meow-col meow-span_1_of_3">
379 <h3><span class="dashicons dashicons-admin-tools"></span> Debug</h3>
380 <div class="inside">
381 <ul>
382 <li><a href="?page=meowapps-main-menu&amp;tool=error_log">Display Error Log</a></li>
383 <li><a href="?page=meowapps-main-menu&amp;tool=phpinfo">Display PHP Info</a></li>
384 </ul>
385 </div>
386 </div>
387
388 <div class="meow-box meow-col meow-span_1_of_3">
389 <h3><span class="dashicons dashicons-admin-tools"></span> Post Types (used by this install)</h3>
390 <div class="inside">
391 <?php
392 global $wpdb;
393 // Maybe we could avoid to check more post_types.
394 // SELECT post_type, COUNT(*) FROM `wp_posts` GROUP BY post_type
395 $types = $wpdb->get_results( "SELECT post_type as 'type', COUNT(*) as 'count' FROM $wpdb->posts GROUP BY post_type" );
396 $result = array();
397 foreach( $types as $type )
398 array_push( $result, "{$type->type} ({$type->count})" );
399 echo implode( $result, ', ' );
400 ?>
401 </div>
402 </div>
403 </div>
404
405
406 <?php
407
408 }
409
410 echo "<br /><small style='color: lightgray;'>Meow Admin " . MeowApps_Admin::$admin_version . "</small></div>";
411 }
412
413 // HELPERS
414
415 static function size_shortname( $name ) {
416 $name = preg_split( '[_-]', $name );
417 $short = strtoupper( substr( $name[0], 0, 1 ) );
418 if ( count( $name ) > 1 )
419 $short .= strtoupper( substr( $name[1], 0, 1 ) );
420 return $short;
421 }
422
423 }
424
425 }
426
427 if ( file_exists( plugin_dir_path( __FILE__ ) . '/meowapps/admin.php' ) ) {
428 require( 'meowapps/admin.php' );
429 }
430
431 ?>
432