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

feat(WP_Term): added getter and setter for backwards compatibility #8191

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
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
47 changes: 47 additions & 0 deletions src/wp-includes/class-wp-term.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public function to_array() {
* Getter.
*
* @since 4.4.0
* @since 6.8.0 Added backwards compatibility aliases.
*
* @param string $key Property to get.
* @return mixed Property value.
Expand All @@ -240,6 +241,52 @@ public function __get( $key ) {
}

return sanitize_term( $data, $data->taxonomy, 'raw' );

// Backwards compatibility aliases.
case 'cat_ID':
return $this->term_id;
case 'category_count':
return $this->count;
case 'category_description':
return $this->description;
case 'cat_name':
return $this->name;
case 'category_nicename':
return $this->slug;
case 'category_parent':
return $this->parent;
}
}

/**
* Setter.
*
* @since 6.8.0
*
* @param string $key Property to set.
* @param mixed $value Property value.
*/
public function __set( $key, $value ) {
switch ( $key ) {
// Backwards compatibility aliases.
case 'cat_ID':
$this->term_id = $value;
break;
case 'category_count':
$this->count = $value;
break;
case 'category_description':
$this->description = $value;
break;
case 'cat_name':
$this->name = $value;
break;
case 'category_nicename':
$this->slug = $value;
break;
case 'category_parent':
$this->parent = $value;
break;
}
}
}
Loading