Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds warning if private properties are accessed outside its class. #2619

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions class-wc-facebookcommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@ public function __construct() {
$this->init_admin();
}

/**
* __get method for backward compatibility.
*
* @param string $key property name
* @return mixed
* @since x.x.x
*/
public function __get( $key ) {
// Add warning for private properties.
if ( in_array( $key, array( 'configuration_detection', 'fb_categories' ), true ) ) {
/* translators: %s property name. */
_doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'The %s property is private and should not be accessed outside its class.', 'facebook-for-woocommerce' ), esc_html( $key ) ), 'x.x.x' );
return $this->$key;
}

return null;
}

/**
* Initializes the plugin.
Expand Down
17 changes: 17 additions & 0 deletions facebook-commerce-messenger-chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ public function __construct( $settings ) {
add_action( 'wp_footer', array( $this, 'inject_messenger_chat_plugin' ) );
}

/**
* __get method for backward compatibility.
*
* @param string $key property name
* @return mixed
* @since x.x.x
*/
public function __get( $key ) {
// Add warning for private properties.
if ( in_array( $key, array( 'page_id', 'jssdk_version' ), true ) ) {
/* translators: %s property name. */
_doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'The %s property is private and should not be accessed outside its class.', 'facebook-for-woocommerce' ), esc_html( $key ) ), 'x.x.x' );
return $this->$key;
}

return null;
}

/**
* Outputs the Facebook Messenger chat script.
Expand Down
18 changes: 18 additions & 0 deletions facebook-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,24 @@ public function __construct( WC_Facebookcommerce $facebook_for_woocommerce ) {
add_action( 'fb_wc_product_set_delete', [ $this, 'delete_product_set_item' ], 99 );
}

/**
* __get method for backward compatibility.
*
* @param string $key property name
* @return mixed
* @since x.x.x
*/
public function __get( $key ) {
// Add warning for private properties.
if ( in_array( $key, array( 'events_tracker', 'messenger_chat', 'background_processor' ), true ) ) {
/* translators: %s property name. */
_doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'The %s property is private and should not be accessed outside its class.', 'facebook-for-woocommerce' ), esc_html( $key ) ), 'x.x.x' );
return $this->$key;
}

return null;
}

/**
* Initialises Facebook Pixel and its settings.
*
Expand Down
18 changes: 18 additions & 0 deletions includes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@ public function __construct() {
add_filter( 'gettext', array( $this, 'change_custom_taxonomy_tip' ), 20, 2 );
}

/**
* __get method for backward compatibility.
*
* @param string $key property name
* @return mixed
* @since x.x.x
*/
public function __get( $key ) {
// Add warning for private properties.
if ( 'product_sets' === $key ) {
/* translators: %s property name. */
_doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'The %s property is protected and should not be accessed outside its class.', 'facebook-for-woocommerce' ), esc_html( $key ) ), 'x.x.x' );
return $this->$key;
}

return null;
}

/**
* Change custom taxonomy tip text
*
Expand Down
18 changes: 18 additions & 0 deletions includes/Admin/Enhanced_Catalog_Attribute_Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ public function __construct( $page_type, \WP_Term $term = null, \WC_Product $pro
$this->category_handler = facebook_for_woocommerce()->get_facebook_category_handler();
}

/**
* __get method for backward compatibility.
*
* @param string $key property name
* @return mixed
* @since x.x.x
*/
public function __get( $key ) {
// Add warning for private properties.
if ( in_array( $key, array( 'page_type', 'term', 'product', 'category_handler' ), true ) ) {
/* translators: %s property name. */
_doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'The %s property is private and should not be accessed outside its class.', 'facebook-for-woocommerce' ), esc_html( $key ) ), 'x.x.x' );
return $this->$key;
}

return null;
}

public static function render_hidden_input_can_show_attributes() {
?>
<input type="hidden" id="<?php echo esc_attr( self::FIELD_CAN_SHOW_ENHANCED_ATTRIBUTES_ID ); ?>"
Expand Down
18 changes: 18 additions & 0 deletions includes/ProductSync/ProductValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ public function __construct( WC_Facebookcommerce_Integration $integration, WC_Pr
$this->integration = $integration;
}

/**
* __get method for backward compatibility.
*
* @param string $key property name
* @return mixed
* @since x.x.x
*/
public function __get( $key ) {
// Add warning for private properties.
if ( 'facebook_product' === $key ) {
/* translators: %s property name. */
_doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'The %s property is protected and should not be accessed outside its class.', 'facebook-for-woocommerce' ), esc_html( $key ) ), 'x.x.x' );
return $this->$key;
}

return null;
}

/**
* Validate whether the product should be synced to Facebook.
*
Expand Down
18 changes: 18 additions & 0 deletions includes/fbbackground.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ public function __construct( $commerce ) {
$this->commerce = $commerce; // Full WC_Facebookcommerce_Integration obj
}

/**
* __get method for backward compatibility.
*
* @param string $key property name
* @return mixed
* @since x.x.x
*/
public function __get( $key ) {
// Add warning for private properties.
if ( 'commerce' === $key ) {
/* translators: %s property name. */
_doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'The %s property is private and should not be accessed outside its class.', 'facebook-for-woocommerce' ), esc_html( $key ) ), 'x.x.x' );
return $this->$key;
}

return null;
}

/**
* @var string
*/
Expand Down
18 changes: 18 additions & 0 deletions includes/fbproduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ public function __construct( $wpid, $parent_product = null ) {
}
}

/**
* __get method for backward compatibility.
*
* @param string $key property name
* @return mixed
* @since x.x.x
*/
public function __get( $key ) {
// Add warning for private properties.
if ( in_array( $key, array( 'fb_description', 'gallery_urls', 'fb_use_parent_image', 'main_description', 'sync_short_description' ), true ) ) {
/* translators: %s property name. */
_doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'The %s property is private and should not be accessed outside its class.', 'facebook-for-woocommerce' ), esc_html( $key ) ), 'x.x.x' );
return $this->$key;
}

return null;
}

public function exists() {
return ( $this->woo_product !== null && $this->woo_product !== false );
}
Expand Down