Simple 301 Redirects – Addon – Bulk Uploader - Version 1.0.5

Version Description

  • Option added to force PHP to auto detect line endings
Download this release

Release Info

Developer ashdurham
Plugin Icon 128x128 Simple 301 Redirects – Addon – Bulk Uploader
Version 1.0.5
Comparing to
See all releases

Code changes from version 1.0.4 to 1.0.5

Files changed (2) hide show
  1. readme.txt +7 -1
  2. simple-301-bulk-uploader.php +13 -3
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://durham.net.au/donate/
4
  Tags: simple 301 redirects, bulk upload, csv, 301, redirects
5
  Requires at least: 3.0.1
6
  Tested up to: 3.7.1
7
- Stable tag: 1.0.4
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -68,6 +68,9 @@ Have a question thats not listed? Get support either on the support forums here
68
 
69
  == Changelog ==
70
 
 
 
 
71
  = 1.0.4 =
72
  * Adding back a mistakenly removed mime type
73
 
@@ -85,6 +88,9 @@ Have a question thats not listed? Get support either on the support forums here
85
 
86
  == Upgrade Notice ==
87
 
 
 
 
88
  = 1.0.4 =
89
  * Adding back a mistakenly removed mime type
90
 
4
  Tags: simple 301 redirects, bulk upload, csv, 301, redirects
5
  Requires at least: 3.0.1
6
  Tested up to: 3.7.1
7
+ Stable tag: 1.0.5
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
68
 
69
  == Changelog ==
70
 
71
+ = 1.0.5 =
72
+ * Option added to force PHP to auto detect line endings
73
+
74
  = 1.0.4 =
75
  * Adding back a mistakenly removed mime type
76
 
88
 
89
  == Upgrade Notice ==
90
 
91
+ = 1.0.5 =
92
+ * Option added to force PHP to auto detect line endings
93
+
94
  = 1.0.4 =
95
  * Adding back a mistakenly removed mime type
96
 
simple-301-bulk-uploader.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Simple 301 Redirects - Addon - Bulk CSV Uploader
4
  Plugin URI: http://kingpro.me/plugins/support-plugins/simple-301-redirects-addon-bulk-csv-uploader
5
  Description: Adds the ability to upload a CSV to populate the Simple 301 Redirects plugin
6
- Version: 1.0.4
7
  Author: Ash Durham
8
  Author URI: http://durham.net.au/
9
  License: GPL2
@@ -70,6 +70,12 @@ if (!class_exists("Bulk301Uploader")) {
70
  <form method="post" action="options-general.php?page=301bulkoptions" enctype="multipart/form-data">
71
 
72
  <input type="file" name="301_bulk_redirects" />
 
 
 
 
 
 
73
 
74
  <p class="submit">
75
  <input type="submit" name="submit_bulk_301" class="button-primary" value="<?php _e('Upload 301s') ?>" />
@@ -84,7 +90,7 @@ if (!class_exists("Bulk301Uploader")) {
84
  /*
85
  save the redirects from the options page to the database
86
  */
87
- function save_bulk_redirects($data)
88
  {
89
  // Get Current Redirects
90
  $current_redirects = get_option('301_redirects');
@@ -120,6 +126,8 @@ if (!class_exists("Bulk301Uploader")) {
120
  $report .= "Size: " . ($data["size"] / 1024) . " kB<br /><br />";
121
 
122
  $row = 1;
 
 
123
 
124
  if (($handle = fopen($data["tmp_name"], "r")) !== FALSE) {
125
  while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
@@ -143,6 +151,8 @@ if (!class_exists("Bulk301Uploader")) {
143
  $report .= "File: ".print_r($data, 1);
144
  }
145
 
 
 
146
  return $report;
147
  }
148
  }
@@ -158,7 +168,7 @@ if (isset($bulk_redirect_plugin) && $bulk_redirect_plugin->check_for_parent()) {
158
 
159
  // if submitted, process the data
160
  if (isset($_POST['submit_bulk_301'])) {
161
- $report = $bulk_redirect_plugin->save_bulk_redirects($_FILES['301_bulk_redirects']);
162
  }
163
  }
164
 
3
  Plugin Name: Simple 301 Redirects - Addon - Bulk CSV Uploader
4
  Plugin URI: http://kingpro.me/plugins/support-plugins/simple-301-redirects-addon-bulk-csv-uploader
5
  Description: Adds the ability to upload a CSV to populate the Simple 301 Redirects plugin
6
+ Version: 1.0.5
7
  Author: Ash Durham
8
  Author URI: http://durham.net.au/
9
  License: GPL2
70
  <form method="post" action="options-general.php?page=301bulkoptions" enctype="multipart/form-data">
71
 
72
  <input type="file" name="301_bulk_redirects" />
73
+
74
+ <p>
75
+ <input type="hidden" name="auto_detect_end_line" value="0" />
76
+ <input type="checkbox" name="auto_detect_end_line" value="1" /> Auto Detect End of Line<br />
77
+ <span style="font-size: 10px;">If you are experiencing unusual results after uploading and/or you are using a Mac and have generated the CSV via excel, it is recommended to use this option to force PHP to detect the end of line automatically. By default, PHP has this turned off. This option changes the <strong>'auto_detect_line_endings'</strong> php.ini option temporarily while uploading and reading your CSV file.</span>
78
+ </p>
79
 
80
  <p class="submit">
81
  <input type="submit" name="submit_bulk_301" class="button-primary" value="<?php _e('Upload 301s') ?>" />
90
  /*
91
  save the redirects from the options page to the database
92
  */
93
+ function save_bulk_redirects($data, $auto_detect = 0)
94
  {
95
  // Get Current Redirects
96
  $current_redirects = get_option('301_redirects');
126
  $report .= "Size: " . ($data["size"] / 1024) . " kB<br /><br />";
127
 
128
  $row = 1;
129
+
130
+ if ($auto_detect == 1) ini_set('auto_detect_line_endings',TRUE);
131
 
132
  if (($handle = fopen($data["tmp_name"], "r")) !== FALSE) {
133
  while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
151
  $report .= "File: ".print_r($data, 1);
152
  }
153
 
154
+ if ($auto_detect == 1) ini_set('auto_detect_line_endings',FALSE);
155
+
156
  return $report;
157
  }
158
  }
168
 
169
  // if submitted, process the data
170
  if (isset($_POST['submit_bulk_301'])) {
171
+ $report = $bulk_redirect_plugin->save_bulk_redirects($_FILES['301_bulk_redirects'], $_POST['auto_detect_end_line']);
172
  }
173
  }
174