diff --git a/classes/addons/advanced-custom-fields-exclusion.php b/classes/addons/advanced-custom-fields-exclusion.php
index f935e7f..f1ee5d3 100644
--- a/classes/addons/advanced-custom-fields-exclusion.php
+++ b/classes/addons/advanced-custom-fields-exclusion.php
@@ -1,4 +1,5 @@
$fields ) {
foreach ( $fields as $field_type => $field_label ) {
- add_action( 'acf/render_field/type=' . $field_type, array( __CLASS__, 'acf_render_field_before' ), 8, 1 );
- add_action( 'acf/render_field/type=' . $field_type, array( __CLASS__, 'acf_render_field_after' ), 10, 1 );
+ add_action( 'acf/render_field/type=' . $field_type, [ __CLASS__, 'acf_render_field_before' ], 8, 1 );
+ add_action( 'acf/render_field/type=' . $field_type, [ __CLASS__, 'acf_render_field_after' ], 10, 1 );
}
}
}
@@ -128,14 +138,16 @@ public static function acf_include_field_types() {
/**
* Do nothing actually.
*
- * @param $field
+ * @param array $field
+ *
+ * @return bool
*/
public static function acf_render_field_before( $field ) {
if ( apply_filters( 'bea/csf/acf-addon-exclusion/allow-types-fieds-exclusion', false, $field ) === false ) {
return false;
}
- if ( in_array( $field['type'], array( 'flexible_content', 'repeater' ) ) ) {
+ if ( in_array( $field['type'], [ 'flexible_content', 'repeater' ] ) ) {
self::build_html_checkbox( $field, __( 'Exclude this group from future synchro', 'bea-content-sync-fusion' ) );
}
@@ -145,14 +157,16 @@ public static function acf_render_field_before( $field ) {
/**
* Add an checkbox after each field for exclude from future synchro
*
- * @param $field
+ * @param array $field
+ *
+ * @return bool
*/
public static function acf_render_field_after( $field ) {
if ( apply_filters( 'bea/csf/acf-addon-exclusion/allow-types-fieds-exclusion', false, $field ) === false ) {
return false;
}
- if ( ! in_array( $field['type'], array( 'flexible_content', 'repeater' ) ) ) {
+ if ( ! in_array( $field['type'], [ 'flexible_content', 'repeater' ] ) ) {
self::build_html_checkbox( $field, __( 'Exclude this field from future synchro', 'bea-content-sync-fusion' ) );
}
@@ -162,7 +176,7 @@ public static function acf_render_field_after( $field ) {
/**
* Helper for display the checkbox before or after ACF fields
*
- * @param array $field
+ * @param array $field
* @param string $label
*
* @return bool
@@ -180,7 +194,7 @@ public static function build_html_checkbox( $field, $label ) {
$current_excluded_items = get_post_meta( $post->ID, 'bea_csf_exclude_acf_fields', true );
// Show checkbox
- echo '';
+ echo '';
// Call once time
wp_nonce_field( plugin_basename( __FILE__ ), 'bea_csf_exclude_acf_fields_nonce' );
@@ -191,15 +205,15 @@ public static function build_html_checkbox( $field, $label ) {
/**
* Delete metadata excluded with ACF fields exclusion form synchro
*
- * @param $data
- * @param $sync_receiver_blog_id
- * @param $sync_fields
+ * @param array $data
+ * @param int $sync_receiver_blog_id
+ * @param array $sync_fields
*
* @return mixed
*/
public static function filter_acf_groups( $data, $sync_receiver_blog_id, $sync_fields ) {
$local_id = BEA_CSF_Relations::get_object_for_any( 'posttype', $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );
- if ( $local_id === false ) {
+ if ( false === $local_id ) {
return $data;
}
@@ -214,7 +228,7 @@ public static function filter_acf_groups( $data, $sync_receiver_blog_id, $sync_f
return $data;
}
- $fields = array();
+ $fields = [];
foreach ( $groups as $group ) {
if ( ! in_array( $group['key'], $current_excluded_groups ) ) {
continue;
@@ -231,7 +245,7 @@ public static function filter_acf_groups( $data, $sync_receiver_blog_id, $sync_f
}
// Get only fields
- self::$acf_fields = array();
+ self::$acf_fields = [];
self::prepare_acf_fields( $fields );
// Loop on each meta
@@ -248,15 +262,15 @@ public static function filter_acf_groups( $data, $sync_receiver_blog_id, $sync_f
/**
* Delete metadata excluded with ACF fields exclusion form synchro
*
- * @param $data
- * @param $sync_receiver_blog_id
- * @param $sync_fields
+ * @param array $data
+ * @param int $sync_receiver_blog_id
+ * @param array $sync_fields
*
* @return mixed
*/
public static function filter_acf_flexibles( $data, $sync_receiver_blog_id, $sync_fields ) {
$local_id = BEA_CSF_Relations::get_object_for_any( 'posttype', $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );
- if ( $local_id === false ) {
+ if ( false === $local_id ) {
return $data;
}
@@ -298,16 +312,18 @@ public static function filter_acf_flexibles( $data, $sync_receiver_blog_id, $syn
* Extract from group fields only ACF field with ID database reference (recursive !)
*
* @param array $fields
+ *
+ * @return void
*/
public static function prepare_acf_fields( $fields ) {
foreach ( (array) $fields as $field ) {
self::$acf_fields[ $field['key'] ] = $field;
- if ( in_array( $field['type'], array( 'flexible_content' ) ) ) { // Flexible is recursive structure with layouts
+ if ( in_array( $field['type'], [ 'flexible_content' ] ) ) { // Flexible is recursive structure with layouts
foreach ( $field['layouts'] as $layout_field ) {
self::prepare_acf_fields( $layout_field['sub_fields'] );
}
- } elseif ( in_array( $field['type'], array( 'repeater' ) ) ) { // Repeater is recursive structure
+ } elseif ( in_array( $field['type'], [ 'repeater' ] ) ) { // Repeater is recursive structure
self::prepare_acf_fields( $field['sub_fields'] );
}
}
@@ -316,15 +332,15 @@ public static function prepare_acf_fields( $fields ) {
/**
* Delete metadata excluded with ACF fields exclusion form synchro
*
- * @param $data
- * @param $sync_receiver_blog_id
- * @param $sync_fields
+ * @param array $data
+ * @param int $sync_receiver_blog_id
+ * @param array $sync_fields
*
- * @return mixed
+ * @return array
*/
public static function filter_acf_fields( $data, $sync_receiver_blog_id, $sync_fields ) {
$local_id = BEA_CSF_Relations::get_object_for_any( 'posttype', $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );
- if ( $local_id === false ) {
+ if ( false === $local_id ) {
return $data;
}
@@ -347,7 +363,7 @@ public static function filter_acf_fields( $data, $sync_receiver_blog_id, $sync_f
// Delete all metadata from flexible/repeater
$acf_field = acf_maybe_get_field( $raw_meta_value[0] );
- if ( $acf_field != false && in_array( $acf_field['type'], array( 'flexible_content', 'repeater' ) ) ) {
+ if ( false !== $acf_field && in_array( $acf_field['type'], [ 'flexible_content', 'repeater' ] ) ) {
foreach ( (array) $data['meta_data'] as $sub_meta_key => $sub_meta_value ) {
if ( ! preg_match( '/' . preg_quote( $acf_field['name'] ) . '[\_]\d*[\_]/', $sub_meta_key ) !== false ) {
continue;
@@ -373,7 +389,7 @@ public static function filter_acf_fields( $data, $sync_receiver_blog_id, $sync_f
if ( $meta_key == $translated_acf_name ) {
// Delete all metadata from flexible/repeater
$acf_field = acf_maybe_get_field( $matches[1][0] );
- if ( $acf_field != false && in_array( $acf_field['type'], array( 'flexible_content', 'repeater' ) ) ) {
+ if ( false !== $acf_field && in_array( $acf_field['type'], [ 'flexible_content', 'repeater' ] ) ) {
foreach ( (array) $data['meta_data'] as $sub_meta_key => $sub_meta_value ) {
if ( ! preg_match( '/' . preg_quote( $acf_field['name'] ) . '[\_]\d*[\_]/', $sub_meta_key ) !== false ) {
continue;
@@ -413,7 +429,9 @@ public static function get_acf_field_name( $acf_key, $translated_acf_name = '' )
foreach ( self::$meta_data as $acf_name => $raw_meta_value ) {
if ( ! empty( $translated_acf_name ) && $raw_meta_value[0] == $acf_key && strpos( $acf_name, $translated_acf_name ) !== false ) {
return str_replace( $translated_acf_name, '', $acf_name );
- } elseif ( empty( $translated_acf_name ) && $raw_meta_value[0] == $acf_key ) {
+ }
+
+ if ( empty( $translated_acf_name ) && $raw_meta_value[0] == $acf_key ) {
return $acf_name;
}
}
@@ -423,6 +441,7 @@ public static function get_acf_field_name( $acf_key, $translated_acf_name = '' )
/**
* Hook on admin_head "as ACF" for get all metaboxes declared by this plugin and append a small checkbox
+ * @return bool
*/
public static function post_edit_form_tag() {
global $wp_meta_boxes;
@@ -452,7 +471,7 @@ public static function post_edit_form_tag() {
* @param $meta_box
* @param $label
*
- * @return bool
+ * @return string|bool
*/
public static function get_html_checkbox_for_metabox( $meta_box, $label ) {
global $post, $wpdb;
@@ -469,7 +488,7 @@ public static function get_html_checkbox_for_metabox( $meta_box, $label ) {
// Get current checked items
$current_excluded_items = get_post_meta( $post->ID, 'bea_csf_exclude_acf_group', true );
- $output = '';
+ $output = '';
$output .= wp_nonce_field( plugin_basename( __FILE__ ), 'bea_csf_exclude_acf_group_nonce', true, false );
return $output;
@@ -478,15 +497,14 @@ public static function get_html_checkbox_for_metabox( $meta_box, $label ) {
/**
* Helper for display the checkbox before or after ACF fields
*
- * @param array $field
+ * @param array $field
* @param string $label
- * @param $layout
- * @param $i
- * @param $value
+ * @param string $layout
+ * @param string $i
*
* @return bool
*/
- public static function build_html_checkbox_flexible( $field, $label, $layout, $i, $value ) {
+ public static function build_html_checkbox_flexible( $field, $label, $layout, $i ) {
global $post, $wpdb, $counter_flexible;
if ( 'acfcloneindex' === $i ) {
@@ -504,15 +522,15 @@ public static function build_html_checkbox_flexible( $field, $label, $layout, $i
// Increment counter
if ( ! isset( $counter_flexible[ $field['name'] ] ) ) {
- $counter_flexible[ $field['name'] ] = -1;
+ $counter_flexible[ $field['name'] ] = - 1;
}
- $counter_flexible[ $field['name'] ]++;
+ $counter_flexible[ $field['name'] ] ++;
// Build value with name + counter
$input_value = $field['name'] . '[' . $counter_flexible[ $field['name'] ] . ']';
// Show checkbox
- echo '';
+ echo '';
// Call once time
wp_nonce_field( plugin_basename( __FILE__ ), 'bea_csf_exclude_acf_fields_flexible_nonce' );
diff --git a/classes/addons/advanced-custom-fields.php b/classes/addons/advanced-custom-fields.php
index 3c888e5..883729b 100644
--- a/classes/addons/advanced-custom-fields.php
+++ b/classes/addons/advanced-custom-fields.php
@@ -1,33 +1,32 @@
$values ) {
@@ -153,10 +152,10 @@ public static function translate_dynamic_acf_fields( $meta_data, $data, $sync_fi
$meta_value_to_translate = maybe_unserialize( $meta_data[ $meta_key_to_translate ][0] );
$types = false;
- if ( in_array( $acf_field['type'], array( 'image', 'post_object', 'file', 'page_link', 'gallery', 'relationship' ) ) ) {
- $types = array( 'attachment', 'posttype' );
- } elseif ( in_array( $acf_field['type'], array( 'taxonomy' ) ) ) {
- $types = array( 'taxonomy' );
+ if ( in_array( $acf_field['type'], [ 'image', 'post_object', 'file', 'page_link', 'gallery', 'relationship' ] ) ) {
+ $types = [ 'attachment', 'posttype' ];
+ } elseif ( in_array( $acf_field['type'], [ 'taxonomy' ] ) ) {
+ $types = [ 'taxonomy' ];
}
// Array or singular value ?
@@ -164,9 +163,9 @@ public static function translate_dynamic_acf_fields( $meta_data, $data, $sync_fi
foreach ( $meta_value_to_translate as $_key => $_value ) {
$object_id = BEA_CSF_Relations::get_object_for_any( $types, $data['blogid'], $sync_fields['_current_receiver_blog_id'], $_value, $_value );
// If relation not exist, try to check if the parent relation is an synchronized content for get an indirect relation
- if ( empty( $object_id ) || (int) $object_id == 0 ) {
+ if ( empty( $object_id ) || 0 === (int) $object_id ) {
$parent_relation = BEA_CSF_Relations::current_object_is_synchronized( $types, $data['blogid'], $meta_value_to_translate );
- if ( $parent_relation != false ) {
+ if ( false !== $parent_relation ) {
$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 );
}
}
@@ -180,11 +179,10 @@ public static function translate_dynamic_acf_fields( $meta_data, $data, $sync_fi
} else {
$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 );
// If relation not exist, try to check if the parent relation is an synchronized content for get an indirect relation
- if ( empty( $object_id ) || (int) $object_id == 0 ) {
+ if ( empty( $object_id ) || 0 === (int) $object_id ) {
$parent_relation = BEA_CSF_Relations::current_object_is_synchronized( $types, $data['blogid'], $meta_value_to_translate );
- if ( $parent_relation != false ) {
+ if ( false !== $parent_relation ) {
$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 );
-
}
}
@@ -204,13 +202,13 @@ public static function translate_dynamic_acf_fields( $meta_data, $data, $sync_fi
*/
public static function prepare_acf_fields( $fields ) {
foreach ( (array) $fields as $field ) {
- if ( in_array( $field['type'], array( 'flexible_content' ) ) ) { // Flexible is recursive structure with layouts
+ if ( in_array( $field['type'], [ 'flexible_content' ], true ) ) { // Flexible is recursive structure with layouts
foreach ( $field['layouts'] as $layout_field ) {
self::prepare_acf_fields( $layout_field['sub_fields'] );
}
- } elseif ( in_array( $field['type'], array( 'repeater', 'group' ) ) ) { // Repeater is recursive structure
+ } elseif ( in_array( $field['type'], [ 'repeater', 'group' ] ) ) { // Repeater is recursive structure
self::prepare_acf_fields( $field['sub_fields'] );
- } elseif ( in_array( $field['type'], array( 'image', 'gallery', 'post_object', 'relationship', 'file', 'page_link', 'taxonomy' ) ) ) {
+ } elseif ( in_array( $field['type'], [ 'image', 'gallery', 'post_object', 'relationship', 'file', 'page_link', 'taxonomy' ] ) ) {
self::$acf_fields[ $field['key'] ] = $field;
}
}
diff --git a/classes/addons/events-calendar-series.php b/classes/addons/events-calendar-series.php
index d16b448..96a66d4 100644
--- a/classes/addons/events-calendar-series.php
+++ b/classes/addons/events-calendar-series.php
@@ -14,25 +14,25 @@ public function __construct() {
return false;
}
- add_action( 'save_post', array( __CLASS__, 'save_post' ), 10, 1 );
+ add_action( 'save_post', [ __CLASS__, 'save_post' ], 10, 1 );
- add_action( 'bea_csf.server.posttype.merge', array( __CLASS__, 'bea_csf_server_posttype_merge' ), 10, 2 );
+ add_action( 'bea_csf.server.posttype.merge', [ __CLASS__, 'bea_csf_server_posttype_merge' ], 10, 2 );
add_action(
'bea_csf.client.posttype.merge',
- array(
+ [
__CLASS__,
'bea_csf_client_posttype_merge_tickets',
- ),
+ ],
10,
3
);
- add_action( 'bea_csf.client.posttype.merge', array( __CLASS__, 'bea_csf_client_posttype_merge_venue' ), 10, 3 );
+ add_action( 'bea_csf.client.posttype.merge', [ __CLASS__, 'bea_csf_client_posttype_merge_venue' ], 10, 3 );
add_action(
'bea_csf.client.posttype.merge',
- array(
+ [
__CLASS__,
'bea_csf_client_posttype_merge_organizer',
- ),
+ ],
10,
3
);
@@ -91,8 +91,8 @@ public static function bea_csf_server_posttype_merge( $data, $sync_fields ) {
// Get tickets
$tickets = Tribe__Tickets__Tickets::get_event_tickets( $data['ID'] );
- if ( $tickets != false && ! empty( $tickets ) ) {
- $data['tickets'] = array();
+ if ( ! empty( $tickets ) ) {
+ $data['tickets'] = [];
foreach ( $tickets as $ticket ) {
$data['tickets'][] = BEA_CSF_Server_PostType::get_data( $ticket->ID, $sync_fields );
@@ -101,13 +101,13 @@ public static function bea_csf_server_posttype_merge( $data, $sync_fields ) {
// Get organizer
$data['_EventOrganizerID'] = get_post_meta( $data['ID'], '_EventOrganizerID', true );
- if ( $data['_EventOrganizerID'] != false ) {
+ if ( false !== $data['_EventOrganizerID'] ) {
$data['_EventOrganizer'] = BEA_CSF_Server_PostType::get_data( $data['_EventOrganizerID'], $sync_fields );
}
// Get venue
$data['_EventVenueID'] = get_post_meta( $data['ID'], '_EventVenueID', true );
- if ( $data['_EventVenueID'] != false ) {
+ if ( false !== $data['_EventVenueID'] ) {
$data['_EventVenue'] = BEA_CSF_Server_PostType::get_data( $data['_EventVenueID'], $sync_fields );
}
@@ -117,8 +117,8 @@ public static function bea_csf_server_posttype_merge( $data, $sync_fields ) {
/**
* Insert/update organizer on client part after event insertion
*
- * @param array $data
- * @param array $sync_fields
+ * @param array $data
+ * @param array $sync_fields
* @param WP_Post $new_post
*
* @return array mixed
@@ -129,19 +129,19 @@ public static function bea_csf_client_posttype_merge_organizer( $data, $sync_fie
}
// Get local event
- $local_event_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );
- if ( false == $local_event_id ) {
+ $local_event_id = BEA_CSF_Relations::get_object_for_any( [ 'posttype' ], $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );
+ if ( false === $local_event_id ) {
return $data;
}
// Create organizer on client if not exists
- $local_organizer_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['_EventOrganizerID'], $data['_EventOrganizerID'] );
- if ( false == $local_organizer_id ) {
+ $local_organizer_id = BEA_CSF_Relations::get_object_for_any( [ 'posttype' ], $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['_EventOrganizerID'], $data['_EventOrganizerID'] );
+ if ( false === $local_organizer_id ) {
$data['_EventOrganizer']['blogid'] = $data['blogid'];
BEA_CSF_Client_PostType::merge( $data['_EventOrganizer'], $sync_fields );
// Renew mapping ID
- $local_organizer_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['_EventOrganizerID'], $data['_EventOrganizerID'] );
+ $local_organizer_id = BEA_CSF_Relations::get_object_for_any( [ 'posttype' ], $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['_EventOrganizerID'], $data['_EventOrganizerID'] );
}
// Update local organizer
@@ -153,8 +153,8 @@ public static function bea_csf_client_posttype_merge_organizer( $data, $sync_fie
/**
* Insert/update venue on client part after event insertion
*
- * @param array $data
- * @param array $sync_fields
+ * @param array $data
+ * @param array $sync_fields
* @param WP_Post $new_post
*
* @return array mixed
@@ -165,19 +165,19 @@ public static function bea_csf_client_posttype_merge_venue( $data, $sync_fields,
}
// Get local event
- $local_event_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );
- if ( false == $local_event_id ) {
+ $local_event_id = BEA_CSF_Relations::get_object_for_any( [ 'posttype' ], $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );
+ if ( false === $local_event_id ) {
return $data;
}
// Create venue on client if not exists
- $local_venue_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['_EventVenueID'], $data['_EventVenueID'] );
- if ( false == $local_venue_id ) {
+ $local_venue_id = BEA_CSF_Relations::get_object_for_any( [ 'posttype' ], $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['_EventVenueID'], $data['_EventVenueID'] );
+ if ( false === $local_venue_id ) {
$data['_EventVenue']['blogid'] = $data['blogid'];
BEA_CSF_Client_PostType::merge( $data['_EventVenue'], $sync_fields );
// Renew mapping ID
- $local_venue_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['_EventVenueID'], $data['_EventVenueID'] );
+ $local_venue_id = BEA_CSF_Relations::get_object_for_any( [ 'posttype' ], $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['_EventVenueID'], $data['_EventVenueID'] );
}
// Update local venue
@@ -189,8 +189,8 @@ public static function bea_csf_client_posttype_merge_venue( $data, $sync_fields,
/**
* Insert/update tickets on client part after event insertion
*
- * @param array $data
- * @param array $sync_fields
+ * @param array $data
+ * @param array $sync_fields
* @param WP_Post $new_post
*
* @return array mixed
@@ -202,8 +202,8 @@ public static function bea_csf_client_posttype_merge_tickets( $data, $sync_field
}
// Get local event
- $local_event_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );
- if ( false == $local_event_id ) {
+ $local_event_id = BEA_CSF_Relations::get_object_for_any( [ 'posttype' ], $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );
+ if ( false === $local_event_id ) {
return $data;
}
@@ -212,7 +212,7 @@ public static function bea_csf_client_posttype_merge_tickets( $data, $sync_field
$local_tickets_id = wp_list_pluck( $local_tickets, 'ID' );
// Loop on each tickets for insertion, and keep ID
- $remote_tickets_id = array();
+ $remote_tickets_id = [];
foreach ( $data['tickets'] as &$ticket ) {
// Fix event ID with local value
if ( isset( $ticket['meta_data']['_tribe_rsvp_for_event'] ) ) {
@@ -223,8 +223,8 @@ public static function bea_csf_client_posttype_merge_tickets( $data, $sync_field
BEA_CSF_Client_PostType::merge( $ticket, $sync_fields );
// Translated remote tickets with current ID
- $local_ticket_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $ticket['ID'], $ticket['ID'] );
- if ( false != $local_ticket_id ) {
+ $local_ticket_id = BEA_CSF_Relations::get_object_for_any( [ 'posttype' ], $data['blogid'], $sync_fields['_current_receiver_blog_id'], $ticket['ID'], $ticket['ID'] );
+ if ( false !== $local_ticket_id ) {
$remote_tickets_id[] = (int) $local_ticket_id;
}
}
diff --git a/classes/addons/revisionize.php b/classes/addons/revisionize.php
index 4b856a9..d06f664 100644
--- a/classes/addons/revisionize.php
+++ b/classes/addons/revisionize.php
@@ -6,43 +6,43 @@ class BEA_CSF_Addon_Revisionize {
*/
public function __construct() {
if ( ! defined( 'REVISIONIZE_VERSION' ) ) {
- return false;
+ return;
}
add_filter(
'bea_csf/client/posttype/before_merge',
- array(
+ [
__CLASS__,
'bea_csf_client_posttype_before_merge',
- ),
+ ],
10,
2
);
- //add_filter( 'bea_csf.client.posttype.merge', array( __CLASS__, 'bea_csf_client_posttype_merge' ), 10, 3 );
add_filter(
- 'bea_csf_client_' . 'PostType' . '_' . 'merge' . '_data_to_transfer',
- array(
+ 'bea_csf_client_PostType_merge_data_to_transfer',
+ [
__CLASS__,
'maybe_transform_data_for_draft',
- ),
+ ],
10,
3
);
- add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_boxes' ), 11, 2 );
- add_action( 'display_post_states', array( __CLASS__, 'display_post_states' ), 11, 2 );
+ add_action( 'add_meta_boxes', [ __CLASS__, 'add_meta_boxes' ], 11, 2 );
+ add_action( 'display_post_states', [ __CLASS__, 'display_post_states' ], 11, 2 );
- add_action( 'revisionize/get_post_custom_keys', array( __CLASS__, 'get_post_custom_keys' ), 11, 3 );
-
- return true;
+ add_action( 'revisionize/get_post_custom_keys', [ __CLASS__, 'get_post_custom_keys' ], 11, 3 );
}
public static function get_post_custom_keys( $meta_keys, $id, $context ) {
- if ( 'copy' === $context ) {
- foreach ( [ '_network_post_revision' ] as $meta_key_delete ) {
- if ( ( $key = array_search( $meta_key_delete, $meta_keys ) ) !== false ) {
- unset( $meta_keys[ $key ] );
- }
+ if ( 'copy' !== $context ) {
+ return $meta_keys;
+ }
+
+ foreach ( [ '_network_post_revision' ] as $meta_key_delete ) {
+ $key = array_search( $meta_key_delete, $meta_keys );
+ if ( false !== $key ) {
+ unset( $meta_keys[ $key ] );
}
}
@@ -65,7 +65,7 @@ public static function add_meta_boxes( $post_type, $post ) {
/**
* Add a custom post states for remote revision
*
- * @param array $states
+ * @param array $states
* @param WP_Post $post
*
* @return array
@@ -90,14 +90,14 @@ public static function maybe_transform_data_for_draft( $data, $sync_receiver_blo
$_post_receivers_status = maybe_unserialize( $data['meta_data'][ '_b' . $data['blogid'] . '_post_receivers_status' ][0] );
if ( isset( $_post_receivers_status[ $sync_receiver_blog_id ] ) &&
- in_array(
- $_post_receivers_status[ $sync_receiver_blog_id ],
- [
- 'publish-draft',
- 'pending-draft',
- ],
- true
- ) ) {
+ in_array(
+ $_post_receivers_status[ $sync_receiver_blog_id ],
+ [
+ 'publish-draft',
+ 'pending-draft',
+ ],
+ true
+ ) ) {
// Mapping ID
$local_id = BEA_CSF_Relations::get_object_for_any( 'posttype', $data['blogid'], $sync_fields['_current_receiver_blog_id'], $data['ID'], $data['ID'] );
@@ -116,9 +116,9 @@ public static function maybe_transform_data_for_draft( $data, $sync_receiver_blo
$data['post_status'] = 'draft';
// Add meta data for revisionize
- $data['meta_data']['_post_revision_of'] = array( 0 => $local_id );
- $data['meta_data']['_post_revision'] = array( 0 => true );
- $data['meta_data']['_network_post_revision'] = array( 0 => true );
+ $data['meta_data']['_post_revision_of'] = [ 0 => $local_id ];
+ $data['meta_data']['_post_revision'] = [ 0 => true ];
+ $data['meta_data']['_network_post_revision'] = [ 0 => true ];
}
}
diff --git a/classes/addons/woocommerce/product-attributes.php b/classes/addons/woocommerce/product-attributes.php
index 3a228d8..8476370 100644
--- a/classes/addons/woocommerce/product-attributes.php
+++ b/classes/addons/woocommerce/product-attributes.php
@@ -25,7 +25,7 @@ public static function resync() {
// Hack WooCommerce check
global $wp_taxonomies;
$bk_wp_taxonomies = $wp_taxonomies;
- $wp_taxonomies = [];
+ $wp_taxonomies = []; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
delete_transient( 'wc_attribute_taxonomies' );
WC_Cache_Helper::incr_cache_prefix( 'woocommerce-attributes' );
@@ -40,13 +40,13 @@ public static function resync() {
foreach ( $attribute_taxonomies as $attribute_taxonomy ) {
$data = (array) $attribute_taxonomy;
wc_create_attribute(
- array(
+ [
'name' => $data['attribute_label'],
'slug' => $data['attribute_name'],
'type' => $data['attribute_type'],
'order_by' => $data['attribute_orderby'],
'has_archives' => $data['attribute_public'],
- )
+ ]
);
}
@@ -54,7 +54,7 @@ public static function resync() {
}
// Restore backup
- $wp_taxonomies = $bk_wp_taxonomies;
+ $wp_taxonomies = $bk_wp_taxonomies; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
unset( $bk_wp_taxonomies );
}
diff --git a/classes/addons/woocommerce/product.php b/classes/addons/woocommerce/product.php
index 0b1e832..ec36e94 100644
--- a/classes/addons/woocommerce/product.php
+++ b/classes/addons/woocommerce/product.php
@@ -41,7 +41,7 @@ function ( $media_id ) use ( $data, $sync_fields ) {
$media_id = (int) $media_id;
$new_media_id = BEA_CSF_Relations::get_object_for_any( array( 'attachment' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $media_id, $media_id );
if ( false !== $new_media_id ) {
- return $new_media_id;
+ return $new_media_id;
}
return $media_id;
@@ -60,7 +60,7 @@ function ( $product_id ) use ( $data, $sync_fields ) {
$product_id = (int) $product_id;
$new_product_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $product_id, $product_id );
if ( false !== $new_product_id ) {
- return $new_product_id;
+ return $new_product_id;
}
return $product_id;
@@ -79,7 +79,7 @@ function ( $product_id ) use ( $data, $sync_fields ) {
$product_id = (int) $product_id;
$new_product_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $product_id, $product_id );
if ( false !== $new_product_id ) {
- return $new_product_id;
+ return $new_product_id;
}
return $product_id;
@@ -98,7 +98,7 @@ function ( $product_id ) use ( $data, $sync_fields ) {
$product_id = (int) $product_id;
$new_product_id = BEA_CSF_Relations::get_object_for_any( array( 'posttype' ), $data['blogid'], $sync_fields['_current_receiver_blog_id'], $product_id, $product_id );
if ( false !== $new_product_id ) {
- return $new_product_id;
+ return $new_product_id;
}
return $product_id;