| @@ -27,9 +27,8 @@ | ||
| 27 | 27 | * |
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | 30 | public function review_request() { |
| 31 | - | |
| 32 | 31 | // Only show the review request to high-level users on Formidable pages |
| 33 | 32 | if ( ! current_user_can( 'frm_change_settings' ) || ! FrmAppHelper::is_formidable_admin() ) { |
| 34 | 33 | return; |
| 35 | 34 | } |
| @@ -45,9 +44,9 @@ | ||
| 45 | 44 | } |
| 46 | 45 | |
| 47 | 46 | $week_ago = $this->review_status['time'] + WEEK_IN_SECONDS <= time(); |
| 48 | 47 | |
| 49 | - if ( empty( $dismissed ) && $week_ago ) { | |
| 48 | + if ( ! $dismissed && $week_ago ) { | |
| 50 | 49 | $this->review(); |
| 51 | 50 | } |
| 52 | 51 | } |
| 53 | 52 | |
| @@ -66,9 +65,9 @@ | ||
| 66 | 65 | 'dismissed' => false, |
| 67 | 66 | 'asked' => 0, |
| 68 | 67 | ); |
| 69 | 68 | |
| 70 | - if ( empty( $review ) ) { | |
| 69 | + if ( ! $review ) { | |
| 71 | 70 | // Set the review request to show in a week |
| 72 | 71 | update_user_meta( $user_id, $this->option_name, $default ); |
| 73 | 72 | } |
| 74 | 73 | |
| @@ -84,10 +83,9 @@ | ||
| 84 | 83 | * |
| 85 | 84 | * @return void |
| 86 | 85 | */ |
| 87 | 86 | private function review() { |
| 88 | - | |
| 89 | - // show the review request 3 times, depending on the number of entries | |
| 87 | + // Show the review request 3 times, depending on the number of entries | |
| 90 | 88 | $show_intervals = array( 50, 200, 500 ); |
| 91 | 89 | $asked = $this->review_status['asked']; |
| 92 | 90 | |
| 93 | 91 | if ( ! isset( $show_intervals[ $asked ] ) ) { |
| @@ -99,9 +97,9 @@ | ||
| 99 | 97 | $user = wp_get_current_user(); |
| 100 | 98 | |
| 101 | 99 | // Only show review request if the site has collected enough entries |
| 102 | 100 | if ( $entries < $count ) { |
| 103 | - // check the entry count again in a week | |
| 101 | + // Check the entry count again in a week | |
| 104 | 102 | $this->review_status['time'] = time(); |
| 105 | 103 | update_user_meta( $user->ID, $this->option_name, $this->review_status ); |
| 106 | 104 | |
| 107 | 105 | return; |
| @@ -106,19 +104,12 @@ | ||
| 106 | 104 | |
| 107 | 105 | return; |
| 108 | 106 | } |
| 109 | 107 | |
| 110 | - if ( $entries <= 100 ) { | |
| 111 | - // round to the nearest 10 | |
| 112 | - $entries = floor( $entries / 10 ) * 10; | |
| 113 | - } else { | |
| 114 | - // round to the nearest 50 | |
| 115 | - $entries = floor( $entries / 50 ) * 50; | |
| 116 | - } | |
| 108 | + $entries = $entries <= 100 ? floor( $entries / 10 ) * 10 : floor( $entries / 50 ) * 50; | |
| 109 | + $name = $user->first_name; | |
| 117 | 110 | |
| 118 | - $name = $user->first_name; | |
| 119 | - | |
| 120 | - if ( ! empty( $name ) ) { | |
| 111 | + if ( $name ) { | |
| 121 | 112 | $name = ' ' . $name; |
| 122 | 113 | } |
| 123 | 114 | |
| 124 | 115 | $title = sprintf( |
| @@ -165,13 +156,13 @@ | ||
| 165 | 156 | |
| 166 | 157 | $message->add_message( |
| 167 | 158 | array( |
| 168 | 159 | 'key' => $key, |
| 169 | - 'message' => __( 'If you are enjoying Formidable, could you do me a BIG favor and give us a review to help me grow my little business and boost our motivation?', 'formidable' ) . '<br/>' . | |
| 160 | + 'message' => __( 'If you are enjoying Formidable, could you do me a BIG favor and give us a review to help me grow my little business and boost our motivation?', 'formidable' ) . '<br/>' . // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 170 | 161 | '- Steph Wells<br/>' . |
| 171 | 162 | '<span>' . esc_html__( 'Co-Founder and CTO of Formidable Forms', 'formidable' ) . '<span>', |
| 172 | 163 | 'subject' => str_replace( $name, '', $title ), |
| 173 | - 'cta' => '<a href="https://wordpress.org/support/plugin/formidable/reviews/?filter=5#new-post" class="frm-dismiss-review-notice frm-review-out button frm-button-secondary" data-link="yes" target="_blank" rel="noopener noreferrer">' . | |
| 164 | + 'cta' => '<a href="https://wordpress.org/support/plugin/formidable/reviews/?filter=5#new-post" class="frm-dismiss-review-notice frm-review-out button frm-button-secondary" data-link="yes" target="_blank" rel="noopener noreferrer">' . // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 174 | 165 | esc_html__( 'Ok, you deserve it', 'formidable' ) . '</a>', |
| 175 | 166 | 'type' => 'feedback', |
| 176 | 167 | ) |
| 177 | 168 | ); |
| @@ -243,14 +234,14 @@ | ||
| 243 | 234 | |
| 244 | 235 | $user_id = get_current_user_id(); |
| 245 | 236 | $review = get_user_meta( $user_id, $this->option_name, true ); |
| 246 | 237 | |
| 247 | - if ( empty( $review ) ) { | |
| 238 | + if ( ! $review ) { | |
| 248 | 239 | $review = array(); |
| 249 | 240 | } |
| 250 | 241 | |
| 251 | 242 | if ( isset( $review['dismissed'] ) && $review['dismissed'] === 'done' ) { |
| 252 | - // if feedback was submitted, don't update it again when the review is dismissed | |
| 243 | + // If feedback was submitted, don't update it again when the review is dismissed | |
| 253 | 244 | $this->set_inbox_dismissed(); |
| 254 | 245 | wp_die(); |
| 255 | 246 | } |
| 256 | 247 | |