1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class acf_admin { |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* __construct |
7
|
|
|
* |
8
|
|
|
* Initialize filters, action, variables and includes |
9
|
|
|
* |
10
|
|
|
* @type function |
11
|
|
|
* @date 23/06/12 |
12
|
|
|
* @since 5.0.0 |
13
|
|
|
* |
14
|
|
|
* @param n/a |
15
|
|
|
* @return n/a |
16
|
|
|
*/ |
|
|
|
|
17
|
|
|
|
18
|
|
|
function __construct() { |
|
|
|
|
19
|
|
|
|
20
|
|
|
// actions |
21
|
|
|
add_action('admin_menu', array($this, 'admin_menu')); |
22
|
|
|
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 0); |
23
|
|
|
add_action('admin_notices', array($this, 'admin_notices')); |
24
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
/* |
29
|
|
|
* admin_menu |
30
|
|
|
* |
31
|
|
|
* This function will add the ACF menu item to the WP admin |
32
|
|
|
* |
33
|
|
|
* @type action (admin_menu) |
34
|
|
|
* @date 28/09/13 |
35
|
|
|
* @since 5.0.0 |
36
|
|
|
* |
37
|
|
|
* @param n/a |
38
|
|
|
* @return n/a |
39
|
|
|
*/ |
|
|
|
|
40
|
|
|
|
41
|
|
|
function admin_menu() { |
|
|
|
|
42
|
|
|
|
43
|
|
|
// bail early if no show_admin |
44
|
|
|
if( !acf_get_setting('show_admin') ) { |
45
|
|
|
|
46
|
|
|
return; |
47
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
// vars |
52
|
|
|
$slug = 'edit.php?post_type=acf-field-group'; |
53
|
|
|
$cap = acf_get_setting('capability'); |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
// add parent |
57
|
|
|
add_menu_page(__("Custom Fields",'acf'), __("Custom Fields",'acf'), $cap, $slug, false, 'dashicons-welcome-widgets-menus', '80.025'); |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
// add children |
61
|
|
|
add_submenu_page($slug, __('Field Groups','acf'), __('Field Groups','acf'), $cap, $slug ); |
62
|
|
|
add_submenu_page($slug, __('Add New','acf'), __('Add New','acf'), $cap, 'post-new.php?post_type=acf-field-group' ); |
63
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/* |
68
|
|
|
* admin_enqueue_scripts |
69
|
|
|
* |
70
|
|
|
* This function will add the already registered css |
71
|
|
|
* |
72
|
|
|
* @type function |
73
|
|
|
* @date 28/09/13 |
74
|
|
|
* @since 5.0.0 |
75
|
|
|
* |
76
|
|
|
* @param n/a |
77
|
|
|
* @return n/a |
78
|
|
|
*/ |
|
|
|
|
79
|
|
|
|
80
|
|
|
function admin_enqueue_scripts() { |
|
|
|
|
81
|
|
|
|
82
|
|
|
wp_enqueue_style( 'acf-global' ); |
83
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
/* |
88
|
|
|
* admin_notices |
89
|
|
|
* |
90
|
|
|
* This function will render any admin notices |
91
|
|
|
* |
92
|
|
|
* @type function |
93
|
|
|
* @date 17/10/13 |
94
|
|
|
* @since 5.0.0 |
95
|
|
|
* |
96
|
|
|
* @param n/a |
97
|
|
|
* @return n/a |
98
|
|
|
*/ |
|
|
|
|
99
|
|
|
|
100
|
|
|
function admin_notices() { |
|
|
|
|
101
|
|
|
|
102
|
|
|
// vars |
103
|
|
|
$admin_notices = acf_get_admin_notices(); |
104
|
|
|
|
105
|
|
|
|
106
|
|
|
// bail early if no notices |
107
|
|
|
if( empty($admin_notices) ) { |
108
|
|
|
|
109
|
|
|
return; |
110
|
|
|
|
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
|
114
|
|
|
foreach( $admin_notices as $notice ) { |
115
|
|
|
|
116
|
|
|
$open = ''; |
117
|
|
|
$close = ''; |
118
|
|
|
|
119
|
|
|
if( $notice['wrap'] ) { |
120
|
|
|
|
121
|
|
|
$open = "<{$notice['wrap']}>"; |
122
|
|
|
$close = "</{$notice['wrap']}>"; |
123
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
?> |
127
|
|
|
<div class="notice is-dismissible <?php echo $notice['class']; ?>"><?php echo $open . $notice['text'] . $close; ?></div> |
128
|
|
|
<?php |
129
|
|
|
|
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
// initialize |
138
|
|
|
new acf_admin(); |
139
|
|
|
|
140
|
|
|
?> |
141
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.