WordPress.org

Make WordPress Core

Changeset 28531


Ignore:
Timestamp:
05/19/2014 05:19:09 PM (4 years ago)
Author:
wonderboymusic
Message:

Upgrade _WP_List_Table_Compat to PHP5-style constructor.

Add public to methods/members of WP_Role.
Add public to methods/members of WP_User where appropriate. Don't set private where indicated until more study has occurred and tests have been written for compatibiliy with existing magic methods.

See #27881, #22234.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/list-table.php

    r28500 r28531  
    8888    public $_columns;
    8989
    90     public function _WP_List_Table_Compat( $screen, $columns = array() ) {
     90    public function __construct( $screen, $columns = array() ) {
    9191        if ( is_string( $screen ) )
    9292            $screen = convert_to_screen( $screen );
  • trunk/src/wp-includes/capabilities.php

    r28503 r28531  
    305305     * @var string
    306306     */
    307     var $name;
     307    public $name;
    308308
    309309    /**
     
    314314     * @var array
    315315     */
    316     var $capabilities;
     316    public $capabilities;
    317317
    318318    /**
     
    328328     * @param array $capabilities List of capabilities.
    329329     */
    330     function __construct( $role, $capabilities ) {
     330    public function __construct( $role, $capabilities ) {
    331331        $this->name = $role;
    332332        $this->capabilities = $capabilities;
     
    343343     * @param bool $grant Whether role has capability privilege.
    344344     */
    345     function add_cap( $cap, $grant = true ) {
     345    public function add_cap( $cap, $grant = true ) {
    346346        global $wp_roles;
    347347
     
    366366     * @param string $cap Capability name.
    367367     */
    368     function remove_cap( $cap ) {
     368    public function remove_cap( $cap ) {
    369369        global $wp_roles;
    370370
     
    390390     * @return bool True, if user has capability. False, if doesn't have capability.
    391391     */
    392     function has_cap( $cap ) {
     392    public function has_cap( $cap ) {
    393393        /**
    394394         * Filter which capabilities a role has.
     
    433433     * @var int
    434434     */
    435     var $ID = 0;
     435    public $ID = 0;
    436436
    437437    /**
     
    442442     * @var array
    443443     */
    444     var $caps = array();
     444    public $caps = array();
    445445
    446446    /**
     
    451451     * @var string
    452452     */
    453     var $cap_key;
     453    public $cap_key;
    454454
    455455    /**
     
    460460     * @var array
    461461     */
    462     var $roles = array();
     462    public $roles = array();
    463463
    464464    /**
     
    469469     * @var array
    470470     */
    471     var $allcaps = array();
     471    public $allcaps = array();
    472472
    473473    /**
     
    495495     * @return WP_User
    496496     */
    497     function __construct( $id = 0, $name = '', $blog_id = '' ) {
     497    public function __construct( $id = 0, $name = '', $blog_id = '' ) {
    498498        if ( ! isset( self::$back_compat_keys ) ) {
    499499            $prefix = $GLOBALS['wpdb']->prefix;
     
    536536     * @param int $blog_id Optional. The blog id to initialize for
    537537     */
    538     function init( $data, $blog_id = '' ) {
     538    public function init( $data, $blog_id = '' ) {
    539539        $this->data = $data;
    540540        $this->ID = (int) $data->ID;
     
    552552     * @return object Raw user object
    553553     */
    554     static function get_data_by( $field, $value ) {
     554    public static function get_data_by( $field, $value ) {
    555555        global $wpdb;
    556556
     
    612612     * @since 3.3.0
    613613     */
    614     function __isset( $key ) {
     614    public function __isset( $key ) {
    615615        if ( 'id' == $key ) {
    616616            _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
     
    632632     * @since 3.3.0
    633633     */
    634     function __get( $key ) {
     634    public function __get( $key ) {
    635635        if ( 'id' == $key ) {
    636636            _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
     
    658658     * @since 3.3.0
    659659     */
    660     function __set( $key, $value ) {
     660    public function __set( $key, $value ) {
    661661        if ( 'id' == $key ) {
    662662            _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
     
    676676     * @return bool True if user exists in the database, false if not.
    677677     */
    678     function exists() {
     678    public function exists() {
    679679        return ! empty( $this->ID );
    680680    }
     
    689689     * @param string $key Property
    690690     */
    691     function get( $key ) {
     691    public function get( $key ) {
    692692        return $this->__get( $key );
    693693    }
     
    702702     * @param string $key Property
    703703     */
    704     function has_prop( $key ) {
     704    public function has_prop( $key ) {
    705705        return $this->__isset( $key );
    706706    }
     
    713713     * @return array Array representation.
    714714     */
    715     function to_array() {
     715    public function to_array() {
    716716        return get_object_vars( $this->data );
    717717    }
     
    760760     * @return array List of all capabilities for the user.
    761761     */
    762     function get_role_caps() {
     762    public function get_role_caps() {
    763763        global $wp_roles;
    764764
     
    791791     * @param string $role Role name.
    792792     */
    793     function add_role( $role ) {
     793    public function add_role( $role ) {
    794794        $this->caps[$role] = true;
    795795        update_user_meta( $this->ID, $this->cap_key, $this->caps );
     
    806806     * @param string $role Role name.
    807807     */
    808     function remove_role( $role ) {
     808    public function remove_role( $role ) {
    809809        if ( !in_array($role, $this->roles) )
    810810            return;
     
    827827     * @param string $role Role name.
    828828     */
    829     function set_role( $role ) {
     829    public function set_role( $role ) {
    830830        if ( 1 == count( $this->roles ) && $role == current( $this->roles ) )
    831831            return;
     
    877877     * @return int Max Level.
    878878     */
    879     function level_reduction( $max, $item ) {
     879    public function level_reduction( $max, $item ) {
    880880        if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) {
    881881            $level = intval( $matches[1] );
     
    896896     * @access public
    897897     */
    898     function update_user_level_from_caps() {
     898    public function update_user_level_from_caps() {
    899899        global $wpdb;
    900900        $this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 );
     
    911911     * @param bool $grant Whether to grant capability to user.
    912912     */
    913     function add_cap( $cap, $grant = true ) {
     913    public function add_cap( $cap, $grant = true ) {
    914914        $this->caps[$cap] = $grant;
    915915        update_user_meta( $this->ID, $this->cap_key, $this->caps );
     
    924924     * @param string $cap Capability name.
    925925     */
    926     function remove_cap( $cap ) {
     926    public function remove_cap( $cap ) {
    927927        if ( ! isset( $this->caps[$cap] ) )
    928928            return;
     
    937937     * @access public
    938938     */
    939     function remove_all_caps() {
     939    public function remove_all_caps() {
    940940        global $wpdb;
    941941        $this->caps = array();
     
    958958     * @return bool True, if user has capability; false, if user does not have capability.
    959959     */
    960     function has_cap( $cap ) {
     960    public function has_cap( $cap ) {
    961961        if ( is_numeric( $cap ) ) {
    962962            _deprecated_argument( __FUNCTION__, '2.0', __('Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.') );
     
    10081008     * @return string
    10091009     */
    1010     function translate_level_to_cap( $level ) {
     1010    public function translate_level_to_cap( $level ) {
    10111011        return 'level_' . $level;
    10121012    }
     
    10191019     * @param int $blog_id Optional Blog ID, defaults to current blog.
    10201020     */
    1021     function for_blog( $blog_id = '' ) {
     1021    public function for_blog( $blog_id = '' ) {
    10221022        global $wpdb;
    10231023        if ( ! empty( $blog_id ) )
Note: See TracChangeset for help on using the changeset viewer.