Permalink Manager Lite - Version 1.11.6.3

Version Description

Download this release

Release Info

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

Code changes from version 1.1.2 to 1.11.6.3

README.txt CHANGED
@@ -6,7 +6,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
6
  Tags: urls, permalinks, slugs, custom url, custom permalinks, uris, url, slug, permalink
7
  Requires at least: 4.0
8
  Tested up to: 4.8
9
- Stable tag: 1.1.2
10
 
11
  Most advanced yet easy-to-use permalink plugin that helps to maintain & bulk change your URLs & slugs.
12
 
@@ -95,20 +95,39 @@ A. Currently there is no 100% guarantee that Permalink Manager will work correct
95
  1. "Permalink editor".
96
  2. "Find and replace" section.
97
  3. "Regenerate/Reset" section.
98
- 4. "Permastructures" section.
99
- 5. A list of updated posts.
100
- 6. Editable URI box in Post/Page/CPT edit pagees.
101
- 7. Settings section.
102
 
103
 
104
  == Changelog ==
105
 
106
- = 1.1.2 =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  * Trailing slashes & Decode URIs - new settings
108
  * Fix for "Bulk Edit" URI reset
109
  * Partial code refactoring
 
 
110
  * Hierarchical taxonomies fix
111
  * New hook: "permalink_manager_filter_final_term_permalink"
 
 
112
  * Taxonomies & permastructures fix
113
 
114
  = 1.1.1 =
6
  Tags: urls, permalinks, slugs, custom url, custom permalinks, uris, url, slug, permalink
7
  Requires at least: 4.0
8
  Tested up to: 4.8
9
+ Stable tag: 1.11.6
10
 
11
  Most advanced yet easy-to-use permalink plugin that helps to maintain & bulk change your URLs & slugs.
12
 
95
  1. "Permalink editor".
96
  2. "Find and replace" section.
97
  3. "Regenerate/Reset" section.
98
+ 4. "Permastructures" section.
99
+ 5. A list of updated posts.
100
+ 6. Editable URI box in Post/Page/CPT edit pagees.
101
+ 7. Settings section.
102
 
103
 
104
  == Changelog ==
105
 
106
+ = 1.11.6 =
107
+ * Hotfix for taxonomy tags
108
+ * Hotfix for custom field tags
109
+ * Hotfix for Jetpack
110
+ * Suuport for WP All Import
111
+ * Support for Custom Permalinks (Permalink Manager Pro only)
112
+
113
+ = 1.11.5.1 =
114
+ * Hotfix for "Custom URI" form
115
+ * Hotfix for Yoast SEO & Visual Composer
116
+ * Now it is possible to disable slugs appendix
117
+
118
+ = 1.11.4 =
119
+ * Hotfix for RSS feeds URLs
120
+
121
+ = 1.11.1 =
122
  * Trailing slashes & Decode URIs - new settings
123
  * Fix for "Bulk Edit" URI reset
124
  * Partial code refactoring
125
+
126
+ = 1.11.0 =
127
  * Hierarchical taxonomies fix
128
  * New hook: "permalink_manager_filter_final_term_permalink"
129
+
130
+ = 1.10.2 =
131
  * Taxonomies & permastructures fix
132
 
133
  = 1.1.1 =
includes/core/permalink-manager-actions.php CHANGED
@@ -50,7 +50,7 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
50
  if($updated_slugs_count > 0) {
51
  $updated_title = __('List of updated items', 'bis');
52
  $alert_content = sprintf( _n( '<strong>%d</strong> slug was updated!', '<strong>%d</strong> slugs were updated!', $updated_slugs_count, 'permalink-manager' ), $updated_slugs_count ) . ' ';
53
- $alert_content .= sprintf( __( '<a %s>Click here</a> to go to the list of updated slugs', 'permalink-manager' ), "href=\"#TB_inline?width=100%&height=600&inlineId=updated-list\" title=\"{$updated_title}\" class=\"thickbox\"");
54
 
55
  $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message($alert_content, 'updated');
56
  $permalink_manager_after_sections_html .= Permalink_Manager_Admin_Functions::display_updated_slugs($updated_slugs_array);
@@ -100,6 +100,9 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
100
  self::flush_sitemaps();
101
  } else if(isset($_GET['clear-permalink-manager-uris'])) {
102
  self::clear_uris();
 
 
 
103
  } else if(!empty($_POST['screen-options-apply'])) {
104
  self::save_screen_options();
105
  }
@@ -159,22 +162,29 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
159
  * Remove URI from options array after post is moved to the trash
160
  */
161
  public static function clear_uris() {
162
- global $permalink_manager_uris, $permalink_manager_before_sections_html;
163
 
164
  if(empty($permalink_manager_uris)) { return; }
165
 
166
- foreach($permalink_manager_uris as $post_id => $uri) {
167
  // Loop only through post URIs
168
- if(is_numeric($post_id)) {
169
- $post_status = get_post_status($post_id);
170
- if(in_array($post_status, array('auto-draft', 'trash', ''))) {
171
- unset($permalink_manager_uris[$post_id]);
 
 
 
 
 
 
 
172
  }
173
  }
174
  }
175
 
176
  // Remove duplicates
177
- $duplicates = array_count_values($permalink_manager_uris);
178
  foreach($duplicates as $uri => $count) {
179
  if($count > 1) {
180
  // Keep the last instance
@@ -183,12 +193,33 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
183
  unset($permalink_manager_uris[$duplicated_id]);
184
  }
185
  }
186
- }
187
 
188
  update_option('permalink-manager-uris', $permalink_manager_uris);
189
  $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'URI array is cleared!', 'permalink-manager' ), 'updated');
190
  }
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  /**
193
  * "Find and replace" in "Tools"
194
  */
@@ -242,7 +273,7 @@ class Permalink_Manager_Actions extends Permalink_Manager_Class {
242
  * Import old URIs from "Custom Permalinks" (Pro)
243
  */
244
  function import_custom_permalinks_uris() {
245
- Permalink_Manager_Pro_Functions::import_custom_permalinks_uris();
246
  }
247
 
248
  }
50
  if($updated_slugs_count > 0) {
51
  $updated_title = __('List of updated items', 'bis');
52
  $alert_content = sprintf( _n( '<strong>%d</strong> slug was updated!', '<strong>%d</strong> slugs were updated!', $updated_slugs_count, 'permalink-manager' ), $updated_slugs_count ) . ' ';
53
+ $alert_content .= sprintf( __( '<a %s>Click here</a> to go to the list of updated slugs', 'permalink-manager' ), "href=\"#updated-list\" title=\"{$updated_title}\" class=\"thickbox\"");
54
 
55
  $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message($alert_content, 'updated');
56
  $permalink_manager_after_sections_html .= Permalink_Manager_Admin_Functions::display_updated_slugs($updated_slugs_array);
100
  self::flush_sitemaps();
101
  } else if(isset($_GET['clear-permalink-manager-uris'])) {
102
  self::clear_uris();
103
+ } else if(!empty($_REQUEST['remove-uri'])) {
104
+ $uri_key = sanitize_text_field($_REQUEST['remove-uri']);
105
+ self::remove_uri($uri_key);
106
  } else if(!empty($_POST['screen-options-apply'])) {
107
  self::save_screen_options();
108
  }
162
  * Remove URI from options array after post is moved to the trash
163
  */
