Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering UI Bugfix #800

Merged
merged 3 commits into from
Nov 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions classes/class-author.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
namespace WP_Stream;

class Author {
/**
* Hold Plugin class
* @var Plugin
*/
public $plugin;

/**
* @var int
*/
Expand Down Expand Up @@ -36,8 +30,6 @@ function __construct( $user_id, $user_meta = array() ) {
if ( $this->id ) {
$this->user = new \WP_User( $this->id );
}

$this->plugin = wp_stream_get_instance();
}

/**
Expand Down Expand Up @@ -129,7 +121,8 @@ function get_avatar_img( $size = 80 ) {
}

if ( 0 === $this->id ) {
$url = $this->plugin->locations['url'] . 'ui/stream-icons/wp-cli.png';
$stream = wp_stream_get_instance();
$url = $stream->locations['url'] . 'ui/stream-icons/wp-cli.png';
$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 ) );
} else {
if ( $this->is_deleted() && isset( $this->meta['user_email'] ) ) {
Expand Down Expand Up @@ -193,23 +186,6 @@ function get_role() {
return $user_role;
}

/**
* Construct a URL for viewing user-specific records
*
* @return string
*/
function get_records_page_url() {
$url = add_query_arg(
array(
'page' => $this->plugin->admin->records_page_slug,
'user_id' => absint( $this->id ),
),
self_admin_url( $this->plugin->admin->admin_parent_page )
);

return $url;
}

/**
* True if user no longer exists, otherwise false
*
Expand Down
2 changes: 1 addition & 1 deletion classes/class-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function existing_records( $column ) {
}

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

Expand Down
10 changes: 9 additions & 1 deletion classes/class-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,17 @@ function column_default( $item, $column_name ) {
case 'user_id' :
$user = new Author( (int) $record->user_id, (array) maybe_unserialize( $record->user_meta ) );

$filtered_records_url = add_query_arg(
array(
'page' => $this->plugin->admin->records_page_slug,
'user_id' => absint( $user->id ),
),
self_admin_url( $this->plugin->admin->admin_parent_page )
);

$out = sprintf(
'<a href="%s">%s <span>%s</span></a>%s%s%s',
$user->get_records_page_url(),
$filtered_records_url,
$user->get_avatar_img( 80 ),
$user->get_display_name(),
$user->is_deleted() ? sprintf( '<br /><small class="deleted">%s</small>', esc_html__( 'Deleted User', 'stream' ) ) : '',
Expand Down
5 changes: 0 additions & 5 deletions tests/tests/test-class-author.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public function test_construct() {
$this->assertNotEmpty( $this->author->id );
$this->assertInternalType( 'array', $this->author->meta );
$this->assertNotEmpty( $this->author->meta );
$this->assertInstanceOf( '\WP_Stream\Plugin', $this->author->plugin );
}

public function test_get() {
Expand Down Expand Up @@ -75,10 +74,6 @@ public function test_get_role() {
$this->assertEquals( 'Administrator', $this->author->get_role() );
}

public function test_get_records_page_url() {
$this->assertNotFalse( parse_url( $this->author->get_records_page_url() ) );
}

public function test_is_deleted() {
$this->assertFalse( $this->author->is_deleted() );
}
Expand Down