Permalink Manager Lite - Version 2.1.0

Version Description

  • Support for "url_to_postid" function
  • Bulk tools use now AJAX & transients to prevent timeout when large number of posts/terms is processed.
  • Fix for multi-domain language setup in WPML
Download this release

Release Info

Developer mbis
Plugin Icon 128x128 Permalink Manager Lite
Version 2.1.0
Comparing to
See all releases

Code changes from version 2.0.6.2.1 to 2.1.0

README.txt CHANGED
@@ -7,7 +7,7 @@ Tags: urls, permalinks, custom permalinks, url, permalink, woocommerce permalink
7
  Requires at least: 4.4.0
8
  Requires PHP: 5.4
9
  Tested up to: 4.9
10
- Stable tag: 2.0.6.2.1
11
 
12
  Advanced plugin that allows to set-up custom permalinks (bulk editors included), slugs and permastructures (WooCommerce compatible).
13
 
@@ -85,9 +85,31 @@ A. Currently there is no 100% guarantee that Permalink Manager will work correct
85
 
86
  == Changelog ==
87
 
88
- = 2.0.6.2 =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  * Japaneese translation added
90
  * Some minor improvements
 
 
 
91
 
92
  = 2.0.6.1 =
93
  * Hotfix for endpoints in REGEX
7
  Requires at least: 4.4.0
8
  Requires PHP: 5.4
9
  Tested up to: 4.9
10
+ Stable tag: 2.1.0
11
 
12
  Advanced plugin that allows to set-up custom permalinks (bulk editors included), slugs and permastructures (WooCommerce compatible).
13
 
85
 
86
  == Changelog ==
87
 
88
+ = 2.1.0 =
89
+ * Support for "url_to_postid" function
90
+ * Bulk tools use now AJAX & transients to prevent timeout when large number of posts/terms is processed.
91
+ * Fix for multi-domain language setup in WPML
92
+
93
+ = 2.0.6.5 =
94
+ * Support for %__sku% permastructure tag (WooCommerce) added (Now SKU number can be added to the custom permalinks).
95
+ * Hotfix for license validation system
96
+
97
+ = 2.0.6.4 =
98
+ * Code optimization
99
+ * New filter: permalink_manager_fix_uri_duplicates
100
+ * Possibility to display the native slug field
101
+ * Hotfix for license validation functions
102
+
103
+ = 2.0.6.3.2 =
104
+ * Support added for Revisionize plugin
105
+ * Minor tweaks
106
+
107
+ = 2.0.6.2/2.0.6.3 =
108
  * Japaneese translation added
109
  * Some minor improvements
110
+ * New filters: permalink_manager_hide_uri_editor_term_{$term->taxonomy}, permalink_manager_hide_uri_editor_post_{$post->post_type} & permalink_manager_update_term_uri_{$this_term->taxonomy}, permalink_manager_update_post_uri_{$post->post_type}, permalink_manager_new_post_uri_{$post_object->post_type}
111
+ * Hotfix for default permalinks (no-hierarchical post types)
112
+ * Hotfix for attachments default permalinks + URI detect function
113
 
114
  = 2.0.6.1 =
115
  * Hotfix for endpoints in REGEX
includes/core/permalink-manager-actions.php CHANGED
@@ -5,9 +5,12 @@
5
  class Permalink_Manager_Actions extends Permalink_Manager_Class {
6
 
7
  public function __construct() {
8
- add_action('admin_init', array($this, 'trigger_action'), 999);
9
  add_action('admin_init', array($this, 'extra_actions'));
10
 
 
 
 
11
  add_action('clean_permalinks_event', array($this, 'clean_permalinks_hook'));
12
  add_action('init', array($this, 'clean_permalinks_cronjob'));
13
  }
@@ -16,24 +19,25 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
16
  * Actions
17
  */
18
  public function trigger_action() {
19
- global $permalink_manager_before_sections_html, $permalink_manager_after_sections_html;
20
 
21
  // 1. Check if the form was submitted
22
  if(empty($_POST)) { return; }
23
 
24
  $actions_map = array(
25
  'uri_editor' => array('function' => 'update_all_permalinks', 'display_uri_table' => true),
26
- 'regenerate' => array('function' => 'regenerate_all_permalinks', 'display_uri_table' => true),
27
- 'find_and_replace' => array('function' => 'find_and_replace', 'display_uri_table' => true),
28
  'permalink_manager_options' => array('function' => 'save_settings'),
29
  'permalink_manager_permastructs' => array('function' => 'save_permastructures'),
30
- 'flush_sitemaps' => array('function' => 'save_permastructures'),
31
  'import' => array('function' => 'import_custom_permalinks_uris'),
32
  );
33
 
34
  // 2. Find the action
35
  foreach($actions_map as $action => $map) {
36
  if(isset($_POST[$action]) && wp_verify_nonce($_POST[$action], 'permalink-manager')) {
 
37
  $output = call_user_func(array($this, $map['function']));
38
 
39
  // Get list of updated URIs
@@ -49,23 +53,14 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
49
 
50
  // 3. Display the slugs table (and append the globals)
51
  if(isset($updated_slugs_count)) {
52
- if($updated_slugs_count > 0) {
53
- $updated_title = __('List of updated items', 'bis');
54
- $alert_content = sprintf( _n( '<strong>%d</strong> slug was updated!', '<strong>%d</strong> slugs were updated!', $updated_slugs_count, 'permalink-manager' ), $updated_slugs_count ) . ' ';
55
- $alert_content .= sprintf( __( '<a %s>Click here</a> to go to the list of updated slugs', 'permalink-manager' ), "href=\"#updated-list\" title=\"{$updated_title}\"");
56
-
57
- $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message($alert_content, 'updated');
58
- $permalink_manager_after_sections_html .= Permalink_Manager_Admin_Functions::display_updated_slugs($updated_slugs_array);
59
- } else {
60
- $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( '<strong>No slugs</strong> were updated!', 'permalink-manager' ), 'error');
61
- }
62
  }
63
  }
64
 
65
  /**
66
  * Save settings
67
  */
68
- public static function save_settings($field = false, $value = false) {
69
  global $permalink_manager_options, $permalink_manager_before_sections_html;
70
 
71
  // Info: The settings array is used also by "Screen Options"
@@ -91,7 +86,103 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
91
  update_option('permalink-manager', $new_options);
92
 
93
  // Display the message
94
- $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'The settings are saved!', 'permalink-manager' ), 'updated');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
96
 
97
  /**
@@ -143,20 +234,13 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
143
  foreach($group as $element => $permastruct) {
144
  // Trim slashes
145
  $permastruct = trim($permastruct, "/");
146
-
147
- // Do not store default permastructures
148
- // $default_permastruct = ($group_name == 'post_types') ? Permalink_Manager_Helper_Functions::get_default_permastruct($element, true) : "";
149
- // if($permastruct == $default_permastruct) { unset($group[$element]); }
150
  }
151
- // Do not store empty permastructures
152
- // $new_options[$group_name] = array_filter($group);
153
  } else {
154
  unset($new_options[$group_name]);
155
  }
156
  }
157
 
158
  // Override the global with settings
159
- // $permalink_manager_permastructs = $new_options = $new_options;
160
  $permalink_manager_permastructs = $new_options;
161
 
162
  // Save the settings in database
@@ -176,21 +260,33 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
176
  $removed_uris = 0;
177
  $removed_redirects = 0;
178
 
179
- foreach($permalink_manager_uris as $element_id => $uri) {
 
 
 
 
180
  $count = self::clear_single_element_uris_and_redirects($element_id, true);
181
 
182
  $removed_uris = (!empty($count[0])) ? $count[0] + $removed_uris : $removed_uris;
183
  $removed_redirects = (!empty($count[1])) ? $count[1] + $removed_redirects : $removed_redirects;
184
  }
185
 
 
 
 
 
 
 
 
 
186
  // Save cleared URIs & Redirects
187
  if($removed_uris > 0 || $removed_redirects > 0) {
188
  update_option('permalink-manager-uris', array_filter($permalink_manager_uris));
189
  update_option('permalink-manager-redirects', array_filter($permalink_manager_redirects));
190
 
191
- $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(sprintf(__( '%d Custom URIs and %d Custom Redirects were removed!', 'permalink-manager' ), $removed_uris, $removed_redirects), 'updated');
192
  } else {
193
- $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'No Custom URIs or Custom Redirects were removed!', 'permalink-manager' ), 'error');
194
  }
195
  }
196
 
@@ -283,6 +379,40 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
283
  }
284
  }
285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  /**
287
  * Remove custom URI & redirects for any requested post or term
288
  */
@@ -329,39 +459,23 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
329
  }
330
 
331
  /**
332
- * "Find and replace" in "Tools"
333
- */
334
- function find_and_replace() {
335
- // Check if posts or terms should be updated
336
- if(!empty($_POST['content_type']) && $_POST['content_type'] == 'taxonomies') {
337
- return Permalink_Manager_URI_Functions_Tax::find_and_replace();
338
- } else {
339
- return Permalink_Manager_URI_Functions_Post::find_and_replace();
340
- }
341
- }
342
 
343
- /**
344
- * Regenerate all permalinks in "Tools"
345
- */
346
- function regenerate_all_permalinks() {
347
- // Check if posts or terms should be updated
348
- if(!empty($_POST['content_type']) && $_POST['content_type'] == 'taxonomies') {
349
- return Permalink_Manager_URI_Functions_Tax::regenerate_all_permalinks();
350
- } else {
351
- return Permalink_Manager_URI_Functions_Post::regenerate_all_permalinks();
352
- }
353
- }
354
 
355
- /**
356
- * Update all permalinks in "Permalink Editor"
357
- */
358
- function update_all_permalinks() {
359
- // Check if posts or terms should be updated
360
- if(!empty($_POST['content_type']) && $_POST['content_type'] == 'taxonomies') {
361
- return Permalink_Manager_URI_Functions_Tax::update_all_permalinks();
362
- } else {
363
- return Permalink_Manager_URI_Functions_Post::update_all_permalinks();
364
  }
 
 
365
  }
366
 
367
  /**
5
  class Permalink_Manager_Actions extends Permalink_Manager_Class {
6
 
7
  public function __construct() {
8
+ add_action('admin_init', array($this, 'trigger_action'), 9);
9
  add_action('admin_init', array($this, 'extra_actions'));
10
 
11
+ // Ajax-based bulk tools
12
+ add_action('wp_ajax_pm_bulk_tools', array($this, 'pm_bulk_tools'));
13
+
14
  add_action('clean_permalinks_event', array($this, 'clean_permalinks_hook'));
15
  add_action('init', array($this, 'clean_permalinks_cronjob'));
16
  }
19
  * Actions
20
  */