164
  public static function clear_uris() {
165
+ global $permalink_manager_uris, $permalink_manager_before_sections_html, $wpdb;
166
 
167
  if(empty($permalink_manager_uris)) { return; }
168
 
169
+ foreach($permalink_manager_uris as $element_id => $uri) {
170
  // Loop only through post URIs
171
+ if(is_numeric($element_id)) {
172
+ $post_status = get_post_status($element_id);
173
+ if(in_array($post_status, array('auto-draft', 'trash', '')) || $post_status == false) {
174
+ unset($permalink_manager_uris[$element_id]);
175
+ }
176
+ } else if(strpos($element_id, 'tax-') !== false) {
177
+ $term_id = preg_replace("/[^0-9]/", "", $element_id);
178
+ $term = $wpdb->get_row($wpdb->prepare("SELECT t.* FROM $wpdb->terms AS t WHERE t.term_id = %s LIMIT 1", $term_id));
179
+
180
+ if(empty($term)) {
181
+ print_r('dupa');
182
  }
183
  }
184
  }
185
 
186
  // Remove duplicates
187
+ /* $duplicates = array_count_values($permalink_manager_uris);
188
  foreach($duplicates as $uri => $count) {
189
  if($count > 1) {
190
  // Keep the last instance
193
  unset($permalink_manager_uris[$duplicated_id]);
194
  }
195
  }
196
+ }*/
197
 
198
  update_option('permalink-manager-uris', $permalink_manager_uris);
199
  $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'URI array is cleared!', 'permalink-manager' ), 'updated');
200
  }
201
 
202
+ /**
203
+ * Remove URI from options array after post is moved to the trash
204
+ */
205
+ public static function remove_uri($uri_key) {
206
+ global $permalink_manager_uris, $permalink_manager_before_sections_html;
207
+
208
+ if(empty($permalink_manager_uris)) { return; }
209
+
210
+ // Check if key exists
211
+ if(isset($permalink_manager_uris[$uri_key])) {
212
+ $uri = $permalink_manager_uris[$uri_key];
213
+ unset($permalink_manager_uris[$uri_key]);
214
+
215
+ update_option('permalink-manager-uris', $permalink_manager_uris);
216
+
217
+ $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(sprintf(__( 'URI "%s" was removed successfully!', 'permalink-manager' ), $uri), 'updated');
218
+ } else {
219
+ $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'URI does not exist or was already removed!', 'permalink-manager' ), 'error');
220
+ }
221
+ }
222
+
223
  /**
224
  * "Find and replace" in "Tools"
225
  */
273
  * Import old URIs from "Custom Permalinks" (Pro)
274
  */
275
  function import_custom_permalinks_uris() {
276
+ Permalink_Manager_Third_Parties::import_custom_permalinks_uris();
277
  }
278
 
279
  }
includes/core/permalink-manager-core-functions.php CHANGED
@@ -58,7 +58,7 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
58
  $request_url = strtok($request_url, '?');
59
 
60
  // Use default REGEX to detect post
61
- preg_match("/^(.+?)\/?(page|feed|embed|attachment|track)?(?:\/([\d+]))?\/?$/i", $request_url, $regex_parts);
62
  $uri_parts['lang'] = false;
63
  $uri_parts['uri'] = (!empty($regex_parts[1])) ? $regex_parts[1] : "";
64
  $uri_parts['endpoint'] = (!empty($regex_parts[2])) ? $regex_parts[2] : "";
@@ -187,9 +187,16 @@ class Permalink_Manager_Core_Functions extends Permalink_Manager_Class {
187
  /**
188
  * 2C. Endpoints
189
  */
190
- if($item_id && !(empty($endpoint_value))) {
191
  $endpoint = ($endpoint) ? str_replace(array('page', 'trackback'), array('paged', 'tb'), $endpoint) : "page";
192
- $query[$endpoint] = $endpoint_value;
 
 
 
 
 
 
 
193
  }
194
 
195
  }
58
  $request_url = strtok($request_url, '?');
59
 
60
  // Use default REGEX to detect post
61
+ preg_match("/^(.+?)(?:\/(page|feed|embed|attachment|track))?(?:\/([\d+]))?\/?$/i", $request_url, $regex_parts);
62
  $uri_parts['lang'] = false;
63
  $uri_parts['uri'] = (!empty($regex_parts[1])) ? $regex_parts[1] : "";
64
  $uri_parts['endpoint'] = (!empty($regex_parts[2])) ? $regex_parts[2] : "";
187
  /**
188
  * 2C. Endpoints
189
  */
190
+ if($item_id && (!empty($endpoint)) || !empty($endpoint_value)) {
191
  $endpoint = ($endpoint) ? str_replace(array('page', 'trackback'), array('paged', 'tb'), $endpoint) : "page";
192
+
193
+ if($endpoint == 'feed') {
194
+ $query[$endpoint] = 'feed';
195
+ } elseif($endpoint == 'trackback') {
196
+ $query[$endpoint] = 1;
197
+ } else {
198
+ $query[$endpoint] = $endpoint_value;
199
+ }
200
  }
201
 
202
  }
includes/core/permalink-manager-helper-functions.php CHANGED
@@ -63,17 +63,17 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
63
  /**
64
  * Get array with all taxonomies
65
  */
66
- static function get_taxonomies_array($format = null, $tax = null) {
67
  $taxonomies = apply_filters('permalink-manager-taxonomies', get_taxonomies(array('public' => true, 'rewrite' => true), 'objects'));
68
 
69
  $taxonomies_array = array();
70
- if($format == 'full') {
71
- foreach ( $taxonomies as $taxonomy ) {
 
 
72
  $taxonomies_array[$taxonomy->name] = array('label' => $taxonomy->labels->name, 'name' => $taxonomy->name);
73
- }
74
- } else {
75
- foreach ( $taxonomies as $taxonomy ) {
76
- $taxonomies_array[$taxonomy->name] = $taxonomy->labels->name;
77
  }
78
  }
79
 
@@ -206,4 +206,38 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
206
  return str_replace("%2F", "/", urlencode($uri));
207
  }
208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  }
63
  /**
64
  * Get array with all taxonomies
65
  */
66
+ static function get_taxonomies_array($format = null, $tax = null, $prefix = false) {
67
  $taxonomies = apply_filters('permalink-manager-taxonomies', get_taxonomies(array('public' => true, 'rewrite' => true), 'objects'));
68
 
69
  $taxonomies_array = array();
70
+
71
+ foreach($taxonomies as $taxonomy) {
72
+ $key = ($prefix) ? "tax-{$taxonomy->name}" : $taxonomy->name;
73
+ if($format == 'full') {
74
  $taxonomies_array[$taxonomy->name] = array('label' => $taxonomy->labels->name, 'name' => $taxonomy->name);
75
+ } else {
76
+ $taxonomies_array[$key] = $taxonomy->labels->name;
 
 
77
  }
78
  }
79
 
206
  return str_replace("%2F", "/", urlencode($uri));
207
  }
208
 
209
+ /**
210
+ * Slugify function
211
+ */
212
+ public static function sanitize_title($str) {
213
+ // Trim slashes & whitespaces
214
+ $clean = trim($str, " /");
215
+
216
+ // Remove accents
217
+ $clean = remove_accents($clean);
218
+
219
+ $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $clean);
220
+ $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
221
+ $clean = strtolower(trim($clean, '-'));
222
+ $clean = preg_replace("/[_|+ -]+/", "-", $clean);
223
+
224
+ return $clean;
225
+ }
226
+
227
+ /**
228
+ * Force custom slugs
229
+ */
230
+ public static function force_custom_slugs($slug, $object) {
231
+ global $permalink_manager_options;
232
+
233
+ if(!empty($permalink_manager_options['general']['force_custom_slugs'])) {
234
+ $old_slug = basename($slug);
235
+ $new_slug = (!empty($object->name)) ? sanitize_title($object->name) : sanitize_title($object->post_title);
236
+
237
+ $slug = ($old_slug != $new_slug) ? str_replace($old_slug, $new_slug, $slug) : $slug;
238
+ }
239
+
240
+ return $slug;
241
+ }
242
+
243
  }
