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-cli.php +11 -16 3.10.03.4.2 View file →
@@ -2,16 +2,12 @@
2 2 /**
3 3 * Stream command for WP-CLI
4 4 *
5 5 * @see https://github.com/wp-cli/wp-cli
6 - * @package WP_Stream
7 6 */
8 7
9 8 namespace WP_Stream;
10 9
11 -/**
12 - * Class - CLI
13 - */
14 10 class CLI extends \WP_CLI_Command {
15 11
16 12 /**
17 13 * Query a set of Stream records.
@@ -89,13 +85,10 @@
89 85 * wp stream query --user_role__not_in=administrator --date_after=2015-01-01T12:00:00
90 86 * wp stream query --user_id=1 --action=login --records_per_page=50 --fields=created
91 87 *
92 88 * @see WP_Stream_Query
93 - * @see https://github.com/xwp/stream/wiki/WP-CLI-Command
94 - * @see https://github.com/xwp/stream/wiki/Query-Reference
95 - *
96 - * @param array $args Unused.
97 - * @param array $assoc_args Fields to return data for.
89 + * @see https://github.com/wp-stream/stream/wiki/WP-CLI-Command
90 + * @see https://github.com/wp-stream/stream/wiki/Query-Reference
98 91 */
99 92 public function query( $args, $assoc_args ) {
100 93 unset( $args );
101 94
@@ -127,13 +120,13 @@
127 120 $query_args['fields'] = implode( ',', $fields );
128 121
129 122 $records = wp_stream_get_instance()->db->query( $query_args );
130 123
131 - // Make structure Formatter compatible.
124 + // Make structure Formatter compatible
132 125 foreach ( (array) $records as $key => $record ) {
133 126 $formatted_records[ $key ] = array();
134 127
135 - // Catch any fields missing in records.
128 + // Catch any fields missing in records
136 129 foreach ( $fields as $field ) {
137 130 if ( ! array_key_exists( $field, $record ) ) {
138 131 $record->$field = null;
139 132 }
@@ -158,11 +151,11 @@
158 151 }
159 152
160 153 if ( 'json_pretty' === $assoc_args['format'] ) {
161 154 if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
162 - \WP_CLI::line( wp_stream_json_encode( $formatted_records ) ); // xss ok.
155 + \WP_CLI::line( wp_stream_json_encode( $formatted_records ) ); // xss ok
163 156 } else {
164 - \WP_CLI::line( wp_stream_json_encode( $formatted_records, JSON_PRETTY_PRINT ) ); // xss ok.
157 + \WP_CLI::line( wp_stream_json_encode( $formatted_records, JSON_PRETTY_PRINT ) ); // xss ok
165 158 }
166 159 }
167 160
168 161 if ( 'csv' === $assoc_args['format'] ) {
@@ -182,10 +175,10 @@
182 175
183 176 /**
184 177 * Convert any field to a flat array.
185 178 *
186 - * @param string $name The output array element name.
187 - * @param mixed $object Any value to be converted to an array.
179 + * @param string $name The output array element name
180 + * @param mixed $object Any value to be converted to an array
188 181 *
189 182 * @return array The flat array
190 183 */
191 184 private function format_field( $name, $object ) {
@@ -206,9 +199,11 @@
206 199
207 200 /**
208 201 * Convert an array of flat records to CSV
209 202 *
210 - * @param array $array The input array of records.
203 + * @param array $array The input array of records
204 + *
205 + * @return string The CSV output
211 206 */
212 207 private function csv_format( $array ) {
213 208 $output = fopen( 'php://output', 'w' ); // @codingStandardsIgnoreLine Clever output for WP CLI using php://output
214 209