Permalink Manager Lite - Version 2.2.1.2

Version Description

Download this release

Release Info

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

Code changes from version 2.1.2.4 to 2.2.1.2

README.txt CHANGED
@@ -1,4 +1,4 @@
1
- === Permalink Manager Lite ===
2
  Contributors: mbis
3
  Donate link: https://www.paypal.me/Bismit
4
  License: GPLv3
@@ -6,8 +6,8 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
6
  Tags: urls, permalinks, custom permalinks, url, permalink, woocommerce permalinks
7
  Requires at least: 4.4.0
8
  Requires PHP: 5.4
9
- Tested up to: 5.0
10
- Stable tag: 2.1.2.4
11
 
12
  Advanced plugin that allows to set-up custom permalinks (bulk editors included), slugs and permastructures (WooCommerce compatible).
13
 
@@ -19,25 +19,26 @@ The plugin supports all custom post types & custom taxonomies and popular 3rd pa
19
 
20
  = All features =
21
 
22
- * **Edit full permalinks** | A completely custom permalink can be set for each post, page and public custom post type individually *(categories, tags & custom taxonomies terms permalinks can be edited in Permalink Manager Pro)*
23
- * **Custom post types support** | It is also possible to exclude specific post types & taxonomies to stop Permalink Manager from filtering their permalinks.
24
- * **Custom permastructures** | The plugin allows to specify how the custom permalinks should be formatted by default (when the new post/term is added or after the permalinks are regenerated)
25
- * **Bulk editors** | "Regenerate/Reset" + "Find and replace" tools that allow to bulk/mass change the permalinks (or native slugs).
26
- * **Auto-redirect** | Old (native) permalinks are redirected to new (custom) permalinks (in 301 or 302 mode) to prevent 404 error (SEO friendly).
27
- * **Canonical redirects** | Possibility to disable native canonical redirects.
28
- * **Trailing slashes settings** | They can be forced or removed from all permalinks.
 
29
 
30
  = Additional features available in Permalink Manager Pro =
31
 
32
- * **Taxonomies** | Full support for taxonomies (categories, tags & custom taxonomies).
33
- * **WooCommerce** | Full support for WooCommerce (products, product tags, product categories). Permalink Manager allows to remove /product-category and /product from WooCommerce permalinks.
34
- * **WooCommerce coupon URLs** | Coupon codes may have their public URLs (eg. http://shop.com/BLACKFRIDAY) that will automatically apply the discount to the cart.
35
- * **Custom fields** | Custom fields can be used inside permalinks (Advanced Custom Fields plugin supported).
36
- * **Extra internal redirects** | Multiple URLs can lead to a single post/term (they could be defined individually for each element).
37
- * **External URL redirect** | Posts/terms can redirect the visitors to external websites (the URLs could be defined individually for each element).
38
- * **"Stop-words"** | User-defined words will be automatically removed from default permalinks.
39
- * **Custom Permalinks** | Import custom permalinks saved with that plugin.
40
- * **Priority support** | All the support requests from Permalink Manager Pro users are handled in the first place.
41
 
42
  Buy <a href="https://permalinkmanager.pro?utm_source=wordpress">Permalink Manager Pro here</a>.
43
 
@@ -75,18 +76,30 @@ A. Currently there is no 100% guarantee that Permalink Manager will work correct
75
 
76
  == Screenshots ==
77
 
78
- 1. "Permalink editor".
79
- 2. "Find and replace" section.
80
- 3. "Regenerate/Reset" section.
81
- 4. "Permastructures" section.
82
- 5. A list of updated posts.
83
- 6. Editable URI box in Post/Page/CPT edit pagees.
84
- 7. Settings section.
85
- 8. URI Editor in Gutenberg.
86
 
87
  == Changelog ==
88
 
89
- = 2.1.2.3/2.1.2.4 =
 
 
 
 
 
 
 
 
 
 
 
 
90
  * Hotfix for WPML - ?lang query parameter is now appended correctly
91
  * Support for comment pages endpoint
92
  * Minor code adjustments
1
+ === Permalink Manager Pro ===
2
  Contributors: mbis
3
  Donate link: https://www.paypal.me/Bismit
4
  License: GPLv3
6
  Tags: urls, permalinks, custom permalinks, url, permalink, woocommerce permalinks
7
  Requires at least: 4.4.0
8
  Requires PHP: 5.4
9
+ Tested up to: 5.1.1
10
+ Stable tag: 2.2.1.2
11
 
12
  Advanced plugin that allows to set-up custom permalinks (bulk editors included), slugs and permastructures (WooCommerce compatible).
13
 
19
 
20
  = All features =
21
 
22
+ * **Edit full permalinks**<br/>A completely custom permalink can be set for each post, page and public custom post type individually *(categories, tags & custom taxonomies terms permalinks can be edited in Permalink Manager Pro)*
23
+ * **Custom post types support**<br/>It is also possible to exclude specific post types & taxonomies to stop Permalink Manager from filtering their permalinks.
24
+ * **Custom permastructures**<br/>The plugin allows to specify how the custom permalinks should be formatted by default (when the new post/term is added or after the permalinks are regenerated)
25
+ * **Translate permalinks**<br/>Permalink Manager allows to translate and set different permalink format/structure per language when WPML or Polylang plugin is enabled.
26
+ * **Auto-redirect**<br/>Old (native) permalinks are redirected to new (custom) permalinks (in 301 or 302 mode) to prevent 404 error (SEO friendly).
27
+ * **Canonical redirects**<br/>Possibility to disable native canonical redirects.
28
+ * **Bulk editors**<br/>"Regenerate/Reset" + "Find and replace" tools that allow to bulk/mass change the permalinks (or native slugs).
29
+ * **Trailing slashes settings**<br/>They can be forced or removed from all permalinks.
30
 
31
  = Additional features available in Permalink Manager Pro =
32
 
33
+ * **Taxonomies**<br/>Full support for taxonomies (categories, tags & custom taxonomies).
34
+ * **WooCommerce**<br/>Full support for WooCommerce (products, product tags, product categories). Permalink Manager allows to remove /product-category and /product from WooCommerce permalinks.
35
+ * **WooCommerce coupon URLs**<br/>Coupon codes may have their public URLs (eg. http://shop.com/BLACKFRIDAY) that will automatically apply the discount to the cart.
36
+ * **Custom fields**<br/>Custom fields can be used inside permalinks (compatible with Advanced Custom Fields).
37
+ * **Extra internal redirects**<br/>Multiple URLs can lead to a single post/term (they could be defined individually for each element).
38
+ * **External URL redirect**<br/>Posts/terms can redirect the visitors to external websites (the URLs could be defined individually for each element).
39
+ * **"Stop-words"**<br/>User-defined words can be automatically removed from default permalinks.
40
+ * **Custom Permalinks**<br/>Import custom permalinks saved with that plugin.
41
+ * **Priority support**<br/>All the support requests from Permalink Manager Pro users are handled in the first place.
42
 
43
  Buy <a href="https://permalinkmanager.pro?utm_source=wordpress">Permalink Manager Pro here</a>.
44
 
76
 
77
  == Screenshots ==
78
 
79
+ 1. Permalink URI editor.
80
+ 2. Permalink URI editor in Gutenberg.
81
+ 3. "Find & replace" tool.
82
+ 4. "Regenerate/Reset" tool.
83
+ 5. A list of updated posts after the permalinks are regenerated.
84
+ 6. Permastructure settings.
85
+ 7. Permastructure settings (different permalink structure per language).
86
+ 8. Permalink Manager settings.
87
 
88
  == Changelog ==
89
 
90
+ = 2.2.1.1/2.2.1.2 =
91
+ * Hotfix for function that detects custom URIs
92
+ * Custom URIs for WP All Import inported posts are now generated 30 seconds after the import job is completed
93
+
94
+ = 2.2.1 =
95
+ * Hotfix for Customizer (custom permalinks filters are disabled in admin panel)
96
+ * Minor UX improvements
97
+ * Partial support for TranslatePress plugin added
98
+ * Term permalinks are processed correctly when WPML enabled and "Adjust IDs for multilingual functionality" mode is activated
99
+ * New setting field separated from "Force custom slugs" - now, both the native slugs and special characters (.|_+) can be kept inside the slugs
100
+ * New filter - "permalink_manager_force_custom_slugs"
101
+
102
+ = 2.2.0 =
103
  * Hotfix for WPML - ?lang query parameter is now appended correctly
104
  * Support for comment pages endpoint
105
  * Minor code adjustments
includes/core/permalink-manager-actions.php CHANGED
@@ -94,6 +94,8 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
94
  * Trigger bulk tools via AJAX
95
  */
96
  function pm_bulk_tools() {
 
 
97
  // Define variables
98
  $return = array('alert' => Permalink_Manager_Admin_Functions::get_alert_message(__( '<strong>No slugs</strong> were updated!', 'permalink-manager' ), 'error updated_slugs'));
99
 
@@ -108,6 +110,14 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
108
 
109
  // Check if both strings are set for "Find and replace" tool
110
  if(!empty($function_name)) {
 
 
 
 
 
 
 
 
111
  // Get the mode
112
  $mode = isset($_POST['mode']) ? $_POST['mode'] : 'custom_uris';
113
 
@@ -184,6 +194,14 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
184
  delete_transient("pm_{$uniq_id}_progress");
185
  }
186
  }
 
 
 
 
 
 
 
 
187
  }
188
 
189
  wp_send_json($return);
@@ -430,12 +448,12 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
430
  $all_redirect_duplicates = Permalink_Manager_Helper_Functions::get_all_duplicates(true);
431
 
432
  foreach($all_redirect_duplicates as $single_redirect_duplicate) {
 
433
 
434
- $last_element = end($single_redirect_duplicate);
435
  foreach($single_redirect_duplicate as $redirect_key) {
436
  // Keep a single redirect
437
  if($last_element == $redirect_key) { continue; }
438
- preg_match("/redirect-([\d]+)_([\d]+)/", $redirect_key, $ids);
439
 
440
  if(!empty($ids[2]) && !empty($permalink_manager_redirects[$ids[2]][$ids[1]])) {
441
  $removed_redirects++;
@@ -487,7 +505,7 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
487
  public static function force_clear_single_redirect($redirect_key) {
488
  global $permalink_manager_redirects, $permalink_manager_before_sections_html;
489
 
490
- preg_match("/redirect-([\d]+)_([\d]+)/", $redirect_key, $ids);
491
 
492
  if(!empty($permalink_manager_redirects[$ids[2]][$ids[1]])) {
493
  unset($permalink_manager_redirects[$ids[2]][$ids[1]]);
94
  * Trigger bulk tools via AJAX
95
  */
96
  function pm_bulk_tools() {
97
+ global $sitepress, $wp_filter;
98
+
99
  // Define variables
100
  $return = array('alert' => Permalink_Manager_Admin_Functions::get_alert_message(__( '<strong>No slugs</strong> were updated!', 'permalink-manager' ), 'error updated_slugs'));
101
 
110
 
111
  // Check if both strings are set for "Find and replace" tool
112
  if(!empty($function_name)) {
113
+ // Hotfix for WPML (start)
114
+ if($sitepress) {
115
+ remove_filter('get_terms_args', array($sitepress, 'get_terms_args_filter'), 10);
116
+ remove_filter('get_term', array($sitepress, 'get_term_adjust_id'), 1);
117
+ remove_filter('terms_clauses', array($sitepress, 'terms_clauses'), 10);
118
+ remove_filter('get_pages', array($sitepress, 'get_pages_adjust_ids'), 1);
119
+ }
120
+
121
  // Get the mode
122
  $mode = isset($_POST['mode']) ? $_POST['mode'] : 'custom_uris';
123
 
194
  delete_transient("pm_{$uniq_id}_progress");
195
  }
196
  }
197
+
198
+ // Hotfix for WPML (end)
199
+ if($sitepress) {
200
+ add_filter('terms_clauses', array($sitepress, 'terms_clauses'), 10, 4);
201
+ add_filter('get_term', array($sitepress, 'get_term_adjust_id'), 1, 1);
202
+ add_filter('get_terms_args', array($sitepress, 'get_terms_args_filter'), 10, 2);
203
+ add_filter('get_pages', array($sitepress, 'get_pages_adjust_ids'), 1, 2);
204
+ }
205
  }
206
 
207
  wp_send_json($return);
448
  $all_redirect_duplicates = Permalink_Manager_Helper_Functions::get_all_duplicates(true);
449
 
450
  foreach($all_redirect_duplicates as $single_redirect_duplicate) {
451
+ $last_element = reset($single_redirect_duplicate);
452
 
 
453
  foreach($single_redirect_duplicate as $redirect_key) {
454
  // Keep a single redirect
455
  if($last_element == $redirect_key) { continue; }
456
+ preg_match("/redirect-([\d]+)_((?:tax-)?(?:[\d]+))/", $redirect_key, $ids);
457
 
458
  if(!empty($ids[2]) && !empty($permalink_manager_redirects[$ids[2]][$ids[1]])) {
459
  $removed_redirects++;
505
  public static function force_clear_single_redirect($redirect_key) {
506
  global $permalink_manager_redirects, $permalink_manager_before_sections_html;
507
 
508
+ preg_match("/redirect-([\d]+)_((?:tax-)?(?:[\d]+))/", $redirect_key, $ids);
509
 
510
  if(!empty($permalink_manager_redirects[$ids[2]][$ids[1]])) {
511
  unset($permalink_manager_redirects[$ids[2]][$ids[1]]);
includes/core/permalink-manager-admin-functions.php CHANGED
@@ -11,6 +11,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
11
  public function __construct() {
12
  add_action( 'admin_menu', array($this, 'add_menu_page') );
13
  add_action( 'admin_init', array($this, 'init') );
 
14
 
15
  add_action( 'admin_notices', array($this, 'display_plugin_notices'));
16
  add_action( 'admin_notices', array($this, 'display_global_notices'));
@@ -29,10 +30,42 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
29
  add_filter( "plugin_action_links_{$this->plugin_basename}", array($this, "plugins_page_links") );
30
 
31
  // Detect current section
32
- $this->sections = apply_filters('permalink-manager-sections', array());
33
  $this->get_current_section();
34
  }
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  /**
37
  * Get current section (only in plugin sections)
38
  */
@@ -135,7 +168,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
135
  $fields = $section_name = $field_name = '';
136
 
137
  // Allow to filter the $args
138
- $args = apply_filters('permalink-manager-field-args', $args, $input_name);
139
 
140
  $field_type = (isset($args['type'])) ? $args['type'] : 'text';
141
  $default = (isset($args['default'])) ? $args['default'] : '';
@@ -273,12 +306,12 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
273
  $type = $args['post_type'];
274
  $type_name = $type['name'];
275
 
276
- $permastructures = $permalink_manager_permastructs['post_types'];
277
  } else if(!empty($args['taxonomy'])) {
278
  $type = $args['taxonomy'];
279
  $type_name = $type['name'];
280
 
281
- $permastructures = $permalink_manager_permastructs['taxonomies'];
282
  } else {
283
  break;
284
  }
@@ -311,7 +344,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
311
  );
312
 
313
  foreach($languages as $lang => $name) {
314
- $current_lang_permastruct = isset($permastructures["{$type_name}_{$lang}"]) ? $permastructures["{$type_name}_{$lang}"] : $default_permastruct;
315
 
316
  $fields .= "<label>{$name}</label>";
317
  $fields .= "<div class=\"permastruct-container\">";
@@ -364,7 +397,7 @@ class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class {
364
  $html = $fields . $append_content;
365
  }
366
 
367
- return apply_filters('permalink-manager-field-output', $html);
368
  }
369
 
370
  /**
11
  public function __construct() {
12
  add_action( 'admin_menu', array($this, 'add_menu_page') );
13
  add_action( 'admin_init', array($this, 'init') );
14
+ add_action( 'admin_init', array($this, 'redirect_customizer') );
15
 
16
  add_action( 'admin_notices', array($this, 'display_plugin_notices'));
17
  add_action( 'admin_notices', array($this, 'display_global_notices'));
30
  add_filter( "plugin_action_links_{$this->plugin_basename}", array($this, "plugins_page_links") );
31
 
32
  // Detect current section
33
+ $this->sections = apply_filters('permalink_manager_sections', array());
34
  $this->get_current_section();
35
  }
36
 
37
+ /**
38
+ * Redirect custom permalinks to the native ones in Customizer editor
39
+ */
40
+ public function redirect_customizer() {
41
+ if(strpos($_SERVER['REQUEST_URI'], 'customize.php') && !empty($_GET['url'])) {
42
+ $old_url = $_GET['url'];
43
+
44
+ // Detect the post/term
45
+ $element = Permalink_Manager_Core_Functions::detect_post(null, $old_url, true);
46
+
47
+ if(!empty($element->ID)) {
48
+ $new_url = get_permalink($element->ID);
49
+ } else if(!empty($element->term_id)) {
50
+ $new_url = get_term_link($element, $element->taxonomy);
51
+ }
52
+
53
+ // Get the full URL
54
+ if(!empty($new_url)) {
55
+ $customize_url = add_query_arg('url', urlencode($new_url), wp_customize_url());
56
+ if(preg_match('/(.*url(?:[^&]+))(&.*)/', $_SERVER['REQUEST_URI'])) {
57
+ $customize_url .= preg_replace('/(.*url(?:[^&]+))(&.*)/', '$2', $_SERVER['REQUEST_URI']);
58
+ }
59
+
60
+ // Redirect to customizer with native permalink
61
+ if($new_url !== $old_url) {
62
+ wp_safe_redirect($customize_url);
63
+ exit();
64
+ }
65
+ }
66
+ }
67
+ }
68
+
69
  /**
70
  * Get current section (only in plugin sections)
71
  */
168
  $fields = $section_name = $field_name = '';
169
 
170
  // Allow to filter the $args
171
+ $args = apply_filters('permalink_manager_field_args', $args, $input_name);
172
 
173
  $field_type = (isset($args['type'])) ? $args['type'] : 'text';
174
  $default = (isset($args['default'])) ? $args['default'] : '';
306
  $type = $args['post_type'];
307
  $type_name = $type['name'];
308
 
309
+ $permastructures = (!empty($permalink_manager_permastructs['post_types'])) ? $permalink_manager_permastructs['post_types'] : array();
310
  } else if(!empty($args['taxonomy'])) {
311
  $type = $args['taxonomy'];
312
  $type_name = $type['name'];
313
 
314
+ $permastructures = (!empty($permalink_manager_permastructs['taxonomies'])) ? $permalink_manager_permastructs['taxonomies'] : array();
315
  } else {
316
  break;
317
  }
344
  );
345
 
346
  foreach($languages as $lang => $name) {
347
+ $current_lang_permastruct = isset($permastructures["{$type_name}_{$lang}"]) ? $permastructures["{$type_name}_{$lang}"] : '';
348
 
349
  $fields .= "<label>{$name}</label>";
350
  $fields .= "<div class=\"permastruct-container\">";
397
  $html = $fields . $append_content;
398
  }
399
 
400
+ return apply_filters('permalink_manager_field_output', $html);
401
  }
402
 
403
  /**
includes/core/permalink-manager-core-functions.php CHANGED
@@ -13,7 +13,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
13
  global $permalink_manager_options;
14
 
15
  // Trigger only in front-end
16
- if(!is_admin() && function_exists('is_customize_preview') && !is_customize_preview()) {
17
  // Use the URIs set in this plugin
18
  add_filter( 'request', array($this, 'detect_post'), 0, 1 );
19
 
@@ -45,10 +45,11 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
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;
@@ -65,7 +66,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
65
 
66
  if(filter_var($request_url, FILTER_VALIDATE_URL)) {
67
  // Check if "Deep Detect" is enabled
68
- $deep_detect_enabled = apply_filters('permalink-manager-deep-uri-detect', $permalink_manager_options['general']['deep_detect']);
69
 
70
  // Keep only the URI
71
  $request_url = str_replace($home_url, "", $request_url);
@@ -89,7 +90,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
89
  $uri_parts['endpoint_value'] = (!empty($regex_parts[3])) ? $regex_parts[3] : "";
90
 
91
  // Allow to filter the results by third-parties + store the URI parts with $pm_query global
92
- $uri_parts = $pm_query = apply_filters('permalink-manager-detect-uri', $uri_parts, $request_url, $endpoints);
93
 
94
  // Support comment pages
95
  preg_match("/(.*)\/{$wp_rewrite->comments_pagination_base}-([\d]+)/", $request_url, $regex_parts);
@@ -116,44 +117,48 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
116
  // Trim slashes
117
  $uri = trim($uri, "/");
118
 
119
- // Decode both request URI & URIs array & make them lowercase (and save in a separate variable)
120
- $uri = strtolower(urldecode($uri));
121
- $all_uris = array();
122
- foreach ($permalink_manager_uris as $key => $value) {
123
- $all_uris[$key] = strtolower(urldecode($value));
124
- }
125
-
126
  // Ignore URLs with no URI grabbed
127
  if(empty($uri)) return $query;
128
 
129
- /**
130
- * 2. Check if found URI matches any element from custom uris array
131
- */
132
- $element_id = array_search($uri, $all_uris);
133
 
134
- // Check again in case someone added .html suffix to particular post (with .html suffix)
135
- $element_id = (empty($element_id)) ? array_search("{$uri}.html", $all_uris) : $element_id;
 
136
 
137
- // Check again in case someone used post/tax IDs instead of slugs
138
- if($deep_detect_enabled && (isset($old_query['page']))) {
139
- $new_item_id = array_search("{$uri}/{$endpoint_value}", $all_uris);
140
- if($new_item_id) {
141
- $element_id = $new_item_id;
142
- $endpoint_value = $endpoint = "";
 
143
  }
 
 
144
  }
145
 
 
 
 
 
 
 
 
 
 
146
  // Check again for attachment custom URIs
147
- if((isset($old_query['attachment']))) {
148
- $new_item_id = array_search("{$uri}/{$endpoint}/{$endpoint_value}", $all_uris);
149
- if($new_item_id) {
150
- $element_id = $new_item_id;
151
  $endpoint_value = $endpoint = "";
152
  }
153
  }
154
 
155
  // Allow to filter the item_id by third-parties after initial detection
156
- $element_id = apply_filters('permalink-manager-detected-initial-id', $element_id, $uri_parts, $request_url);
157
 
158
  // Clear the original query before it is filtered
159
  $query = ($element_id) ? array() : $query;
@@ -166,7 +171,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
166
  $term_id = intval(preg_replace("/[^0-9]/", "", $element_id));
167
 
168
  // Filter detected post ID
169
- $term_id = apply_filters('permalink-manager-detected-term-id', intval($term_id), $uri_parts, true);
170
 
171
  // Get the variables to filter wp_query and double-check if taxonomy exists
172
  $term = get_term($term_id);
@@ -214,7 +219,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
214
  $element_id = ($is_revision) ? $is_revision : $element_id;
215
 
216
  // Filter detected post ID
217
- $element_id = apply_filters('permalink-manager-detected-post-id', $element_id, $uri_parts);
218
 
219
  $post_to_load = get_post($element_id);
220
  $final_uri = (!empty($post_to_load->post_name)) ? $post_to_load->post_name : false;
@@ -244,7 +249,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
244
  $query['post_type'] = $post_type;
245
  } else if($post_type == 'page') {
246
  $query['pagename'] = $final_uri;
247
- $query['post_type'] = $post_type;
248
  } else if($post_type == 'post') {
249
  $query['name'] = $final_uri;
250
  } else if($post_type == 'attachment') {
@@ -344,6 +349,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
344
  * 8. Debug mode
345
  */
346
  if(isset($_REQUEST['debug_url'])) {
 
347
  $debug_info['old_query_vars'] = $old_query;
348
  $debug_info['new_query_vars'] = $query;
349
  $debug_info['detected_id'] = (!empty($pm_query['id'])) ? $pm_query['id'] : "-";
@@ -354,6 +360,14 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
354
  $debug_info['taxonomy'] = $term_taxonomy;
355
  }
356
 
 
 
 
 
 
 
 
 
357
  $debug_txt = sprintf("<pre style=\"display:block;\">%s</pre>", print_r($debug_info, true));
358
  wp_die($debug_txt);
359
  }
@@ -452,6 +466,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
452
  $redirect_mode = (!empty($permalink_manager_options['general']['redirect'])) ? $permalink_manager_options['general']['redirect'] : false;
453
  $trailing_slashes_mode = (!empty($permalink_manager_options['general']['trailing_slashes'])) ? $permalink_manager_options['general']['trailing_slashes'] : false;
454
  $trailing_slashes_redirect_mode = (!empty($permalink_manager_options['general']['trailing_slashes_redirect'])) ? $permalink_manager_options['general']['trailing_slashes_redirect'] : 301;
 
455
 
456
  // Get query string & URI
457
  $query_string = $_SERVER['QUERY_STRING'];
@@ -507,7 +522,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
507
  }
508
  }
509
 
510
- $redirect_type = (!empty($correct_permalink)) ? 'custom_redirect' : '-';
511
  }
512
 
513
  // Ignore WP-Content links
@@ -540,7 +555,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
540
  $correct_permalink = get_term_link($queried_object->term_id, $queried_object->taxonomy);
541
  }