includes/core/permalink-manager-third-parties.php CHANGED
@@ -43,10 +43,13 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
43
  $yoast_permalink_options = get_option('wpseo_permalinks');
44
 
45
  // Redirect attachment to parent post/page enabled
46
- if(!empty($yoast_permalink_options['redirectattachment']) && !empty($permalink_manager_options['general']['redirect'])) {
47
  add_filter('permalink-manager-detected-initial-id', array($this, 'yoast_detect_attachment'), 9, 3);
48
  }
49
  }
 
 
 
50
  }
51
 
52
  /**
@@ -219,5 +222,52 @@ class Permalink_Manager_Third_Parties extends Permalink_Manager_Class {
219
  return $custom_permalinks_uris;
220
  }
221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  }
223
  ?>
43
  $yoast_permalink_options = get_option('wpseo_permalinks');
44
 
45
  // Redirect attachment to parent post/page enabled
46
+ if(!empty($yoast_permalink_options['redirectattachment']) && !empty($permalink_manager_options['general']['yoast_attachment_redirect'])) {
47
  add_filter('permalink-manager-detected-initial-id', array($this, 'yoast_detect_attachment'), 9, 3);
48
  }
49
  }
50
+
51
+ // 5. WP All Import
52
+ add_action('pmxi_after_xml_import', array($this, 'pmxi_fix_permalinks'), 10);
53
  }
54
 
55
  /**
222
  return $custom_permalinks_uris;
223
  }
224
 
225
+ static public function import_custom_permalinks_uris() {
226
+ global $permalink_manager_uris, $permalink_manager_before_sections_html;
227
+
228
+ $custom_permalinks_plugin = 'custom-permalinks/custom-permalinks.php';
229
+
230
+ if(is_plugin_active($custom_permalinks_plugin) && !empty($_POST['disable_custom_permalinks'])) {
231
+ deactivate_plugins($custom_permalinks_plugin);
232
+ }
233
+
234
+ // Get a list of imported URIs
235
+ $custom_permalinks_uris = self::custom_permalinks_uris();
236
+
237
+ if(!empty($custom_permalinks_uris) && count($custom_permalinks_uris) > 0) {
238
+ foreach($custom_permalinks_uris as $item) {
239
+ $permalink_manager_uris[$item['id']] = $item['uri'];
240
+ }
241
+
242
+ $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( '"Custom Permalinks" URIs were imported!', 'permalink-manager' ), 'updated');
243
+ update_option('permalink-manager-uris', $permalink_manager_uris);
244
+ } else {
245
+ $permalink_manager_before_sections_html .= Permalink_Manager_Admin_Functions::get_alert_message(__( 'No "Custom Permalinks" URIs were imported!', 'permalink-manager' ), 'error');
246
+ }
247
+ }
248
+
249
+ /**
250
+ * 5. WP All Import
251
+ */
252
+ function pmxi_fix_permalinks($import_id) {
253
+ global $permalink_manager_uris, $wpdb;
254
+
255
+ $post_ids = $wpdb->get_col($wpdb->prepare("SELECT post_id FROM {$wpdb->prefix}pmxi_posts WHERE import_id = %s", $import_id));
256
+
257
+ // Just in case
258
+ sleep(3);
259
+
260
+ if(array($post_ids)) {
261
+ foreach($post_ids as $id) {
262
+ // Get default post URI
263
+ $new_uri = Permalink_Manager_URI_Functions_Post::get_default_post_uri($id);
264
+ $permalink_manager_uris[$id] = $new_uri;
265
+ }
266
+ }
267
+
268
+ update_option('permalink-manager-uris', $permalink_manager_uris);
269
+ }
270
+
271
+
272
  }
273
  ?>
includes/core/permalink-manager-uri-functions-post.php CHANGED
@@ -15,11 +15,10 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
15
  add_filter( 'attachment_link', array($this, 'custom_post_permalinks'), 999, 2);
16
 
17
  add_filter( 'permalink-manager-uris', array($this, 'exclude_homepage'), 999, 2);
18
- add_action( 'save_post', array($this, 'update_post_uri'), 999, 3 );
19
  add_action( 'edit_attachment', array($this, 'update_post_uri'), 999, 1 );
20
- add_action( 'wp_trash_post', array($this, 'remove_post_uri'), 10, 3 );
21
-
22
- add_filter( 'permalink_manager_filter_default_post_slug', array($this, 'force_custom_slugs'), 5, 3 );
23
  }
24
 
