config.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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_href = array(
  5. 'a' => array(
  6. 'href' => true,
  7. ),
  8. );
  9. ?>
  10. <div id="akismet-plugin-container">
  11. <div class="akismet-masthead">
  12. <div class="akismet-masthead__inside-container">
  13. <?php Akismet::view( 'logo' ); ?>
  14. </div>
  15. </div>
  16. <div class="akismet-lower">
  17. <?php if ( Akismet::get_api_key() ) { ?>
  18. <?php Akismet_Admin::display_status(); ?>
  19. <?php } ?>
  20. <?php if ( ! empty( $notices ) ) { ?>
  21. <?php foreach ( $notices as $notice ) { ?>
  22. <?php Akismet::view( 'notice', $notice ); ?>
  23. <?php } ?>
  24. <?php } ?>
  25. <div class="akismet-card">
  26. <div class="akismet-section-header">
  27. <h2 class="akismet-section-header__label">
  28. <span><?php esc_html_e( 'Statistics', 'akismet' ); ?></span>
  29. </h2>
  30. <?php if ( $stat_totals && isset( $stat_totals['all'] ) && (int) $stat_totals['all']->spam > 0 ) : ?>
  31. <div class="akismet-section-header__actions">
  32. <a href="<?php echo esc_url( Akismet_Admin::get_page_url( 'stats' ) ); ?>">
  33. <?php esc_html_e( 'Detailed stats', 'akismet' ); ?>
  34. </a>
  35. </div>
  36. </div> <!-- close akismet-section-header -->
  37. <div class="akismet-new-snapshot">
  38. <?php /* name attribute on iframe is used as a cache-buster here to force Firefox to load the new style charts: https://bugzilla.mozilla.org/show_bug.cgi?id=356558 */ ?>
  39. <div class="akismet-new-snapshot__chart">
  40. <iframe id="stats-iframe" allowtransparency="true" scrolling="no" frameborder="0" style="width: 100%; height: 220px; overflow: hidden;" src="<?php echo esc_url( sprintf( 'https://tools.akismet.com/1.0/snapshot.php?blog=%s&token=%s&height=200&locale=%s&is_redecorated=1', rawurlencode( get_option( 'home' ) ), rawurlencode( Akismet::get_access_token() ), get_locale() ) ); ?>" name="<?php echo esc_attr( 'snapshot-' . filemtime( __FILE__ ) ); ?>" title="<?php echo esc_attr__( 'Akismet stats' ); ?>"></iframe>
  41. </div>
  42. <ul class="akismet-new-snapshot__list">
  43. <li class="akismet-new-snapshot__item">
  44. <h3 class="akismet-new-snapshot__header"><?php esc_html_e( 'Past six months', 'akismet' ); ?></h3>
  45. <span class="akismet-new-snapshot__number"><?php echo number_format( $stat_totals['6-months']->spam ); ?></span>
  46. <span class="akismet-new-snapshot__text"><?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['6-months']->spam, 'akismet' ) ); ?></span>
  47. </li>
  48. <li class="akismet-new-snapshot__item">
  49. <h3 class="akismet-new-snapshot__header"><?php esc_html_e( 'All time', 'akismet' ); ?></h3>
  50. <span class="akismet-new-snapshot__number"><?php echo number_format( $stat_totals['all']->spam ); ?></span>
  51. <span class="akismet-new-snapshot__text"><?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['all']->spam, 'akismet' ) ); ?></span>
  52. </li>
  53. <li class="akismet-new-snapshot__item">
  54. <h3 class="akismet-new-snapshot__header"><?php esc_html_e( 'Accuracy', 'akismet' ); ?></h3>
  55. <span class="akismet-new-snapshot__number"><?php echo floatval( $stat_totals['all']->accuracy ); ?>%</span>
  56. <span class="akismet-new-snapshot__text">
  57. <?php
  58. /* translators: %s: number of spam missed by Akismet */
  59. echo esc_html( sprintf( _n( '%s missed spam', '%s missed spam', $stat_totals['all']->missed_spam, 'akismet' ), number_format( $stat_totals['all']->missed_spam ) ) ) . ', ';
  60. /* translators: %s: number of false positive spam flagged by Akismet */
  61. echo esc_html( sprintf( _n( '%s false positive', '%s false positives', $stat_totals['all']->false_positives, 'akismet' ), number_format( $stat_totals['all']->false_positives ) ) );
  62. ?>
  63. </span>
  64. </li>
  65. </ul>
  66. </div> <!-- close akismet-new-snapshot -->
  67. <?php else : ?>
  68. </div> <!-- close akismet-section-header -->
  69. <div class="inside">
  70. <p class="akismet-awaiting-stats"><?php esc_html_e( 'Akismet is active and ready to stop spam. Your site&#8217;s spam statistics will be displayed here.', 'akismet' ); ?></p>
  71. </div>
  72. <?php endif; ?>
  73. </div> <!-- close akismet-card -->
  74. <?php if ( $akismet_user ) : ?>
  75. <div class="akismet-card">
  76. <div class="akismet-section-header">
  77. <h2 class="akismet-section-header__label">
  78. <span><?php esc_html_e( 'Settings', 'akismet' ); ?></span>
  79. </h2>
  80. </div>
  81. <div class="inside">
  82. <form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" autocomplete="off" method="POST" id="akismet-settings-form">
  83. <div class="akismet-settings">
  84. <?php if ( ! Akismet::predefined_api_key() ) : ?>
  85. <div class="akismet-settings__row">
  86. <h3 class="akismet-settings__row-title">
  87. <label class="akismet-settings__row-label" for="key"><?php esc_html_e( 'API key', 'akismet' ); ?></label>
  88. </h3>
  89. <div class="akismet-settings__row-input">
  90. <span class="api-key"><input id="key" name="key" type="text" size="15" value="<?php echo esc_attr( get_option( 'wordpress_api_key' ) ); ?>" class="<?php echo esc_attr( 'regular-text code ' . $akismet_user->status ); ?>"></span>
  91. </div>
  92. </div>
  93. <?php endif; ?>
  94. <?php
  95. //phpcs:ignore WordPress.Security.NonceVerification.Recommended
  96. if ( isset( $_GET['ssl_status'] ) ) :
  97. ?>
  98. <div class="akismet-settings__row">
  99. <div class="akismet-settings__row-text">
  100. <h3 class="akismet-settings__row-title"><?php esc_html_e( 'SSL status', 'akismet' ); ?></h3>
  101. <div class="akismet-settings__row-description">
  102. <?php if ( ! wp_http_supports( array( 'ssl' ) ) ) : ?>
  103. <strong><?php esc_html_e( 'Disabled.', 'akismet' ); ?></strong>
  104. <?php esc_html_e( 'Your Web server cannot make SSL requests; contact your Web host and ask them to add support for SSL requests.', 'akismet' ); ?>
  105. <?php else : ?>
  106. <?php $ssl_disabled = get_option( 'akismet_ssl_disabled' ); ?>
  107. <?php if ( $ssl_disabled ) : ?>
  108. <strong><?php esc_html_e( 'Temporarily disabled.', 'akismet' ); ?></strong>
  109. <?php esc_html_e( 'Akismet encountered a problem with a previous SSL request and disabled it temporarily. It will begin using SSL for requests again shortly.', 'akismet' ); ?>
  110. <?php else : ?>
  111. <strong><?php esc_html_e( 'Enabled.', 'akismet' ); ?></strong>
  112. <?php esc_html_e( 'All systems functional.', 'akismet' ); ?>
  113. <?php endif; ?>
  114. <?php endif; ?>
  115. </div>
  116. </div>
  117. </div>
  118. <?php endif; ?>
  119. <div class="akismet-settings__row">
  120. <div class="akismet-settings__row-text">
  121. <h3 class="akismet-settings__row-title"><?php esc_html_e( 'Comments', 'akismet' ); ?></h3>
  122. </div>
  123. <div class="akismet-settings__row-input">
  124. <label class="akismet-settings__row-input-label" for="akismet_show_user_comments_approved">
  125. <input
  126. name="akismet_show_user_comments_approved"
  127. id="akismet_show_user_comments_approved"
  128. value="1"
  129. type="checkbox"
  130. <?php
  131. // If the option isn't set, or if it's enabled ('1'), or if it was enabled a long time ago ('true'), check the checkbox.
  132. checked( true, ( in_array( get_option( 'akismet_show_user_comments_approved' ), array( false, '1', 'true' ), true ) ) );
  133. ?>
  134. />
  135. <span class="akismet-settings__row-label-text">
  136. <?php esc_html_e( 'Show the number of approved comments beside each comment author.', 'akismet' ); ?>
  137. </span>
  138. </label>
  139. </div>
  140. </div>
  141. <div class="akismet-settings__row is-radio">
  142. <div class="akismet-settings__row-text">
  143. <h3 class="akismet-settings__row-title"><?php esc_html_e( 'Spam filtering', 'akismet' ); ?></h3>
  144. </div>
  145. <div class="akismet-settings__row-input">
  146. <fieldset>
  147. <legend class="screen-reader-text">
  148. <span><?php esc_html_e( 'Akismet Anti-spam strictness', 'akismet' ); ?></span>
  149. </legend>
  150. <div>
  151. <label class="akismet-settings__row-input-label" for="akismet_strictness_1">
  152. <input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked( '1', get_option( 'akismet_strictness' ) ); ?> />
  153. <span class="akismet-settings__row-label-text">
  154. <?php esc_html_e( 'Silently discard the worst and most pervasive spam so I never see it.', 'akismet' ); ?>
  155. </span>
  156. </label>
  157. </div>
  158. <div>
  159. <label class="akismet-settings__row-input-label" for="akismet_strictness_0">
  160. <input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked( '0', get_option( 'akismet_strictness' ) ); ?> />
  161. <span class="akismet-settings__row-label-text">
  162. <?php esc_html_e( 'Always put spam in the Spam folder for review.', 'akismet' ); ?>
  163. </span>
  164. </label>
  165. </div>
  166. </fieldset>
  167. <div class="akismet-settings__row-note">
  168. <strong><?php esc_html_e( 'Note:', 'akismet' ); ?></strong>
  169. <?php
  170. $delete_interval = max( 1, intval( apply_filters( 'akismet_delete_comment_interval', 15 ) ) );
  171. $spam_folder_link = sprintf(
  172. '<a href="%s">%s</a>',
  173. esc_url( admin_url( 'edit-comments.php?comment_status=spam' ) ),
  174. esc_html__( 'spam folder', 'akismet' )
  175. );
  176. // The _n() needs to be on one line so the i18n tooling can extract the translator comment.
  177. /* translators: %1$s: spam folder link, %2$d: delete interval in days */
  178. $delete_message = _n( 'Spam in the %1$s older than %2$d day is deleted automatically.', 'Spam in the %1$s older than %2$d days is deleted automatically.', $delete_interval, 'akismet' );
  179. printf(
  180. wp_kses( $delete_message, $kses_allow_link_href ),
  181. wp_kses( $spam_folder_link, $kses_allow_link_href ),
  182. esc_html( $delete_interval )
  183. );
  184. ?>
  185. </div>
  186. </div>
  187. </div>
  188. <div class="akismet-settings__row is-radio">
  189. <div class="akismet-settings__row-text">
  190. <h3 class="akismet-settings__row-title"><?php esc_html_e( 'Privacy', 'akismet' ); ?></h3>
  191. </div>
  192. <div class="akismet-settings__row-input">
  193. <fieldset>
  194. <legend class="screen-reader-text">
  195. <span><?php esc_html_e( 'Akismet privacy notice', 'akismet' ); ?></span>
  196. </legend>
  197. <div>
  198. <label class="akismet-settings__row-input-label" for="akismet_comment_form_privacy_notice_display">
  199. <input type="radio" name="akismet_comment_form_privacy_notice" id="akismet_comment_form_privacy_notice_display" value="display" <?php checked( 'display', get_option( 'akismet_comment_form_privacy_notice' ) ); ?> />
  200. <span class="akismet-settings__row-label-text">
  201. <?php esc_html_e( 'Display a privacy notice under your comment forms.', 'akismet' ); ?>
  202. </span>
  203. </label>
  204. </div>
  205. <div>
  206. <label class="akismet-settings__row-input-label" for="akismet_comment_form_privacy_notice_hide">
  207. <input type="radio" name="akismet_comment_form_privacy_notice" id="akismet_comment_form_privacy_notice_hide" value="hide" <?php echo in_array( get_option( 'akismet_comment_form_privacy_notice' ), array( 'display', 'hide' ), true ) ? checked( 'hide', get_option( 'akismet_comment_form_privacy_notice' ), false ) : 'checked="checked"'; ?> />
  208. <span class="akismet-settings__row-label-text">
  209. <?php esc_html_e( 'Do not display privacy notice.', 'akismet' ); ?>
  210. </span>
  211. </label>
  212. </div>
  213. </fieldset>
  214. <div class="akismet-settings__row-note">
  215. <?php esc_html_e( 'To help your site with transparency under privacy laws like the GDPR, Akismet can display a notice to your users under your comment forms.', 'akismet' ); ?>
  216. </div>
  217. </div>
  218. </div>
  219. </div>
  220. <div class="akismet-card-actions">
  221. <?php if ( ! Akismet::predefined_api_key() ) : ?>
  222. <div id="delete-action" class="akismet-card-actions__secondary-action">
  223. <a class="submitdelete deletion" href="<?php echo esc_url( Akismet_Admin::get_page_url( 'delete_key' ) ); ?>"><?php esc_html_e( 'Disconnect this account', 'akismet' ); ?></a>
  224. </div>
  225. <?php endif; ?>
  226. <?php wp_nonce_field( Akismet_Admin::NONCE ); ?>
  227. <div id="publishing-action">
  228. <input type="hidden" name="action" value="enter-key">
  229. <input type="submit" name="submit" id="submit" class="akismet-button akismet-could-be-primary" value="<?php esc_attr_e( 'Save changes', 'akismet' ); ?>">
  230. </div>
  231. </div>
  232. </form>
  233. </div>
  234. </div>
  235. <?php if ( ! Akismet::predefined_api_key() ) : ?>
  236. <div class="akismet-card">
  237. <div class="akismet-section-header">
  238. <h2 class="akismet-section-header__label">
  239. <span><?php esc_html_e( 'Account', 'akismet' ); ?></span>
  240. </h2>
  241. </div>
  242. <div class="inside">
  243. <table class="akismet-account">
  244. <tbody>
  245. <tr>
  246. <th scope="row"><?php esc_html_e( 'Subscription type', 'akismet' ); ?></th>
  247. <td>
  248. <?php echo esc_html( $akismet_user->account_name ); ?>
  249. </td>
  250. </tr>
  251. <tr>
  252. <th scope="row"><?php esc_html_e( 'Status', 'akismet' ); ?></th>
  253. <td>
  254. <?php
  255. if ( 'cancelled' === $akismet_user->status ) :
  256. esc_html_e( 'Cancelled', 'akismet' );
  257. elseif ( 'suspended' === $akismet_user->status ) :
  258. esc_html_e( 'Suspended', 'akismet' );
  259. elseif ( 'missing' === $akismet_user->status ) :
  260. esc_html_e( 'Missing', 'akismet' );
  261. elseif ( 'no-sub' === $akismet_user->status ) :
  262. esc_html_e( 'No subscription found', 'akismet' );
  263. else :
  264. esc_html_e( 'Active', 'akismet' );
  265. endif;
  266. ?>
  267. </td>
  268. </tr>
  269. <?php if ( $akismet_user->next_billing_date ) : ?>
  270. <tr>
  271. <th scope="row"><?php esc_html_e( 'Next billing date', 'akismet' ); ?></th>
  272. <td>
  273. <?php echo esc_html( gmdate( 'F j, Y', $akismet_user->next_billing_date ) ); ?>
  274. </td>
  275. </tr>
  276. <?php endif; ?>
  277. </tbody>
  278. </table>
  279. <div class="akismet-card-actions">
  280. <?php if ( $akismet_user->status === 'active' ) : ?>
  281. <div class="akismet-card-actions__secondary-action">
  282. <a href="https://akismet.com/account" target="_blank" rel="noopener noreferrer" aria-label="Account overview on akismet.com (opens in a new window)"><?php esc_html_e( 'Account overview', 'akismet' ); ?></a>
  283. </div>
  284. <?php endif; ?>
  285. <div id="publishing-action">
  286. <?php
  287. Akismet::view(
  288. 'get',
  289. array(
  290. 'text' => ( $akismet_user->account_type === 'free-api-key' && $akismet_user->status === 'active' ? __( 'Upgrade', 'akismet' ) : __( 'Change', 'akismet' ) ),
  291. 'redirect' => 'upgrade',
  292. )
  293. );
  294. ?>
  295. </div>
  296. </div>
  297. </div>
  298. </div>
  299. <?php endif; ?>
  300. <?php endif; ?>
  301. </div>
  302. </div>