| @@ -50,8 +50,15 @@ | ||
| 50 | 50 | */ |
| 51 | 51 | protected $file_type = ''; |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | + * Store selected IDs for selective export | |
| 55 | + * | |
| 56 | + * @var array | |
| 57 | + */ | |
| 58 | + protected $selected_ids = []; | |
| 59 | + | |
| 60 | + /** | |
| 54 | 61 | * Prepare data that will be exported |
| 55 | 62 | * |
| 56 | 63 | * @return void |
| 57 | 64 | */ |
| @@ -111,14 +118,14 @@ | ||
| 111 | 118 | */ |
| 112 | 119 | protected function export_columns() { |
| 113 | 120 | $colunms = $this->get_columns(); |
| 114 | 121 | ob_clean(); |
| 115 | - $output = fopen( 'php://output', 'w' ); | |
| 122 | + $output = fopen( 'php://output', 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- php://output is a stream wrapper, not a filesystem operation | |
| 116 | 123 | ob_start(); |
| 117 | 124 | |
| 118 | 125 | fputcsv( $output, $colunms ); |
| 119 | 126 | |
| 120 | - fclose( $output ); | |
| 127 | + fclose( $output ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- Closing php://output stream | |
| 121 | 128 | |
| 122 | 129 | return ob_get_clean(); |
| 123 | 130 | } |
| 124 | 131 | |
| @@ -129,13 +136,15 @@ | ||
| 129 | 136 | */ |
| 130 | 137 | protected function export_rows() { |
| 131 | 138 | $data = $this->get_data(); |
| 132 | 139 | ob_clean(); |
| 133 | - $buffer = fopen( 'php://output', 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen | |
| 140 | + $buffer = fopen( 'php://output', 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- php://output is a stream wrapper, not a filesystem operation | |
| 134 | 141 | ob_start(); |
| 135 | 142 | |
| 136 | 143 | array_walk( $data, array( $this, 'export_row' ), $buffer ); |
| 137 | 144 | |
| 145 | + fclose( $buffer ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- Closing php://output stream | |
| 146 | + | |
| 138 | 147 | return ob_get_clean(); |
| 139 | 148 | } |
| 140 | 149 | |
| 141 | 150 | /** |
| @@ -169,9 +178,9 @@ | ||
| 169 | 178 | * |
| 170 | 179 | * @return void |
| 171 | 180 | */ |
| 172 | 181 | protected function send_content( $content ) { |
| 173 | - echo $content; | |
| 182 | + echo wp_kses( $content, 'post' ); | |
| 174 | 183 | } |
| 175 | 184 | |
| 176 | 185 | /** |
| 177 | 186 | * Export data to csv format |
| @@ -198,9 +207,9 @@ | ||
| 198 | 207 | $this->prepare_data(); |
| 199 | 208 | $this->send_headers(); |
| 200 | 209 | $data = $this->get_data(); |
| 201 | 210 | |
| 202 | - echo json_encode( $data, JSON_PRETTY_PRINT ); | |
| 211 | + echo wp_json_encode( $data, JSON_PRETTY_PRINT ); | |
| 203 | 212 | die(); |
| 204 | 213 | } |
| 205 | 214 | |
| 206 | 215 | /** |