25
  /**
@@ -125,15 +124,26 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
125
  $author = $authordata->user_nicename;
126
  }
127
 
128
- // 2. Fix for hierarchical CPT (start)
129
  $full_slug = get_page_uri($post);
130
  $full_slug = (empty($full_slug)) ? $post_name : $full_slug;
131
- $full_slug = ($native_uri == false) ? apply_filters('permalink_manager_filter_default_post_slug', $full_slug, $post, $post_name) : $full_slug;
 
 
 
 
 
 
 
 
 
 
132
  $post_type_tag = Permalink_Manager_Helper_Functions::get_post_tag($post_type);
133
 
134
  // 3A. Do the replacement (post tag is removed now to enable support for hierarchical CPT)
135
  $tags = array('%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%post_id%', '%author%', $post_type_tag);
136
  $replacements = array($date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $post->ID, $author, '');
 
137
  $default_uri = str_replace($tags, $replacements, "{$default_base}/{$full_slug}");
138
 
139
  // 3B. Replace taxonomies
@@ -141,33 +151,37 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
141
 
142
  if($taxonomies) {
143
  foreach($taxonomies as $taxonomy) {
144
- // 1. Try to use Yoast SEO Primary Term
 
 
 
145
  $replacement_term = Permalink_Manager_Helper_Functions::get_primary_term($post->ID, $taxonomy, false);
146
 
147
- // 2. Get the first assigned term to this taxonomy
148
  if(empty($replacement_term)) {
149
  $terms = wp_get_object_terms($post->ID, $taxonomy);
150
  $replacement_term = (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) ? $terms[0] : "";
151
  }
152
 
153
- // 3A. Hierarhcical taxonomy base
154
  if(!empty($replacement_term->term_id) && strpos($default_uri, "%{$taxonomy}_flat%") === false && is_taxonomy_hierarchical($taxonomy)) {
155
  $ancestors = get_ancestors( $replacement_term->term_id, $taxonomy, 'taxonomy' );
156
  $hierarchical_slugs = array();
157
 
158
- foreach ( (array) $ancestors as $ancestor ) {
159
  $ancestor_term = get_term($ancestor, $taxonomy);
160
- $hierarchical_slugs[] = $ancestor_term->slug;
161
  }
162
  $hierarchical_slugs = array_reverse($hierarchical_slugs);
163
  $replacement = implode('/', $hierarchical_slugs);
164
 
165
  // Append the term slug now
166
- $replacement = "{$replacement}/{$replacement_term->slug}";
 
167
  }
168
- // 3B. Flat taxonomy base
169
  else if(!empty($replacement_term->slug)) {
170
- $replacement = $replacement_term->slug;
171
  }
172
 
173
  // 4. Do the replacement
@@ -175,6 +189,8 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
175
  }
176
  }
177
 
 
 
178
  $default_uri = preg_replace('/\s+/', '', $default_uri);
179
  $default_uri = str_replace('//', '/', $default_uri);
180
  $default_uri = trim($default_uri, "/");
@@ -280,11 +296,6 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
280
  $updated_array[] = array('item_title' => $row['post_title'], 'ID' => $row['ID'], 'old_uri' => $old_uri, 'new_uri' => $new_uri, 'old_slug' => $old_post_name, 'new_slug' => $new_post_name);
281
  $updated_slugs_count++;
282
  }
283
-
284
- // Do not store default values
285
- // if(isset($permalink_manager_uris[$row['ID']]) && ($new_uri == $native_uri)) {
286
- // unset($permalink_manager_uris[$row['ID']]);
287
- // }
288
  }
289
 
290
  // Filter array before saving
@@ -361,7 +372,15 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
361
  // Process URI & slug
362
  $new_slug = wp_unique_post_slug($correct_slug, $row['ID'], get_post_status($row['ID']), get_post_type($row['ID']), null);
363
  $new_post_name = ($mode == 'slugs') ? $new_slug : $old_post_name; // Post name is changed only in first mode
364
- $new_uri = ($mode == 'slugs') ? $old_uri : $default_uri;
 
 
 
 
 
 
 
 
365
 
366
  //print_r("{$old_uri} - {$new_uri} - {$native_uri} - {$default_uri} \n");
367
 
@@ -375,11 +394,6 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
375
  $updated_array[] = array('item_title' => $row['post_title'], 'ID' => $row['ID'], 'old_uri' => $old_uri, 'new_uri' => $new_uri, 'old_slug' => $old_post_name, 'new_slug' => $new_post_name);
376
  $updated_slugs_count++;
377
  }
378
-
379
- // Do not store default values
380
- // if(isset($permalink_manager_uris[$row['ID']]) && ($new_uri == $native_uri)) {
381
- // unset($permalink_manager_uris[$row['ID']]);
382
- // }
383
  }
384
 
385
  // Filter array before saving
@@ -436,12 +450,6 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
436
  $updated_array[] = array('item_title' => get_the_title($id), 'ID' => $id, 'old_uri' => $old_uri, 'new_uri' => $new_uri);
437
  $updated_slugs_count++;
438
  }
439
-
440
- // Do not store native URIs
441
- // if($new_uri == $native_uri) {
442
- // unset($old_uris[$id]);
443
- // }
444
-
445
  }
446
 
447
  // Filter array before saving & append the global
@@ -551,12 +559,36 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
551
  return $html;
552
  }
553
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
554
  /**
555
  * Update URI from "Edit Post" admin page
556
  */
557
- function update_post_uri($post_id, $post, $update) {
558
  global $permalink_manager_uris, $permalink_manager_options, $permalink_manager_before_sections_html;
559
 
 
560
  if(!isset($_POST['custom_uri'])) { return; }
561
 
562
  // Fix for revisions
@@ -565,7 +597,6 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
565
  $post = get_post($post_id);
566
 
567
  // Ignore auto-drafts & removed posts
568
- //if(in_array($post->post_status, array('auto-draft', 'trash')) || empty($post->post_name) || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) { return; }
569
  if(in_array($post->post_status, array('auto-draft', 'trash')) || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (!empty($_REQUEST['bulk_edit'])) || (!empty($_REQUEST['post_view']))) { return; }
570
 
571
  // Get auto-update URI setting (if empty use global setting)
@@ -577,17 +608,7 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
577
  $old_uri = (isset($permalink_manager_uris[$post->ID])) ? $permalink_manager_uris[$post->ID] : $native_uri;
578
 
579
  // Use default URI if URI is cleared by user OR URI should be automatically updated
580
- $new_uri = (empty($_POST['custom_uri']) || $auto_update_uri == 1) ? $default_uri : trim($_POST['custom_uri'], "/");
581
-
582
- // Do not store default values
583
- // if(isset($permalink_manager_uris[$post->ID]) && ($new_uri == $native_uri)) {
584
- // unset($permalink_manager_uris[$post->ID]);
585
- // } else
586
-
587
- // Save only changed URIs
588
- if($new_uri != $old_uri) {
589
- $permalink_manager_uris[$post->ID] = $new_uri;
590
- }
591
 
592
  // Save or remove "Auto-update URI" settings
593
  if(!empty($auto_update_uri_current)) {
@@ -596,7 +617,13 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
596
  delete_post_meta($post_id, "auto_update_uri");
597
  }
598
 
599
- update_option('permalink-manager-uris', $permalink_manager_uris);
 
 
 
 
 
 
600
  }
601
 
602
  /**
@@ -613,22 +640,6 @@ class Permalink_Manager_URI_Functions_Post extends Permalink_Manager_Class {
613
  update_option('permalink-manager-uris', $permalink_manager_uris);
614
  }
615
 
616
- /**
617
- * Force custom slugs
618
- */
619
- public function force_custom_slugs($slug, $object, $name) {
620
- global $permalink_manager_options;
621
-
622
- if(!empty($permalink_manager_options['general']['force_custom_slugs'])) {
623
- $old_slug = basename($slug);
624
- $new_slug = sanitize_title($object->post_title);
625
-
626
- $slug = ($old_slug != $new_slug) ? str_replace($old_slug, $new_slug, $slug) : $slug;
627
- }
628
-
629
- return $slug;
630
- }
631
-
632
  }
633
 
634
  ?>
15
  add_filter( 'attachment_link', array($this, 'custom_post_permalinks'), 999, 2);
16
 
17
  add_filter( 'permalink-manager-uris', array($this, 'exclude_homepage'), 999, 2);
18
+ add_action( 'save_post', array($this, 'update_post_uri'), 999, 1);
19
  add_action( 'edit_attachment', array($this, 'update_post_uri'), 999, 1 );
20
+ add_action( 'wp_insert_post', array($this, 'update_post_uri'), 999, 1 );
21
+ add_action( 'wp_trash_post', array($this, 'remove_post_uri'), 10, 1 );
 
22
  }
23
 
