From 9f7ab7a1876d62e6a9439b126dfcbc0e01f584ce Mon Sep 17 00:00:00 2001 From: Shady Sharaf Date: Thu, 5 Dec 2013 06:20:48 +0200 Subject: [PATCH] Add ability to define multiple url args for column link #18 --- includes/list-table.php | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/includes/list-table.php b/includes/list-table.php index 7e23980c2..74f0351ed 100644 --- a/includes/list-table.php +++ b/includes/list-table.php @@ -109,14 +109,20 @@ function get_total_found_rows() { function column_default( $item, $column_name ) { switch ( $column_name ) { case 'date': - $out = $this->column_link( 'date', date( 'Y/m/d', strtotime( $item->created ) ), date( 'Y/m/d', strtotime( $item->created ) ) ); + $out = $this->column_link( date( 'Y/m/d', strtotime( $item->created ) ), 'date', date( 'Y/m/d', strtotime( $item->created ) ) ); $out .= '
'; $out .= date( "\nh:i:s A", strtotime( $item->created ) ); break; case 'summary': if ( $item->object_id ) { - $out = $this->column_link( 'object_id', $item->object_id, $item->summary ); + $out = $this->column_link( + $item->summary, + array( + 'object_id' => $item->object_id, + 'context' => $item->context, + ) + ); } else { $out = $item->summary; } @@ -143,7 +149,7 @@ function column_default( $item, $column_name ) { case 'context': case 'action': - $out = $this->column_link( $column_name, $item->{$column_name}, WP_Stream_Connectors::$term_labels['stream_'.$column_name][$item->{$column_name}] ); + $out = $this->column_link( WP_Stream_Connectors::$term_labels['stream_'.$column_name][$item->{$column_name}], $column_name, $item->{$column_name} ); break; case 'id': @@ -151,11 +157,11 @@ function column_default( $item, $column_name ) { break; case 'ip': - $out = $this->column_link( 'ip', $item->{$column_name}, $item->{$column_name} ); + $out = $this->column_link( $item->{$column_name}, 'ip', $item->{$column_name} ); break; case 'connector': - $out = $this->column_link( 'connector', $item->connector, WP_Stream_Connectors::$term_labels['stream_connector'][$item->connector] ); + $out = $this->column_link( WP_Stream_Connectors::$term_labels['stream_connector'][$item->connector], 'connector', $item->connector ); break; default: @@ -165,8 +171,18 @@ function column_default( $item, $column_name ) { echo $out; //xss okay } - function column_link( $key, $value, $display ) { - $url = add_query_arg( $key, $value, admin_url( 'admin.php?page=wp_stream' ) ); + function column_link( $display, $key, $value = null ) { + $url = admin_url( 'admin.php?page=wp_stream' ); + + if ( ! is_array( $key ) ) { + $args = array( $key => $value ); + } else { + $args = $key; + } + foreach ( $args as $k => $v ) { + $url = add_query_arg( $k, $v, $url ); + } + return sprintf( '%s', $url,