From ab6d069f59c094d45959669263ad64ad0b23bd03 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 19 May 2014 15:48:15 +0000 Subject: [PATCH] Add access modifiers to `WP_User_Query`. Add magic methods for BC: __get(), __set(), __isset(), __unset(), and __call(). See #27881, #22234. Built from https://develop.svn.wordpress.org/trunk@28528 git-svn-id: http://core.svn.wordpress.org/trunk@28354 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/user.php | 89 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 16 deletions(-) diff --git a/wp-includes/user.php b/wp-includes/user.php index 7952a5ccfc..3da96815cb 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -449,7 +449,7 @@ class WP_User_Query { * @access public * @var array */ - var $query_vars = array(); + public $query_vars = array(); /** * List of found user ids @@ -458,7 +458,7 @@ class WP_User_Query { * @access private * @var array */ - var $results; + private $results; /** * Total number of found users for the current query @@ -467,14 +467,14 @@ class WP_User_Query { * @access private * @var int */ - var $total_users = 0; + private $total_users = 0; // SQL clauses - var $query_fields; - var $query_from; - var $query_where; - var $query_orderby; - var $query_limit; + public $query_fields; + public $query_from; + public $query_where; + public $query_orderby; + public $query_limit; /** * PHP5 constructor. @@ -484,7 +484,7 @@ class WP_User_Query { * @param string|array $args Optional. The query variables. * @return WP_User_Query */ - function __construct( $query = null ) { + public function __construct( $query = null ) { if ( ! empty( $query ) ) { $this->prepare_query( $query ); $this->query(); @@ -498,7 +498,7 @@ class WP_User_Query { * * @param string|array $args Optional. The query variables. */ - function prepare_query( $query = array() ) { + public function prepare_query( $query = array() ) { global $wpdb; if ( empty( $this->query_vars ) || ! empty( $query ) ) { @@ -712,7 +712,7 @@ class WP_User_Query { * * @global wpdb $wpdb WordPress database object for queries. */ - function query() { + public function query() { global $wpdb; $qv =& $this->query_vars; @@ -764,7 +764,7 @@ class WP_User_Query { * @param string $query_var Query variable key. * @return mixed */ - function get( $query_var ) { + public function get( $query_var ) { if ( isset( $this->query_vars[$query_var] ) ) return $this->query_vars[$query_var]; @@ -780,7 +780,7 @@ class WP_User_Query { * @param string $query_var Query variable key. * @param mixed $value Query variable value. */ - function set( $query_var, $value ) { + public function set( $query_var, $value ) { $this->query_vars[$query_var] = $value; } @@ -796,7 +796,7 @@ class WP_User_Query { * single site. Single site allows leading and trailing wildcards, Network Admin only trailing. * @return string */ - function get_search_sql( $string, $cols, $wild = false ) { + protected function get_search_sql( $string, $cols, $wild = false ) { $string = esc_sql( $string ); $searches = array(); @@ -820,7 +820,7 @@ class WP_User_Query { * * @return array Array of results. */ - function get_results() { + public function get_results() { return $this->results; } @@ -832,9 +832,66 @@ class WP_User_Query { * * @return array Array of total users. */ - function get_total() { + public function get_total() { return $this->total_users; } + + /** + * Make private properties readable for backwards compatibility + * + * @since 4.0.0 + * @param string $name + * @return mixed + */ + public function __get( $name ) { + return $this->$name; + } + + /** + * Make private properties setable for backwards compatibility + * + * @since 4.0.0 + * @param string $name + * @param string $value + * @return mixed + */ + public function __set( $name, $value ) { + return $this->$name = $value; + } + + /** + * Make private properties checkable for backwards compatibility + * + * @since 4.0.0 + * @param string $name + * @return mixed + */ + public function __isset( $name ) { + return isset( $this->$name ); + } + + /** + * Make private properties unsetable for backwards compatibility + * + * @since 4.0.0 + * @param string $name + * @return mixed + */ + public function __unset( $name ) { + unset( $this->$name ); + } + + /** + * Make private/protected methods readable for backwards compatibility + * + * @since 4.0.0 + * @param string $name + * @param array $arguments + * @return mixed + */ + public function __call( $name, $arguments ) { + return call_user_func_array( array( $this, $name ), $arguments ); + } } /**