24
  /**
124
  $author = $authordata->user_nicename;
125
  }
126
 
127
+ // 2A. Fix for hierarchical CPT (start)
128
  $full_slug = get_page_uri($post);
129
  $full_slug = (empty($full_slug)) ? $post_name : $full_slug;
130
+
131
+ if(!$native_uri) {
132
+ // 2B. Remove the post slug (the last occurence of post_name)
133
+ if(!empty($permalink_manager_options['general']['disable_slug_appendix']) && in_array($post_type, $permalink_manager_options['general']['disable_slug_appendix'])) {
134
+ $full_slug = (strpos($full_slug, '/') !== false) ? preg_replace("/(.*)\/(.*)$/", "$1", $full_slug) : "";
135
+ }
136
+
137
+ // 2C. Allow filter the default slug
138
+ $full_slug = Permalink_Manager_Helper_Functions::force_custom_slugs($full_slug, $post);
139
+ $full_slug = apply_filters('permalink_manager_filter_default_post_slug', $full_slug, $post, $post_name);
140
+ }
141
  $post_type_tag = Permalink_Manager_Helper_Functions::get_post_tag($post_type);
142
 
143
  // 3A. Do the replacement (post tag is removed now to enable support for hierarchical CPT)
144
  $tags = array('%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%post_id%', '%author%', $post_type_tag);
145
  $replacements = array($date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $post->ID, $author, '');
146
+
147
  $default_uri = str_replace($tags, $replacements, "{$default_base}/{$full_slug}");
148
 
149
  // 3B. Replace taxonomies
151
 
152
  if($taxonomies) {
153
  foreach($taxonomies as $taxonomy) {
154
+ // 1. Reset $replacement
155
+ $replacement = $terms = $replacement_term = "";
156
+
157
+ // 2. Try to use Yoast SEO Primary Term
158
  $replacement_term = Permalink_Manager_Helper_Functions::get_primary_term($post->ID, $taxonomy, false);
159
 
160
+ // 3. Get the first assigned term to this taxonomy
161
  if(empty($replacement_term)) {
162
  $terms = wp_get_object_terms($post->ID, $taxonomy);
163
  $replacement_term = (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) ? $terms[0] : "";
164
  }
165
 
166
+ // 4A. Hierarhcical taxonomy base
167
  if(!empty($replacement_term->term_id) && strpos($default_uri, "%{$taxonomy}_flat%") === false && is_taxonomy_hierarchical($taxonomy)) {
168
  $ancestors = get_ancestors( $replacement_term->term_id, $taxonomy, 'taxonomy' );
169
  $hierarchical_slugs = array();
170
 
171
+ foreach((array) $ancestors as $ancestor) {
172
  $ancestor_term = get_term($ancestor, $taxonomy);
173
+ $hierarchical_slugs[] = Permalink_Manager_Helper_Functions::force_custom_slugs($ancestor_term->slug, $ancestor_term);
174
  }
175
  $hierarchical_slugs = array_reverse($hierarchical_slugs);
176
  $replacement = implode('/', $hierarchical_slugs);
177
 
178
  // Append the term slug now
179
+ $last_term_slug = Permalink_Manager_Helper_Functions::force_custom_slugs($replacement_term->slug, $replacement_term);
180
+ $replacement = "{$replacement}/{$last_term_slug}";
181
  }
182
+ // 4B. Flat taxonomy base
183
  else if(!empty($replacement_term->slug)) {
184
+ $replacement = Permalink_Manager_Helper_Functions::force_custom_slugs($replacement_term->slug, $replacement_term);
185
  }
186
 
187
  // 4. Do the replacement
189
  }
190
  }
191
 
192
+ // Clear the URI
193
+ $default_uri = preg_replace("/(%(?:.+?)%\/)/i", "", $default_uri);
194
  $default_uri = preg_replace('/\s+/', '', $default_uri);
195
  $default_uri = str_replace('//', '/', $default_uri);
196
  $default_uri = trim($default_uri, "/");
296
  $updated_array[] = array('item_title' => $row['post_title'], 'ID' => $row['ID'], 'old_uri' => $old_uri, 'new_uri' => $new_uri, 'old_slug' => $old_post_name, 'new_slug' => $new_post_name);
297
  $updated_slugs_count++;
298
  }
 
 
 
 
 
299
  }
300
 
301
  // Filter array before saving
372
  // Process URI & slug
373
  $new_slug = wp_unique_post_slug($correct_slug, $row['ID'], get_post_status($row['ID']), get_post_type($row['ID']), null);
374
  $new_post_name = ($mode == 'slugs') ? $new_slug : $old_post_name; // Post name is changed only in first mode
375
+
376
+ // Prepare the new URI
377
+ if($mode == 'slugs') {
378
+ $new_uri = $old_uri;
379
+ } else if($mode == 'native') {
380
+ $new_uri = $native_uri;
381
+ } else {
382
+ $new_uri = $default_uri;
383
+ }
384
 
385
  //print_r("{$old_uri} - {$new_uri} - {$native_uri} - {$default_uri} \n");
386
 
394
  $updated_array[] = array('item_title' => $row['post_title'], 'ID' => $row['ID'], 'old_uri' => $old_uri, 'new_uri' => $new_uri, 'old_slug' => $old_post_name, 'new_slug' => $new_post_name);
395
  $updated_slugs_count++;
396
  }
 
 
 
 
 
397
  }
398
 
399
  // Filter array before saving
450
  $updated_array[] = array('item_title' => get_the_title($id), 'ID' => $id, 'old_uri' => $old_uri, 'new_uri' => $new_uri);
451
  $updated_slugs_count++;
452
  }
 
 
 
 
 
 
453
  }
454
 
455
  // Filter array before saving & append the global
559
  return $html;
560
  }
561
 
562
+ /**
563
+ * Update URI when new post is added
564
+ */
565
+ function new_post_uri($post_id) {
566
+ global $permalink_manager_uris, $permalink_manager_options, $permalink_manager_before_sections_html;
567
+
568
+ // Hotfix
569
+ if(!empty($_POST['custom_uri'])) { return; }
570
+
571
+ // Fix for revisions
572
+ $is_revision = wp_is_post_revision($post_id);
573
+ $post_id = ($is_revision) ? $is_revision : $post_id;
574
+ $post = get_post($post_id);
575
+
576
+ $native_uri = self::get_default_post_uri($post_id, true);
577
+ $new_uri = self::get_default_post_uri($post_id);;
578
+ $permalink_manager_uris[$post->ID] = $new_uri;
579
+
580
+ update_option('permalink-manager-uris', $permalink_manager_uris);
581
+
582
+ do_action('permalink-manager-new-post-uri', $post_id, $new_uri, $native_uri);
583
+ }
584
+
585
  /**
586
  * Update URI from "Edit Post" admin page
587
  */
588
+ function update_post_uri($post_id) {
589
  global $permalink_manager_uris, $permalink_manager_options, $permalink_manager_before_sections_html;
590
 
591
+ // Do not do anything if the field with URI is not present
592
  if(!isset($_POST['custom_uri'])) { return; }
593
 
594
  // Fix for revisions
597
  $post = get_post($post_id);
598
 
599
  // Ignore auto-drafts & removed posts
 
600
  if(in_array($post->post_status, array('auto-draft', 'trash')) || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (!empty($_REQUEST['bulk_edit'])) || (!empty($_REQUEST['post_view']))) { return; }
601
 
602
  // Get auto-update URI setting (if empty use global setting)
608
  $old_uri = (isset($permalink_manager_uris[$post->ID])) ? $permalink_manager_uris[$post->ID] : $native_uri;
609
 
610
  // Use default URI if URI is cleared by user OR URI should be automatically updated
611
+ $new_uri = (($_POST['custom_uri'] == '') || $auto_update_uri == 1) ? $default_uri : Permalink_Manager_Helper_Functions::sanitize_title($_POST['custom_uri']);
 
 
 
 
 
 
 
 
 
 
612
 
613
  // Save or remove "Auto-update URI" settings
614
  if(!empty($auto_update_uri_current)) {
617
  delete_post_meta($post_id, "auto_update_uri");
618
  }
619
 
620
+ // Save only changed URIs
621
+ if($new_uri != $old_uri) {
622
+ $permalink_manager_uris[$post->ID] = $new_uri;
623
+ update_option('permalink-manager-uris', $permalink_manager_uris);
624
+ }
625
+
626
+ do_action('permalink-manager-updated-post-uri', $post_id, $new_uri, $old_uri, $native_uri, $default_uri);
627
  }
628
 
