PluginProbe
Stream – Activity Log & Audit Trail / 4.0.2
Stream – Activity Log & Audit Trail v4.0.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 +27 -22 3.14.0.2 View file →
@@ -1,10 +1,19 @@
1 1 <?php
2 +/**
3 + * Loads & Manages exporter classes.
4 + *
5 + * @package WP_Stream
6 + */
7 +
2 8 namespace WP_Stream;
3 9
10 +/**
11 + * Class - Export
12 + */
4 13 class Export {
5 14 /**
6 - * Hold Plugin class
15 + * Holds instance of plugin object
7 16 *
8 17 * @var Plugin
9 18 */
10 19 public $plugin;
@@ -59,27 +68,29 @@
59 68 add_filter( 'wp_stream_list_table_columns', array( $this, 'expand_columns' ), 10, 1 );
60 69
61 70 $records = $list_table->get_records();
62 71 $columns = $list_table->get_columns();
63 - $output = array();
72 + $output = array();
64 73 foreach ( $records as $item ) {
65 74 $output[] = $this->build_record( $item, $columns );
66 75 }
67 76
68 77 $exporters = $this->get_exporters();
69 - $exporter = $exporters[ $output_type ];
78 + $exporter = $exporters[ $output_type ];
70 79 $exporter->output_file( $output, $columns );
71 - return;
72 80 }
73 81
74 82 /**
75 83 * Add Export options to record actions menu
76 84 *
85 + * @param array $action_menu_items Export types.
86 + *
77 87 * @return array
78 88 */
79 - function actions_menu_export_items( $action_menu_items ) {
89 + public function actions_menu_export_items( $action_menu_items ) {
80 90 foreach ( $this->get_exporters() as $exporter ) {
81 91 $action = 'export-' . $exporter->slug;
92 + /* translators: %s: an export format (e.g. "CSV") */
82 93 $action_menu_items[ $action ] = sprintf( __( 'Export as %s', 'stream' ), $exporter->name );
83 94 }
84 95
85 96 return $action_menu_items;
@@ -91,25 +102,25 @@
91 102 * @param array $item Post to extract data from.
92 103 * @param array $columns Columns being extracted.
93 104 * @return array Numerically-indexed array with extracted data.
94 105 */
95 - function build_record( $item, $columns ) {
106 + public function build_record( $item, $columns ) {
96 107 $record = new Record( $item );
97 108
98 109 $row_out = array();
99 110 foreach ( array_keys( $columns ) as $column_name ) {
100 111 switch ( $column_name ) {
101 - case 'date' :
102 - $created = date( 'Y-m-d H:i:s', strtotime( $record->created ) );
112 + case 'date':
113 + $created = gmdate( 'Y-m-d H:i:s', strtotime( $record->created ) );
103 114 $row_out[ $column_name ] = get_date_from_gmt( $created, 'Y/m/d h:i:s A' );
104 115 break;
105 116
106 - case 'summary' :
117 + case 'summary':
107 118 $row_out[ $column_name ] = $record->summary;
108 119 break;
109 120
110 - case 'user_id' :
111 - $user = new Author( (int) $record->user_id, (array) maybe_unserialize( $record->user_meta ) );
121 + case 'user_id':
122 + $user = new Author( (int) $record->user_id, (array) $record->user_meta );
112 123 $row_out[ $column_name ] = $user->get_display_name();
113 124 break;
114 125
115 126 case 'connector':
@@ -127,9 +138,9 @@
127 138 case 'blog_id':
128 139 $row_out[ $column_name ] = $record->blog_id;
129 140 break;
130 141
131 - case 'ip' :
142 + case 'ip':
132 143 $row_out[ $column_name ] = $record->{$column_name};
133 144 break;
134 145 }
135 146 }
@@ -139,11 +150,11 @@
139 150
140 151 /**
141 152 * Increase pagination limit for CSV Output
142 153 *
143 - * @param int $records_per_page Old limit for records_per_page.
154 + * @return int
144 155 */
145 - public function disable_paginate( $records_per_page ) {
156 + public function disable_paginate() {
146 157 return 10000;
147 158 }
148 159
149 160 /**
@@ -162,9 +173,9 @@
162 173 'action' => $columns['action'],
163 174 'ip' => $columns['ip'],
164 175 );
165 176
166 - if ( is_multisite() && is_plugin_active_for_network( $this->plugin->locations['plugin'] ) ) {
177 + if ( is_multisite() && $this->plugin->is_network_activated() ) {
167 178 $new_columns['blog_id'] = __( 'Blog ID', 'stream' );
168 179 }
169 180
170 181 return $new_columns;
@@ -201,18 +212,12 @@
201 212 * @param array $classes An array of Exporter objects. In the format exporter_slug => Exporter_Class()
202 213 */
203 214 $this->exporters = apply_filters( 'wp_stream_exporters', $classes );
204 215
205 - // Ensure that all exporters extend Exporter
216 + // Ensure that all exporters extend Exporter.
206 217 foreach ( $this->exporters as $key => $exporter ) {
207 218 if ( ! $this->is_valid_exporter( $exporter ) ) {
208 219 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 220 }
216 221 }
217 222 }
218 223