In WP_List_Table, only call magic method internals again whitelists of properties and methods, $compat_fields and $compat_methods.

See #30891.


git-svn-id: https://develop.svn.wordpress.org/trunk@31146 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-01-11 22:19:58 +00:00
parent ad6dd738b2
commit 274253629f

View File

@ -80,6 +80,13 @@ class WP_List_Table {
*/
protected $_column_headers;
protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' );
protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions',
'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination',
'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav',
'single_row_columns' );
/**
* Constructor.
*
@ -149,7 +156,9 @@ class WP_List_Table {
* @return mixed Property.
*/
public function __get( $name ) {
return $this->$name;
if ( in_array( $name, $this->compat_fields ) ) {
return $this->$name;
}
}
/**
@ -158,12 +167,14 @@ class WP_List_Table {
* @since 4.0.0
* @access public
*
* @param string $name Property to set.
* @param string $name Property to check if set.
* @param mixed $value Property value.
* @return mixed Newly-set property.
*/
public function __set( $name, $value ) {
return $this->$name = $value;
if ( in_array( $name, $this->compat_fields ) ) {
return $this->$name = $value;
}
}
/**
@ -176,7 +187,9 @@ class WP_List_Table {
* @return bool Whether the property is set.
*/
public function __isset( $name ) {
return isset( $this->$name );
if ( in_array( $name, $this->compat_fields ) ) {
return isset( $this->$name );
}
}
/**
@ -188,7 +201,9 @@ class WP_List_Table {
* @param string $name Property to unset.
*/
public function __unset( $name ) {
unset( $this->$name );
if ( in_array( $name, $this->compat_fields ) ) {
unset( $this->$name );
}
}
/**
@ -202,7 +217,10 @@ class WP_List_Table {
* @return mixed|bool Return value of the callback, false otherwise.
*/
public function __call( $name, $arguments ) {
return call_user_func_array( array( $this, $name ), $arguments );
if ( in_array( $name, $this->compat_methods ) ) {
return call_user_func_array( array( $this, $name ), $arguments );
}
return false;
}
/**