629
  /**
640
  update_option('permalink-manager-uris', $permalink_manager_uris);
641
  }
642
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
643
  }
644
 
645
  ?>
includes/views/permalink-manager-settings.php CHANGED
@@ -25,7 +25,8 @@ class Permalink_Manager_Settings extends Permalink_Manager_Class {
25
  // Get all registered post types array & statuses
26
  $all_post_statuses_array = get_post_statuses();
27
  $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array();
28
- $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array();
 
29
 
30
  $sections_and_fields = apply_filters('permalink-manager-settings-fields', array(
31
  'general' => array(
@@ -58,6 +59,12 @@ class Permalink_Manager_Settings extends Permalink_Manager_Class {
58
  'input_class' => '',
59
  'description' => __('Used to generate default permalinks in pages, posts & custom post types. Works only when "Yoast SEO" plugin is enabled.', 'permalink-manager')
60
  ),
 
 
 
 
 
 
61
  'canonical_redirect' => array(
62
  'type' => 'single_checkbox',
63
  'label' => __('Canonical redirect', 'permalink-manager'),
@@ -97,6 +104,12 @@ class Permalink_Manager_Settings extends Permalink_Manager_Class {
97
  'choices' => array(0 => __('Use default settings', 'permalink-manager'), 1 => __('Always add trailing slashes', 'permalink-manager'), 2 => __('Always remove trailing slashes', 'permalink-manager')),
98
  'description' => __('This option can be used to alter the native settings and control if trailing slash should be added or removed from the end of posts & terms permalinks.', 'permalink-manager')
99
  ),
 
 
 
 
 
 
100
  /*'extension_suffix' => array(
101
  'type' => 'select',
102
  'label' => __('Extension suffix', 'permalink-manager'),
25
  // Get all registered post types array & statuses
26
  $all_post_statuses_array = get_post_statuses();
27
  $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array();
28
+ $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array(false, false, true);
29
+ $content_types = (defined('PERMALINK_MANAGER_PRO')) ? array_merge($all_post_types, $all_taxonomies) : $all_post_types;
30
 
31
  $sections_and_fields = apply_filters('permalink-manager-settings-fields', array(
32
  'general' => array(
59
  'input_class' => '',
60
  'description' => __('Used to generate default permalinks in pages, posts & custom post types. Works only when "Yoast SEO" plugin is enabled.', 'permalink-manager')
61
  ),
62
+ 'yoast_attachment_redirect' => array(
63
+ 'type' => 'single_checkbox',
64
+ 'label' => __('Attachment redirect support', 'permalink-manager'),
65
+ 'input_class' => '',
66
+ 'description' => __('Support for redirect attachment URLs to parent post URL. Works only when "Yoast SEO Premium" plugin is enabled.', 'permalink-manager')
67
+ ),
68
  'canonical_redirect' => array(
69
  'type' => 'single_checkbox',
70
  'label' => __('Canonical redirect', 'permalink-manager'),
104
  'choices' => array(0 => __('Use default settings', 'permalink-manager'), 1 => __('Always add trailing slashes', 'permalink-manager'), 2 => __('Always remove trailing slashes', 'permalink-manager')),
105
  'description' => __('This option can be used to alter the native settings and control if trailing slash should be added or removed from the end of posts & terms permalinks.', 'permalink-manager')
106
  ),
107
+ 'disable_slug_appendix' => array(
108
+ 'type' => 'checkbox',
109
+ 'label' => __('Disable slug appendix', 'permalink-manager'),
110
+ 'choices' => $content_types,
111
+ 'description' => __('The slugs will not be automatically apended to the end of permastructure in the default permalinks for selected post types & taxonomies.<br />Works correctly only if <strong>"Force custom slugs" is disabled!</strong>', 'permalink-manager')
112
+ ),
113
  /*'extension_suffix' => array(
114
  'type' => 'select',
115
  'label' => __('Extension suffix', 'permalink-manager'),
includes/views/permalink-manager-tools.php CHANGED
@@ -26,10 +26,10 @@ class Permalink_Manager_Tools extends Permalink_Manager_Class {
26
  'name' => __('Stop words', 'permalink-manager'),
27
  'function' => array('class' => 'Permalink_Manager_Admin_Functions', 'method' => 'pro_text')
28
  ),
29
- /*'import' => array(
30
- 'name' => __('"Custom Permalinks" import', 'permalink-manager'),
31
  'function' => array('class' => 'Permalink_Manager_Admin_Functions', 'method' => 'pro_text')
32
- )*/
33
  )
34
  );
35
 
@@ -133,7 +133,7 @@ class Permalink_Manager_Tools extends Permalink_Manager_Class {
133
  'label' => __( 'Mode', 'permalink-manager' ),
134
  'type' => 'select',
135
  'container' => 'row',
136
- 'choices' => array('custom_uris' => __('Custom URIs', 'permalink-manager'), 'slugs' => __('Native slugs', 'permalink-manager')),
137
  ),
138
  'content_type' => array(
139
  'label' => __( 'Select content type', 'permalink-manager' ),
26
  'name' => __('Stop words', 'permalink-manager'),
27
  'function' => array('class' => 'Permalink_Manager_Admin_Functions', 'method' => 'pro_text')
28
  ),
29
+ 'import' => array(
30
+ 'name' => __('Custom Permalinks', 'permalink-manager'),
31
  'function' => array('class' => 'Permalink_Manager_Admin_Functions', 'method' => 'pro_text')
32
+ )
33
  )
34
  );
35
 
133
  'label' => __( 'Mode', 'permalink-manager' ),
134
  'type' => 'select',
135
  'container' => 'row',
136
+ 'choices' => array('custom_uris' => __('Custom URIs', 'permalink-manager'), 'slugs' => __('Restore native slugs', 'permalink-manager'), 'native' => __('Restore native permalinks', 'permalink-manager')),
137
  ),
