<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
<?php
/**
 * Registers Akismet abilities with the WordPress Abilities API.
 *
 * @package Akismet
 * @since 5.7
 */

declare( strict_types = 1 );

// Load ability interface and classes.
require_once __DIR__ . '/abilities/interface-akismet-ability.php';
require_once __DIR__ . '/abilities/class-akismet-ability.php';
require_once __DIR__ . '/abilities/class-akismet-ability-get-stats.php';
require_once __DIR__ . '/abilities/class-akismet-ability-comment-check.php';

/**
 * Class Akismet_Abilities
 *
 * Registers Akismet abilities with the WordPress Abilities API.
 * Provides abilities for spam detection and comment moderation.
 */
class Akismet_Abilities {

	/**
	 * The category slug for Akismet abilities.
	 *
	 * @var string
	 */
	const CATEGORY_SLUG = 'akismet';

	/**
	 * Initialize the ability registration.
	 *
	 * @return void
	 */
	public static function init() {
		// Register category.
		if ( did_action( 'wp_abilities_api_categories_init' ) ) {
			self::register_category();
		} else {
			add_action( 'wp_abilities_api_categories_init', array( __CLASS__, 'register_category' ) );
		}

		// Register abilities.
		if ( did_action( 'wp_abilities_api_init' ) ) {
			self::register_abilities();
		} else {
			add_action( 'wp_abilities_api_init', array( __CLASS__, 'register_abilities' ) );
		}
	}

	/**
	 * Register the Akismet ability category.
	 *
	 * @return void
	 */
	public static function register_category() {
		if ( ! function_exists( 'wp_register_ability_category' ) ) {
			return;
		}

		wp_register_ability_category(
			self::CATEGORY_SLUG,
			array(
				'label'       => 'Akismet',
				'description' => __( 'Abilities for spam protection and comment moderation with Akismet.', 'akismet' ),
			)
		);
	}

	/**
	 * Register all Akismet abilities.
	 *
	 * @return void
	 */
	public static function register_abilities() {
		if ( ! function_exists( 'wp_register_ability' ) ) {
			return;
		}

		$abilities = array(
			Akismet_Ability_Get_Stats::class,
			Akismet_Ability_Comment_Check::class,
		);

		foreach ( $abilities as $ability_class ) {
			new $ability_class();
		}
	}
}