21
  public function trigger_action() {
22
+ global $permalink_manager_after_sections_html;
23
 
24
  // 1. Check if the form was submitted
25
  if(empty($_POST)) { return; }
26
 
27
  $actions_map = array(
28
  'uri_editor' => array('function' => 'update_all_permalinks', 'display_uri_table' => true),
29
+ //'regenerate' => array('function' => 'regenerate_all_permalinks', 'display_uri_table' => true),
30
+ //'find_and_replace' => array('function' => 'find_and_replace', 'display_uri_table' => true),
31
  'permalink_manager_options' => array('function' => 'save_settings'),
32
  'permalink_manager_permastructs' => array('function' => 'save_permastructures'),
33
+ 'flush_sitemaps' => array('function' => 'flush_sitemaps'),
34
  'import' => array('function' => 'import_custom_permalinks_uris'),
35
  );
36
 
37
  // 2. Find the action
38
  foreach($actions_map as $action => $map) {
39
  if(isset($_POST[$action]) && wp_verify_nonce($_POST[$action], 'permalink-manager')) {
40
+ // Execute the function
41
  $output = call_user_func(array($this, $map['function']));
42
 
43
  // Get list of updated URIs
53
 
54
  // 3. Display the slugs table (and append the globals)
55
  if(isset($updated_slugs_count)) {
56
+ $permalink_manager_after_sections_html .= Permalink_Manager_Admin_Functions::display_updated_slugs($updated_slugs_array);
 
 
 
 
 
 
 
 
 
57
  }
58
  }
59
 
60
  /**
61
  * Save settings
62
  */
63
+ public static function save_settings($field = false, $value = false, $display_alert = true) {
64
  global $permalink_manager_options, $permalink_manager_before_sections_html;
65
 
66
  // Info: The settings array is used also by "Screen Options"
86
  update_option('permalink-manager', $new_options);
87
 
88
  // Display the message
89
+ $permalink_manager_before_sections_html .= ($display_alert) ? Permalink_Manager_Admin_Functions::get_alert_message(__( 'The settings are saved!', 'permalink-manager' ), 'updated') : "";
90
+ }
91
+
92
+ /**
93
+ * Trigger bulk tools via AJAX
94
+ */
95
+ function pm_bulk_tools() {
96
+ // Define variables
97
+ $return = array('alert' => Permalink_Manager_Admin_Functions::get_alert_message(__( '<strong>No slugs</strong> were updated!', 'permalink-manager' ), 'error updated_slugs'));
98
+
99
+ // Get the name of the function
100
+ if(isset($_POST['regenerate']) && wp_verify_nonce($_POST['regenerate'], 'permalink-manager')) {
101
+ $function_name = 'regenerate_all_permalinks';
102
+ $uniq_id = $_POST['pm_session_id'];
103
+ } else if(isset($_POST['find_and_replace']) && wp_verify_nonce($_POST['find_and_replace'], 'permalink-manager') && !empty($_POST['old_string']) && !empty($_POST['new_string'])) {
104
+ $function_name = 'find_and_replace';
105
+ $uniq_id = $_POST['pm_session_id'];
106
+ }
107
+
108
+ // Check if both strings are set for "Find and replace" tool
109
+ if(!empty($function_name)) {
110
+ // Get the mode
111
+ $mode = isset($_POST['mode']) ? $_POST['mode'] : 'custom_uris';
112
+
113
+ // Get the content type
114
+ if(!empty($_POST['content_type']) && $_POST['content_type'] == 'taxonomies') {
115
+ $class_name = 'Permalink_Manager_URI_Functions_Tax';
116
+ } else {
117
+ $class_name = 'Permalink_Manager_URI_Functions_Post';
118
+ }
119
+
120
+ // Get items (try to get them from transient)
121
+ $items = get_transient("pm_{$uniq_id}");
122
+ $first_chunk = true;
123
+
124
+ if(empty($items)) {
125
+ $items = $class_name::get_items();
126
+
127
+ // Split items array into chunks and save them to transient
128
+ $items = array_chunk($items, 25);
129
+
130
+ set_transient("pm_{$uniq_id}", $items, 300);
131
+
132
+ // $return['first_chunk'] = $first_chunk = true;
133
+ }
134
+
135
+ // Get homepage URL and ensure that it ends with slash
136
+ $home_url = Permalink_Manager_Helper_Functions::get_permalink_base() . "/";
137
+
138
+ // Process the variables from $_POST object
139
+ $old_string = (!empty($_POST['old_string'])) ? str_replace($home_url, '', esc_sql($_POST['old_string'])) : '';
140
+ $new_string = (!empty($_POST['old_string'])) ? str_replace($home_url, '', esc_sql($_POST['new_string'])) : '';
141
+
142
+ // Process only one subarray
143
+ if(!empty($items[0])) {
144
+ $chunk = $items[0];
145
+
146
+ // Remove from array & update the transient
147
+ unset($items[0]);
148
+ $items = array_values($items);
149
+ set_transient("pm_{$uniq_id}", $items, 300);
150
+
151
+ // Check if posts or terms should be updated
152
+ if($function_name == 'find_and_replace') {
153
+ $output = $class_name::find_and_replace($chunk, $mode, $old_string, $new_string);
154
+ } else {
155
+ $output = $class_name::regenerate_all_permalinks($chunk, $mode);
156
+ }
157
+
158
+ if(!empty($output['updated_count'])) {
159
+ $return = array_merge($return, (array) Permalink_Manager_Admin_Functions::display_updated_slugs($output['updated'], true, $first_chunk));
160
+ $return['updated_count'] = $output['updated_count'];
161
+ }
162
+
163
+ // Check if there are any chunks left
164
+ if(count($items) > 0) {
165
+ $return['left_chunks'] = true;
166
+ } else {
167
+ delete_transient("pm_{$uniq_id}");
168
+ }
169
+ }
170
+ }
171
+
172
+ wp_send_json($return);
173
+ die();
174
+ }
175
+
176
+ /**
177
+ * Update all permalinks in "Permalink Editor"
178
+ */
179
+ function update_all_permalinks() {
180
+ // Check if posts or terms should be updated
181
+ if(!empty($_POST['content_type']) && $_POST['content_type'] == 'taxonomies') {
182
+ return Permalink_Manager_URI_Functions_Tax::update_all_permalinks();
183
+ } else {
184
+ return Permalink_Manager_URI_Functions_Post::update_all_permalinks();
185
+ }
186
  }
187
 
188
  /**
234
  foreach($group as $element => $permastruct) {
235
  // Trim slashes
236
  $permastruct = trim($permastruct, "/");
 
 
 
 
237
  }
 
 
238
  } else {
239
  unset($new_options[$group_name]);
240
  }
241
  }
242
 
243
  // Override the global with settings
 
244
  $permalink_manager_permastructs = $new_options;
245
 
246
  // Save the settings in database
260
  $removed_uris = 0;
261
  $removed_redirects = 0;
262
 
263
+ // Get all element IDs
264
+ $element_ids = array_merge(array_keys((array) $permalink_manager_uris), array_keys((array) $permalink_manager_redirects));
265
+
266
+ // 1. Remove unused custom URI & redirects for deleted post or term
267
+ foreach($element_ids as $element_id => $uri) {
268
  $count = self::clear_single_element_uris_and_redirects($element_id, true);
269
 
270
  $removed_uris = (!empty($count[0])) ? $count[0] + $removed_uris : $removed_uris;
271
  $removed_redirects = (!empty($count[1])) ? $count[1] + $removed_redirects : $removed_redirects;
272
  }
273
 
274
+ // 2. Keep only a single redirect (make it unique)
275
+ $removed_redirects += self::clear_redirects_array(true);
276
+
277
+ // 3. Optional method to keep the permalinks unique
278
+ if(apply_filters('permalink_manager_fix_uri_duplicates', false) == true) {
279
+ self::fix_uri_duplicates();
280
+ }
281
+
282
  // Save cleared URIs & Redirects
283
  if($removed_uris > 0 || $removed_redirects > 0) {
284
  update_option('permalink-manager-uris', array_filter($permalink_manager_uris));
285
  update_option('permalink-manager-redirects', array_filter($permalink_manager_redirects));
286
 
287
+ $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(sprintf(__( '%d Custom URIs and %d Custom Redirects were removed!', 'permalink-manager' ), $removed_uris, $removed_redirects), 'updated updated_slugs');
288
  } else {
289
+ $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'No Custom URIs or Custom Redirects were removed!', 'permalink-manager' ), 'error updated_slugs');
290
  }
291
  }
292
 
379
  }
380
  }
381
 
382
+ /**
383
+ * Make the redirects unique
384
+ */
385
+ public static function clear_redirects_array($count_removed = false) {
386
+ global $permalink_manager_redirects;
387
+
388
+ $removed_redirects = 0;
389
+
390
+ $all_redirect_duplicates = Permalink_Manager_Helper_Functions::get_all_duplicates(true);
391
+
392
+ foreach($all_redirect_duplicates as $single_redirect_duplicate) {
393
+
394
+ $last_element = end($single_redirect_duplicate);
395
+ foreach($single_redirect_duplicate as $redirect_key) {
396
+ // Keep a single redirect
397
+ if($last_element == $redirect_key) { continue; }
398
+ preg_match("/redirect-([\d]+)_([\d]+)/", $redirect_key, $ids);
399
+
400
+ if(!empty($ids[2]) && !empty($permalink_manager_redirects[$ids[2]][$ids[1]])) {
401
+ $removed_redirects++;
402
+ unset($permalink_manager_redirects[$ids[2]][$ids[1]]);
403
+ }
404
+ }
405
+ }
406
+
407
+ // Check if function should only return the counts or update
408
+ if($count_removed) {
409
+ return $removed_redirects;
410
+ } else if(isset($duplicated_redirect_id)) {
411
+ update_option('permalink-manager-redirects', array_filter($permalink_manager_redirects));
412
+ return true;
413
+ }
414
+ }
415
+
416
  /**
417
  * Remove custom URI & redirects for any requested post or term
418
  */
459
  }
460
 
461
  /**
462
+ * Keep the permalinks unique
463
+ */
464
+ public static function fix_uri_duplicates() {
465
+ global $permalink_manager_uris;
 
 
 
 
 
 
466
 
467
+ $duplicates = array_count_values($permalink_manager_uris);
 
 
 
 
 
 
 
 
 
 
468
 
469
+ foreach($duplicates as $uri => $count) {
470
+ if($count == 1) { continue; }
471
+
472
+ $ids = array_keys($permalink_manager_uris, $uri);
473
+ foreach($ids as $index => $id) {
474
+ $permalink_manager_uris[$id] = ($index > 0) ? "{$uri}-{$index}" : $uri;
475
+ }
 
 
476
  }
477
+
478
+ update_option('permalink-manager-uris', $permalink_manager_uris);
479
  }
480
 
481
  /**
includes/core/permalink-manager-admin-functions.php CHANGED
@@ -6,7 +6,6 @@
6
  class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
7
 
8
  public $menu_name, $sections, $active_section, $active_subsection;
9
- public $plugin_slug = PERMALINK_MANAGER_PLUGIN_SLUG;
10
  public $plugin_basename = PERMALINK_MANAGER_BASENAME;
11
 
12
  public function __construct() {
@@ -41,7 +40,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
41
  global $active_section, $active_subsection, $current_admin_tax;
42
 
43
  // 1. Get current section
44
- if(isset($_GET['page']) && $_GET['page'] == $this->plugin_slug) {
45
  if(isset($_POST['section'])) {
46
  $this->active_section = $_POST['section'];
47
  } else if(isset($_GET['section'])) {
@@ -80,7 +79,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
80
  * Add menu page.
81
  */
82
  public function add_menu_page() {
83
- $this->menu_name = add_management_page( __('Permalink Manager', 'permalink-manager'), __('Permalink Manager', 'permalink-manager'), 'manage_options', $this->plugin_slug, array($this, 'display_section') );
84
 
85
  add_action( 'admin_init', array($this, 'enqueue_styles' ) );
86
  add_action( 'admin_init', array($this, 'enqueue_scripts' ) );
@@ -101,20 +100,23 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
101
  wp_enqueue_script( 'permalink-manager-plugins', PERMALINK_MANAGER_URL . '/out/permalink-manager-plugins.js', array( 'jquery', ), PERMALINK_MANAGER_VERSION, false );
102
  wp_enqueue_script( 'permalink-manager', PERMALINK_MANAGER_URL . '/out/permalink-manager-admin.js', array( 'jquery', 'permalink-manager-plugins' ), PERMALINK_MANAGER_VERSION, false );
103
 
104
- wp_localize_script( 'permalink-manager', 'permalink_manager', array('ajax_url' => admin_url('admin-ajax.php'), 'url' => PERMALINK_MANAGER_URL) );
105
 
106
  }
107
 
108
  /**
109
- * Get admin url for the plugin
110
- */
111
- function get_admin_url($append = '') {
112
- return menu_page_url( "{$this->plugin_slug}", false ) . $append;
 
 
 
113
  }
114
 
115
  /**
116
- * Additional links on "Plugins" page
117
- */
118
  public function plugins_page_links($links) {
119
  $links[] = sprintf('<a href="%s">%s</a>', $this->get_admin_url(), __( 'URI Editor', 'permalink-manager' ));
120
  if(!defined('PERMALINK_MANAGER_PRO')) {
@@ -385,7 +387,10 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
385
  $html .= ($wrap) ? "</table>" : "";
386
 
387
  // End the fields' section + add button & nonce fields
388
- $html .= ($nonce_action && $nonce_name) ? wp_nonce_field($nonce_action, $nonce_name, true, true) : "";
 
 
 
389
  $html .= ($button_text) ? get_submit_button($button_text, $button_class, '', false, $button_attributes) : "";
390
  $html .= '</form>';
391
  $html .= ($form_column_class) ? "</div>" : "";
@@ -483,12 +488,6 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
483
  return $html;
484
  }
485
 
486
- static function pro_text($text_only = false) {
487
- $text = sprintf(__('This functionality is available only in <a href="%s" target="_blank">Permalink Manager Pro</a>.', 'permalink-manager'), PERMALINK_MANAGER_WEBSITE);
488
-
489
- return ($text_only) ? $text : sprintf("<div class=\"alert info\"> %s</div>", wpautop($text, 'alert', false));
490
- }
491
-
492
  /**
493
  * Help tooltip
494
  */
@@ -500,52 +499,83 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
500
  /**
501
  * Display the table with updated slugs after one of the actions is triggered
502
  */
503
- static function display_updated_slugs($updated_array, $uri_type = 'post') {
504
- // Check if slugs should be displayed
505
- $first_slug = reset($updated_array);
506
-
507
- $header_footer = '<tr>';
508
- $header_footer .= '<th class="column-primary">' . __('Title', 'permalink-manager') . '</th>';
509
- $header_footer .= '<th>' . __('Old URI', 'permalink-manager') . '</th>';
510
- $header_footer .= '<th>' . __('New URI', 'permalink-manager') . '</th>';
511
- $header_footer .= (isset($first_slug['old_slug'])) ? '<th>' . __('Old Slug', 'permalink-manager') . '</th>' : "";
512
- $header_footer .= (isset($first_slug['new_slug'])) ? '<th>' . __('New Slug', 'permalink-manager') . '</th>' : "";
513
- $header_footer .= '</tr>';
514
 
515
  $updated_slugs_count = 0;
516
- $main_content = "";
517
- foreach($updated_array as $row) {
518
- // Odd/even class
519
- $updated_slugs_count++;
520
- $alternate_class = ($updated_slugs_count % 2 == 1) ? ' class="alternate"' : '';
521
-
522
- // Taxonomy
523
- if(!empty($row['tax'])) {
524
- $term_link = get_term_link(intval($row['ID']), $row['tax']);
525
- $permalink = (is_wp_error($term_link)) ? "-" : $term_link;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
526
  } else {
527
- $permalink = get_permalink($row['ID']);
528
  }
529
 
530
- // Decode permalink
531
- $permalink = urldecode(urldecode($permalink));
 
 
 
 
 
 
532
 
533
- $main_content .= "<tr{$alternate_class}>";
534
- $main_content .= '<td class="row-title column-primary" data-colname="' . __('Title', 'permalink-manager') . '">' . $row['item_title'] . "<a target=\"_blank\" href=\"{$permalink}\"><span class=\"small\">{$permalink}</span></a>" . '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __('Show more details', 'permalink-manager') . '</span></button></td>';
535
- $main_content .= '<td data-colname="' . __('Old URI', 'permalink-manager') . '">' . urldecode($row['old_uri']) . '</td>';
536
- $main_content .= '<td data-colname="' . __('New URI', 'permalink-manager') . '">' . urldecode($row['new_uri']) . '</td>';
537
- $main_content .= (isset($row['old_slug'])) ? '<td data-colname="' . __('Old Slug', 'permalink-manager') . '">' . urldecode($row['old_slug']) . '</td>' : "";
538
- $main_content .= (isset($row['new_slug'])) ? '<td data-colname="' . __('New Slug', 'permalink-manager') . '">' . urldecode($row['new_slug']) . '</td>' : "";
539
- $main_content .= '</tr>';
540
  }
541
 
542
- // Merge header, footer and content
543
- $html = '<h3 id="updated-list">' . __('List of updated items', 'permalink-manager') . '</h3>';
544
- $html .= '<table class="widefat wp-list-table updated-slugs-table">';
545
- $html .= "<thead>{$header_footer}</thead><tbody>{$main_content}</tbody><tfoot>{$header_footer}</tfoot>";
546
- $html .= '</table>';
 
 
547
 
548
- return $html;
 
549
  }
550
 
551
  /**
@@ -580,6 +610,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
580
 
581
  if(!empty($element->ID)) {
582
  $id = $element_id = $element->ID;
 
583
 
584
  // Auto-update settings
585
  $auto_update_val = get_post_meta($id, "auto_update_uri", true);
@@ -593,6 +624,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
593
  } else {
594
  $id = $element->term_id;
595
  $element_id = "tax-{$id}";
 
596
  }
597
 
598
  // Decode default URI
@@ -624,9 +656,20 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
624
  $custom_uri_field
625
  );
626
 
 
 
 
 
 
 
 
 
 
 
 
627
  // Three fields that should be hidden on front-page
628
  if(get_option('page_on_front') != $id) {
629
- // 5. Auto-update URI
630
  if(!empty($auto_update_choices)) {
631
  $html .= sprintf("<div><label for=\"auto_auri\" class=\"strong\">%s %s</label><span>%s</span></div>",
632
  __("Auto-update the URI", "permalink-manager"),
@@ -635,14 +678,14 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
635
  );
636
  }
637
 
638
- // 6. Default URI
639
  $html .= sprintf(
640
  "<div class=\"default-permalink-row columns-container\"><span class=\"column-3_4\"><strong>%s:</strong> %s</span><span class=\"column-1_4\"><a href=\"#\" class=\"restore-default\"><span class=\"dashicons dashicons-image-rotate\"></span> %s</a></span></div>",
641
  __("Default URI", "permalink-manager"), esc_html($default_uri),
642
  __("Restore to Default URI", "permalink-manager")
643
  );
644
 
645
- // 7. Native URI info
646
  if(!empty($permalink_manager_options['general']['redirect']) && ((!empty($element->post_status) && in_array($element->post_status, array('auto-draft', 'trash', 'draft'))) == false)) {
647
  $native_permalink = trim(Permalink_Manager_Helper_Functions::get_permalink_base($element), "/") . "/";
648
  $native_permalink .= $native_uri;
@@ -656,7 +699,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
656
  }
657
  }
658
 
659
- // 8. Custom redirects
660
  $html .= ($element->ID) ? self::display_redirect_panel($id) : self::display_redirect_panel("tax-{$id}");
661
 
662
  $html .= "</div>";
@@ -685,7 +728,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
685
  $html .= "<div id=\"redirect-panel-inside\">";
686
 
687
  // Table
688
- if(class_exists('Permalink_Manager_Pro_Addons')) {
689
  $html .= Permalink_Manager_Pro_Addons::display_redirect_form($element_id);
690
  } else {
691
  $html .= self::pro_text(true);
@@ -782,4 +825,36 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
782
  die();
783
  }
784
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
785
  }
6
  class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
7
 
8
  public $menu_name, $sections, $active_section, $active_subsection;
 
9
  public $plugin_basename = PERMALINK_MANAGER_BASENAME;
10
 
11
  public function __construct() {
40
  global $active_section, $active_subsection, $current_admin_tax;
41
 
42
  // 1. Get current section
43
+ if(isset($_GET['page']) && $_GET['page'] == PERMALINK_MANAGER_PLUGIN_SLUG) {
44
  if(isset($_POST['section'])) {
45
  $this->active_section = $_POST['section'];
46
  } else if(isset($_GET['section'])) {
79
  * Add menu page.
80
  */
81
  public function add_menu_page() {
82
+ $this->menu_name = add_management_page( __('Permalink Manager', 'permalink-manager'), __('Permalink Manager', 'permalink-manager'), 'manage_options', PERMALINK_MANAGER_PLUGIN_SLUG, array($this, 'display_section') );
83
 
84
  add_action( 'admin_init', array($this, 'enqueue_styles' ) );
85
  add_action( 'admin_init', array($this, 'enqueue_scripts' ) );
100
  wp_enqueue_script( 'permalink-manager-plugins', PERMALINK_MANAGER_URL . '/out/permalink-manager-plugins.js', array( 'jquery', ), PERMALINK_MANAGER_VERSION, false );
101
  wp_enqueue_script( 'permalink-manager', PERMALINK_MANAGER_URL . '/out/permalink-manager-admin.js', array( 'jquery', 'permalink-manager-plugins' ), PERMALINK_MANAGER_VERSION, false );
102
 
103
+ wp_localize_script( 'permalink-manager', 'permalink_manager', array('ajax_url' => admin_url('admin-ajax.php'), 'url' => PERMALINK_MANAGER_URL, 'spinners' => admin_url('images')) );
104
 
105
  }
106
 
107
  /**
108
+ * Get admin url for the plugin
109
+ */
110
+ public static function get_admin_url($append = '') {
111
+ //return menu_page_url(PERMALINK_MANAGER_PLUGIN_SLUG, false) . $append;
112
+ $admin_page = sprintf("tools.php?page=%s", PERMALINK_MANAGER_PLUGIN_SLUG . $append);
113
+
114
+ return admin_url($admin_page);
115
  }
116
 
117
  /**
118
+ * Additional links on "Plugins" page
119
+ */
120
  public function plugins_page_links($links) {
121
  $links[] = sprintf('<a href="%s">%s</a>', $this->get_admin_url(), __( 'URI Editor', 'permalink-manager' ));
122
  if(!defined('PERMALINK_MANAGER_PRO')) {
387
  $html .= ($wrap) ? "</table>" : "";
388
 
389
  // End the fields' section + add button & nonce fields
390
+ if($nonce_action && $nonce_name) {
391
+ $html .= wp_nonce_field($nonce_action, $nonce_name, true, true);
392
+ $html .= self::generate_option_field('pm_session_id', array('value' => uniqid(), 'type' => 'hidden'));
393
+ }
394
  $html .= ($button_text) ? get_submit_button($button_text, $button_class, '', false, $button_attributes) : "";
395
  $html .= '</form>';
396
  $html .= ($form_column_class) ? "</div>" : "";
488
  return $html;
489
  }
490
 
 
 
 
 
 
 
491
  /**
492
  * Help tooltip
493
  */
499
  /**
500
  * Display the table with updated slugs after one of the actions is triggered
501
  */
502
+ static function display_updated_slugs($updated_array, $return_array = false, $display_full_table = true) {
503
+ global $permalink_manager_before_sections_html, $permalink_manager_after_sections_html;
 
 
 
 
 
 
 
 
 
504
 
505
  $updated_slugs_count = 0;
506
+ $html = $main_content = $alert = "";
507
+
508
+ if(is_array($updated_array)) {
509
+ // Check if slugs should be displayed
510
+ $first_slug = reset($updated_array);
511
+
512
+ $header_footer = '<tr>';
513
+ $header_footer .= '<th class="column-primary">' . __('Title', 'permalink-manager') . '</th>';
514
+ $header_footer .= '<th>' . __('Old URI', 'permalink-manager') . '</th>';
515
+ $header_footer .= '<th>' . __('New URI', 'permalink-manager') . '</th>';
516
+ $header_footer .= (isset($first_slug['old_slug'])) ? '<th>' . __('Old Slug', 'permalink-manager') . '</th>' : "";
517
+ $header_footer .= (isset($first_slug['new_slug'])) ? '<th>' . __('New Slug', 'permalink-manager') . '</th>' : "";
518
+ $header_footer .= '</tr>';
519
+
520
+ foreach($updated_array as $row) {
521
+ // Odd/even class
522
+ $updated_slugs_count++;
523
+ $alternate_class = ($updated_slugs_count % 2 == 1) ? ' class="alternate"' : '';
524
+
525
+ // Taxonomy
526
+ if(!empty($row['tax'])) {
527
+ $term_link = get_term_link(intval($row['ID']), $row['tax']);
528
+ $permalink = (is_wp_error($term_link)) ? "-" : $term_link;
529
+ } else {
530
+ $permalink = get_permalink($row['ID']);
531
+ }
532
+
533
+ // Decode permalink
534
+ $permalink = urldecode(urldecode($permalink));
535
+
536
+ $main_content .= "<tr{$alternate_class}>";
537
+ $main_content .= '<td class="row-title column-primary" data-colname="' . __('Title', 'permalink-manager') . '">' . $row['item_title'] . "<a target=\"_blank\" href=\"{$permalink}\"><span class=\"small\">{$permalink}</span></a>" . '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __('Show more details', 'permalink-manager') . '</span></button></td>';
538
+ $main_content .= '<td data-colname="' . __('Old URI', 'permalink-manager') . '">' . urldecode($row['old_uri']) . '</td>';
539
+ $main_content .= '<td data-colname="' . __('New URI', 'permalink-manager') . '">' . urldecode($row['new_uri']) . '</td>';
540
+ $main_content .= (isset($row['old_slug'])) ? '<td data-colname="' . __('Old Slug', 'permalink-manager') . '">' . urldecode($row['old_slug']) . '</td>' : "";
541
+ $main_content .= (isset($row['new_slug'])) ? '<td data-colname="' . __('New Slug', 'permalink-manager') . '">' . urldecode($row['new_slug']) . '</td>' : "";
542
+ $main_content .= '</tr>';
543
+ }
544
+
545
+ // Merge header, footer and content
546
+ if($display_full_table) {
547
+ $html = '<h3 id="updated-list">' . __('List of updated items', 'permalink-manager') . '</h3>';
548
+ $html .= '<table class="widefat wp-list-table updated-slugs-table">';
549
+ $html .= "<thead>{$header_footer}</thead><tbody>{$main_content}</tbody><tfoot>{$header_footer}</tfoot>";
550
  } else {
551
+ $html = $main_content;
552
  }
553
 
554
+ $html .= '</table>';
555
+ }
556
+
557
+ // 3. Display the alert
558
+ if(isset($updated_slugs_count)) {
559
+ if($updated_slugs_count > 0) {
560
+ $alert_content = sprintf( _n( '<strong class="updated_count">%d</strong> slug was updated!', '<strong class="updated_count">%d</strong> slugs were updated!', $updated_slugs_count, 'permalink-manager' ), $updated_slugs_count ) . ' ';
561
+ $alert_content .= sprintf( __( '<a %s>Click here</a> to go to the list of updated slugs', 'permalink-manager' ), "href=\"#updated-list\"");
562
 
563
+ $alert = Permalink_Manager_Admin_Functions::get_alert_message($alert_content, 'updated updated_slugs');
564
+ } else {
565
+ $alert = Permalink_Manager_Admin_Functions::get_alert_message(__( '<strong>No slugs</strong> were updated!', 'permalink-manager' ), 'error updated_slugs');
566
+ }
 
 
 
567
  }
568
 
569
+ if($return_array) {
570
+ return array(
571
+ 'html' => $html,
572
+ 'alert' => $alert
573
+ );
574
+ } else {
575
+ $permalink_manager_before_sections_html .= $alert;
576
 
577
+ return $html;
578
+ }
579
  }
580
 
581
  /**
610
 
611
  if(!empty($element->ID)) {
612
  $id = $element_id = $element->ID;
613
+ $native_slug = $element->post_name;
614
 
615
  // Auto-update settings
616
  $auto_update_val = get_post_meta($id, "auto_update_uri", true);
624
  } else {
625
  $id = $element->term_id;
626
  $element_id = "tax-{$id}";
627
+ $native_slug = $element->slug;
628
  }
629
 
630
  // Decode default URI
656
  $custom_uri_field
657
  );
658
 
659
+ // 5. Native slug
660
+ if(!empty($element->ID) && !empty($permalink_manager_options["general"]["show_native_slug_field"])) {
661
+ $native_slug_field = Permalink_Manager_Admin_Functions::generate_option_field("native_slug", array("extra_atts" => "data-default=\"{$native_slug}\" data-element-id=\"{$element_id}\"", "input_class" => "widefat custom_uri", "value" => urldecode($native_slug)));
662
+
663
+ $html .= sprintf("<div class=\"native_slug_container\"><label for=\"custom_uri\" class=\"strong\">%s %s</label><span>%s</span></div>",
664
+ __("Native slug", "permalink-manager"),
665
+ Permalink_Manager_Admin_Functions::help_tooltip(__("The native slug is by default automatically used in native permalinks (when Permalink Manager is disabled).", "permalink-manager")),
666
+ $native_slug_field
667
+ );
668
+ }
669
+
670
  // Three fields that should be hidden on front-page
671
  if(get_option('page_on_front') != $id) {
672
+ // 6. Auto-update URI
673
  if(!empty($auto_update_choices)) {
674
  $html .= sprintf("<div><label for=\"auto_auri\" class=\"strong\">%s %s</label><span>%s</span></div>",
675
  __("Auto-update the URI", "permalink-manager"),
678
  );
679
  }
680
 
681
+ // 7. Default URI
682
  $html .= sprintf(
683
  "<div class=\"default-permalink-row columns-container\"><span class=\"column-3_4\"><strong>%s:</strong> %s</span><span class=\"column-1_4\"><a href=\"#\" class=\"restore-default\"><span class=\"dashicons dashicons-image-rotate\"></span> %s</a></span></div>",
684
  __("Default URI", "permalink-manager"), esc_html($default_uri),
685
  __("Restore to Default URI", "permalink-manager")
686
  );
687
 
688
+ // 8. Native URI info
689
  if(!empty($permalink_manager_options['general']['redirect']) && ((!empty($element->post_status) && in_array($element->post_status, array('auto-draft', 'trash', 'draft'))) == false)) {
690
  $native_permalink = trim(Permalink_Manager_Helper_Functions::get_permalink_base($element), "/") . "/";
691
  $native_permalink .= $native_uri;
699
  }
700
  }
701
 
702
+ // 9. Custom redirects
703
  $html .= ($element->ID) ? self::display_redirect_panel($id) : self::display_redirect_panel("tax-{$id}");
704
 
705
  $html .= "</div>";
728
  $html .= "<div id=\"redirect-panel-inside\">";
729
 
730
  // Table
731
+ if(Permalink_Manager_Admin_Functions::is_pro_active()) {
732
  $html .= Permalink_Manager_Pro_Addons::display_redirect_form($element_id);
733
  } else {
734
  $html .= self::pro_text(true);
825
  die();
826
  }
827
 
828
+ /**
829
+ * Check if Permalink Manager Pro is active
830
+ */
831
+ public static function is_pro_active($return_text = false) {
832
+ if(defined('PERMALINK_MANAGER_PRO') && PERMALINK_MANAGER_PRO == true) {
833
+ $is_pro = true;
834
+ } else {
835
+ $is_pro = false;
836
+ }
837
+
838
+ // Check if license is active
839
+ if(class_exists('Permalink_Manager_Pro_Functions')) {
840
+ $exp_date = Permalink_Manager_Pro_Functions::get_expiration_date(true);
841
+
842
+ $is_pro = ($exp_date > 0) ? false : true;
843
+ } else {
844
+ $is_pro = false;
845
+ }
846
+
847
+ return $is_pro;
848
+ }
849
+
850
+ static function pro_text($text_only = false) {
851
+ if(class_exists('Permalink_Manager_Pro_Functions')) {
852
+ $text = Permalink_Manager_Pro_Functions::get_expiration_date(false, true);
853
+ } else {
854
+ $text = sprintf(__('This functionality is available only in <a href="%s" target="_blank">Permalink Manager Pro</a>.', 'permalink-manager'), PERMALINK_MANAGER_WEBSITE);
855
+ }
856
+
857
+ return ($text_only) ? $text : sprintf("<div class=\"alert info\"> %s</div>", wpautop($text, 'alert', false));
858
+ }
859
+
860
  }
includes/core/permalink-manager-core-functions.php CHANGED
@@ -44,11 +44,11 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
44
  /**
45
  * The most important Permalink Manager function
46
  */
47
- function detect_post($query) {
48
  global $wpdb, $wp, $wp_rewrite, $permalink_manager_uris, $wp_filter, $permalink_manager_options, $pm_query, $pm_uri_parts;
49
 
50
  // Check if any custom URI is used and we are not in WP-Admin dashboard
51
- if(!(is_array($permalink_manager_uris)) || empty($query)) return $query;
52
 
53
  // Used in debug mode & endpoints
54
  $old_query = $query;
@@ -56,7 +56,10 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
56
  /**
57
  * 1. Prepare URL and check if it is correct (make sure that both requested URL & home_url share the same protoocl and get rid of www prefix)
58
  */
59
- $request_url = sprintf("http://%s%s", str_replace("www.", "", $_SERVER['HTTP_HOST']), strtok($_SERVER['REQUEST_URI'], "?"));
 
 
 
60
  $raw_home_url = trim(get_option('home'));
61
  $home_url = preg_replace("/http(s)?:\/\/(www\.)?(.+?)\/?$/", "http://$3", $raw_home_url);
62
 
@@ -329,7 +332,13 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
329
  wp_die($debug_txt);
330
  }
331
 
332
- return $query;
 
 
 
 
 
 
333
  }
334
 
335
  /**
@@ -580,6 +589,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
580
  if(!($permalink_manager_options['general']['canonical_redirect']) || !empty($wp->query_vars['do_not_redirect'])) {
581
  remove_action('template_redirect', 'redirect_canonical');
582
  add_filter('wpml_is_redirected', '__return_false', 99, 2);
 
583
  }
584
  }
585
 
44
  /**
45
  * The most important Permalink Manager function
46
  */
47
+ public static function detect_post($query, $request_url = false, $return_object = false) {
48
  global $wpdb, $wp, $wp_rewrite, $permalink_manager_uris, $wp_filter, $permalink_manager_options, $pm_query, $pm_uri_parts;
49
 
50
  // Check if any custom URI is used and we are not in WP-Admin dashboard
51
+ if(!(is_array($permalink_manager_uris)) || (empty($query) && empty($request_url))) return $query;
52
 
53
  // Used in debug mode & endpoints
54
  $old_query = $query;
56
  /**
57
  * 1. Prepare URL and check if it is correct (make sure that both requested URL & home_url share the same protoocl and get rid of www prefix)
58
  */
59
+ $request_url = (!empty($request_url)) ? parse_url($request_url, PHP_URL_PATH) : $_SERVER['REQUEST_URI'];
60
+ $request_url = strtok($request_url, "?");
61
+
62
+ $request_url = sprintf("http://%s%s", str_replace("www.", "", $_SERVER['HTTP_HOST']), $request_url);
63
  $raw_home_url = trim(get_option('home'));
64
  $home_url = preg_replace("/http(s)?:\/\/(www\.)?(.+?)\/?$/", "http://$3", $raw_home_url);
65
 
332
  wp_die($debug_txt);
333
  }
334
 
335
+ if($return_object && !empty($term)) {
336
+ return $term;
337
+ } else if($return_object && !empty($post_to_load)) {
338
+ return $post_to_load;
339
+ } else {
340
+ return $query;
341
+ }
342
  }
