• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Akismet_Admin::enter_api_key() –

You appear to be a bot. Output may be restricted

Description

Usage

Akismet_Admin::enter_api_key();

Parameters

Returns

void

Source

File name: akismet/class.akismet-admin.php
Lines:

1 to 37 of 37
  public static function enter_api_key() {
    if ( ! current_user_can( 'manage_options' ) ) {
      die( __( 'Cheatin’ uh?', 'akismet' ) );
    }

    if ( !wp_verify_nonce( $_POST['_wpnonce'], self::NONCE ) )
      return false;

    foreach( array( 'akismet_strictness', 'akismet_show_user_comments_approved' ) as $option ) {
      update_option( $option, isset( $_POST[$option] ) && (int) $_POST[$option] == 1 ? '1' : '0' );
    }

    if ( ! empty( $_POST['akismet_comment_form_privacy_notice'] ) ) {
      self::set_form_privacy_notice_option( $_POST['akismet_comment_form_privacy_notice'] );
    } else {
      self::set_form_privacy_notice_option( 'hide' );
    }

    if ( Akismet::predefined_api_key() ) {
      return false; //shouldn't have option to save key if already defined
    }
    
    $new_key = preg_replace( '/[^a-f0-9]/i', '', $_POST['key'] );
    $old_key = Akismet::get_api_key();

    if ( empty( $new_key ) ) {
      if ( !empty( $old_key ) ) {
        delete_option( 'wordpress_api_key' );
        self::$notices[] = 'new-key-empty';
      }
    }
    elseif ( $new_key != $old_key ) {
      self::save_key( $new_key );
    }

    return true;
  }
 

 View on GitHub View on Trac

Published: 19th December 2019 | Last updated: 19th December 2019

Primary Sidebar

Information

Function name: Akismet_Admin::enter_api_key
Class ref: Akismet_Admin
Plugin ref: Akismet
Version: 5.0.1
Sourcefile: class.akismet-admin.php
File ref: class.akismet-admin.php
Deprecated?: No
API Letters: A,E,K

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.27
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites