PluginProbe
Advanced Custom Fields (ACF®) / 5.11.2
Advanced Custom Fields (ACF®) v5.11.2
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 in Advanced Custom Fields (ACF®) 5.11.2, at includes/admin/admin.php

210 lines 6.5 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' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 if ( ! class_exists( 'ACF_Admin' ) ) :
8
9 class ACF_Admin {
10
11 /**
12 * Constructor.
13 *
14 * @date 23/06/12
15 * @since 5.0.0
16 *
17 * @param void
18 * @return void
19 */
20 function __construct() {
21 // Add actions.
22 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
23 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
24 add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
25 add_action( 'current_screen', array( $this, 'current_screen' ) );
26 }
27
28 /**
29 * Adds the ACF menu item.
30 *
31 * @date 28/09/13
32 * @since 5.0.0
33 *
34 * @param void
35 * @return void
36 */
37 function admin_menu() {
38
39 // Bail early if ACF is hidden.
40 if ( ! acf_get_setting( 'show_admin' ) ) {
41 return;
42 }
43
44 // Vars.
45 $slug = 'edit.php?post_type=acf-field-group';
46 $cap = acf_get_setting( 'capability' );
47
48 // Add menu items.
49 add_menu_page( __( 'Custom Fields', 'acf' ), __( 'Custom Fields', 'acf' ), $cap, $slug, false, 'dashicons-welcome-widgets-menus', 80 );
50 add_submenu_page( $slug, __( 'Field Groups', 'acf' ), __( 'Field Groups', 'acf' ), $cap, $slug );
51 add_submenu_page( $slug, __( 'Add New', 'acf' ), __( 'Add New', 'acf' ), $cap, 'post-new.php?post_type=acf-field-group' );
52 }
53
54 /**
55 * Enqueues global admin styling.
56 *
57 * @date 28/09/13
58 * @since 5.0.0
59 *
60 * @param void
61 * @return void
62 */
63 function admin_enqueue_scripts() {
64 wp_enqueue_style( 'acf-global' );
65 }
66
67 /**
68 * Appends custom admin body classes.
69 *
70 * @date 5/11/19
71 * @since 5.8.7
72 *
73 * @param string $classes Space-separated list of CSS classes.
74 * @return string
75 */
76 function admin_body_class( $classes ) {
77 global $wp_version;
78
79 // Determine body class version.
80 $wp_minor_version = floatval( $wp_version );
81 if ( $wp_minor_version >= 5.3 ) {
82 $classes .= ' acf-admin-5-3';
83 } else {
84 $classes .= ' acf-admin-3-8';
85 }
86
87 // Add browser for specific CSS.
88 $classes .= ' acf-browser-' . acf_get_browser();
89
90 // Return classes.
91 return $classes;
92 }
93
94 /**
95 * Adds custom functionality to "ACF" admin pages.
96 *
97 * @date 7/4/20
98 * @since 5.9.0
99 *
100 * @param void
101 * @return void
102 */
103 function current_screen( $screen ) {
104
105 // Determine if the current page being viewed is "ACF" related.
106 if ( isset( $screen->post_type ) && $screen->post_type === 'acf-field-group' ) {
107 add_action( 'in_admin_header', array( $this, 'in_admin_header' ) );
108 add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
109 $this->setup_help_tab();
110 }
111 }
112
113 /**
114 * Sets up the admin help tab.
115 *
116 * @date 20/4/20
117 * @since 5.9.0
118 *
119 * @param void
120 * @return void
121 */
122 public function setup_help_tab() {
123 $screen = get_current_screen();
124
125 // Overview tab.
126 $screen->add_help_tab(
127 array(
128 'id' => 'overview',
129 'title' => __( 'Overview', 'acf' ),
130 'content' =>
131 '<p><strong>' . __( 'Overview', 'acf' ) . '</strong></p>' .
132 '<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>' .
133 '<p>' . sprintf(
134 __( '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' ),
135 'https://www.advancedcustomfields.com/resources/getting-started-with-acf/'
136 ) . '</p>' .
137 '<p>' . __( 'Please use the Help & Support tab to get in touch should you find yourself requiring assistance.', 'acf' ) . '</p>' .
138 '',
139 )
140 );
141
142 // Help tab.
143 $screen->add_help_tab(
144 array(
145 'id' => 'help',
146 'title' => __( 'Help & Support', 'acf' ),
147 'content' =>
148 '<p><strong>' . __( 'Help & Support', 'acf' ) . '</strong></p>' .
149 '<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>' .
150 '<ul>' .
151 '<li>' . sprintf(
152 __( '<a href="%s" target="_blank">Documentation</a>. Our extensive documentation contains references and guides for most situations you may encounter.', 'acf' ),
153 'https://www.advancedcustomfields.com/resources/'
154 ) . '</li>' .
155 '<li>' . sprintf(
156 __( '<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' ),
157 'https://support.advancedcustomfields.com/'
158 ) . '</li>' .
159 '<li>' . sprintf(
160 __( '<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' ),
161 'https://www.advancedcustomfields.com/support/'
162 ) . '</li>' .
163 '</ul>',
164 )
165 );
166
167 // Sidebar.
168 $screen->set_help_sidebar(
169 '<p><strong>' . __( 'Information', 'acf' ) . '</strong></p>' .
170 '<p><span class="dashicons dashicons-admin-plugins"></span> ' . sprintf( __( 'Version %s', 'acf' ), ACF_VERSION ) . '</p>' .
171 '<p><span class="dashicons dashicons-wordpress"></span> <a href="https://wordpress.org/plugins/advanced-custom-fields/" target="_blank">' . __( 'View details', 'acf' ) . '</a></p>' .
172 '<p><span class="dashicons dashicons-admin-home"></span> <a href="https://www.advancedcustomfields.com/" target="_blank" target="_blank">' . __( 'Visit website', 'acf' ) . '</a></p>' .
173 ''
174 );
175 }
176
177 /**
178 * Renders the admin navigation element.
179 *
180 * @date 27/3/20
181 * @since 5.9.0
182 *
183 * @param void
184 * @return void
185 */
186 function in_admin_header() {
187 acf_get_view( 'html-admin-navigation' );
188 }
189
190 /**
191 * Modifies the admin footer text.
192 *
193 * @date 7/4/20
194 * @since 5.9.0
195 *
196 * @param string $text The admin footer text.
197 * @return string
198 */
199 function admin_footer_text( $text ) {
200 // Use RegExp to append "ACF" after the <a> element allowing translations to read correctly.
201 return preg_replace( '/(<a[\S\s]+?\/a>)/', '$1 ' . __( 'and', 'acf' ) . ' <a href="https://www.advancedcustomfields.com" target="_blank">ACF</a>', $text, 1 );
202 }
203
204 }
205
206 // Instantiate.
207 acf_new_instance( 'ACF_Admin' );
208
209 endif; // class_exists check
210