138
  'content_type' => array(
139
  'label' => __( 'Select content type', 'permalink-manager' ),
includes/views/permalink-manager-upgrade.php CHANGED
@@ -40,12 +40,12 @@ class Permalink_Manager_Upgrade extends Permalink_Manager_Class {
40
  $output .= "<div class=\"column-1_3\">";
41
  $output .= sprintf("<h5>%s</h5>", __("Custom fields inside permalinks", "permalink-manager"));
42
  $output .= wpautop(__("Automatically embed your custom fields values inside the permalinks, by adding the custom field tags to the permastructures.", "permalink-manager"));
43
- $output .= wpautop(__("This functionality is also compatible with meta keys set with Advanced Custom Fields plugin.", "permalink-manager"));
44
  $output .= "</div>";
45
- /*$output .= "<div class=\"column-1_3\">";
46
  $output .= sprintf("<h5>%s</h5>", __("Import permalinks from \"Custom Permalinks\"", "permalink-manager"));
47
  $output .= wpautop(__("Additionally, Permalink Manager Pro allows to import the custom URIs defined previously with \"Custom Permalinks\" plugin. ", "permalink-manager"));
48
- $output .= "</div>";*/
49
  $output .= "<div class=\"column-1_3\">";
50
  $output .= sprintf("<h5>%s</h5>", __("Remove \"stop words\" from permalinks", "permalink-manager"));
51
  $output .= wpautop(__("Set your own list of stop words or use a predefined one available in 21 languages. If enabled, all the words will be automatically removed from the default permalinks.", "permalink-manager"));
40
  $output .= "<div class=\"column-1_3\">";
41
  $output .= sprintf("<h5>%s</h5>", __("Custom fields inside permalinks", "permalink-manager"));
42
  $output .= wpautop(__("Automatically embed your custom fields values inside the permalinks, by adding the custom field tags to the permastructures.", "permalink-manager"));
43
+ $output .= wpautop(__("This functionality is compatible with meta keys set with Advanced Custom Fields plugin.", "permalink-manager"));
44
  $output .= "</div>";
45
+ $output .= "<div class=\"column-1_3\">";
46
  $output .= sprintf("<h5>%s</h5>", __("Import permalinks from \"Custom Permalinks\"", "permalink-manager"));
47
  $output .= wpautop(__("Additionally, Permalink Manager Pro allows to import the custom URIs defined previously with \"Custom Permalinks\" plugin. ", "permalink-manager"));
48
+ $output .= "</div>";
49
  $output .= "<div class=\"column-1_3\">";
50
  $output .= sprintf("<h5>%s</h5>", __("Remove \"stop words\" from permalinks", "permalink-manager"));
51
  $output .= wpautop(__("Set your own list of stop words or use a predefined one available in 21 languages. If enabled, all the words will be automatically removed from the default permalinks.", "permalink-manager"));
includes/views/permalink-manager-uri-editor-post.php CHANGED
@@ -80,7 +80,7 @@ class Permalink_Manager_URI_Editor_Post extends WP_List_Table {
80
 
81
  $uri = Permalink_Manager_URI_Functions_Post::get_post_uri($item['ID'], true);
82
  $uri = (!empty($permalink_manager_options['general']['decode_uris'])) ? urldecode($uri) : $uri;
83
-
84
  $field_args_base = array('type' => 'text', 'value' => $uri, 'without_label' => true, 'input_class' => '');
85
  $permalink = get_permalink($item['ID']);
86
  $post_statuses_array = get_post_statuses();
@@ -199,7 +199,6 @@ class Permalink_Manager_URI_Editor_Post extends WP_List_Table {
199
  }
200
 
201
  // Grab posts from database
202
- //$sql_query = "SELECT * FROM {$wpdb->posts} WHERE post_status IN ($this->displayed_post_statuses) AND post_type IN ($this->displayed_post_types) ORDER BY $orderby $order LIMIT $per_page OFFSET $offset";
203
  $sql_query = "SELECT * FROM {$wpdb->posts} WHERE post_status IN ($this->displayed_post_statuses) AND post_type IN ($this->displayed_post_types) {$extra_filters} ORDER BY $orderby $order";
204
  $all_data = $wpdb->get_results($sql_query, ARRAY_A);
205
 
80
 
81
  $uri = Permalink_Manager_URI_Functions_Post::get_post_uri($item['ID'], true);
82
  $uri = (!empty($permalink_manager_options['general']['decode_uris'])) ? urldecode($uri) : $uri;
83
+
84
  $field_args_base = array('type' => 'text', 'value' => $uri, 'without_label' => true, 'input_class' => '');
85
  $permalink = get_permalink($item['ID']);
86
  $post_statuses_array = get_post_statuses();
199
  }
200
 
201
  // Grab posts from database
 
202
  $sql_query = "SELECT * FROM {$wpdb->posts} WHERE post_status IN ($this->displayed_post_statuses) AND post_type IN ($this->displayed_post_types) {$extra_filters} ORDER BY $orderby $order";
203
  $all_data = $wpdb->get_results($sql_query, ARRAY_A);
204
 
includes/views/permalink-manager-uri-editor.php CHANGED
@@ -95,7 +95,11 @@ class Permalink_Manager_Uri_Editor extends Permalink_Manager_Class {
95
  'choices' => get_post_statuses(),
96
  'select_all' => '',
97
  'unselect_all' => '',
98
- )
 
 
 
 
99
  );
100
 
101
  foreach($screen_options as $field_name => $field_args) {
95
  'choices' => get_post_statuses(),
96
  'select_all' => '',
97
  'unselect_all' => '',
98
+ ),
99
+ /*'group' => array(
100
+ 'type' => 'single_checkbox',
101
+ 'label' => __('Group children pages', 'permalink-manager'),
102
+ ),*/
103
  );
104
 
105
  foreach($screen_options as $field_name => $field_args) {
out/permalink-manager-admin.css CHANGED
@@ -57,8 +57,9 @@
57
  #permalink-manager .extra-links a,.permalink-manager-screen-options .extra-links a{color:#666;display:inline-block;text-decoration:none}
58
  #permalink-manager .extra-links a:before,.permalink-manager-screen-options .extra-links a:before{content:" | "}
59
  #permalink-manager .extra-links a:first-child:before,.permalink-manager-screen-options .extra-links a:first-child:before{content:""}
 
60
  #permalink-manager .checkboxes{margin-left:-15px;margin-right:15px;overflow:hidden;display:block}
61
- #permalink-manager .checkboxes > label{display:inline-block;width:33%;float:left;padding:0 15px;box-sizing:border-box;padding-bottom:5px}
62
  #permalink-manager .checkboxes > label:nth-of-type(3n+1){clear:both}
63
  #permalink-manager .field-description{font-size:12px}
64
  #permalink-manager .appended-row td{padding-left:0;padding-right:0}
@@ -68,6 +69,9 @@
68
  #permalink-manager .structure-tags-list{display:block;line-height:175%}
69
  #permalink-manager .structure-tags-list code{}
70
 
 
 
 
71
  /**
72
  * Columns
73
  */
57
  #permalink-manager .extra-links a,.permalink-manager-screen-options .extra-links a{color:#666;display:inline-block;text-decoration:none}
58
  #permalink-manager .extra-links a:before,.permalink-manager-screen-options .extra-links a:before{content:" | "}
59
  #permalink-manager .extra-links a:first-child:before,.permalink-manager-screen-options .extra-links a:first-child:before{content:""}
60
+ .permalink-manager-screen-options{margin-bottom:15px}
61
  #permalink-manager .checkboxes{margin-left:-15px;margin-right:15px;overflow:hidden;display:block}
62
+ #permalink-manager .checkboxes > label{display:inline-block;width:33%;float:left;padding:0 15px;box-sizing:border-box;padding-bottom:5px;overflow:hidden}
63
  #permalink-manager .checkboxes > label:nth-of-type(3n+1){clear:both}
64
  #permalink-manager .field-description{font-size:12px}
65
  #permalink-manager .appended-row td{padding-left:0;padding-right:0}
69
  #permalink-manager .structure-tags-list{display:block;line-height:175%}
70
  #permalink-manager .structure-tags-list code{}
71
 
72
+ #permalink-manager .updated-slugs-table .row-title{max-width:400px}
73
+
74
+
75
  /**
76
  * Columns
77
  */
permalink-manager.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Permalink Manager Lite
5
  * Plugin URI: https://permalinkmanager.pro?utm_source=plugin
6
  * Description: Most advanced Permalink utility for Wordpress. It allows to bulk edit the permalinks & permastructures and regenerate/reset all the URIs in your Wordpress instance.
7
- * Version: 1.1.2
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', '1.1.2' );
25
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit( dirname( __FILE__ ) ) );
26
  define( 'PERMALINK_MANAGER_BASENAME', plugin_basename(__FILE__) );
