Filter hook 'akismet_spam_check_warning_link_text'

in WP Core File wp-content/plugins/akismet/class.akismet-admin.php at line 999

Description

Find out whether any comments in the Pending queue have not yet been checked by Akismet. / public static function are_any_comments_waiting_to_be_checked() { return !! get_comments( array( // Exclude comments that are not pending. This would happen if someone manually approved or spammed a comment // that was waiting to be checked. The akismet_error meta entry will eventually be removed by the cron recheck job. 'status' => 'hold', // This is the commentmeta that is saved when a comment couldn't be checked. 'meta_key' => 'akismet_error', // We only need to know whether at least one comment is waiting for a check. 'number' => 1, ) ); } public static function get_page_url( $page = 'config' ) { $args = array( 'page' => 'akismet-key-config' ); if ( $page == 'stats' ) { $args = array( 'page' => 'akismet-key-config', 'view' => 'stats' ); } elseif ( $page == 'delete_key' ) { $args = array( 'page' => 'akismet-key-config', 'view' => 'start', 'action' => 'delete-key', '_wpnonce' => wp_create_nonce( self::NONCE ) ); } elseif ( $page === 'init' ) { $args = array( 'page' => 'akismet-key-config', 'view' => 'start' ); } return add_query_arg( $args, menu_page_url( 'akismet-key-config', false ) ); } public static function get_akismet_user( $api_key ) { $akismet_user = false; $request_args = array( 'key' => $api_key, 'blog' => get_option( 'home' ), ); $request_args = apply_filters( 'akismet_request_args', $request_args, 'get-subscription' ); $subscription_verification = Akismet::http_post( Akismet::build_query( $request_args ), 'get-subscription' ); if ( ! empty( $subscription_verification[1] ) ) { if ( 'invalid' !== $subscription_verification[1] ) { $akismet_user = json_decode( $subscription_verification[1] ); } } return $akismet_user; } public static function get_stats( $api_key ) { $stat_totals = array(); foreach( array( '6-months', 'all' ) as $interval ) { $request_args = array( 'blog' => get_option( 'home' ), 'key' => $api_key, 'from' => $interval, ); $request_args = apply_filters( 'akismet_request_args', $request_args, 'get-stats' ); $response = Akismet::http_post( Akismet::build_query( $request_args ), 'get-stats' ); if ( ! empty( $response[1] ) ) { $data = json_decode( $response[1] ); /* The json decoded response should be an object. If it's not an object, something's wrong, and the data shouldn't be added to the stats_totals array. / if ( is_object( $data ) ) { $stat_totals[ $interval ] = $data; } } } return $stat_totals; } public static function verify_wpcom_key( $api_key, $user_id, $extra = array() ) { $request_args = array_merge( array( 'user_id' => $user_id, 'api_key' => $api_key, 'get_account_type' => 'true', ), $extra ); $request_args = apply_filters( 'akismet_request_args', $request_args, 'verify-wpcom-key' ); $akismet_account = Akismet::http_post( Akismet::build_query( $request_args ), 'verify-wpcom-key' ); if ( ! empty( $akismet_account[1] ) ) $akismet_account = json_decode( $akismet_account[1] ); Akismet::log( compact( 'akismet_account' ) ); return $akismet_account; } public static function connect_jetpack_user() { if ( $jetpack_user = self::get_jetpack_user() ) { if ( isset( $jetpack_user['user_id'] ) && isset( $jetpack_user['api_key'] ) ) { $akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'], array( 'action' => 'connect_jetpack_user' ) ); if ( is_object( $akismet_user ) ) { self::save_key( $akismet_user->api_key ); return in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub' ) ); } } } return false; } public static function display_alert() { Akismet::view( 'notice', array( 'type' => 'alert', 'code' => (int) get_option( 'akismet_alert_code' ), 'msg' => get_option( 'akismet_alert_msg' ) ) ); } public static function get_usage_limit_alert_data() { return array( 'type' => 'usage-limit', 'code' => (int) get_option( 'akismet_alert_code' ), 'msg' => get_option( 'akismet_alert_msg' ), 'api_calls' => get_option( 'akismet_alert_api_calls' ), 'usage_limit' => get_option( 'akismet_alert_usage_limit' ), 'upgrade_plan' => get_option( 'akismet_alert_upgrade_plan' ), 'upgrade_url' => get_option( 'akismet_alert_upgrade_url' ), 'upgrade_type' => get_option( 'akismet_alert_upgrade_type' ), 'upgrade_via_support' => get_option( 'akismet_alert_upgrade_via_support' ) === 'true', ); } public static function display_usage_limit_alert() { Akismet::view( 'notice', self::get_usage_limit_alert_data() ); } public static function display_spam_check_warning() { Akismet::fix_scheduled_recheck(); if ( wp_next_scheduled('akismet_schedule_cron_recheck') > time() && self::are_any_comments_waiting_to_be_checked() ) { /* The 'akismet_display_cron_disabled_notice' filter can be used to control whether the WP-Cron disabled notice is displayed.

Occurrences

Filename Line Number
wp-content/plugins/akismet/class.akismet-admin.php 999

PHP Doc

/**
	 * Find out whether any comments in the Pending queue have not yet been checked by Akismet.
	 *
	 * @return bool
	 */
	public static function are_any_comments_waiting_to_be_checked() {
		return !! get_comments( array(
			// Exclude comments that are not pending. This would happen if someone manually approved or spammed a comment
			// that was waiting to be checked. The akismet_error meta entry will eventually be removed by the cron recheck job.
			'status' => 'hold',

			// This is the commentmeta that is saved when a comment couldn't be checked.
			'meta_key' => 'akismet_error',

			// We only need to know whether at least one comment is waiting for a check.
			'number' => 1,
		) );
	}

	public static function get_page_url( $page = 'config' ) {

		$args = array( 'page' => 'akismet-key-config' );

		if ( $page == 'stats' ) {
			$args = array( 'page' => 'akismet-key-config', 'view' => 'stats' );
		} elseif ( $page == 'delete_key' ) {
			$args = array( 'page' => 'akismet-key-config', 'view' => 'start', 'action' => 'delete-key', '_wpnonce' => wp_create_nonce( self::NONCE ) );
		} elseif ( $page === 'init' ) {
			$args = array( 'page' => 'akismet-key-config', 'view' => 'start' );
		}

		return add_query_arg( $args, menu_page_url( 'akismet-key-config', false ) );
	}

	public static function get_akismet_user( $api_key ) {
		$akismet_user = false;

		$request_args = array(
			'key' => $api_key,
			'blog' => get_option( 'home' ),
		);

		$request_args = apply_filters( 'akismet_request_args', $request_args, 'get-subscription' );

		$subscription_verification = Akismet::http_post( Akismet::build_query( $request_args ), 'get-subscription' );

		if ( ! empty( $subscription_verification[1] ) ) {
			if ( 'invalid' !== $subscription_verification[1] ) {
				$akismet_user = json_decode( $subscription_verification[1] );
			}
		}

		return $akismet_user;
	}

	public static function get_stats( $api_key ) {
		$stat_totals = array();

		foreach( array( '6-months', 'all' ) as $interval ) {
			$request_args = array(
				'blog' => get_option( 'home' ),
				'key' => $api_key,
				'from' => $interval,
			);

			$request_args = apply_filters( 'akismet_request_args', $request_args, 'get-stats' );

			$response = Akismet::http_post( Akismet::build_query( $request_args ), 'get-stats' );

			if ( ! empty( $response[1] ) ) {
				$data = json_decode( $response[1] );
				/*
				 * The json decoded response should be an object. If it's not an object, something's wrong, and the data
				 * shouldn't be added to the stats_totals array.
				 */
				if ( is_object( $data ) ) {
					$stat_totals[ $interval ] = $data;
				}
			}
		}

		return $stat_totals;
	}

	public static function verify_wpcom_key( $api_key, $user_id, $extra = array() ) {
		$request_args = array_merge(
			array(
				'user_id' => $user_id,
				'api_key' => $api_key,
				'get_account_type' => 'true',
			),
			$extra
		);

		$request_args = apply_filters( 'akismet_request_args', $request_args, 'verify-wpcom-key' );

		$akismet_account = Akismet::http_post( Akismet::build_query( $request_args ), 'verify-wpcom-key' );

		if ( ! empty( $akismet_account[1] ) )
			$akismet_account = json_decode( $akismet_account[1] );

		Akismet::log( compact( 'akismet_account' ) );

		return $akismet_account;
	}

	public static function connect_jetpack_user() {

		if ( $jetpack_user = self::get_jetpack_user() ) {
			if ( isset( $jetpack_user['user_id'] ) && isset(  $jetpack_user['api_key'] ) ) {
				$akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'], array( 'action' => 'connect_jetpack_user' ) );

				if ( is_object( $akismet_user ) ) {
					self::save_key( $akismet_user->api_key );
					return in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub' ) );
				}
			}
		}

		return false;
	}

	public static function display_alert() {
		Akismet::view( 'notice', array(
			'type' => 'alert',
			'code' => (int) get_option( 'akismet_alert_code' ),
			'msg'  => get_option( 'akismet_alert_msg' )
		) );
	}

	public static function get_usage_limit_alert_data() {
		return array(
			'type'                => 'usage-limit',
			'code'                => (int) get_option( 'akismet_alert_code' ),
			'msg'                 => get_option( 'akismet_alert_msg' ),
			'api_calls'           => get_option( 'akismet_alert_api_calls' ),
			'usage_limit'         => get_option( 'akismet_alert_usage_limit' ),
			'upgrade_plan'        => get_option( 'akismet_alert_upgrade_plan' ),
			'upgrade_url'         => get_option( 'akismet_alert_upgrade_url' ),
			'upgrade_type'        => get_option( 'akismet_alert_upgrade_type' ),
			'upgrade_via_support' => get_option( 'akismet_alert_upgrade_via_support' ) === 'true',
		);
	}

	public static function display_usage_limit_alert() {
		Akismet::view( 'notice', self::get_usage_limit_alert_data() );
	}

	public static function display_spam_check_warning() {
		Akismet::fix_scheduled_recheck();

		if ( wp_next_scheduled('akismet_schedule_cron_recheck') > time() && self::are_any_comments_waiting_to_be_checked() ) {
			/*
			 * The 'akismet_display_cron_disabled_notice' filter can be used to control whether the WP-Cron disabled notice is displayed.
			 */