| @@ -59,17 +59,16 @@ | ||
| 59 | 59 | add_filter( 'wp_stream_list_table_columns', array( $this, 'expand_columns' ), 10, 1 ); |
| 60 | 60 | |
| 61 | 61 | $records = $list_table->get_records(); |
| 62 | 62 | $columns = $list_table->get_columns(); |
| 63 | - $output = array(); | |
| 63 | + $output = array(); | |
| 64 | 64 | foreach ( $records as $item ) { |
| 65 | 65 | $output[] = $this->build_record( $item, $columns ); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $exporters = $this->get_exporters(); |
| 69 | - $exporter = $exporters[ $output_type ]; | |
| 69 | + $exporter = $exporters[ $output_type ]; | |
| 70 | 70 | $exporter->output_file( $output, $columns ); |
| 71 | - return; | |
| 72 | 71 | } |
| 73 | 72 | |
| 74 | 73 | /** |
| 75 | 74 | * Add Export options to record actions menu |
| @@ -75,11 +74,12 @@ | ||
| 75 | 74 | * Add Export options to record actions menu |
| 76 | 75 | * |
| 77 | 76 | * @return array |
| 78 | 77 | */ |
| 79 | - function actions_menu_export_items( $action_menu_items ) { | |
| 78 | + public function actions_menu_export_items( $action_menu_items ) { | |
| 80 | 79 | foreach ( $this->get_exporters() as $exporter ) { |
| 81 | 80 | $action = 'export-' . $exporter->slug; |
| 81 | + // translators: Placeholder refers to an export format (e.g. "CSV") | |
| 82 | 82 | $action_menu_items[ $action ] = sprintf( __( 'Export as %s', 'stream' ), $exporter->name ); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | return $action_menu_items; |
| @@ -91,25 +91,25 @@ | ||
| 91 | 91 | * @param array $item Post to extract data from. |
| 92 | 92 | * @param array $columns Columns being extracted. |
| 93 | 93 | * @return array Numerically-indexed array with extracted data. |
| 94 | 94 | */ |
| 95 | - function build_record( $item, $columns ) { | |
| 95 | + public function build_record( $item, $columns ) { | |
| 96 | 96 | $record = new Record( $item ); |
| 97 | 97 | |
| 98 | 98 | $row_out = array(); |
| 99 | 99 | foreach ( array_keys( $columns ) as $column_name ) { |
| 100 | 100 | switch ( $column_name ) { |
| 101 | - case 'date' : | |
| 102 | - $created = date( 'Y-m-d H:i:s', strtotime( $record->created ) ); | |
| 101 | + case 'date': | |
| 102 | + $created = date( 'Y-m-d H:i:s', strtotime( $record->created ) ); | |
| 103 | 103 | $row_out[ $column_name ] = get_date_from_gmt( $created, 'Y/m/d h:i:s A' ); |
| 104 | 104 | break; |
| 105 | 105 | |
| 106 | - case 'summary' : | |
| 106 | + case 'summary': | |
| 107 | 107 | $row_out[ $column_name ] = $record->summary; |
| 108 | 108 | break; |
| 109 | 109 | |
| 110 | - case 'user_id' : | |
| 111 | - $user = new Author( (int) $record->user_id, (array) $record->user_meta ); | |
| 110 | + case 'user_id': | |
| 111 | + $user = new Author( (int) $record->user_id, (array) $record->user_meta ); | |
| 112 | 112 | $row_out[ $column_name ] = $user->get_display_name(); |
| 113 | 113 | break; |
| 114 | 114 | |
| 115 | 115 | case 'connector': |
| @@ -127,9 +127,9 @@ | ||
| 127 | 127 | case 'blog_id': |
| 128 | 128 | $row_out[ $column_name ] = $record->blog_id; |
| 129 | 129 | break; |
| 130 | 130 | |
| 131 | - case 'ip' : | |
| 131 | + case 'ip': | |
| 132 | 132 | $row_out[ $column_name ] = $record->{$column_name}; |
| 133 | 133 | break; |
| 134 | 134 | } |
| 135 | 135 | } |
| @@ -140,8 +140,9 @@ | ||
| 140 | 140 | /** |
| 141 | 141 | * Increase pagination limit for CSV Output |
| 142 | 142 | * |
| 143 | 143 | * @param int $records_per_page Old limit for records_per_page. |
| 144 | + * @return int | |
| 144 | 145 | */ |
| 145 | 146 | public function disable_paginate( $records_per_page ) { |
| 146 | 147 | return 10000; |
| 147 | 148 | } |
| @@ -162,9 +163,9 @@ | ||
| 162 | 163 | 'action' => $columns['action'], |
| 163 | 164 | 'ip' => $columns['ip'], |
| 164 | 165 | ); |
| 165 | 166 | |
| 166 | - if ( is_multisite() && is_plugin_active_for_network( $this->plugin->locations['plugin'] ) ) { | |
| 167 | + if ( is_multisite() && $this->plugin->is_network_activated() ) { | |
| 167 | 168 | $new_columns['blog_id'] = __( 'Blog ID', 'stream' ); |
| 168 | 169 | } |
| 169 | 170 | |
| 170 | 171 | return $new_columns; |
| @@ -205,14 +206,8 @@ | ||
| 205 | 206 | // Ensure that all exporters extend Exporter |
| 206 | 207 | foreach ( $this->exporters as $key => $exporter ) { |
| 207 | 208 | if ( ! $this->is_valid_exporter( $exporter ) ) { |
| 208 | 209 | unset( $this->exporters[ $key ] ); |
| 209 | - trigger_error( | |
| 210 | - sprintf( | |
| 211 | - esc_html__( 'Registered exporter %s does not extend WP_Stream\Exporter.', 'stream' ), | |
| 212 | - esc_html( get_class( $exporter ) ) | |
| 213 | - ) | |
| 214 | - ); | |
| 215 | 210 | } |
| 216 | 211 | } |
| 217 | 212 | } |
| 218 | 213 | |