27
  define( 'PERMALINK_MANAGER_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) );
@@ -36,7 +36,7 @@ class Permalink_Manager_Class {
36
  /**
37
  * Get options from DB, load subclasses & hooks
38
  */
39
- public function __construct() {
40
  $this->include_subclassess();
41
  $this->register_init_hooks();
42
  }
@@ -92,10 +92,10 @@ class Permalink_Manager_Class {
92
  */
93
  public function register_init_hooks() {
94
  // Localize plugin
95
- add_action( 'plugins_loaded', array($this, 'localize_me'), 1 );
96
-
97
- // Load options
98
- add_action( 'init', array($this, 'get_options_and_globals'), 1 );
99
 
100
  // Legacy support
101
  add_action( 'init', array($this, 'legacy_support'), 2 );
@@ -103,6 +103,9 @@ class Permalink_Manager_Class {
103
  // Default settings & alerts
104
  add_filter( 'permalink-manager-options', array($this, 'default_settings'), 1 );
105
  add_filter( 'permalink-manager-alerts', array($this, 'default_alerts'), 1 );
 
 
 
106
  }
107
 
108
  /**
@@ -128,7 +131,7 @@ class Permalink_Manager_Class {
128
 
129
  $this->permalink_manager_alerts = $permalink_manager_alerts = apply_filters('permalink-manager-alerts', get_option('permalink-manager-alerts', array()));
130
  $this->permalink_manager_before_sections_html = $permalink_manager_before_sections_html = apply_filters('permalink-manager-before-sections', '');
131
- $this->permalink_manager_after_sections_html = $permalink_manager_after_sections_html = apply_filters('permalink-manager-after-sections', '');
132
  }
133
 
134
  /**
@@ -141,7 +144,8 @@ class Permalink_Manager_Class {
141
  $default_settings = apply_filters('permalink-manager-default-options', array(
142
  'screen-options' => array(
143
  'per_page' => 20,
144
- 'post_statuses' => array('publish')
 
145
  ),
146
  'general' => array(
147
  'force_custom_slugs' => 0,
@@ -150,8 +154,10 @@ class Permalink_Manager_Class {
150
  'decode_uris' => 0,
151
  'yoast_primary_term' => 1,
152
  'redirect' => '302',
 
153
  'canonical_redirect' => 1,
154
- 'trailing_slashes' => 0
 
155
  ),
156
  'licence' => array()
157
  ));
@@ -173,15 +179,15 @@ class Permalink_Manager_Class {
173
  */
174
  public function default_alerts($alerts) {
175
  $default_alerts = apply_filters('permalink-manager-default-alerts', array(
176
- 'summer-promo' => array(
177
  'txt' => sprintf(
178
- __("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 30&#37; using \"SUMMER\" coupon code (valid until 2017-08-01)!</strong>", "permalink-manager"),
179
  PERMALINK_MANAGER_WEBSITE
180
  ),
181
  'type' => 'notice-info',
182
  'show' => 'pro_hide',
183
  'plugin_only' => true,
184
- 'until' => '2017-08-01'
185
  )
186
  ));
187
 
@@ -226,6 +232,32 @@ class Permalink_Manager_Class {
226
  }
227
  }
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  }
230
 
231
  /**
4
  * Plugin Name: Permalink Manager Lite
5
  * Plugin URI: https://permalinkmanager.pro?utm_source=plugin
6
  * Description: Most advanced Permalink utility for Wordpress. It allows to bulk edit the permalinks & permastructures and regenerate/reset all the URIs in your Wordpress instance.
7
+ * Version: 1.11.6
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', '1.11.6' );
25
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit( dirname( __FILE__ ) ) );
26
  define( 'PERMALINK_MANAGER_BASENAME', plugin_basename(__FILE__) );
27
  define( 'PERMALINK_MANAGER_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) );
36
  /**
37
  * Get options from DB, load subclasses & hooks
38
  */
39
+ public function __construct() {
40
  $this->include_subclassess();
41
  $this->register_init_hooks();
42
  }
92
  */
93
  public function register_init_hooks() {
94
  // Localize plugin
95
+ add_action( 'plugins_loaded', array($this, 'localize_me'), 1 );
96
+
97
+ // Load globals & options
98
+ add_action( 'plugins_loaded', array($this, 'get_options_and_globals'), 9 );
99
 
100
  // Legacy support
101
  add_action( 'init', array($this, 'legacy_support'), 2 );
103
  // Default settings & alerts
104
  add_filter( 'permalink-manager-options', array($this, 'default_settings'), 1 );
105
  add_filter( 'permalink-manager-alerts', array($this, 'default_alerts'), 1 );
106
+
107
+ // Check for updates
108
+ add_action( 'init', array($this, 'check_for_updates'), 999 );
109
  }
110
 
111
  /**
131
 
132
  $this->permalink_manager_alerts = $permalink_manager_alerts = apply_filters('permalink-manager-alerts', get_option('permalink-manager-alerts', array()));
133
  $this->permalink_manager_before_sections_html = $permalink_manager_before_sections_html = apply_filters('permalink-manager-before-sections', '');
134
+ $this->permalink_manager_after_sections_html = $permalink_manager_after_sections_html = apply_filters('permalink-manager-after-sections', '');
135
  }
136
 
137
  /**
144
  $default_settings = apply_filters('permalink-manager-default-options', array(
145
  'screen-options' => array(
146
  'per_page' => 20,
147
+ 'post_statuses' => array('publish'),
148
+ 'group' => false,
149
  ),
150
  'general' => array(
151
  'force_custom_slugs' => 0,
154
  'decode_uris' => 0,
155
  'yoast_primary_term' => 1,
156
  'redirect' => '302',
157
+ 'yoast_attachment_redirect' => 1,
158
  'canonical_redirect' => 1,
159
+ 'trailing_slashes' => 0,
160
+ 'disable_slug_appendix' => array()
161
  ),
162
  'licence' => array()
163
  ));
179
  */
180
  public function default_alerts($alerts) {
181
  $default_alerts = apply_filters('permalink-manager-default-alerts', array(
182
+ 'september' => array(
183
  'txt' => sprintf(
184
+ __("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 20&#37; using \"SUMMER\" coupon code!</strong>", "permalink-manager"),
185
  PERMALINK_MANAGER_WEBSITE
186
  ),
187
  'type' => 'notice-info',
188
  'show' => 'pro_hide',
189
  'plugin_only' => true,
190
+ 'until' => '2017-09-10'
191
  )
192
  ));
193
 
232
  }
233
  }
234
 
235
+ /**
236
+ * Update check
237
+ */
238
+ public function check_for_updates() {
239
+ global $permalink_manager_options;
240
+
241
+ if(defined('PERMALINK_MANAGER_PRO')) {
242
+ // Get the licence key
243
+ $license_key = (!empty($permalink_manager_options['licence']['licence_key'])) ? $permalink_manager_options['licence']['licence_key'] : "";
244
+
245
+ // Get expiration date
246
+ // add_filter('puc_request_info_result-permalink-manager-pro', array($this, 'update_pro_info'), 99, 2);
247
+
248
+ // Load Plugin Update Checker by YahnisElsts
249
+ require_once PERMALINK_MANAGER_DIR . '/includes/ext/plugin-update-checker/plugin-update-checker.php';
250
+
251
+ $UpdateChecker = Puc_v4_Factory::buildUpdateChecker(
252
+ "https://updates.permalinkmanager.pro/?action=get_metadata&slug=permalink-manager-pro&license_key={$license_key}",
253
+ __FILE__,
254
+ "permalink-manager-pro"
255
+ );
256
+
257
+ $file = PERMALINK_MANAGER_BASENAME;
258
+ }
259
+ }
260
+
261
  }
262
 
263
  /**