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