PluginProbe
Advanced Custom Fields (ACF®) / 5.8.9
Advanced Custom Fields (ACF®) v5.8.9
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
142 lines 3.0 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 * __construct
11 *
12 * Sets up the class functionality.
13 *
14 * @date 23/06/12
15 * @since 5.0.0
16 *
17 * @param void
18 * @return void
19 */
20 function __construct() {
21
22 // Add hooks.
23 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
24 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
25 add_action( 'admin_body_class', array( $this, 'admin_body_class' ) );
26 }
27
28 /**
29 * admin_menu
30 *
31 * Adds the ACF menu item.
32 *
33 * @date 28/09/13
34 * @since 5.0.0
35 *
36 * @param void
37 * @return void
38 */
39 function admin_menu() {
40
41 // Bail early if ACF is hidden.
42 if( !acf_get_setting('show_admin') ) {
43 return;
44 }
45
46 // Vars.
47 $slug = 'edit.php?post_type=acf-field-group';
48 $cap = acf_get_setting('capability');
49
50 // Add menu items.
51 add_menu_page( __("Custom Fields",'acf'), __("Custom Fields",'acf'), $cap, $slug, false, 'dashicons-welcome-widgets-menus', '80.025' );
52 add_submenu_page( $slug, __('Field Groups','acf'), __('Field Groups','acf'), $cap, $slug );
53 add_submenu_page( $slug, __('Add New','acf'), __('Add New','acf'), $cap, 'post-new.php?post_type=acf-field-group' );
54
55 // Only register info page when needed.
56 if( isset($_GET['page']) && $_GET['page'] === 'acf-settings-info' ) {
57 add_submenu_page( $slug, __('Info','acf'), __('Info','acf'), $cap,'acf-settings-info', array($this,'info_page_html') );
58 }
59 }
60
61 /**
62 * admin_enqueue_scripts
63 *
64 * Enqueues global admin styling.
65 *
66 * @date 28/09/13
67 * @since 5.0.0
68 *
69 * @param void
70 * @return void
71 */
72 function admin_enqueue_scripts() {
73
74 // Enqueue global style. To-do: Change to admin.
75 wp_enqueue_style( 'acf-global' );
76 }
77
78 /**
79 * admin_body_class
80 *
81 * Appends the determined body_class.
82 *
83 * @date 5/11/19
84 * @since 5.8.7
85 *
86 * @param string $classes Space-separated list of CSS classes.
87 * @return string
88 */
89 function admin_body_class( $classes ) {
90 global $wp_version;
91
92 // Determine body class version.
93 $wp_minor_version = floatval( $wp_version );
94 if( $wp_minor_version >= 5.3 ) {
95 $body_class = 'acf-admin-5-3';
96 } else {
97 $body_class = 'acf-admin-3-8';
98 }
99
100 // Append and return.
101 return $classes . ' ' . $body_class;
102 }
103
104 /**
105 * info_page_html
106 *
107 * Renders the Info page HTML.
108 *
109 * @date 5/11/19
110 * @since 5.8.7
111 *
112 * @param void
113 * @return void
114 */
115 function info_page_html() {
116
117 // Vars.
118 $view = array(
119 'version' => acf_get_setting('version'),
120 'have_pro' => acf_get_setting('pro'),
121 'tabs' => array(
122 'new' => __("What's New", 'acf'),
123 'changelog' => __("Changelog", 'acf')
124 ),
125 'active' => 'new'
126 );
127
128 // Find active tab.
129 if( isset($_GET['tab']) && $_GET['tab'] === 'changelog' ) {
130 $view['active'] = 'changelog';
131 }
132
133 // Load view.
134 acf_get_view('settings-info', $view);
135 }
136 }
137
138 // Instantiate.
139 acf_new_instance('ACF_Admin');
140
141 endif; // class_exists check
142