Skip to content

Commit 152596a

Browse files
author
Luke Carbis
committed
Merge pull request #800 from xwp/bugfix/issue-793
Filtering UI Bugfix
2 parents ba6a30f + 2da3a3c commit 152596a

File tree

4 files changed

+12
-33
lines changed

4 files changed

+12
-33
lines changed

classes/class-author.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
namespace WP_Stream;
33

44
class Author {
5-
/**
6-
* Hold Plugin class
7-
* @var Plugin
8-
*/
9-
public $plugin;
10-
115
/**
126
* @var int
137
*/
@@ -36,8 +30,6 @@ function __construct( $user_id, $user_meta = array() ) {
3630
if ( $this->id ) {
3731
$this->user = new \WP_User( $this->id );
3832
}
39-
40-
$this->plugin = wp_stream_get_instance();
4133
}
4234

4335
/**
@@ -129,7 +121,8 @@ function get_avatar_img( $size = 80 ) {
129121
}
130122

131123
if ( 0 === $this->id ) {
132-
$url = $this->plugin->locations['url'] . 'ui/stream-icons/wp-cli.png';
124+
$stream = wp_stream_get_instance();
125+
$url = $stream->locations['url'] . 'ui/stream-icons/wp-cli.png';
133126
$avatar = sprintf( '<img alt="%1$s" src="%2$s" class="avatar avatar-%3$s photo" height="%3$s" width="%3$s">', esc_attr( $this->get_display_name() ), esc_url( $url ), esc_attr( $size ) );
134127
} else {
135128
if ( $this->is_deleted() && isset( $this->meta['user_email'] ) ) {
@@ -193,23 +186,6 @@ function get_role() {
193186
return $user_role;
194187
}
195188

196-
/**
197-
* Construct a URL for viewing user-specific records
198-
*
199-
* @return string
200-
*/
201-
function get_records_page_url() {
202-
$url = add_query_arg(
203-
array(
204-
'page' => $this->plugin->admin->records_page_slug,
205-
'user_id' => absint( $this->id ),
206-
),
207-
self_admin_url( $this->plugin->admin->admin_parent_page )
208-
);
209-
210-
return $url;
211-
}
212-
213189
/**
214190
* True if user no longer exists, otherwise false
215191
*

classes/class-db.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function existing_records( $column ) {
187187
}
188188

189189
$rows = $wpdb->get_results(
190-
$wpdb->prepare( "SELECT $column FROM $wpdb->stream GROUP BY %s", $column ), // @codingStandardsIgnoreLine can't prepare column name
190+
"SELECT DISTINCT $column FROM $wpdb->stream", // @codingStandardsIgnoreLine can't prepare column name
191191
'ARRAY_A'
192192
);
193193

classes/class-list-table.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,17 @@ function column_default( $item, $column_name ) {
257257
case 'user_id' :
258258
$user = new Author( (int) $record->user_id, (array) maybe_unserialize( $record->user_meta ) );
259259

260+
$filtered_records_url = add_query_arg(
261+
array(
262+
'page' => $this->plugin->admin->records_page_slug,
263+
'user_id' => absint( $user->id ),
264+
),
265+
self_admin_url( $this->plugin->admin->admin_parent_page )
266+
);
267+
260268
$out = sprintf(
261269
'<a href="%s">%s <span>%s</span></a>%s%s%s',
262-
$user->get_records_page_url(),
270+
$filtered_records_url,
263271
$user->get_avatar_img( 80 ),
264272
$user->get_display_name(),
265273
$user->is_deleted() ? sprintf( '<br /><small class="deleted">%s</small>', esc_html__( 'Deleted User', 'stream' ) ) : '',

tests/tests/test-class-author.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public function test_construct() {
3535
$this->assertNotEmpty( $this->author->id );
3636
$this->assertInternalType( 'array', $this->author->meta );
3737
$this->assertNotEmpty( $this->author->meta );
38-
$this->assertInstanceOf( '\WP_Stream\Plugin', $this->author->plugin );
3938
}
4039

4140
public function test_get() {
@@ -75,10 +74,6 @@ public function test_get_role() {
7574
$this->assertEquals( 'Administrator', $this->author->get_role() );
7675
}
7776

78-
public function test_get_records_page_url() {
79-
$this->assertNotFalse( parse_url( $this->author->get_records_page_url() ) );
80-
}
81-
8277
public function test_is_deleted() {
8378
$this->assertFalse( $this->author->is_deleted() );
8479
}

0 commit comments

Comments
 (0)