PHP code example of piotrpress / wordpress-abilities
1. Go to this page and download the library: Download piotrpress/wordpress-abilities library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
piotrpress / wordpress-abilities example snippets
use PiotrPress\WordPress\Ability;
use PiotrPress\WordPress\AbilityCategory;
use PiotrPress\WordPress\AbstractAbility;
#[ Ability(
name: 'example/ability',
label: 'Example Ability',
description: 'Example description',
category: new AbilityCategory(
slug: 'example-category',
label: 'Example Category',
description: 'Example description'
),
textdomain: 'example',
public: true
) ]
final class ExampleAbility extends AbstractAbility {
public function __invoke( array $input ) : mixed {...}
public function input() : array {...}
public function output() : array {...}
public function permission( array $input ) : bool|\WP_Error {...}
}
( new ExampleAbility() )->register();