PluginProbe
Stream – Activity Log & Audit Trail / 3.4.2
Stream – Activity Log & Audit Trail v3.4.2
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
← All changes | classes/class-export.php +19 -20 3.0.53.4.2 View file →
@@ -19,9 +19,8 @@
19 19 /**
20 20 * Class constructor
21 21 *
22 22 * @param Plugin $plugin The plugin object.
23 - * @return void
24 23 */
25 24 public function __construct( $plugin ) {
26 25 $this->plugin = $plugin;
27 26
@@ -37,8 +36,13 @@
37 36 *
38 37 * @return void
39 38 */
40 39 public function render_download() {
40 + $nonce = wp_stream_filter_input( INPUT_GET, 'stream_record_actions_nonce' );
41 + if ( ! wp_verify_nonce( $nonce, 'stream_record_actions_nonce' ) ) {
42 + return;
43 + }
44 +
41 45 $action = wp_stream_filter_input( INPUT_GET, 'record-actions' );
42 46 if ( strpos( $action, 'export-' ) !== 0 ) {
43 47 return;
44 48 }
@@ -55,17 +59,16 @@
55 59 add_filter( 'wp_stream_list_table_columns', array( $this, 'expand_columns' ), 10, 1 );
56 60
57 61 $records = $list_table->get_records();
58 62 $columns = $list_table->get_columns();
59 - $output = array();
63 + $output = array();
60 64 foreach ( $records as $item ) {
61 65 $output[] = $this->build_record( $item, $columns );
62 66 }
63 67
64 68 $exporters = $this->get_exporters();
65 - $exporter = $exporters[ $output_type ];
69 + $exporter = $exporters[ $output_type ];
66 70 $exporter->output_file( $output, $columns );
67 - return;
68 71 }
69 72
70 73 /**
71 74 * Add Export options to record actions menu
@@ -71,11 +74,12 @@
71 74 * Add Export options to record actions menu
72 75 *
73 76 * @return array
74 77 */
75 - function actions_menu_export_items( $action_menu_items ) {
78 + public function actions_menu_export_items( $action_menu_items ) {
76 79 foreach ( $this->get_exporters() as $exporter ) {
77 80 $action = 'export-' . $exporter->slug;
81 + // translators: Placeholder refers to an export format (e.g. "CSV")
78 82 $action_menu_items[ $action ] = sprintf( __( 'Export as %s', 'stream' ), $exporter->name );
79 83 }
80 84
81 85 return $action_menu_items;
@@ -87,25 +91,25 @@
87 91 * @param array $item Post to extract data from.
88 92 * @param array $columns Columns being extracted.
89 93 * @return array Numerically-indexed array with extracted data.
90 94 */
91 - function build_record( $item, $columns ) {
95 + public function build_record( $item, $columns ) {
92 96 $record = new Record( $item );
93 97
94 98 $row_out = array();
95 99 foreach ( array_keys( $columns ) as $column_name ) {
96 100 switch ( $column_name ) {
97 - case 'date' :
98 - $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 ) );
99 103 $row_out[ $column_name ] = get_date_from_gmt( $created, 'Y/m/d h:i:s A' );
100 104 break;
101 105
102 - case 'summary' :
106 + case 'summary':
103 107 $row_out[ $column_name ] = $record->summary;
104 108 break;
105 109
106 - case 'user_id' :
107 - $user = new Author( (int) $record->user_id, (array) maybe_unserialize( $record->user_meta ) );
110 + case 'user_id':
111 + $user = new Author( (int) $record->user_id, (array) $record->user_meta );
108 112 $row_out[ $column_name ] = $user->get_display_name();
109 113 break;
110 114
111 115 case 'connector':
@@ -123,9 +127,9 @@
123 127 case 'blog_id':
124 128 $row_out[ $column_name ] = $record->blog_id;
125 129 break;
126 130
127 - case 'ip' :
131 + case 'ip':
128 132 $row_out[ $column_name ] = $record->{$column_name};
129 133 break;
130 134 }
131 135 }
@@ -136,8 +140,9 @@
136 140 /**
137 141 * Increase pagination limit for CSV Output
138 142 *
139 143 * @param int $records_per_page Old limit for records_per_page.
144 + * @return int
140 145 */
141 146 public function disable_paginate( $records_per_page ) {
142 147 return 10000;
143 148 }
@@ -158,9 +163,9 @@
158 163 'action' => $columns['action'],
159 164 'ip' => $columns['ip'],
160 165 );
161 166
162 - if ( is_multisite() && is_plugin_active_for_network( $this->plugin->locations['plugin'] ) ) {
167 + if ( is_multisite() && $this->plugin->is_network_activated() ) {
163 168 $new_columns['blog_id'] = __( 'Blog ID', 'stream' );
164 169 }
165 170
166 171 return $new_columns;
@@ -178,9 +183,9 @@
178 183 );
179 184
180 185 $classes = array();
181 186 foreach ( $exporters as $exporter ) {
182 - include_once $this->plugin->locations['dir'] . '/exporters/class-exporter-' . $exporter .'.php';
187 + include_once $this->plugin->locations['dir'] . '/exporters/class-exporter-' . $exporter . '.php';
183 188 $class_name = sprintf( '\WP_Stream\Exporter_%s', str_replace( '-', '_', $exporter ) );
184 189 if ( ! class_exists( $class_name ) ) {
185 190 continue;
186 191 }
@@ -201,14 +206,8 @@
201 206 // Ensure that all exporters extend Exporter
202 207 foreach ( $this->exporters as $key => $exporter ) {
203 208 if ( ! $this->is_valid_exporter( $exporter ) ) {
204 209 unset( $this->exporters[ $key ] );
205 - trigger_error(
206 - sprintf(
207 - esc_html__( 'Registered exporter %s does not extend WP_Stream\Exporter.', 'stream' ),
208 - esc_html( get_class( $exporter ) )
209 - )
210 - );
211 210 }
212 211 }
213 212 }
214 213