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 / third-party.php
third-party.php
214 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * ACF 3rd Party Compatibility Class
5 *
6 * All the logic for 3rd party functionality
7 *
8 * @class acf_third_party
9 * @package ACF
10 * @subpackage Core
11 */
12
13 if( ! class_exists('acf_third_party') ) :
14
15 class acf_third_party {
16
17
18 /*
19 * __construct
20 *
21 * This function will setup the class functionality
22 *
23 * @type function
24 * @date 5/03/2014
25 * @since 5.0.0
26 *
27 * @param n/a
28 * @return n/a
29 */
30
31 function __construct() {
32
33 // Tabify Edit Screen - http://wordpress.org/extend/plugins/tabify-edit-screen/
34 if( class_exists('Tabify_Edit_Screen') ) {
35 add_filter('tabify_posttypes', array($this, 'tabify_posttypes'));
36 add_action('tabify_add_meta_boxes', array($this, 'tabify_add_meta_boxes'));
37 }
38
39 // Post Type Switcher - http://wordpress.org/extend/plugins/post-type-switcher/
40 if( class_exists('Post_Type_Switcher') ) {
41 add_filter('pts_allowed_pages', array($this, 'pts_allowed_pages'));
42 }
43
44 // Event Espresso - https://wordpress.org/plugins/event-espresso-decaf/
45 if( function_exists('espresso_version') ) {
46 add_filter('acf/get_post_types', array($this, 'ee_get_post_types'), 10, 2);
47 }
48
49 // Dark Mode
50 if( class_exists('Dark_Mode') ) {
51 add_action('doing_dark_mode', array($this, 'doing_dark_mode'));
52 }
53 }
54
55
56 /**
57 * acf_get_post_types
58 *
59 * EE post types do not use the native post.php edit page, but instead render their own.
60 * Show the EE post types in lists where 'show_ui' is used.
61 *
62 * @date 24/2/18
63 * @since 5.6.9
64 *
65 * @param array $post_types
66 * @param array $args
67 * @return array
68 */
69
70 function ee_get_post_types( $post_types, $args ) {
71
72 if( !empty($args['show_ui']) ) {
73 $ee_post_types = get_post_types(array('show_ee_ui' => 1));
74 $ee_post_types = array_keys($ee_post_types);
75 $post_types = array_merge($post_types, $ee_post_types);
76 $post_types = array_unique($post_types);
77 }
78
79 // return
80 return $post_types;
81 }
82
83
84 /*
85 * tabify_posttypes
86 *
87 * This function removes ACF post types from the tabify edit screen (post type selection sidebar)
88 *
89 * @type function
90 * @date 9/10/12
91 * @since 3.5.1
92 *
93 * @param $post_id (int)
94 * @return $post_id (int)
95 */
96
97 function tabify_posttypes( $posttypes ) {
98
99 // unset
100 unset( $posttypes['acf-field-group'] );
101 unset( $posttypes['acf-field'] );
102
103
104 // return
105 return $posttypes;
106 }
107
108
109 /*
110 * tabify_add_meta_boxes
111 *
112 * This function creates dummy metaboxes on the tabify edit screen page
113 *
114 * @type function
115 * @date 9/10/12
116 * @since 3.5.1
117 *
118 * @param $post_type (string)
119 * @return n/a
120 */
121
122 function tabify_add_meta_boxes( $post_type ) {
123
124 // get field groups
125 $field_groups = acf_get_field_groups();
126
127
128 if( !empty($field_groups) ) {
129
130 foreach( $field_groups as $field_group ) {
131
132 // vars
133 $id = "acf-{$field_group['key']}";
134 $title = 'ACF: ' . $field_group['title'];
135
136
137
138 // add meta box
139 add_meta_box( $id, $title, '__return_true', $post_type );
140
141 }
142
143 }
144
145 }
146
147
148 /*
149 * pts_allowed_pages
150 *
151 * This filter will prevent PTS from running on the field group page!
152 *
153 * @type function
154 * @date 25/09/2014
155 * @since 5.0.0
156 *
157 * @param $pages (array)
158 * @return $pages
159 */
160
161 function pts_allowed_pages( $pages ) {
162
163 // vars
164 $post_type = '';
165
166
167 // check $_GET becuase it is too early to use functions / global vars
168 if( !empty($_GET['post_type']) ) {
169
170 $post_type = $_GET['post_type'];
171
172 } elseif( !empty($_GET['post']) ) {
173
174 $post_type = get_post_type( $_GET['post'] );
175
176 }
177
178
179 // check post type
180 if( $post_type == 'acf-field-group' ) {
181
182 $pages = array();
183
184 }
185
186
187 // return
188 return $pages;
189
190 }
191
192 /**
193 * doing_dark_mode
194 *
195 * Runs during 'admin_enqueue_scripts' if dark mode is enabled
196 *
197 * @date 13/8/18
198 * @since 5.7.3
199 *
200 * @param void
201 * @return void
202 */
203
204 function doing_dark_mode() {
205 wp_enqueue_style('acf-dark', acf_get_url('assets/css/acf-dark.css'), array(), ACF_VERSION );
206 }
207
208 }
209
210 new acf_third_party();
211
212 endif;
213
214 ?>