PluginProbe
Meow Gallery / 4.2.0
Meow Gallery v4.2.0
5.5.4 5.5.3 5.5.2 5.5.1 5.5.0 5.4.9 5.4.8 5.4.7 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 All 156 releases
meow-gallery / common / classes / ratings.php

ratings.php in Meow Gallery 4.2.0, at common/classes/ratings.php

115 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( !class_exists( 'MeowCommon_Classes_Ratings' ) ) {
4
5 class MeowCommon_Classes_Ratings {
6
7 public $mainfile; // plugin main file (media-file-renamer.php)
8 public $domain; // domain used for translation (media-file-renamer)
9 public $prefix; // used for many things (filters, options, etc)
10
11 public function __construct( $prefix, $mainfile, $domain ) {
12 $this->mainfile = $mainfile;
13 $this->domain = $domain;
14 $this->prefix = $prefix;
15
16 register_activation_hook( $mainfile, array( $this, 'show_meowapps_create_rating_date' ) );
17
18 if ( is_admin() ) {
19 $rating_date = $this->create_rating_date();
20 if ( time() > $rating_date ) {
21 add_action( 'admin_notices', array( $this, 'admin_notices_rating' ) );
22 }
23 }
24 }
25
26 function show_meowapps_create_rating_date() {
27 delete_option( 'meowapps_hide_meowapps' );
28 $this->create_rating_date();
29 }
30
31 function create_rating_date() {
32 $rating_date = get_option( $this->prefix . '_rating_date' );
33 if ( empty( $rating_date ) ) {
34 $two_months = strtotime( '+2 months' );
35 $six_months = strtotime( '+4 months' );
36 $rating_date = mt_rand( $two_months, $six_months );
37 update_option( $this->prefix . '_rating_date', $rating_date, false );
38 }
39 return $rating_date;
40 }
41
42 function admin_notices_rating() {
43 if ( isset( $_POST[$this->prefix . '_remind_me'] ) ) {
44 $two_weeks = strtotime( '+2 weeks' );
45 $six_weeks = strtotime( '+6 weeks' );
46 $future_date = mt_rand( $two_weeks, $six_weeks );
47 update_option( $this->prefix . '_rating_date', $future_date, false );
48 return;
49 }
50 else if ( isset( $_POST[$this->prefix . '_never_remind_me'] ) ) {
51 $twenty_years = strtotime( '+5 years' );
52 update_option( $this->prefix . '_rating_date', $twenty_years, false );
53 return;
54 }
55 else if ( isset( $_POST[$this->prefix . '_did_it'] ) ) {
56 $twenty_years = strtotime( '+10 years' );
57 update_option( $this->prefix . '_rating_date', $twenty_years, false );
58 return;
59 }
60 $rating_date = get_option( $this->prefix . '_rating_date' );
61 echo '<div class="notice notice-success" data-rating-date="' . date( 'Y-m-d', $rating_date ) . '">';
62 echo '<p style="font-size: 100%;">';
63 printf(
64 // translators: %1$s is a plugin nicename, %2$s is a short url (slug)
65 __( 'You have been using <b>%1$s</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/%2$s/reviews/?rate=5#new-post">write a little review</a>. That will also bring me joy and motivation! I will get back to you :)', $this->domain ),
66 $this->nice_name_from_file( $this->mainfile ),
67 $this->nice_short_url_from_file( $this->mainfile )
68 );
69 echo '<p>
70 <form method="post" action="" style="float: right;">
71 <input type="hidden" name="' . $this->prefix . '_never_remind_me" value="true">
72 <input type="submit" name="submit" id="submit" class="button button-red" value="'
73 . __( 'Never remind me!', $this->domain ) . '">
74 </form>
75 <form method="post" action="" style="float: right; margin-right: 10px;">
76 <input type="hidden" name="' . $this->prefix . '_remind_me" value="true">
77 <input type="submit" name="submit" id="submit" class="button button-primary" value="'
78 . __( 'Remind me in a few weeks...', $this->domain ) . '">
79 </form>
80 <form method="post" action="" style="float: right; margin-right: 10px;">
81 <input type="hidden" name="' . $this->prefix . '_did_it" value="true">
82 <input type="submit" name="submit" id="submit" class="button button-primary" value="'
83 . __( 'Yes, I did it!', $this->domain ) . '">
84 </form>
85 <div style="clear: both;"></div>
86 </p>
87 ';
88 echo '</div>';
89 }
90
91 function nice_short_url_from_file( $file ) {
92 $info = pathinfo( $file );
93 if ( !empty( $info ) ) {
94 $info['filename'] = str_replace( '-pro', '', $info['filename'] );
95 return $info['filename'];
96 }
97 return "";
98 }
99
100 function nice_name_from_file( $file ) {
101 $info = pathinfo( $file );
102 if ( !empty( $info ) ) {
103 if ( $info['filename'] == 'wplr-sync' ) {
104 return "Photo Engine";
105 }
106 $info['filename'] = str_replace( '-', ' ', $info['filename'] );
107 $file = ucwords( $info['filename'] );
108 }
109 return $file;
110 }
111 }
112 }
113
114 ?>
115