PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 4.7.4
Responsive Menu – Create Mobile-Friendly Menu v4.7.4
4.7.4 4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 All 91 releases
responsive-menu / review-banner-class.php

review-banner-class.php in Responsive Menu – Create Mobile-Friendly Menu 4.7.4, at review-banner-class.php

130 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class that handles displaying of review notice
5 *
6 * @since 4.1.3
7 */
8 class RM_Review_Message {
9
10
11 /**
12 * Variable to hold how many results needed to show message
13 *
14 * @since 4.1.3
15 */
16 public $trigger = -1;
17
18 /**
19 * Main Construct Function
20 *
21 * Adds the notice check to init and then check to display message
22 *
23 * @since 4.1.3
24 */
25 public function __construct() {
26 $this->add_hooks();
27 }
28
29 /**
30 * Adds check message to admin_init hook
31 *
32 * @since 4.1.3
33 */
34 public function add_hooks() {
35 add_action( 'admin_init', array( $this, 'check_message_display' ) );
36 }
37
38 /**
39 * Checks if message should be displayed
40 *
41 * @since 4.1.3
42 */
43 public function check_message_display() {
44 $this->admin_notice_check();
45 $this->trigger = $this->check_message_trigger();
46 if ( -1 !== $this->trigger ) {
47 $amount = $this->check_results_amount();
48 if ( $amount >= $this->trigger ) {
49 add_action( 'admin_notices', array( $this, 'display_admin_message' ) );
50 }
51 }
52 }
53
54 /**
55 * Retrieves what the next trigger value is
56 *
57 * @since 4.1.3
58 * @return int The amount of menus needed to display message
59 */
60 public function check_message_trigger() {
61 $trigger = get_option( 'rm_review_message_trigger' );
62 if ( empty( $trigger ) || is_null( $trigger ) ) {
63 add_option( 'rm_review_message_trigger', 1 );
64 return 1;
65 }
66 return intval( $trigger );
67 }
68
69 /**
70 * Checks the amount of Menus
71 *
72 * @return int The amount of menus
73 */
74 public function check_results_amount() {
75 global $wpdb;
76 $amount = $wpdb->get_var(
77 'SELECT COUNT(*) FROM `' . $wpdb->prefix . "posts`
78 WHERE post_type = 'rmp_menu'"
79 );
80 return $amount;
81 }
82
83 /**
84 * Displays the message
85 *
86 * Displays the message asking for review
87 */
88 public function display_admin_message() {
89 ?>
90 <div class='updated'><br />
91 <?php
92 /* translators: %d: Result count */
93 echo sprintf( esc_html__( 'Greetings! I just noticed that you have created %d Menus. That is awesome! Could you please help me out by giving this plugin a 5-star rating on WordPress? This will help us by helping other users discover this plugin.', 'responsive-menu' ), esc_html( $this->check_results_amount() ) );
94 ?>
95 <br/><strong><em>~ <?php esc_html_e( 'RM Team', 'responsive-menu' ); ?></em></strong><br/><br/>
96 <a target="_blank" rel="noopener" href="https://wordpress.org/support/plugin/responsive-menu/reviews/#new-topic-0" class="button-primary"><?php esc_html_e( 'Yeah, you deserve it!', 'responsive-menu' ); ?></a>
97 <a href="<?php echo esc_url( add_query_arg( 'rm_review_notice_check', 'already_did' ) ); ?>" class="button-secondary"><?php esc_html_e( 'I already did!', 'responsive-menu' ); ?></a>
98 <a href="<?php echo esc_url( add_query_arg( 'rm_review_notice_check', 'remove_message' ) ); ?>" class="button-secondary"><?php esc_html_e( 'No, this plugin is not good enough', 'responsive-menu' ); ?></a>
99 <br /><br /></div>
100 <?php
101 }
102
103 /**
104 * Checks if a link in the admin message has been clicked
105 *
106 * @since 4.1.3
107 */
108 public function admin_notice_check() {
109 if ( isset( $_GET['rm_review_notice_check'] ) && 'remove_message' === $_GET['rm_review_notice_check'] ) {
110 $this->trigger = $this->check_message_trigger();
111 $update_trigger = -1;
112 if ( -1 === $this->trigger ) {
113 exit;
114 } elseif ( 1 === $this->trigger ) {
115 $update_trigger = 5;
116 } elseif ( 5 === $this->trigger ) {
117 $update_trigger = 10;
118 } elseif ( 10 === $this->trigger ) {
119 $update_trigger = -1;
120 }
121 update_option( 'rm_review_message_trigger', $update_trigger );
122 }
123 if ( isset( $_GET['rm_review_notice_check'] ) && 'already_did' === $_GET['rm_review_notice_check'] ) {
124 update_option( 'rm_review_message_trigger', -1 );
125 }
126 }
127 }
128
129 $rm_review_message = new RM_Review_Message();
130