542
 
543
- $redirect_type = (!empty($correct_permalink)) ? 'native_redirect' : '-';
544
  }
545
 
546
  /**
@@ -580,7 +595,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
580
  * 3. Check if URL contains duplicated slashes
581
  */
582
  if(!empty($old_uri) && ($old_uri != '/') && preg_match('/\/{2,}/', $old_uri)) {
583
- $new_uri = ltrim(preg_replace('/\/{2,}/', '/', $old_uri), "/");
584
  $correct_permalink = "{$home_url}/{$new_uri}";
585
  }
586
 
13
  global $permalink_manager_options;
14
 
15
  // Trigger only in front-end
16
+ if(!is_admin() && (function_exists('is_customize_preview') && is_customize_preview()) == false) {
17
  // Use the URIs set in this plugin
18
  add_filter( 'request', array($this, 'detect_post'), 0, 1 );
19
 
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, $permalink_manager_uris, $wp_filter, $permalink_manager_options, $pm_query, $pm_uri_parts;
49
 
50
+ // Check if the array with custom URIs is set
51
+ //if(!(is_array($permalink_manager_uris)) || (empty($query) && empty($request_url))) return $query;
52
+ if(!(is_array($permalink_manager_uris))) return $query;
53
 
54
  // Used in debug mode & endpoints
55
  $old_query = $query;
66
 
67
  if(filter_var($request_url, FILTER_VALIDATE_URL)) {
68
  // Check if "Deep Detect" is enabled
69
+ $deep_detect_enabled = apply_filters('permalink_manager_deep_uri_detect', $permalink_manager_options['general']['deep_detect']);
70
 
71
  // Keep only the URI
72
  $request_url = str_replace($home_url, "", $request_url);
90
  $uri_parts['endpoint_value'] = (!empty($regex_parts[3])) ? $regex_parts[3] : "";
91
 
92
  // Allow to filter the results by third-parties + store the URI parts with $pm_query global
93
+ $uri_parts = $pm_query = apply_filters('permalink_manager_detect_uri', $uri_parts, $request_url, $endpoints);
94
 
95
  // Support comment pages
96
  preg_match("/(.*)\/{$wp_rewrite->comments_pagination_base}-([\d]+)/", $request_url, $regex_parts);
117
  // Trim slashes
118
  $uri = trim($uri, "/");
119
 
 
 
 
 
 
 
 
120
  // Ignore URLs with no URI grabbed
121
  if(empty($uri)) return $query;
122
 
123
+ // Flip array for better performance
124
+ $all_uris = array_flip($permalink_manager_uris);
 
 
125
 
126
+ // Attempt 1.
127
+ // Find the element ID
128
+ $element_id = isset($all_uris[$uri]) ? $all_uris[$uri] : false;
129
 
130
+ // Atempt 2.
131
+ // Decode both request URI & URIs array & make them lowercase (and save in a separate variable)
132
+ if(empty($element_id)) {
133
+ $uri = strtolower(urldecode($uri));
134
+ foreach($all_uris as $raw_uri => $uri_id) {
135
+ $raw_uri = strtolower(urldecode($raw_uri));
136
+ $all_uris[$raw_uri] = $uri_id;
137
  }
138
+
139
+ $element_id = isset($all_uris[$uri]) ? $all_uris[$uri] : $element_id;
140
  }
141
 
142
+ // Atempt 3.
143
+ // Check again in case someone used post/tax IDs instead of slugs
144
+ //if(empty($element_id) && $deep_detect_enabled && (isset($old_query['page']))) {
145
+ if($deep_detect_enabled && (isset($old_query['page'])) && isset($all_uris["{$uri}/{$endpoint_value}"])) {
146
+ $element_id = $all_uris["{$uri}/{$endpoint_value}"];
147
+ $endpoint_value = $endpoint = "";
148
+ }
149
+
150
+ // Atempt 4.
151
  // Check again for attachment custom URIs
152
+ if(empty($element_id) && isset($old_query['attachment'])) {
153
+ $element_id = isset($all_uris["{$uri}/{$endpoint}/{$endpoint_value}"]) ? $all_uris["{$uri}/{$endpoint}/{$endpoint_value}"] : $element_id;
154
+
155
+ if($element_id) {
156
  $endpoint_value = $endpoint = "";
157
  }
158
  }
159
 
160
  // Allow to filter the item_id by third-parties after initial detection
161
+ $element_id = apply_filters('permalink_manager_detected_element_id', $element_id, $uri_parts, $request_url);
162
 
163
  // Clear the original query before it is filtered
164
  $query = ($element_id) ? array() : $query;
171
  $term_id = intval(preg_replace("/[^0-9]/", "", $element_id));
172
 
173
  // Filter detected post ID
174
+ $term_id = apply_filters('permalink_manager_detected_term_id', intval($term_id), $uri_parts, true);
175
 
176
  // Get the variables to filter wp_query and double-check if taxonomy exists
177
  $term = get_term($term_id);
219
  $element_id = ($is_revision) ? $is_revision : $element_id;
220
 
221
  // Filter detected post ID
222
+ $element_id = apply_filters('permalink_manager_detected_post_id', $element_id, $uri_parts);
223
 
224
  $post_to_load = get_post($element_id);
225
  $final_uri = (!empty($post_to_load->post_name)) ? $post_to_load->post_name : false;
249
  $query['post_type'] = $post_type;
250
  } else if($post_type == 'page') {
251
  $query['pagename'] = $final_uri;
252
+ // $query['post_type'] = $post_type;
253
  } else if($post_type == 'post') {
254
  $query['name'] = $final_uri;
255
  } else if($post_type == 'attachment') {
349
  * 8. Debug mode
350
  */
351
  if(isset($_REQUEST['debug_url'])) {
352
+ $debug_info['uri_parts'] = $uri_parts;
353
  $debug_info['old_query_vars'] = $old_query;
354
  $debug_info['new_query_vars'] = $query;
355
  $debug_info['detected_id'] = (!empty($pm_query['id'])) ? $pm_query['id'] : "-";
360
  $debug_info['taxonomy'] = $term_taxonomy;
361
  }
362
 
363
+ // License key info
364
+ if(class_exists('Permalink_Manager_Pro_Functions')) {
365
+ $license_key = $permalink_manager->functions['pro-functions']->get_license_key();
366
+
367
+ // Mask the license key
368
+ $debug_info['license_key'] = preg_replace('/([^-]+)-([^-]+)-([^-]+)-([^-]+)$/', '***-***-$3', $license_key);
369
+ }
370
+
371
  $debug_txt = sprintf("<pre style=\"display:block;\">%s</pre>", print_r($debug_info, true));
372
  wp_die($debug_txt);
373
  }
466
  $redirect_mode = (!empty($permalink_manager_options['general']['redirect'])) ? $permalink_manager_options['general']['redirect'] : false;
467
  $trailing_slashes_mode = (!empty($permalink_manager_options['general']['trailing_slashes'])) ? $permalink_manager_options['general']['trailing_slashes'] : false;
468
  $trailing_slashes_redirect_mode = (!empty($permalink_manager_options['general']['trailing_slashes_redirect'])) ? $permalink_manager_options['general']['trailing_slashes_redirect'] : 301;
469
+ $redirect_type = '-';
470
 
471
  // Get query string & URI
472
  $query_string = $_SERVER['QUERY_STRING'];
522
  }
