PluginProbe
Advanced Custom Fields (ACF®) / 6.0.0
Advanced Custom Fields (ACF®) v6.0.0
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
207 lines 4.1 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 // return
104 return $posttypes;
105 }
106
107
108 /*
109 * tabify_add_meta_boxes
110 *
111 * This function creates dummy metaboxes on the tabify edit screen page
112 *
113 * @type function
114 * @date 9/10/12
115 * @since 3.5.1
116 *
117 * @param $post_type (string)
118 * @return n/a
119 */
120
121 function tabify_add_meta_boxes( $post_type ) {
122
123 // get field groups
124 $field_groups = acf_get_field_groups();
125
126 if ( ! empty( $field_groups ) ) {
127
128 foreach ( $field_groups as $field_group ) {
129
130 // vars
131 $id = "acf-{$field_group['key']}";
132 $title = 'ACF: ' . $field_group['title'];
133
134 // add meta box
135 add_meta_box( $id, acf_esc_html( $title ), '__return_true', $post_type );
136
137 }
138 }
139
140 }
141
142
143 /*
144 * pts_allowed_pages
145 *
146 * This filter will prevent PTS from running on the field group page!
147 *
148 * @type function
149 * @date 25/09/2014
150 * @since 5.0.0
151 *
152 * @param $pages (array)
153 * @return $pages
154 */
155
156 function pts_allowed_pages( $pages ) {
157
158 // vars
159 $post_type = '';
160
161 // check $_GET becuase it is too early to use functions / global vars
162 if ( ! empty( $_GET['post_type'] ) ) {
163
164 $post_type = $_GET['post_type'];
165
166 } elseif ( ! empty( $_GET['post'] ) ) {
167
168 $post_type = get_post_type( $_GET['post'] );
169
170 }
171
172 // check post type
173 if ( $post_type == 'acf-field-group' ) {
174
175 $pages = array();
176
177 }
178
179 // return
180 return $pages;
181
182 }
183
184 /**
185 * doing_dark_mode
186 *
187 * Runs during 'admin_enqueue_scripts' if dark mode is enabled
188 *
189 * @date 13/8/18
190 * @since 5.7.3
191 *
192 * @param void
193 * @return void
194 */
195
196 function doing_dark_mode() {
197 wp_enqueue_style( 'acf-dark', acf_get_url( 'assets/css/acf-dark.css' ), array(), ACF_VERSION );
198 }
199
200 }
201
202 new acf_third_party();
203
204 endif;
205
206
207