77 *
88 */
99class BEA_CSF_Addon_ACF_Exclusion {
10- static $ acf_fields = array () ;
11- static $ meta_data = array () ;
10+ static $ acf_fields = [] ;
11+ static $ meta_data = [] ;
1212
1313 /**
1414 * BEA_CSF_Addon_ACF_Exclusion constructor.
@@ -21,23 +21,23 @@ public function __construct() {
2121 // Fields
2222 if ( apply_filters ( 'bea/csf/acf-addon-exclusion/allow-fieds-exclusion ' , false ) !== false ) {
2323
24- add_action ( 'save_post ' , array ( __CLASS__ , 'save_post_fields ' ) , 10 , 1 );
25- add_action ( 'acf/include_field_types ' , array ( __CLASS__ , 'acf_include_field_types ' ) , 9999999 );
26- add_filter ( 'bea_csf_client_ ' . 'Attachment ' . '_ ' . 'merge ' . '_data_to_transfer ' , array ( __CLASS__ , 'filter_acf_fields ' ) , 11 , 3 );
27- add_filter ( 'bea_csf_client_ ' . 'PostType ' . '_ ' . 'merge ' . '_data_to_transfer ' , array ( __CLASS__ , 'filter_acf_fields ' ) , 11 , 3 );
24+ add_action ( 'save_post ' , [ __CLASS__ , 'save_post_fields ' ] , 10 , 1 );
25+ add_action ( 'acf/include_field_types ' , [ __CLASS__ , 'acf_include_field_types ' ] , 9999999 );
26+ add_filter ( 'bea_csf_client_ ' . 'Attachment ' . '_ ' . 'merge ' . '_data_to_transfer ' , [ __CLASS__ , 'filter_acf_fields ' ] , 11 , 3 );
27+ add_filter ( 'bea_csf_client_ ' . 'PostType ' . '_ ' . 'merge ' . '_data_to_transfer ' , [ __CLASS__ , 'filter_acf_fields ' ] , 11 , 3 );
2828
2929 }
3030
3131 // Groups
32- add_action ( 'save_post ' , array ( __CLASS__ , 'save_post_groups ' ) , 10 , 1 );
33- add_filter ( 'bea_csf_client_ ' . 'Attachment ' . '_ ' . 'merge ' . '_data_to_transfer ' , array ( __CLASS__ , 'filter_acf_groups ' ) , 10 , 3 );
34- add_filter ( 'bea_csf_client_ ' . 'PostType ' . '_ ' . 'merge ' . '_data_to_transfer ' , array ( __CLASS__ , 'filter_acf_groups ' ) , 10 , 3 );
35- add_action ( 'post_edit_form_tag ' , array ( __CLASS__ , 'post_edit_form_tag ' ) , 1 );
32+ add_action ( 'save_post ' , [ __CLASS__ , 'save_post_groups ' ] , 10 , 1 );
33+ add_filter ( 'bea_csf_client_ ' . 'Attachment ' . '_ ' . 'merge ' . '_data_to_transfer ' , [ __CLASS__ , 'filter_acf_groups ' ] , 10 , 3 );
34+ add_filter ( 'bea_csf_client_ ' . 'PostType ' . '_ ' . 'merge ' . '_data_to_transfer ' , [ __CLASS__ , 'filter_acf_groups ' ] , 10 , 3 );
35+ add_action ( 'post_edit_form_tag ' , [ __CLASS__ , 'post_edit_form_tag ' ] , 1 );
3636
3737 // Flexible
38- add_action ( 'save_post ' , array ( __CLASS__ , 'save_post_flexibles ' ) , 10 , 1 );
39- add_filter ( 'bea_csf_client_ ' . 'Attachment ' . '_ ' . 'merge ' . '_data_to_transfer ' , array ( __CLASS__ , 'filter_acf_flexibles ' ) , 10 , 3 );
40- add_filter ( 'bea_csf_client_ ' . 'PostType ' . '_ ' . 'merge ' . '_data_to_transfer ' , array ( __CLASS__ , 'filter_acf_flexibles ' ) , 10 , 3 );
38+ add_action ( 'save_post ' , [ __CLASS__ , 'save_post_flexibles ' ] , 10 , 1 );
39+ add_filter ( 'bea_csf_client_ ' . 'Attachment ' . '_ ' . 'merge ' . '_data_to_transfer ' , [ __CLASS__ , 'filter_acf_flexibles ' ] , 10 , 3 );
40+ add_filter ( 'bea_csf_client_ ' . 'PostType ' . '_ ' . 'merge ' . '_data_to_transfer ' , [ __CLASS__ , 'filter_acf_flexibles ' ] , 10 , 3 );
4141
4242 return true ;
4343 }
@@ -119,8 +119,8 @@ public static function save_post_flexibles( $post_id ) {
119119 public static function acf_include_field_types () {
120120 foreach ( acf_get_field_types () as $ sections => $ fields ) {
121121 foreach ( $ fields as $ field_type => $ field_label ) {
122- add_action ( 'acf/render_field/type= ' . $ field_type , array ( __CLASS__ , 'acf_render_field_before ' ) , 8 , 1 );
123- add_action ( 'acf/render_field/type= ' . $ field_type , array ( __CLASS__ , 'acf_render_field_after ' ) , 10 , 1 );
122+ add_action ( 'acf/render_field/type= ' . $ field_type , [ __CLASS__ , 'acf_render_field_before ' ] , 8 , 1 );
123+ add_action ( 'acf/render_field/type= ' . $ field_type , [ __CLASS__ , 'acf_render_field_after ' ] , 10 , 1 );
124124 }
125125 }
126126 }
@@ -135,7 +135,7 @@ public static function acf_render_field_before( $field ) {
135135 return false ;
136136 }
137137
138- if ( in_array ( $ field ['type ' ], array ( 'flexible_content ' , 'repeater ' ) ) ) {
138+ if ( in_array ( $ field ['type ' ], [ 'flexible_content ' , 'repeater ' ] ) ) {
139139 self ::build_html_checkbox ( $ field , __ ( 'Exclude this group from future synchro ' , 'bea-content-sync-fusion ' ) );
140140 }
141141
@@ -152,7 +152,7 @@ public static function acf_render_field_after( $field ) {
152152 return false ;
153153 }
154154
155- if ( ! in_array ( $ field ['type ' ], array ( 'flexible_content ' , 'repeater ' ) ) ) {
155+ if ( ! in_array ( $ field ['type ' ], [ 'flexible_content ' , 'repeater ' ] ) ) {
156156 self ::build_html_checkbox ( $ field , __ ( 'Exclude this field from future synchro ' , 'bea-content-sync-fusion ' ) );
157157 }
158158
@@ -214,7 +214,7 @@ public static function filter_acf_groups( $data, $sync_receiver_blog_id, $sync_f
214214 return $ data ;
215215 }
216216
217- $ fields = array () ;
217+ $ fields = [] ;
218218 foreach ( $ groups as $ group ) {
219219 if ( ! in_array ( $ group ['key ' ], $ current_excluded_groups ) ) {
220220 continue ;
@@ -231,7 +231,7 @@ public static function filter_acf_groups( $data, $sync_receiver_blog_id, $sync_f
231231 }
232232
233233 // Get only fields
234- self ::$ acf_fields = array () ;
234+ self ::$ acf_fields = [] ;
235235 self ::prepare_acf_fields ( $ fields );
236236
237237 // Loop on each meta
@@ -303,11 +303,11 @@ public static function prepare_acf_fields( $fields ) {
303303 foreach ( (array ) $ fields as $ field ) {
304304 self ::$ acf_fields [ $ field ['key ' ] ] = $ field ;
305305
306- if ( in_array ( $ field ['type ' ], array ( 'flexible_content ' ) ) ) { // Flexible is recursive structure with layouts
306+ if ( in_array ( $ field ['type ' ], [ 'flexible_content ' ] ) ) { // Flexible is recursive structure with layouts
307307 foreach ( $ field ['layouts ' ] as $ layout_field ) {
308308 self ::prepare_acf_fields ( $ layout_field ['sub_fields ' ] );
309309 }
310- } elseif ( in_array ( $ field ['type ' ], array ( 'repeater ' ) ) ) { // Repeater is recursive structure
310+ } elseif ( in_array ( $ field ['type ' ], [ 'repeater ' ] ) ) { // Repeater is recursive structure
311311 self ::prepare_acf_fields ( $ field ['sub_fields ' ] );
312312 }
313313 }
@@ -347,7 +347,7 @@ public static function filter_acf_fields( $data, $sync_receiver_blog_id, $sync_f
347347
348348 // Delete all metadata from flexible/repeater
349349 $ acf_field = acf_maybe_get_field ( $ raw_meta_value [0 ] );
350- if ( $ acf_field != false && in_array ( $ acf_field ['type ' ], array ( 'flexible_content ' , 'repeater ' ) ) ) {
350+ if ( $ acf_field != false && in_array ( $ acf_field ['type ' ], [ 'flexible_content ' , 'repeater ' ] ) ) {
351351 foreach ( (array ) $ data ['meta_data ' ] as $ sub_meta_key => $ sub_meta_value ) {
352352 if ( ! preg_match ( '/ ' . preg_quote ( $ acf_field ['name ' ] ) . '[\_]\d*[\_]/ ' , $ sub_meta_key ) !== false ) {
353353 continue ;
@@ -373,7 +373,7 @@ public static function filter_acf_fields( $data, $sync_receiver_blog_id, $sync_f
373373 if ( $ meta_key == $ translated_acf_name ) {
374374 // Delete all metadata from flexible/repeater
375375 $ acf_field = acf_maybe_get_field ( $ matches [1 ][0 ] );
376- if ( $ acf_field != false && in_array ( $ acf_field ['type ' ], array ( 'flexible_content ' , 'repeater ' ) ) ) {
376+ if ( $ acf_field != false && in_array ( $ acf_field ['type ' ], [ 'flexible_content ' , 'repeater ' ] ) ) {
377377 foreach ( (array ) $ data ['meta_data ' ] as $ sub_meta_key => $ sub_meta_value ) {
378378 if ( ! preg_match ( '/ ' . preg_quote ( $ acf_field ['name ' ] ) . '[\_]\d*[\_]/ ' , $ sub_meta_key ) !== false ) {
379379 continue ;
0 commit comments