beta-features
7 months ago
post-types
2 months ago
tools
7 months ago
views
1 week ago
admin-commands.php
2 months ago
admin-internal-post-type-list.php
10 months ago
admin-internal-post-type.php
1 year ago
admin-notices.php
1 year ago
admin-tools.php
10 months ago
admin-upgrade.php
1 year ago
admin.php
10 months ago
beta-features.php
7 months ago
class-acf-admin-options-page.php
2 months ago
index.php
1 year ago
admin-commands.php
46 lines
| 1 | <?php |
| 2 | /** |
| 3 | * SCF Commands Integration |
| 4 | * |
| 5 | * @package Secure Custom Fields |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly. |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Initializes SCF commands integration |
| 14 | * |
| 15 | * This function handles the integration with WordPress Commands (Cmd+K / Ctrl+K), |
| 16 | * providing navigation commands for SCF admin pages and custom post types. |
| 17 | * |
| 18 | * The implementation follows these principles: |
| 19 | * 1. Only loads in screens where WordPress commands are available. |
| 20 | * 2. Performs capability checks to ensure users only see commands they can access. |
| 21 | * 3. Core administrative commands are only shown to users with SCF admin capabilities. |
| 22 | * 4. Custom post type commands are conditionally shown based on edit_posts capability |
| 23 | * for each specific post type. |
| 24 | * 5. Post types must have UI enabled (show_ui setting) to appear in commands. |
| 25 | * |
| 26 | * @since SCF 6.5.0 |
| 27 | */ |
| 28 | function acf_commands_init() { |
| 29 | // Ensure we only load our commands where the WordPress commands API is available. |
| 30 | if ( ! wp_script_is( 'wp-commands', 'registered' ) ) { |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | $scf_post_types = acf_get_acf_post_types( array( 'active' => true ) ); |
| 35 | if ( ! empty( $scf_post_types ) ) { |
| 36 | wp_enqueue_script( 'scf-commands-custom-post-types' ); |
| 37 | } |
| 38 | |
| 39 | // Only load admin commands if user has SCF admin capabilities. |
| 40 | if ( current_user_can( acf_get_setting( 'capability' ) ) ) { |
| 41 | wp_enqueue_script( 'scf-commands-admin' ); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | add_action( 'admin_enqueue_scripts', 'acf_commands_init' ); |
| 46 |