PluginProbe
Advanced Custom Fields (ACF®) / 5.9.0
Advanced Custom Fields (ACF®) v5.9.0
6.8.9 6.8.8 6.8.7 6.8.6 6.8.5 6.8.4 6.8.3 6.8.2 6.8.1 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 All 230 releases
advanced-custom-fields / includes / admin / admin.php
admin.php
208 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5 if( ! class_exists('ACF_Admin') ) :
6
7 class ACF_Admin {
8
9 /**
10 * Constructor.
11 *
12 * @date 23/06/12
13 * @since 5.0.0
14 *
15 * @param void
16 * @return void
17 */
18 function __construct() {
19
20 // Add actions.
21 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
22 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
23 add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
24 add_action( 'current_screen', array( $this, 'current_screen' ) );
25 }
26
27 /**
28 * Adds the ACF menu item.
29 *
30 * @date 28/09/13
31 * @since 5.0.0
32 *
33 * @param void
34 * @return void
35 */
36 function admin_menu() {
37
38 // Bail early if ACF is hidden.
39 if( !acf_get_setting('show_admin') ) {
40 return;
41 }
42
43 // Vars.
44 $slug = 'edit.php?post_type=acf-field-group';
45 $cap = acf_get_setting('capability');
46
47 // Add menu items.
48 add_menu_page( __("Custom Fields",'acf'), __("Custom Fields",'acf'), $cap, $slug, false, 'dashicons-welcome-widgets-menus', '80.025' );
49 add_submenu_page( $slug, __('Field Groups','acf'), __('Field Groups','acf'), $cap, $slug );
50 add_submenu_page( $slug, __('Add New','acf'), __('Add New','acf'), $cap, 'post-new.php?post_type=acf-field-group' );
51 }
52
53 /**
54 * Enqueues global admin styling.
55 *
56 * @date 28/09/13
57 * @since 5.0.0
58 *
59 * @param void
60 * @return void
61 */
62 function admin_enqueue_scripts() {
63 wp_enqueue_style( 'acf-global' );
64 }
65
66 /**
67 * Appends custom admin body classes.
68 *
69 * @date 5/11/19
70 * @since 5.8.7
71 *
72 * @param string $classes Space-separated list of CSS classes.
73 * @return string
74 */
75 function admin_body_class( $classes ) {
76 global $wp_version;
77
78 // Determine body class version.
79 $wp_minor_version = floatval( $wp_version );
80 if( $wp_minor_version >= 5.3 ) {
81 $classes .= ' acf-admin-5-3';
82 } else {
83 $classes .= ' acf-admin-3-8';
84 }
85
86 // Add browser for specific CSS.
87 $classes .= ' acf-browser-' . acf_get_browser();
88
89 // Return classes.
90 return $classes;
91 }
92
93 /**
94 * Adds custom functionality to "ACF" admin pages.
95 *
96 * @date 7/4/20
97 * @since 5.9.0
98 *
99 * @param void
100 * @return void
101 */
102 function current_screen( $screen ) {
103
104 // Determine if the current page being viewed is "ACF" related.
105 if( isset( $screen->post_type ) && $screen->post_type === 'acf-field-group' ) {
106 add_action( 'in_admin_header', array( $this, 'in_admin_header' ) );
107 add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
108 $this->setup_help_tab();
109 }
110 }
111
112 /**
113 * Sets up the admin help tab.
114 *
115 * @date 20/4/20
116 * @since 5.9.0
117 *
118 * @param void
119 * @return void
120 */
121 public function setup_help_tab() {
122 $screen = get_current_screen();
123
124 // Overview tab.
125 $screen->add_help_tab(
126 array(
127 'id' => 'overview',
128 'title' => __( 'Overview', 'acf' ),
129 'content' =>
130 '<p><strong>' . __( 'Overview', 'acf' ) . '</strong></p>' .
131 '<p>' . __( 'The Advanced Custom Fields plugin provides a visual form builder to customize WordPress edit screens with extra fields, and an intuitive API to display custom field values in any theme template file.', 'acf' ) . '</p>' .
132 '<p>' . sprintf(
133 __( 'Before creating your first Field Group, we recommend first reading our <a href="%s" target="_blank">Getting started</a> guide to familiarize yourself with the plugin\'s philosophy and best practises.', 'acf' ),
134 'https://www.advancedcustomfields.com/resources/getting-started-with-acf/'
135 ) . '</p>' .
136 '<p>' . __( 'Please use the Help & Support tab to get in touch should you find yourself requiring assistance.', 'acf' ) . '</p>' .
137 ''
138 )
139 );
140
141 // Help tab.
142 $screen->add_help_tab(
143 array(
144 'id' => 'help',
145 'title' => __( 'Help & Support', 'acf' ),
146 'content' =>
147 '<p><strong>' . __( 'Help & Support', 'acf' ) . '</strong></p>' .
148 '<p>' . __( 'We are fanatical about support, and want you to get the best out of your website with ACF. If you run into any difficulties, there are several places you can find help:', 'acf' ) . '</p>' .
149 '<ul>' .
150 '<li>' . sprintf(
151 __( '<a href="%s" target="_blank">Documentation</a>. Our extensive documentation contains references and guides for most situations you may encounter.', 'acf' ),
152 'https://www.advancedcustomfields.com/resources/'
153 ) . '</li>' .
154 '<li>' . sprintf(
155 __( '<a href="%s" target="_blank">Discussions</a>. We have an active and friendly community on our Community Forums who may be able to help you figure out the ‘how-tos’ of the ACF world.', 'acf' ),
156 'https://support.advancedcustomfields.com/'
157 ) . '</li>' .
158 '<li>' . sprintf(
159 __( '<a href="%s" target="_blank">Help Desk</a>. The support professionals on our Help Desk will assist with your more in depth, technical challenges.', 'acf' ),
160 'https://www.advancedcustomfields.com/support/'
161 ) . '</li>' .
162 '</ul>'
163 )
164 );
165
166 // Sidebar.
167 $screen->set_help_sidebar(
168 '<p><strong>' . __( 'Information', 'acf' ) . '</strong></p>' .
169 '<p><span class="dashicons dashicons-admin-plugins"></span> ' . sprintf( __( 'Version %s', 'acf' ), ACF_VERSION ) . '</p>' .
170 '<p><span class="dashicons dashicons-wordpress"></span> <a href="https://wordpress.org/plugins/advanced-custom-fields/" target="_blank">' . __( 'View details', 'acf' ) . '</a></p>' .
171 '<p><span class="dashicons dashicons-admin-home"></span> <a href="https://www.advancedcustomfields.com/" target="_blank" target="_blank">' . __( 'Visit website', 'acf' ) . '</a></p>' .
172 ''
173 );
174 }
175
176 /**
177 * Renders the admin navigation element.
178 *
179 * @date 27/3/20
180 * @since 5.9.0
181 *
182 * @param void
183 * @return void
184 */
185 function in_admin_header() {
186 acf_get_view( 'html-admin-navigation' );
187 }
188
189 /**
190 * Modifies the admin footer text.
191 *
192 * @date 7/4/20
193 * @since 5.9.0
194 *
195 * @param string $text The admin footer text.
196 * @return string
197 */
198 function admin_footer_text( $text ) {
199 // Use RegExp to append "ACF" after the <a> element allowing translations to read correctly.
200 return preg_replace( '/(<a[\S\s]+?\/a>)/', '$1 ' . __('and', 'acf') . ' <a href="https://www.advancedcustomfields.com" target="_blank">ACF</a>', $text, 1 );
201 }
202 }
203
204 // Instantiate.
205 acf_new_instance('ACF_Admin');
206
207 endif; // class_exists check
208