[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/plugins/akismet/abilities/ -> class-akismet-ability.php (source)

   1  <?php
   2  /**
   3   * Represents a Base Ability.
   4   *
   5   * This class holds a default constructor to register the ability and a default permission.
   6   *
   7   * @package Akismet
   8   * @since 5.7
   9   */
  10  
  11  declare( strict_types = 1 );
  12  
  13  /**
  14   * Base class for Akismet abilities.
  15   *
  16   * @package Akismet
  17   * @since 5.7
  18   */
  19  abstract class Akismet_Ability implements Akismet_Ability_Interface {
  20  
  21      /**
  22       * Get the ability name.
  23       *
  24       * Classes extending this must implement this method to provide the ability name into the registration.
  25       *
  26       * @return string The ability name.
  27       */
  28      abstract protected function get_ability_name(): string;
  29  
  30      /**
  31       * Get the config.
  32       *
  33       * Classes extending this must implement this method to provide the ability configuration into the registration.
  34       *
  35       * @return array The ability configuration array.
  36       */
  37      abstract public function get_config(): array;
  38  
  39      /**
  40       * Constructor - registers the ability.
  41       */
  42  	public function __construct() {
  43          wp_register_ability(
  44              $this->get_ability_name(),
  45              $this->get_config()
  46          );
  47      }
  48  
  49      // phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.Found -- Base class default, subclasses use $input.
  50      /**
  51       * Permission callback for any ability that uses this trait.
  52       *
  53       * @param array|null $input The input parameters (unused).
  54       * @return bool Whether the current user can use this ability.
  55       */
  56  	public function current_user_has_permission( ?array $input = null ): bool {
  57      // phpcs:enable Generic.CodeAnalysis.UnusedFunctionParameter.Found
  58          return current_user_can( 'moderate_comments' );
  59      }
  60  }


Generated : Sat Jun 13 09:38:55 2026 Cross-referenced by PHPXref