343
 
344
  /**
589
  if(!($permalink_manager_options['general']['canonical_redirect']) || !empty($wp->query_vars['do_not_redirect'])) {
590
  remove_action('template_redirect', 'redirect_canonical');
591
  add_filter('wpml_is_redirected', '__return_false', 99, 2);
592
+ add_filter('pll_check_canonical_url', '__return_false', 99, 2);
593
  }
594
  }
595
 
includes/core/permalink-manager-helper-functions.php CHANGED
@@ -5,7 +5,15 @@
5
  */
6
  class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
7
 
8
- public function __construct() { }
 
 
 
 
 
 
 
 
9
 
10
  /**
11
  * Support for multidimensional arrays - array_map()
@@ -433,6 +441,17 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
433
  return $clean;
434
  }
435
 
 
 
 
 
 
 
 
 
 
 
 
436
  /**
437
  * Force custom slugs
438
  */
@@ -443,7 +462,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
443
  $title = (!empty($object->name)) ? $object->name : $object->post_title;
444
 
445
  $old_slug = basename($slug);
446
- $new_slug = self::sanitize_title($title, false);
447
 
448
  $slug = ($old_slug != $new_slug) ? str_replace($old_slug, $new_slug, $slug) : $slug;
449
  }
@@ -471,11 +490,11 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
471
  /**
472
  * Detect duplicates
473
  */
