| 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 |
* Initialize filters, action, variables and includes |
| 13 |
* |
| 14 |
* @type function |
| 15 |
* @date 23/06/12 |
| 16 |
* @since 5.0.0 |
| 17 |
* |
| 18 |
* @param n/a |
| 19 |
* @return n/a |
| 20 |
*/ |
| 21 |
|
| 22 |
function __construct() { |
| 23 |
|
| 24 |
// actions |
| 25 |
add_action('admin_menu', array($this, 'admin_menu')); |
| 26 |
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 0); |
| 27 |
} |
| 28 |
|
| 29 |
/* |
| 30 |
* admin_menu |
| 31 |
* |
| 32 |
* This function will add the ACF menu item to the WP admin |
| 33 |
* |
| 34 |
* @type action (admin_menu) |
| 35 |
* @date 28/09/13 |
| 36 |
* @since 5.0.0 |
| 37 |
* |
| 38 |
* @param n/a |
| 39 |
* @return n/a |
| 40 |
*/ |
| 41 |
|
| 42 |
function admin_menu() { |
| 43 |
|
| 44 |
// bail early if no show_admin |
| 45 |
if( !acf_get_setting('show_admin') ) return; |
| 46 |
|
| 47 |
|
| 48 |
// vars |
| 49 |
$slug = 'edit.php?post_type=acf-field-group'; |
| 50 |
$cap = acf_get_setting('capability'); |
| 51 |
|
| 52 |
|
| 53 |
// add parent |
| 54 |
add_menu_page(__("Custom Fields",'acf'), __("Custom Fields",'acf'), $cap, $slug, false, 'dashicons-welcome-widgets-menus', '80.025'); |
| 55 |
|
| 56 |
|
| 57 |
// add children |
| 58 |
add_submenu_page($slug, __('Field Groups','acf'), __('Field Groups','acf'), $cap, $slug ); |
| 59 |
add_submenu_page($slug, __('Add New','acf'), __('Add New','acf'), $cap, 'post-new.php?post_type=acf-field-group' ); |
| 60 |
|
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
/* |
| 65 |
* admin_enqueue_scripts |
| 66 |
* |
| 67 |
* This function will add the already registered css |
| 68 |
* |
| 69 |
* @type function |
| 70 |
* @date 28/09/13 |
| 71 |
* @since 5.0.0 |
| 72 |
* |
| 73 |
* @param n/a |
| 74 |
* @return n/a |
| 75 |
*/ |
| 76 |
|
| 77 |
function admin_enqueue_scripts() { |
| 78 |
|
| 79 |
wp_enqueue_style( 'acf-global' ); |
| 80 |
|
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
// initialize |
| 85 |
acf()->admin = new acf_admin(); |
| 86 |
|
| 87 |
endif; // class_exists check |
| 88 |
|
| 89 |
?> |