PluginProbe
Advanced Custom Fields (ACF®) / 5.6.6
Advanced Custom Fields (ACF®) v5.6.6
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 / settings-addons.php
settings-addons.php
123 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class acf_settings_addons {
4
5 var $view;
6
7
8 /*
9 * __construct
10 *
11 * Initialize filters, action, variables and includes
12 *
13 * @type function
14 * @date 23/06/12
15 * @since 5.0.0
16 *
17 * @param n/a
18 * @return n/a
19 */
20
21 function __construct() {
22
23 // actions
24 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
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 // add page
51 $page = add_submenu_page('edit.php?post_type=acf-field-group', __('Add-ons','acf'), __('Add-ons','acf'), acf_get_setting('capability'),'acf-settings-addons', array($this,'html') );
52
53
54 // actions
55 add_action('load-' . $page, array($this,'load'));
56
57 }
58
59
60 /*
61 * load
62 *
63 * description
64 *
65 * @type function
66 * @date 7/01/2014
67 * @since 5.0.0
68 *
69 * @param $post_id (int)
70 * @return $post_id (int)
71 */
72
73 function load() {
74
75 // vars
76 $this->view = array(
77 'json' => array(),
78 );
79
80
81 // load json
82 $request = wp_remote_post( 'https://assets.advancedcustomfields.com/add-ons/add-ons.json' );
83
84 // validate
85 if( is_wp_error($request) || wp_remote_retrieve_response_code($request) != 200)
86 {
87 acf_add_admin_notice(__('<b>Error</b>. Could not load add-ons list', 'acf'), 'error');
88 }
89 else
90 {
91 $this->view['json'] = json_decode( $request['body'], true );
92 }
93
94 }
95
96
97 /*
98 * html
99 *
100 * description
101 *
102 * @type function
103 * @date 7/01/2014
104 * @since 5.0.0
105 *
106 * @param $post_id (int)
107 * @return $post_id (int)
108 */
109
110 function html() {
111
112 // load view
113 acf_get_view('settings-addons', $this->view);
114
115 }
116
117 }
118
119
120 // initialize
121 new acf_settings_addons();
122
123 ?>