474
- public static function get_all_duplicates() {
475
  global $permalink_manager_uris, $permalink_manager_redirects, $permalink_manager_options, $wpdb;
476
 
477
  // Make sure that both variables are arrays
478
- $all_uris = (is_array($permalink_manager_uris)) ? $permalink_manager_uris : array();
479
  $permalink_manager_redirects = (is_array($permalink_manager_redirects)) ? $permalink_manager_redirects : array();
480
 
481
  // Convert redirects list, so it can be merged with $permalink_manager_uris
5
  */
6
  class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
7
 
8
+ public function __construct() {
9
+ add_action('plugins_loaded', array($this, 'init'), 5);
10
+ }
11
+
12
+ public function init() {
13
+ // Clear the final default URIs
14
+ add_filter( 'permalink_manager_filter_default_term_uri', array('Permalink_Manager_Helper_Functions', 'clear_single_uri'), 20);
15
+ add_filter( 'permalink_manager_filter_default_post_uri', array('Permalink_Manager_Helper_Functions', 'clear_single_uri'), 20);
16
+ }
17
 
18
  /**
19
  * Support for multidimensional arrays - array_map()
441
  return $clean;
442
  }
443
 
444
+ /**
445
+ * Clear the URI
446
+ */
447
+ public static function clear_single_uri($uri) {
448
+ $uri = preg_replace('/\s+/', '', $uri);
449
+ $uri = str_replace('//', '/', $uri);
450
+ $uri = trim($uri, "/");
451
+
452
+ return $uri;
453
+ }
454
+
455
  /**
456
  * Force custom slugs
457
  */
462
  $title = (!empty($object->name)) ? $object->name : $object->post_title;
463
 
464
  $old_slug = basename($slug);
465
+ $new_slug = self::sanitize_title($title, false, null, true);
466
 
467
  $slug = ($old_slug != $new_slug) ? str_replace($old_slug, $new_slug, $slug) : $slug;
468
  }
490
  /**
491
  * Detect duplicates
492
  */
493
+ public static function get_all_duplicates($include_custom_uris = true) {
494
  global $permalink_manager_uris, $permalink_manager_redirects, $permalink_manager_options, $wpdb;
495
 
496
  // Make sure that both variables are arrays
497
+ $all_uris = ($include_custom_uris && is_array($permalink_manager_uris)) ? $permalink_manager_uris : array();
498
  $permalink_manager_redirects = (is_array($permalink_manager_redirects)) ? $permalink_manager_redirects : array();
499
 
500
  // Convert redirects list, so it can be merged with $permalink_manager_uris
includes/core/permalink-manager-third-parties.php CHANGED
@@ -79,6 +79,12 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
79
  if(function_exists('tinv_get_option')) {
80
  add_filter('permalink-manager-detect-uri', array($this, 'ti_woocommerce_wishlist_uris'), 15, 3);
81
  }
 
 
 
 
 
 
82
  }
83
 
