Skip to content

Commit

Permalink
Merge pull request #2246 from the-events-calendar/fix/TEC-5312-deprec…
Browse files Browse the repository at this point in the history
…ated-props-still-in-use
  • Loading branch information
dpanta94 authored Nov 1, 2024
2 parents c4b08be + 6c27025 commit e21b1bd
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-TEC-5312-deprecated-props-still-in-use
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Include backwards compatibility for deprecated proprieties in the Settings class used in The Events Calendar and Event Tickets [TEC-5312]
50 changes: 50 additions & 0 deletions src/Tribe/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,59 @@ public function __construct() {
$this->default_tab = null;
$this->current_tab = null;

/**
* Once we remove our last usage these internally in Event Tickets and Event Tickets Plus we can
* remove these from our code and keep the magic getter to be able to catch any other usage.
*
* @deprecated 6.1.0
*/
$this->menuName = $this->menu_name;
$this->requiredCap = $this->required_cap;
$this->allTabs = $this->all_tabs;
$this->defaultTab = $this->default_tab;
$this->currentTab = $this->current_tab;
$this->noSaveTabs = $this->no_save_tabs;
$this->adminSlug = $this->admin_slug;

$this->hook();
}

/**
* Magic getter for deprecated properties.
*
* @since TBD
*
* @param string $name The property name we are looking for.
*
* @return mixed
*/
public function __get( $name ) {
// Map of deprecated properties and their respective actual property names.
$properties = [
'menuName' => 'menu_name',
'requiredCap' => 'required_cap',
'allTabs' => 'all_tabs',
'defaultTab' => 'default_tab',
'currentTab' => 'current_tab',
'noSaveTabs' => 'no_save_tabs',
'adminSlug' => 'admin_slug',
];

// Check if the requested property exists in the map.
if ( isset( $properties[ $name ] ) ) {
// Trigger deprecation notice for camel-case property names.
trigger_deprecation(
__CLASS__,
'6.1.0',
'Replace the use of ' . $name . ' with ' . $properties[ $name ] . ' in your code.'
);

return $this->{$properties[ $name ]};
}

return null;
}

/**
* Hooks the actions and filters required for the class to work.
*/
Expand Down

0 comments on commit e21b1bd

Please sign in to comment.