523
  }
524
 
525
+ $redirect_type = (!empty($correct_permalink)) ? 'custom_redirect' : $redirect_type;
526
  }
527
 
528
  // Ignore WP-Content links
555
  $correct_permalink = get_term_link($queried_object->term_id, $queried_object->taxonomy);
556
  }
557
 
558
+ $redirect_type = (!empty($correct_permalink)) ? 'native_redirect' : $redirect_type;
559
  }
560
 
561
  /**
595
  * 3. Check if URL contains duplicated slashes
596
  */
597
  if(!empty($old_uri) && ($old_uri != '/') && preg_match('/\/{2,}/', $old_uri)) {
598
+ $new_uri = ltrim(preg_replace('/([^:])([\/]+)/', '$1/', $old_uri), "/");
599
  $correct_permalink = "{$home_url}/{$new_uri}";
600
  }
601
 
includes/core/permalink-manager-gutenberg.php CHANGED
@@ -15,7 +15,7 @@ class Permalink_Manager_Gutenberg extends Permalink_Manager_Class {
15
  }
16
 
17
  public function pm_gutenberg_scripts() {
18
- wp_enqueue_script( 'permalink-manager-gutenberg', PERMALINK_MANAGER_URL . '/out/permalink-manager-gutenberg.js', array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-i18n', ), PERMALINK_MANAGER_VERSION, true );
19
  }
20
 
21
  public function meta_box($post) {
15
  }
16
 
17
  public function pm_gutenberg_scripts() {
18
+ wp_enqueue_script('permalink-manager-gutenberg', PERMALINK_MANAGER_URL . '/out/permalink-manager-gutenberg.js', array('wp-blocks', 'wp-element', 'wp-components', 'wp-i18n'), PERMALINK_MANAGER_VERSION, true);
19
  }
20
 
21
  public function meta_box($post) {
includes/core/permalink-manager-helper-functions.php CHANGED
@@ -38,7 +38,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
38
  static function get_primary_term($post_id, $taxonomy, $slug_only = true) {
39
  global $permalink_manager_options;
40
 
41
- $primary_term_enabled = apply_filters('permalink-manager-primary-term', true);
42
 
43
  if($primary_term_enabled && class_exists('WPSEO_Primary_Term')) {
44
  $primary_term = new WPSEO_Primary_Term($taxonomy, $post_id);
@@ -138,7 +138,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
138
  if($is_taxonomy) {
139
  return array('product_shipping_class');
140
  } else {
141
- return array('revision', 'algolia_task', 'fl_builder', 'fl-builder', 'fl-theme-layout', 'wc_product_tab', 'wc_voucher', 'wc_voucher_template');
142
  }
143
  }
144
 
@@ -163,7 +163,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
163
 
164
  $disabled_post_types = (!empty($permalink_manager_options['general']['partial_disable']['post_types'])) ? array_merge((array) $permalink_manager_options['general']['partial_disable']['post_types'], $initial_disabled_post_types) : $initial_disabled_post_types;
165
 
166
- return apply_filters('permalink-manager-disabled-post-types', $disabled_post_types);
167
  }
168
 
169
  static function get_disabled_taxonomies() {
@@ -173,7 +173,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
173
 
174
  $disabled_taxonomies = (!empty($permalink_manager_options['general']['partial_disable']['taxonomies'])) ? array_merge((array) $permalink_manager_options['general']['partial_disable']['taxonomies'], $initial_disabled_taxonomies) : array();
175
 
176
- return apply_filters('permalink-manager-disabled-taxonomies', $disabled_taxonomies);
177
  }
178
 
179
  static public function is_disabled($content_name, $content_type = 'post_type', $check_if_exists = true) {
@@ -303,7 +303,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
303
  }
304
  }
305
 
306
- return apply_filters("permalink-manager-endpoints", str_replace("/", "\/", $endpoints));
307
  }
308
 
309
  /**
@@ -364,7 +364,7 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
364
  * Get permalink base (home URL)
365
  */
366
  public static function get_permalink_base($element = null) {
367
- return apply_filters('permalink_manager-filter-permalink-base', trim(get_option('home'), "/"), $element);
368
  }
369
 
370
  /**
@@ -426,9 +426,10 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
426
  global $permalink_manager_options;
427
 
428
  // Foree lowercase & hyphens
429
- $force_lowercase = (!is_null($force_lowercase)) ? $force_lowercase : apply_filters('permalink-manager-force-lowercase-uris', true);
 
430
  if(is_null($sanitize_slugs)) {
431
- $sanitize_slugs = ($permalink_manager_options['general']['force_custom_slugs'] == 2) ? false : true;
432
  }
433
 
434
  // Trim slashes & whitespaces
@@ -481,12 +482,15 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
481
  public static function force_custom_slugs($slug, $object, $flat = false) {
482
  global $permalink_manager_options;
483
 
484
- if(!empty($permalink_manager_options['general']['force_custom_slugs'])) {
 
 
 
485
  $title = (!empty($object->name)) ? $object->name : $object->post_title;
486
  $title = self::remove_slashes($title);
487
 
488
  $old_slug = basename($slug);
489
- $new_slug = self::sanitize_title($title, false, null, true);
490
 
491
  $slug = ($old_slug != $new_slug) ? str_replace($old_slug, $new_slug, $slug) : $slug;
492
  }
@@ -563,11 +567,11 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
563
 
564
  if(in_array($uri, $permalink_manager_uris)) {
565
  $all_duplicates = (array) array_keys($permalink_manager_uris, $uri);
566
- $this_uri_lang = Permalink_Manager_Third_Parties::wpml_get_language_code($element_id);
567
 
568
  if($this_uri_lang) {
569
  foreach($all_duplicates as $key => $duplicated_id) {
570
- $duplicated_uri_lang = Permalink_Manager_Third_Parties::wpml_get_language_code($duplicated_id);
571
 
572
  if($duplicated_uri_lang !== $this_uri_lang) {
573
  unset($all_duplicates[$key]);
38
  static function get_primary_term($post_id, $taxonomy, $slug_only = true) {
39
  global $permalink_manager_options;
40
 
41
+ $primary_term_enabled = apply_filters('permalink_manager_primary_term', true);
42
 
43
  if($primary_term_enabled && class_exists('WPSEO_Primary_Term')) {
44
  $primary_term = new WPSEO_Primary_Term($taxonomy, $post_id);
138
  if($is_taxonomy) {
139
  return array('product_shipping_class');
140
  } else {
141
+ return array('revision', 'algolia_task', 'fl_builder', 'fl-builder', 'fl-theme-layout', 'wc_product_tab', 'wc_voucher', 'wc_voucher_template', 'sliders');
142
  }
143
  }
144
 
163
 
164
  $disabled_post_types = (!empty($permalink_manager_options['general']['partial_disable']['post_types'])) ? array_merge((array) $permalink_manager_options['general']['partial_disable']['post_types'], $initial_disabled_post_types) : $initial_disabled_post_types;
165
 
166
+ return apply_filters('permalink_manager_disabled_post_types', $disabled_post_types);
167
  }
168
 
169
  static function get_disabled_taxonomies() {
173
 
174
  $disabled_taxonomies = (!empty($permalink_manager_options['general']['partial_disable']['taxonomies'])) ? array_merge((array) $permalink_manager_options['general']['partial_disable']['taxonomies'], $initial_disabled_taxonomies) : array();
175
 
176
+ return apply_filters('permalink_manager_disabled_taxonomies', $disabled_taxonomies);
177
  }
178
 
179
  static public function is_disabled($content_name, $content_type = 'post_type', $check_if_exists = true) {
303
  }
304
  }
305
 
306
+ return apply_filters("permalink_manager_endpoints", str_replace("/", "\/", $endpoints));
307
  }
308
 
309
  /**
364
  * Get permalink base (home URL)
365
  */
366
  public static function get_permalink_base($element = null) {
367
+ return apply_filters('permalink_manager_filter_permalink_base', trim(get_option('home'), "/"), $element);
368
  }
369
 
