forked from codepress/admin-columns-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacp-quick_add-enable.php
34 lines (28 loc) · 911 Bytes
/
acp-quick_add-enable.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* This hooks allows you to enable Quick Add for a specific List Screen in the Hide on Screen Settings
*/
/**
* @param bool $enabled
* @param AC\ListScreen $list_screen
*
* @return bool
*/
function acp_quick_add_enable( $enabled, AC\ListScreen $list_screen ) {
return $enabled;
}
add_filter( 'acp/quick_add/enable', 'acp_quick_add_enable', 10, 2 );
// Anonymous function
add_filter( 'acp/quick_add/enable', function ( $enabled, AC\ListScreen $list_screen ) {
return $enabled;
}, 10, 2 );
/*
* Example hook that enabled quick always for specific post types
*/
add_filter( 'acp/quick_add/enable', function ( $enabled, AC\ListScreen $list_screen ) {
$enabled_post_types = [ 'post', 'page', 'custom_post_type' ];
if ( $list_screen instanceof AC\ListScreen\Post && in_array( $list_screen->get_post_type(), $enabled_post_types ) ) {
return true;
}
return $enabled;
}, 10, 2 );