Skip to content

Commit 4fb3b1f

Browse files
authored
Abilities API integration: add Post Type abilities (#225)
1 parent 440d7e1 commit 4fb3b1f

File tree

6 files changed

+689
-0
lines changed

6 files changed

+689
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* WordPress Abilities API integration for Secure Custom Fields.
4+
*
5+
* @package SCF
6+
* @since 6.6.0
7+
*/
8+
9+
if ( ! defined( 'ABSPATH' ) ) {
10+
exit;
11+
}
12+
13+
if ( ! class_exists( 'SCF_Abilities_Integration' ) ) {
14+
15+
/**
16+
* Handles integration with WordPress Abilities API.
17+
*
18+
* @since 6.6.0
19+
*/
20+
class SCF_Abilities_Integration {
21+
22+
/**
23+
* Constructor.
24+
*
25+
* @since 6.6.0
26+
*/
27+
public function __construct() {
28+
add_action( 'plugins_loaded', array( $this, 'init' ), 20 );
29+
}
30+
31+
/**
32+
* Initialize abilities integration if dependencies are available.
33+
*
34+
* @since 6.6.0
35+
*/
36+
public function init() {
37+
if ( ! $this->dependencies_available() ) {
38+
return;
39+
}
40+
41+
acf_include( 'includes/abilities/class-scf-post-type-abilities.php' );
42+
}
43+
44+
/**
45+
* Check if required dependencies are available.
46+
*
47+
* @since 6.6.0
48+
* @return bool True if dependencies are available.
49+
*/
50+
private function dependencies_available() {
51+
return function_exists( 'wp_register_ability' )
52+
&& function_exists( 'wp_register_ability_category' );
53+
}
54+
}
55+
56+
acf_new_instance( 'SCF_Abilities_Integration' );
57+
}

0 commit comments

Comments
 (0)