370
  /**
426
  global $permalink_manager_options;
427
 
428
  // Foree lowercase & hyphens
429
+ $force_lowercase = (!is_null($force_lowercase)) ? $force_lowercase : apply_filters('permalink_manager_force_lowercase_uris', true);
430
+
431
  if(is_null($sanitize_slugs)) {
432
+ $sanitize_slugs = (!empty($permalink_manager_options['general']['disable_slug_sanitization'])) ? false : true;
433
  }
434
 
435
  // Trim slashes & whitespaces
482
  public static function force_custom_slugs($slug, $object, $flat = false) {
483
  global $permalink_manager_options;
484
 
485
+ $force_custom_slugs = (!empty($permalink_manager_options['general']['force_custom_slugs'])) ? true : false;
486
+ $force_custom_slugs = apply_filters('permalink_manager_force_custom_slugs', $force_custom_slugs, $slug, $object);
487
+
488
+ if($force_custom_slugs) {
489
  $title = (!empty($object->name)) ? $object->name : $object->post_title;
490
  $title = self::remove_slashes($title);
491
 
492
  $old_slug = basename($slug);
493
+ $new_slug = self::sanitize_title($title, false, null, null);
494
 
495
  $slug = ($old_slug != $new_slug) ? str_replace($old_slug, $new_slug, $slug) : $slug;
496
  }
567
 
568
  if(in_array($uri, $permalink_manager_uris)) {
569
  $all_duplicates = (array) array_keys($permalink_manager_uris, $uri);
570
+ $this_uri_lang = Permalink_Manager_Third_Parties::get_language_code($element_id);
571
 
572
  if($this_uri_lang) {
573
  foreach($all_duplicates as $key => $duplicated_id) {
574
+ $duplicated_uri_lang = Permalink_Manager_Third_Parties::get_language_code($duplicated_id);
575
 
576
  if($duplicated_uri_lang !== $this_uri_lang) {
577
  unset($all_duplicates[$key]);
includes/core/permalink-manager-third-parties.php CHANGED
@@ -10,33 +10,61 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
10
  }
11
 
12
  function init_hooks() {
13
- global $sitepress_settings, $permalink_manager_options, $polylang;
14
 
15
  // 0. Stop redirect
16
  add_action('wp', array($this, 'stop_redirect'), 0);
17
 
18
- // 1. WPML & Polylang
19
- if($sitepress_settings || !empty($polylang->links_model->options)) {
20
  // Detect Post/Term function
21
  if(!empty($permalink_manager_options['general']['fix_language_mismatch'])) {
22
- add_filter('permalink-manager-detected-post-id', array($this, 'wpml_language_mismatch_fix'), 9, 3);
23
- add_filter('permalink-manager-detected-term-id', array($this, 'wpml_language_mismatch_fix'), 9, 3);
24
  }
25
 
26
  // URI Editor
27
- add_filter('permalink-manager-uri-editor-extra-info', array($this, 'wpml_lang_column_content_uri_editor'), 9, 3);
28
 
29
  // Adjust front page ID
30
  add_filter('permalink_manager_is_front_page', array($this, 'wpml_is_front_page'), 9, 3);
31
 
32
- if((isset($sitepress_settings['language_negotiation_type']) && in_array($sitepress_settings['language_negotiation_type'], array(1, 2))) || (isset($polylang->links_model->options['force_lang']) && in_array($polylang->links_model->options['force_lang'], array(1, 2, 3)))) {
33
- add_filter('permalink-manager-detect-uri', array($this, 'wpml_detect_post'), 9, 3);
34
- add_filter('permalink_manager-filter-permalink-base', array($this, 'wpml_prepend_lang_prefix'), 9, 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  add_filter('template_redirect', array($this, 'wpml_redirect'), 0, 998 );
36
- } else if(isset($sitepress_settings['language_negotiation_type']) && $sitepress_settings['language_negotiation_type'] == 3) {
37
- add_filter('permalink_manager_filter_final_post_permalink', array($this, 'wpml_append_lang_prefix'), 5, 2);
38
- add_filter('permalink_manager_filter_final_term_permalink', array($this, 'wpml_append_lang_prefix'), 5, 2);
39
- add_filter('permalink-manager-detect-uri', array($this, 'wpml_ignore_lang_query_parameter'), 9);
40
  }
41
 
42
  // Translate slugs
@@ -46,17 +74,17 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
46
  }
47
 
48
  // Translate permastructure
49
- add_filter('permalink_manager_filter_permastructure', array($this, 'wpml_translate_permastructure'), 9, 2);
50
  }
51
 
52
  // 2. AMP
53
  if(defined('AMP_QUERY_VAR')) {
54
  // Detect AMP endpoint
55
- add_filter('permalink-manager-detect-uri', array($this, 'detect_amp'), 10, 2);
56
  add_filter('request', array($this, 'enable_amp'), 10, 1);
57
  }
58
 
59
- // 3. WooCommerce
60
  if(class_exists('WooCommerce')) {
61
  add_filter('request', array($this, 'woocommerce_detect'), 9, 1);
62
  add_filter('template_redirect', array($this, 'woocommerce_checkout_fix'), 9);
@@ -68,39 +96,43 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
68
  add_action('woocommerce_coupon_options_save', 'Permalink_Manager_Pro_Functions::woocommerce_save_coupon_uri', 9, 2);
69
  }
70
  add_filter('request', 'Permalink_Manager_Pro_Functions::woocommerce_detect_coupon_code', 1, 1);
71
- add_filter('permalink-manager-disabled-post-types', 'Permalink_Manager_Pro_Functions::woocommerce_coupon_uris', 9, 1);
72
  }
73
 
74
  add_action('woocommerce_product_import_inserted_product_object', array($this, 'woocommerce_generate_permalinks_after_import'), 9, 2);
75
  }
76
 
77
- // 4. Theme My Login
78
  if(class_exists('Theme_My_Login')) {
79
  add_filter('permalink_manager_filter_final_post_permalink', array($this, 'tml_keep_query_parameters'), 9, 3);
80
  }
81
 
82
- // 5. Yoast SEO
83
  add_filter('wpseo_xml_sitemap_post_url', array($this, 'yoast_fix_sitemap_urls'));
84
 
85
- // 6. WooCommerce Wishlist Plugin
86
  if(function_exists('tinv_get_option')) {
87
- add_filter('permalink-manager-detect-uri', array($this, 'ti_woocommerce_wishlist_uris'), 15, 3);
88
  }
89
 
90
- // 7. Revisionize
91
  if(defined('REVISIONIZE_ROOT')) {
92
  add_action('revisionize_after_create_revision', array($this, 'revisionize_keep_post_uri'), 9, 2);
93
  add_action('revisionize_before_publish', array($this,'revisionize_clone_uri'), 9, 2);
94
  }
95
 
96
- // 8. WP All Import
97
  if(class_exists('PMXI_Plugin') && (empty($permalink_manager_options['general']['pmxi_import_support']))) {
98
  add_action('pmxi_extend_options_featured', array($this, 'wpaiextra_uri_display'), 9, 2);
99
  add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
100
  add_filter('pmxi_addons', array($this, 'wpai_api_register'));
101
  add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse'));
102
  add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
 
103
  add_action('pmxi_saved_post', array($this, 'wpai_save_redirects'));
 
 
 
104
  }
105
  }
106
 
@@ -125,9 +157,11 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
125
  }
126
 
127
  /**
128
- * 1. WPML filters
129
  */
130
- public static function wpml_get_language_code($element) {
 
 
131
  // Fallback
132
  if(is_string($element) && strpos($element, 'tax-') !== false) {
133
  $element = get_term($element);
@@ -135,29 +169,48 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
135
  $element = get_post($element);
136
  }
137
 
138
- if(isset($element->post_type)) {
139
- $element_id = $element->ID;
140
- $element_type = $element->post_type;
141
- } else if(isset($element->taxonomy)) {
142
- $element_id = $element->term_taxonomy_id;
143
- $element_type = $element->taxonomy;
144
- } else {
145
- return false;
146
  }
 
 
 
 
 
 
 
 
 
 
 
147
 
148
- $lang_code = apply_filters('wpml_element_language_code', null, array('element_id' => $element_id, 'element_type' => $element_type));
 
149
 
150
  // Use default language if nothing detected
151
  return ($lang_code) ? $lang_code : self::get_default_language();
152
  }
153
 
 
 
 
 
 
 
 
 
 
 
154
  public static function get_default_language() {
155
- global $sitepress;
156
 
157
  if(function_exists('pll_default_language')) {
158
  $def_lang = pll_default_language('slug');
159
  } else if(is_object($sitepress)) {
160
  $def_lang = $sitepress->get_default_language();
 
 
161
  } else {
162
  $def_lang = '';
163
  }
@@ -166,7 +219,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
166
  }
167
 
168
  public static function get_all_languages($exclude_default_language = false) {
169
- global $sitepress, $sitepress_settings, $polylang;
170
 
171
  $languages_array = $active_languages = array();
172
  $default_language = self::get_default_language();
@@ -175,6 +228,8 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
175
  $languages_array = $sitepress_settings['active_languages'];
176
  } elseif(function_exists('pll_languages_list')) {
177
  $languages_array = pll_languages_list(array('fields' => null));
 
 
178
  }
179
 
180
  // Get native language names as value
@@ -198,11 +253,10 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
198
  }
199
  }
200
 
201
-
202
  return (array) $active_languages;
203
  }
204
 
205
- function wpml_language_mismatch_fix($item_id, $uri_parts, $is_term = false) {
206
  global $wp, $language_code;
207
 
208
  if($is_term) {
@@ -224,7 +278,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
224
  // Stop if no term or post is detected
225
  if(empty($element)) { return false; }
226
 
227
- $language_code = self::wpml_get_language_code($element);
228
 
229
  if(!empty($uri_parts['lang']) && ($uri_parts['lang'] != $language_code)) {
230
  $wpml_item_id = apply_filters('wpml_object_id', $element_id);
@@ -234,14 +288,22 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
234
  return $item_id;
235
  }
236
 
237
- function wpml_detect_post($uri_parts, $request_url, $endpoints) {
238
- global $sitepress, $sitepress_settings, $polylang;
239
 
240
  if(!empty($sitepress_settings['active_languages'])) {
241
- $languages_list = implode("|", $sitepress_settings['active_languages']);
242
  } elseif(function_exists('pll_languages_list')) {
243
  $languages_array = pll_languages_list();
244
- $languages_list = (is_array($languages_array)) ? implode("|", $languages_array) : "";
 
 
 
 
 
 
 
 
245
  }
246
 
247
  $default_language = self::get_default_language();
@@ -274,15 +336,15 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
274
  return $uri_parts;
275
  }
276
 
277
- function wpml_prepend_lang_prefix($base, $element) {
278
- global $sitepress_settings, $polylang, $permalink_manager_uris;
279
 
280
- $language_code = self::wpml_get_language_code($element);
281
  $default_language_code = self::get_default_language();
282
  $home_url = get_home_url();
283
 
284
  // Hide language code if "Use directory for default language" option is enabled
285
- $hide_prefix_for_default_lang = ((isset($sitepress_settings['urls']['directory_for_default_language']) && $sitepress_settings['urls']['directory_for_default_language'] != 1) || !empty($polylang->links_model->options['hide_default'])) ? true : false;
286
 
287
  // Last instance - use language paramater from &_GET array
288
  if(is_admin()) {
@@ -338,10 +400,10 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
338
  return $base;
339
  }
340
 
341
- function wpml_append_lang_prefix($permalink, $element) {
342
  global $sitepress_settings, $polylang, $permalink_manager_uris;
343
 
344
- $language_code = self::wpml_get_language_code($element);
345
  $default_language_code = self::get_default_language();
346
 
347
  // Last instance - use language paramater from &_GET array
@@ -361,21 +423,17 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
361
  return $permalink;
362
  }
363
 
364
- function wpml_translate_post_type_slug($post_type_slug, $element, $post_type) {
365
- $post = (is_integer($element)) ? get_post($element) : $element;
366
- $language_code = self::wpml_get_language_code($post);
367
-
368
- $post_type_slug = apply_filters('wpml_get_translated_slug', $post_type_slug, $post_type, $language_code);
369
-
370
- // Translate %post_type% tag in custom permastructures
371
- return $post_type_slug;
372
- }
373
-
374
- function wpml_translate_permastructure($permastructure, $element) {
375
- global $permalink_manager_permastructs;
376
 
377
  // Get element language code
378
- $language_code = self::wpml_get_language_code($element);
 
 
 
 
 
 
379
 
380
  if(!empty($element->ID)) {
381
  $translated_permastructure = (!empty($permalink_manager_permastructs["post_types"]["{$element->post_type}_{$language_code}"])) ? $permalink_manager_permastructs["post_types"]["{$element->post_type}_{$language_code}"] : '';
@@ -386,21 +444,24 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
386
  return (!empty($translated_permastructure)) ? $translated_permastructure : $permastructure;
387
  }
388
 
389
- function wpml_lang_column_uri_editor($columns) {
390
- if(class_exists('SitePress') || class_exists('Polylang')) {
391
- $columns['post_lang'] = __('Language', 'permalink-manager');
392
- }
393
 
394
- return $columns;
395
- }
396
-
397
- function wpml_lang_column_content_uri_editor($output, $column, $element) {
398
- $language_code = self::wpml_get_language_code($element);
399
  $output .= (!empty($language_code)) ? sprintf(" | <span><strong>%s:</strong> %s</span>", __("Language"), $language_code) : "";
400
 
401
  return $output;
402
  }
403
 
 
 
 
 
 
 
 
 
 
 
404
  function wpml_is_front_page($bool, $page_id, $front_page_id) {
405
  $default_language_code = self::get_default_language();
406
  $page_id = apply_filters('wpml_object_id', $page_id, 'page', true, $default_language_code);
@@ -454,7 +515,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
454
  }
455
 
456
  /**
457
- * Parse Custom Permalinks
458
  */
459
  public static function custom_permalinks_uris() {
460
  global $wpdb;
@@ -510,10 +571,10 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
510
  }
511
 
512
  /**
513
- * 3. WooCommerce
514
  */
515
  function woocommerce_detect($query) {
516
- global $woocommerce, $pm_query;
517
 
518
  $shop_page_id = get_option('woocommerce_shop_page_id');
519
 
@@ -521,7 +582,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
521
  $shop_page_id = apply_filters('wpml_object_id', $shop_page_id, 'page', TRUE);
522
 
523
  // Fix shop page
524
- if(!empty($pm_query['id']) && is_numeric($pm_query['id']) && $shop_page_id == $pm_query['id']) {
525
  $query['post_type'] = 'product';
526
  unset($query['pagename']);
527
  }
@@ -543,10 +604,10 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
543
  }
544
 
545
  function woocommerce_checkout_fix() {
546
- global $wp_query, $pm_query, $permalink_manager_options;
547
 
548
  // Redirect from Shop archive to selected page
549
- if(is_shop() && empty($pm_query['id'])) {
550
  $redirect_mode = (!empty($permalink_manager_options['general']['redirect'])) ? $permalink_manager_options['general']['redirect'] : false;
551
  $redirect_shop = apply_filters('permalink-manager-redirect-shop-archive', false);
552
  $shop_page = get_option('woocommerce_shop_page_id');
@@ -578,7 +639,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
578
  }
579
 
580
  /**
581
- * 4. Theme My Login
582
  */
583
  function tml_keep_query_parameters($permalink, $post, $old_permalink) {
584
  // Get the query string from old permalink
@@ -588,7 +649,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
588
  }
589
 
590
  /**
591
- * 5. Fix Yoast's homepage URL
592
  */
593
  function yoast_fix_sitemap_urls($permalink) {
594
  if(class_exists('WPSEO_Utils')) {
@@ -602,7 +663,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
602
  }
603
 
604
  /**
605
- * 6. Support WooCommerce Wishlist Plugin
606
  */
607
  function ti_woocommerce_wishlist_uris($uri_parts, $request_url, $endpoints) {
608
  global $permalink_manager_uris, $wp;
@@ -627,7 +688,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
627
  }
628
 
629
  /**
630
- * 7. Revisionize
631
  */
632
  function revisionize_keep_post_uri($old_id, $new_id) {
633
  global $permalink_manager_uris;
@@ -653,7 +714,7 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
653
  }
654
 
655
  /**
656
- * 8. WP All Import
657
  */
658
  function wpaiextra_uri_display($post_type, $current_values) {
659
 
@@ -766,16 +827,30 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
766
  if($external_url && class_exists('Permalink_Manager_Pro_Functions')) {
767
  Permalink_Manager_Pro_Functions::save_external_redirect($external_url, $pid);
768
  }
 
769
 
770
- // Save custom URI only if the post type is not disabled (third parameter in get_default_post_uri() function)
771
- if(empty($permalink_manager_uris[$pid])) {
772
- $custom_uri = Permalink_Manager_URI_Functions_Post::get_default_post_uri($pid, false, true);
773
 
774
- if(!empty($custom_uri)) {
775
- $permalink_manager_uris[$pid] = $custom_uri;
776
- update_option('permalink-manager-uris', $permalink_manager_uris);
777
- }
 
 
 
 
 
 
 
 
 
 
 
 
778
  }
 
 
779
  }
780
 
781
  }
10
  }
11
 
12
  function init_hooks() {
13
+ global $sitepress_settings, $permalink_manager_options, $polylang, $translate_press_settings;
14
 
15
  // 0. Stop redirect
16
  add_action('wp', array($this, 'stop_redirect'), 0);
17
 
18
+ // 1. WPML, Polylang & TranslatePress
19
+ if($sitepress_settings || !empty($polylang->links_model->options) || class_exists('TRP_Translate_Press')) {
20
  // Detect Post/Term function
21
  if(!empty($permalink_manager_options['general']['fix_language_mismatch'])) {
22
+ add_filter('permalink_manager_detected_post_id', array($this, 'fix_language_mismatch'), 9, 3);
23
+ add_filter('permalink_manager_detected_term_id', array($this, 'fix_language_mismatch'), 9, 3);
24
  }
25
 
26
  // URI Editor
27
+ add_filter('permalink_manager_uri_editor_extra_info', array($this, 'language_column_uri_editor'), 9, 3);
28
 
29
  // Adjust front page ID
30
  add_filter('permalink_manager_is_front_page', array($this, 'wpml_is_front_page'), 9, 3);
31
 
32
+ // Get translation mode
33
+ $mode = 0;
34
+
35
+ // A. WPML
36
+ if(isset($sitepress_settings['language_negotiation_type'])) {
37
+ $url_settings = $sitepress_settings['language_negotiation_type'];
38
+
39
+ if(in_array($sitepress_settings['language_negotiation_type'], array(1, 2))) {
40
+ $mode = 'prepend';
41
+ } else if($sitepress_settings['language_negotiation_type'] == 3) {
42
+ $mode = 'append';
43
+ }
44
+ }
45
+ // B. Polylang
46
+ else if(isset($polylang->links_model->options['force_lang'])) {
47
+ $url_settings = $polylang->links_model->options['force_lang'];
48
+
49
+ if(in_array($url_settings, array(1, 2, 3))) {
50
+ $mode = 'prepend';
51
+ }
52
+ }
53
+ // C. TranslatePress
54
+ else if(class_exists('TRP_Translate_Press')) {
55
+ $translate_press_settings = get_option('trp_settings');
56
+
57
+ $mode = 'prepend';
58
+ }
59
+
60
+ if($mode == 'prepend') {
61
+ add_filter('permalink_manager_detect_uri', array($this, 'detect_uri_language'), 9, 3);
62
+ add_filter('permalink_manager_filter_permalink_base', array($this, 'prepend_lang_prefix'), 9, 2);
63
  add_filter('template_redirect', array($this, 'wpml_redirect'), 0, 998 );
64
+ } else if($mode == 'append') {
65
+ add_filter('permalink_manager_filter_final_post_permalink', array($this, 'append_lang_prefix'), 5, 2);
66
+ add_filter('permalink_manager_filter_final_term_permalink', array($this, 'append_lang_prefix'), 5, 2);
67
+ add_filter('permalink_manager_detect_uri', array($this, 'wpml_ignore_lang_query_parameter'), 9);
68
  }
69
 
70
  // Translate slugs
74
  }
75
 
76
  // Translate permastructure
77
+ add_filter('permalink_manager_filter_permastructure', array($this, 'translate_permastructure'), 9, 2);
78
  }
79
 
80
  // 2. AMP
81
  if(defined('AMP_QUERY_VAR')) {
82
  // Detect AMP endpoint
83
+ add_filter('permalink_manager_detect_uri', array($this, 'detect_amp'), 10, 2);
84
  add_filter('request', array($this, 'enable_amp'), 10, 1);
85
  }
86
 
87
+ // 4. WooCommerce
88
  if(class_exists('WooCommerce')) {
89
  add_filter('request', array($this, 'woocommerce_detect'), 9, 1);
90
  add_filter('template_redirect', array($this, 'woocommerce_checkout_fix'), 9);
96
  add_action('woocommerce_coupon_options_save', 'Permalink_Manager_Pro_Functions::woocommerce_save_coupon_uri', 9, 2);
97
  }
98
  add_filter('request', 'Permalink_Manager_Pro_Functions::woocommerce_detect_coupon_code', 1, 1);
99
+ add_filter('permalink_manager_disabled_post_types', 'Permalink_Manager_Pro_Functions::woocommerce_coupon_uris', 9, 1);
100
  }
101
 
102
  add_action('woocommerce_product_import_inserted_product_object', array($this, 'woocommerce_generate_permalinks_after_import'), 9, 2);
103
  }
104
 
105
+ // 5. Theme My Login
106
  if(class_exists('Theme_My_Login')) {
107
  add_filter('permalink_manager_filter_final_post_permalink', array($this, 'tml_keep_query_parameters'), 9, 3);
108
  }
109
 
110
+ // 6. Yoast SEO
111
  add_filter('wpseo_xml_sitemap_post_url', array($this, 'yoast_fix_sitemap_urls'));
112
 
113
+ // 7. WooCommerce Wishlist Plugin
114
  if(function_exists('tinv_get_option')) {
115
+ add_filter('permalink_manager_detect_uri', array($this, 'ti_woocommerce_wishlist_uris'), 15, 3);
116
  }
117
 
118
+ // 8. Revisionize
119
  if(defined('REVISIONIZE_ROOT')) {
120
  add_action('revisionize_after_create_revision', array($this, 'revisionize_keep_post_uri'), 9, 2);
121
  add_action('revisionize_before_publish', array($this,'revisionize_clone_uri'), 9, 2);
122
  }
123
 
124
+ // 9. WP All Import
125
  if(class_exists('PMXI_Plugin') && (empty($permalink_manager_options['general']['pmxi_import_support']))) {
126
  add_action('pmxi_extend_options_featured', array($this, 'wpaiextra_uri_display'), 9, 2);
127
  add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
128
  add_filter('pmxi_addons', array($this, 'wpai_api_register'));
129
  add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse'));
130
  add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
131
+
132
  add_action('pmxi_saved_post', array($this, 'wpai_save_redirects'));
133
+
134
+ add_action('pmxi_after_xml_import', array($this, 'wpai_schedule_regenerate_uris_after_xml_import'), 10, 1);
135
+ add_action('wpai_regenerate_uris_after_import_event', array($this, 'wpai_regenerate_uris_after_import'), 10, 1);
136
  }
137
  }
138
 
157
  }
