From 2008f9234fa2b2807e6230f87954a8bd82d27667 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Thu, 27 Feb 2014 16:47:30 -0600 Subject: [PATCH 01/42] Use readonly input for stream feeds key field in profile --- includes/feeds.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/feeds.php b/includes/feeds.php index e4edc39ec..1bd92b9c3 100644 --- a/includes/feeds.php +++ b/includes/feeds.php @@ -70,10 +70,10 @@ public static function user_feed_key( $user ) { ?> - +

- +

From 975c457cb1139ec07d6bbca980fc3132d560e7db Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Thu, 27 Feb 2014 16:48:05 -0600 Subject: [PATCH 02/42] Use field highlighter in link to user profile --- includes/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/settings.php b/includes/settings.php index 52e2a5ae7..457cc570a 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -97,7 +97,7 @@ public static function get_fields() { __( 'Users from the selected roles above will be given a private key found in their %suser profile%s to access feeds of Stream Records securely.', 'stream' ), sprintf( '', - admin_url( 'profile.php' ), + admin_url( sprintf( 'profile.php#wp-stream-highlight:%s', WP_Stream_Feeds::USER_FEED_KEY ) ), esc_attr__( 'View Profile', 'stream' ) ), '' From 154bc8a32182f3968ed2eaad34a210e7589b6535 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Thu, 27 Feb 2014 16:55:41 -0600 Subject: [PATCH 03/42] Use highlighter in URL after generating a new key --- includes/feeds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/feeds.php b/includes/feeds.php index 1bd92b9c3..b605f873e 100644 --- a/includes/feeds.php +++ b/includes/feeds.php @@ -74,7 +74,7 @@ public static function user_feed_key( $user ) {

- +

From 7e7e09ba74abe67be07af8a9d0732329d3395494 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 09:54:03 -0800 Subject: [PATCH 04/42] Add dashboard pagination rudimentary workings --- includes/admin.php | 117 +++++++++++++++++++++++++++++++++++++++++---- ui/dashboard.js | 21 ++++++++ 2 files changed, 129 insertions(+), 9 deletions(-) create mode 100644 ui/dashboard.js diff --git a/includes/admin.php b/includes/admin.php index 4b5482a74..76943006f 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -56,6 +56,9 @@ public static function load() { // Load Dashboard widget add_action( 'wp_dashboard_setup', array( __CLASS__, 'dashboard_stream_activity' ) ); + + // Dashboard AJAX pagination + add_action( 'wp_ajax_stream_dashboard_update', array( __CLASS__, 'dashboard_stream_activity_update_contents' ) ); // Heartbeat live update add_filter( 'heartbeat_received', array( __CLASS__, 'live_update' ), 10, 2 ); @@ -143,6 +146,11 @@ public static function admin_enqueue_scripts( $hook ) { wp_enqueue_style( 'wp-stream-admin', WP_STREAM_URL . 'ui/admin.css', array() ); + if ( ! in_array( $hook, self::$screen_id ) && 'dashboard.php' !== $hook ) { + wp_enqueue_script( 'wp-stream-admin-dashboard', WP_STREAM_URL . 'ui/dashboard.js', array( 'jquery' ) ); + return; + } + if ( ! in_array( $hook, self::$screen_id ) && 'plugins.php' !== $hook ) { return; } @@ -504,19 +512,41 @@ public static function dashboard_stream_activity() { wp_add_dashboard_widget( 'dashboard_stream_activity', __( 'Stream Activity', 'stream' ), - array( __CLASS__, 'dashboard_stream_activity_contents' ), + array( __CLASS__, 'dashboard_stream_activity_initial_contents' ), array( __CLASS__, 'dashboard_stream_activity_options' ) ); } + public static function dashboard_get_total_found_rows(){ + global $wpdb; + return $wpdb->get_var( 'SELECT FOUND_ROWS()' ); + } + + public static function dashboard_stream_activity_initial_contents(){ + self::dashboard_stream_activity_contents(); + } + + public static function dashboard_stream_activity_update_contents(){ + + if( ! empty( $_POST['stream-paged'] ) ){ + $paged = absint( $_POST['stream-paged'] ); + }else{ + $paged = 1; + } + + self::dashboard_stream_activity_contents( $paged ); + die; + } + /** * Contents of the Stream Activity dashboard widget */ - public static function dashboard_stream_activity_contents() { - $options = get_option( 'dashboard_stream_activity_options', array() ); + public static function dashboard_stream_activity_contents( $paged = 1 ) { + $options = get_option( 'dashboard_stream_activity_options', array() ); $args = array( 'records_per_page' => isset( $options['records_per_page'] ) ? absint( $options['records_per_page'] ) : 5, + 'paged' => $paged ); $records = stream_query( $args ); @@ -581,12 +611,81 @@ public static function dashboard_stream_activity_contents() { echo ''; - echo sprintf( - '

', - esc_url( $records_link ), - esc_attr__( 'View all Stream Records', 'stream' ), - esc_html__( 'More', 'stream' ) - ); // xss ok + $total_items = self::dashboard_get_total_found_rows(); + $args = array( + 'total_pages' => ceil( $total_items / $options['records_per_page'] ), + 'current' => $paged + ); + + self::dashboard_pagination( $args ); + } + + /* + * Display pagination links for Dashboard Widget + * Copied from private class WP_List_Table::pagination() + */ + public static function dashboard_pagination( $args = array() ){ + + $args = wp_parse_args( $args, array( + 'current' => 1, + 'total_pages' => 1 + + ) ); + extract( $args ); + + $records_link = add_query_arg( + array( 'page' => self::RECORDS_PAGE_SLUG ), + admin_url( self::ADMIN_PARENT_PAGE ) + ); + + $page_links = array(); + $output = ''; + $disable_first = $disable_last = ''; + if ( $current == 1 ){ + $disable_first = ' disabled'; + } + if ( $current == $total_pages ){ + $disable_last = ' disabled'; + } + + $page_links[] = sprintf( "%s", + 'first-page' . $disable_first, + esc_attr__( 'Go to the first page' ), + esc_url( remove_query_arg( 'paged', $records_link ) ), + '«' + ); + + $page_links[] = sprintf( "%s", + 'prev-page' . $disable_first, + esc_attr__( 'Go to the previous page' ), + esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $records_link ) ), + max( 1, $current-1), + '‹' + ); + + $html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) ); + $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging' ), $current, $html_total_pages ) . ''; + + $page_links[] = sprintf( "%s", + 'next-page' . $disable_last, + esc_attr__( 'Go to the next page' ), + esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $records_link ) ), + min( $total_pages, $current+1 ), + '›' + ); + + $page_links[] = sprintf( "%s", + 'last-page' . $disable_last, + esc_attr__( 'Go to the last page' ), + esc_url( add_query_arg( 'paged', $total_pages, $records_link ) ), + $total_pages, + '»' + ); + + $pagination_links_class = 'pagination-links'; + $output .= "\n" . join( "\n", $page_links ) . ''; + + echo "
$output
"; } /** diff --git a/ui/dashboard.js b/ui/dashboard.js new file mode 100644 index 000000000..82785f8e1 --- /dev/null +++ b/ui/dashboard.js @@ -0,0 +1,21 @@ +/* dashboard pagination */ +jQuery(function($){ + + var dashboardBind = function(){ + $( '#dashboard_stream_activity .pagination-links a').click(function(e){ + e.preventDefault(); + var data = { + 'action' : 'stream_dashboard_update', + 'stream-paged' : $(this).data('page'), + }; + + $.post( ajaxurl, data, function( response ){ + $( '#dashboard_stream_activity .inside' ).html( response ); + dashboardBind(); + } ); + } ); + }; + + dashboardBind(); + +}); From 5e0a47ac638a78d67967a4b2c433f12378f95008 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 10:35:47 -0800 Subject: [PATCH 05/42] Add CSS Styling and cleanup text domains --- includes/admin.php | 23 +++++++++++++++-------- ui/admin.css | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 76943006f..2217e96df 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -638,8 +638,14 @@ public static function dashboard_pagination( $args = array() ){ admin_url( self::ADMIN_PARENT_PAGE ) ); + $html_view_all = sprintf( "%s", + 'view-all', + esc_attr__( 'View all records', 'stream' ), + esc_url( $records_link ), + __( 'View All', 'stream' ) + ); + $page_links = array(); - $output = ''; $disable_first = $disable_last = ''; if ( $current == 1 ){ $disable_first = ' disabled'; @@ -650,25 +656,25 @@ public static function dashboard_pagination( $args = array() ){ $page_links[] = sprintf( "%s", 'first-page' . $disable_first, - esc_attr__( 'Go to the first page' ), + esc_attr__( 'Go to the first page', 'stream' ), esc_url( remove_query_arg( 'paged', $records_link ) ), '«' ); $page_links[] = sprintf( "%s", 'prev-page' . $disable_first, - esc_attr__( 'Go to the previous page' ), + esc_attr__( 'Go to the previous page', 'stream' ), esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $records_link ) ), max( 1, $current-1), '‹' ); $html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) ); - $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging' ), $current, $html_total_pages ) . ''; + $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging', 'stream' ), $current, $html_total_pages ) . ''; $page_links[] = sprintf( "%s", 'next-page' . $disable_last, - esc_attr__( 'Go to the next page' ), + esc_attr__( 'Go to the next page', 'stream' ), esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $records_link ) ), min( $total_pages, $current+1 ), '›' @@ -676,16 +682,17 @@ public static function dashboard_pagination( $args = array() ){ $page_links[] = sprintf( "%s", 'last-page' . $disable_last, - esc_attr__( 'Go to the last page' ), + esc_attr__( 'Go to the last page', 'stream' ), esc_url( add_query_arg( 'paged', $total_pages, $records_link ) ), $total_pages, '»' ); $pagination_links_class = 'pagination-links'; - $output .= "\n" . join( "\n", $page_links ) . ''; + $output = "\n'; + - echo "
$output
"; + echo "
$html_view_all $output
"; } /** diff --git a/ui/admin.css b/ui/admin.css index b1a93ab69..02cfef13c 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -45,6 +45,37 @@ padding: 12px; } +#dashboard_stream_activity .pagination-links { + height: 23px; + margin: 6px 0px 4px; + padding: 10px; + vertical-align: middle; +} +#dashboard_stream_activity .pagination-links a { + background: #eee; + background: rgba( 0, 0, 0, 0.05 ); + color: #777; + font-weight: 600; + margin-right: 1px; + font-size: 16px; + padding: 0 10px 3px; +} + +#dashboard_stream_activity .current-page{ + padding-top: 0; + text-align: center; +} + +#dashboard_stream_activity .next-page{ + margin-left: 2px; +} + +#dashboard_stream_activity .view-all{ + float: right; + padding: 0 10px 3px; + margin-top: 11px; +} + .toplevel_page_wp_stream .tablenav { padding-top: 6px; } From d534044661688e6af6c643f45286c11c4d95deae Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 10:38:19 -0800 Subject: [PATCH 06/42] Standardize hook names --- includes/admin.php | 2 +- ui/dashboard.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 2217e96df..261e05e9f 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -58,7 +58,7 @@ public static function load() { add_action( 'wp_dashboard_setup', array( __CLASS__, 'dashboard_stream_activity' ) ); // Dashboard AJAX pagination - add_action( 'wp_ajax_stream_dashboard_update', array( __CLASS__, 'dashboard_stream_activity_update_contents' ) ); + add_action( 'wp_ajax_stream_activity_dashboard_update', array( __CLASS__, 'dashboard_stream_activity_update_contents' ) ); // Heartbeat live update add_filter( 'heartbeat_received', array( __CLASS__, 'live_update' ), 10, 2 ); diff --git a/ui/dashboard.js b/ui/dashboard.js index 82785f8e1..45bd41bde 100644 --- a/ui/dashboard.js +++ b/ui/dashboard.js @@ -5,7 +5,7 @@ jQuery(function($){ $( '#dashboard_stream_activity .pagination-links a').click(function(e){ e.preventDefault(); var data = { - 'action' : 'stream_dashboard_update', + 'action' : 'stream_activity_dashboard_update', 'stream-paged' : $(this).data('page'), }; From 05a7e256f0377e33c7797cc59f21cab1313fda5e Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 10:54:31 -0800 Subject: [PATCH 07/42] Cleaned up syntax --- includes/admin.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 261e05e9f..9efdca4cc 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -528,9 +528,9 @@ public static function dashboard_stream_activity_initial_contents(){ public static function dashboard_stream_activity_update_contents(){ - if( ! empty( $_POST['stream-paged'] ) ){ + if ( ! empty( $_POST['stream-paged'] ) ) { $paged = absint( $_POST['stream-paged'] ); - }else{ + } else { $paged = 1; } @@ -614,7 +614,7 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) { $total_items = self::dashboard_get_total_found_rows(); $args = array( 'total_pages' => ceil( $total_items / $options['records_per_page'] ), - 'current' => $paged + 'current' => $paged, ); self::dashboard_pagination( $args ); @@ -626,10 +626,11 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) { */ public static function dashboard_pagination( $args = array() ){ - $args = wp_parse_args( $args, array( - 'current' => 1, - 'total_pages' => 1 - + $args = wp_parse_args( + $args, + array( + 'current' => 1, + 'total_pages' => 1 ) ); extract( $args ); @@ -664,8 +665,8 @@ public static function dashboard_pagination( $args = array() ){ $page_links[] = sprintf( "%s", 'prev-page' . $disable_first, esc_attr__( 'Go to the previous page', 'stream' ), - esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $records_link ) ), - max( 1, $current-1), + esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $records_link ) ), + max( 1, $current - 1), '‹' ); @@ -675,8 +676,8 @@ public static function dashboard_pagination( $args = array() ){ $page_links[] = sprintf( "%s", 'next-page' . $disable_last, esc_attr__( 'Go to the next page', 'stream' ), - esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $records_link ) ), - min( $total_pages, $current+1 ), + esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $records_link ) ), + min( $total_pages, $current + 1 ), '›' ); From 3f8a208869b82cba0a7883711c3f0ccde2db4fe2 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 10:59:05 -0800 Subject: [PATCH 08/42] Cleaned up sprintf syntax. Renamed variable for clairity --- includes/admin.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 9efdca4cc..e68aa1460 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -546,7 +546,7 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) { $options = get_option( 'dashboard_stream_activity_options', array() ); $args = array( 'records_per_page' => isset( $options['records_per_page'] ) ? absint( $options['records_per_page'] ) : 5, - 'paged' => $paged + 'paged' => $paged, ); $records = stream_query( $args ); @@ -630,8 +630,9 @@ public static function dashboard_pagination( $args = array() ){ $args, array( 'current' => 1, - 'total_pages' => 1 - ) ); + 'total_pages' => 1, + ) + ); extract( $args ); $records_link = add_query_arg( @@ -639,7 +640,8 @@ public static function dashboard_pagination( $args = array() ){ admin_url( self::ADMIN_PARENT_PAGE ) ); - $html_view_all = sprintf( "%s", + $html_view_all = sprintf( + "%s", 'view-all', esc_attr__( 'View all records', 'stream' ), esc_url( $records_link ), @@ -655,14 +657,16 @@ public static function dashboard_pagination( $args = array() ){ $disable_last = ' disabled'; } - $page_links[] = sprintf( "%s", + $page_links[] = sprintf( + "%s", 'first-page' . $disable_first, esc_attr__( 'Go to the first page', 'stream' ), esc_url( remove_query_arg( 'paged', $records_link ) ), '«' ); - $page_links[] = sprintf( "%s", + $page_links[] = sprintf( + "%s", 'prev-page' . $disable_first, esc_attr__( 'Go to the previous page', 'stream' ), esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $records_link ) ), @@ -673,7 +677,8 @@ public static function dashboard_pagination( $args = array() ){ $html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) ); $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging', 'stream' ), $current, $html_total_pages ) . ''; - $page_links[] = sprintf( "%s", + $page_links[] = sprintf( + "%s", 'next-page' . $disable_last, esc_attr__( 'Go to the next page', 'stream' ), esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $records_link ) ), @@ -681,7 +686,8 @@ public static function dashboard_pagination( $args = array() ){ '›' ); - $page_links[] = sprintf( "%s", + $page_links[] = sprintf( + "%s", 'last-page' . $disable_last, esc_attr__( 'Go to the last page', 'stream' ), esc_url( add_query_arg( 'paged', $total_pages, $records_link ) ), @@ -690,10 +696,9 @@ public static function dashboard_pagination( $args = array() ){ ); $pagination_links_class = 'pagination-links'; - $output = "\n'; - + $html_pagination_links = "\n'; - echo "
$html_view_all $output
"; + echo '
' . $html_view_all . $html_pagination_links . '
'; } /** From 844b1e5bbf7509aa3f68f865f7a553dbaf929e79 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 11:04:44 -0800 Subject: [PATCH 09/42] Remove whitespace after multi-line function calls --- includes/admin.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index e68aa1460..005e3d0fd 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -626,7 +626,7 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) { */ public static function dashboard_pagination( $args = array() ){ - $args = wp_parse_args( + $args = wp_parse_args( $args, array( 'current' => 1, @@ -640,7 +640,7 @@ public static function dashboard_pagination( $args = array() ){ admin_url( self::ADMIN_PARENT_PAGE ) ); - $html_view_all = sprintf( + $html_view_all = sprintf( "%s", 'view-all', esc_attr__( 'View all records', 'stream' ), @@ -657,7 +657,7 @@ public static function dashboard_pagination( $args = array() ){ $disable_last = ' disabled'; } - $page_links[] = sprintf( + $page_links[] = sprintf( "%s", 'first-page' . $disable_first, esc_attr__( 'Go to the first page', 'stream' ), @@ -670,14 +670,14 @@ public static function dashboard_pagination( $args = array() ){ 'prev-page' . $disable_first, esc_attr__( 'Go to the previous page', 'stream' ), esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $records_link ) ), - max( 1, $current - 1), + max( 1, $current - 1 ), '‹' ); $html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) ); $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging', 'stream' ), $current, $html_total_pages ) . ''; - $page_links[] = sprintf( + $page_links[] = sprintf( "%s", 'next-page' . $disable_last, esc_attr__( 'Go to the next page', 'stream' ), @@ -686,7 +686,7 @@ public static function dashboard_pagination( $args = array() ){ '›' ); - $page_links[] = sprintf( + $page_links[] = sprintf( "%s", 'last-page' . $disable_last, esc_attr__( 'Go to the last page', 'stream' ), From 736b25b3c2322437fb18c551e38e9d4151559c84 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 11:17:08 -0800 Subject: [PATCH 10/42] Switch to use .tablenav CSS. Remove potential for undefined index error. --- includes/admin.php | 8 ++++---- ui/admin.css | 30 +++++------------------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 005e3d0fd..a9a9201cc 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -544,8 +544,9 @@ public static function dashboard_stream_activity_update_contents(){ public static function dashboard_stream_activity_contents( $paged = 1 ) { $options = get_option( 'dashboard_stream_activity_options', array() ); + $records_per_page = isset( $options['record_per_page'] ) ? absint( $options['records_per_page'] ) : 5; $args = array( - 'records_per_page' => isset( $options['records_per_page'] ) ? absint( $options['records_per_page'] ) : 5, + 'records_per_page' => $records_per_page, 'paged' => $paged, ); $records = stream_query( $args ); @@ -613,7 +614,7 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) { $total_items = self::dashboard_get_total_found_rows(); $args = array( - 'total_pages' => ceil( $total_items / $options['records_per_page'] ), + 'total_pages' => ceil( $total_items / $records_per_page ), 'current' => $paged, ); @@ -695,8 +696,7 @@ public static function dashboard_pagination( $args = array() ){ '»' ); - $pagination_links_class = 'pagination-links'; - $html_pagination_links = "\n'; + $html_pagination_links = "\n
" . join( "\n", $page_links ) . '
'; echo '
' . $html_view_all . $html_pagination_links . '
'; } diff --git a/ui/admin.css b/ui/admin.css index 02cfef13c..1ef336206 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -45,35 +45,15 @@ padding: 12px; } -#dashboard_stream_activity .pagination-links { - height: 23px; - margin: 6px 0px 4px; - padding: 10px; - vertical-align: middle; -} -#dashboard_stream_activity .pagination-links a { - background: #eee; - background: rgba( 0, 0, 0, 0.05 ); - color: #777; - font-weight: 600; - margin-right: 1px; - font-size: 16px; - padding: 0 10px 3px; -} - -#dashboard_stream_activity .current-page{ - padding-top: 0; - text-align: center; -} - -#dashboard_stream_activity .next-page{ - margin-left: 2px; +#dashboard_stream_activity .tablenav{ + clear: none; + padding-right: 5px; } #dashboard_stream_activity .view-all{ - float: right; + float: left; padding: 0 10px 3px; - margin-top: 11px; + margin-top: 5px; } .toplevel_page_wp_stream .tablenav { From 27ff40c7e6b6a9a2d2ce7c89576a3fd7b853107b Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 11:24:38 -0800 Subject: [PATCH 11/42] Switch to yoda conditionals as well as using identical comparison operators --- includes/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index a9a9201cc..671f1f709 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -651,10 +651,10 @@ public static function dashboard_pagination( $args = array() ){ $page_links = array(); $disable_first = $disable_last = ''; - if ( $current == 1 ){ + if ( 1 === $current ){ $disable_first = ' disabled'; } - if ( $current == $total_pages ){ + if ( $current === $total_pages ){ $disable_last = ' disabled'; } From fb6e52ca4e886c2f8ee3237cc36d9cf8708413f2 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 11:28:02 -0800 Subject: [PATCH 12/42] Fix whitespace --- includes/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin.php b/includes/admin.php index 671f1f709..9c6c7496b 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -666,7 +666,7 @@ public static function dashboard_pagination( $args = array() ){ '«' ); - $page_links[] = sprintf( + $page_links[] = sprintf( "%s", 'prev-page' . $disable_first, esc_attr__( 'Go to the previous page', 'stream' ), From a0933d4fde355367bb47144a6eead7ae8e0e18b1 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 11:41:33 -0800 Subject: [PATCH 13/42] Fixing unit tests for whitespace --- includes/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 9c6c7496b..4df1e7fb7 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -649,7 +649,7 @@ public static function dashboard_pagination( $args = array() ){ __( 'View All', 'stream' ) ); - $page_links = array(); + $page_links = array(); $disable_first = $disable_last = ''; if ( 1 === $current ){ $disable_first = ' disabled'; @@ -676,7 +676,7 @@ public static function dashboard_pagination( $args = array() ){ ); $html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) ); - $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging', 'stream' ), $current, $html_total_pages ) . ''; + $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging', 'stream' ), $current, $html_total_pages ) . ''; $page_links[] = sprintf( "%s", From ef27822cbcc7b36ff6e98d94ecff91b485e65ca6 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 11:48:29 -0800 Subject: [PATCH 14/42] Put spaces before equal sign, not after. --- includes/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 4df1e7fb7..2f8bc4377 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -649,7 +649,7 @@ public static function dashboard_pagination( $args = array() ){ __( 'View All', 'stream' ) ); - $page_links = array(); + $page_links = array(); $disable_first = $disable_last = ''; if ( 1 === $current ){ $disable_first = ' disabled'; @@ -676,7 +676,7 @@ public static function dashboard_pagination( $args = array() ){ ); $html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) ); - $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging', 'stream' ), $current, $html_total_pages ) . ''; + $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging', 'stream' ), $current, $html_total_pages ) . ''; $page_links[] = sprintf( "%s", From 53d6d33315939ab003cb9daee93ee27ae64808b7 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Fri, 28 Feb 2014 11:51:21 -0800 Subject: [PATCH 15/42] Remove whitespace. Reference window.ajaxurl instead of ajaxurl --- ui/dashboard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/dashboard.js b/ui/dashboard.js index 45bd41bde..2cfc2f8ae 100644 --- a/ui/dashboard.js +++ b/ui/dashboard.js @@ -1,5 +1,5 @@ /* dashboard pagination */ -jQuery(function($){ +jQuery(function($){ var dashboardBind = function(){ $( '#dashboard_stream_activity .pagination-links a').click(function(e){ @@ -9,7 +9,7 @@ jQuery(function($){ 'stream-paged' : $(this).data('page'), }; - $.post( ajaxurl, data, function( response ){ + $.post( window.ajaxurl, data, function( response ){ $( '#dashboard_stream_activity .inside' ).html( response ); dashboardBind(); } ); From fedba93498e1313e00cb9a3accc0fadcc6731240 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Sat, 1 Mar 2014 10:01:37 -0800 Subject: [PATCH 16/42] Fixed typo in records_per_page --- includes/admin.php | 2 +- readme.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 2f8bc4377..c2cc02841 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -544,7 +544,7 @@ public static function dashboard_stream_activity_update_contents(){ public static function dashboard_stream_activity_contents( $paged = 1 ) { $options = get_option( 'dashboard_stream_activity_options', array() ); - $records_per_page = isset( $options['record_per_page'] ) ? absint( $options['records_per_page'] ) : 5; + $records_per_page = isset( $options['records_per_page'] ) ? absint( $options['records_per_page'] ) : 5; $args = array( 'records_per_page' => $records_per_page, 'paged' => $paged, diff --git a/readme.md b/readme.md index cfbf8eff7..a9f4b336f 100755 --- a/readme.md +++ b/readme.md @@ -88,7 +88,7 @@ Great! There are several ways you can get involved to help make Stream better: Thank you for wanting to make Stream better for everyone! We salute you. -[![Build Status](https://travis-ci.org/x-team/wp-stream.png?branch=master)](https://travis-ci.org/x-team/wp-stream) +[![Build Status](https://travis-ci.org/chacha/wp-stream.png?branch=master)](https://travis-ci.org/chacha/wp-stream) ## Screenshots ## From bb16f5df251cac31a8f26dc17ec41889ed448e22 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Sat, 1 Mar 2014 10:07:58 -0800 Subject: [PATCH 17/42] Switch from double quotes to single quotes where appropriate --- includes/admin.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index c2cc02841..23c924a55 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -642,7 +642,7 @@ public static function dashboard_pagination( $args = array() ){ ); $html_view_all = sprintf( - "%s", + '%s', 'view-all', esc_attr__( 'View all records', 'stream' ), esc_url( $records_link ), @@ -659,7 +659,7 @@ public static function dashboard_pagination( $args = array() ){ } $page_links[] = sprintf( - "%s", + '%s', 'first-page' . $disable_first, esc_attr__( 'Go to the first page', 'stream' ), esc_url( remove_query_arg( 'paged', $records_link ) ), @@ -667,7 +667,7 @@ public static function dashboard_pagination( $args = array() ){ ); $page_links[] = sprintf( - "%s", + '%s', 'prev-page' . $disable_first, esc_attr__( 'Go to the previous page', 'stream' ), esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $records_link ) ), @@ -675,11 +675,11 @@ public static function dashboard_pagination( $args = array() ){ '‹' ); - $html_total_pages = sprintf( "%s", number_format_i18n( $total_pages ) ); + $html_total_pages = sprintf( '%s', number_format_i18n( $total_pages ) ); $page_links[] = '' . sprintf( _x( '%1$s of %2$s', 'paging', 'stream' ), $current, $html_total_pages ) . ''; $page_links[] = sprintf( - "%s", + '%s', 'next-page' . $disable_last, esc_attr__( 'Go to the next page', 'stream' ), esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $records_link ) ), @@ -688,7 +688,7 @@ public static function dashboard_pagination( $args = array() ){ ); $page_links[] = sprintf( - "%s", + '%s', 'last-page' . $disable_last, esc_attr__( 'Go to the last page', 'stream' ), esc_url( add_query_arg( 'paged', $total_pages, $records_link ) ), @@ -696,7 +696,7 @@ public static function dashboard_pagination( $args = array() ){ '»' ); - $html_pagination_links = "\n
" . join( "\n", $page_links ) . '
'; + $html_pagination_links = '
' . join( "\n", $page_links ) . '
'; echo '
' . $html_view_all . $html_pagination_links . '
'; } From f76f1ca1edead791691fd1add458fa3d7fce77ed Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Sat, 1 Mar 2014 10:08:59 -0800 Subject: [PATCH 18/42] Escape localized strings for maximum security. --- includes/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin.php b/includes/admin.php index 23c924a55..1a38ffe89 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -646,7 +646,7 @@ public static function dashboard_pagination( $args = array() ){ 'view-all', esc_attr__( 'View all records', 'stream' ), esc_url( $records_link ), - __( 'View All', 'stream' ) + esc_html__( 'View All', 'stream' ) ); $page_links = array(); From 4f79de2fe3a541dfe12659c89602d1a91ec797f8 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Sat, 1 Mar 2014 10:10:17 -0800 Subject: [PATCH 19/42] Fix styling --- ui/admin.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/admin.css b/ui/admin.css index 1ef336206..83dc77db0 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -48,12 +48,12 @@ #dashboard_stream_activity .tablenav{ clear: none; padding-right: 5px; + margin: 4px 0 6px; } #dashboard_stream_activity .view-all{ float: left; - padding: 0 10px 3px; - margin-top: 5px; + margin: 7px 0 0 12px; } .toplevel_page_wp_stream .tablenav { From 84edb2181e6aa563d6579f4cbb5144c892437a4b Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Sat, 1 Mar 2014 10:14:22 -0800 Subject: [PATCH 20/42] Refactor if statement for brevity --- includes/admin.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 1a38ffe89..d41f02365 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -528,12 +528,7 @@ public static function dashboard_stream_activity_initial_contents(){ public static function dashboard_stream_activity_update_contents(){ - if ( ! empty( $_POST['stream-paged'] ) ) { - $paged = absint( $_POST['stream-paged'] ); - } else { - $paged = 1; - } - + $paged = ! empty( $_POST['stream-paged'] ) ? absint( $_POST['stream-paged'] ) : 1; self::dashboard_stream_activity_contents( $paged ); die; } From da9acd3c9f20b6756cf52c678a0d6c3cdd781464 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Mon, 3 Mar 2014 13:32:39 -0800 Subject: [PATCH 21/42] Use jQuery.on instead of click handler --- ui/dashboard.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/ui/dashboard.js b/ui/dashboard.js index 2cfc2f8ae..3b532abe2 100644 --- a/ui/dashboard.js +++ b/ui/dashboard.js @@ -1,21 +1,16 @@ /* dashboard pagination */ jQuery(function($){ - var dashboardBind = function(){ - $( '#dashboard_stream_activity .pagination-links a').click(function(e){ - e.preventDefault(); - var data = { - 'action' : 'stream_activity_dashboard_update', - 'stream-paged' : $(this).data('page'), - }; + $( '#dashboard_stream_activity').on( 'click', '.pagination-links a', function(e){ + e.preventDefault(); + var data = { + 'action' : 'stream_activity_dashboard_update', + 'stream-paged' : $(this).data('page'), + }; - $.post( window.ajaxurl, data, function( response ){ - $( '#dashboard_stream_activity .inside' ).html( response ); - dashboardBind(); - } ); + $.post( window.ajaxurl, data, function( response ){ + $( '#dashboard_stream_activity .inside' ).html( response ); } ); - }; - - dashboardBind(); + } ); }); From 750fed959f569bdcf7e49298c1399f1b0680e289 Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Mon, 3 Mar 2014 13:41:22 -0800 Subject: [PATCH 22/42] Add clear fix to extend widget past pagination --- includes/admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/admin.php b/includes/admin.php index d41f02365..1edc73c44 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -614,6 +614,7 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) { ); self::dashboard_pagination( $args ); + echo '
'; } /* From 2a57e46f9086a0c1607723dcd5af4be1e700284d Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Mon, 3 Mar 2014 13:49:00 -0800 Subject: [PATCH 23/42] Remove view-all on mobile. Add padding to tablenav on mobile --- ui/admin.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/admin.css b/ui/admin.css index 83dc77db0..f40039838 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -116,6 +116,12 @@ .toplevel_page_wp_stream .fixed .column-author { display: none; } + #dashboard_stream_activity .view-all{ + display: none; + } + #dashboard_stream_activity .tablenav{ + padding-top: 15px; + } } .toplevel_page_wp_stream .column-author a { From 2227a13ed2c9fb91a688b4d1d246857ad553fdcb Mon Sep 17 00:00:00 2001 From: Tyler Carter Date: Mon, 3 Mar 2014 14:00:11 -0800 Subject: [PATCH 24/42] Change view-all fix to apply to both tablets and mobile --- ui/admin.css | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/admin.css b/ui/admin.css index f40039838..7fad11505 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -112,10 +112,7 @@ } } -@media only screen and (max-width: 480px) { - .toplevel_page_wp_stream .fixed .column-author { - display: none; - } +@media only screen and (max-width: 782px) { #dashboard_stream_activity .view-all{ display: none; } @@ -124,6 +121,12 @@ } } +@media only screen and (max-width: 480px) { + .toplevel_page_wp_stream .fixed .column-author { + display: none; + } +} + .toplevel_page_wp_stream .column-author a { vertical-align : top; } From 3971dbf586c4190747efa1c04c58e2b619b7ace1 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Mon, 3 Mar 2014 17:01:23 -0600 Subject: [PATCH 25/42] Tweak clearfix and CSS in dashboard widget pagination --- includes/admin.php | 11 +++++------ readme.md | 2 +- ui/admin.css | 13 ++++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 1edc73c44..e3f39769c 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -56,7 +56,7 @@ public static function load() { // Load Dashboard widget add_action( 'wp_dashboard_setup', array( __CLASS__, 'dashboard_stream_activity' ) ); - + // Dashboard AJAX pagination add_action( 'wp_ajax_stream_activity_dashboard_update', array( __CLASS__, 'dashboard_stream_activity_update_contents' ) ); @@ -611,10 +611,9 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) { $args = array( 'total_pages' => ceil( $total_items / $records_per_page ), 'current' => $paged, - ); + ); self::dashboard_pagination( $args ); - echo '
'; } /* @@ -624,11 +623,11 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) { public static function dashboard_pagination( $args = array() ){ $args = wp_parse_args( - $args, + $args, array( 'current' => 1, 'total_pages' => 1, - ) + ) ); extract( $args ); @@ -692,7 +691,7 @@ public static function dashboard_pagination( $args = array() ){ '»' ); - $html_pagination_links = '
' . join( "\n", $page_links ) . '
'; + $html_pagination_links = '
' . join( "\n", $page_links ) . '
'; echo '
' . $html_view_all . $html_pagination_links . '
'; } diff --git a/readme.md b/readme.md index f617c15c9..81c47ec9d 100755 --- a/readme.md +++ b/readme.md @@ -83,7 +83,7 @@ Great! There are several ways you can get involved to help make Stream better: Thank you for wanting to make Stream better for everyone! We salute you. -[![Build Status](https://travis-ci.org/chacha/wp-stream.png?branch=master)](https://travis-ci.org/chacha/wp-stream) +[![Build Status](https://travis-ci.org/x-team/wp-stream.png?branch=master)](https://travis-ci.org/x-team/wp-stream) ## Screenshots ## diff --git a/ui/admin.css b/ui/admin.css index 7fad11505..30b35327d 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -45,13 +45,16 @@ padding: 12px; } -#dashboard_stream_activity .tablenav{ +#dashboard_stream_activity .tablenav { clear: none; - padding-right: 5px; margin: 4px 0 6px; } -#dashboard_stream_activity .view-all{ +#dashboard_stream_activity .tablenav .tablenav-pages { + margin-right: 6px; +} + +#dashboard_stream_activity .view-all { float: left; margin: 7px 0 0 12px; } @@ -116,8 +119,8 @@ #dashboard_stream_activity .view-all{ display: none; } - #dashboard_stream_activity .tablenav{ - padding-top: 15px; + #dashboard_stream_activity .tablenav .tablenav-pages { + margin: 15px 0; } } From 9cdb6d7806216a23d192be476625672b7486f7de Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Mon, 3 Mar 2014 17:06:08 -0600 Subject: [PATCH 26/42] Code formatting --- includes/admin.php | 24 +++++++++++++++--------- ui/admin.css | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index e3f39769c..6df9507c9 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -511,7 +511,7 @@ public static function dashboard_stream_activity() { wp_add_dashboard_widget( 'dashboard_stream_activity', - __( 'Stream Activity', 'stream' ), + esc_html__( 'Stream Activity', 'stream' ), array( __CLASS__, 'dashboard_stream_activity_initial_contents' ), array( __CLASS__, 'dashboard_stream_activity_options' ) ); @@ -538,11 +538,11 @@ public static function dashboard_stream_activity_update_contents(){ */ public static function dashboard_stream_activity_contents( $paged = 1 ) { - $options = get_option( 'dashboard_stream_activity_options', array() ); + $options = get_option( 'dashboard_stream_activity_options', array() ); $records_per_page = isset( $options['records_per_page'] ) ? absint( $options['records_per_page'] ) : 5; - $args = array( + $args = array( 'records_per_page' => $records_per_page, - 'paged' => $paged, + 'paged' => $paged, ); $records = stream_query( $args ); @@ -610,7 +610,7 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) { $total_items = self::dashboard_get_total_found_rows(); $args = array( 'total_pages' => ceil( $total_items / $records_per_page ), - 'current' => $paged, + 'current' => $paged, ); self::dashboard_pagination( $args ); @@ -625,7 +625,7 @@ public static function dashboard_pagination( $args = array() ){ $args = wp_parse_args( $args, array( - 'current' => 1, + 'current' => 1, 'total_pages' => 1, ) ); @@ -691,7 +691,13 @@ public static function dashboard_pagination( $args = array() ){ '»' ); - $html_pagination_links = '
' . join( "\n", $page_links ) . '
'; + $html_pagination_links = ' +
+
+ ' . join( "\n", $page_links ) . ' +
+
+
'; echo '
' . $html_view_all . $html_pagination_links . '
'; } @@ -702,7 +708,7 @@ public static function dashboard_pagination( $args = array() ){ public static function dashboard_stream_activity_options() { $options = get_option( 'dashboard_stream_activity_options', array() ); - if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['dashboard_stream_activity_options'] ) ) { + if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['dashboard_stream_activity_options'] ) ) { $options['records_per_page'] = absint( $_POST['dashboard_stream_activity_options']['records_per_page'] ); update_option( 'dashboard_stream_activity_options', $options ); } @@ -739,7 +745,7 @@ public static function live_update( $response, $data ) { $enable_update = get_user_meta( get_current_user_id(), 'stream_live_update_records', true ); $enable_update = isset( $enable_update ) ? $enable_update : ''; - if ( isset( $data['wp-stream-heartbeat'] ) && 'live-update' === $data['wp-stream-heartbeat'] && $enable_update == 'on' ) { + if ( isset( $data['wp-stream-heartbeat'] ) && 'live-update' === $data['wp-stream-heartbeat'] && 'on' === $enable_update ) { // Register list table require_once WP_STREAM_INC_DIR . 'list-table.php'; self::$list_table = new WP_Stream_List_Table( array( 'screen' => self::RECORDS_PAGE_SLUG ) ); diff --git a/ui/admin.css b/ui/admin.css index 30b35327d..efaf47ff7 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -116,7 +116,7 @@ } @media only screen and (max-width: 782px) { - #dashboard_stream_activity .view-all{ + #dashboard_stream_activity .view-all { display: none; } #dashboard_stream_activity .tablenav .tablenav-pages { From 0b250f36d81a7ffff6a07f5320011de86ed3d587 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Mon, 3 Mar 2014 17:10:48 -0600 Subject: [PATCH 27/42] Mobile/tablet CSS fixes for configure link --- ui/admin.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/admin.css b/ui/admin.css index efaf47ff7..a01e3fea2 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -2,6 +2,10 @@ border-bottom: 0; } +#dashboard_stream_activity h3 .postbox-title-action { + top: 6px; +} + #dashboard_stream_activity.postbox .inside, #dashboard_stream_activity ul, #dashboard_stream_activity ul li { @@ -116,6 +120,9 @@ } @media only screen and (max-width: 782px) { + #dashboard_stream_activity h3 .postbox-title-action { + top: 10px; + } #dashboard_stream_activity .view-all { display: none; } From 352899fb54f3873940fbff16ef3690220c16db78 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Mon, 3 Mar 2014 17:14:02 -0600 Subject: [PATCH 28/42] Change dashboard widget config to be records per page --- includes/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index 6df9507c9..952276fbc 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -720,8 +720,8 @@ public static function dashboard_stream_activity_options() { ?>

- - + +

Date: Mon, 3 Mar 2014 18:29:03 -0600 Subject: [PATCH 29/42] Release notes for 1.2.7 --- readme.md | 3 +++ readme.txt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/readme.md b/readme.md index 81c47ec9d..14d97d658 100755 --- a/readme.md +++ b/readme.md @@ -105,6 +105,9 @@ Thank you for wanting to make Stream better for everyone! We salute you. ## Changelog ## +### 1.2.7 ### +**2014/03/04** - Pagination added to Stream Activity dashboard widget. Bug fixes. Props [chacha](https://github.com/chacha/), [fjarrett](http://profiles.wordpress.org/fjarrett/) + ### 1.2.6 ### **2014/02/28** - Improved context names in Users connector. Props [powelski](http://profiles.wordpress.org/powelski/) diff --git a/readme.txt b/readme.txt index c51873dcf..0f1cf4ab0 100644 --- a/readme.txt +++ b/readme.txt @@ -90,6 +90,9 @@ Thank you for wanting to make Stream better for everyone! We salute you. == Changelog == += 1.2.7 = +**2014/03/04** - Pagination added to Stream Activity dashboard widget. Bug fixes. Props [chacha](https://github.com/chacha/), [fjarrett](http://profiles.wordpress.org/fjarrett/) + = 1.2.6 = **2014/02/28** - Improved context names in Users connector. Props [powelski](http://profiles.wordpress.org/powelski/) From 63f77078e90c7c24f10312e990e944ecfea7f12e Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Mon, 3 Mar 2014 18:29:20 -0600 Subject: [PATCH 30/42] Version bump to 1.2.7 --- stream.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stream.php b/stream.php index 09a080722..2f0db204a 100644 --- a/stream.php +++ b/stream.php @@ -3,7 +3,7 @@ * Plugin Name: Stream * Plugin URI: http://wordpress.org/plugins/stream/ * Description: Stream tracks logged-in user activity so you can monitor every change made on your WordPress site in beautifully organized detail. All activity is organized by context, action and IP address for easy filtering. Developers can extend Stream with custom connectors to log any kind of action. - * Version: 1.2.6 + * Version: 1.2.7 * Author: X-Team * Author URI: http://x-team.com/wordpress/ * License: GPLv2+ @@ -37,7 +37,7 @@ class WP_Stream { * * @const string */ - const VERSION = '1.2.6'; + const VERSION = '1.2.7'; /** * Hold Stream instance From 82849d6504c29b5140594692a075398ef2fa872f Mon Sep 17 00:00:00 2001 From: Luke Carbis Date: Tue, 4 Mar 2014 11:58:46 +1000 Subject: [PATCH 31/42] Add media attachment types as contexts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The media connector now references the media type as the context, instead of simply repeating the connector (‘Media’). The media types are borrowed from wp_ext2type() in wp-includes/functions.php. (also - this is my first Stream commit!) --- connectors/media.php | 51 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/connectors/media.php b/connectors/media.php index fb10ddd0f..ce36dc0c0 100644 --- a/connectors/media.php +++ b/connectors/media.php @@ -48,14 +48,46 @@ public static function get_action_labels() { /** * Return translated context labels * + * Based on extension types used by wp_ext2type() in wp-includes/functions.php. + * * @return array Context label translations */ public static function get_context_labels() { return array( - 'media' => __( 'Media', 'stream' ), + 'image' => __( 'Image', 'stream' ), + 'audio' => __( 'Audio', 'stream' ), + 'video' => __( 'Video', 'stream' ), + 'document' => __( 'Document', 'stream' ), + 'spreadsheet' => __( 'Spreadsheet', 'stream' ), + 'interactive' => __( 'Interactive', 'stream' ), + 'text' => __( 'Text', 'stream' ), + 'archive' => __( 'Archive', 'stream' ), + 'code' => __( 'Code', 'stream' ), ); } + /** + * Return the file type for an attachment which corresponds with a context label + * + * @param object $file_uri URI of the attachment + * @return string A file type which corresponds with a context label + */ + public static function get_attachment_type( $file_uri ) { + + $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $file_uri ); + $ext_type = wp_ext2type( $ext ); + if ( ! $ext_type ) $ext_type = 'document'; + + $context_labels = self::get_context_labels(); + + if ( isset( $context_labels[$ext_type] ) ) { + return $context_labels[$ext_type]; + } else { + return 'document'; + } + + } + /** * Add action links to Stream drop row in admin list screen * @@ -97,11 +129,13 @@ public static function callback_add_attachment( $post_id ) { $parent_id = $post->post_parent; if ( $parent_id && $parent = get_post( $post->post_parent ) ) $parent_title = $parent->post_title; + $attachment_type = self::get_attachment_type( $post->guid ); + self::log( $message, compact( 'name', 'parent_title', 'parent_id', 'url' ), $post_id, - array( 'media' => $post->post_parent ? 'attached' : 'uploaded' ) + array( $attachment_type => $post->post_parent ? 'attached' : 'uploaded' ) ); } @@ -115,11 +149,13 @@ public static function callback_edit_attachment( $post_id ) { $message = __( 'Updated "%s"', 'stream' ); $name = $post->post_title; + $attachment_type = self::get_attachment_type( $post->guid ); + self::log( $message, compact( 'name' ), $post_id, - array( 'media' => 'updated' ) + array( $attachment_type => 'updated' ) ); } @@ -136,21 +172,26 @@ public static function callback_delete_attachment( $post_id ) { $name = $post->post_title; $url = $post->guid; + $attachment_type = self::get_attachment_type( $post->guid ); + self::log( $message, compact( 'name', 'parent_id', 'url' ), $post_id, - array( 'media' => 'deleted' ) + array( $attachment_type => 'deleted' ) ); } public static function callback_wp_save_image_editor_file( $dummy, $filename, $image, $mime_type, $post_id ) { $name = basename( $filename ); + + $attachment_type = self::get_attachment_type( $post->guid ); + self::log( __( 'Edited image "%s"', 'stream' ), compact( 'name', 'filename', 'post_id' ), $post_id, - array( 'media' => 'edited' ) + array( $attachment_type => 'edited' ) ); } From ff5286d7a73a90db950db28742051987d03ad620 Mon Sep 17 00:00:00 2001 From: Luke Carbis Date: Tue, 4 Mar 2014 13:17:12 +1000 Subject: [PATCH 32/42] Fixed get_attachment_type() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Was returning translated string instead of context key. Also added spaces around variables in square brackets. Is it work making lines 80-82, and 86-88 shorter? $extension_type = isset( $context_labels[ $extension_type ] ? $extension_type : ‘document’; I opted for (imho) a more readable version. --- connectors/media.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/connectors/media.php b/connectors/media.php index ce36dc0c0..06ad6d2de 100644 --- a/connectors/media.php +++ b/connectors/media.php @@ -74,18 +74,21 @@ public static function get_context_labels() { */ public static function get_attachment_type( $file_uri ) { - $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $file_uri ); - $ext_type = wp_ext2type( $ext ); - if ( ! $ext_type ) $ext_type = 'document'; + $extension = pathinfo( $file_uri, PATHINFO_EXTENSION ); + $extension_type = wp_ext2type( $extension ); + + if ( empty( $extension_type ) ) { + $extension_type = 'document'; + } $context_labels = self::get_context_labels(); - if ( isset( $context_labels[$ext_type] ) ) { - return $context_labels[$ext_type]; - } else { - return 'document'; + if ( ! isset( $context_labels[ $extension_type ] ) ) { + $extension_type = 'document'; } + return $extension_type; + } /** From ad4c929af6671017e4787fde03a21823355cbb8c Mon Sep 17 00:00:00 2001 From: Luke Carbis Date: Tue, 4 Mar 2014 13:17:50 +1000 Subject: [PATCH 33/42] Simplify $parent_title variable --- connectors/media.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/connectors/media.php b/connectors/media.php index 06ad6d2de..f5b45c237 100644 --- a/connectors/media.php +++ b/connectors/media.php @@ -127,10 +127,10 @@ public static function callback_add_attachment( $post_id ) { } else { $message = __( 'Added "%s" to Media library', 'stream' ); } - $name = $post->post_title; - $url = $post->guid; - $parent_id = $post->post_parent; - if ( $parent_id && $parent = get_post( $post->post_parent ) ) $parent_title = $parent->post_title; + $name = $post->post_title; + $url = $post->guid; + $parent_id = $post->post_parent; + $parent_title = $parent_id ? get_the_title‎( $parent_id ) : null; $attachment_type = self::get_attachment_type( $post->guid ); From 4b769d7dc1ad872e9bbf68e25d16627f3ba6ac75 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Mon, 3 Mar 2014 21:23:14 -0600 Subject: [PATCH 34/42] Add bottom border to dashboard widget list before pagination controls --- ui/admin.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/admin.css b/ui/admin.css index a01e3fea2..913dc89e3 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -18,6 +18,10 @@ padding: 1em 12px; } +#dashboard_stream_activity ul { + border-bottom: 1px solid #eee; +} + #dashboard_stream_activity ul li, #dashboard_stream_activity .sub-links { padding: 1em 12px; From 652023ee174d3b44211c2bcf0ba2da859fbc0b62 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Mon, 3 Mar 2014 21:29:53 -0600 Subject: [PATCH 35/42] Fix placeholder text misalignment in date input fields --- ui/admin.css | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/admin.css b/ui/admin.css index 913dc89e3..2ac180dc7 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -161,6 +161,7 @@ .toplevel_page_wp_stream .alignleft.actions input[type=text] { height: 27px; + line-height: 19px; } .toplevel_page_wp_stream .select2-container { From 4821ee2d956b4e4ff5b915beaa2aa6ef7a3f5261 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Mon, 3 Mar 2014 21:34:26 -0600 Subject: [PATCH 36/42] Don't use Yoda labels --- includes/list-table.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/list-table.php b/includes/list-table.php index 607b6dce5..0a35a9e20 100644 --- a/includes/list-table.php +++ b/includes/list-table.php @@ -534,9 +534,9 @@ function filter_date() { ', - esc_attr__( 'Date start', 'stream' ), + esc_attr__( 'Start date', 'stream' ), isset( $_GET['date_from'] ) ? esc_attr( $_GET['date_from'] ) : null, - esc_attr__( 'Date end', 'stream' ), + esc_attr__( 'End date', 'stream' ), isset( $_GET['date_to'] ) ? esc_attr( $_GET['date_to'] ) : null ); From a5c9a8956306ca5bd30c67bbf96aa5201385469e Mon Sep 17 00:00:00 2001 From: Luke Carbis Date: Tue, 4 Mar 2014 15:02:18 +1000 Subject: [PATCH 37/42] Change the context for old entries to the attachment type - draft Still trying to get my head around this. Am I going about this the right way, or is it time to stop for a coffee? --- includes/install.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/includes/install.php b/includes/install.php index f504dcea9..118b70918 100644 --- a/includes/install.php +++ b/includes/install.php @@ -165,6 +165,47 @@ public static function update( $db_version, $current ) { } } } + + // If version is lower than 1.2.7, do the update routine + // Change the context for Media connectors to the attachment type + if ( version_compare( $db_version, '1.2.7', '<' ) ) { + + require_once( WP_STREAM_CLASS_DIR . 'connector.php' ); + require_once( WP_STREAM_DIR . 'connectors/media.php' ); + + $sql = "SELECT r.ID id, r.object_id pid, c.meta_id mid + FROM $wpdb->stream r + JOIN $wpdb->streamcontext c + ON r.ID = c.record_id AND c.connector = 'media' AND c.context = 'media' + "; + $media_records = $wpdb->get_results( $sql ); // db call okay + + foreach ( $media_records as $record ) { + + $post = get_post( $record->pid ); + + if ( empty( $post ) ) { + $sql = "SELECT meta_value + FROM $wpdb->streammeta + WHERE meta_key = 'url' AND meta_id = %d + "; + $url = $wpdb->get_var( $wpdb->prepare( $sql, $record->mid ) ); + } else { + $url = $post->guid; + } + + if ( ! empty( $url ) ) { + $context = WP_Stream_Connector_Media::get_attachment_type( $url ); + $wpdb->update( + $wpdb->streamcontext, + array( 'context' => $context ), + array( 'record_id' => $record->id ), + array( '%s' ), + array( '%d' ) + ); + } + } + } } } From 422bf86d4e560f3f63abd74ed8691afa2579077f Mon Sep 17 00:00:00 2001 From: Krzysztof Powelski Date: Wed, 5 Mar 2014 05:48:26 +0100 Subject: [PATCH 38/42] [issue-288] Return false instead of event manipulation --- ui/admin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/admin.js b/ui/admin.js index 553d3a0f3..f27d0983e 100644 --- a/ui/admin.js +++ b/ui/admin.js @@ -84,13 +84,13 @@ jQuery(function($){ $optionsForm.prop('action', currentAction.replace( /(^[^#]*).*$/, '$1#' + index )); }; - $tabs.on('click', 'a', function(e){ - e.preventDefault(); + $tabs.on('click', 'a', function(){ var index = $tabs.find('a').index( $(this) ); $panels.hide().eq(index).show(); $tabs.find('a').removeClass('nav-tab-active').filter($(this)).addClass('nav-tab-active'); window.location.hash = index; syncFormAction(index); + return false; }); $tabs.children().eq( currentHash ).trigger('click'); From 80e038d62fad38ef50ae86ea24f94001ec5810c4 Mon Sep 17 00:00:00 2001 From: Krzysztof Powelski Date: Wed, 5 Mar 2014 06:14:32 +0100 Subject: [PATCH 39/42] [issue-288] Inject CSS tweak --- includes/admin.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/includes/admin.php b/includes/admin.php index 952276fbc..be740d82e 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -72,6 +72,20 @@ public static function load() { // Ajax author's name by ID add_action( 'wp_ajax_wp_stream_get_author_name_by_id', array( __CLASS__, 'get_author_name_by_id' ) ); + // Fix CSS glitch on tabs + add_action( 'admin_head', array( __CLASS__, 'fix_tabs_glitch' ) ); + + } + + public static function fix_tabs_glitch() { + $screen = get_current_screen(); + if ( sprintf( 'stream_page_%s', self::SETTINGS_PAGE_SLUG ) === $screen->id ) : ?> + + Date: Wed, 5 Mar 2014 20:04:59 +0100 Subject: [PATCH 40/42] Revert "[issue-288] Inject CSS tweak" This reverts commit 80e038d62fad38ef50ae86ea24f94001ec5810c4. --- includes/admin.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/includes/admin.php b/includes/admin.php index be740d82e..952276fbc 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -72,20 +72,6 @@ public static function load() { // Ajax author's name by ID add_action( 'wp_ajax_wp_stream_get_author_name_by_id', array( __CLASS__, 'get_author_name_by_id' ) ); - // Fix CSS glitch on tabs - add_action( 'admin_head', array( __CLASS__, 'fix_tabs_glitch' ) ); - - } - - public static function fix_tabs_glitch() { - $screen = get_current_screen(); - if ( sprintf( 'stream_page_%s', self::SETTINGS_PAGE_SLUG ) === $screen->id ) : ?> - - Date: Wed, 5 Mar 2014 20:08:19 +0100 Subject: [PATCH 41/42] [issue-288] Move tweak to external CSS file --- ui/admin.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/admin.css b/ui/admin.css index 2ac180dc7..c16373fee 100644 --- a/ui/admin.css +++ b/ui/admin.css @@ -200,3 +200,7 @@ .toplevel_page_wp_stream .new-row.fadeout { background-color: transparent; } + +.stream_page_wp_stream_settings .nav-tab-wrapper a:not(.nav-tab-active) { + border-bottom: 1px solid #ccc; +} From 30d72ea63030ac46aa49a292cb2d33a44fbceebb Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Wed, 5 Mar 2014 13:11:43 -0600 Subject: [PATCH 42/42] Do upgrade routine if less than 1.2.8 --- includes/install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/install.php b/includes/install.php index 118b70918..b8b587f38 100644 --- a/includes/install.php +++ b/includes/install.php @@ -166,9 +166,9 @@ public static function update( $db_version, $current ) { } } - // If version is lower than 1.2.7, do the update routine + // If version is lower than 1.2.8, do the update routine // Change the context for Media connectors to the attachment type - if ( version_compare( $db_version, '1.2.7', '<' ) ) { + if ( version_compare( $db_version, '1.2.8', '<' ) ) { require_once( WP_STREAM_CLASS_DIR . 'connector.php' ); require_once( WP_STREAM_DIR . 'connectors/media.php' );