PluginProbe
Redirection / 2.9
Redirection v2.9
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
← All changes | fileio/csv.php +10 -7 4.02.9 View file →
@@ -3,15 +3,18 @@
3 3 class Red_Csv_File extends Red_FileIO {
4 4 const CSV_SOURCE = 0;
5 5 const CSV_TARGET = 1;
6 6 const CSV_REGEX = 2;
7 - const CSV_CODE = 3;
7 + const CSV_TYPE = 3;
8 + const CSV_CODE = 4;
8 9
9 10 public function force_download() {
10 11 parent::force_download();
11 12
13 + $filename = 'redirection-'.date_i18n( get_option( 'date_format' ) ).'.csv';
14 +
12 15 header( 'Content-Type: text/csv' );
13 - header( 'Content-Disposition: attachment; filename="' . $this->export_filename( 'csv' ) . '"' );
16 + header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
14 17 }
15 18
16 19 public function get_data( array $items, array $groups ) {
17 20 $lines[] = implode( ',', array( 'source', 'target', 'regex', 'type', 'code', 'match', 'hits', 'title' ) );
@@ -19,9 +22,9 @@
19 22 foreach ( $items as $line ) {
20 23 $lines[] = $this->item_as_csv( $line );
21 24 }
22 25
23 - return implode( PHP_EOL, $lines ) . PHP_EOL;
26 + return implode( PHP_EOL, $lines ).PHP_EOL;
24 27 }
25 28
26 29 public function item_as_csv( $item ) {
27 30 $data = $item->match->get_data();
@@ -42,9 +45,9 @@
42 45 return join( $csv, ',' );
43 46 }
44 47
45 48 public function escape_csv( $item ) {
46 - return '"' . str_replace( '"', '""', $item ) . '"';
49 + return '"'.str_replace( '"', '""', $item ).'"';
47 50 }
48 51
49 52 public function load( $group, $filename, $data ) {
50 53 ini_set( 'auto_detect_line_endings', true );
@@ -86,12 +89,12 @@
86 89 return 301;
87 90 }
88 91
89 92 public function csv_as_item( $csv, $group ) {
90 - if ( count( $csv ) > 1 && $csv[ self::CSV_SOURCE ] !== 'source' && $csv[ self::CSV_TARGET ] !== 'target' ) {
93 + if ( $csv[ self::CSV_SOURCE ] !== 'source' && $csv[ self::CSV_TARGET ] !== 'target' && count( $csv ) > 1 ) {
91 94 return array(
92 - 'url' => trim( $csv[ self::CSV_SOURCE ] ),
93 - 'action_data' => array( 'url' => trim( $csv[ self::CSV_TARGET ] ) ),
95 + 'url' => trim( $csv[ self ::CSV_SOURCE ] ),
96 + 'action_data' => array( 'url' => trim( $csv[ self ::CSV_TARGET ] ) ),
94 97 'regex' => isset( $csv[ self::CSV_REGEX ] ) ? $this->parse_regex( $csv[ self::CSV_REGEX ] ) : $this->is_regex( $csv[ self::CSV_SOURCE ] ),
95 98 'group_id' => $group,
96 99 'match_type' => 'url',
97 100 'action_type' => 'url',