158
 
159
  /**
160
+ * 1. WPML/Polylang/TranslatePress filters
161
  */
162
+ public static function get_language_code($element) {
163
+ global $TRP_LANGUAGE, $translate_press_settings;
164
+
165
  // Fallback
166
  if(is_string($element) && strpos($element, 'tax-') !== false) {
167
  $element = get_term($element);
169
  $element = get_post($element);
170
  }
171
 
172
+ // A. TranslatePress
173
+ if(!empty($TRP_LANGUAGE)) {
174
+ $lang_code = self::get_translatepress_language_code($TRP_LANGUAGE);
 
 
 
 
 
175
  }
176
+ // B. WPML & Polylang
177
+ else {
178
+ if(isset($element->post_type)) {
179
+ $element_id = $element->ID;
180
+ $element_type = $element->post_type;
181
+ } else if(isset($element->taxonomy)) {
182
+ $element_id = $element->term_taxonomy_id;
183
+ $element_type = $element->taxonomy;
184
+ } else {
185
+ return false;
186
+ }
187
 
188
+ $lang_code = apply_filters('wpml_element_language_code', null, array('element_id' => $element_id, 'element_type' => $element_type));
189
+ }
190
 
191
  // Use default language if nothing detected
192
  return ($lang_code) ? $lang_code : self::get_default_language();
193
  }
194
 
195
+ public static function get_translatepress_language_code($lang) {
196
+ global $translate_press_settings;
197
+
198
+ if(!empty($translate_press_settings['url-slugs'])) {
199
+ $lang_code = (!empty($translate_press_settings['url-slugs'][$lang])) ? $translate_press_settings['url-slugs'][$lang] : '';
200
+ }
201
+
202
+ return (!empty($lang_code)) ? $lang_code : false;
203
+ }
204
+
205
  public static function get_default_language() {
206
+ global $sitepress, $translate_press_settings;
207
 
208
  if(function_exists('pll_default_language')) {
209
  $def_lang = pll_default_language('slug');
210
  } else if(is_object($sitepress)) {
211
  $def_lang = $sitepress->get_default_language();
212
+ } else if(!empty($translate_press_settings['default-language'])) {
213
+ $def_lang = self::get_translatepress_language_code($translate_press_settings['default-language']);
214
  } else {
215
  $def_lang = '';
216
  }
219
  }
220
 
221
  public static function get_all_languages($exclude_default_language = false) {
222
+ global $sitepress, $sitepress_settings, $polylang, $translate_press_settings;
223
 
224
  $languages_array = $active_languages = array();
225
  $default_language = self::get_default_language();
228
  $languages_array = $sitepress_settings['active_languages'];
229
  } elseif(function_exists('pll_languages_list')) {
230
  $languages_array = pll_languages_list(array('fields' => null));
231
+ } if(!empty($translate_press_settings['url-slugs'])) {
232
+ // $languages_array = $translate_press_settings['url-slugs'];
233
  }
234
 
235
  // Get native language names as value
253
  }
254
  }
255
 
 
256
  return (array) $active_languages;
257
  }
258
 
