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