notice.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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 = array(
  5. 'a' => array(
  6. 'href' => true,
  7. 'target' => true,
  8. ),
  9. );
  10. $kses_allow_strong = array( 'strong' => true );
  11. /*
  12. * Some notices (plugin, spam-check, spam-check-cron-disabled, alert and usage-limit) are shown elsewhere in wp-admin,
  13. * so look different to the standard notices.
  14. */
  15. ?>
  16. <?php if ( $type === 'plugin' ) : ?>
  17. <div class="updated" id="akismet_setup_prompt">
  18. <form name="akismet_activate" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
  19. <div class="akismet_activate">
  20. <div class="aa_a">A</div>
  21. <div class="aa_button_container">
  22. <div class="aa_button_border">
  23. <input type="submit" class="aa_button" value="<?php esc_attr_e( 'Set up your Akismet account', 'akismet' ); ?>" />
  24. </div>
  25. </div>
  26. <div class="aa_description">
  27. <?php
  28. echo wp_kses(
  29. __( '<strong>Almost done</strong> - configure Akismet and say goodbye to spam', 'akismet' ),
  30. $kses_allow_strong
  31. );
  32. ?>
  33. </div>
  34. </div>
  35. </form>
  36. </div>
  37. <?php elseif ( $type === 'spam-check' ) : ?>
  38. <div class="notice notice-warning">
  39. <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' ); ?></strong></p>
  40. <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>
  41. <?php if ( $link_text ) : ?>
  42. <p><?php echo wp_kses( $link_text, $kses_allow_link ); ?></p>
  43. <?php endif; ?>
  44. </div>
  45. <?php elseif ( $type === 'spam-check-cron-disabled' ) : ?>
  46. <div class="notice notice-warning">
  47. <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' ); ?></strong></p>
  48. <p><?php esc_html_e( 'WP-Cron has been disabled using the DISABLE_WP_CRON constant. Comment rechecks may not work properly.', 'akismet' ); ?></p>
  49. </div>
  50. <?php elseif ( $type === 'alert' ) : ?>
  51. <div class="error">
  52. <?php /* translators: The placeholder is an error code returned by Akismet. */ ?>
  53. <p><strong><?php printf( esc_html__( 'Akismet error code: %s', 'akismet' ), esc_html( $code ) ); ?></strong></p>
  54. <p><?php echo esc_html( $msg ); ?></p>
  55. <p>
  56. <?php
  57. /* translators: the placeholder is a clickable URL that leads to more information regarding an error code. */
  58. printf( esc_html__( 'For more information: %s', 'akismet' ), '<a href="https://akismet.com/errors/' . esc_attr( $code ) . '">https://akismet.com/errors/' . esc_attr( $code ) . '</a>' );
  59. ?>
  60. </p>
  61. </div>
  62. <?php elseif ( $type === 'notice' ) : ?>
  63. <div class="akismet-alert is-bad">
  64. <h3 class="akismet-alert__heading"><?php echo wp_kses( $notice_header, Akismet_Admin::get_notice_kses_allowed_elements() ); ?></h3>
  65. <p>
  66. <?php echo wp_kses( $notice_text, Akismet_Admin::get_notice_kses_allowed_elements() ); ?>
  67. </p>
  68. </div>
  69. <?php elseif ( $type === 'missing-functions' ) : ?>
  70. <div class="akismet-alert is-bad">
  71. <h3 class="akismet-alert__heading"><?php esc_html_e( 'Network functions are disabled.', 'akismet' ); ?></h3>
  72. <p>
  73. <?php
  74. /* translators: The placeholder is a URL. */
  75. echo wp_kses( sprintf( __( 'Your web host or server administrator has disabled PHP&#8217;s <code>gethostbynamel</code> function. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet&#8217;s system requirements</a>.', 'akismet' ), esc_url( 'https://akismet.com/akismet-hosting-faq/' ) ), array_merge( $kses_allow_link, $kses_allow_strong, array( 'code' => true ) ) );
  76. ?>
  77. </p>
  78. </div>
  79. <?php elseif ( $type === 'servers-be-down' ) : ?>
  80. <div class="akismet-alert is-bad">
  81. <h3 class="akismet-alert__heading"><?php esc_html_e( 'Your site can&#8217;t connect to the Akismet servers.', 'akismet' ); ?></h3>
  82. <p>
  83. <?php
  84. /* translators: The placeholder is a URL. */
  85. echo wp_kses( sprintf( __( 'Your firewall may be blocking Akismet from connecting to its API. Please contact your host and refer to <a href="%s" target="_blank">our guide about firewalls</a>.', 'akismet' ), esc_url( 'https://akismet.com/akismet-hosting-faq/' ) ), $kses_allow_link );
  86. ?>
  87. </p>
  88. </div>
  89. <?php elseif ( $type === 'active-dunning' ) : ?>
  90. <div class="akismet-alert is-bad">
  91. <h3 class="akismet-alert__heading"><?php esc_html_e( 'Please update your payment information.', 'akismet' ); ?></h3>
  92. <p>
  93. <?php
  94. /* translators: The placeholder is a URL. */
  95. echo wp_kses( sprintf( __( 'We cannot process your payment. Please <a href="%s" target="_blank">update your payment details</a>.', 'akismet' ), esc_url( 'https://akismet.com/account/' ) ), $kses_allow_link );
  96. ?>
  97. </p>
  98. </div>
  99. <?php elseif ( $type === 'cancelled' ) : ?>
  100. <div class="akismet-alert is-bad">
  101. <h3 class="akismet-alert__heading"><?php esc_html_e( 'Your Akismet plan has been cancelled.', 'akismet' ); ?></h3>
  102. <p>
  103. <?php
  104. /* translators: The placeholder is a URL. */
  105. echo wp_kses( sprintf( __( 'Please visit your <a href="%s" target="_blank">Akismet account page</a> to reactivate your subscription.', 'akismet' ), esc_url( 'https://akismet.com/account/' ) ), $kses_allow_link );
  106. ?>
  107. </p>
  108. </div>
  109. <?php elseif ( $type === 'suspended' ) : ?>
  110. <div class="akismet-alert is-bad">
  111. <h3 class="akismet-alert__heading"><?php esc_html_e( 'Your Akismet subscription is suspended.', 'akismet' ); ?></h3>
  112. <p>
  113. <?php
  114. /* translators: The placeholder is a URL. */
  115. echo wp_kses( sprintf( __( 'Please contact <a href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet' ), esc_url( 'https://akismet.com/contact/' ) ), $kses_allow_link );
  116. ?>
  117. </p>
  118. </div>
  119. <?php elseif ( $type === 'active-notice' && $time_saved ) : ?>
  120. <div class="akismet-alert is-neutral">
  121. <h3 class="akismet-alert__heading"><?php echo esc_html( $time_saved ); ?></h3>
  122. <p>
  123. <?php
  124. /* translators: the placeholder is a clickable URL to the Akismet account upgrade page. */
  125. echo wp_kses( sprintf( __( 'You can help us fight spam and upgrade your account by <a href="%s" target="_blank">contributing a token amount</a>.', 'akismet' ), esc_url( 'https://akismet.com/pricing' ) ), $kses_allow_link );
  126. ?>
  127. </p>
  128. </div>
  129. <?php elseif ( $type === 'missing' ) : ?>
  130. <div class="akismet-alert is-bad">
  131. <h3 class="akismet-alert__heading"><?php esc_html_e( 'There is a problem with your API key.', 'akismet' ); ?></h3>
  132. <p>
  133. <?php
  134. /* translators: The placeholder is a URL to the Akismet contact form. */
  135. echo wp_kses( sprintf( __( 'Please contact <a href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet' ), esc_url( 'https://akismet.com/contact/' ) ), $kses_allow_link );
  136. ?>
  137. </p>
  138. </div>
  139. <?php elseif ( $type === 'no-sub' ) : ?>
  140. <div class="akismet-alert is-bad">
  141. <h3 class="akismet-alert__heading"><?php esc_html_e( 'You don&#8217;t have an Akismet plan.', 'akismet' ); ?></h3>
  142. <p>
  143. <?php
  144. /* translators: the placeholder is a clickable URL to the Akismet account upgrade page. */
  145. echo wp_kses( sprintf( __( 'In 2012, Akismet began using subscription plans for all accounts (even free ones). A plan has not been assigned to your account, and we&#8217;d appreciate it if you&#8217;d <a href="%s" target="_blank">sign into your account</a> and choose one.', 'akismet' ), esc_url( 'https://akismet.com/pricing' ) ), $kses_allow_link );
  146. ?>
  147. <br /><br />
  148. <?php
  149. /* translators: The placeholder is a URL to the Akismet contact form. */
  150. echo wp_kses( sprintf( __( 'Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet' ), esc_url( 'https://akismet.com/contact/' ) ), $kses_allow_link );
  151. ?>
  152. </p>
  153. </div>
  154. <?php elseif ( $type === 'new-key-valid' ) : ?>
  155. <?php
  156. global $wpdb;
  157. $check_pending_link = false;
  158. $at_least_one_comment_in_moderation = ! ! $wpdb->get_var( "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_approved = '0' LIMIT 1" );
  159. if ( $at_least_one_comment_in_moderation ) {
  160. $check_pending_link = 'edit-comments.php?akismet_recheck=' . wp_create_nonce( 'akismet_recheck' );
  161. }
  162. ?>
  163. <div class="akismet-alert is-good">
  164. <p><?php esc_html_e( 'Akismet is now protecting your site from spam.', 'akismet' ); ?></p>
  165. <?php if ( $check_pending_link ) : ?>
  166. <p>
  167. <?php
  168. echo wp_kses(
  169. sprintf(
  170. /* translators: The placeholder is a URL for checking pending comments. */
  171. __( 'Would you like to <a href="%s">check pending comments</a>?', 'akismet' ),
  172. esc_url( $check_pending_link )
  173. ),
  174. $kses_allow_link
  175. );
  176. ?>
  177. </p>
  178. <?php endif; ?>
  179. </div>
  180. <?php elseif ( $type === 'new-key-invalid' ) : ?>
  181. <div class="akismet-alert is-bad">
  182. <p><?php esc_html_e( 'The key you entered is invalid. Please double-check it.', 'akismet' ); ?></p>
  183. </div>
  184. <?php elseif ( $type === 'existing-key-invalid' ) : ?>
  185. <div class="akismet-alert is-bad">
  186. <h3 class="akismet-alert__heading"><?php echo esc_html( __( 'Your API key is no longer valid.', 'akismet' ) ); ?></h3>
  187. <p>
  188. <?php
  189. echo wp_kses(
  190. sprintf(
  191. /* translators: The placeholder is a URL to the Akismet contact form. */
  192. __( 'Please enter a new key or <a href="%s" target="_blank">contact Akismet support</a>.', 'akismet' ),
  193. 'https://akismet.com/contact/'
  194. ),
  195. $kses_allow_link
  196. );
  197. ?>
  198. </p>
  199. </div>
  200. <?php elseif ( $type === 'new-key-failed' ) : ?>
  201. <div class="akismet-alert is-bad">
  202. <h3 class="akismet-alert__heading"><?php esc_html_e( 'The API key you entered could not be verified.', 'akismet' ); ?></h3>
  203. <p>
  204. <?php
  205. echo wp_kses(
  206. sprintf(
  207. /* translators: The placeholder is a URL. */
  208. __( 'The connection to akismet.com could not be established. Please refer to <a href="%s" target="_blank">our guide about firewalls</a> and check your server configuration.', 'akismet' ),
  209. 'https://blog.akismet.com/akismet-hosting-faq/'
  210. ),
  211. $kses_allow_link
  212. );
  213. ?>
  214. </p>
  215. </div>
  216. <?php elseif ( $type === 'usage-limit' && isset( Akismet::$limit_notices[ $code ] ) ) : ?>
  217. <div class="error akismet-usage-limit-alert">
  218. <div class="akismet-usage-limit-logo">
  219. <img src="<?php echo esc_url( plugins_url( '../_inc/img/logo-a-2x.png', __FILE__ ) ); ?>" alt="Akismet logo" />
  220. </div>
  221. <div class="akismet-usage-limit-text">
  222. <h3>
  223. <?php
  224. switch ( Akismet::$limit_notices[ $code ] ) {
  225. case 'FIRST_MONTH_OVER_LIMIT':
  226. case 'SECOND_MONTH_OVER_LIMIT':
  227. esc_html_e( 'Your Akismet account usage is over your plan&#8217;s limit', 'akismet' );
  228. break;
  229. case 'THIRD_MONTH_APPROACHING_LIMIT':
  230. esc_html_e( 'Your Akismet account usage is approaching your plan&#8217;s limit', 'akismet' );
  231. break;
  232. case 'THIRD_MONTH_OVER_LIMIT':
  233. case 'FOUR_PLUS_MONTHS_OVER_LIMIT':
  234. esc_html_e( 'Your account has been restricted', 'akismet' );
  235. break;
  236. default:
  237. }
  238. ?>
  239. </h3>
  240. <p>
  241. <?php
  242. switch ( Akismet::$limit_notices[ $code ] ) {
  243. case 'FIRST_MONTH_OVER_LIMIT':
  244. echo esc_html(
  245. sprintf(
  246. /* translators: The first placeholder is a date, the second is a (formatted) number, the third is another formatted number. */
  247. __( 'Since %1$s, your account made %2$s API calls, compared to your plan&#8217;s limit of %3$s.', 'akismet' ),
  248. esc_html( gmdate( 'F' ) . ' 1' ),
  249. number_format( $api_calls ),
  250. number_format( $usage_limit )
  251. )
  252. );
  253. echo '&nbsp;';
  254. echo '<a href="https://docs.akismet.com/akismet-api-usage-limits/" target="_blank">';
  255. echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) );
  256. echo '</a>';
  257. break;
  258. case 'SECOND_MONTH_OVER_LIMIT':
  259. echo esc_html( __( 'Your Akismet usage has been over your plan&#8217;s limit for two consecutive months. Next month, we will restrict your account after you reach the limit. Please consider upgrading your plan.', 'akismet' ) );
  260. echo '&nbsp;';
  261. echo '<a href="https://docs.akismet.com/akismet-api-usage-limits/" target="_blank">';
  262. echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) );
  263. echo '</a>';
  264. break;
  265. case 'THIRD_MONTH_APPROACHING_LIMIT':
  266. echo esc_html( __( 'Your Akismet usage is nearing your plan&#8217;s limit for the third consecutive month. We will restrict your account after you reach the limit. Upgrade your plan so Akismet can continue blocking spam.', 'akismet' ) );
  267. echo '&nbsp;';
  268. echo '<a href="https://docs.akismet.com/akismet-api-usage-limits/" target="_blank">';
  269. echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) );
  270. echo '</a>';
  271. break;
  272. case 'THIRD_MONTH_OVER_LIMIT':
  273. case 'FOUR_PLUS_MONTHS_OVER_LIMIT':
  274. echo esc_html( __( 'Your Akismet usage has been over your plan&#8217;s limit for three consecutive months. We have restricted your account for the rest of the month. Upgrade your plan so Akismet can continue blocking spam.', 'akismet' ) );
  275. echo '&nbsp;';
  276. echo '<a href="https://docs.akismet.com/akismet-api-usage-limits/" target="_blank">';
  277. echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) );
  278. echo '</a>';
  279. break;
  280. default:
  281. }
  282. ?>
  283. </p>
  284. </div>
  285. <div class="akismet-usage-limit-cta">
  286. <a href="<?php echo esc_attr( $upgrade_url ); ?>" class="button" target="_blank">
  287. <?php
  288. // If only a qty upgrade is required, show a more generic message.
  289. if ( ! empty( $upgrade_type ) && 'qty' === $upgrade_type ) {
  290. esc_html_e( 'Upgrade your subscription level', 'akismet' );
  291. } else {
  292. echo esc_html(
  293. sprintf(
  294. /* translators: The placeholder is the name of a subscription level, like "Plus" or "Enterprise" . */
  295. __( 'Upgrade to %s', 'akismet' ),
  296. $upgrade_plan
  297. )
  298. );
  299. }
  300. ?>
  301. </a>
  302. </div>
  303. </div>
  304. <?php endif; ?>