259
+ function fix_language_mismatch($item_id, $uri_parts, $is_term = false) {
260
  global $wp, $language_code;
261
 
262
  if($is_term) {
278
  // Stop if no term or post is detected
279
  if(empty($element)) { return false; }
280
 
281
+ $language_code = self::get_language_code($element);
282
 
283
  if(!empty($uri_parts['lang']) && ($uri_parts['lang'] != $language_code)) {
284
  $wpml_item_id = apply_filters('wpml_object_id', $element_id);
288
  return $item_id;
289
  }
290
 
291
+ function detect_uri_language($uri_parts, $request_url, $endpoints) {
292
+ global $sitepress, $sitepress_settings, $polylang, $translate_press_settings;
293
 
294
  if(!empty($sitepress_settings['active_languages'])) {
295
+ $languages_list = (array) $sitepress_settings['active_languages'];
296
  } elseif(function_exists('pll_languages_list')) {
297
  $languages_array = pll_languages_list();
298
+ $languages_list = (is_array($languages_array)) ? (array) $languages_array : "";
299
+ } elseif($translate_press_settings['url-slugs']) {
300
+ $languages_list = $translate_press_settings['url-slugs'];
301
+ }
302
+
303
+ if(is_array($languages_list)) {
304
+ $languages_list = implode("|", $languages_list);
305
+ } else {
306
+ return $uri_parts;
307
  }
308
 
309
  $default_language = self::get_default_language();
336
  return $uri_parts;
337
  }
338
 
339
+ function prepend_lang_prefix($base, $element) {
340
+ global $sitepress_settings, $polylang, $permalink_manager_uris, $translate_press_settings;
341
 
342
+ $language_code = self::get_language_code($element);
343
  $default_language_code = self::get_default_language();
344
  $home_url = get_home_url();
345
 
346
  // Hide language code if "Use directory for default language" option is enabled
347
+ $hide_prefix_for_default_lang = ((isset($sitepress_settings['urls']['directory_for_default_language']) && $sitepress_settings['urls']['directory_for_default_language'] != 1) || !empty($polylang->links_model->options['hide_default']) || !empty($translate_press_settings['add-subdirectory-to-default-language'])) ? true : false;
348
 
349
  // Last instance - use language paramater from &_GET array
350
  if(is_admin()) {
400
  return $base;
401
  }
402
 
403
+ function append_lang_prefix($permalink, $element) {
404
  global $sitepress_settings, $polylang, $permalink_manager_uris;
405
 
406
+ $language_code = self::get_language_code($element);
407
  $default_language_code = self::get_default_language();
408
 
409
  // Last instance - use language paramater from &_GET array
423
  return $permalink;
424
  }
425
 
426
+ function translate_permastructure($permastructure, $element) {
427
+ global $permalink_manager_permastructs, $pagenow;;
 
 
 
 
 
 
 
 
 
 
428
 
429
  // Get element language code
430
+ if(!empty($_REQUEST['data']) && strpos($_REQUEST['data'], "target_lang")) {
431
+ $language_code = preg_replace('/(.*target_lang=)([^=&]+)(.*)/', '$2', $_REQUEST['data']);
432
+ } else if($pagenow == 'post.php' && !empty($_GET['lang'])) {
433
+ $language_code = $_GET['lang'];
434
+ } else {
435
+ $language_code = self::get_language_code($element);
436
+ }
437
 
438
  if(!empty($element->ID)) {
439
  $translated_permastructure = (!empty($permalink_manager_permastructs["post_types"]["{$element->post_type}_{$language_code}"])) ? $permalink_manager_permastructs["post_types"]["{$element->post_type}_{$language_code}"] : '';
444
  return (!empty($translated_permastructure)) ? $translated_permastructure : $permastructure;
445
  }
446
 
 
 
 
 
447
 
448
+ function language_column_uri_editor($output, $column, $element) {
449
+ $language_code = self::get_language_code($element);
 
 
 
450
  $output .= (!empty($language_code)) ? sprintf(" | <span><strong>%s:</strong> %s</span>", __("Language"), $language_code) : "";
451
 
452
  return $output;
453
  }
454
 
455
+ function wpml_translate_post_type_slug($post_type_slug, $element, $post_type) {
456
+ $post = (is_integer($element)) ? get_post($element) : $element;
457
+ $language_code = self::get_language_code($post);
458
+
459
+ $post_type_slug = apply_filters('wpml_get_translated_slug', $post_type_slug, $post_type, $language_code);
460
+
461
+ // Translate %post_type% tag in custom permastructures
462
+ return $post_type_slug;
463
+ }
464
+
465
  function wpml_is_front_page($bool, $page_id, $front_page_id) {
466
  $default_language_code = self::get_default_language();
467
  $page_id = apply_filters('wpml_object_id', $page_id, 'page', true, $default_language_code);
515
  }
516
 
517
  /**
518
+ * 3. Parse Custom Permalinks import
519
  */
520
  public static function custom_permalinks_uris() {
521
  global $wpdb;
571
  }
572
 
573
  /**
574
+ * 4. WooCommerce
575
  */
576
  function woocommerce_detect($query) {
577
+ global $woocommerce, $wpai_query;
578
 
579
  $shop_page_id = get_option('woocommerce_shop_page_id');
580
 
582
  $shop_page_id = apply_filters('wpml_object_id', $shop_page_id, 'page', TRUE);
583
 
584
  // Fix shop page
585
+ if(!empty($wpai_query['id']) && is_numeric($wpai_query['id']) && $shop_page_id == $wpai_query['id']) {
586
  $query['post_type'] = 'product';
587
  unset($query['pagename']);
588
  }
604
  }
605
 
606
  function woocommerce_checkout_fix() {
607
+ global $wp_query, $wpai_query, $permalink_manager_options;
608
 
609
  // Redirect from Shop archive to selected page
610
+ if(is_shop() && empty($wpai_query['id'])) {
611
  $redirect_mode = (!empty($permalink_manager_options['general']['redirect'])) ? $permalink_manager_options['general']['redirect'] : false;
612
  $redirect_shop = apply_filters('permalink-manager-redirect-shop-archive', false);
613
  $shop_page = get_option('woocommerce_shop_page_id');
639
  }
640
 
641
  /**
642
+ * 5. Theme My Login
643
  */
644
  function tml_keep_query_parameters($permalink, $post, $old_permalink) {
645
  // Get the query string from old permalink
649
  }
650
 
651
  /**
652
+ * 6. Fix Yoast's homepage URL
653
  */
654
  function yoast_fix_sitemap_urls($permalink) {
655
  if(class_exists('WPSEO_Utils')) {
663
  }
664
 
665
  /**
666
+ * 7. Support WooCommerce Wishlist Plugin
667
  */
668
  function ti_woocommerce_wishlist_uris($uri_parts, $request_url, $endpoints) {
669
  global $permalink_manager_uris, $wp;
688
  }
689
 
690
  /**
691
+ * 8. Revisionize
692
  */
693
  function revisionize_keep_post_uri($old_id, $new_id) {
694
  global $permalink_manager_uris;
714
  }
715
 
716
  /**
717
+ * 9. WP All Import
718
  */
719
  function wpaiextra_uri_display($post_type, $current_values) {
720
 
827
  if($external_url && class_exists('Permalink_Manager_Pro_Functions')) {
828
  Permalink_Manager_Pro_Functions::save_external_redirect($external_url, $pid);
829
  }
830
+ }
831
 
832
+ function wpai_schedule_regenerate_uris_after_xml_import($import_id) {
833
+ global $wpdb;
 
834
 
835
+ $post_ids = $wpdb->get_col("SELECT post_id FROM {$wpdb->prefix}pmxi_posts WHERE import_id = {$import_id}");
836
+ $chunks = array_chunk($post_ids, 200);
837
+
838
+ // Schedule URI regenerate and split into bulks
839
+ foreach($chunks as $i => $chunk) {
840
+ wp_schedule_single_event(time() + ($i * 30), 'wpai_regenerate_uris_after_import_event', array($chunk));
841
+ }
842
+ }
843
+
844
+ function wpai_regenerate_uris_after_import($post_ids) {
845
+ global $permalink_manager_uris;
846
+
847
+ if(!is_array($post_ids)) { return; }
848
+
849
+ foreach($post_ids as $id) {
850
+ $permalink_manager_uris[$id] = Permalink_Manager_URI_Functions_Post::get_default_post_uri($id);
851
  }
852
+
853
+ update_option('permalink-manager-uris', $permalink_manager_uris);
854
  }
855
 
856
  }
includes/core/permalink-manager-uri-functions-post.php CHANGED
@@ -14,7 +14,7 @@ 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);
18
 
19
  // Support url_to_postid
20
  add_filter( 'url_to_postid', array($this, 'url_to_postid'), 99);
@@ -51,6 +51,9 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
51
  function custom_post_permalinks($permalink, $post) {
52
  global $wp_rewrite, $permalink_manager_uris, $permalink_manager_options;
53
 
 
 
 
54
  $post = (is_integer($post)) ? get_post($post) : $post;
55
 
56
  // Start with homepage URL
@@ -558,10 +561,8 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
558
  }
559
 
560
  // Filter array before saving & append the global
561
- $old_uris = $permalink_manager_uris = array_filter($old_uris);
562
- update_option('permalink-manager-uris', $old_uris);
563
-
564
- //print_r($permalink_manager_uris);
565
 
566
  $output = array('updated' => $updated_array, 'updated_count' => $updated_slugs_count);
567
  }
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);
51
  function custom_post_permalinks($permalink, $post) {
52
  global $wp_rewrite, $permalink_manager_uris, $permalink_manager_options;
53
 
54
+ // Do not filter permalinks in Customizer
55
+ if((function_exists('is_customize_preview') && is_customize_preview())) { return $permalink; }
56
+
57
  $post = (is_integer($post)) ? get_post($post) : $post;
58
 
59
  // Start with homepage URL
561
  }
562
 
563
  // Filter array before saving & append the global
564
+ $permalink_manager_uris = array_filter($old_uris);
565
+ update_option('permalink-manager-uris', $permalink_manager_uris);
 
 
566
 
567
  $output = array('updated' => $updated_array, 'updated_count' => $updated_slugs_count);
568
  }
includes/views/permalink-manager-debug.php CHANGED
@@ -6,7 +6,7 @@
6
  class Permalink_Manager_Debug extends Permalink_Manager_Class {
7
 
8
  public function __construct() {
9
- add_filter( 'permalink-manager-sections', array($this, 'add_debug_section'), 1 );
10
  }
11
 
12
  public function add_debug_section($admin_sections) {
@@ -21,7 +21,7 @@ class Permalink_Manager_Debug extends Permalink_Manager_Class {
21
  public function output() {
22
  global $permalink_manager_options, $permalink_manager_uris, $permalink_manager_permastructs, $permalink_manager_redirects, $wp_filter;
23
 
24
- $sections_and_fields = apply_filters('permalink-manager-debug-fields', array(
25
  'debug-data' => array(
26
  'section_name' => __('Debug data', 'permalink-manager'),
27
  'fields' => array(
6
  class Permalink_Manager_Debug extends Permalink_Manager_Class {
7
 
8
  public function __construct() {
9
+ add_filter( 'permalink_manager_sections', array($this, 'add_debug_section'), 4 );
10
  }
11
 
12
  public function add_debug_section($admin_sections) {
21
  public function output() {
22
  global $permalink_manager_options, $permalink_manager_uris, $permalink_manager_permastructs, $permalink_manager_redirects, $wp_filter;
23
 
24
+ $sections_and_fields = apply_filters('permalink_manager_debug_fields', array(
25
  'debug-data' => array(
26
  'section_name' => __('Debug data', 'permalink-manager'),
27
  'fields' => array(
includes/views/permalink-manager-permastructs.php CHANGED
@@ -6,7 +6,7 @@
6
  class Permalink_Manager_Permastructs extends Permalink_Manager_Class {
7
 
8
  public function __construct() {
9
- add_filter( 'permalink-manager-sections', array($this, 'add_admin_section'), 1 );
10
  }
11
 
12
  public function add_admin_section($admin_sections) {
@@ -25,19 +25,11 @@ class Permalink_Manager_Permastructs extends Permalink_Manager_Class {
25
  $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array('full');
26
  $woocommerce_icon = "<i class=\"woocommerce-icon woocommerce-cart\"></i>";
27
 
28
- // 1. Get notes
29
- $post_types_notes = wpautop(sprintf(__('All allowed <a href="%s" target="_blank">structure tags</a> are listed below.', 'permalink-manager'), "https://codex.wordpress.org/Using_Permalinks#Structure_Tags"));
30
- $post_types_notes .= Permalink_Manager_Helper_Functions::get_all_structure_tags();
31
- $post_types_notes .= wpautop(sprintf(__('Please note that some of them can be used only for particular post types permastructures.', 'permalink-manager'), "https://codex.wordpress.org/Using_Permalinks#Structure_Tags"));
32
- $post_types_notes .= __('<h5>Custom fields inside permastructures <small>(Permalink Manager Pro only)</small></h5>', 'permalink-manager');
33
- $post_types_notes .= wpautop(__('To use the custom fields inside the permalink, please use following tag <code>%__custom_field_key%</code> and replace "<em>custom_field_key</em>" with the full name of your custom field key.', 'permalink-manager'));
34
-
35
- // 2. Get fields
36
  $fields = array(
37
  'post_types' => array(
38
  'section_name' => __('Post types', 'permalink-manager'),
39
  'container' => 'row',
40
- 'append_content' => $post_types_notes,
41
  'fields' => array()
42
  ),
43
  'taxonomies' => array(
@@ -70,7 +62,7 @@ class Permalink_Manager_Permastructs extends Permalink_Manager_Class {
70
  );
71
  }
72
 
73
- return apply_filters('permalink-manager-permastructs-fields', $fields);
74
  }
75
 
76
  /**
@@ -79,9 +71,12 @@ class Permalink_Manager_Permastructs extends Permalink_Manager_Class {
79
  public function output() {
80
  global $permalink_manager_permastructs;
81
 
82
- $sidebar = '<h3>' . __('Important notices', 'permalink-manager') . '</h3>';
83
- $sidebar .= wpautop(__('This tool <strong>automatically appends the slug to the end of permastructure</strong>, so there is no need to use them within the fields. To prevent the overlapping URLs problem please keep the permastructures unique.', 'permalink-manager'));
84
- $sidebar .= sprintf(wpautop(__('The current permastructures settings will be applied <strong>only to the new posts & terms</strong>. To apply the <strong>new permastructures to old posts & terms</strong>, please use "Regenerate/reset" tool available <a href="%s">here</a>.', 'permalink-manager')), admin_url('tools.php?page=permalink-manager&section=tools&subsection=regenerate_slugs'));
 
 
 
85
 
86
  return Permalink_Manager_Admin_Functions::get_the_form(self::get_fields(), '', array('text' => __( 'Save permastructures', 'permalink-manager' ), 'class' => 'primary margin-top'), $sidebar, array('action' => 'permalink-manager', 'name' => 'permalink_manager_permastructs'));
87
  }
6
  class Permalink_Manager_Permastructs extends Permalink_Manager_Class {
7
 
8
  public function __construct() {
9
+ add_filter( 'permalink_manager_sections', array($this, 'add_admin_section'), 2 );
10
  }
11
 
12
  public function add_admin_section($admin_sections) {
25
  $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array('full');
26
  $woocommerce_icon = "<i class=\"woocommerce-icon woocommerce-cart\"></i>";
27
 
28
+ // 1. Get fields
 
 
 
 
 
 
 
29
  $fields = array(
30
  'post_types' => array(
31
  'section_name' => __('Post types', 'permalink-manager'),
32
  'container' => 'row',
 
33
  'fields' => array()
34
  ),
35
  'taxonomies' => array(
62
  );
63
  }
64
 
65
+ return apply_filters('permalink_manager_permastructs_fields', $fields);
66
  }
67
 
68
  /**
71
  public function output() {
72
  global $permalink_manager_permastructs;
73
 
74
+ $sidebar = sprintf('<h3>%s</h3>', __('Instructions', 'permalink-manager'));
75
+ $sidebar .= sprintf(wpautop(__('The current permastructures settings will be applied <strong>only to the new posts & terms</strong>. To apply the <strong>new permastructures to existing posts and terms</strong>, please regenerate the custom permalinks <a href="%s">here</a>.', 'permalink-manager')), admin_url('tools.php?page=permalink-manager&section=tools&subsection=regenerate_slugs'));
76
+
77
+ $sidebar .= sprintf('<h4>%s</h4>', __('Permastructure tags', 'permalink-manager'));
78
+ $sidebar .= wpautop(sprintf(__('All allowed <a href="%s" target="_blank">permastructure tags</a> are listed below. Please note that some of them can be used only for particular post types or taxonomies.', 'permalink-manager'), "https://codex.wordpress.org/Using_Permalinks#Structure_Tags"));
79
+ $sidebar .= Permalink_Manager_Helper_Functions::get_all_structure_tags();
80
 
81
  return Permalink_Manager_Admin_Functions::get_the_form(self::get_fields(), '', array('text' => __( 'Save permastructures', 'permalink-manager' ), 'class' => 'primary margin-top'), $sidebar, array('action' => 'permalink-manager', 'name' => 'permalink_manager_permastructs'));
82
  }
includes/views/permalink-manager-settings.php CHANGED
@@ -6,7 +6,7 @@
6
  class Permalink_Manager_Settings extends Permalink_Manager_Class {
7
 
8
  public function __construct() {
9
- add_filter( 'permalink-manager-sections', array($this, 'add_admin_section'), 1 );
10
  }
11
 
12
  public function add_admin_section($admin_sections) {
@@ -28,7 +28,7 @@ class Permalink_Manager_Settings extends Permalink_Manager_Class {
28
  $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array(false, false, false, true);
29
  $content_types = (defined('PERMALINK_MANAGER_PRO')) ? array('post_types' => $all_post_types, 'taxonomies' => $all_taxonomies) : array('post_types' => $all_post_types);
30
 
31
- $sections_and_fields = apply_filters('permalink-manager-settings-fields', array(
32
  'general' => array(
33
  'section_name' => __('General settings', 'permalink-manager'),
34
  'container' => 'row',
@@ -114,11 +114,18 @@ class Permalink_Manager_Settings extends Permalink_Manager_Class {
114
  ),
115
  'force_custom_slugs' => array(
116
  'type' => 'select',
117
- 'label' => __('Force custom slugs', 'permalink-manager'),
118
  'input_class' => 'settings-select',
119
- 'choices' => array(0 => __('No, use native slugs', 'permalink-manager'), 1 => __('Yes, use post/term titles', 'permalink-manager'), 2 => __('Yes, use post/term titles + do not strip special characters: .|-+', 'permalink-manager')),
120
  'description' => __('If enabled, the slugs in the default custom permalinks will be recreated from the post titles.<br />This may cause permalinks duplicates when the post or term title is used more than once.', 'permalink-manager')
121
  ),
 
 
 
 
 
 
 
122
  'partial_disable' => array(
123
  'type' => 'checkbox',
124
  'label' => __('Disable Permalink Manager functionalities', 'permalink-manager'),
6
  class Permalink_Manager_Settings extends Permalink_Manager_Class {
7
 
8
  public function __construct() {
9
+ add_filter( 'permalink_manager_sections', array($this, 'add_admin_section'), 3 );
10
  }
11
 
12
  public function add_admin_section($admin_sections) {
28
  $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array(false, false, false, true);
29
  $content_types = (defined('PERMALINK_MANAGER_PRO')) ? array('post_types' => $all_post_types, 'taxonomies' => $all_taxonomies) : array('post_types' => $all_post_types);
30
 
31
+ $sections_and_fields = apply_filters('permalink_manager_settings_fields', array(
32
  'general' => array(
33
  'section_name' => __('General settings', 'permalink-manager'),
34
  'container' => 'row',
114
  ),
115
  'force_custom_slugs' => array(
116
  'type' => 'select',
117
+ 'label' => __('Use actual post/term titles (Force custom slugs)', 'permalink-manager'),
118
  'input_class' => 'settings-select',
119
+ 'choices' => array(0 => __('No, use native slugs', 'permalink-manager'), 1 => __('Yes, use post/term titles', 'permalink-manager')),
120
  'description' => __('If enabled, the slugs in the default custom permalinks will be recreated from the post titles.<br />This may cause permalinks duplicates when the post or term title is used more than once.', 'permalink-manager')
121
  ),
122
+ 'disable_slug_sanitization' => array(
123
+ 'type' => 'select',
124
+ 'label' => __('Strip special characters from slugs', 'permalink-manager'),
125
+ 'input_class' => 'settings-select',
126
+ 'choices' => array(0 => __('Yes, use native settings', 'permalink-manager'), 1 => __('No, keep special characters (.|_+) in the slugs', 'permalink-manager')),
127
+ 'description' => __('If enabled only alphanumeric characters, underscores and dashes will be allowed for post/term slugs.', 'permalink-manager')
128
+ ),
129
  'partial_disable' => array(
130
  'type' => 'checkbox',
131
  'label' => __('Disable Permalink Manager functionalities', 'permalink-manager'),
includes/views/permalink-manager-tools.php CHANGED
@@ -6,7 +6,7 @@
6
  class Permalink_Manager_Tools extends Permalink_Manager_Class {
7
 
8
  public function __construct() {
9
- add_filter( 'permalink-manager-sections', array($this, 'add_admin_section'), 1 );
10
  }
11
 
12
  public function add_admin_section($admin_sections) {
@@ -129,7 +129,7 @@ class Permalink_Manager_Tools extends Permalink_Manager_Class {
129
  $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array();
130
  $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array();
131
 
132
- $fields = apply_filters('permalink-manager-tools-fields', array(
133
  'old_string' => array(
134
  'label' => __( 'Find ...', 'permalink-manager' ),
135
  'type' => 'text',
@@ -146,7 +146,10 @@ class Permalink_Manager_Tools extends Permalink_Manager_Class {
146
  'label' => __( 'Mode', 'permalink-manager' ),
147
  'type' => 'select',
148
  'container' => 'row',
149
- 'choices' => array('custom_uris' => __('Custom URIs', 'permalink-manager'), 'slugs' => __('Native slugs', 'permalink-manager')),
 
 
 
150
  ),
151
  'content_type' => array(
152
  'label' => __( 'Select content type', 'permalink-manager' ),
@@ -155,7 +158,10 @@ class Permalink_Manager_Tools extends Permalink_Manager_Class {
155
  'pro' => true,
156
  'container' => 'row',
157
  'default' => 'post_types',
158
- 'choices' => array('post_types' => __('Post types', 'permalink-manager'), 'taxonomies' => __('Taxonomies', 'permalink-manager')),
 
 
 
159
  ),
160
  'post_types' => array(
161
  'label' => __( 'Select post types', 'permalink-manager' ),
@@ -211,12 +217,16 @@ class Permalink_Manager_Tools extends Permalink_Manager_Class {
211
  $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array();
212
  $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array();
213
 
214
- $fields = apply_filters('permalink-manager-tools-fields', array(
215
  'mode' => array(
216
  'label' => __( 'Mode', 'permalink-manager' ),
217
  'type' => 'select',
218
  'container' => 'row',
219
- 'choices' => array('custom_uris' => __('Custom URIs', 'permalink-manager'), 'slugs' => __('Restore native slugs', 'permalink-manager'), 'native' => __('Restore native permalinks', 'permalink-manager')),
 
 
 
 
220
  ),
221
  'content_type' => array(
222
  'label' => __( 'Select content type', 'permalink-manager' ),
@@ -225,7 +235,10 @@ class Permalink_Manager_Tools extends Permalink_Manager_Class {
225
  'pro' => true,
226
  'container' => 'row',
227
  'default' => 'post_types',
228
- 'choices' => array('post_types' => __('Post types', 'permalink-manager'), 'taxonomies' => __('Taxonomies', 'permalink-manager')),
 
 
 
229
  ),
230
  'post_types' => array(
231
  'label' => __( 'Select post types', 'permalink-manager' ),
6
  class Permalink_Manager_Tools extends Permalink_Manager_Class {
7
 
8
  public function __construct() {
9
+ add_filter( 'permalink_manager_sections', array($this, 'add_admin_section'), 1 );
10
  }
11
 
12
  public function add_admin_section($admin_sections) {
129
  $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array();
130
  $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array();
131
 
132
+ $fields = apply_filters('permalink_manager_tools_fields', array(
133
  'old_string' => array(
134
  'label' => __( 'Find ...', 'permalink-manager' ),
135
  'type' => 'text',
146
  'label' => __( 'Mode', 'permalink-manager' ),
147
  'type' => 'select',
148
  'container' => 'row',
149
+ 'choices' => array(
150
+ 'custom_uris' => __('Custom URIs', 'permalink-manager'),
151
+ 'slugs' => __('Native slugs', 'permalink-manager')
152
+ ),
153
  ),
154
  'content_type' => array(
155
  'label' => __( 'Select content type', 'permalink-manager' ),
158
  'pro' => true,
159
  'container' => 'row',
160
  'default' => 'post_types',
161
+ 'choices' => array(
162
+ 'post_types' => __('Post types', 'permalink-manager'),
163
+ 'taxonomies' => __('Taxonomies', 'permalink-manager')
164
+ ),
165
  ),
166
  'post_types' => array(
167
  'label' => __( 'Select post types', 'permalink-manager' ),
217
  $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array();
218
  $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array();
219
 
220
+ $fields = apply_filters('permalink_manager_tools_fields', array(
221
  'mode' => array(
222
  'label' => __( 'Mode', 'permalink-manager' ),
223
  'type' => 'select',
224
  'container' => 'row',
225
+ 'choices' => array(
226
+ 'custom_uris' => __('Regenerate custom permalinks', 'permalink-manager'),
227
+ 'slugs' => __('Regenerate native slugs', 'permalink-manager'),
228
+ 'native' => __('Use original URLs as custom permalinks', 'permalink-manager')
229
+ ),
230
  ),
231
  'content_type' => array(
232
  'label' => __( 'Select content type', 'permalink-manager' ),
235
  'pro' => true,
236
  'container' => 'row',
237
  'default' => 'post_types',
238
+ 'choices' => array(
239
+ 'post_types' => __('Post types', 'permalink-manager'),
240
+ 'taxonomies' => __('Taxonomies', 'permalink-manager')
241
+ ),
242
  ),
243
  'post_types' => array(
244
  'label' => __( 'Select post types', 'permalink-manager' ),
includes/views/permalink-manager-upgrade.php CHANGED
@@ -7,7 +7,7 @@ class Permalink_Manager_Upgrade extends Permalink_Manager_Class {
7
 
8
  public function __construct() {
9
  if(!defined('PERMALINK_MANAGER_PRO')) {
10
- add_filter( 'permalink-manager-sections', array($this, 'add_upgrade_section'), 1 );
11
  }
12
  }
13
 
7
 
8
  public function __construct() {
9
  if(!defined('PERMALINK_MANAGER_PRO')) {
10
+ add_filter( 'permalink_manager_sections', array($this, 'add_upgrade_section'), 1 );
11
  }
12
  }
13
 
includes/views/permalink-manager-uri-editor-post.php CHANGED
@@ -51,7 +51,7 @@ class Permalink_Manager_URI_Editor_Post extends WP_List_Table {
51
  * Override the parent columns method. Defines the columns to use in your listing table
52
  */
53
  public function get_columns() {
54
- return apply_filters('permalink-manager-uri-editor-columns', array(
55
  'item_title' => __('Post title', 'permalink-manager'),
56
  'item_uri' => __('Full URI & Permalink', 'permalink-manager')
57
  ));
@@ -88,7 +88,7 @@ class Permalink_Manager_URI_Editor_Post extends WP_List_Table {
88
  $post_statuses_array = get_post_statuses();
89
  $post_statuses_array['inherit'] = __('Inherit (Attachment)', 'permalink-manager');
90
 
91
- $output = apply_filters('permalink-manager-uri-editor-column-content', '', $column_name, get_post($item['ID']));
92
  if(!empty($output)) { return $output; }
93
 
94
  switch( $column_name ) {
@@ -105,7 +105,7 @@ class Permalink_Manager_URI_Editor_Post extends WP_List_Table {
105
  $output .= '<div class="extra-info small">';
106
  $output .= sprintf("<span><strong>%s:</strong> %s</span>", __("Slug", "permalink-manager"), urldecode($item['post_name']));
107
  $output .= sprintf(" | <span><strong>%s:</strong> {$post_statuses_array[$item["post_status"]]}</span>", __("Post status", "permalink-manager"));
108
- $output .= apply_filters('permalink-manager-uri-editor-extra-info', '', $column_name, get_post($item['ID']));
109
  $output .= '</div>';
110
 
111
  $output .= '<div class="row-actions">';
51
  * Override the parent columns method. Defines the columns to use in your listing table
52
  */
53
  public function get_columns() {
54
+ return apply_filters('permalink_manager_uri_editor_columns', array(
55
  'item_title' => __('Post title', 'permalink-manager'),
56
  'item_uri' => __('Full URI & Permalink', 'permalink-manager')
57
  ));
88
  $post_statuses_array = get_post_statuses();
89
  $post_statuses_array['inherit'] = __('Inherit (Attachment)', 'permalink-manager');
90
 
91
+ $output = apply_filters('permalink_manager_uri_editor_column_content', '', $column_name, get_post($item['ID']));
92
  if(!empty($output)) { return $output; }
93
 
94
  switch( $column_name ) {
105
  $output .= '<div class="extra-info small">';
106
  $output .= sprintf("<span><strong>%s:</strong> %s</span>", __("Slug", "permalink-manager"), urldecode($item['post_name']));
107
  $output .= sprintf(" | <span><strong>%s:</strong> {$post_statuses_array[$item["post_status"]]}</span>", __("Post status", "permalink-manager"));
108
+ $output .= apply_filters('permalink_manager_uri_editor_extra_info', '', $column_name, get_post($item['ID']));
109
  $output .= '</div>';
110
 
111
  $output .= '<div class="row-actions">';
includes/views/permalink-manager-uri-editor.php CHANGED
@@ -7,7 +7,7 @@ class Permalink_Manager_Uri_Editor extends Permalink_Manager_Class {
7
  public $this_section = 'uri_editor';
8
 
9
  public function __construct() {
10
- add_filter( 'permalink-manager-sections', array($this, 'add_admin_section'), 1 );
11
  add_filter( 'screen_settings', array($this, 'screen_options'), 99, 2 );
12
  }
13
 
7
  public $this_section = 'uri_editor';
8
 
9
  public function __construct() {
10
+ add_filter( 'permalink_manager_sections', array($this, 'add_admin_section'), 0 );
11
  add_filter( 'screen_settings', array($this, 'screen_options'), 99, 2 );
12
  }
13
 
out/permalink-manager-admin.css CHANGED
@@ -46,11 +46,11 @@
46
  #permalink-manager .warning{background:#dc3232}
47
  #permalink-manager .warning,#permalink-manager .warning a{color:#fff}
48
  #permalink-manager .info{background:#f9f9f9}
49
- #permalink-manager .section-notes,#permalink-manager .short-pre,#permalink-manager .short-textarea{padding:15px;font-size:13px;margin-top:15px;line-height:20px;background:#e5e5e5;border:1px solid #ccc;color:#555}
50
  #permalink-manager .section-notes a,#permalink-manager .section-notes h3{color:#111}
51
- #permalink-manager .section-notes h3,#permalink-manager .section-notes h4{margin-top:0}
52
  #permalink-manager .section-notes h4{font-size:14px}
53
- #permalink-manager .section-notes code{font-size:11px;background:#444;color:#fff}
54
  #permalink-manager .section-notes ol{margin-top:0;margin-bottom:0}
55
  #permalink-manager .section-notes ol li:last-of-type{margin-bottom:0}
56
  #permalink-manager .short-pre,#permalink-manager .short-textarea{height:150px;overflow:auto;max-width:100%;display:block}
46
  #permalink-manager .warning{background:#dc3232}
47
  #permalink-manager .warning,#permalink-manager .warning a{color:#fff}
48
  #permalink-manager .info{background:#f9f9f9}
49
+ /*#permalink-manager .section-notes,#permalink-manager .short-pre,#permalink-manager .short-textarea{padding:15px;font-size:13px;margin-top:15px;line-height:20px;background:#e5e5e5;border:1px solid #ccc;color:#555}
50
  #permalink-manager .section-notes a,#permalink-manager .section-notes h3{color:#111}
51
+ #permalink-manager .section-notes h3,#permalink-manager .section-notes h4{margin-top:0}*/
52
  #permalink-manager .section-notes h4{font-size:14px}
53
+ #permalink-manager .section-notes code{font-size:11px}
54
  #permalink-manager .section-notes ol{margin-top:0;margin-bottom:0}
55
  #permalink-manager .section-notes ol li:last-of-type{margin-bottom:0}
56
  #permalink-manager .short-pre,#permalink-manager .short-textarea{height:150px;overflow:auto;max-width:100%;display:block}
permalink-manager.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
 
3
  /**
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.2.4
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.1.2.4' );
25
  define( 'PERMALINK_MANAGER_FILE', __FILE__ );
26
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit(dirname(__FILE__)) );
27
  define( 'PERMALINK_MANAGER_BASENAME', dirname(plugin_basename(__FILE__)));
@@ -31,7 +31,7 @@ define( 'PERMALINK_MANAGER_DONATE', 'https://www.paypal.me/Bismit' );
31
 
32
  class Permalink_Manager_Class {
33
 
34
- public $permalink_manager, $permalink_manager_options_page, $permalink_manager_options;
35
  public $sections, $functions, $permalink_manager_before_sections_html, $permalink_manager_after_sections_html;
36
 
37
  /**
@@ -71,6 +71,7 @@ class Permalink_Manager_Class {
71
  'debug' => 'Permalink_Manager_Debug',
72
  'pro-addons' => 'Permalink_Manager_Pro_Addons',
73
  'upgrade' => 'Permalink_Manager_Upgrade',
 
74
  'uri-editor-tax' => false,
75
  'uri-editor-post' => false
76
  )
@@ -96,6 +97,9 @@ class Permalink_Manager_Class {
96
  // Localize plugin
97
  add_action( 'init', array($this, 'localize_me'), 1 );
98
 
 
 
 
99
  // Load globals & options
100
  add_action( 'plugins_loaded', array($this, 'get_options_and_globals'), 9 );
101
 
@@ -103,8 +107,8 @@ class Permalink_Manager_Class {
103
  add_action( 'init', array($this, 'legacy_support'), 2 );
104
 
105
  // Default settings & alerts
106
- add_filter( 'permalink-manager-options', array($this, 'default_settings'), 1 );
107
- add_filter( 'permalink-manager-alerts', array($this, 'default_alerts'), 1 );
108
  }
109
 
110
  /**
@@ -121,18 +125,18 @@ class Permalink_Manager_Class {
121
  // 1. Globals with data stored in DB
122
  global $permalink_manager_options, $permalink_manager_uris, $permalink_manager_permastructs, $permalink_manager_redirects, $permalink_manager_external_redirects;
123
 
124
- $this->permalink_manager_options = $permalink_manager_options = apply_filters('permalink-manager-options', get_option('permalink-manager', array()));
125
- $this->permalink_manager_uris = $permalink_manager_uris = apply_filters('permalink-manager-uris', get_option('permalink-manager-uris', array()));
126
- $this->permalink_manager_permastructs = $permalink_manager_permastructs = apply_filters('permalink-manager-permastructs', get_option('permalink-manager-permastructs', array()));
127
- $this->permalink_manager_redirects = $permalink_manager_redirects = apply_filters('permalink-manager-redirects', get_option('permalink-manager-redirects', array()));
128
- $this->permalink_manager_external_redirects = $permalink_manager_external_redirects = apply_filters('permalink-manager-external-redirects', get_option('permalink-manager-external-redirects', array()));
129
 
130
  // 2. Globals used to display additional content (eg. alerts)
131
  global $permalink_manager_alerts, $permalink_manager_before_sections_html, $permalink_manager_after_sections_html;
132
 
133
- $this->permalink_manager_alerts = $permalink_manager_alerts = apply_filters('permalink-manager-alerts', get_option('permalink-manager-alerts', array()));
134
- $this->permalink_manager_before_sections_html = $permalink_manager_before_sections_html = apply_filters('permalink-manager-before-sections', '');
135
- $this->permalink_manager_after_sections_html = $permalink_manager_after_sections_html = apply_filters('permalink-manager-after-sections', '');
136
  }
137
 
138
  /**
@@ -150,6 +154,7 @@ class Permalink_Manager_Class {
150
  ),
151
  'general' => array(
152
  'force_custom_slugs' => 0,
 
153
  'show_native_slug_field' => 0,
154
  'auto_update_uris' => 0,
155
  'setup_redirects' => 1,
@@ -181,7 +186,7 @@ class Permalink_Manager_Class {
181
  * Set the initial/default admin notices
182
  */
183
  public function default_alerts($alerts) {
184
- $default_alerts = apply_filters('permalink-manager-default-alerts', array(
185
  'spring' => array(
186
  'txt' => sprintf(
187
  __("Get access to extra features: full taxonomy and WooCommerce support, possibility to use custom fields inside the permalinks and more!<br /><strong>Buy Permalink Manager Pro <a href=\"%s\" target=\"_blank\">here</a> and save %s using \"%s\" coupon code!</strong> Valid until %s!", "permalink-manager"),
@@ -202,8 +207,8 @@ class Permalink_Manager_Class {
202
  }
203
 
204
  /**
205
- * Temporary hook
206
- */
207
  function legacy_support() {
208
  global $permalink_manager_permastructs, $permalink_manager_options;
209
 
@@ -211,16 +216,13 @@ class Permalink_Manager_Class {
211
  $new_options['post_types'] = $permalink_manager_options['base-editor'];
212
  update_option('permalink-manager-permastructs', $new_options);
213
  }
214
- else if(empty($permalink_manager_permastructs['post_types']) && count($permalink_manager_permastructs) > 0) {
215
  $new_options['post_types'] = $permalink_manager_permastructs;
216
  update_option('permalink-manager-permastructs', $new_options);
217
  }
218
 
219
  // Adjust options structure
220
  if(!empty($permalink_manager_options['miscellaneous'])) {
221
- // Get the options direclty from database
222
- $permalink_manager_unfiltered_options = get_option('permalink-manager', array('general' => array(), 'miscellaneous' => array(), 'licence'));
223
-
224
  // Combine general & general
225
  $permalink_manager_unfiltered_options['general'] = array_merge($permalink_manager_unfiltered_options['general'], $permalink_manager_unfiltered_options['miscellaneous']);
226
 
@@ -232,18 +234,97 @@ class Permalink_Manager_Class {
232
  unset($permalink_manager_unfiltered_options['miscellaneous']);
233
  unset($permalink_manager_unfiltered_options['permalink_manager_options']);
234
  unset($permalink_manager_unfiltered_options['_wp_http_referer']);
 
 
 
 
 
235
 
236
- // Save the settings in database
 
 
 
 
 
237
  update_option('permalink-manager', $permalink_manager_unfiltered_options);
238
  }
239
  }
240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  }
242
 
243
  /**
244
  * Begins execution of the plugin.
245
  */
246
  function run_permalink_manager() {
247
- $Permalink_Manager_Class = new Permalink_Manager_Class();
 
 
248
  }
249
  run_permalink_manager();
1
  <?php
2
 
3
  /**
4
+ * Plugin Name: Permalink Manager Pro
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.2.1.2
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.2.1.2' );
25
  define( 'PERMALINK_MANAGER_FILE', __FILE__ );
26
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit(dirname(__FILE__)) );
27
  define( 'PERMALINK_MANAGER_BASENAME', dirname(plugin_basename(__FILE__)));
31
 
32
  class Permalink_Manager_Class {
33
 
34
+ public $permalink_manager_options_page, $permalink_manager_options;
35
  public $sections, $functions, $permalink_manager_before_sections_html, $permalink_manager_after_sections_html;
36
 
37
  /**
71
  'debug' => 'Permalink_Manager_Debug',
72
  'pro-addons' => 'Permalink_Manager_Pro_Addons',
73
  'upgrade' => 'Permalink_Manager_Upgrade',
74
+ 'help' => 'Permalink_Manager_Help',
75
  'uri-editor-tax' => false,
76
  'uri-editor-post' => false
77
  )
97
  // Localize plugin
98
  add_action( 'init', array($this, 'localize_me'), 1 );
99
 
100
+ // Support deprecated hooks
101
+ add_action( 'plugins_loaded', array($this, 'deprecated_hooks'), 9 );
102
+
103
  // Load globals & options
104
  add_action( 'plugins_loaded', array($this, 'get_options_and_globals'), 9 );
105
 
107
  add_action( 'init', array($this, 'legacy_support'), 2 );
108
 
109
  // Default settings & alerts
110
+ add_filter( 'permalink_manager_options', array($this, 'default_settings'), 1 );
111
+ add_filter( 'permalink_manager_alerts', array($this, 'default_alerts'), 1 );
112
  }
113
 
114
  /**
125
  // 1. Globals with data stored in DB
126
  global $permalink_manager_options, $permalink_manager_uris, $permalink_manager_permastructs, $permalink_manager_redirects, $permalink_manager_external_redirects;
127
 
128
+ $this->permalink_manager_options = $permalink_manager_options = apply_filters('permalink_manager_options', get_option('permalink-manager', array()));
129
+ $this->permalink_manager_uris = $permalink_manager_uris = apply_filters('permalink_manager_uris', get_option('permalink-manager-uris', array()));
130
+ $this->permalink_manager_permastructs = $permalink_manager_permastructs = apply_filters('permalink_manager_permastructs', get_option('permalink-manager-permastructs', array()));
131
+ $this->permalink_manager_redirects = $permalink_manager_redirects = apply_filters('permalink_manager_redirects', get_option('permalink-manager-redirects', array()));
132
+ $this->permalink_manager_external_redirects = $permalink_manager_external_redirects = apply_filters('permalink_manager_external_redirects', get_option('permalink-manager-external-redirects', array()));
133
 
134
  // 2. Globals used to display additional content (eg. alerts)
135
  global $permalink_manager_alerts, $permalink_manager_before_sections_html, $permalink_manager_after_sections_html;
136
 
137
+ $this->permalink_manager_alerts = $permalink_manager_alerts = apply_filters('permalink_manager_alerts', get_option('permalink-manager-alerts', array()));
138
+ $this->permalink_manager_before_sections_html = $permalink_manager_before_sections_html = apply_filters('permalink_manager_before_sections', '');
139
+ $this->permalink_manager_after_sections_html = $permalink_manager_after_sections_html = apply_filters('permalink_manager_after_sections', '');
140
  }
141
 
142
  /**
154
  ),
155
  'general' => array(
156
  'force_custom_slugs' => 0,
157
+ 'disable_slug_sanitization' => 0,
158
  'show_native_slug_field' => 0,
159
  'auto_update_uris' => 0,
160
  'setup_redirects' => 1,
186
  * Set the initial/default admin notices
187
  */
188
  public function default_alerts($alerts) {
189
+ $default_alerts = apply_filters('permalink_manager_default_alerts', array(
190
  'spring' => array(
191
  'txt' => sprintf(
192
  __("Get access to extra features: full taxonomy and WooCommerce support, possibility to use custom fields inside the permalinks and more!<br /><strong>Buy Permalink Manager Pro <a href=\"%s\" target=\"_blank\">here</a> and save %s using \"%s\" coupon code!</strong> Valid until %s!", "permalink-manager"),
207
  }
208
 
209
  /**
210
+ * Temporary hook
211
+ */
212
  function legacy_support() {
213
  global $permalink_manager_permastructs, $permalink_manager_options;
214
 
216
  $new_options['post_types'] = $permalink_manager_options['base-editor'];
217
  update_option('permalink-manager-permastructs', $new_options);
218
  }
219
+ else if(empty($permalink_manager_permastructs['post_types']) && empty($permalink_manager_permastructs['taxonomies']) && count($permalink_manager_permastructs) > 0) {
220
  $new_options['post_types'] = $permalink_manager_permastructs;
221
  update_option('permalink-manager-permastructs', $new_options);
222
  }
223
 
224
  // Adjust options structure
225
  if(!empty($permalink_manager_options['miscellaneous'])) {
 
 
 
226
  // Combine general & general
227
  $permalink_manager_unfiltered_options['general'] = array_merge($permalink_manager_unfiltered_options['general'], $permalink_manager_unfiltered_options['miscellaneous']);
228
 
234
  unset($permalink_manager_unfiltered_options['miscellaneous']);
235
  unset($permalink_manager_unfiltered_options['permalink_manager_options']);
236
  unset($permalink_manager_unfiltered_options['_wp_http_referer']);
237
+ }
238
+
239
+ // Adjust "Force Custom Slugs" + "Sanitize" settings
240
+ if(!empty($permalink_manager_options['general']['force_custom_slugs']) && $permalink_manager_options['general']['force_custom_slugs'] == 2) {
241
+ $permalink_manager_unfiltered_options = $permalink_manager_options;
242
 
243
+ $permalink_manager_unfiltered_options['general']['force_custom_slugs'] = 1;
244
+ $permalink_manager_unfiltered_options['general']['disable_slug_sanitization'] = 1;
245
+ }
246
+
247
+ // Save the settings in database
248
+ if(!empty($permalink_manager_unfiltered_options)) {
249
  update_option('permalink-manager', $permalink_manager_unfiltered_options);
250
  }
251
  }
252
 
253
+ /**
254
+ * Support deprecated hooks
255
+ */
256
+ function deprecated_hooks_list($filters = true) {
257
+ $deprecated_filters = array(
258
+ 'permalink_manager_options' => 'permalink-manager-options',
259
+ 'permalink_manager_uris' => 'permalink-manager-uris',
260
+ 'permalink_manager_alerts' => 'permalink-manager-alerts',
261
+ 'permalink_manager_redirects' => 'permalink-manager-redirects',
262
+ 'permalink_manager_external_redirects' => 'permalink-manager-external-redirects',
263
+ 'permalink_manager_permastructs' => 'permalink-manager-permastructs',
264
+
265
+ 'permalink_manager_alerts' => 'permalink-manager-alerts',
266
+ 'permalink_manager_before_sections' => 'permalink-manager-before-sections',
267
+ 'permalink_manager_sections' => 'permalink-manager-sections',
268
+ 'permalink_manager_after_sections' => 'permalink-manager-after-sections',
269
+
270
+ 'permalink_manager_field_args' => 'permalink-manager-field-args',
271
+ 'permalink_manager_field_output' => 'permalink-manager-field-output',
272
+
273
+ 'permalink_manager_deep_uri_detect' => 'permalink-manager-deep-uri-detect',
274
+ 'permalink_manager_detect_uri' => 'permalink-manager-detect-uri',
275
+ 'permalink_manager_detected_element_id' => 'permalink-manager-detected-initial-id',
276
+ 'permalink_manager_detected_term_id' => 'permalink-manager-detected-term-id',
277
+ 'permalink_manager_detected_post_id' => 'permalink-manager-detected-post-id',
278
+
279
+ 'permalink_manager_primary_term' => 'permalink-manager-primary-term',
280
+ 'permalink_manager_disabled_post_types' => 'permalink-manager-disabled-post-types',
281
+ 'permalink_manager_disabled_taxonomies' => 'permalink-manager-disabled-taxonomies',
282
+ 'permalink_manager_endpoints' => 'permalink-manager-endpoints',
283
+ 'permalink_manager_filter_permalink_base' => 'permalink_manager-filter-permalink-base',
284
+ 'permalink_manager_force_lowercase_uris' => 'permalink-manager-force-lowercase-uris',
285
+
286
+ 'permalink_manager_uri_editor_extra_info' => 'permalink-manager-uri-editor-extra-info',
287
+ 'permalink_manager_debug_fields' => 'permalink-manager-debug-fields',
288
+ 'permalink_manager_permastructs_fields' => 'permalink-manager-permastructs-fields',
289
+ 'permalink_manager_settings_fields' => 'permalink-manager-settings-fields',
290
+ 'permalink_manager_tools_fields' => 'permalink-manager-tools-fields',
291
+
292
+ 'permalink_manager_uri_editor_columns' => 'permalink-manager-uri-editor-columns',
293
+ 'permalink_manager_uri_editor_column_content' => 'permalink-manager-uri-editor-column-content',
294
+ );
295
+
296
+ return ($filters) ? $deprecated_filters : array();
297
+ }
298
+
299
+ function deprecated_hooks() {
300
+ $deprecated_filters = (array) $this->deprecated_hooks_list(true);
301
+ foreach($deprecated_filters as $new => $old) {
302
+ add_filter($new, array($this, 'deprecated_hooks_mapping'), -1000, 8);
303
+ }
304
+ }
305
+
306
+ function deprecated_hooks_mapping($data) {
307
+ $deprecated_filters = $this->deprecated_hooks_list(true);
308
+ $filter = current_filter();
309
+
310
+ if(isset($deprecated_filters[$filter])) {
311
+ if(has_filter($deprecated_filters[$filter])) {
312
+ $args = func_get_args();
313
+ $data = apply_filters_ref_array($deprecated_filters[$filter], $args);
314
+ }
315
+ }
316
+
317
+ return $data;
318
+ }
319
+
320
  }
321
 
322
  /**
323
  * Begins execution of the plugin.
324
  */
325
  function run_permalink_manager() {
326
+ global $permalink_manager;
327
+
328
+ $permalink_manager = new Permalink_Manager_Class();
329
  }
330
  run_permalink_manager();