84
  /**
@@ -176,11 +182,15 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
176
  }
177
 
178
  // Fix for multidomain language configuration
179
- if(!empty($polylang->options['force_lang']) && $polylang->options['force_lang'] == 3) {
180
- $domains = (array) $polylang->options['domains'];
 
 
 
 
181
 
182
  foreach($domains as &$domain) {
183
- $domain = preg_replace("/http(s)?:\/\/(www\.)?(.+?)\/?$/", "http://$3", $domain);
184
  }
185
 
186
  $request_url = trim(str_replace($domains, "", $request_url), "/");
@@ -455,7 +465,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
455
  }
456
 
457
  // Do not redirect "thank you" & another WooCommerce pages
458
- if(is_checkout() || is_wc_endpoint_url()) {
459
  $wp_query->query_vars['do_not_redirect'] = 1;
460
  }
461
  }
@@ -509,5 +519,31 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
509
  return $uri_parts;
510
  }
511
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
  }
513
  ?>
79
  if(function_exists('tinv_get_option')) {
80
  add_filter('permalink-manager-detect-uri', array($this, 'ti_woocommerce_wishlist_uris'), 15, 3);
81
  }
82
+
83
+ // 9. Revisionize
84
+ if(defined('REVISIONIZE_ROOT')) {
85
+ add_action('revisionize_after_create_revision', array($this, 'revisionize_keep_post_uri'), 9, 2);
86
+ add_action('revisionize_before_publish', array($this,'revisionize_clone_uri'), 9, 2);
87
+ }
88
  }
89
 
90
  /**
182
  }
183
 
184
  // Fix for multidomain language configuration
185
+ if((isset($sitepress_settings['language_negotiation_type']) && $sitepress_settings['language_negotiation_type'] == 2) || (!empty($polylang->options['force_lang']) && $polylang->options['force_lang'] == 3)) {
186
+ if(!empty($polylang->options['domains'])) {
187
+ $domains = (array) $polylang->options['domains'];
188
+ } else if(!empty($sitepress_settings['language_domains'])) {
189
+ $domains = (array) $sitepress_settings['language_domains'];
190
+ }
191
 
192
  foreach($domains as &$domain) {
193
+ $domain = preg_replace("/(http(s)?:\/\/(www\.)?)?(.+?)\/?$/", "http://$4", $domain);
194
  }
195
 
196
  $request_url = trim(str_replace($domains, "", $request_url), "/");
465
  }
466
 
467
  // Do not redirect "thank you" & another WooCommerce pages
468
+ if(is_checkout() || (function_exists('is_wc_endpoint_url') && is_wc_endpoint_url())) {
469
  $wp_query->query_vars['do_not_redirect'] = 1;
470
  }
471
  }
519
  return $uri_parts;
520
  }
521
 
522
+ /**
523
+ * 9. Revisionize
524
+ */
525
+ function revisionize_keep_post_uri($old_id, $new_id) {
526
+ global $permalink_manager_uris;
527
+
528
+ // Copy the custom URI from original post and apply it to the new temp. revision post
529
+ if(!empty($permalink_manager_uris[$old_id])) {
530
+ $permalink_manager_uris[$new_id] = $permalink_manager_uris[$old_id];
531
+
532
+ update_option('permalink-manager-uris', $permalink_manager_uris);
533
+ }
534
+ }
535
+
536
+ function revisionize_clone_uri($old_id, $new_id) {
537
+ global $permalink_manager_uris;
538
+
539
+ if(!empty($permalink_manager_uris[$new_id])) {
540
+ // Copy the custom URI from revision post and apply it to the original post
541
+ $permalink_manager_uris[$old_id] = $permalink_manager_uris[$new_id];
542
+ unset($permalink_manager_uris[$new_id]);
543
+
544
+ update_option('permalink-manager-uris', $permalink_manager_uris);
545
+ }
546
+ }
547
+
548
  }
549
  ?>
includes/core/permalink-manager-uri-functions-post.php CHANGED
@@ -14,7 +14,10 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
14
  add_filter( 'post_type_link', array($this, 'custom_post_permalinks'), 99, 2);
15
  add_filter( 'attachment_link', array($this, 'custom_post_permalinks'), 99, 2);
16
 
17
- add_filter( 'permalink-manager-uris', array($this, 'exclude_homepage'), 99, 2);
 
 
 
18
 
19
  /**
20
  * URI Editor
@@ -77,7 +80,7 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
77
  $permalink = "{$home_url}/" . Permalink_Manager_Helper_Functions::encode_uri("{$permalink_manager_uris[$post->ID]}");
78
  }
79
  } else if($post->post_type == 'attachment' && $post->post_parent > 0 && $post->post_parent != $post->ID && !empty($permalink_manager_uris[$post->post_parent])) {
80
- $permalink = "{$home_url}/{$permalink_manager_uris[$post->post_parent]}/{$post->post_name}";
81
  } else if(!empty($permalink_manager_options['general']['decode_uris'])) {
82
  $permalink = "{$home_url}/" . urldecode("/{$permalink}");
83
  }
@@ -135,7 +138,15 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
135
  // 1. Get the permastruct
136
  if($post_type == 'attachment') {
137
  $parent_page = ($post->post_parent > 0 && $post->post_parent != $post->ID) ? get_post($post->post_parent) : false;
138
- $default_permastruct = ($parent_page) ? trim(get_page_uri($parent_page->ID), "/") : "";
 
 
 
 
 
 
 
 
139
 
140
  if($native_uri) {
141
  $permastruct = $default_permastruct;
@@ -273,9 +284,7 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
273
  }
274
 
275
  // 5. Clear the URI
276
- $default_uri = preg_replace('/\s+/', '', $default_uri);
277
- $default_uri = str_replace('//', '/', $default_uri);
278
- $default_uri = trim($default_uri, "/");
279
 
280
  return apply_filters('permalink_manager_filter_default_post_uri', $default_uri, $post->post_name, $post, $post_name, $native_uri);
281
  }
@@ -292,31 +301,32 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
292
  }
293
 
294
  /**
295
- * Find & replace (bulk action)
296
- */
297
- public static function find_and_replace() {
298
- global $wpdb, $permalink_manager_uris;
299
 
300
- // Check if post types & statuses are not empty
301
- if(empty($_POST['post_types']) || empty($_POST['post_statuses'])) { return false; }
 
 
302
 
303
- // Get homepage URL and ensure that it ends with slash
304
- $home_url = Permalink_Manager_Helper_Functions::get_permalink_base($post) . "/";
305
 
306
- // Reset variables
307
- $updated_slugs_count = 0;
308
- $updated_array = array();
309
- $alert_type = $alert_content = $errors = '';
 
310
 
311
- // Process the variables from $_POST object
312
- $old_string = str_replace($home_url, '', esc_sql($_POST['old_string']));
313
- $new_string = str_replace($home_url, '', esc_sql($_POST['new_string']));
314
 
315
  $post_types_array = ($_POST['post_types']);
316
  $post_statuses_array = ($_POST['post_statuses']);
317
  $post_types = implode("', '", $post_types_array);
318
  $post_statuses = implode("', '", $post_statuses_array);
319
- $mode = isset($_POST['mode']) ? $_POST['mode'] : 'custom_uris';
320
 
321
  // Filter the posts by IDs
322
  $where = '';
@@ -343,12 +353,25 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
343
  }
344
 
345
  // Support for attachments
346
- if(in_array('attachment', $post_types_array)) {
347
- $attachment_support = " OR (post_type = 'attachment')";
348
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
349
 
350
  // Get the rows before they are altered
351
- $posts_to_update = $wpdb->get_results("SELECT post_title, post_name, ID FROM {$wpdb->posts} WHERE ((post_status IN ('{$post_statuses}') AND post_type IN ('{$post_types}')){$attachment_support}) {$where}", ARRAY_A);
352
 
353
  // Now if the array is not empty use IDs from each subarray as a key
354
  if($posts_to_update && empty($errors)) {
@@ -401,56 +424,16 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
401
  /**
402
  * Regenerate slugs & bases (bulk action)
403
  */
404
- static function regenerate_all_permalinks() {
405
  global $wpdb, $permalink_manager_uris;
406
 
407
- // Check if post types & statuses are not empty
408
- if(empty($_POST['post_types']) || empty($_POST['post_statuses'])) { return false; }
409
-
410
- // Process the variables from $_POST object
411
  $updated_slugs_count = 0;
412
  $updated_array = array();
413
  $alert_type = $alert_content = $errors = '';
414
 
415
- $post_types_array = ($_POST['post_types']) ? ($_POST['post_types']) : '';
416
- $post_statuses_array = ($_POST['post_statuses']) ? $_POST['post_statuses'] : '';
417
- $post_types = implode("', '", $post_types_array);
418
- $post_statuses = implode("', '", $post_statuses_array);
419
- $mode = isset($_POST['mode']) ? $_POST['mode'] : 'custom_uris';
420
-
421
- // Filter the posts by IDs
422
- $where = '';
423
- if(!empty($_POST['ids'])) {
424
- // Remove whitespaces and prepare array with IDs and/or ranges
425
- $ids = esc_sql(preg_replace('/\s*/m', '', $_POST['ids']));
426
- preg_match_all("/([\d]+(?:-?[\d]+)?)/x", $ids, $groups);
427
-
428
- // Prepare the extra ID filters
429
- $where .= "AND (";
430
- foreach($groups[0] as $group) {
431
- $where .= ($group == reset($groups[0])) ? "" : " OR ";
432
- // A. Single number
433
- if(is_numeric($group)) {
434
- $where .= "(ID = {$group})";
435
- }
436
- // B. Range
437
- else if(substr_count($group, '-')) {
438
- $range_edges = explode("-", $group);
439
- $where .= "(ID BETWEEN {$range_edges[0]} AND {$range_edges[1]})";
440
- }
441
- }
442
- $where .= ")";
443
- }
444
-
445
- // Support for attachments
446
- if(in_array('attachment', $post_types_array)) {
447
- $attachment_support = " OR (post_type = 'attachment')";
448
- } else {
449
- $attachment_support = "";
450
- }
451
-
452
  // Get the rows before they are altered
453
- $posts_to_update = $wpdb->get_results("SELECT post_title, post_name, ID FROM {$wpdb->posts} WHERE ((post_status IN ('{$post_statuses}') AND post_type IN ('{$post_types}')){$attachment_support}) {$where}", ARRAY_A);
454
 
455
  // Now if the array is not empty use IDs from each subarray as a key
456
  if($posts_to_update && empty($errors)) {
@@ -752,10 +735,15 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
752
 
753
  // Save only changed URIs
754
  if($new_uri != $old_uri) {
755
- $permalink_manager_uris[$post->ID] = $new_uri;
756
  update_option('permalink-manager-uris', $permalink_manager_uris);
757
  }
758
 
 
 
 
 
 
759
  do_action('permalink-manager-updated-post-uri', $post_id, $new_uri, $old_uri, $native_uri, $default_uri, $single_update = true);
760
  }
761
 
14
  add_filter( 'post_type_link', array($this, 'custom_post_permalinks'), 99, 2);
15
  add_filter( 'attachment_link', array($this, 'custom_post_permalinks'), 99, 2);
16
 
17
+ add_filter( 'permalink-manager-uris', array($this, 'exclude_homepage'), 99);
18
+
19
+ // Support url_to_postid
20
+ add_filter( 'url_to_postid', array($this, 'url_to_postid'), 99);
21
 
22
  /**
23
  * URI Editor
80
  $permalink = "{$home_url}/" . Permalink_Manager_Helper_Functions::encode_uri("{$permalink_manager_uris[$post->ID]}");
81
  }
82
  } else if($post->post_type == 'attachment' && $post->post_parent > 0 && $post->post_parent != $post->ID && !empty($permalink_manager_uris[$post->post_parent])) {
83
+ $permalink = "{$home_url}/{$permalink_manager_uris[$post->post_parent]}/attachment/{$post->post_name}";
84
  } else if(!empty($permalink_manager_options['general']['decode_uris'])) {
85
  $permalink = "{$home_url}/" . urldecode("/{$permalink}");
86
  }
138
  // 1. Get the permastruct
139
  if($post_type == 'attachment') {
140
  $parent_page = ($post->post_parent > 0 && $post->post_parent != $post->ID) ? get_post($post->post_parent) : false;
141
+ // $default_permastruct = ($parent_page) ? trim(get_page_uri($parent_page->ID), "/") . "/attachment" : "";
142
+
143
+ if(!empty($parent_page->ID)) {
144
+ $parent_page_uri = (!empty($permalink_manager_uris[$parent_page->ID])) ? $permalink_manager_uris[$parent_page->ID] : get_page_uri($parent_page->ID);
145
+ } else {
146
+ $parent_page_uri = "";
147
+ }
148
+
149
+ $default_permastruct = ($parent_page) ? trim($parent_page_uri, "/") . "/attachment" : "";
150
 
151
  if($native_uri) {
152
  $permastruct = $default_permastruct;
284
  }
285
 
286
  // 5. Clear the URI
287
+ $default_uri = Permalink_Manager_Helper_Functions::clear_single_uri($default_uri);
 
 
288
 
289
  return apply_filters('permalink_manager_filter_default_post_uri', $default_uri, $post->post_name, $post, $post_name, $native_uri);
290
  }
301
  }
302
 
303
  /**
304
+ * Support url_to_postid
305
+ */
306
+ public function url_to_postid($url) {
307
+ $post = Permalink_Manager_Core_Functions::detect_post(null, $url, true);
308
 
309
+ if(!empty($post->ID)) {
310
+ $native_uri = self::get_default_post_uri($post->ID, true);
311
+ $native_url = sprintf("%s/%s", trim(home_url(), "/"), $native_uri);
312
+ }
313
 
314
+ return ($native_url) ? $native_url : $url;
315
+ }
316
 
317
+ /**
318
+ * Bulk tools
319
+ */
320
+ public static function get_items() {
321
+ global $wpdb;
322
 
323
+ // Check if post types & statuses are not empty
324
+ if(empty($_POST['post_types']) || empty($_POST['post_statuses'])) { return false; }
 
325
 
326
  $post_types_array = ($_POST['post_types']);
327
  $post_statuses_array = ($_POST['post_statuses']);
328
  $post_types = implode("', '", $post_types_array);
329
  $post_statuses = implode("', '", $post_statuses_array);
 
330
 
331
  // Filter the posts by IDs
332
  $where = '';
353
  }
354
 
355
  // Support for attachments
356
+ $attachment_support = (in_array('attachment', $post_types_array)) ? " OR (post_type = 'attachment')" : "";
357
+
358
+ // Get the rows before they are altered
359
+ return $wpdb->get_results("SELECT post_title, post_name, ID FROM {$wpdb->posts} WHERE ((post_status IN ('{$post_statuses}') AND post_type IN ('{$post_types}')){$attachment_support}) {$where}", ARRAY_A);
360
+ }
361
+
362
+ /**
363
+ * Find & replace (bulk action)
364
+ */
365
+ public static function find_and_replace($chunk = null, $mode = '', $old_string = '', $new_string = '') {
366
+ global $wpdb, $permalink_manager_uris;
367
+
368
+ // Reset variables
369
+ $updated_slugs_count = 0;
370
+ $updated_array = array();
371
+ $alert_type = $alert_content = $errors = '';
372
 
373
  // Get the rows before they are altered
374
+ $posts_to_update = ($chunk) ? $chunk : self::get_items();
375
 
376
  // Now if the array is not empty use IDs from each subarray as a key
377
  if($posts_to_update && empty($errors)) {
424
  /**
425
  * Regenerate slugs & bases (bulk action)
426
  */
427
+ static function regenerate_all_permalinks($chunk = null, $mode = '') {
428
  global $wpdb, $permalink_manager_uris;
429
 
430
+ // Reset variables
 
 
 
431
  $updated_slugs_count = 0;
432
  $updated_array = array();
433
  $alert_type = $alert_content = $errors = '';
434
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  // Get the rows before they are altered
436
+ $posts_to_update = ($chunk) ? $chunk : self::get_items();
437
 
438
  // Now if the array is not empty use IDs from each subarray as a key
439
  if($posts_to_update && empty($errors)) {
735
 
736
  // Save only changed URIs
737
  if($new_uri != $old_uri) {
738
+ $permalink_manager_uris[$post_id] = $new_uri;
739
  update_option('permalink-manager-uris', $permalink_manager_uris);
740
  }
741
 
742
+ // Update the slug (if changed)
743
+ if(!empty($_POST['post_name']) && isset($_POST['native_slug']) && ($_POST['native_slug'] !== $_POST['post_name'])) {
744
+ self::update_slug_by_id($_POST['native_slug'], $post_id);
745
+ }
746
+
747
  do_action('permalink-manager-updated-post-uri', $post_id, $new_uri, $old_uri, $native_uri, $default_uri, $single_update = true);
748
  }
749
 
includes/views/permalink-manager-settings.php CHANGED
@@ -39,6 +39,12 @@ class Permalink_Manager_Settings extends Permalink_Manager_Class {
39
  'label' => __('Auto-update permalinks', 'permalink-manager'),
40
  'input_class' => '',
41
  'description' => __('If enabled, the custom permalinks will be automatically updated every time the post is saved or updated.', 'permalink-manager')
 
 
 
 
 
 
42
  )
43
  )
44
  ),
39
  'label' => __('Auto-update permalinks', 'permalink-manager'),
40
  'input_class' => '',
41
  'description' => __('If enabled, the custom permalinks will be automatically updated every time the post is saved or updated.', 'permalink-manager')
42
+ ),
43
+ 'show_native_slug_field' => array(
44
+ 'type' => 'single_checkbox',
45
+ 'label' => __('Show "Native slug" field', 'permalink-manager'),
46
+ 'input_class' => '',
47
+ 'description' => __('If enabled, it would be possible to edit the native slug via URI Editor on single post/term edit page.', 'permalink-manager')
48
  )
49
  )
50
  ),
includes/views/permalink-manager-tools.php CHANGED
@@ -52,7 +52,7 @@ class Permalink_Manager_Tools extends Permalink_Manager_Class {
52
  $home_url = trim(get_option('home'), "/");
53
 
54
  $html = sprintf("<h3>%s</h3>", __("List of duplicated permalinks", "permalink-manager"));
55
- $html .= wpautop(sprintf("<a class=\"button button-primary\" href=\"%s\">%s</a>", admin_url('tools.php?page=permalink-manager&section=tools&subsection=duplicates&clear-permalink-manager-uris=1'), __('Remove all broken URIs', 'permalink-manager')));
56
 
57
  if(!empty($all_duplicates)) {
58
  foreach($all_duplicates as $uri => $duplicates) {
@@ -103,7 +103,7 @@ class Permalink_Manager_Tools extends Permalink_Manager_Class {
103
  }
104
 
105
  $html .= sprintf(
106
- '<td><a href="%1$s">%2$s</a>%3$s</td><td>%4$s</td><td class="actions"><a href="%1$s" target="_blank">%5$s</a>%6$s</td>',
107
  $edit_link,
108
  $title,
109
  " <small>#{$detected_id}</small>",
52
  $home_url = trim(get_option('home'), "/");
53
 
54
  $html = sprintf("<h3>%s</h3>", __("List of duplicated permalinks", "permalink-manager"));
55
+ $html .= wpautop(sprintf("<a class=\"button button-primary\" href=\"%s\">%s</a>", admin_url('tools.php?page=permalink-manager&section=tools&subsection=duplicates&clear-permalink-manager-uris=1'), __('Fix custom permalinks & redirects', 'permalink-manager')));
56
 
57
  if(!empty($all_duplicates)) {
58
  foreach($all_duplicates as $uri => $duplicates) {
103
  }
104
 
105
  $html .= sprintf(
106
+ '<td><a href="%1$s">%2$s</a>%3$s</td><td>%4$s</td><td class="actions"><a href="%1$s">%5$s</a>%6$s</td>',
107
  $edit_link,
108
  $title,
109
  " <small>#{$detected_id}</small>",
includes/views/permalink-manager-uri-editor-post.php CHANGED
@@ -27,6 +27,7 @@ class Permalink_Manager_URI_Editor_Post extends WP_List_Table {
27
 
28
  $output = "<form id=\"permalinks-post-types-table\" class=\"slugs-table\" method=\"post\">";
29
  $output .= wp_nonce_field('permalink-manager', 'uri_editor', true, true);
 
30
 
31
  // Bypass
32
  ob_start();
27
 
28
  $output = "<form id=\"permalinks-post-types-table\" class=\"slugs-table\" method=\"post\">";
29
  $output .= wp_nonce_field('permalink-manager', 'uri_editor', true, true);
30
+ $output .= Permalink_Manager_Admin_Functions::generate_option_field('pm_session_id', array('value' => uniqid(), 'type' => 'hidden'));
31
 
32
  // Bypass
33
  ob_start();
out/permalink-manager-admin.css CHANGED
@@ -6,6 +6,7 @@
6
  #permalink-manager h4{font-size:18px;margin-bottom:10px}
7
  #permalink-manager h5{font-size:15px;margin-bottom:10px}
8
  #permalink-manager .small{display:block;font-weight:400;color:#888;font-size:80%}
 
9
  #permalink-manager .settings-select{min-width:200px}
10
  #permalink-manager .fixed-table{max-width:100%;table-layout:fixed}
11
  #permalink-manager .margin-top{margin-top:15px}
@@ -64,6 +65,7 @@
64
  #permalink-manager .checkboxes > label:nth-of-type(3n+1){clear:both}
65
  #permalink-manager .field-description{font-size:12px}
66
  #permalink-manager .appended-row td{padding-left:0;padding-right:0}
 
67
  #permalink-manager #tools select{min-width:60%}
68
  #permalink-manager fieldset label{margin-bottom:0 !important}
69
 
6
  #permalink-manager h4{font-size:18px;margin-bottom:10px}
7
  #permalink-manager h5{font-size:15px;margin-bottom:10px}
8
  #permalink-manager .small{display:block;font-weight:400;color:#888;font-size:80%}
9
+ #permalink-manager .mute{color:#888}
10
  #permalink-manager .settings-select{min-width:200px}
11
  #permalink-manager .fixed-table{max-width:100%;table-layout:fixed}
12
  #permalink-manager .margin-top{margin-top:15px}
65
  #permalink-manager .checkboxes > label:nth-of-type(3n+1){clear:both}
66
  #permalink-manager .field-description{font-size:12px}
67
  #permalink-manager .appended-row td{padding-left:0;padding-right:0}
68
+ #permalink-manager #tools{margin:0 -15px;padding:0 15px 15px}
69
  #permalink-manager #tools select{min-width:60%}
70
  #permalink-manager fieldset label{margin-bottom:0 !important}
71
 
out/permalink-manager-admin.js CHANGED
@@ -222,6 +222,106 @@ jQuery(document).ready(function() {
222
  });
223
  });
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  /**
226
  * Help tooltips
227
  */
222
  });
223
  });
224
 
225
+ /**
226
+ * Check expiration date
227
+ */
228
+ jQuery(document).on('click', '#pm_get_exp_date', function() {
229
+ jQuery.ajax(permalink_manager.ajax_url, {
230
+ type: 'POST',
231
+ data: {
232
+ action: 'pm_get_exp_date',
233
+ },
234
+ beforeSend: function() {
235
+ var spinner = '<img src="' + permalink_manager.spinners + '/wpspin_light-2x.gif" width="16" height="16">';
236
+ jQuery('#permalink-manager .licence-info').html(spinner);
237
+ },
238
+ success: function(data) {
239
+ jQuery('#permalink-manager .licence-info').html(data);
240
+ }
241
+ });
242
+
243
+ return false;
244
+ });
245
+
246
+ /**
247
+ * Bulk tools
248
+ */
249
+ jQuery('#permalink-manager #tools form').on('submit', function() {
250
+ var data = jQuery(this).serialize() + '&action=' + 'pm_bulk_tools';
251
+ var form = jQuery(this);
252
+ var updated_count = 0;
253
+
254
+ // Hide alert & results table
255
+ jQuery('#permalink-manager .updated-slugs-table, .permalink-manager-notice.updated_slugs, #permalink-manager #updated-list').remove();
256
+
257
+ jQuery.ajax({
258
+ type: 'POST',
259
+ url: permalink_manager.ajax_url,
260
+ data: data,
261
+ beforeSend: function() {
262
+ // Show progress overlay
263
+ jQuery("#permalink-manager #tools").LoadingOverlay("show", {
264
+ background : "rgba(0, 0, 0, 0.1)"
265
+ });
266
+ },
267
+ success: function(data) {
268
+ var table_dom = jQuery('#permalink-manager .updated-slugs-table');
269
+ //console.log(data);
270
+
271
+ // Display the table
272
+ if(data.hasOwnProperty('html')) {
273
+ var table = jQuery(data.html);
274
+
275
+ if(table_dom.length == 0) {
276
+ jQuery('#permalink-manager #tools').after(data.html);
277
+ } else {
278
+ jQuery(table_dom).append(jQuery(table).find('tbody').html());
279
+ }
280
+ }
281
+
282
+ // Hide error message
283
+ jQuery('.permalink-manager-notice.updated_slugs.error').remove();
284
+
285
+ // Display the alert (should be hidden at first)
286
+ if(data.hasOwnProperty('alert') && jQuery('.permalink-manager-notice.updated_slugs .updated_count').length == 0) {
287
+ var alert = jQuery(data.alert).hide();
288
+ jQuery('#plugin-name-heading').after(alert);
289
+ }
290
+
291
+ // Increase updated count
292
+ if(data.hasOwnProperty('updated_count')) {
293
+ if(jQuery(form).attr("data-updated_count")) {
294
+ updated_count = parseInt(jQuery(form).attr("data-updated_count")) + parseInt(data.updated_count);
295
+ } else {
296
+ updated_count = parseInt(data.updated_count);
297
+ }
298
+
299
+ jQuery(form).attr("data-updated_count", updated_count);
300
+ jQuery('.permalink-manager-notice.updated_slugs .updated_count').text(updated_count);
301
+ }
302
+
303
+ // Trigger again
304
+ if(data.hasOwnProperty('left_chunks')) {
305
+ jQuery.ajax(this);
306
+ } else {
307
+ // Display results
308
+ jQuery('.permalink-manager-notice.updated_slugs').fadeIn();
309
+ jQuery('#permalink-manager #tools').LoadingOverlay("hide", true);
310
+
311
+ if(table_dom.length > 0) {
312
+ jQuery('html, body').animate({
313
+ scrollTop: table_dom.offset().top - 100
314
+ }, 2000);
315
+ }
316
+
317
+ jQuery(form).attr("data-updated_count", 0);
318
+ }
319
+ }
320
+ });
321
+
322
+ return false;
323
+ });
324
+
325
  /**
326
  * Help tooltips
327
  */
out/permalink-manager-plugins.js CHANGED
@@ -16,3 +16,12 @@
16
  * @version 2.1.3
17
  */
18
  !function(e,t,n){function y(e){return t.createElement(e)}function x(e){return Object.keys(e)}function C(e){return x(e).length}var i="__instance__",r=setTimeout,s="innerHTML",a="textContent",o="className",f="classes",u="toLowerCase",l="replace",c="firstChild",p="parentNode",g="nextSibling",d="previousSibling",v="appendChild",h="insertBefore",b="removeChild",m="setAttribute",w="getAttribute",j="preventDefault",k="addEventListener";!function(e){e.version="2.1.3",e[i]={},e.each=function(t,n){return r(function(){var r,n=e[i];for(r in n)t(n[r],r,n)},0===n?0:n||1),e}}(e[n]=function(t,D){function H(){B.focus()}function I(e){var n,t=e?this:B;r(function(){n=t[a].split(N.join);for(K in n)_.set(n[K])},1)}var B,K,O,_=this,E=Date.now(),L=t.placeholder||"",N={join:", ",max:9999,escape:[",","\n"],alert:!0,text:["Delete “%s”","Duplicate “%s”"],classes:["tags","tag","tags-input","tags-output","tags-view"],update:function(){}},S=y("span"),T=y("span"),A="data-tag";e[n][i][t.id||t.name||C(e[n][i])]=_,D="string"==typeof D?{join:D}:D||{};for(K in N)"undefined"!=typeof D[K]&&(N[K]=D[K]);t[o]=N[f][3],S[o]=N[f][0]+" "+N[f][0]+"-"+E,S[k]("click",H,!1),S.id=N[f][0]+":"+(t.id||E),S[s]='<span class="'+N[f][4]+'"></span>',T[o]=N[f][2],T[s]='<span contenteditable spellcheck="false" style="white-space:nowrap;outline:none;"></span><span>'+L+"</span>",t[p][h](S,t[g]||null),S[c][v](T),B=T[c],_.tags={},_.error=0,_.filter=function(e){return(e+"")[l](new RegExp("["+N.join[l](/\s/g,"")+"]|\\s{2,}|^\\s+|\\s+$","g"),"")[u]()},_.update=function(e,n){for(t.value="";(K=S[c][c])&&K[w](A);)S[c][b](K);if(0===e)e=x(_.tags);else{for(K in e)O=_.filter(e[K]),O&&(_.tags[O]=1);e=x(_.tags)}_.tags={};for(K in e)_.set(e[K],n);return N.update(_),_},_.reset=function(e){return e=_.filter(e||""),e?delete _.tags[e]:_.tags={},_.update(0,1)},_.set=function(e,n){if(e=_.filter(e),""===e||C(_.tags)===N.max)return B[s]="",_;var i=y("span"),r=y("a");if(i[o]=N[f][1],i[m](A,e),r.href="javascript:;",r.title=(N.text[0]||"")[l](/%s/g,e),r[k]("click",function(e){var t=this,n=t[p],i=t[p][w](A);n[p][b](n),_.reset(i),H(),e[j]()},!1),i[v](r),B[s]="",B[g][s]=L,_.tags[e]){if(n)S[c][h](i,T);else if(N.alert){_.error=1;var a=(N.text[1]||e)[l](/%s/g,e);"function"==typeof N.alert?N.alert(a,e,_):alert(a)}}else _.tags[e]=1,S[c][h](i,T);return t.value=x(_.tags).join(N.join),!n&&N.update(_),_},function(){return B[k]("blur",function(){_.error=0,_.set(this[a])},!1),B[k]("paste",I,!1),B[k]("keydown",function(e){_.error=0;var y,t=this,n=e.keyCode,i=S,o=(e.key||String.fromCharCode(n))[u](),f=e.ctrlKey,l=e.shiftKey,c=T[d]&&T[d][w](A),v=B[g],h="tab"===o||!l&&9===n,b="enter"===o||!l&&13===n,m=" "===o||!l&&32===n,k="backspace"===o||!l&&8===n;if(!f&&b){for(;i=i[p];)if("form"===i.nodeName[u]()){y=i;break}_.set(t[a]),0===_.error&&y&&y.submit()}else if(f&&("v"===o||!l&&86===n))I();else if(!t[a]&&k)_.reset(c),H();else{var C,D,x=N.escape;for(K in x)if(C=x[K],D="s"===C,(D||" "===C)&&h||(D||"\n"===C)&&b||(D||" "===C)&&m)return r(function(){_.set(t[a]),H()},1),void e[j]();r(function(){var e=t[a];for(v[s]=e?"":L,K=0,O=x.length;O>K;++K)if(x[K]&&-1!==e.indexOf(x[K])){_.set(e.split(x[K]).join(""));break}},1)}},!1),_}(),_.update(t.value.split(N.join),1),_.config=N,_.input=T,_.view=S,_.target=_.output=t})}(window,document,"TIB");
 
 
 
 
 
 
 
 
 
16
  * @version 2.1.3
17
  */
18
  !function(e,t,n){function y(e){return t.createElement(e)}function x(e){return Object.keys(e)}function C(e){return x(e).length}var i="__instance__",r=setTimeout,s="innerHTML",a="textContent",o="className",f="classes",u="toLowerCase",l="replace",c="firstChild",p="parentNode",g="nextSibling",d="previousSibling",v="appendChild",h="insertBefore",b="removeChild",m="setAttribute",w="getAttribute",j="preventDefault",k="addEventListener";!function(e){e.version="2.1.3",e[i]={},e.each=function(t,n){return r(function(){var r,n=e[i];for(r in n)t(n[r],r,n)},0===n?0:n||1),e}}(e[n]=function(t,D){function H(){B.focus()}function I(e){var n,t=e?this:B;r(function(){n=t[a].split(N.join);for(K in n)_.set(n[K])},1)}var B,K,O,_=this,E=Date.now(),L=t.placeholder||"",N={join:", ",max:9999,escape:[",","\n"],alert:!0,text:["Delete “%s”","Duplicate “%s”"],classes:["tags","tag","tags-input","tags-output","tags-view"],update:function(){}},S=y("span"),T=y("span"),A="data-tag";e[n][i][t.id||t.name||C(e[n][i])]=_,D="string"==typeof D?{join:D}:D||{};for(K in N)"undefined"!=typeof D[K]&&(N[K]=D[K]);t[o]=N[f][3],S[o]=N[f][0]+" "+N[f][0]+"-"+E,S[k]("click",H,!1),S.id=N[f][0]+":"+(t.id||E),S[s]='<span class="'+N[f][4]+'"></span>',T[o]=N[f][2],T[s]='<span contenteditable spellcheck="false" style="white-space:nowrap;outline:none;"></span><span>'+L+"</span>",t[p][h](S,t[g]||null),S[c][v](T),B=T[c],_.tags={},_.error=0,_.filter=function(e){return(e+"")[l](new RegExp("["+N.join[l](/\s/g,"")+"]|\\s{2,}|^\\s+|\\s+$","g"),"")[u]()},_.update=function(e,n){for(t.value="";(K=S[c][c])&&K[w](A);)S[c][b](K);if(0===e)e=x(_.tags);else{for(K in e)O=_.filter(e[K]),O&&(_.tags[O]=1);e=x(_.tags)}_.tags={};for(K in e)_.set(e[K],n);return N.update(_),_},_.reset=function(e){return e=_.filter(e||""),e?delete _.tags[e]:_.tags={},_.update(0,1)},_.set=function(e,n){if(e=_.filter(e),""===e||C(_.tags)===N.max)return B[s]="",_;var i=y("span"),r=y("a");if(i[o]=N[f][1],i[m](A,e),r.href="javascript:;",r.title=(N.text[0]||"")[l](/%s/g,e),r[k]("click",function(e){var t=this,n=t[p],i=t[p][w](A);n[p][b](n),_.reset(i),H(),e[j]()},!1),i[v](r),B[s]="",B[g][s]=L,_.tags[e]){if(n)S[c][h](i,T);else if(N.alert){_.error=1;var a=(N.text[1]||e)[l](/%s/g,e);"function"==typeof N.alert?N.alert(a,e,_):alert(a)}}else _.tags[e]=1,S[c][h](i,T);return t.value=x(_.tags).join(N.join),!n&&N.update(_),_},function(){return B[k]("blur",function(){_.error=0,_.set(this[a])},!1),B[k]("paste",I,!1),B[k]("keydown",function(e){_.error=0;var y,t=this,n=e.keyCode,i=S,o=(e.key||String.fromCharCode(n))[u](),f=e.ctrlKey,l=e.shiftKey,c=T[d]&&T[d][w](A),v=B[g],h="tab"===o||!l&&9===n,b="enter"===o||!l&&13===n,m=" "===o||!l&&32===n,k="backspace"===o||!l&&8===n;if(!f&&b){for(;i=i[p];)if("form"===i.nodeName[u]()){y=i;break}_.set(t[a]),0===_.error&&y&&y.submit()}else if(f&&("v"===o||!l&&86===n))I();else if(!t[a]&&k)_.reset(c),H();else{var C,D,x=N.escape;for(K in x)if(C=x[K],D="s"===C,(D||" "===C)&&h||(D||"\n"===C)&&b||(D||" "===C)&&m)return r(function(){_.set(t[a]),H()},1),void e[j]();r(function(){var e=t[a];for(v[s]=e?"":L,K=0,O=x.length;O>K;++K)if(x[K]&&-1!==e.indexOf(x[K])){_.set(e.split(x[K]).join(""));break}},1)}},!1),_}(),_.update(t.value.split(N.join),1),_.config=N,_.input=T,_.view=S,_.target=_.output=t})}(window,document,"TIB");
19
+
20
+ /**
21
+ * LoadingOverlay
22
+ * Copyright (c) Gaspare Sganga
23
+ * https://gasparesganga.com/labs/jquery-loading-overlay/
24
+ * @license MIT
25
+ * @version 2.1.5
26
+ */
27
+ !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?e(require("jquery")):e(jQuery)}(function(e,s){"use strict";var t={background:"rgba(255, 255, 255, 0.8)",backgroundClass:"",image:"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 1000'><circle r='80' cx='500' cy='90'/><circle r='80' cx='500' cy='910'/><circle r='80' cx='90' cy='500'/><circle r='80' cx='910' cy='500'/><circle r='80' cx='212' cy='212'/><circle r='80' cx='788' cy='212'/><circle r='80' cx='212' cy='788'/><circle r='80' cx='788' cy='788'/></svg>",imageAnimation:"2000ms rotate_right",imageAutoResize:!0,imageResizeFactor:1,imageColor:"#202020",imageClass:"",imageOrder:1,fontawesome:"",fontawesomeAnimation:"",fontawesomeAutoResize:!0,fontawesomeResizeFactor:1,fontawesomeColor:"#202020",fontawesomeOrder:2,custom:"",customAnimation:"",customAutoResize:!0,customResizeFactor:1,customOrder:3,text:"",textAnimation:"",textAutoResize:!0,textResizeFactor:.5,textColor:"#202020",textClass:"",textOrder:4,progress:!1,progressAutoResize:!0,progressResizeFactor:.25,progressColor:"#a0a0a0",progressClass:"",progressOrder:5,progressFixedPosition:"",progressSpeed:200,progressMin:0,progressMax:100,size:50,maxSize:120,minSize:20,direction:"column",fade:!0,resizeInterval:50,zIndex:2147483647},a={overlay:{"box-sizing":"border-box",position:"relative",display:"flex","flex-wrap":"nowrap","align-items":"center","justify-content":"space-around"},element:{"box-sizing":"border-box",overflow:"visible",flex:"0 0 auto",display:"flex","justify-content":"center","align-items":"center"},element_svg:{width:"100%",height:"100%"},progress_fixed:{position:"absolute",left:"0",width:"100%"},progress_wrapper:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%"},progress_bar:{position:"absolute",left:"0"}},o={count:0,container:s,settings:s,wholePage:s,resizeIntervalId:s,text:s,progress:s},r={animations:["rotate_right","rotate_left","fadein","pulse"],progressPosition:["top","bottom"]},i={animations:{name:"rotate_right",time:"2000ms"},fade:[400,200]};function n(s,t){s=e(s),t.size=y(t.size),t.maxSize=parseInt(t.maxSize,10)||0,t.minSize=parseInt(t.minSize,10)||0,t.resizeInterval=parseInt(t.resizeInterval,10)||0;var r=f(s),n=p(s);if(!1===n){if((n=e.extend({},o)).container=s,n.wholePage=s.is("body"),r=e("<div>",{class:"loadingoverlay"}).css(a.overlay).css("flex-direction","row"===t.direction.toLowerCase()?"row":"column"),t.backgroundClass?r.addClass(t.backgroundClass):r.css("background",t.background),n.wholePage&&r.css({position:"fixed",top:0,left:0,width:"100%",height:"100%"}),void 0!==t.zIndex&&r.css("z-index",t.zIndex),t.image){e.isArray(t.imageColor)?0===t.imageColor.length?t.imageColor=!1:1===t.imageColor.length?t.imageColor={fill:t.imageColor[0]}:t.imageColor={fill:t.imageColor[0],stroke:t.imageColor[1]}:t.imageColor&&(t.imageColor={fill:t.imageColor});var l=u(r,t.imageOrder,t.imageAutoResize,t.imageResizeFactor,t.imageAnimation);"<svg"===t.image.slice(0,4).toLowerCase()&&"</svg>"===t.image.slice(-6).toLowerCase()?(l.append(t.image),l.children().css(a.element_svg),!t.imageClass&&t.imageColor&&l.find("*").css(t.imageColor)):".svg"===t.image.slice(-4).toLowerCase()||"data:image/svg"===t.image.slice(0,14).toLowerCase()?e.ajax({url:t.image,type:"GET",dataType:"html",global:!1}).done(function(e){l.html(e),l.children().css(a.element_svg),!t.imageClass&&t.imageColor&&l.find("*").css(t.imageColor)}):l.css({"background-image":"url("+t.image+")","background-position":"center","background-repeat":"no-repeat","background-size":"cover"}),t.imageClass&&l.addClass(t.imageClass)}if(t.fontawesome){l=u(r,t.fontawesomeOrder,t.fontawesomeAutoResize,t.fontawesomeResizeFactor,t.fontawesomeAnimation).addClass("loadingoverlay_fa");e("<div>",{class:t.fontawesome}).appendTo(l),t.fontawesomeColor&&l.css("color",t.fontawesomeColor)}if(t.custom)l=u(r,t.customOrder,t.customAutoResize,t.customResizeFactor,t.customAnimation).append(t.custom);if(t.text&&(n.text=u(r,t.textOrder,t.textAutoResize,t.textResizeFactor,t.textAnimation).addClass("loadingoverlay_text").text(t.text),t.textClass?n.text.addClass(t.textClass):t.textColor&&n.text.css("color",t.textColor)),t.progress){l=u(r,t.progressOrder,t.progressAutoResize,t.progressResizeFactor,!1).addClass("loadingoverlay_progress");var g=e("<div>").css(a.progress_wrapper).appendTo(l);n.progress={bar:e("<div>").css(a.progress_bar).appendTo(g),fixed:!1,margin:0,min:parseFloat(t.progressMin),max:parseFloat(t.progressMax),speed:parseInt(t.progressSpeed,10)};var c=(t.progressFixedPosition+"").replace(/\s\s+/g," ").toLowerCase().split(" ");2===c.length&&h(c[0])?(n.progress.fixed=c[0],n.progress.margin=y(c[1])):2===c.length&&h(c[1])?(n.progress.fixed=c[1],n.progress.margin=y(c[0])):1===c.length&&h(c[0])&&(n.progress.fixed=c[0],n.progress.margin=0),"top"===n.progress.fixed?l.css(a.progress_fixed).css("top",n.progress.margin?n.progress.margin.value+(n.progress.margin.fixed?n.progress.margin.units:"%"):0):"bottom"===n.progress.fixed&&l.css(a.progress_fixed).css("top","auto"),t.progressClass?n.progress.bar.addClass(t.progressClass):t.progressColor&&n.progress.bar.css("background",t.progressColor)}t.fade?!0===t.fade?t.fade=i.fade:"string"==typeof t.fade||"number"==typeof t.fade?t.fade=[t.fade,t.fade]:e.isArray(t.fade)&&t.fade.length<2&&(t.fade=[t.fade[0],t.fade[0]]):t.fade=[0,0],t.fade=[parseInt(t.fade[0],10),parseInt(t.fade[1],10)],n.settings=t,r.data("loadingoverlay_data",n),s.data("loadingoverlay",r),r.fadeTo(0,.01).appendTo("body"),m(s,!0),t.resizeInterval>0&&(n.resizeIntervalId=setInterval(function(){m(s,!1)},t.resizeInterval)),r.fadeTo(t.fade[0],1)}n.count++}function l(s,t){var a=f(s=e(s)),o=p(s);!1!==o&&(o.count--,(t||o.count<=0)&&(o.resizeIntervalId&&clearInterval(o.resizeIntervalId),a.fadeOut(o.settings.fade[1],function(){e(this).remove()}),s.removeData("loadingoverlay")))}function g(s){m(e(s),!0)}function c(s,t){var a=p(s=e(s));!1!==a&&a.text&&(!1===t?a.text.hide():a.text.show().text(t))}function d(s,t){var a=p(s=e(s));if(!1!==a&&a.progress)if(!1===t)a.progress.bar.hide();else{var o=100*((parseFloat(t)||0)-a.progress.min)/(a.progress.max-a.progress.min);o<0&&(o=0),o>100&&(o=100),a.progress.bar.show().animate({width:o+"%"},a.progress.speed)}}function m(s,t){var a=f(s),o=p(s);if(!1!==o){if(!o.wholePage){var r="fixed"===s.css("position"),i=r?s[0].getBoundingClientRect():s.offset();a.css({position:r?"fixed":"absolute",top:i.top+parseInt(s.css("border-top-width"),10),left:i.left+parseInt(s.css("border-left-width"),10),width:s.innerWidth(),height:s.innerHeight()})}if(o.settings.size){var n=o.wholePage?e(window):s,l=o.settings.size.value;o.settings.size.fixed||(l=Math.min(n.innerWidth(),n.innerHeight())*l/100,o.settings.maxSize&&l>o.settings.maxSize&&(l=o.settings.maxSize),o.settings.minSize&&l<o.settings.minSize&&(l=o.settings.minSize)),a.children(".loadingoverlay_element").each(function(){var s=e(this);if(t||s.data("loadingoverlay_autoresize")){var a=s.data("loadingoverlay_resizefactor");s.hasClass("loadingoverlay_fa")||s.hasClass("loadingoverlay_text")?s.css("font-size",l*a+o.settings.size.units):s.hasClass("loadingoverlay_progress")?(o.progress.bar.css("height",l*a+o.settings.size.units),o.progress.fixed?"bottom"===o.progress.fixed&&s.css("bottom",o.progress.margin?o.progress.margin.value+(o.progress.margin.fixed?o.progress.margin.units:"%"):0).css("bottom","+="+l*a+o.settings.size.units):o.progress.bar.css("top",s.position().top).css("top","-="+l*a*.5+o.settings.size.units)):s.css({width:l*a+o.settings.size.units,height:l*a+o.settings.size.units})}})}}}function f(e){return e.data("loadingoverlay")}function p(t){var a=f(t),o=void 0===a?s:a.data("loadingoverlay_data");return void 0===o?(e(".loadingoverlay").each(function(){var s=e(this),t=s.data("loadingoverlay_data");document.body.contains(t.container[0])||(t.resizeIntervalId&&clearInterval(t.resizeIntervalId),s.remove())}),!1):(a.toggle(t.is(":visible")),o)}function u(s,t,o,r,n){var l=e("<div>",{class:"loadingoverlay_element",css:{order:t}}).css(a.element).data({loadingoverlay_autoresize:o,loadingoverlay_resizefactor:r}).appendTo(s);if(!0===n&&(n=i.animations.time+" "+i.animations.name),"string"==typeof n){var g,c,d=n.replace(/\s\s+/g," ").toLowerCase().split(" ");2===d.length&&v(d[0])&&x(d[1])?(g=d[1],c=d[0]):2===d.length&&v(d[1])&&x(d[0])?(g=d[0],c=d[1]):1===d.length&&v(d[0])?(g=i.animations.name,c=d[0]):1===d.length&&x(d[0])&&(g=d[0],c=i.animations.time),l.css({"animation-name":"loadingoverlay_animation__"+g,"animation-duration":c,"animation-timing-function":"linear","animation-iteration-count":"infinite"})}return l}function v(e){return!isNaN(parseFloat(e))&&("s"===e.slice(-1)||"ms"===e.slice(-2))}function x(e){return r.animations.indexOf(e)>-1}function h(e){return r.progressPosition.indexOf(e)>-1}function y(e){return!(!e||e<0)&&("string"==typeof e&&["vmin","vmax"].indexOf(e.slice(-4))>-1?{fixed:!0,units:e.slice(-4),value:e.slice(0,-4)}:"string"==typeof e&&["rem"].indexOf(e.slice(-3))>-1?{fixed:!0,units:e.slice(-3),value:e.slice(0,-3)}:"string"==typeof e&&["px","em","cm","mm","in","pt","pc","vh","vw"].indexOf(e.slice(-2))>-1?{fixed:!0,units:e.slice(-2),value:e.slice(0,-2)}:{fixed:!1,units:"px",value:parseFloat(e)})}e.LoadingOverlaySetup=function(s){e.extend(!0,t,s)},e.LoadingOverlay=function(s,a){switch(s.toLowerCase()){case"show":n("body",e.extend(!0,{},t,a));break;case"hide":l("body",a);break;case"resize":g("body");break;case"text":c("body",a);break;case"progress":d("body",a)}},e.fn.LoadingOverlay=function(s,a){switch(s.toLowerCase()){case"show":var o=e.extend(!0,{},t,a);return this.each(function(){n(this,o)});case"hide":return this.each(function(){l(this,a)});case"resize":return this.each(function(){g(this)});case"text":return this.each(function(){c(this,a)});case"progress":return this.each(function(){d(this,a)})}},e(function(){e("head").append(["<style>","@-webkit-keyframes loadingoverlay_animation__rotate_right {","to {","-webkit-transform : rotate(360deg);","transform : rotate(360deg);","}","}","@keyframes loadingoverlay_animation__rotate_right {","to {","-webkit-transform : rotate(360deg);","transform : rotate(360deg);","}","}","@-webkit-keyframes loadingoverlay_animation__rotate_left {","to {","-webkit-transform : rotate(-360deg);","transform : rotate(-360deg);","}","}","@keyframes loadingoverlay_animation__rotate_left {","to {","-webkit-transform : rotate(-360deg);","transform : rotate(-360deg);","}","}","@-webkit-keyframes loadingoverlay_animation__fadein {","0% {","opacity : 0;","-webkit-transform : scale(0.1, 0.1);","transform : scale(0.1, 0.1);","}","50% {","opacity : 1;","}","100% {","opacity : 0;","-webkit-transform : scale(1, 1);","transform : scale(1, 1);","}","}","@keyframes loadingoverlay_animation__fadein {","0% {","opacity : 0;","-webkit-transform : scale(0.1, 0.1);","transform : scale(0.1, 0.1);","}","50% {","opacity : 1;","}","100% {","opacity : 0;","-webkit-transform : scale(1, 1);","transform : scale(1, 1);","}","}","@-webkit-keyframes loadingoverlay_animation__pulse {","0% {","-webkit-transform : scale(0, 0);","transform : scale(0, 0);","}","50% {","-webkit-transform : scale(1, 1);","transform : scale(1, 1);","}","100% {","-webkit-transform : scale(0, 0);","transform : scale(0, 0);","}","}","@keyframes loadingoverlay_animation__pulse {","0% {","-webkit-transform : scale(0, 0);","transform : scale(0, 0);","}","50% {","-webkit-transform : scale(1, 1);","transform : scale(1, 1);","}","100% {","-webkit-transform : scale(0, 0);","transform : scale(0, 0);","}","}","</style>"].join(" "))})});
permalink-manager.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Permalink Manager Lite
5
  * Plugin URI: https://permalinkmanager.pro?utm_source=plugin
6
  * Description: Advanced plugin that allows to set-up custom permalinks (bulk editors included), slugs and permastructures (WooCommerce compatible).
7
- * Version: 2.0.6.2.1
8
  * Author: Maciej Bis
9
  * Author URI: http://maciejbis.net/
10
  * License: GPL-2.0+
@@ -21,7 +21,7 @@ if (!defined('WPINC')) {
21
  // Define the directories used to load plugin files.
22
  define( 'PERMALINK_MANAGER_PLUGIN_NAME', 'Permalink Manager' );
23
  define( 'PERMALINK_MANAGER_PLUGIN_SLUG', 'permalink-manager' );
24
- define( 'PERMALINK_MANAGER_VERSION', '2.0.6.2.1' );
25
  define( 'PERMALINK_MANAGER_FILE', __FILE__ );
26
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit(dirname(__FILE__)) );
27
  define( 'PERMALINK_MANAGER_BASENAME', dirname(plugin_basename(__FILE__)));
@@ -149,6 +149,7 @@ class Permalink_Manager_Class {
149
  ),
150
  'general' => array(
151
  'force_custom_slugs' => 0,
 
152
  'auto_update_uris' => 0,
153
  'setup_redirects' => 1,
154
  'redirect' => '301',
4
  * Plugin Name: Permalink Manager Lite
5
  * Plugin URI: https://permalinkmanager.pro?utm_source=plugin
6
  * Description: Advanced plugin that allows to set-up custom permalinks (bulk editors included), slugs and permastructures (WooCommerce compatible).
7
+ * Version: 2.1.0
8
  * Author: Maciej Bis
9
  * Author URI: http://maciejbis.net/
10
  * License: GPL-2.0+
21
  // Define the directories used to load plugin files.
22
  define( 'PERMALINK_MANAGER_PLUGIN_NAME', 'Permalink Manager' );
23
  define( 'PERMALINK_MANAGER_PLUGIN_SLUG', 'permalink-manager' );
24
+ define( 'PERMALINK_MANAGER_VERSION', '2.1.0' );
25
  define( 'PERMALINK_MANAGER_FILE', __FILE__ );
26
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit(dirname(__FILE__)) );
27
  define( 'PERMALINK_MANAGER_BASENAME', dirname(plugin_basename(__FILE__)));
149
  ),
150
  'general' => array(
151
  'force_custom_slugs' => 0,
152
+ 'show_native_slug_field' => 0,
153
  'auto_update_uris' => 0,
154
  'setup_redirects' => 1,
155
  'redirect' => '301',