[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/plugins/akismet/views/ -> notice.php (source)

   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  if ( ! isset( $type ) ) {
  13      $type = false; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
  14  }
  15  
  16  /*
  17   * 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.
  18   */
  19  ?>
  20  <?php if ( $type === 'plugin' ) : ?>
  21      <?php // Displayed on edit-comments.php to users who have not set up Akismet yet. ?>
  22      <div class="updated" id="akismet-setup-prompt">
  23          <form name="akismet_activate" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
  24              <div class="akismet-activate">
  25                  <input type="submit" class="akismet-activate__button akismet-button" value="<?php esc_attr_e( 'Set up your Akismet account', 'akismet' ); ?>" />
  26                  <div class="akismet-activate__description">
  27                      <?php esc_html_e( 'Almost done! Configure Akismet and say goodbye to spam', 'akismet' ); ?>
  28                  </div>
  29              </div>
  30          </form>
  31      </div>
  32  
  33  <?php elseif ( $type === 'spam-check' ) : ?>
  34      <?php // This notice is only displayed on edit-comments.php. ?>
  35      <div class="notice notice-warning">
  36          <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' ); ?></strong></p>
  37          <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>
  38          <?php if ( ! empty( $link_text ) ) : ?>
  39              <p><?php echo wp_kses( $link_text, $kses_allow_link ); ?></p>
  40          <?php endif; ?>
  41      </div>
  42  
  43  <?php elseif ( $type === 'spam-check-cron-disabled' ) : ?>
  44      <?php // This notice is only displayed on edit-comments.php. ?>
  45      <div class="notice notice-warning">
  46          <p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' ); ?></strong></p>
  47          <p><?php esc_html_e( 'WP-Cron has been disabled using the DISABLE_WP_CRON constant. Comment rechecks may not work properly.', 'akismet' ); ?></p>
  48      </div>
  49  
  50  <?php elseif ( $type === 'alert' && $code === Akismet::ALERT_CODE_COMMERCIAL && $parent_view === 'config' ) : ?>
  51      <?php // Display a different commercial warning alert on the config page ?>
  52      <div class="akismet-card akismet-alert is-commercial">
  53          <div>
  54              <h3 class="akismet-alert-header"><?php esc_html_e( 'We detected commercial activity on your site', 'akismet' ); ?></h3>
  55              <p class="akismet-alert-info">
  56                  <?php
  57                      /* translators: The placeholder is a URL. */
  58                      echo wp_kses( sprintf( __( 'Your current subscription is for <a href="%s">personal, non-commercial use</a>. Please upgrade your plan to continue using Akismet.', 'akismet' ), esc_url( 'https://akismet.com/support/getting-started/free-or-paid/' ) ), $kses_allow_link );
  59                  ?>
  60              </p>
  61              <p class="akismet-alert-info">
  62                  <?php
  63                      /* translators: The placeholder is a URL to the contact form. */
  64                      echo wp_kses( sprintf( __( 'If you believe your site should not be classified as commercial, <a href="%s">please get in touch</a>.', 'akismet' ), esc_url( 'https://akismet.com/contact/?purpose=commercial' ) ), $kses_allow_link );
  65                  ?>
  66              </p>
  67          </div>
  68          <div class="akismet-alert-button-wrapper">
  69              <a href="https://akismet.com/pricing/?flow=upgrade&amp;utm_source=akismet_plugin&amp;utm_campaign=commercial_notice&amp;utm_medium=banner" class="akismet-alert-button akismet-button">
  70              <?php esc_html_e( 'Upgrade plan' ); ?>
  71              </a>
  72          </div>
  73      </div>
  74  
  75  <?php elseif ( $type === 'alert' ) : ?>
  76  <div class="<?php echo isset( $parent_view ) && $parent_view === 'config' ? 'akismet-alert is-bad' : 'error'; ?>">
  77      <?php /* translators: The placeholder is an error code returned by Akismet. */ ?>
  78      <p><strong><?php printf( esc_html__( 'Akismet error code: %s', 'akismet' ), esc_html( $code ) ); ?></strong></p>
  79      <p><?php echo isset( $msg ) ? esc_html( $msg ) : ''; ?></p>
  80      <p>
  81          <?php
  82          /* translators: the placeholder is a clickable URL that leads to more information regarding an error code. */
  83          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>' );
  84          ?>
  85      </p>
  86  </div>
  87  
  88  <?php elseif ( $type === 'notice' ) : ?>
  89  <div class="akismet-alert is-bad">
  90      <h3 class="akismet-alert__heading"><?php echo wp_kses( $notice_header, Akismet_Admin::get_notice_kses_allowed_elements() ); ?></h3>
  91      <p>
  92          <?php echo wp_kses( $notice_text, Akismet_Admin::get_notice_kses_allowed_elements() ); ?>
  93      </p>
  94  </div>
  95  
  96  <?php elseif ( $type === 'missing-functions' ) : ?>
  97  <div class="akismet-alert is-bad">
  98      <h3 class="akismet-alert__heading"><?php esc_html_e( 'Network functions are disabled.', 'akismet' ); ?></h3>
  99      <p>
 100          <?php
 101          /* translators: The placeholder is a URL. */
 102          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 ) ) );
 103          ?>
 104      </p>
 105  </div>
 106  
 107  <?php elseif ( $type === 'servers-be-down' ) : ?>
 108  <div class="akismet-alert is-bad">
 109      <h3 class="akismet-alert__heading"><?php esc_html_e( 'Your site can&#8217;t connect to the Akismet servers.', 'akismet' ); ?></h3>
 110      <p>
 111      <?php
 112          /* translators: The placeholder is a URL. */
 113          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 );
 114      ?>
 115      </p>
 116  </div>
 117  
 118  <?php elseif ( $type === 'active-dunning' ) : ?>
 119  <div class="akismet-alert is-bad">
 120      <h3 class="akismet-alert__heading"><?php esc_html_e( 'Please update your payment information.', 'akismet' ); ?></h3>
 121      <p>
 122          <?php
 123          /* translators: The placeholder is a URL. */
 124          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 );
 125          ?>
 126      </p>
 127  </div>
 128  
 129  <?php elseif ( $type === 'cancelled' ) : ?>
 130  <div class="akismet-alert is-bad">
 131      <h3 class="akismet-alert__heading"><?php esc_html_e( 'Your Akismet plan has been cancelled.', 'akismet' ); ?></h3>
 132      <p>
 133          <?php
 134          /* translators: The placeholder is a URL. */
 135          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 );
 136          ?>
 137      </p>
 138  </div>
 139  
 140  <?php elseif ( $type === 'suspended' ) : ?>
 141  <div class="akismet-alert is-bad">
 142      <h3 class="akismet-alert__heading"><?php esc_html_e( 'Your Akismet subscription is suspended.', 'akismet' ); ?></h3>
 143      <p>
 144          <?php
 145          /* translators: The placeholder is a URL. */
 146          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 );
 147          ?>
 148      </p>
 149  </div>
 150  
 151  <?php elseif ( $type === 'active-notice' && $time_saved ) : ?>
 152  <div class="akismet-alert is-neutral">
 153      <h3 class="akismet-alert__heading"><?php echo esc_html( $time_saved ); ?></h3>
 154      <p>
 155          <?php
 156          /* translators: the placeholder is a clickable URL to the Akismet account upgrade page. */
 157          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 );
 158          ?>
 159      </p>
 160  </div>
 161  
 162  <?php elseif ( $type === 'missing' ) : ?>
 163  <div class="akismet-alert is-bad">
 164      <h3 class="akismet-alert__heading"><?php esc_html_e( 'There is a problem with your API key.', 'akismet' ); ?></h3>
 165      <p>
 166          <?php
 167          /* translators: The placeholder is a URL to the Akismet contact form. */
 168          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 );
 169          ?>
 170      </p>
 171  </div>
 172  
 173  <?php elseif ( $type === 'no-sub' ) : ?>
 174  <div class="akismet-alert is-bad">
 175      <h3 class="akismet-alert__heading"><?php esc_html_e( 'You don&#8217;t have an Akismet plan.', 'akismet' ); ?></h3>
 176      <p><?php echo esc_html__( 'Your API key must have an Akismet plan before it can protect your site from spam.', 'akismet' ); ?></p>
 177      <p>
 178          <?php
 179          /* translators: the placeholder is the URL to the Akismet pricing page. */
 180          echo wp_kses( sprintf( __( 'Please <a href="%s" target="_blank">choose a plan</a> to get started with Akismet.', 'akismet' ), esc_url( 'https://akismet.com/pricing' ) ), $kses_allow_link );
 181          ?>
 182      </p>
 183  </div>
 184  
 185  <?php elseif ( $type === 'new-key-valid' ) : ?>
 186      <?php
 187      global $wpdb;
 188  
 189      $check_pending_link = false;
 190  
 191      $at_least_one_comment_in_moderation = ! ! $wpdb->get_var( "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_approved = '0' LIMIT 1" );
 192  
 193      if ( $at_least_one_comment_in_moderation ) {
 194          $check_pending_link = 'edit-comments.php?akismet_recheck=' . wp_create_nonce( 'akismet_recheck' );
 195      }
 196      ?>
 197      <div class="akismet-alert is-good">
 198          <p><?php esc_html_e( 'Akismet is now protecting your site from spam.', 'akismet' ); ?></p>
 199          <?php if ( $check_pending_link ) : ?>
 200              <p>
 201                  <?php
 202                  echo wp_kses(
 203                      sprintf(
 204                          /* translators: The placeholder is a URL for checking pending comments. */
 205                          __( 'Would you like to <a href="%s">check pending comments</a>?', 'akismet' ),
 206                          esc_url( $check_pending_link )
 207                      ),
 208                      $kses_allow_link
 209                  );
 210                  ?>
 211              </p>
 212          <?php endif; ?>
 213      </div>
 214  
 215  <?php elseif ( $type === 'new-key-invalid' ) : ?>
 216  <div class="akismet-alert is-bad">
 217      <p><?php esc_html_e( 'The key you entered is invalid. Please double-check it.', 'akismet' ); ?></p>
 218  </div>
 219  
 220  <?php elseif ( $type === 'existing-key-invalid' ) : ?>
 221  <div class="akismet-alert is-bad">
 222      <h3 class="akismet-alert__heading"><?php echo esc_html( __( 'Your API key is no longer valid.', 'akismet' ) ); ?></h3>
 223      <p>
 224          <?php
 225          echo wp_kses(
 226              sprintf(
 227                  /* translators: The placeholder is a URL to the Akismet contact form. */
 228                  __( 'Please enter a new key or <a href="%s" target="_blank">contact Akismet support</a>.', 'akismet' ),
 229                  'https://akismet.com/contact/'
 230              ),
 231              $kses_allow_link
 232          );
 233          ?>
 234      </p>
 235  </div>
 236  
 237  <?php elseif ( $type === 'new-key-failed' ) : ?>
 238  <div class="akismet-alert is-bad">
 239      <h3 class="akismet-alert__heading"><?php esc_html_e( 'The API key you entered could not be verified.', 'akismet' ); ?></h3>
 240      <p>
 241          <?php
 242          echo wp_kses(
 243              sprintf(
 244                  /* translators: The placeholder is a URL. */
 245                  __( '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' ),
 246                  'https://blog.akismet.com/akismet-hosting-faq/'
 247              ),
 248              $kses_allow_link
 249          );
 250          ?>
 251      </p>
 252  </div>
 253  
 254  <?php elseif ( $type === 'usage-limit' && isset( Akismet::$limit_notices[ $code ] ) ) : ?>
 255  <div class="error akismet-usage-limit-alert">
 256      <div class="akismet-usage-limit-logo">
 257          <img src="<?php echo esc_url( plugins_url( '../_inc/img/logo-a-2x.png', __FILE__ ) ); ?>" alt="Akismet logo" />
 258      </div>
 259      <div class="akismet-usage-limit-text">
 260          <h3>
 261          <?php
 262          switch ( Akismet::$limit_notices[ $code ] ) {
 263              case 'FIRST_MONTH_OVER_LIMIT':
 264              case 'SECOND_MONTH_OVER_LIMIT':
 265                  esc_html_e( 'Your Akismet account usage is over your plan&#8217;s limit', 'akismet' );
 266                  break;
 267              case 'THIRD_MONTH_APPROACHING_LIMIT':
 268                  esc_html_e( 'Your Akismet account usage is approaching your plan&#8217;s limit', 'akismet' );
 269                  break;
 270              case 'THIRD_MONTH_OVER_LIMIT':
 271              case 'FOUR_PLUS_MONTHS_OVER_LIMIT':
 272                  esc_html_e( 'Your account has been restricted', 'akismet' );
 273                  break;
 274              default:
 275          }
 276          ?>
 277          </h3>
 278          <p>
 279          <?php
 280          switch ( Akismet::$limit_notices[ $code ] ) {
 281              case 'FIRST_MONTH_OVER_LIMIT':
 282                  echo esc_html(
 283                      sprintf(
 284                          /* translators: The first placeholder is a date, the second is a (formatted) number, the third is another formatted number. */
 285                          __( 'Since %1$s, your account made %2$s API calls, compared to your plan&#8217;s limit of %3$s.', 'akismet' ),
 286                          esc_html( gmdate( 'F' ) . ' 1' ),
 287                          number_format( $api_calls ),
 288                          number_format( $usage_limit )
 289                      )
 290                  );
 291                  echo '&nbsp;';
 292                  echo '<a href="https://docs.akismet.com/akismet-api-usage-limits/" target="_blank">';
 293                  echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) );
 294                  echo '</a>';
 295  
 296                  break;
 297              case 'SECOND_MONTH_OVER_LIMIT':
 298                  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' ) );
 299                  echo '&nbsp;';
 300                  echo '<a href="https://docs.akismet.com/akismet-api-usage-limits/" target="_blank">';
 301                  echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) );
 302                  echo '</a>';
 303  
 304                  break;
 305              case 'THIRD_MONTH_APPROACHING_LIMIT':
 306                  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' ) );
 307                  echo '&nbsp;';
 308                  echo '<a href="https://docs.akismet.com/akismet-api-usage-limits/" target="_blank">';
 309                  echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) );
 310                  echo '</a>';
 311  
 312                  break;
 313              case 'THIRD_MONTH_OVER_LIMIT':
 314              case 'FOUR_PLUS_MONTHS_OVER_LIMIT':
 315                  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' ) );
 316                  echo '&nbsp;';
 317                  echo '<a href="https://docs.akismet.com/akismet-api-usage-limits/" target="_blank">';
 318                  echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) );
 319                  echo '</a>';
 320  
 321                  break;
 322  
 323              default:
 324          }
 325          ?>
 326          </p>
 327      </div>
 328      <div class="akismet-usage-limit-cta">
 329          <a href="<?php echo esc_attr( $upgrade_url ); ?>" class="button" target="_blank">
 330              <?php
 331              if ( isset( $upgrade_via_support ) && $upgrade_via_support ) {
 332                  // Direct user to contact support.
 333                  esc_html_e( 'Contact Akismet support', 'akismet' );
 334              } elseif ( ! empty( $upgrade_type ) && 'qty' === $upgrade_type ) {
 335                  // If only a qty upgrade is required, show a more generic message.
 336                  esc_html_e( 'Upgrade your subscription level', 'akismet' );
 337              } else {
 338                  echo esc_html(
 339                      sprintf(
 340                          /* translators: The placeholder is the name of a subscription level, like "Plus" or "Enterprise" . */
 341                          __( 'Upgrade to %s', 'akismet' ),
 342                          $upgrade_plan
 343                      )
 344                  );
 345              }
 346              ?>
 347          </a>
 348      </div>
 349  </div>
 350  <?php endif; ?>


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref