<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[28531] trunk/src: Upgrade `_WP_List_Table_Compat` to PHP5-style constructor.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/28531">28531</a></dd>
<dt>Author</dt> <dd>wonderboymusic</dd>
<dt>Date</dt> <dd>2014-05-19 17:19:09 +0000 (Mon, 19 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 <a href="http://core.trac.wordpress.org/ticket/27881">#27881</a>, <a href="http://core.trac.wordpress.org/ticket/22234">#22234</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludeslisttablephp">trunk/src/wp-admin/includes/list-table.php</a></li>
<li><a href="#trunksrcwpincludescapabilitiesphp">trunk/src/wp-includes/capabilities.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludeslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/list-table.php (28530 => 28531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/list-table.php       2014-05-19 17:09:42 UTC (rev 28530)
+++ trunk/src/wp-admin/includes/list-table.php  2014-05-19 17:19:09 UTC (rev 28531)
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx">  public $_screen;
</span><span class="cx">  public $_columns;
</span><span class="cx"> 
</span><del>-       public function _WP_List_Table_Compat( $screen, $columns = array() ) {
</del><ins>+        public function __construct( $screen, $columns = array() ) {
</ins><span class="cx">           if ( is_string( $screen ) )
</span><span class="cx">                  $screen = convert_to_screen( $screen );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunksrcwpincludescapabilitiesphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/capabilities.php (28530 => 28531)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/capabilities.php   2014-05-19 17:09:42 UTC (rev 28530)
+++ trunk/src/wp-includes/capabilities.php      2014-05-19 17:19:09 UTC (rev 28531)
</span><span class="lines">@@ -304,7 +304,7 @@
</span><span class="cx">   * @access public
</span><span class="cx">   * @var string
</span><span class="cx">   */
</span><del>-       var $name;
</del><ins>+        public $name;
</ins><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * List of capabilities the role contains.
</span><span class="lines">@@ -313,7 +313,7 @@
</span><span class="cx">   * @access public
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><del>-       var $capabilities;
</del><ins>+        public $capabilities;
</ins><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Constructor - Set up object properties.
</span><span class="lines">@@ -327,7 +327,7 @@
</span><span class="cx">   * @param string $role Role name.
</span><span class="cx">   * @param array $capabilities List of capabilities.
</span><span class="cx">   */
</span><del>-       function __construct( $role, $capabilities ) {
</del><ins>+        public function __construct( $role, $capabilities ) {
</ins><span class="cx">           $this->name = $role;
</span><span class="cx">          $this->capabilities = $capabilities;
</span><span class="cx">  }
</span><span class="lines">@@ -342,7 +342,7 @@
</span><span class="cx">   * @param string $cap Capability name.
</span><span class="cx">   * @param bool $grant Whether role has capability privilege.
</span><span class="cx">   */
</span><del>-       function add_cap( $cap, $grant = true ) {
</del><ins>+        public function add_cap( $cap, $grant = true ) {
</ins><span class="cx">           global $wp_roles;
</span><span class="cx"> 
</span><span class="cx">          if ( ! isset( $wp_roles ) )
</span><span class="lines">@@ -365,7 +365,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @param string $cap Capability name.
</span><span class="cx">   */
</span><del>-       function remove_cap( $cap ) {
</del><ins>+        public function remove_cap( $cap ) {
</ins><span class="cx">           global $wp_roles;
</span><span class="cx"> 
</span><span class="cx">          if ( ! isset( $wp_roles ) )
</span><span class="lines">@@ -389,7 +389,7 @@
</span><span class="cx">   * @param string $cap Capability name.
</span><span class="cx">   * @return bool True, if user has capability. False, if doesn't have capability.
</span><span class="cx">   */
</span><del>-       function has_cap( $cap ) {
</del><ins>+        public function has_cap( $cap ) {
</ins><span class="cx">           /**
</span><span class="cx">           * Filter which capabilities a role has.
</span><span class="cx">           *
</span><span class="lines">@@ -432,7 +432,7 @@
</span><span class="cx">   * @access public
</span><span class="cx">   * @var int
</span><span class="cx">   */
</span><del>-       var $ID = 0;
</del><ins>+        public $ID = 0;
</ins><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * The individual capabilities the user has been given.
</span><span class="lines">@@ -441,7 +441,7 @@
</span><span class="cx">   * @access public
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><del>-       var $caps = array();
</del><ins>+        public $caps = array();
</ins><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * User metadata option name.
</span><span class="lines">@@ -450,7 +450,7 @@
</span><span class="cx">   * @access public
</span><span class="cx">   * @var string
</span><span class="cx">   */
</span><del>-       var $cap_key;
</del><ins>+        public $cap_key;
</ins><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * The roles the user is part of.
</span><span class="lines">@@ -459,7 +459,7 @@
</span><span class="cx">   * @access public
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><del>-       var $roles = array();
</del><ins>+        public $roles = array();
</ins><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * All capabilities the user has, including individual and role based.
</span><span class="lines">@@ -468,7 +468,7 @@
</span><span class="cx">   * @access public
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><del>-       var $allcaps = array();
</del><ins>+        public $allcaps = array();
</ins><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * The filter context applied to user data fields.
</span><span class="lines">@@ -494,7 +494,7 @@
</span><span class="cx">   * @param int $blog_id Optional Blog ID, defaults to current blog.
</span><span class="cx">   * @return WP_User
</span><span class="cx">   */
</span><del>-       function __construct( $id = 0, $name = '', $blog_id = '' ) {
</del><ins>+        public function __construct( $id = 0, $name = '', $blog_id = '' ) {
</ins><span class="cx">           if ( ! isset( self::$back_compat_keys ) ) {
</span><span class="cx">                  $prefix = $GLOBALS['wpdb']->prefix;
</span><span class="cx">                  self::$back_compat_keys = array(
</span><span class="lines">@@ -535,7 +535,7 @@
</span><span class="cx">   * @param object $data User DB row object
</span><span class="cx">   * @param int $blog_id Optional. The blog id to initialize for
</span><span class="cx">   */
</span><del>-       function init( $data, $blog_id = '' ) {
</del><ins>+        public function init( $data, $blog_id = '' ) {
</ins><span class="cx">           $this->data = $data;
</span><span class="cx">          $this->ID = (int) $data->ID;
</span><span class="cx"> 
</span><span class="lines">@@ -551,7 +551,7 @@
</span><span class="cx">   * @param string|int $value The field value
</span><span class="cx">   * @return object Raw user object
</span><span class="cx">   */
</span><del>-       static function get_data_by( $field, $value ) {
</del><ins>+        public static function get_data_by( $field, $value ) {
</ins><span class="cx">           global $wpdb;
</span><span class="cx"> 
</span><span class="cx">          if ( 'id' == $field ) {
</span><span class="lines">@@ -611,7 +611,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @since 3.3.0
</span><span class="cx">   */
</span><del>-       function __isset( $key ) {
</del><ins>+        public function __isset( $key ) {
</ins><span class="cx">           if ( 'id' == $key ) {
</span><span class="cx">                  _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
</span><span class="cx">                  $key = 'ID';
</span><span class="lines">@@ -631,7 +631,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @since 3.3.0
</span><span class="cx">   */
</span><del>-       function __get( $key ) {
</del><ins>+        public function __get( $key ) {
</ins><span class="cx">           if ( 'id' == $key ) {
</span><span class="cx">                  _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
</span><span class="cx">                  return $this->ID;
</span><span class="lines">@@ -657,7 +657,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @since 3.3.0
</span><span class="cx">   */
</span><del>-       function __set( $key, $value ) {
</del><ins>+        public function __set( $key, $value ) {
</ins><span class="cx">           if ( 'id' == $key ) {
</span><span class="cx">                  _deprecated_argument( 'WP_User->id', '2.1', __( 'Use <code>WP_User->ID</code> instead.' ) );
</span><span class="cx">                  $this->ID = $value;
</span><span class="lines">@@ -675,7 +675,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @return bool True if user exists in the database, false if not.
</span><span class="cx">   */
</span><del>-       function exists() {
</del><ins>+        public function exists() {
</ins><span class="cx">           return ! empty( $this->ID );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -688,7 +688,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @param string $key Property
</span><span class="cx">   */
</span><del>-       function get( $key ) {
</del><ins>+        public function get( $key ) {
</ins><span class="cx">           return $this->__get( $key );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -701,7 +701,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @param string $key Property
</span><span class="cx">   */
</span><del>-       function has_prop( $key ) {
</del><ins>+        public function has_prop( $key ) {
</ins><span class="cx">           return $this->__isset( $key );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -712,7 +712,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @return array Array representation.
</span><span class="cx">   */
</span><del>-       function to_array() {
</del><ins>+        public function to_array() {
</ins><span class="cx">           return get_object_vars( $this->data );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -759,7 +759,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @return array List of all capabilities for the user.
</span><span class="cx">   */
</span><del>-       function get_role_caps() {
</del><ins>+        public function get_role_caps() {
</ins><span class="cx">           global $wp_roles;
</span><span class="cx"> 
</span><span class="cx">          if ( ! isset( $wp_roles ) )
</span><span class="lines">@@ -790,7 +790,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @param string $role Role name.
</span><span class="cx">   */
</span><del>-       function add_role( $role ) {
</del><ins>+        public function add_role( $role ) {
</ins><span class="cx">           $this->caps[$role] = true;
</span><span class="cx">          update_user_meta( $this->ID, $this->cap_key, $this->caps );
</span><span class="cx">          $this->get_role_caps();
</span><span class="lines">@@ -805,7 +805,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @param string $role Role name.
</span><span class="cx">   */
</span><del>-       function remove_role( $role ) {
</del><ins>+        public function remove_role( $role ) {
</ins><span class="cx">           if ( !in_array($role, $this->roles) )
</span><span class="cx">                  return;
</span><span class="cx">          unset( $this->caps[$role] );
</span><span class="lines">@@ -826,7 +826,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @param string $role Role name.
</span><span class="cx">   */
</span><del>-       function set_role( $role ) {
</del><ins>+        public function set_role( $role ) {
</ins><span class="cx">           if ( 1 == count( $this->roles ) && $role == current( $this->roles ) )
</span><span class="cx">                  return;
</span><span class="cx"> 
</span><span class="lines">@@ -876,7 +876,7 @@
</span><span class="cx">   * @param string $item Level capability name.
</span><span class="cx">   * @return int Max Level.
</span><span class="cx">   */
</span><del>-       function level_reduction( $max, $item ) {
</del><ins>+        public function level_reduction( $max, $item ) {
</ins><span class="cx">           if ( preg_match( '/^level_(10|[0-9])$/i', $item, $matches ) ) {
</span><span class="cx">                  $level = intval( $matches[1] );
</span><span class="cx">                  return max( $max, $level );
</span><span class="lines">@@ -895,7 +895,7 @@
</span><span class="cx">   * @since 2.0.0
</span><span class="cx">   * @access public
</span><span class="cx">   */
</span><del>-       function update_user_level_from_caps() {
</del><ins>+        public function update_user_level_from_caps() {
</ins><span class="cx">           global $wpdb;
</span><span class="cx">          $this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 );
</span><span class="cx">          update_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level', $this->user_level );
</span><span class="lines">@@ -910,7 +910,7 @@
</span><span class="cx">   * @param string $cap Capability name.
</span><span class="cx">   * @param bool $grant Whether to grant capability to user.
</span><span class="cx">   */
</span><del>-       function add_cap( $cap, $grant = true ) {
</del><ins>+        public function add_cap( $cap, $grant = true ) {
</ins><span class="cx">           $this->caps[$cap] = $grant;
</span><span class="cx">          update_user_meta( $this->ID, $this->cap_key, $this->caps );
</span><span class="cx">  }
</span><span class="lines">@@ -923,7 +923,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @param string $cap Capability name.
</span><span class="cx">   */
</span><del>-       function remove_cap( $cap ) {
</del><ins>+        public function remove_cap( $cap ) {
</ins><span class="cx">           if ( ! isset( $this->caps[$cap] ) )
</span><span class="cx">                  return;
</span><span class="cx">          unset( $this->caps[$cap] );
</span><span class="lines">@@ -936,7 +936,7 @@
</span><span class="cx">   * @since 2.1.0
</span><span class="cx">   * @access public
</span><span class="cx">   */
</span><del>-       function remove_all_caps() {
</del><ins>+        public function remove_all_caps() {
</ins><span class="cx">           global $wpdb;
</span><span class="cx">          $this->caps = array();
</span><span class="cx">          delete_user_meta( $this->ID, $this->cap_key );
</span><span class="lines">@@ -957,7 +957,7 @@
</span><span class="cx">   * @param string|int $cap Capability or role name to search.
</span><span class="cx">   * @return bool True, if user has capability; false, if user does not have capability.
</span><span class="cx">   */
</span><del>-       function has_cap( $cap ) {
</del><ins>+        public function has_cap( $cap ) {
</ins><span class="cx">           if ( is_numeric( $cap ) ) {
</span><span class="cx">                  _deprecated_argument( __FUNCTION__, '2.0', __('Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.') );
</span><span class="cx">                  $cap = $this->translate_level_to_cap( $cap );
</span><span class="lines">@@ -1007,7 +1007,7 @@
</span><span class="cx">   * @param int $level Level number, 1 to 10.
</span><span class="cx">   * @return string
</span><span class="cx">   */
</span><del>-       function translate_level_to_cap( $level ) {
</del><ins>+        public function translate_level_to_cap( $level ) {
</ins><span class="cx">           return 'level_' . $level;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -1018,7 +1018,7 @@
</span><span class="cx">   *
</span><span class="cx">   * @param int $blog_id Optional Blog ID, defaults to current blog.
</span><span class="cx">   */
</span><del>-       function for_blog( $blog_id = '' ) {
</del><ins>+        public function for_blog( $blog_id = '' ) {
</ins><span class="cx">           global $wpdb;
</span><span class="cx">          if ( ! empty( $blog_id ) )
</span><span class="cx">                  $cap_key = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
</span></span></pre>
</div>
</div>

</body>
</html>