| @@ -3,14 +3,16 @@ | ||
| 3 | 3 | class Red_Json_File extends Red_FileIO { |
| 4 | 4 | public function force_download() { |
| 5 | 5 | parent::force_download(); |
| 6 | 6 | |
| 7 | + $filename = 'redirection-'.date_i18n( get_option( 'date_format' ) ).'.json'; | |
| 8 | + | |
| 7 | 9 | header( 'Content-Type: application/json' ); |
| 8 | - header( 'Content-Disposition: attachment; filename="' . $this->export_filename( 'json' ) . '"' ); | |
| 10 | + header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); | |
| 9 | 11 | } |
| 10 | 12 | |
| 11 | 13 | public function get_data( array $items, array $groups ) { |
| 12 | - $version = red_get_plugin_data( dirname( dirname( __FILE__ ) ) . '/redirection.php' ); | |
| 14 | + $version = get_plugin_data( dirname( dirname( __FILE__ ) ).'/redirection.php' ); | |
| 13 | 15 | |
| 14 | 16 | $items = array( |
| 15 | 17 | 'plugin' => array( |
| 16 | 18 | 'version' => trim( $version['Version'] ), |
| @@ -21,9 +23,9 @@ | ||
| 21 | 23 | return $item->to_json(); |
| 22 | 24 | }, $items ), |
| 23 | 25 | ); |
| 24 | 26 | |
| 25 | - return wp_json_encode( $items, JSON_PRETTY_PRINT ) . PHP_EOL; | |
| 27 | + return json_encode( $items, JSON_PRETTY_PRINT ).PHP_EOL; | |
| 26 | 28 | } |
| 27 | 29 | |
| 28 | 30 | public function load( $group, $filename, $data ) { |
| 29 | 31 | global $wpdb; |
| @@ -57,10 +59,9 @@ | ||
| 57 | 59 | foreach ( $json['redirects'] as $pos => $redirect ) { |
| 58 | 60 | unset( $redirect['id'] ); |
| 59 | 61 | |
| 60 | 62 | if ( ! isset( $group_map[ $redirect['group_id'] ] ) ) { |
| 61 | - $new_group = Red_Group::create( 'Group', 1 ); | |
| 62 | - $group_map[ $redirect['group_id'] ] = $new_group->get_id(); | |
| 63 | + $group_map[ $redirect['group_id'] ] = Red_Group::create( 'Group', 1 ); | |
| 63 | 64 | } |
| 64 | 65 | |
| 65 | 66 | if ( $redirect['match_type'] === 'url' && isset( $redirect['action_data'] ) && ! is_array( $redirect['action_data'] ) ) { |
| 66 | 67 | $redirect['action_data'] = array( 'url' => $redirect['action_data'] ); |
| @@ -70,9 +71,9 @@ | ||
| 70 | 71 | Red_Item::create( $redirect ); |
| 71 | 72 | $count++; |
| 72 | 73 | |
| 73 | 74 | // Helps reduce memory usage |
| 74 | - unset( $json['redirects'][ $pos ] ); | |
| 75 | + unset( $json['redirects'][$pos] ); | |
| 75 | 76 | $wpdb->queries = array(); |
| 76 | 77 | $wpdb->num_queries = 0; |
| 77 | 78 | } |
| 78 | 79 | } |