Skip to content

Commit c870b2e

Browse files
committed
apply cbf format
1 parent e777e7e commit c870b2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1654
-1324
lines changed

classes/addons/advanced-custom-fields-exclusion.php

+72-68
Large diffs are not rendered by default.

classes/addons/advanced-custom-fields.php

+24-24
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class BEA_CSF_Addon_ACF {
1111
* BEA_CSF_Addon_ACF constructor.
1212
*/
1313
public function __construct() {
14-
if ( ! class_exists('acf') ) {
14+
if ( ! class_exists( 'acf' ) ) {
1515
return false;
1616
}
1717

@@ -47,7 +47,7 @@ public static function bea_csf_client_posttype_merge( $data, $sync_fields, $new_
4747
$fields = array();
4848
foreach ( $groups as $group ) {
4949
$_fields = (array) acf_get_fields( $group );
50-
foreach ($_fields as $_field ) {
50+
foreach ( $_fields as $_field ) {
5151
$fields[] = $_field;
5252
}
5353
}
@@ -62,7 +62,7 @@ public static function bea_csf_client_posttype_merge( $data, $sync_fields, $new_
6262

6363
// Translate
6464
$meta_data_to_update = self::translate_dynamic_acf_fields( $data['meta_data'], $data, $sync_fields );
65-
if ( is_array($meta_data_to_update) && !empty($meta_data_to_update) ) {
65+
if ( is_array( $meta_data_to_update ) && ! empty( $meta_data_to_update ) ) {
6666
foreach ( $meta_data_to_update as $meta_data_to_update_key => $meta_data_to_update_value ) {
6767
update_post_meta( $new_post->ID, $meta_data_to_update_key, $meta_data_to_update_value );
6868
}
@@ -95,7 +95,7 @@ public static function bea_csf_client_taxonomy_merge( $data, $sync_fields, $new_
9595
$fields = array();
9696
foreach ( $groups as $group ) {
9797
$_fields = (array) acf_get_fields( $group );
98-
foreach ($_fields as $_field ) {
98+
foreach ( $_fields as $_field ) {
9999
$fields[] = $_field;
100100
}
101101
}
@@ -110,7 +110,7 @@ public static function bea_csf_client_taxonomy_merge( $data, $sync_fields, $new_
110110

111111
// Translate
112112
$meta_data_to_update = self::translate_dynamic_acf_fields( $data['meta_data'], $data, $sync_fields );
113-
if ( is_array($meta_data_to_update) && !empty($meta_data_to_update) ) {
113+
if ( is_array( $meta_data_to_update ) && ! empty( $meta_data_to_update ) ) {
114114
foreach ( $meta_data_to_update as $meta_data_to_update_key => $meta_data_to_update_value ) {
115115
update_term_meta( $new_term->term_id, $meta_data_to_update_key, $meta_data_to_update_value );
116116
}
@@ -139,57 +139,57 @@ public static function translate_dynamic_acf_fields( $meta_data, $data, $sync_fi
139139
}
140140

141141
// Keep only metadata with ID database reference
142-
if ( !isset(self::$acf_fields[$values[0]]) ) {
142+
if ( ! isset( self::$acf_fields[ $values[0] ] ) ) {
143143
continue;
144144
}
145145

146146
// Get ACF field data
147-
$acf_field = self::$acf_fields[$values[0]];
147+
$acf_field = self::$acf_fields[ $values[0] ];
148148

149149
// Build meta_key to metadata to translate
150-
$meta_key_to_translate = substr($key, 1) ;
150+
$meta_key_to_translate = substr( $key, 1 );
151151

152152
// Get data to translate
153-
$meta_value_to_translate = maybe_unserialize($meta_data[$meta_key_to_translate][0]);
153+
$meta_value_to_translate = maybe_unserialize( $meta_data[ $meta_key_to_translate ][0] );
154154

155155
$types = false;
156-
if ( in_array($acf_field['type'], array('image', 'post_object', 'file', 'page_link', 'gallery', 'relationship')) ) {
157-
$types = array('attachment', 'posttype');
158-
} elseif ( in_array($acf_field['type'], array('taxonomy')) ) {
159-
$types = array('taxonomy');
156+
if ( in_array( $acf_field['type'], array( 'image', 'post_object', 'file', 'page_link', 'gallery', 'relationship' ) ) ) {
157+
$types = array( 'attachment', 'posttype' );
158+
} elseif ( in_array( $acf_field['type'], array( 'taxonomy' ) ) ) {
159+
$types = array( 'taxonomy' );
160160
}
161161

162162
// Array or singular value ?
163-
if ( is_array($meta_value_to_translate) ) {
164-
foreach( $meta_value_to_translate as $_key => $_value ) {
163+
if ( is_array( $meta_value_to_translate ) ) {
164+
foreach ( $meta_value_to_translate as $_key => $_value ) {
165165
$object_id = BEA_CSF_Relations::get_object_for_any( $types, $data['blogid'], $sync_fields['_current_receiver_blog_id'], $_value, $_value );
166166
// If relation not exist, try to check if the parent relation is an synchronized content for get an indirect relation
167167
if ( empty( $object_id ) || (int) $object_id == 0 ) {
168-
$parent_relation = BEA_CSF_Relations::current_object_is_synchronized($types, $data['blogid'], $meta_value_to_translate);
168+
$parent_relation = BEA_CSF_Relations::current_object_is_synchronized( $types, $data['blogid'], $meta_value_to_translate );
169169
if ( $parent_relation != false ) {
170170
$object_id = BEA_CSF_Relations::get_object_for_any( $types, $parent_relation->emitter_blog_id, $sync_fields['_current_receiver_blog_id'], $parent_relation->emitter_id, $parent_relation->emitter_id );
171171
}
172172
}
173173

174174
if ( ! empty( $object_id ) && (int) $object_id > 0 ) {
175-
$meta_value_to_translate[$_key] = $object_id;
175+
$meta_value_to_translate[ $_key ] = $object_id;
176176
}
177177
}
178178

179-
$meta_data_to_update[$meta_key_to_translate] = $meta_value_to_translate;
179+
$meta_data_to_update[ $meta_key_to_translate ] = $meta_value_to_translate;
180180
} else {
181181
$object_id = BEA_CSF_Relations::get_object_for_any( $types, $data['blogid'], $sync_fields['_current_receiver_blog_id'], $meta_value_to_translate, $meta_value_to_translate );
182182
// If relation not exist, try to check if the parent relation is an synchronized content for get an indirect relation
183183
if ( empty( $object_id ) || (int) $object_id == 0 ) {
184-
$parent_relation = BEA_CSF_Relations::current_object_is_synchronized($types, $data['blogid'], $meta_value_to_translate);
184+
$parent_relation = BEA_CSF_Relations::current_object_is_synchronized( $types, $data['blogid'], $meta_value_to_translate );
185185
if ( $parent_relation != false ) {
186186
$object_id = BEA_CSF_Relations::get_object_for_any( $types, $parent_relation->emitter_blog_id, $sync_fields['_current_receiver_blog_id'], $parent_relation->emitter_id, $parent_relation->emitter_id );
187187

188188
}
189189
}
190190

191191
if ( ! empty( $object_id ) && (int) $object_id > 0 ) {
192-
$meta_data_to_update[$meta_key_to_translate] = $object_id;
192+
$meta_data_to_update[ $meta_key_to_translate ] = $object_id;
193193
}
194194
}
195195
}
@@ -204,13 +204,13 @@ public static function translate_dynamic_acf_fields( $meta_data, $data, $sync_fi
204204
*/
205205
public static function prepare_acf_fields( $fields ) {
206206
foreach ( (array) $fields as $field ) {
207-
if (in_array($field['type'], array('flexible_content') ) ) { // Flexible is recursive structure with layouts
208-
foreach( $field['layouts'] as $layout_field ) {
207+
if ( in_array( $field['type'], array( 'flexible_content' ) ) ) { // Flexible is recursive structure with layouts
208+
foreach ( $field['layouts'] as $layout_field ) {
209209
self::prepare_acf_fields( $layout_field['sub_fields'] );
210210
}
211-
} elseif (in_array($field['type'], array('repeater', 'group') ) ) { // Repeater is recursive structure
211+
} elseif ( in_array( $field['type'], array( 'repeater', 'group' ) ) ) { // Repeater is recursive structure
212212
self::prepare_acf_fields( $field['sub_fields'] );
213-
} elseif ( in_array($field['type'], array('image', 'gallery', 'post_object', 'relationship', 'file', 'page_link', 'taxonomy') ) ) {
213+
} elseif ( in_array( $field['type'], array( 'image', 'gallery', 'post_object', 'relationship', 'file', 'page_link', 'taxonomy' ) ) ) {
214214
self::$acf_fields[ $field['key'] ] = $field;
215215
}
216216
}

classes/addons/events-calendar-series.php

+20-10
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,25 @@ public function __construct() {
1717
add_action( 'save_post', array( __CLASS__, 'save_post' ), 10, 1 );
1818

1919
add_action( 'bea_csf.server.posttype.merge', array( __CLASS__, 'bea_csf_server_posttype_merge' ), 10, 2 );
20-
add_action( 'bea_csf.client.posttype.merge', array(
21-
__CLASS__,
22-
'bea_csf_client_posttype_merge_tickets'
23-
), 10, 3 );
20+
add_action(
21+
'bea_csf.client.posttype.merge',
22+
array(
23+
__CLASS__,
24+
'bea_csf_client_posttype_merge_tickets',
25+
),
26+
10,
27+
3
28+
);
2429
add_action( 'bea_csf.client.posttype.merge', array( __CLASS__, 'bea_csf_client_posttype_merge_venue' ), 10, 3 );
25-
add_action( 'bea_csf.client.posttype.merge', array(
26-
__CLASS__,
27-
'bea_csf_client_posttype_merge_organizer'
28-
), 10, 3 );
30+
add_action(
31+
'bea_csf.client.posttype.merge',
32+
array(
33+
__CLASS__,
34+
'bea_csf_client_posttype_merge_organizer',
35+
),
36+
10,
37+
3
38+
);
2939

3040
return true;
3141
}
@@ -41,7 +51,7 @@ public static function save_post( $post_id ) {
4151
global $wpdb;
4252

4353
$post_type = get_post_type( $post_id );
44-
if ( "tribe_rsvp_tickets" !== $post_type ) {
54+
if ( 'tribe_rsvp_tickets' !== $post_type ) {
4555
return false;
4656
}
4757

@@ -229,4 +239,4 @@ public static function bea_csf_client_posttype_merge_tickets( $data, $sync_field
229239

230240
return $data;
231241
}
232-
}
242+
}

classes/addons/gutenberg.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class BEA_CSF_Addon_Gutenberg {
1010
*/
1111
public function __construct() {
1212
if ( class_exists( 'WP_Block_Type' ) ) {
13-
add_filter( 'bea_csf_client_PostType_merge_data_to_transfer', [ $this, 'bea_csf_client_data_to_transfer', ], 10, 2 );
13+
add_filter( 'bea_csf_client_PostType_merge_data_to_transfer', [ $this, 'bea_csf_client_data_to_transfer' ], 10, 2 );
1414
}
1515
}
1616

@@ -63,7 +63,7 @@ public function translate_blocks( array $blocks, int $emitter_blog_id, int $rece
6363
$block['attrs'] = $this->translate_block_attributes( $block['attrs'], $block['blockName'], $emitter_blog_id, $receiver_blog_id );
6464
$block['innerContent'] = $this->translate_block_content( $block['innerContent'], $block['blockName'], $emitter_blog_id, $receiver_blog_id );
6565
}
66-
unset($block);
66+
unset( $block );
6767

6868
return $blocks;
6969
}

classes/addons/multisite-clone-duplicator.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ public function duplicate_relations( $from_site_id, $to_site_id ) {
6161
public function create_missing_relations( $from_site_id, $to_site_id ) {
6262
switch_to_blog( $to_site_id );
6363

64-
$media_query = new WP_Query( array(
65-
'post_type' => 'attachment',
66-
'bea_csf_filter' => 'local-only',
67-
'nopaging' => true,
68-
'fields' => 'ids',
69-
'suppress_filters' => false,
70-
'post_status' => 'any',
71-
) );
64+
$media_query = new WP_Query(
65+
array(
66+
'post_type' => 'attachment',
67+
'bea_csf_filter' => 'local-only',
68+
'nopaging' => true,
69+
'fields' => 'ids',
70+
'suppress_filters' => false,
71+
'post_status' => 'any',
72+
)
73+
);
7274

7375
if ( $media_query->have_posts() ) {
7476
foreach ( $media_query->posts as $media_query_id ) {

classes/addons/revisionize.php

+26-12
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,25 @@ public function __construct() {
99
return false;
1010
}
1111

12-
add_filter( 'bea_csf/client/posttype/before_merge', array(
13-
__CLASS__,
14-
'bea_csf_client_posttype_before_merge',
15-
), 10, 2 );
12+
add_filter(
13+
'bea_csf/client/posttype/before_merge',
14+
array(
15+
__CLASS__,
16+
'bea_csf_client_posttype_before_merge',
17+
),
18+
10,
19+
2
20+
);
1621
//add_filter( 'bea_csf.client.posttype.merge', array( __CLASS__, 'bea_csf_client_posttype_merge' ), 10, 3 );
17-
add_filter( 'bea_csf_client_' . 'PostType' . '_' . 'merge' . '_data_to_transfer', array(
18-
__CLASS__,
19-
'maybe_transform_data_for_draft',
20-
), 10, 3 );
22+
add_filter(
23+
'bea_csf_client_' . 'PostType' . '_' . 'merge' . '_data_to_transfer',
24+
array(
25+
__CLASS__,
26+
'maybe_transform_data_for_draft',
27+
),
28+
10,
29+
3
30+
);
2131

2232
add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_boxes' ), 11, 2 );
2333
add_action( 'display_post_states', array( __CLASS__, 'display_post_states' ), 11, 2 );
@@ -80,10 +90,14 @@ public static function maybe_transform_data_for_draft( $data, $sync_receiver_blo
8090
$_post_receivers_status = maybe_unserialize( $data['meta_data'][ '_b' . $data['blogid'] . '_post_receivers_status' ][0] );
8191

8292
if ( isset( $_post_receivers_status[ $sync_receiver_blog_id ] ) &&
83-
in_array( $_post_receivers_status[ $sync_receiver_blog_id ], [
84-
'publish-draft',
85-
'pending-draft',
86-
], true ) ) {
93+
in_array(
94+
$_post_receivers_status[ $sync_receiver_blog_id ],
95+
[
96+
'publish-draft',
97+
'pending-draft',
98+
],
99+
true
100+
) ) {
87101

88102
// Mapping ID
89103
$local_id = BEA_CSF_Relations::get_object_for_any( 'posttype', $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );

classes/addons/woocommerce.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ public function __construct() {
1313
new BEA_CSF_Addon_WooCommerce_Product_Variation();
1414
new BEA_CSF_Addon_WooCommerce_Product_Attributes();
1515
}
16-
}
16+
}

classes/addons/woocommerce/product-attributes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@ public static function flush_attributes() {
124124

125125
return $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_attribute_taxonomies" );
126126
}
127-
}
127+
}

0 commit comments

Comments
 (0)