Simple 301 Redirects – Addon – Bulk Uploader - Version 1.2.3

Version Description

  • Fix some bugs
Download this release

Release Info

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

Code changes from version 1.0.15 to 1.2.3

includes/admin-notices.php ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Admin Notices class
5
+ *
6
+ * @package WordPress
7
+ * @subpackage Admin Notices
8
+ */
9
+ class Admin_Notices {
10
+
11
+ // Configuration
12
+ // ---------------------------------------------------------------------------------------------------
13
+
14
+ /**
15
+ * Plugin suggestions
16
+ */
17
+ private $days_dismissing_suggestions = 180; // 6 months reappear
18
+ private $suggestions_message;
19
+ private $suggestions;
20
+
21
+ // Properties
22
+ // ---------------------------------------------------------------------------------------------------
23
+ /**
24
+ * Store missing plugins
25
+ */
26
+ private $missing;
27
+ /**
28
+ * Default prefix
29
+ * Can be changed by the external initialization.
30
+ */
31
+ private $prefix = 'wbcr_srabup';
32
+ /**
33
+ * Caller plugin file
34
+ */
35
+ private $plugin_file;
36
+
37
+ /**
38
+ * Single class instance
39
+ */
40
+ private static $instance;
41
+
42
+ // Initialization
43
+ // ---------------------------------------------------------------------------------------------------
44
+
45
+ /**
46
+ * Create or retrieve instance
47
+ */
48
+ public static function instance($plugin_file = null)
49
+ {
50
+
51
+ // Avoid direct calls
52
+ if( !function_exists('add_action') ) {
53
+ die;
54
+ }
55
+
56
+ // Check instance
57
+ if( !isset(self::$instance) ) {
58
+ self::$instance = new self($plugin_file);
59
+ }
60
+
61
+ // Done
62
+ return self::$instance;
63
+ }
64
+
65
+
66
+ /**
67
+ * Constructor
68
+ */
69
+ private function __construct($plugin_file = null)
70
+ {
71
+ // Main plugin file
72
+ $this->plugin_file = isset($plugin_file)
73
+ ? $plugin_file
74
+ : __FILE__;
75
+
76
+ // Uninstall hook endpoint
77
+ register_uninstall_hook($this->plugin_file, array(__CLASS__, 'uninstall'));
78
+
79
+ $this->suggestions_message = '<b>%plugin% Recomended plugins:</b><br>';
80
+
81
+ $this->suggestions = array(
82
+ 'disable-admin-notices' => array(
83
+ 'name' => 'Disable admin notices',
84
+ 'desc' => 'This plugin helps to disable notices, so no annoying updates or nag notices (update to premium, leave a comment, etc.) will bug you anymore. You can hide any particular notice or all at once.',
85
+ 'filename' => 'disable-admin-notices.php',
86
+ ),
87
+ 'gonzales' => array(
88
+ 'name' => 'Assets Manager',
89
+ 'desc' => 'You can disable unused scripts and styles per page or at all website. It also helps to avoid duplication of similar scripts, fonts and styles.',
90
+ 'filename' => 'gonzales.php',
91
+ ),
92
+ 'hide-login-page' => array(
93
+ 'name' => 'Hide login and admin page',
94
+ 'desc' => 'This simple plugin safely hides login page and disables access to the WordPress admin page. Plugin doesn’t affect the source code, doesn’t rename files and doesn’t change your server configuration.',
95
+ 'filename' => 'hide-login-page.php',
96
+ ),
97
+ 'clearfy' => array(
98
+ 'name' => '<span style="color:#f44336;">Clearfy - base Wordpress optimization in one plugin</span>',
99
+ 'desc' => 'This is a free plugin to optimize Wordpress. We recommend that you use it, because it performs complex optimization, improves SEO, improves securety of your site, speeds up your site without replacing the popular optimization plugins, but simply completing them. For example, you can extended YOAST SEO features at 30%, and speed optimization plugins by 15-20%! Clearfy will allow you to get rid of a large number of small plug-ins and reduce the load on your site. Try it, it\'s free!',
100
+ 'url' => 'https://clearfy.pro/?utm_source=wordpress.org&utm_campaign=simple-301-redirects-addon-bulk-uploader',
101
+ )
102
+ );
103
+
104
+ // Check notices
105
+ if( is_admin() ) {
106
+ $this->check_timestamps();
107
+ $this->check_suggestions();
108
+ }
109
+ }
110
+
111
+ // Timestamp checks
112
+ // ---------------------------------------------------------------------------------------------------
113
+
114
+ /**
115
+ * Creates the activation timestamp only if it does not exist
116
+ */
117
+ private function check_timestamps()
118
+ {
119
+ $timestamp = $this->get_activation_timestamp();
120
+ if( empty($timestamp) ) {
121
+ $this->update_activation_timestamp();
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Check the suggestions dismissed timestamp
127
+ */
128
+ private function check_suggestions()
129
+ {
130
+
131
+ // Compare timestamp
132
+ $timestamp = $this->get_dismissed_timestamp('suggestions');
133
+ if( empty($timestamp) || (time() - $timestamp) > ($this->days_dismissing_suggestions * 86400) ) {
134
+
135
+ // Check AJAX submit
136
+ if( defined('DOING_AJAX') && DOING_AJAX ) {
137
+ add_action('wp_ajax_' . $this->prefix . '_dismiss_suggestions', array(
138
+ &$this,
139
+ 'dismiss_suggestions'
140
+ ));
141
+ // Admin area (except install or activate plugins page)
142
+ } elseif( !in_array(basename($_SERVER['PHP_SELF']), array(
143
+ 'plugins.php',
144
+ 'plugin-install.php',
145
+ 'update.php'
146
+ ))
147
+ ) {
148
+ add_action('wp_loaded', array(&$this, 'load_notices_suggestions'), PHP_INT_MAX);
149
+ }
150
+ }
151
+ }
152
+
153
+ // Loaders
154
+ // ---------------------------------------------------------------------------------------------------
155
+
156
+ /**
157
+ * Check and load the sugestions notices
158
+ */
159
+ public function load_notices_suggestions()
160
+ {
161
+ // Check the disable nag constant
162
+ if( $this->disable_nag_notices() ) {
163
+ return;
164
+ }
165
+
166
+ // Collect missing plugins
167
+ $this->missing = $this->get_missing_plugins();
168
+ if( !empty($this->missing) && is_array($this->missing) ) {
169
+ add_action('admin_footer', array(&$this, 'admin_footer_suggestions'));
170
+ add_action('admin_notices', array(&$this, 'admin_notices_suggestions'));
171
+ }
172
+ }
173
+
174
+ // Admin Notices display
175
+ // ---------------------------------------------------------------------------------------------------
176
+
177
+ /**
178
+ * Suggestions display
179
+ */
180
+ public function admin_notices_suggestions()
181
+ {
182
+ $plugin_data = get_plugin_data($this->plugin_file);
183
+
184
+ ?>
185
+ <div class="<?php echo esc_attr($this->prefix); ?>-dismiss-suggestions notice notice-success is-dismissible" data-nonce="<?php echo esc_attr(wp_create_nonce($this->prefix . '-dismiss-suggestions')); ?>">
186
+ <p><?php echo str_replace('%plugin%', $plugin_data['Name'], $this->suggestions_message); ?></p>
187
+ <ul><?php foreach($this->missing as $plugin) : ?>
188
+
189
+ <li><strong><?php echo $this->suggestions[$plugin]['name']; ?></strong>
190
+ <a href="<?php echo esc_url($this->get_install_url($plugin)); ?>">
191
+ <?php if( in_array(get_locale(), array(
192
+ 'ru_RU',
193
+ 'bel',
194
+ 'kk',
195
+ 'uk',
196
+ 'bg',
197
+ 'bg_BG',
198
+ 'ka_GE'
199
+ )) ): ?>
200
+ (Установить бесплатно)
201
+ <?php else: ?>
202
+ (Install for free)
203
+ <?php endif ?>
204
+ </a><br/><?php echo $this->suggestions[$plugin]['desc']; ?></li>
205
+
206
+ <?php endforeach; ?></ul>
207
+ </div>
208
+ <?php
209
+ }
210
+
211
+ // AJAX Handlers
212
+ // ---------------------------------------------------------------------------------------------------
213
+
214
+ /**
215
+ * Dismiss suggestions
216
+ */
217
+ public function dismiss_suggestions()
218
+ {
219
+ if( !empty($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], $this->prefix . '-dismiss-suggestions') ) {
220
+ $this->update_dismissed_timestamp('suggestions');
221
+ }
222
+ }
223
+
224
+
225
+ // Plugins information retrieval
226
+ // ---------------------------------------------------------------------------------------------------
227
+
228
+ /**
229
+ * Retrieve uninstalled plugins
230
+ */
231
+ private function get_missing_plugins()
232
+ {
233
+
234
+ // Initialize
235
+ $inactive = array();
236
+
237
+ // Check plugins directory
238
+ $directories = array_merge(self::get_mu_plugins_directories(), self::get_plugins_directories());
239
+ if( !empty($directories) ) {
240
+ $required = array_keys($this->suggestions);
241
+ foreach($required as $plugin) {
242
+ if( !in_array($plugin, $directories) ) {
243
+ $inactive[] = $plugin;
244
+ }
245
+ }
246
+ }
247
+
248
+ // Check inactives
249
+ if( empty($inactive) ) {
250
+ return false;
251
+ }
252
+
253
+ // Done
254
+ return $inactive;
255
+ }
256
+
257
+
258
+ /**
259
+ * Collects all active plugins
260
+ */
261
+ private function get_plugins_directories()
262
+ {
263
+
264
+ // Initialize
265
+ $directories = array();
266
+
267
+ // Plugins split directory
268
+ $split = '/' . basename(WP_CONTENT_DIR) . '/' . basename(WP_PLUGIN_DIR) . '/';
269
+
270
+ // Multisite plugins
271
+ if( is_multisite() ) {
272
+ $ms_plugins = wp_get_active_network_plugins();
273
+ if( !empty($ms_plugins) && is_array($ms_plugins) ) {
274
+ foreach($ms_plugins as $file) {
275
+ $directory = explode($split, $file);
276
+ $directory = explode('/', ltrim($directory[1], '/'));
277
+ $directory = $directory[0];
278
+ if( !in_array($directory, $directories) ) {
279
+ $directories[] = $directory;
280
+ }
281
+ }
282
+ }
283
+ }
284
+
285
+ // Active plugins
286
+ $plugins = wp_get_active_and_valid_plugins();
287
+ if( !empty($plugins) && is_array($plugins) ) {
288
+ foreach($plugins as $file) {
289
+ $directory = explode($split, $file);
290
+ $directory = explode('/', ltrim($directory[1], '/'));
291
+ $directory = $directory[0];
292
+ if( !in_array($directory, $directories) ) {
293
+ $directories[] = $directory;
294
+ }
295
+ }
296
+ }
297
+
298
+ // Done
299
+ return $directories;
300
+ }
301
+
302
+
303
+ /**
304
+ * Retrieve mu-plugins directories
305
+ */
306
+ private function get_mu_plugins_directories()
307
+ {
308
+
309
+ // Initialize
310
+ $directories = array();
311
+
312
+ // Dependencies
313
+ if( !function_exists('get_plugins') ) {
314
+ require_once(ABSPATH . 'wp-admin/includes/plugin.php');
315
+ }
316
+
317
+ // Retrieve mu-plugins
318
+ $plugins = get_plugins('/../mu-plugins');
319
+ if( !empty($plugins) && is_array($plugins) ) {
320
+ foreach($plugins as $path => $info) {
321
+ $directory = dirname($path);
322
+ if( !in_array($directory, array('.', '..')) ) {
323
+ $directories[] = $directory;
324
+ }
325
+ }
326
+ }
327
+
328
+ // Done
329
+ return $directories;
330
+ }
331
+
332
+
333
+ /**
334
+ * Plugin install/activate URL
335
+ */
336
+ private function get_install_url($plugin)
337
+ {
338
+ if( !isset($this->suggestions[$plugin]['filename']) && isset($this->suggestions[$plugin]['url']) ) {
339
+ return $this->suggestions[$plugin]['url'];
340
+ }
341
+
342
+ // Check existing plugin
343
+ $exists = @file_exists(WP_PLUGIN_DIR . '/' . $plugin);
344
+
345
+ // Activate
346
+ if( $exists ) {
347
+
348
+ // Existing plugin
349
+ $path = $plugin . '/' . $this->suggestions[$plugin]['filename'];
350
+
351
+ return admin_url('plugins.php?action=activate&plugin=' . $path . '&_wpnonce=' . wp_create_nonce('activate-plugin_' . $path));
352
+ // Install
353
+ } else {
354
+
355
+ // New plugin
356
+ return admin_url('update.php?action=install-plugin&plugin=' . $plugin . '&_wpnonce=' . wp_create_nonce('install-plugin_' . $plugin));
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Determines the admin notices display
362
+ */
363
+ private function disable_nag_notices()
364
+ {
365
+ return (defined('DISABLE_NAG_NOTICES') && DISABLE_NAG_NOTICES);
366
+ }
367
+
368
+ // Plugin related
369
+ // ---------------------------------------------------------------------------------------------------
370
+
371
+ /**
372
+ * Plugin uninstall hook
373
+ */
374
+ public static function uninstall()
375
+ {
376
+ $admin_notices = self::instance();
377
+ $admin_notices->delete_activation_timestamp();
378
+ $admin_notices->delete_dismissed_timestamp('suggestions');
379
+ }
380
+
381
+
382
+
383
+ // Activation timestamp management
384
+ // ---------------------------------------------------------------------------------------------------
385
+
386
+ /**
387
+ * Retrieves the plugin activation timestamp
388
+ */
389
+ private function get_activation_timestamp()
390
+ {
391
+ return (int)get_option($this->prefix . '_activated_on');
392
+ }
393
+
394
+ /**
395
+ * Updates activation timestamp
396
+ */
397
+ private function update_activation_timestamp()
398
+ {
399
+ update_option($this->prefix . '_activated_on', time(), true);
400
+ }
401
+
402
+ /**
403
+ * Removes activation timestamp
404
+ */
405
+ private function delete_activation_timestamp()
406
+ {
407
+ delete_option($this->prefix . '_activated_on');
408
+ }
409
+
410
+ // Dismissed timestamp management
411
+ // ---------------------------------------------------------------------------------------------------
412
+
413
+ /**
414
+ * Current timestamp by key
415
+ */
416
+ private function get_dismissed_timestamp($key)
417
+ {
418
+ return (int)get_option($this->prefix . '_dismissed_' . $key . '_on');
419
+ }
420
+
421
+ /**
422
+ * Update with the current timestamp
423
+ */
424
+ private function update_dismissed_timestamp($key)
425
+ {
426
+ update_option($this->prefix . '_dismissed_' . $key . '_on', time(), true);
427
+ }
428
+
429
+ /**
430
+ * Removes dismissied option
431
+ */
432
+ private function delete_dismissed_timestamp($key)
433
+ {
434
+ delete_option($this->prefix . '_dismissed_' . $key . '_on');
435
+ }
436
+
437
+ // Javascript code
438
+ // ---------------------------------------------------------------------------------------------------
439
+
440
+ /**
441
+ * Footer script for Suggestions
442
+ */
443
+ public function admin_footer_suggestions()
444
+ {
445
+ ?>
446
+ <script type="text/javascript">
447
+ jQuery(function($) {
448
+
449
+ $(document).on('click', '.<?php echo $this->prefix; ?>-dismiss-suggestions .notice-dismiss', function() {
450
+ $.post(ajaxurl, {
451
+ 'action': '<?php echo $this->prefix; ?>_dismiss_suggestions',
452
+ 'nonce': $(this).parent().attr('data-nonce')
453
+ });
454
+ });
455
+
456
+ });
457
+ </script>
458
+ <?php
459
+ }
460
+ }
languages/s301r-bulk-uploader-ru_RU.mo ADDED
Binary file
languages/s301r-bulk-uploader-ru_RU.po ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: clearfy\n"
4
+ "POT-Creation-Date: 2018-06-26 21:03+0300\n"
5
+ "PO-Revision-Date: 2018-06-26 21:09+0300\n"
6
+ "Last-Translator: alex.kovalevv@gmail.com <alex.kovalevv@gmail.com>\n"
7
+ "Language-Team: Alex Kovalev <alex.kovalevv@gmail.com>\n"
8
+ "Language: ru_RU\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.8.8\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
15
+ "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c\n"
18
+ "X-Poedit-SearchPath-0: .\n"
19
+ "X-Poedit-SearchPathExcluded-0: libs\n"
20
+ "X-Poedit-SearchPathExcluded-1: components\n"
21
+ "X-Poedit-SearchPathExcluded-2: cache\n"
22
+
23
+ #: simple-301-bulk-uploader.php:81
24
+ msgid ""
25
+ "301 Bulk Uploader requires the Simple 301 Redirects plugin to be installed "
26
+ "and active in order to work."
27
+ msgstr ""
28
+ "Для работы 301 Bulk Uploader требуется, чтобы плагин Simple 301 Redirects "
29
+ "был установлен и активирован."
30
+
31
+ #: simple-301-bulk-uploader.php:91
32
+ msgid "301 Bulk Redirects"
33
+ msgstr ""
34
+
35
+ #: simple-301-bulk-uploader.php:105
36
+ msgid "Simple 301 Redirects - Bulk Upload"
37
+ msgstr "Simple 301 Redirects - массовая загрузка"
38
+
39
+ #: simple-301-bulk-uploader.php:106
40
+ msgid "Example CSV"
41
+ msgstr "Пример CSV"
42
+
43
+ #: simple-301-bulk-uploader.php:108
44
+ msgid "Export current 301's to CSV"
45
+ msgstr ""
46
+
47
+ #: simple-301-bulk-uploader.php:110
48
+ msgid ""
49
+ "Are you sure you want to do this? This will not be able to be retrieved. As "
50
+ "a backup, please use the export feature to download a current copy before "
51
+ "doing this."
52
+ msgstr ""
53
+
54
+ #: simple-301-bulk-uploader.php:112
55
+ msgid "Clear 301 Redirect List (DO SO WITH CAUTION!)"
56
+ msgstr ""
57
+
58
+ #: simple-301-bulk-uploader.php:119
59
+ msgid "Auto Detect End of Line"
60
+ msgstr ""
61
+
62
+ #: simple-301-bulk-uploader.php:121
63
+ msgid ""
64
+ "If you are experiencing unusual results after uploading and/or you are using "
65
+ "a Mac and have generated the CSV via excel, it is recommended to use this "
66
+ "option to force PHP to detect the end of line automatically. By default, PHP "
67
+ "has this turned off. This option changes the "
68
+ "<strong>'auto_detect_line_endings'</strong> php.ini option temporarily while "
69
+ "uploading and reading your CSV file."
70
+ msgstr ""
71
+
72
+ #: simple-301-bulk-uploader.php:125
73
+ msgid "Upload 301s"
74
+ msgstr ""
75
+
76
+ #: simple-301-bulk-uploader.php:186
77
+ msgid "was added to redirect to"
78
+ msgstr ""
79
+
80
+ #: simple-301-bulk-uploader.php:188
81
+ msgid "is missing a corresponding URL to redirect to"
82
+ msgstr ""
83
+
84
+ #: simple-301-bulk-uploader.php:189
85
+ msgid "already exists and was not added"
86
+ msgstr ""
87
+
88
+ #: simple-301-bulk-uploader.php:196
89
+ msgid ""
90
+ "<strong>Invalid file</strong>. Use the below for debugging and when asking "
91
+ "for support."
92
+ msgstr ""
93
+
94
+ #: simple-301-bulk-uploader.php:198
95
+ msgid "File"
96
+ msgstr ""
97
+
98
+ #: simple-301-bulk-uploader.php:200
99
+ msgid "Approved Mime Types"
100
+ msgstr ""
101
+
102
+ #: simple-301-bulk-uploader.php:203
103
+ msgid ""
104
+ "If you are certain that your filetype should be in this list, please let us "
105
+ "know on the"
106
+ msgstr ""
107
+
108
+ #: simple-301-bulk-uploader.php:203
109
+ msgid "forums"
110
+ msgstr "форумы"
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Simple 301 Redirects - Addon - Bulk Uploader ===
2
- Contributors: Webcraftic, ashdurham
3
- 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: 4.4.2
7
- Stable tag: 1.0.14
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,12 +12,6 @@ Adds on the ability to bulk upload 301 redirects via CSV to the Simple 301 Redir
12
 
13
  == Description ==
14
 
15
- --
16
-
17
- Stay up-to-date with the latest by following [@kingproplugins on Twitter](http://twitter.com/kingproplugins), [KingProPlugins on Facebook](http://facebook.com/kingproplugins) or [King Pro Plugins on Google+](https://plus.google.com/b/101488033905569308183/101488033905569308183/about)
18
-
19
- --
20
-
21
  This is an ADDON plugin to give further functionality to the plugin [Simple 301 Redirects](http://wordpress.org/plugins/simple-301-redirects/) plugin.
22
 
23
  [Simple 301 Redirects - Addon - Bulk Uploader](http://kingpro.me/plugins/support-plugins/simple-301-redirects-addon-bulk-uploader/) adds an extra section to the settings tab
@@ -33,7 +27,22 @@ Any issues you are having, I'd also love to know, so again, please let me know u
33
 
34
  --
35
 
36
- [Check out the King Pro Plugins range](http://kingpro.me/)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
 
39
  == Installation ==
@@ -67,59 +76,12 @@ Have a question thats not listed? Get support either on the support forums here
67
  --
68
 
69
  == Changelog ==
70
- = 1.0.15 =
71
- * Updated contributors
72
-
73
- = 1.0.14 =
74
- * Added mime type "plain/text"
75
-
76
- = 1.0.13 =
77
- * Added mime type "application/ms-excel"
78
- * Added mime type "application/x-excel"
79
 
80
- = 1.0.12 =
81
- * Updated permissions to match that of the parent plugin
82
- * Another mime type added
83
- * Added icons for WP4.0
84
-
85
- = 1.0.11 =
86
- * Addition of another mime type
87
- * Addition of some error code to help determine mime type issues
88
-
89
- = 1.0.10 =
90
- * Addition of another mime type found in Firefox
91
-
92
- = 1.0.9 =
93
- * Update to deprecated user levels to the matching role
94
-
95
- = 1.0.8 =
96
- * Added ability to delete 301 redirect list
97
-
98
- = 1.0.7 =
99
- * Update to allowed file type list
100
-
101
- = 1.0.6 =
102
- * Export to CSV feature
103
-
104
- = 1.0.5 =
105
- * Option added to force PHP to auto detect line endings
106
-
107
- = 1.0.4 =
108
- * Adding back a mistakenly removed mime type
109
-
110
- = 1.0.3 =
111
- * Addition of another mime type
112
-
113
- = 1.0.2 =
114
- * Addition of further mime types
115
-
116
- = 1.0.1 =
117
- * Update to uploader to read the file coming from a PC
118
-
119
- = 1.0 =
120
- * Initial
121
-
122
- == Upgrade Notice ==
123
 
124
  = 1.0.14 =
125
  * Added mime type "plain/text"
@@ -144,7 +106,7 @@ Have a question thats not listed? Get support either on the support forums here
144
  * Update to deprecated user levels to the matching role
145
 
146
  = 1.0.8 =
147
- * Added ability to delete 301 redirects list
148
 
149
  = 1.0.7 =
150
  * Update to allowed file type list
@@ -168,4 +130,4 @@ Have a question thats not listed? Get support either on the support forums here
168
  * Update to uploader to read the file coming from a PC
169
 
170
  = 1.0 =
171
- * Gotta start somewhere
1
  === Simple 301 Redirects - Addon - Bulk Uploader ===
2
+ Contributors: webcraftic, ashdurham
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VDX7JNTQPNPFW
4
  Tags: simple 301 redirects, bulk upload, csv, 301, redirects
5
  Requires at least: 3.0.1
6
+ Tested up to: 4.9.6
7
+ Stable tag: trunk
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
 
 
 
 
 
 
15
  This is an ADDON plugin to give further functionality to the plugin [Simple 301 Redirects](http://wordpress.org/plugins/simple-301-redirects/) plugin.
16
 
17
  [Simple 301 Redirects - Addon - Bulk Uploader](http://kingpro.me/plugins/support-plugins/simple-301-redirects-addon-bulk-uploader/) adds an extra section to the settings tab
27
 
28
  --
29
 
30
+ #### BIG THANKS ####
31
+ Many thanks to [Ash Durham](http://kingpro.me/), for his great contribution to the development of this plugin.
32
+ He has excellent projects, you can find out about them here [@kingproplugins on Twitter](http://twitter.com/kingproplugins), [KingProPlugins on Facebook](http://facebook.com/kingproplugins) or [King Pro Plugins on Google+](https://plus.google.com/b/101488033905569308183/101488033905569308183/about)
33
+
34
+ #### Recommended our plugins ####
35
+
36
+ We invite you to check out a few other related free plugins that our team has also produced that you may find especially useful:
37
+
38
+ * [Clearfy – WordPress optimization plugin and disable ultimate tweaker](https://wordpress.org/plugins/clearfy/)
39
+ * [Disable Comments for Any Post Types (Remove Comments)](https://wordpress.org/plugins/comments-plus/)
40
+ * [Cyrlitera – transliteration of links and file names](https://wordpress.org/plugins/cyrlitera/)
41
+ * [Cyr-to-lat reloaded – transliteration of links and file names](https://wordpress.org/plugins/cyr-and-lat/ "Cyr-to-lat reloaded")
42
+ * [Disable admin notices individually](https://wordpress.org/plugins/disable-admin-notices/ "Disable admin notices individually")
43
+ * [Hide login page](https://wordpress.org/plugins/hide-login-page/ "Hide login page")
44
+ * [Disable updates, Disable automatic updates, Updates manager](https://wordpress.org/plugins/webcraftic-updates-manager/)
45
+ * [WordPress Assets manager, dequeue scripts, dequeue styles](https://wordpress.org/plugins/gonzales/ "WordPress Assets manager, dequeue scripts, dequeue styles")
46
 
47
 
48
  == Installation ==
76
  --
77
 
78
  == Changelog ==
79
+ = 1.2.3 =
80
+ * Fix some bugs
 
 
 
 
 
 
 
81
 
82
+ = 1.2.2 =
83
+ * Compatible with the latest version of Wordpress
84
+ * Bug fixes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
  = 1.0.14 =
87
  * Added mime type "plain/text"
106
  * Update to deprecated user levels to the matching role
107
 
108
  = 1.0.8 =
109
+ * Added ability to delete 301 redirect list
110
 
111
  = 1.0.7 =
112
  * Update to allowed file type list
130
  * Update to uploader to read the file coming from a PC
131
 
132
  = 1.0 =
133
+ * Initial
simple-301-bulk-uploader.php CHANGED
@@ -1,226 +1,268 @@
1
  <?php
2
- /*
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.15
7
- Author: Webcraftic, Ash Durham
8
- Author URI: http://durham.net.au/
9
- License: GPL2
10
-
11
- Copyright 2016 Ash Durham (email : plugins@kingpro.me)
12
-
13
- This program is free software; you can redistribute it and/or modify
14
- it under the terms of the GNU General Public License, version 2, as
15
- published by the Free Software Foundation.
16
-
17
- This program is distributed in the hope that it will be useful,
18
- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- GNU General Public License for more details.
21
-
22
- You should have received a copy of the GNU General Public License
23
- along with this program; if not, write to the Free Software
24
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
- */
26
-
27
- if (!class_exists("Bulk301Uploader")) {
28
- class Bulk301Uploader {
29
- /*
30
- check if Simple 301 Redirects exists and is active
31
- */
32
- function check_for_parent()
33
- {
34
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
35
- if (!is_plugin_active('simple-301-redirects/wp-simple-301-redirects.php')) {
36
- add_action( 'admin_notices', array($this,'bulk301_admin_notice') );
37
- return false;
38
- }
39
- return true;
40
- }
41
-
42
- function bulk301_admin_notice() {
43
- ?>
44
- <div class="error">
45
- <p><?php _e( "301 Bulk Uploader requires the Simple 301 Redirects plugin to be installed and active in order to work.", 'bulk301_text' ); ?></p>
46
- </div>
47
- <?php
48
- }
49
-
50
- /*
51
- generate the link to the options page under settings
52
- */
53
- function create_bulk_menu()
54
- {
55
- add_options_page('301 Bulk Redirects', '301 Bulk Redirects', 'manage_options', '301bulkoptions', array($this,'bulk_options_page'));
56
- }
57
-
58
- /*
59
- generate the options page in the wordpress admin
60
- */
61
- function bulk_options_page()
62
- {
63
- global $report;
64
- ?>
65
- <div class="wrap">
66
- <h2>Simple 301 Redirects - Bulk Upload</h2>
67
-
68
- <a href="<?= plugins_url( '301-example.csv', __FILE__ ); ?>">Example CSV</a> - <a href='<?= admin_url('admin.php?action=bulk301export') ?>'>Export current 301's to CSV</a> - <a href="<?= admin_url('admin.php?action=bulk301clearlist') ?>" onclick="if(confirm('Are you sure you want to do this? This will not be able to be retrieved. As a backup, please use the export feature to download a current copy before doing this.')) return true; else return false;">Clear 301 Redirect List (DO SO WITH CAUTION!)</a>
69
-
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') ?>" />
82
- </p>
83
- </form>
84
-
85
- <?php if (isset($report)) : echo $report; endif; ?>
86
- </div>
87
- <?php
88
- } // end of function options_page
89
-
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');
97
-
98
- // Get CSV File
99
- $allowedExts = array("csv");
100
- $temp = explode(".", $data["name"]);
101
- $extension = end($temp);
102
- $report = '';
103
-
104
- $mime_types = array(
105
- 'application/csv',
106
- 'application/excel',
107
- 'application/ms-excel',
108
- 'application/x-excel',
109
- 'application/vnd.ms-excel',
110
- 'application/vnd.msexcel',
111
- 'application/octet-stream',
112
- 'application/data',
113
- 'application/x-csv',
114
- 'application/txt',
115
- 'plain/text',
116
- 'text/anytext',
117
- 'text/csv',
118
- 'text/x-csv',
119
- 'text/plain',
120
- 'text/comma-separated-values'
121
- );
122
-
123
- if (in_array($data["type"], $mime_types)
124
- && ($data["size"] < 10000000)
125
- && in_array($extension, $allowedExts))
126
- {
127
- if ($data["error"] > 0)
128
- {
129
- $report .= "Return Code: " . $data["error"] . "<br>";
130
- }
131
- else
132
- {
133
- $report .= "Upload: " . $data["name"] . "<br />";
134
- $report .= "Size: " . ($data["size"] / 1024) . " kB<br /><br />";
135
-
136
- $row = 1;
137
-
138
- if ($auto_detect == 1) ini_set('auto_detect_line_endings',TRUE);
139
-
140
- if (($handle = fopen($data["tmp_name"], "r")) !== FALSE) {
141
- while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
142
- $num = count($data);
143
- $row++;
144
- if (!isset($current_redirects[$data[0]]) && $data[1] !== '') {
145
- $current_redirects[$data[0]] = $data[1];
146
- $report .= "<strong>".$data[0]."</strong> was added to redirect to ".$data[1]."<br />";
147
- } elseif (!isset($current_redirects[$data[0]]) && $data[1] !== '') {
148
- $report .= "<span style='color: red'><strong>".$data[0]."</strong> is missing a corresponding URL to redirect to.</span><br />";
149
- } else $report .= "<span style='color: red'><strong>".$data[0]."</strong> already exists and was not added.</span><br />";
150
- }
151
- fclose($handle);
152
- update_option('301_redirects', $current_redirects);
153
- }
154
- }
155
- }
156
- else
157
- {
158
- $report .= "<strong>Invalid file</strong>. Use the below for debugging and when asking for support.<br /><br />";
159
- $report .= "<strong>File</strong>: ".print_r($data, 1);
160
- if (!in_array($data["type"], $mime_types))
161
- {
162
- $report .= "<br /><br /><strong>Approved Mime Types</strong>:<br />";
163
- foreach ($mime_types as $mtype)
164
- $report .= $mtype."<br />";
165
- $report .= "<br />If you are certain that your filetype should be in this list, please let us know on the <a href='http://wordpress.org/support/plugin/simple-301-redirects-addon-bulk-uploader' target='_blank'>forums</a>.";
166
- }
167
- }
168
-
169
- if ($auto_detect == 1) ini_set('auto_detect_line_endings',FALSE);
170
-
171
- return $report;
172
- }
173
-
174
- /*
175
- Export redirects to CSV
176
- */
177
- function export_bulk_redirects() {
178
- // Get Current Redirects
179
- $current_redirects = get_option('301_redirects');
180
-
181
- header('Content-Type: application/excel');
182
- header('Content-Disposition: attachment; filename="301_redirects.csv"');
183
- $data = array();
184
-
185
- foreach ($current_redirects as $old_url=>$new_url) {
186
- $data[] = array($old_url,$new_url);
187
- }
188
-
189
- $fp = fopen('php://output', 'w');
190
- foreach ( $data as $line ) {
191
- fputcsv($fp, $line);
192
- }
193
- fclose($fp);
194
- }
195
-
196
- /*
197
- Clear 301 Redirects list
198
- */
199
- function clear_301_redirects() {
200
- update_option('301_redirects', '');
201
- header("Location: ".$_SERVER['HTTP_REFERER']);
202
- }
203
- }
204
- }
205
-
206
- // instantiate
207
- $bulk_redirect_plugin = new Bulk301Uploader();
208
-
209
- if (isset($bulk_redirect_plugin) && $bulk_redirect_plugin->check_for_parent()) {
210
-
211
- // create the menu
212
- add_action('admin_menu', array($bulk_redirect_plugin,'create_bulk_menu'));
213
-
214
- // Create export action
215
- add_action( 'admin_action_bulk301export', array($bulk_redirect_plugin,'export_bulk_redirects') );
216
-
217
- // Create clear action
218
- add_action( 'admin_action_bulk301clearlist', array($bulk_redirect_plugin,'clear_301_redirects') );
219
-
220
- // if submitted, process the data
221
- if (isset($_POST['submit_bulk_301'])) {
222
- $report = $bulk_redirect_plugin->save_bulk_redirects($_FILES['301_bulk_redirects'], $_POST['auto_detect_end_line']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  }
224
- }
225
 
226
  ?>
1
  <?php
2
+ /**
3
+ * Plugin Name: Simple 301 Redirects - Addon - Bulk CSV Uploader
4
+ * Plugin URI: https://wordpress.org/support/plugin/simple-301-redirects-addon-bulk-uploader
5
+ * Description: Adds the ability to upload a CSV to populate the Simple 301 Redirects plugin
6
+ * Author: Webcraftic <wordpress.webraftic@gmail.com>, Ash Durham <plugins@kingpro.me>
7
+ * Version: 1.2.3
8
+ * Text Domain: s301r-bulk-uploader
9
+ * Domain Path: /languages/
10
+ * Author URI: https://clearfy.pro
11
+ */
12
+
13
+ /*
14
+ Copyright 2018 Webcraftic (email : wordpress.webraftic@gmail.com)
15
+ Copyright 2016 Ash Durham (email : plugins@kingpro.me)
16
+
17
+ This program is free software; you can redistribute it and/or modify
18
+ it under the terms of the GNU General Public License, version 2, as
19
+ published by the Free Software Foundation.
20
+
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program; if not, write to the Free Software
28
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29
+ */
30
+
31
+ if( !class_exists("Bulk301Uploader") ) {
32
+
33
+ class Bulk301Uploader {
34
+
35
+ public function __construct()
36
+ {
37
+ require_once dirname(__FILE__) . '/includes/admin-notices.php';
38
+ Admin_Notices::instance(__FILE__);
39
+
40
+ add_filter('plugin_row_meta', array($this, 'setPluginMeta'), 10, 2);
41
+ // Localization plugin
42
+ load_plugin_textdomain('s301r-bulk-uploader', false, dirname(plugin_basename(__FILE__)) . '/languages/');
43
+ }
44
+
45
+ /**
46
+ * @param $links
47
+ * @param $file
48
+ * @return array
49
+ */
50
+ public function setPluginMeta($links, $file)
51
+ {
52
+ $link_title = 'Speed up your site for one click (100% free)';
53
+ $url = 'https://clearfy.pro/?utm_source=wordpress.org&utm_campaign=simple-301-redirects-addon-bulk-uploader';
54
+
55
+ if( $file == plugin_basename(__FILE__) ) {
56
+ $links[] = '<a href="' . $url . '" style="color: #FF5722;font-weight: bold;" target="_blank">' . $link_title . '</a>';
57
+ }
58
+
59
+ return $links;
60
+ }
61
+
62
+ /*
63
+ check if Simple 301 Redirects exists and is active
64
+ */
65
+ public function check_for_parent()
66
+ {
67
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
68
+ if( !is_plugin_active('simple-301-redirects/wp-simple-301-redirects.php') ) {
69
+ add_action('admin_notices', array($this, 'bulk301_admin_notice'));
70
+
71
+ return false;
72
+ }
73
+
74
+ return true;
75
+ }
76
+
77
+ public function bulk301_admin_notice()
78
+ {
79
+ ?>
80
+ <div class="error">
81
+ <p><?php _e("301 Bulk Uploader requires the Simple 301 Redirects plugin to be installed and active in order to work.", 's301r-bulk-uploader'); ?></p>
82
+ </div>
83
+ <?php
84
+ }
85
+
86
+ /*
87
+ generate the link to the options page under settings
88
+ */
89
+ public function create_bulk_menu()
90
+ {
91
+ add_options_page(__('301 Bulk Redirects', 's301r-bulk-uploader'), __('301 Bulk Redirects', 's301r-bulk-uploader'), 'manage_options', '301bulkoptions', array(
92
+ $this,
93
+ 'bulk_options_page'
94
+ ));
95
+ }
96
+
97
+ /*
98
+ generate the options page in the wordpress admin
99
+ */
100
+ public function bulk_options_page()
101
+ {
102
+ global $report;
103
+ ?>
104
+ <div class="wrap">
105
+ <h2><?php _e('Simple 301 Redirects - Bulk Upload', 's301r-bulk-uploader') ?></h2>
106
+ <a href="<?= plugins_url('301-example.csv', __FILE__); ?>"><?php _e('Example CSV', 's301r-bulk-uploader') ?></a>
107
+ -
108
+ <a href='<?= admin_url('admin.php?action=bulk301export') ?>'><?php _e('Export current 301\'s to CSV', 's301r-bulk-uploader') ?></a>
109
+ -
110
+ <a href="<?= admin_url('admin.php?action=bulk301clearlist') ?>" onclick="if(confirm('<?php _e("Are you sure you want to do this? This will not be able to be retrieved. As a backup, please use the export feature to download a current copy before doing this.", 's301r-bulk-uploader') ?>')) {return true;
111
+ }else {return false;
112
+ }"><?php _e('Clear 301 Redirect List (DO SO WITH CAUTION!)', 's301r-bulk-uploader') ?></a>
113
+
114
+ <form method="post" action="options-general.php?page=301bulkoptions" enctype="multipart/form-data">
115
+ <input type="file" name="301_bulk_redirects"/>
116
+
117
+ <p>
118
+ <input type="hidden" name="auto_detect_end_line" value="0"/>
119
+ <input type="checkbox" name="auto_detect_end_line" value="1"/><?php _e('Auto Detect End of Line', 's301r-bulk-uploader') ?>
120
+ <br/>
121
+ <span style="font-size: 10px;"><?php _e("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.", 's301r-bulk-uploader') ?></span>
122
+ </p>
123
+
124
+ <p class="submit">
125
+ <input type="submit" name="submit_bulk_301" class="button-primary" value="<?php _e('Upload 301s', 's301r-bulk-uploader') ?>"/>
126
+ </p>
127
+ </form>
128
+
129
+ <?php if( isset($report) ) : echo $report; endif; ?>
130
+ </div>
131
+ <?php
132
+ } // end of function options_page
133
+
134
+ /*
135
+ save the redirects from the options page to the database
136
+ */
137
+ public function save_bulk_redirects($data, $auto_detect = 0)
138
+ {
139
+ // Get Current Redirects
140
+ $current_redirects = get_option('301_redirects');
141
+
142
+ // Get CSV File
143
+ $allowedExts = array("csv");
144
+ $temp = explode(".", $data["name"]);
145
+ $extension = end($temp);
146
+ $report = '';
147
+
148
+ $mime_types = array(
149
+ 'application/csv',
150
+ 'application/excel',
151
+ 'application/ms-excel',
152
+ 'application/x-excel',
153
+ 'application/vnd.ms-excel',
154
+ 'application/vnd.msexcel',
155
+ 'application/octet-stream',
156
+ 'application/data',
157
+ 'application/x-csv',
158
+ 'application/txt',
159
+ 'plain/text',
160
+ 'text/anytext',
161
+ 'text/csv',
162
+ 'text/x-csv',
163
+ 'text/plain',
164
+ 'text/comma-separated-values'
165
+ );
166
+
167
+ if( in_array($data["type"], $mime_types) && ($data["size"] < 10000000) && in_array($extension, $allowedExts) ) {
168
+ if( $data["error"] > 0 ) {
169
+ $report .= "Return Code: " . $data["error"] . "<br>";
170
+ } else {
171
+ $report .= "Upload: " . $data["name"] . "<br />";
172
+ $report .= "Size: " . ($data["size"] / 1024) . " kB<br /><br />";
173
+
174
+ $row = 1;
175
+
176
+ if( $auto_detect == 1 ) {
177
+ ini_set('auto_detect_line_endings', true);
178
+ }
179
+
180
+ if( ($handle = fopen($data["tmp_name"], "r")) !== false ) {
181
+ while( ($data = fgetcsv($handle, 1000, ",")) !== false ) {
182
+ $num = count($data);
183
+ $row++;
184
+ if( !isset($current_redirects[$data[0]]) && $data[1] !== '' ) {
185
+ $current_redirects[$data[0]] = $data[1];
186
+ $report .= "<strong>" . $data[0] . "</strong> " . __('was added to redirect to', 's301r-bulk-uploader') . $data[1] . "<br />";
187
+ } elseif( !isset($current_redirects[$data[0]]) && $data[1] !== '' ) {
188
+ $report .= "<span style='color: red'><strong>" . $data[0] . "</strong> " . __('is missing a corresponding URL to redirect to', 's301r-bulk-uploader') . ".</span><br />";
189
+ } else $report .= "<span style='color: red'><strong>" . $data[0] . "</strong> " . __('already exists and was not added', 's301r-bulk-uploader') . ".</span><br />";
190
+ }
191
+ fclose($handle);
192
+ update_option('301_redirects', $current_redirects);
193
+ }
194
+ }
195
+ } else {
196
+ $report .= __('<strong>Invalid file</strong>. Use the below for debugging and when asking for support.', 's301r-bulk-uploader') . "<br /><br />";
197
+
198
+ $report .= "<strong>" . __('File', 's301r-bulk-uploader') . "</strong>: " . print_r($data, 1);
199
+ if( !in_array($data["type"], $mime_types) ) {
200
+ $report .= "<br /><br /><strong>" . __('Approved Mime Types', 's301r-bulk-uploader') . "</strong>:<br />";
201
+ foreach($mime_types as $mtype)
202
+ $report .= $mtype . "<br />";
203
+ $report .= "<br />" . __('If you are certain that your filetype should be in this list, please let us know on the', 's301r-bulk-uploader') . " <a href='http://wordpress.org/support/plugin/simple-301-redirects-addon-bulk-uploader' target='_blank'>" . __('forums', 's301r-bulk-uploader') . "</a>.";
204
+ }
205
+ }
206
+
207
+ if( $auto_detect == 1 ) {
208
+ ini_set('auto_detect_line_endings', false);
209
+ }
210
+
211
+ return $report;
212
+ }
213
+
214
+ /*
215
+ Export redirects to CSV
216
+ */
217
+ public function export_bulk_redirects()
218
+ {
219
+ // Get Current Redirects
220
+ $current_redirects = get_option('301_redirects');
221
+
222
+ header('Content-Type: application/excel');
223
+ header('Content-Disposition: attachment; filename="301_redirects.csv"');
224
+ $data = array();
225
+
226
+ foreach($current_redirects as $old_url => $new_url) {
227
+ $data[] = array($old_url, $new_url);
228
+ }
229
+
230
+ $fp = fopen('php://output', 'w');
231
+ foreach($data as $line) {
232
+ fputcsv($fp, $line);
233
+ }
234
+ fclose($fp);
235
+ }
236
+
237
+ /*
238
+ Clear 301 Redirects list
239
+ */
240
+ public function clear_301_redirects()
241
+ {
242
+ update_option('301_redirects', '');
243
+ header("Location: " . $_SERVER['HTTP_REFERER']);
244
+ }
245
+ }
246
+ }
247
+
248
+ // instantiate
249
+ $bulk_redirect_plugin = new Bulk301Uploader();
250
+
251
+ if( isset($bulk_redirect_plugin) && $bulk_redirect_plugin->check_for_parent() ) {
252
+
253
+ // create the menu
254
+ add_action('admin_menu', array($bulk_redirect_plugin, 'create_bulk_menu'));
255
+
256
+ // Create export action
257
+ add_action('admin_action_bulk301export', array($bulk_redirect_plugin, 'export_bulk_redirects'));
258
+
259
+ // Create clear action
260
+ add_action('admin_action_bulk301clearlist', array($bulk_redirect_plugin, 'clear_301_redirects'));
261
+
262
+ // if submitted, process the data
263
+ if( isset($_POST['submit_bulk_301']) ) {
264
+ $report = $bulk_redirect_plugin->save_bulk_redirects($_FILES['301_bulk_redirects'], (int)$_POST['auto_detect_end_line']);
265
+ }
266
  }
 
267
 
268
  ?>