| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 //phpcs:disable VariableAnalysis 3 // There are "undefined" variables here because they're defined in the code that includes this file as a template. 4 $kses_allow_link = Akismet_Admin::get_link_kses_allowed_elements(); 5 $kses_allow_strong = array( 'strong' => true ); 6 7 // Screen-reader new-tab hint, reused as the %2$s placeholder in the links below. 8 $opens_in_new_tab = Akismet::get_new_tab_screen_reader_html(); 9 10 if ( ! isset( $type ) ) { 11 $type = false; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited 12 } 13 14 /* 15 * Some notices (plugin, spam-check, spam-check-cron-disabled, alert and usage-limit) are also shown elsewhere in wp-admin, so have different classes applied so that they match the standard WordPress notice format. 16 */ 17 ?> 18 <?php if ( $type === 'plugin' ) : ?> 19 <?php // Displayed on edit-comments.php to users who have not set up Akismet yet. ?> 20 <div class="updated" id="akismet-setup-prompt"> 21 <form name="akismet_activate" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post"> 22 <div class="akismet-activate"> 23 <input type="submit" class="akismet-activate__button akismet-button" value="<?php esc_attr_e( 'Set up your Akismet account', 'akismet' ); ?>" /> 24 <div class="akismet-activate__description"> 25 <?php esc_html_e( 'Almost done! Configure Akismet and say goodbye to spam', 'akismet' ); ?> 26 </div> 27 </div> 28 </form> 29 </div> 30 <?php elseif ( $type === 'spam-check' ) : ?> 31 <?php // This notice is only displayed on edit-comments.php. ?> 32 <div class="notice notice-warning"> 33 <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' ); ?></strong></p> 34 <p><?php esc_html_e( 'Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation and will automatically be rechecked later.', 'akismet' ); ?></p> 35 <?php if ( ! empty( $link_text ) ) : ?> 36 <p><?php echo wp_kses( $link_text, $kses_allow_link ); ?></p> 37 <?php endif; ?> 38 </div> 39 40 <?php elseif ( $type === 'spam-check-cron-disabled' ) : ?> 41 <?php // This notice is only displayed on edit-comments.php. ?> 42 <div class="notice notice-warning"> 43 <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' ); ?></strong></p> 44 <p><?php esc_html_e( 'WP-Cron has been disabled using the DISABLE_WP_CRON constant. Comment rechecks may not work properly.', 'akismet' ); ?></p> 45 </div> 46 47 <?php elseif ( $type === 'alert' && $code === Akismet::ALERT_CODE_COMMERCIAL && isset( $parent_view ) && $parent_view === 'config' ) : ?> 48 <?php // Display a different commercial warning alert on the config page ?> 49 <div class="akismet-card akismet-alert is-commercial"> 50 <div> 51 <h3 class="akismet-alert-header"><?php esc_html_e( 'We detected commercial activity on your site', 'akismet' ); ?></h3> 52 <p class="akismet-alert-info"> 53 <?php 54 /* translators: 1: URL, 2: hidden screen-reader text noting the link opens in a new tab. */ 55 echo wp_kses( sprintf( __( 'Your current subscription is for <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">personal, non-commercial use%2$s</a>. Please upgrade your plan to continue using Akismet.', 'akismet' ), esc_url( 'https://akismet.com/support/getting-started/free-or-paid/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=commercial_support' ), $opens_in_new_tab ), $kses_allow_link ); 56 ?> 57 </p> 58 <p class="akismet-alert-info"> 59 <?php 60 /* translators: 1: URL to the contact form, 2: hidden screen-reader text noting the link opens in a new tab. */ 61 echo wp_kses( sprintf( __( 'If you believe your site should not be classified as commercial, <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">please get in touch%2$s</a>', 'akismet' ), esc_url( 'https://akismet.com/contact/?purpose=commercial&utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=commercial_contact' ), $opens_in_new_tab ), $kses_allow_link ); 62 ?> 63 </p> 64 </div> 65 <div class="akismet-alert-button-wrapper"> 66 <?php 67 Akismet::view( 68 'get', 69 array( 70 'text' => __( 'Upgrade plan', 'akismet' ), 71 'classes' => array( 'akismet-alert-button', 'akismet-button' ), 72 'redirect' => 'upgrade', 73 'utm_content' => 'commercial_upgrade', 74 ) 75 ); 76 ?> 77 </div> 78 </div> 79 80 <?php elseif ( $type === 'alert' ) : ?> 81 <div class="<?php echo isset( $parent_view ) && $parent_view === 'config' ? 'akismet-alert is-bad' : 'error'; ?>"> 82 <?php /* translators: The placeholder is an error code returned by Akismet. */ ?> 83 <p><strong><?php printf( esc_html__( 'Akismet error code: %s', 'akismet' ), esc_html( $code ) ); ?></strong></p> 84 <p><?php echo isset( $msg ) ? esc_html( $msg ) : ''; ?></p> 85 <p> 86 <?php 87 echo wp_kses( 88 sprintf( 89 /* translators: 1: clickable URL that leads to more information regarding an error code, 2: hidden screen-reader text noting the link opens in a new tab. */ 90 __( 'For more information, see the <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">error documentation on akismet.com%2$s</a>', 'akismet' ), 91 esc_url( 'https://akismet.com/developers/detailed-docs/errors/akismet-error-' . absint( $code ) . '?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=error_info' ), 92 $opens_in_new_tab 93 ), 94 $kses_allow_link 95 ); 96 ?> 97 </p> 98 </div> 99 100 <?php elseif ( $type === 'notice' ) : ?> 101 <div class="akismet-alert is-bad"> 102 <h3 class="akismet-alert__heading"><?php echo wp_kses( $notice_header, Akismet_Admin::get_notice_kses_allowed_elements() ); ?></h3> 103 <p> 104 <?php echo wp_kses( $notice_text, Akismet_Admin::get_notice_kses_allowed_elements() ); ?> 105 </p> 106 </div> 107 108 <?php elseif ( $type === 'missing-functions' ) : ?> 109 <div class="akismet-alert is-bad"> 110 <h3 class="akismet-alert__heading"><?php esc_html_e( 'Network functions are disabled.', 'akismet' ); ?></h3> 111 <p> 112 <?php 113 echo wp_kses( __( 'Your web host or server administrator has disabled PHP’s <code>gethostbynamel</code> function.', 'akismet' ), array_merge( $kses_allow_link, $kses_allow_strong, array( 'code' => true ) ) ); 114 ?> 115 </p> 116 <p> 117 <?php 118 /* translators: 1: URL, 2: hidden screen-reader text noting the link opens in a new tab. */ 119 echo wp_kses( sprintf( __( 'Please contact your web host or firewall administrator and give them <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">this information about Akismet’s system requirements%2$s</a>', 'akismet' ), esc_url( 'https://akismet.com/akismet-hosting-faq/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=hosting_faq_php' ), $opens_in_new_tab ), array_merge( $kses_allow_link, $kses_allow_strong, array( 'code' => true ) ) ); 120 ?> 121 </p> 122 </div> 123 124 <?php elseif ( $type === 'servers-be-down' ) : ?> 125 <div class="akismet-alert is-bad"> 126 <h3 class="akismet-alert__heading"><?php esc_html_e( 'Your site can’t connect to the Akismet servers.', 'akismet' ); ?></h3> 127 <p> 128 <?php 129 /* translators: 1: URL, 2: hidden screen-reader text noting the link opens in a new tab. */ 130 echo wp_kses( sprintf( __( 'Your firewall may be blocking Akismet from connecting to its API. Please contact your host and refer to <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">our guide about firewalls%2$s</a>', 'akismet' ), esc_url( 'https://akismet.com/akismet-hosting-faq/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=hosting_faq_firewall' ), $opens_in_new_tab ), $kses_allow_link ); 131 ?> 132 </p> 133 </div> 134 135 <?php elseif ( $type === 'cancelled' ) : ?> 136 <div class="akismet-alert is-bad"> 137 <h3 class="akismet-alert__heading"><?php esc_html_e( 'Your Akismet plan has been cancelled.', 'akismet' ); ?></h3> 138 <p> 139 <?php 140 /* translators: 1: URL, 2: hidden screen-reader text noting the link opens in a new tab. */ 141 echo wp_kses( sprintf( __( 'Please visit <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">Akismet.com%2$s</a> to purchase a new subscription.', 'akismet' ), esc_url( 'https://akismet.com/pricing/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=pricing_cancelled' ), $opens_in_new_tab ), $kses_allow_link ); 142 ?> 143 </p> 144 </div> 145 146 <?php elseif ( $type === 'suspended' ) : ?> 147 <div class="akismet-alert is-bad"> 148 <h3 class="akismet-alert__heading"><?php esc_html_e( 'Your Akismet subscription is suspended.', 'akismet' ); ?></h3> 149 <p> 150 <?php 151 /* translators: 1: URL, 2: hidden screen-reader text noting the link opens in a new tab. */ 152 echo wp_kses( sprintf( __( 'Please contact <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">Akismet support%2$s</a> for assistance.', 'akismet' ), esc_url( 'https://akismet.com/contact/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=support_suspended' ), $opens_in_new_tab ), $kses_allow_link ); 153 ?> 154 </p> 155 </div> 156 157 <?php elseif ( $type === 'active-notice' && $time_saved ) : ?> 158 <div class="akismet-alert is-neutral"> 159 <h3 class="akismet-alert__heading"><?php echo esc_html( $time_saved ); ?></h3> 160 <p> 161 <?php 162 /* translators: 1: clickable URL to the Akismet account upgrade page, 2: hidden screen-reader text noting the link opens in a new tab. */ 163 echo wp_kses( sprintf( __( 'You can help us fight spam and upgrade your account by <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">contributing a token amount%2$s</a>', 'akismet' ), esc_url( 'https://akismet.com/pricing?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=upgrade_contribution' ), $opens_in_new_tab ), $kses_allow_link ); 164 ?> 165 </p> 166 </div> 167 168 <?php elseif ( $type === 'missing' ) : ?> 169 <div class="akismet-alert is-bad"> 170 <h3 class="akismet-alert__heading"><?php esc_html_e( 'There is a problem with your API key.', 'akismet' ); ?></h3> 171 <p> 172 <?php 173 /* translators: 1: URL to the Akismet contact form, 2: hidden screen-reader text noting the link opens in a new tab. */ 174 echo wp_kses( sprintf( __( 'Please contact <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">Akismet support%2$s</a> for assistance.', 'akismet' ), esc_url( 'https://akismet.com/contact/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=support_missing' ), $opens_in_new_tab ), $kses_allow_link ); 175 ?> 176 </p> 177 </div> 178 179 <?php elseif ( $type === 'no-sub' ) : ?> 180 <div class="akismet-alert is-bad"> 181 <h3 class="akismet-alert__heading"><?php esc_html_e( 'You don’t have an Akismet plan.', 'akismet' ); ?></h3> 182 <p> 183 <?php 184 /* translators: 1: URL to the Akismet pricing page, 2: hidden screen-reader text noting the link opens in a new tab. */ 185 echo wp_kses( sprintf( __( 'Please <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">choose a free or paid plan%2$s</a> so Akismet can protect your site from spam.', 'akismet' ), esc_url( 'https://akismet.com/pricing?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=choose_plan' ), $opens_in_new_tab ), $kses_allow_link ); 186 ?> 187 </p> 188 <p><?php echo esc_html__( 'Once you\'ve chosen a plan, return here to complete your setup.', 'akismet' ); ?></p> 189 </div> 190 191 <?php elseif ( $type === 'new-key-valid' ) : ?> 192 <?php 193 global $wpdb; 194 195 $check_pending_link = false; 196 197 $at_least_one_comment_in_moderation = ! ! $wpdb->get_var( "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_approved = '0' LIMIT 1" ); 198 199 if ( $at_least_one_comment_in_moderation ) { 200 $check_pending_link = 'edit-comments.php?akismet_recheck=' . wp_create_nonce( 'akismet_recheck' ); 201 } 202 ?> 203 <div class="akismet-alert is-good"> 204 <p><?php esc_html_e( 'Akismet is now protecting your site from spam.', 'akismet' ); ?></p> 205 <?php if ( $check_pending_link ) : ?> 206 <p> 207 <?php 208 echo wp_kses( 209 sprintf( 210 /* translators: The placeholder is a URL for checking pending comments. */ 211 __( 'Would you like to <a href="%s">scan pending comments for spam</a>?', 'akismet' ), 212 esc_url( $check_pending_link ) 213 ), 214 $kses_allow_link 215 ); 216 ?> 217 </p> 218 <?php endif; ?> 219 </div> 220 221 <?php elseif ( $type === 'new-key-invalid' ) : ?> 222 <div class="akismet-alert is-bad"> 223 <p><?php esc_html_e( 'The key you entered is invalid. Please double-check it.', 'akismet' ); ?></p> 224 </div> 225 226 <?php elseif ( $type === Akismet_Admin::NOTICE_EXISTING_KEY_INVALID ) : ?> 227 <div class="akismet-alert is-bad"> 228 <h3 class="akismet-alert__heading"><?php echo esc_html( __( 'Your API key is no longer valid.', 'akismet' ) ); ?></h3> 229 <p> 230 <?php 231 echo wp_kses( 232 sprintf( 233 /* translators: 1: URL to the Akismet contact form, 2: hidden screen-reader text noting the link opens in a new tab. */ 234 __( 'Please enter a new key or <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">contact Akismet support%2$s</a>', 'akismet' ), 235 'https://akismet.com/contact/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=support_invalid_key', 236 $opens_in_new_tab 237 ), 238 $kses_allow_link 239 ); 240 ?> 241 </p> 242 </div> 243 244 <?php elseif ( $type === 'new-key-failed' ) : ?> 245 <div class="akismet-alert is-bad"> 246 <h3 class="akismet-alert__heading"><?php esc_html_e( 'The API key you entered could not be verified.', 'akismet' ); ?></h3> 247 <p> 248 <?php 249 echo wp_kses( 250 sprintf( 251 /* translators: 1: URL, 2: hidden screen-reader text noting the link opens in a new tab. */ 252 __( 'The connection to akismet.com could not be established. Please refer to <a class="akismet-external-link" href="%1$s" target="_blank" rel="noopener">our guide about firewalls%2$s</a> and check your server configuration.', 'akismet' ), 253 'https://akismet.com/akismet-hosting-faq/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=hosting_faq', 254 $opens_in_new_tab 255 ), 256 $kses_allow_link 257 ); 258 ?> 259 </p> 260 </div> 261 262 <?php elseif ( $type === 'usage-limit' && isset( Akismet::$limit_notices[ $code ] ) ) : ?> 263 <div class="error akismet-usage-limit-alert"> 264 <div class="akismet-usage-limit-logo"> 265 <img src="<?php echo esc_url( plugins_url( '../_inc/img/logo-a-2x.png', __FILE__ ) ); ?>" alt="Akismet logo" /> 266 </div> 267 <div class="akismet-usage-limit-text"> 268 <h3> 269 <?php 270 switch ( Akismet::$limit_notices[ $code ] ) { 271 case 'FIRST_MONTH_OVER_LIMIT': 272 case 'SECOND_MONTH_OVER_LIMIT': 273 esc_html_e( 'Your Akismet account usage is over your plan’s limit', 'akismet' ); 274 break; 275 case 'THIRD_MONTH_APPROACHING_LIMIT': 276 esc_html_e( 'Your Akismet account usage is approaching your plan’s limit', 'akismet' ); 277 break; 278 case 'THIRD_MONTH_OVER_LIMIT': 279 case 'FOUR_PLUS_MONTHS_OVER_LIMIT': 280 esc_html_e( 'Your account has been restricted', 'akismet' ); 281 break; 282 default: 283 } 284 ?> 285 </h3> 286 <p> 287 <?php 288 switch ( Akismet::$limit_notices[ $code ] ) { 289 case 'FIRST_MONTH_OVER_LIMIT': 290 echo esc_html( 291 sprintf( 292 /* translators: The first placeholder is a date, the second is a (formatted) number, the third is another formatted number. */ 293 __( 'Since %1$s, your account made %2$s API calls, compared to your plan’s limit of %3$s.', 'akismet' ), 294 esc_html( gmdate( 'F' ) . ' 1' ), 295 number_format( $api_calls ), 296 number_format( $usage_limit ) 297 ) 298 ); 299 echo ' '; 300 echo '<a class="akismet-external-link" href="https://akismet.com/support/general/akismet-api-usage-limits/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=usage_limit_docs" target="_blank" rel="noopener">'; 301 echo esc_html( __( 'Learn more about usage limits', 'akismet' ) ); 302 echo Akismet::get_new_tab_screen_reader_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Returns markup escaped in the helper. 303 echo '</a>'; 304 305 break; 306 case 'SECOND_MONTH_OVER_LIMIT': 307 echo esc_html( __( 'Your Akismet usage has been over your plan’s limit for two consecutive months. Next month, we will restrict your account after you reach the limit. Increase your limit to make sure your site stays protected from spam.', 'akismet' ) ); 308 echo ' '; 309 echo '<a class="akismet-external-link" href="https://akismet.com/support/general/akismet-api-usage-limits/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=usage_limit_docs" target="_blank" rel="noopener">'; 310 echo esc_html( __( 'Learn more about usage limits', 'akismet' ) ); 311 echo Akismet::get_new_tab_screen_reader_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Returns markup escaped in the helper. 312 echo '</a>'; 313 314 break; 315 case 'THIRD_MONTH_APPROACHING_LIMIT': 316 echo esc_html( __( 'Your Akismet usage is nearing your plan’s limit for the third consecutive month. We will restrict your account after you reach the limit. Increase your limit to make sure your site stays protected from spam.', 'akismet' ) ); 317 echo ' '; 318 echo '<a class="akismet-external-link" href="https://akismet.com/support/general/akismet-api-usage-limits/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=usage_limit_docs" target="_blank" rel="noopener">'; 319 echo esc_html( __( 'Learn more about usage limits', 'akismet' ) ); 320 echo Akismet::get_new_tab_screen_reader_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Returns markup escaped in the helper. 321 echo '</a>'; 322 323 break; 324 case 'THIRD_MONTH_OVER_LIMIT': 325 case 'FOUR_PLUS_MONTHS_OVER_LIMIT': 326 echo esc_html( __( 'Your Akismet usage has been over your plan’s limit for three consecutive months. We have restricted your account for the rest of the month. Increase your limit to make sure your site stays protected from spam.', 'akismet' ) ); 327 echo ' '; 328 echo '<a class="akismet-external-link" href="https://akismet.com/support/general/akismet-api-usage-limits/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=usage_limit_docs" target="_blank" rel="noopener">'; 329 echo esc_html( __( 'Learn more about usage limits', 'akismet' ) ); 330 echo Akismet::get_new_tab_screen_reader_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Returns markup escaped in the helper. 331 echo '</a>'; 332 333 break; 334 335 default: 336 } 337 ?> 338 </p> 339 </div> 340 <div class="akismet-usage-limit-cta"> 341 <a href="<?php echo esc_url( $upgrade_url . ( strpos( $upgrade_url, '?' ) !== false ? '&' : '?' ) . 'utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=usage_limit_upgrade' ); ?>" class="button" target="_blank" rel="noopener"> 342 <?php 343 if ( isset( $upgrade_via_support ) && $upgrade_via_support ) { 344 // Direct user to contact support. 345 esc_html_e( 'Contact Akismet support', 'akismet' ); 346 } elseif ( ! empty( $upgrade_type ) && 'qty' === $upgrade_type ) { 347 // If a qty upgrade is required, use recommended plan name if available. 348 if ( ! empty( $recommended_plan_name ) && is_string( $recommended_plan_name ) ) { 349 echo esc_html( 350 sprintf( 351 /* translators: The placeholder is the name of an Akismet subscription plan, like "Akismet Pro" or "Akismet Business" . */ 352 __( 'Add an %s subscription', 'akismet' ), 353 $recommended_plan_name 354 ) 355 ); 356 } else { 357 esc_html_e( 'Increase your limit', 'akismet' ); 358 } 359 } else { 360 echo esc_html( 361 sprintf( 362 /* translators: The placeholder is the name of a subscription level, like "Akismet Business" or "Akismet Enterprise" . */ 363 __( 'Upgrade to %s', 'akismet' ), 364 $upgrade_plan 365 ) 366 ); 367 } 368 ?> 369 <?php echo Akismet::get_new_tab_screen_reader_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Returns markup escaped in the helper. ?> 370 </a> 371 </div> 372 </div> 373 <?php endif; ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Thu Sep 3 08:20:25 2026 | Cross-referenced by PHPXref |