Custom Permalinks - Version 1.7.0

Version Description

  • Aug 20, 2020 =

    • Bugs
    • Paged NextGen Galleries Broken with Custom Permalinks 1.62
    • custom permalink issue with weglot
    • Permalinks reverting back to old ones
    • A problem with wrongly deleted permalinks
    • Enhancements
    • Enhanced security through characters restriction
    • Introduce filter to disable specific redirect(s) or complete functionality
    • Automatic replacement of upper case letters to lower case
Download this release

Release Info

Developer sasiddiqui
Plugin Icon Custom Permalinks
Version 1.7.0
Comparing to
See all releases

Code changes from version 1.6.2 to 1.7.0

admin/class-custom-permalinks-pager.php CHANGED
@@ -28,7 +28,8 @@ class Custom_Permalinks_Pager
28
  if ( 1 == $total_pager ) {
29
  $pagination_html = '<div class="tablenav-pages one-page">' .
30
  '<span class="displaying-num">' .
31
- $total_permalinks . ' items' .
 
32
  '</span>' .
33
  '</div>';
34
 
@@ -43,7 +44,8 @@ class Custom_Permalinks_Pager
43
  }
44
  $pagination_html = '<div class="tablenav-pages">' .
45
  '<span class="displaying-num">' .
46
- $total_permalinks . ' items' .
 
47
  '</span>' .
48
  '<span class="pagination-links">';
49
 
@@ -55,19 +57,25 @@ class Custom_Permalinks_Pager
55
  if ( 1 == $prev_page ) {
56
  $pagination_html .= '<span class="tablenav-pages-navspan" aria-hidden="true">&laquo;</span>';
57
  } else {
58
- $pagination_html .= ' <a href="' . $remove_pager_uri[0] . '&paged=1" title="First page" class="first-page">' .
59
- '<span class="screen-reader-text">First page</span>' .
 
 
60
  '<span aria-hidden="true">&laquo;</span>' .
61
  '</a> ';
62
  }
63
- $pagination_html .= ' <a href="' . $remove_pager_uri[0] . '&paged=' . $prev_page . '" title="Previous page" class="prev-page">' .
64
- '<span class="screen-reader-text">Previous page</span>' .
 
 
65
  '<span aria-hidden="true">&lsaquo;</span>' .
66
  '</a> ';
67
  }
68
 
69
  $pagination_html .= '<span class="paging-input">' .
70
- '<label for="current-page-selector" class="screen-reader-text">Current Page</label>' .
 
 
71
  '<input class="current-page" id="current-page-selector" type="text" name="paged" value="' . $current_pager_value . '" size="1" aria-describedby="table-paging" />' .
72
  '<span class="tablenav-paging-text"> of <span class="total-pages">' . $total_pager . ' </span> </span>' .
73
  '</span>';
@@ -77,15 +85,19 @@ class Custom_Permalinks_Pager
77
  '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo; </span>';
78
  } else {
79
  $next_page = $current_pager_value + 1;
80
- $pagination_html .= ' <a href="' . $remove_pager_uri[0] . '&paged=' . $next_page . '" title="Next page" class="next-page">' .
81
- '<span class="screen-reader-text">Next page</span>' .
 
 
82
  '<span aria-hidden="true">&rsaquo;</span>' .
83
  '</a> ';
84
  if ( $total_pager == $next_page ) {
85
  $pagination_html .= '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo;</span>';
86
  } else {
87
- $pagination_html .= ' <a href="' . $remove_pager_uri[0] . '&paged=' . $total_pager . '" title="Last page" class="last-page">' .
88
- '<span class="screen-reader-text">Last page</span>' .
 
 
89
  '<span aria-hidden="true">&raquo;</span>' .
90
  '</a> ';
91
  }
28
  if ( 1 == $total_pager ) {
29
  $pagination_html = '<div class="tablenav-pages one-page">' .
30
  '<span class="displaying-num">' .
31
+ $total_permalinks .
32
+ __( 'items', 'custom-permalinks' ) .
33
  '</span>' .
34
  '</div>';
35
 
44
  }
45
  $pagination_html = '<div class="tablenav-pages">' .
46
  '<span class="displaying-num">' .
47
+ $total_permalinks .
48
+ __( 'items', 'custom-permalinks' ) .
49
  '</span>' .
50
  '<span class="pagination-links">';
51
 
57
  if ( 1 == $prev_page ) {
58
  $pagination_html .= '<span class="tablenav-pages-navspan" aria-hidden="true">&laquo;</span>';
59
  } else {
60
+ $pagination_html .= ' <a href="' . $remove_pager_uri[0] . '&paged=1" title="' . __( "First page", "custom-permalinks" ) .'" class="first-page">' .
61
+ '<span class="screen-reader-text">' .
62
+ __( 'First page', 'custom-permalinks' ) .
63
+ '</span>' .
64
  '<span aria-hidden="true">&laquo;</span>' .
65
  '</a> ';
66
  }
67
+ $pagination_html .= ' <a href="' . $remove_pager_uri[0] . '&paged=' . $prev_page . '" title="' . __( "Previous page", "custom-permalinks" ) . '" class="prev-page">' .
68
+ '<span class="screen-reader-text">' .
69
+ __( 'Previous page', 'custom-permalinks' ) .
70
+ '</span>' .
71
  '<span aria-hidden="true">&lsaquo;</span>' .
72
  '</a> ';
73
  }
74
 
75
  $pagination_html .= '<span class="paging-input">' .
76
+ '<label for="current-page-selector" class="screen-reader-text">' .
77
+ __( 'Current Page', 'custom-permalinks' ) .
78
+ '</label>' .
79
  '<input class="current-page" id="current-page-selector" type="text" name="paged" value="' . $current_pager_value . '" size="1" aria-describedby="table-paging" />' .
80
  '<span class="tablenav-paging-text"> of <span class="total-pages">' . $total_pager . ' </span> </span>' .
81
  '</span>';
85
  '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo; </span>';
86
  } else {
87
  $next_page = $current_pager_value + 1;
88
+ $pagination_html .= ' <a href="' . $remove_pager_uri[0] . '&paged=' . $next_page . '" title="' . __( "Next page", "custom-permalinks" ) . '" class="next-page">' .
89
+ '<span class="screen-reader-text">' .
90
+ __( 'Next page', 'custom-permalinks' ) .
91
+ '</span>' .
92
  '<span aria-hidden="true">&rsaquo;</span>' .
93
  '</a> ';
94
  if ( $total_pager == $next_page ) {
95
  $pagination_html .= '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo;</span>';
96
  } else {
97
+ $pagination_html .= ' <a href="' . $remove_pager_uri[0] . '&paged=' . $total_pager . '" title="' . __( "Last page", "custom-permalinks" ) . '" class="last-page">' .
98
+ '<span class="screen-reader-text">' .
99
+ __( 'Last page', 'custom-permalinks' ) .
100
+ '</span>' .
101
  '<span aria-hidden="true">&raquo;</span>' .
102
  '</a> ';
103
  }
admin/class-custom-permalinks-posttypes.php CHANGED
@@ -28,19 +28,40 @@ class Custom_Permalinks_PostTypes
28
  */
29
  private function post_nav( $order_by_class, $order_by, $search_permalink )
30
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  $post_nav = '<tr>' .
32
  '<td id="cb" class="manage-column column-cb check-column">' .
33
- '<label class="screen-reader-text" for="cb-select-all-1">Select All</label>' .
 
 
34
  '<input id="cb-select-all-1" type="checkbox">' .
35
  '</td>' .
36
  '<th scope="col" id="title" class="manage-column column-title column-primary sortable ' . $order_by_class . '">' .
37
- '<a href="/wp-admin/admin.php?page=cp-post-permalinks&amp;orderby=title&amp;order=' . $order_by . $search_permalink . '">' .
38
- '<span>' . __( "Title", "custom-permalinks" ) . '</span>' .
 
 
39
  '<span class="sorting-indicator"></span>' .
40
  '</a>' .
41
  '</th>' .
42
- '<th scope="col">' . __( "Type", "custom-permalinks" ) . '</th>' .
43
- '<th scope="col">' . __( "Permalink", "custom-permalinks" ) . '</th>' .
 
 
 
 
44
  '</tr>';
45
 
46
  return $post_nav;
@@ -77,37 +98,34 @@ class Custom_Permalinks_PostTypes
77
  }
78
 
79
  // Handle Bulk Operations
80
- if ( (
81
- ( isset( $post_action ) && 'delete' === $post_action )
82
- || ( isset( $post_action2 ) && 'delete' === $post_action2 )
83
- )
84
  && check_admin_referer( 'custom-permalinks-post_' . $user_id,
85
  '_custom_permalinks_post_nonce'
86
  )
87
  ) {
88
- if ( isset( $post_permalinks ) && ! empty( $post_permalinks ) ) {
89
  $post_ids = $post_permalinks;
90
  if ( is_array( $post_ids ) && 0 < count( $post_ids ) ) {
91
  foreach ( $post_ids as $post_id ) {
92
  if ( is_numeric( $post_id ) ) {
93
- delete_post_meta( $post_id, 'custom_permalink' );
94
  }
95
  }
96
  } else {
97
  $error = '<div id="message" class="error">' .
98
  '<p>' .
99
- __( 'Please select permalinks which you like to be deleted.',
100
- 'custom-permalinks'
101
- ) .
102
  '</p>' .
103
  '</div>';
104
  }
105
  } else {
106
  $error = '<div id="message" class="error">' .
107
  '<p>' .
108
- __( 'There is some error to proceed your request. Please retry with your request or contact to the plugin author.',
109
- 'custom-permalinks'
110
- ) .
111
  '</p>' .
112
  '</div>';
113
  }
@@ -139,14 +157,14 @@ class Custom_Permalinks_PostTypes
139
  $post_html .= '<span class="subtitle">Search results for "' . $search_value . '"</span>';
140
  }
141
 
142
- if ( $get_paged && is_numeric( $get_paged ) && 1 < $get_paged ) {
143
  $pager = 20 * ( $get_paged - 1 );
144
  $page_limit = 'LIMIT ' . $pager . ', 20';
145
  }
146
 
147
- if ( $get_order_by && 'title' === $get_order_by ) {
148
  $filter_options .= '<input type="hidden" name="orderby" value="title" />';
149
- if ( $get_order && 'desc' === $get_order ) {
150
  $sorting_by = 'ORDER By p.post_title DESC';
151
  $order_by = 'asc';
152
  $order_by_class = 'desc';
@@ -161,9 +179,8 @@ class Custom_Permalinks_PostTypes
161
 
162
  $count_query = "SELECT COUNT(p.ID) AS total_permalinks FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id) WHERE pm.meta_key = 'custom_permalink' AND pm.meta_value != '' " . $filter_permalink . "";
163
  $count_posts = $wpdb->get_row( $count_query );
164
- $post_nonce = wp_nonce_field(
165
- 'custom-permalinks-post_' . $user_id, '_custom_permalinks_post_nonce',
166
- true, false
167
  );
168
 
169
  $post_html .= '<form action="' . $site_url . $request_uri . '" method="get">' .
@@ -171,24 +188,28 @@ class Custom_Permalinks_PostTypes
171
  '<input type="hidden" name="page" value="cp-post-permalinks" />' .
172
  $post_nonce .
173
  $filter_options .
174
- '<label class="screen-reader-text" for="custom-permalink-search-input">Search Custom Permalink:</label>' .
 
 
175
  '<input type="search" id="custom-permalink-search-input" name="s" value="' . $search_value . '">' .
176
- '<input type="submit" id="search-submit" class="button" value="Search Permalink"></p>' .
177
  '</form>' .
178
  '<form action="' . $site_url . $request_uri . '" method="post">' .
179
  '<div class="tablenav top">' .
180
  '<div class="alignleft actions bulkactions">' .
181
- '<label for="bulk-action-selector-top" class="screen-reader-text">Select bulk action</label>' .
 
 
182
  $post_nonce .
183
  '<select name="action" id="bulk-action-selector-top">' .
184
  '<option value="-1">' .
185
- __( "Bulk Actions", "custom-permalinks" ) .
186
  '</option>' .
187
  '<option value="delete">' .
188
- __( "Delete Permalinks", "custom-permalinks" ) .
189
  '</option>' .
190
  '</select>' .
191
- '<input type="submit" id="doaction" class="button action" value="Apply">' .
192
  '</div>';
193
 
194
  $posts = 0;
@@ -199,13 +220,15 @@ class Custom_Permalinks_PostTypes
199
  include_once CUSTOM_PERMALINKS_PATH . 'admin/class-custom-permalinks-pager.php';
200
 
201
  $cp_pager = new Custom_Permalinks_Pager();
202
- $post_html .= '<h2 class="screen-reader-text">Custom Permalink navigation</h2>';
 
 
203
 
204
  $query = "SELECT p.ID, p.post_title, p.post_type, pm.meta_value FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id) WHERE pm.meta_key = 'custom_permalink' AND pm.meta_value != '' " . $filter_permalink . " " . $sorting_by . " " . $page_limit . "";
205
  $posts = $wpdb->get_results( $query );
206
 
207
  $total_pages = ceil( $count_posts->total_permalinks / 20 );
208
- if ( $get_paged && is_numeric( $get_paged ) && 0 < $get_paged ) {
209
  $pagination_html = $cp_pager->get_pagination(
210
  $count_posts->total_permalinks, $get_paged, $total_pages
211
  );
@@ -287,7 +310,7 @@ class Custom_Permalinks_PostTypes
287
  } else {
288
  $post_html .= '<tr class="no-items">' .
289
  '<td class="colspanchange" colspan="4">' .
290
- __( "No permalinks found.", "custom-permalinks" ) .
291
  '</td>' .
292
  '</tr>';
293
  }
@@ -297,16 +320,18 @@ class Custom_Permalinks_PostTypes
297
 
298
  $post_html .= '<div class="tablenav bottom">' .
299
  '<div class="alignleft actions bulkactions">' .
300
- '<label for="bulk-action-selector-bottom" class="screen-reader-text">Select bulk action</label>' .
 
 
301
  '<select name="action2" id="bulk-action-selector-bottom">' .
302
- '<option value="-1">'
303
- . __( "Bulk Actions", "custom-permalinks" ) .
304
  '</option>' .
305
  '<option value="delete">' .
306
- __( "Delete Permalinks", "custom-permalinks" ) .
307
  '</option>' .
308
  '</select>' .
309
- '<input type="submit" id="doaction2" class="button action" value="Apply">' .
310
  '</div>' .
311
  $pagination_html .
312
  '</div>' .
28
  */
29
  private function post_nav( $order_by_class, $order_by, $search_permalink )
30
  {
31
+ $admin_url = get_admin_url();
32
+ $page_url = $admin_url . 'admin.php?page=cp-post-permalinks';
33
+ $title_url = $page_url . '&amp;orderby=title&amp;order=' . $order_by;
34
+ $user_id = get_current_user_id();
35
+
36
+ if ( $search_permalink ) {
37
+ $title_url = $title_url . $search_permalink;
38
+ $title_url = wp_nonce_url( $title_url,
39
+ 'custom-permalinks-post_' . $user_id,
40
+ '_custom_permalinks_post_nonce'
41
+ );
42
+ }
43
+
44
  $post_nav = '<tr>' .
45
  '<td id="cb" class="manage-column column-cb check-column">' .
46
+ '<label class="screen-reader-text" for="cb-select-all-1">' .
47
+ __( 'Select All', 'custom-permalinks' ) .
48
+ '</label>' .
49
  '<input id="cb-select-all-1" type="checkbox">' .
50
  '</td>' .
51
  '<th scope="col" id="title" class="manage-column column-title column-primary sortable ' . $order_by_class . '">' .
52
+ '<a href="' . $title_url . '">' .
53
+ '<span>' .
54
+ __( 'Title', 'custom-permalinks' ) .
55
+ '</span>' .
56
  '<span class="sorting-indicator"></span>' .
57
  '</a>' .
58
  '</th>' .
59
+ '<th scope="col">' .
60
+ __( 'Type', 'custom-permalinks' ) .
61
+ '</th>' .
62
+ '<th scope="col">' .
63
+ __( 'Permalink', 'custom-permalinks' ) .
64
+ '</th>' .
65
  '</tr>';
66
 
67
  return $post_nav;
98
  }
99
 
100
  // Handle Bulk Operations
101
+ if ( ( 'delete' === $post_action || 'delete' === $post_action2 )
 
 
 
102
  && check_admin_referer( 'custom-permalinks-post_' . $user_id,
103
  '_custom_permalinks_post_nonce'
104
  )
105
  ) {
106
+ if ( ! empty( $post_permalinks ) ) {
107
  $post_ids = $post_permalinks;
108
  if ( is_array( $post_ids ) && 0 < count( $post_ids ) ) {
109
  foreach ( $post_ids as $post_id ) {
110
  if ( is_numeric( $post_id ) ) {
111
+ delete_metadata( 'post', $post_id, 'custom_permalink' );
112
  }
113
  }
114
  } else {
115
  $error = '<div id="message" class="error">' .
116
  '<p>' .
117
+ __( 'Please select permalinks which you like to be deleted.',
118
+ 'custom-permalinks'
119
+ ) .
120
  '</p>' .
121
  '</div>';
122
  }
123
  } else {
124
  $error = '<div id="message" class="error">' .
125
  '<p>' .
126
+ __( 'There is some error to proceed your request. Please retry with your request or contact to the plugin author.',
127
+ 'custom-permalinks'
128
+ ) .
129
  '</p>' .
130
  '</div>';
131
  }
157
  $post_html .= '<span class="subtitle">Search results for "' . $search_value . '"</span>';
158
  }
159
 
160
+ if ( is_numeric( $get_paged ) && 1 < $get_paged ) {
161
  $pager = 20 * ( $get_paged - 1 );
162
  $page_limit = 'LIMIT ' . $pager . ', 20';
163
  }
164
 
165
+ if ( 'title' === $get_order_by ) {
166
  $filter_options .= '<input type="hidden" name="orderby" value="title" />';
167
+ if ( 'desc' === $get_order ) {
168
  $sorting_by = 'ORDER By p.post_title DESC';
169
  $order_by = 'asc';
170
  $order_by_class = 'desc';
179
 
180
  $count_query = "SELECT COUNT(p.ID) AS total_permalinks FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id) WHERE pm.meta_key = 'custom_permalink' AND pm.meta_value != '' " . $filter_permalink . "";
181
  $count_posts = $wpdb->get_row( $count_query );
182
+ $post_nonce = wp_nonce_field( 'custom-permalinks-post_' . $user_id,
183
+ '_custom_permalinks_post_nonce', true, false
 
184
  );
185
 
186
  $post_html .= '<form action="' . $site_url . $request_uri . '" method="get">' .
188
  '<input type="hidden" name="page" value="cp-post-permalinks" />' .
189
  $post_nonce .
190
  $filter_options .
191
+ '<label class="screen-reader-text" for="custom-permalink-search-input">' .
192
+ __( 'Search Custom Permalink:', 'custom-permalinks' ) .
193
+ '</label>' .
194
  '<input type="search" id="custom-permalink-search-input" name="s" value="' . $search_value . '">' .
195
+ '<input type="submit" id="search-submit" class="button" value="' . __( "Search Permalink", "custom-permalinks" ) . '"></p>' .
196
  '</form>' .
197
  '<form action="' . $site_url . $request_uri . '" method="post">' .
198
  '<div class="tablenav top">' .
199
  '<div class="alignleft actions bulkactions">' .
200
+ '<label for="bulk-action-selector-top" class="screen-reader-text">' .
201
+ __( 'Select bulk action', 'custom-permalinks' ) .
202
+ '</label>' .
203
  $post_nonce .
204
  '<select name="action" id="bulk-action-selector-top">' .
205
  '<option value="-1">' .
206
+ __( 'Bulk Actions', 'custom-permalinks' ) .
207
  '</option>' .
208
  '<option value="delete">' .
209
+ __( 'Delete Permalinks', 'custom-permalinks' ) .
210
  '</option>' .
211
  '</select>' .
212
+ '<input type="submit" id="doaction" class="button action" value="' . __( "Apply", "custom-permalinks" ) . '">' .
213
  '</div>';
214
 
215
  $posts = 0;
220
  include_once CUSTOM_PERMALINKS_PATH . 'admin/class-custom-permalinks-pager.php';
221
 
222
  $cp_pager = new Custom_Permalinks_Pager();
223
+ $post_html .= '<h2 class="screen-reader-text">' .
224
+ __( 'Custom Permalink navigation', 'custom-permalinks' ) .
225
+ '</h2>';
226
 
227
  $query = "SELECT p.ID, p.post_title, p.post_type, pm.meta_value FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id) WHERE pm.meta_key = 'custom_permalink' AND pm.meta_value != '' " . $filter_permalink . " " . $sorting_by . " " . $page_limit . "";
228
  $posts = $wpdb->get_results( $query );
229
 
230
  $total_pages = ceil( $count_posts->total_permalinks / 20 );
231
+ if ( is_numeric( $get_paged ) && 0 < $get_paged ) {
232
  $pagination_html = $cp_pager->get_pagination(
233
  $count_posts->total_permalinks, $get_paged, $total_pages
234
  );
310
  } else {
311
  $post_html .= '<tr class="no-items">' .
312
  '<td class="colspanchange" colspan="4">' .
313
+ __( 'No permalinks found.', 'custom-permalinks' ) .
314
  '</td>' .
315
  '</tr>';
316
  }
320
 
321
  $post_html .= '<div class="tablenav bottom">' .
322
  '<div class="alignleft actions bulkactions">' .
323
+ '<label for="bulk-action-selector-bottom" class="screen-reader-text">' .
324
+ __( 'Select bulk action', 'custom-permalinks' ) .
325
+ '</label>' .
326
  '<select name="action2" id="bulk-action-selector-bottom">' .
327
+ '<option value="-1">' .
328
+ __( 'Bulk Actions', 'custom-permalinks' ) .
329
  '</option>' .
330
  '<option value="delete">' .
331
+ __( 'Delete Permalinks', 'custom-permalinks' ) .
332
  '</option>' .
333
  '</select>' .
334
+ '<input type="submit" id="doaction2" class="button action" value="' . __( "Apply", "custom-permalinks" ) . '">' .
335
  '</div>' .
336
  $pagination_html .
337
  '</div>' .
admin/class-custom-permalinks-taxonomies.php CHANGED
@@ -26,14 +26,20 @@ class Custom_Permalinks_Taxonomies
26
  {
27
  $navigation = '<tr>' .
28
  '<td id="cb" class="manage-column column-cb check-column">' .
29
- '<label class="screen-reader-text" for="cb-select-all-1">Select All</label>' .
 
 
30
  '<input id="cb-select-all-1" type="checkbox">' .
31
  '</td>' .
32
  '<th scope="col" id="title" class="manage-column column-title column-primary">' .
33
- __( "Title", "custom-permalinks" ) .
 
 
 
 
 
 
34
  '</th>' .
35
- '<th scope="col">' . __( "Type", "custom-permalinks" ) . '</th>' .
36
- '<th scope="col">' . __( "Permalink", "custom-permalinks" ) . '</th>' .
37
  '</tr>';
38
 
39
  return $navigation;
@@ -77,15 +83,12 @@ class Custom_Permalinks_Taxonomies
77
  }
78
 
79
  // Handle Bulk Operations
80
- if ( (
81
- ( isset( $term_action ) && 'delete' === $term_action )
82
- || ( isset( $term_action2 ) && 'delete' === $term_action2 )
83
- )
84
  && check_admin_referer( 'custom-permalinks-term_' . $user_id,
85
  '_custom_permalinks_term_nonce'
86
  )
87
  ) {
88
- if ( isset( $term_permalinks ) && ! empty( $term_permalinks ) ) {
89
  $data = get_option( 'custom_permalink_table' );
90
  if ( isset( $data ) && is_array( $data ) ) {
91
  $loopCount = 0;
@@ -116,12 +119,11 @@ class Custom_Permalinks_Taxonomies
116
  $pager_offset = '0';
117
  $search_input = filter_input( INPUT_GET, 's' );
118
  $search_value = '';
119
- $term_nonce = wp_nonce_field(
120
- 'custom-permalinks-term_' . $user_id, '_custom_permalinks_term_nonce',
121
- true, false
122
  );
123
 
124
- if ( $search_input && ! empty( $search_input )
125
  && check_admin_referer( 'custom-permalinks-term_' . $user_id,
126
  '_custom_permalinks_term_nonce'
127
  )
@@ -130,29 +132,38 @@ class Custom_Permalinks_Taxonomies
130
  $page_html .= '<span class="subtitle">Search results for "' . $search_value . '"</span>';
131
  }
132
 
133
- if ( $get_paged && is_numeric( $get_paged ) && 1 < $get_paged ) {
134
  $pager_offset = 20 * ( $get_paged - 1 );
135
  $page_limit = $pager_offset + 20;
136
  }
137
 
138
  $page_html .= '<form action="' . $site_url . $request_uri . '" method="get">' .
139
  '<p class="search-box">' .
140
- '<input type="hidden" name="page" value="cp-category-permalinks" />' .
141
- $term_nonce .
142
- '<label class="screen-reader-text" for="custom-permalink-search-input">Search Custom Permalink:</label>' .
143
- '<input type="search" id="custom-permalink-search-input" name="s" value="' . $search_value . '">' .
144
- '<input type="submit" id="search-submit" class="button" value="Search Permalink"></p>' .
 
 
 
145
  '</form>' .
146
  '<form action="' . $site_url . $request_uri . '" method="post">' .
147
  '<div class="tablenav top">' .
148
  '<div class="alignleft actions bulkactions">' .
149
- '<label for="bulk-action-selector-top" class="screen-reader-text">Select bulk action</label>' .
 
 
150
  $term_nonce .
151
  '<select name="action" id="bulk-action-selector-top">' .
152
- '<option value="-1">' . __( "Bulk Actions", "custom-permalinks" ) . '</option>' .
153
- '<option value="delete">' . __( "Delete Permalinks", "custom-permalinks" ) . '</option>' .
 
 
 
 
154
  '</select>' .
155
- '<input type="submit" id="doaction" class="button action" value="Apply">' .
156
  '</div>';
157
 
158
  $table = get_option( 'custom_permalink_table' );
@@ -177,10 +188,12 @@ class Custom_Permalinks_Taxonomies
177
  $count_tags = count( $table );
178
  }
179
 
180
- $page_html .= '<h2 class="screen-reader-text">Custom Permalink navigation</h2>';
 
 
181
 
182
  $total_pages = ceil( $count_tags / 20 );
183
- if ( $get_paged && is_numeric( $get_paged ) && 0 < $get_paged ) {
184
  $pagination_html = $cp_pager->get_pagination(
185
  $count_tags, $get_paged, $total_pages
186
  );
@@ -256,20 +269,22 @@ class Custom_Permalinks_Taxonomies
256
  '</th>' .
257
  '<td><strong>' .
258
  '<a class="row-title" href="' . $site_url . '/wp-admin/edit-tags.php?action=edit&taxonomy=' . $type . '&tag_ID=' . $info['id'] . ' ">' .
259
- $term->name .
260
  '</a>' .
261
  '</strong></td>' .
262
  '<td>' . ucwords( $info['kind'] ) . '</td>' .
263
  '<td>' .
264
  '<a href="' . $permalink . '" target="_blank" title="' . __( "Visit " . $term->name, "custom-permalinks" ) . '">' .
265
- $perm_text .
266
  '</a>' .
267
  '</td>' .
268
  '</tr>';
269
  }
270
  } else {
271
  $page_html .= '<tr class="no-items">' .
272
- '<td class="colspanchange" colspan="4">' . __( "No permalinks found.", "custom-permalinks" ) . '</td>' .
 
 
273
  '</tr>';
274
  }
275
  $page_html .= '</tbody>' .
@@ -278,12 +293,18 @@ class Custom_Permalinks_Taxonomies
278
 
279
  $page_html .= '<div class="tablenav bottom">' .
280
  '<div class="alignleft actions bulkactions">' .
281
- '<label for="bulk-action-selector-bottom" class="screen-reader-text">Select bulk action</label>' .
 
 
282
  '<select name="action2" id="bulk-action-selector-bottom">' .
283
- '<option value="-1">' . __( "Bulk Actions", "custom-permalinks" ) . '</option>' .
284
- '<option value="delete">' . __( "Delete Permalinks", "custom-permalinks" ) . '</option>' .
 
 
 
 
285
  '</select>' .
286
- '<input type="submit" id="doaction2" class="button action" value="Apply">' .
287
  '</div>' .
288
  $pagination_html .
289
  '</div>' .
26
  {
27
  $navigation = '<tr>' .
28
  '<td id="cb" class="manage-column column-cb check-column">' .
29
+ '<label class="screen-reader-text" for="cb-select-all-1">' .
30
+ __( 'Select All', 'custom-permalinks' ) .
31
+ '</label>' .
32
  '<input id="cb-select-all-1" type="checkbox">' .
33
  '</td>' .
34
  '<th scope="col" id="title" class="manage-column column-title column-primary">' .
35
+ __( 'Title', 'custom-permalinks' ) .
36
+ '</th>' .
37
+ '<th scope="col">' .
38
+ __( 'Type', 'custom-permalinks' ) .
39
+ '</th>' .
40
+ '<th scope="col">' .
41
+ __( 'Permalink', 'custom-permalinks' ) .
42
  '</th>' .
 
 
43
  '</tr>';
44
 
45
  return $navigation;
83
  }
84
 
85
  // Handle Bulk Operations
86
+ if ( ( 'delete' === $term_action || 'delete' === $term_action2 )
 
 
 
87
  && check_admin_referer( 'custom-permalinks-term_' . $user_id,
88
  '_custom_permalinks_term_nonce'
89
  )
90
  ) {
91
+ if ( ! empty( $term_permalinks ) ) {
92
  $data = get_option( 'custom_permalink_table' );
93
  if ( isset( $data ) && is_array( $data ) ) {
94
  $loopCount = 0;
119
  $pager_offset = '0';
120
  $search_input = filter_input( INPUT_GET, 's' );
121
  $search_value = '';
122
+ $term_nonce = wp_nonce_field( 'custom-permalinks-term_' . $user_id,
123
+ '_custom_permalinks_term_nonce', true, false
 
124
  );
125
 
126
+ if ( ! empty( $search_input )
127
  && check_admin_referer( 'custom-permalinks-term_' . $user_id,
128
  '_custom_permalinks_term_nonce'
129
  )
132
  $page_html .= '<span class="subtitle">Search results for "' . $search_value . '"</span>';
133
  }
134
 
135
+ if ( is_numeric( $get_paged ) && 1 < $get_paged ) {
136
  $pager_offset = 20 * ( $get_paged - 1 );
137
  $page_limit = $pager_offset + 20;
138
  }
139
 
140
  $page_html .= '<form action="' . $site_url . $request_uri . '" method="get">' .
141
  '<p class="search-box">' .
142
+ '<input type="hidden" name="page" value="cp-category-permalinks" />' .
143
+ $term_nonce .
144
+ '<label class="screen-reader-text" for="custom-permalink-search-input">' .
145
+ __( 'Search Custom Permalink:', 'custom-permalinks' ) .
146
+ '</label>' .
147
+ '<input type="search" id="custom-permalink-search-input" name="s" value="' . $search_value . '">' .
148
+ '<input type="submit" id="search-submit" class="button" value="' . __( "Search Permalink", "custom-permalinks" ) . '">' .
149
+ '</p>' .
150
  '</form>' .
151
  '<form action="' . $site_url . $request_uri . '" method="post">' .
152
  '<div class="tablenav top">' .
153
  '<div class="alignleft actions bulkactions">' .
154
+ '<label for="bulk-action-selector-top" class="screen-reader-text">' .
155
+ __( 'Select bulk action', 'custom-permalinks' ) .
156
+ '</label>' .
157
  $term_nonce .
158
  '<select name="action" id="bulk-action-selector-top">' .
159
+ '<option value="-1">' .
160
+ __( 'Bulk Actions', 'custom-permalinks' ) .
161
+ '</option>' .
162
+ '<option value="delete">' .
163
+ __( 'Delete Permalinks', 'custom-permalinks' ) .
164
+ '</option>' .
165
  '</select>' .
166
+ '<input type="submit" id="doaction" class="button action" value="' . __( "Apply", "custom-permalinks" ) . '">' .
167
  '</div>';
168
 
169
  $table = get_option( 'custom_permalink_table' );
188
  $count_tags = count( $table );
189
  }
190
 
191
+ $page_html .= '<h2 class="screen-reader-text">' .
192
+ __( 'Custom Permalink navigation', 'custom-permalinks' ) .
193
+ '</h2>';
194
 
195
  $total_pages = ceil( $count_tags / 20 );
196
+ if ( is_numeric( $get_paged ) && 0 < $get_paged ) {
197
  $pagination_html = $cp_pager->get_pagination(
198
  $count_tags, $get_paged, $total_pages
199
  );
269
  '</th>' .
270
  '<td><strong>' .
271
  '<a class="row-title" href="' . $site_url . '/wp-admin/edit-tags.php?action=edit&taxonomy=' . $type . '&tag_ID=' . $info['id'] . ' ">' .
272
+ $term->name .
273
  '</a>' .
274
  '</strong></td>' .
275
  '<td>' . ucwords( $info['kind'] ) . '</td>' .
276
  '<td>' .
277
  '<a href="' . $permalink . '" target="_blank" title="' . __( "Visit " . $term->name, "custom-permalinks" ) . '">' .
278
+ $perm_text .
279
  '</a>' .
280
  '</td>' .
281
  '</tr>';
282
  }
283
  } else {
284
  $page_html .= '<tr class="no-items">' .
285
+ '<td class="colspanchange" colspan="4">' .
286
+ __( 'No permalinks found.', 'custom-permalinks' ) .
287
+ '</td>' .
288
  '</tr>';
289
  }
290
  $page_html .= '</tbody>' .
293
 
294
  $page_html .= '<div class="tablenav bottom">' .
295
  '<div class="alignleft actions bulkactions">' .
296
+ '<label for="bulk-action-selector-bottom" class="screen-reader-text">' .
297
+ __( 'Select bulk action', 'custom-permalinks' ) .
298
+ '</label>' .
299
  '<select name="action2" id="bulk-action-selector-bottom">' .
300
+ '<option value="-1">' .
301
+ __( 'Bulk Actions', 'custom-permalinks' ) .
302
+ '</option>' .
303
+ '<option value="delete">' .
304
+ __( 'Delete Permalinks', 'custom-permalinks' ) .
305
+ '</option>' .
306
  '</select>' .
307
+ '<input type="submit" id="doaction2" class="button action" value="' . __( "Apply", "custom-permalinks" ) . '">' .
308
  '</div>' .
309
  $pagination_html .
310
  '</div>' .
admin/css/{about-plugins-1.6.2.min.css → about-plugins-1.7.0.min.css} RENAMED
File without changes
changelog.txt CHANGED
@@ -1,8 +1,40 @@
1
-
2
  == Changelog ==
3
 
4
  This file contains only old changelog. See readme.txt for newer versions.
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  = 1.2.22 - May 16, 2018 =
7
 
8
  * Enhancement
 
1
  == Changelog ==
2
 
3
  This file contains only old changelog. See readme.txt for newer versions.
4
 
5
+ = 1.5.1 - Jun 11, 2019 =
6
+
7
+ * Bug
8
+ * Added additional check for [Call to undefined function pll_current_language](https://wordpress.org/support/topic/call-to-undefined-function-pll_current_language/)
9
+
10
+ = 1.5.0 - Jun 04, 2019 =
11
+
12
+ * Bugs
13
+ * [Issue with Polylang Setting Hide Default Language](https://wordpress.org/support/topic/issue-with-polylang-setting-hide-default-language/)
14
+ * Change deprecated actions with appropriate actions
15
+
16
+ = 1.4.0 - Nov 08, 2018 =
17
+
18
+ * Enhancements
19
+ * Added Support for Gutenberg
20
+ * Set meta_keys to be protected to stop duplication in Custom Fields
21
+
22
+ = 1.3.0 - June 07, 2018 =
23
+
24
+ * Enhancements
25
+ * [Conflict with WPML](https://wordpress.org/support/topic/conflict-with-wpml-17/)
26
+ * Avoid appending slashes and use trailingslashit instead
27
+
28
+ = 1.2.24 - May 31, 2018 =
29
+
30
+ * Bug
31
+ * [FATAL ERROR when the administrator role not found](https://wordpress.org/support/topic/fatal-error-on-update-15/)
32
+
33
+ = 1.2.23 - May 22, 2018 =
34
+
35
+ * Enhancement
36
+ * Added Privacy Policy Content for WordPress 4.9.6 and higher.
37
+
38
  = 1.2.22 - May 16, 2018 =
39
 
40
  * Enhancement
custom-permalinks.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Custom Permalinks
4
  * Plugin URI: https://wordpress.org/plugins/custom-permalinks/
5
  * Description: Set custom permalinks on a per-post basis
6
- * Version: 1.6.2
7
  * Author: Sami Ahmed Siddiqui
8
  * Author URI: https://www.custompermalinks.com/
9
  * License: GPLv3
@@ -51,7 +51,7 @@ class Custom_Permalinks
51
  }
52
 
53
  if ( ! defined( 'CUSTOM_PERMALINKS_PLUGIN_VERSION' ) ) {
54
- define( 'CUSTOM_PERMALINKS_PLUGIN_VERSION', '1.6.2' );
55
  }
56
 
57
  if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
3
  * Plugin Name: Custom Permalinks
4
  * Plugin URI: https://wordpress.org/plugins/custom-permalinks/
5
  * Description: Set custom permalinks on a per-post basis
6
+ * Version: 1.7.0
7
  * Author: Sami Ahmed Siddiqui
8
  * Author URI: https://www.custompermalinks.com/
9
  * License: GPLv3
51
  }
52
 
53
  if ( ! defined( 'CUSTOM_PERMALINKS_PLUGIN_VERSION' ) ) {
54
+ define( 'CUSTOM_PERMALINKS_PLUGIN_VERSION', '1.7.0' );
55
  }
56
 
57
  if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
frontend/class-custom-permalinks-form.php CHANGED
@@ -63,6 +63,11 @@ class Custom_Permalinks_Form
63
  $exclude_post_types = apply_filters( 'custom_permalinks_exclude_post_type',
64
  $post->post_type
65
  );
 
 
 
 
 
66
  $exclude_posts = apply_filters( 'custom_permalinks_exclude_posts',
67
  $post
68
  );
@@ -72,7 +77,7 @@ class Custom_Permalinks_Form
72
  $check_availability = true;
73
  } elseif ( 'attachment' === $post->post_type ) {
74
  $check_availability = true;
75
- } elseif ( $post->ID === intval( get_option( 'page_on_front' ) ) ) {
76
  $check_availability = true;
77
  } elseif ( ! isset( $public_post_types[$post->post_type] ) ) {
78
  $check_availability = true;
@@ -96,7 +101,7 @@ class Custom_Permalinks_Form
96
  public function permalink_edit_box()
97
  {
98
  add_meta_box( 'custom-permalinks-edit-box',
99
- __( 'Permalink', 'custom-permalinks' ),
100
  array( $this, 'meta_edit_form' ), null, 'normal', 'high',
101
  array(
102
  '__back_compat_meta_box' => false,
@@ -137,18 +142,55 @@ class Custom_Permalinks_Form
137
  return;
138
  }
139
 
140
- $this->delete_permalink( $post_id );
141
-
142
  $cp_frontend = new Custom_Permalinks_Frontend();
143
  $original_link = $cp_frontend->original_post_link( $post_id );
144
- if ( $_REQUEST['custom_permalink']
 
145
  && $_REQUEST['custom_permalink'] != $original_link
146
  ) {
147
- add_post_meta( $post_id, 'custom_permalink',
148
- str_replace( '%2F', '/', urlencode(
149
- ltrim( stripcslashes( $_REQUEST['custom_permalink'] ), '/' )
150
- ) )
 
151
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  }
153
  }
154
 
@@ -161,7 +203,7 @@ class Custom_Permalinks_Form
161
  */
162
  public function delete_permalink( $post_id )
163
  {
164
- delete_post_meta( $post_id, 'custom_permalink' );
165
  }
166
 
167
  /**
@@ -236,7 +278,7 @@ class Custom_Permalinks_Form
236
  }
237
 
238
  $content .= ' <span id="view-post-btn">' .
239
- '<a href="' . $view_post_link . '" class="button button-small" target="_blank">' . $view_post .'</a>' .
240
  '</span><br>';
241
  if ( true === $meta_box ) {
242
  $content .= '<style>.editor-post-permalink,.cp-permalink-hidden{display:none;}</style>';
@@ -261,7 +303,7 @@ class Custom_Permalinks_Form
261
  $post = get_post( $post_id );
262
 
263
  $disable_cp = $this->exclude_custom_permalinks( $post );
264
- $this->permalink_metabox = 1;
265
  if ( $disable_cp ) {
266
  return $html;
267
  }
@@ -467,7 +509,9 @@ class Custom_Permalinks_Form
467
 
468
  if ( $render_containers ) {
469
  echo '<br />' .
470
- '<small>' . __( "Leave blank to disable", "custom-permalinks" ) . '</small>' .
 
 
471
  '</td>' .
472
  '</tr>' .
473
  '</table>';
@@ -485,7 +529,9 @@ class Custom_Permalinks_Form
485
  public function save_term( $term_id )
486
  {
487
  $term = get_term( $term_id );
488
- if ( isset( $term ) && isset( $term->taxonomy ) ) {
 
 
489
  $taxonomy_name = $term->taxonomy;
490
  if ( 'category' === $taxonomy_name
491
  || 'post_tag' === $taxonomy_name
63
  $exclude_post_types = apply_filters( 'custom_permalinks_exclude_post_type',
64
  $post->post_type
65
  );
66
+ /*
67
+ * Exclude custom permalink `form` from any post(s) if filter returns `true`.
68
+ *
69
+ * @since 1.6.0
70
+ */
71
  $exclude_posts = apply_filters( 'custom_permalinks_exclude_posts',
72
  $post
73
  );
77
  $check_availability = true;
78
  } elseif ( 'attachment' === $post->post_type ) {
79
  $check_availability = true;
80
+ } elseif ( $post->ID == get_option( 'page_on_front' ) ) {
81
  $check_availability = true;
82
  } elseif ( ! isset( $public_post_types[$post->post_type] ) ) {
83
  $check_availability = true;
101
  public function permalink_edit_box()
102
  {
103
  add_meta_box( 'custom-permalinks-edit-box',
104
+ __( 'Custom Permalinks', 'custom-permalinks' ),
105
  array( $this, 'meta_edit_form' ), null, 'normal', 'high',
106
  array(
107
  '__back_compat_meta_box' => false,
142
  return;
143
  }
144
 
 
 
145
  $cp_frontend = new Custom_Permalinks_Frontend();
146
  $original_link = $cp_frontend->original_post_link( $post_id );
147
+
148
+ if ( isset( $_REQUEST['custom_permalink'] )
149
  && $_REQUEST['custom_permalink'] != $original_link
150
  ) {
151
+ $reserved_chars = array(
152
+ '(',
153
+ ')',
154
+ '[',
155
+ ']',
156
  );
157
+
158
+ $unsafe_chars = array(
159
+ '<',
160
+ '>',
161
+ '{',
162
+ '}',
163
+ '|',
164
+ '`',
165
+ '^',
166
+ '\\',
167
+ );
168
+
169
+ $permalink = $_REQUEST['custom_permalink'];
170
+ $permalink = ltrim( $permalink, '/' );
171
+ $permalink = strtolower( $permalink );
172
+ $permalink = str_replace( $reserved_chars, '', $permalink );
173
+ $permalink = str_replace( $unsafe_chars, '', $permalink );
174
+ $permalink = urlencode( $permalink );
175
+ // Replace encoded slash input with slash
176
+ $permalink = str_replace( '%2F', '/', $permalink );
177
+
178
+ $replace_hyphen = array( '%20', '%2B', '+' );
179
+ $split_path = explode( '%3F', $permalink );
180
+ if ( 1 < count( $split_path ) ) {
181
+ // Replace encoded space and plus input with hyphen
182
+ $replaced_path = str_replace( $replace_hyphen, '-', $split_path[0] );
183
+ $replaced_path = preg_replace( '/(\-+)/', '-', $replaced_path );
184
+ $permalink = str_replace( $split_path[0], $replaced_path,
185
+ $permalink
186
+ );
187
+ } else {
188
+ // Replace encoded space and plus input with hyphen
189
+ $permalink = str_replace( $replace_hyphen, '-', $permalink );
190
+ $permalink = preg_replace( '/(\-+)/', '-', $permalink );
191
+ }
192
+
193
+ update_post_meta( $post_id, 'custom_permalink', $permalink );
194
  }
195
  }
196
 
203
  */
204
  public function delete_permalink( $post_id )
205
  {
206
+ delete_metadata( 'post', $post_id, 'custom_permalink' );
207
  }
208
 
209
  /**
278
  }
279
 
280
  $content .= ' <span id="view-post-btn">' .
281
+ '<a href="' . $view_post_link . '" class="button button-medium" target="_blank">' . $view_post .'</a>' .
282
  '</span><br>';
283
  if ( true === $meta_box ) {
284
  $content .= '<style>.editor-post-permalink,.cp-permalink-hidden{display:none;}</style>';
303
  $post = get_post( $post_id );
304
 
305
  $disable_cp = $this->exclude_custom_permalinks( $post );
306
+ $this->permalink_metabox = 1;
307
  if ( $disable_cp ) {
308
  return $html;
309
  }
509
 
510
  if ( $render_containers ) {
511
  echo '<br />' .
512
+ '<small>' .
513
+ __( 'Leave blank to disable', 'custom-permalinks' ) .
514
+ '</small>' .
515
  '</td>' .
516
  '</tr>' .
517
  '</table>';
529
  public function save_term( $term_id )
530
  {
531
  $term = get_term( $term_id );
532
+ if ( isset( $_REQUEST['custom_permalink'] ) && isset( $term )
533
+ && isset( $term->taxonomy )
534
+ ) {
535
  $taxonomy_name = $term->taxonomy;
536
  if ( 'category' === $taxonomy_name
537
  || 'post_tag' === $taxonomy_name
frontend/class-custom-permalinks-frontend.php CHANGED
@@ -125,6 +125,12 @@ class Custom_Permalinks_Frontend
125
  global $wpdb;
126
  global $_CPRegisteredURL;
127
 
 
 
 
 
 
 
128
  /*
129
  * First, search for a matching custom permalink, and if found
130
  * generate the corresponding original URL
@@ -195,15 +201,15 @@ class Custom_Permalinks_Frontend
195
  $_CPRegisteredURL = $request;
196
  }
197
 
198
- if ( 'draft' == $posts[0]->post_status ) {
199
- if ( 'page' == $posts[0]->post_type ) {
200
  $original_url = '?page_id=' . $posts[0]->ID;
201
  } else {
202
  $original_url = '?post_type=' . $posts[0]->post_type . '&p=' . $posts[0]->ID;
203
  }
204
  } else {
205
  $post_meta = trim( strtolower( $posts[0]->meta_value ), '/' );
206
- if ( $posts[0]->post_type == 'page' ) {
207
  $get_original_url = $this->original_page_link( $posts[0]->ID );
208
  $original_url = preg_replace( '@/+@', '/',
209
  str_replace( $post_meta, $get_original_url,
@@ -319,6 +325,12 @@ class Custom_Permalinks_Frontend
319
  {
320
  global $wpdb;
321
 
 
 
 
 
 
 
322
  $custom_permalink = '';
323
  $original_permalink = '';
324
 
@@ -331,6 +343,19 @@ class Custom_Permalinks_Frontend
331
  $request = substr( $request, 0, $pos );
332
  }
333
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  if ( defined( 'POLYLANG_VERSION' ) ) {
335
  $cp_file_path = CUSTOM_PERMALINKS_PATH;
336
  $cp_file_path .= 'frontend/class-custom-permalinks-form.php';
@@ -595,8 +620,8 @@ class Custom_Permalinks_Frontend
595
  */
596
  public function original_post_link( $post_id )
597
  {
598
- remove_filter( 'post_link', array( $this, 'custom_post_link' ), 10, 3 );
599
- remove_filter( 'post_type_link', array( $this, 'custom_post_link' ), 10, 2 );
600
 
601
  $post_file_path = ABSPATH . '/wp-admin/includes/post.php';
602
  require_once $post_file_path;
@@ -625,7 +650,7 @@ class Custom_Permalinks_Frontend
625
  */
626
  public function original_page_link( $post_id )
627
  {
628
- remove_filter( 'page_link', array( $this, 'custom_page_link' ), 10, 2 );
629
  remove_filter( 'user_trailingslashit',
630
  array( $this, 'custom_trailingslash' )
631
  );
@@ -658,7 +683,7 @@ class Custom_Permalinks_Frontend
658
  */
659
  public function original_term_link( $term_id )
660
  {
661
- remove_filter( 'term_link', array( $this, 'custom_term_link' ), 10, 2 );
662
  remove_filter( 'user_trailingslashit',
663
  array( $this, 'custom_trailingslash' )
664
  );
125
  global $wpdb;
126
  global $_CPRegisteredURL;
127
 
128
+ if ( isset( $_SERVER['REQUEST_URI'] )
129
+ && $_SERVER['REQUEST_URI'] !== $this->request_uri
130
+ ) {
131
+ $this->request_uri = $_SERVER['REQUEST_URI'];
132
+ }
133
+
134
  /*
135
  * First, search for a matching custom permalink, and if found
136
  * generate the corresponding original URL
201
  $_CPRegisteredURL = $request;
202
  }
203
 
204
+ if ( 'draft' === $posts[0]->post_status ) {
205
+ if ( 'page' === $posts[0]->post_type ) {
206
  $original_url = '?page_id=' . $posts[0]->ID;
207
  } else {
208
  $original_url = '?post_type=' . $posts[0]->post_type . '&p=' . $posts[0]->ID;
209
  }
210
  } else {
211
  $post_meta = trim( strtolower( $posts[0]->meta_value ), '/' );
212
+ if ( 'page' === $posts[0]->post_type ) {
213
  $get_original_url = $this->original_page_link( $posts[0]->ID );
214
  $original_url = preg_replace( '@/+@', '/',
215
  str_replace( $post_meta, $get_original_url,
325
  {
326
  global $wpdb;
327
 
328
+ if ( isset( $_SERVER['REQUEST_URI'] )
329
+ && $_SERVER['REQUEST_URI'] !== $this->request_uri
330
+ ) {
331
+ $this->request_uri = $_SERVER['REQUEST_URI'];
332
+ }
333
+
334
  $custom_permalink = '';
335
  $original_permalink = '';
336
 
343
  $request = substr( $request, 0, $pos );
344
  }
345
 
346
+ /*
347
+ * Disable redirects to be processed if filter returns `true`.
348
+ *
349
+ * @since 1.7.0
350
+ */
351
+ $avoid_redirect = apply_filters( 'custom_permalinks_avoid_redirect',
352
+ $request
353
+ );
354
+
355
+ if ( is_bool( $avoid_redirect ) && $avoid_redirect ) {
356
+ return;
357
+ }
358
+
359
  if ( defined( 'POLYLANG_VERSION' ) ) {
360
  $cp_file_path = CUSTOM_PERMALINKS_PATH;
361
  $cp_file_path .= 'frontend/class-custom-permalinks-form.php';
620
  */
621
  public function original_post_link( $post_id )
622
  {
623
+ remove_filter( 'post_link', array( $this, 'custom_post_link' ) );
624
+ remove_filter( 'post_type_link', array( $this, 'custom_post_link' ) );
625
 
626
  $post_file_path = ABSPATH . '/wp-admin/includes/post.php';
627
  require_once $post_file_path;
650
  */
651
  public function original_page_link( $post_id )
652
  {
653
+ remove_filter( 'page_link', array( $this, 'custom_page_link' ) );
654
  remove_filter( 'user_trailingslashit',
655
  array( $this, 'custom_trailingslash' )
656
  );
683
  */
684
  public function original_term_link( $term_id )
685
  {
686
+ remove_filter( 'term_link', array( $this, 'custom_term_link' ) );
687
  remove_filter( 'user_trailingslashit',
688
  array( $this, 'custom_trailingslash' )
689
  );
frontend/js/{script-form-1.6.2.min.js → script-form-1.7.0.min.js} RENAMED
File without changes
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: sasiddiqui, michaeltyson
3
  Tags: permalink, url, link, address, custom, redirect, custom post type, GDPR, GDPR Compliant
4
  Requires at least: 2.6
5
- Tested up to: 5.4
6
- Stable tag: 1.6.2
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl.html
9
 
@@ -11,7 +11,7 @@ Set custom permalinks on a per-post, per-tag or per-category basis.
11
 
12
  == Description ==
13
 
14
- Lay out your site the way *you* want it. Set the URL of any post, page, tag or category to anything you want. Old permalinks will redirect properly to the new address. Custom Permalinks gives you ultimate control over your site structure.
15
 
16
  > Be warned: *This plugin is not a replacement for WordPress's built-in permalink system*. Check your WordPress administration's "Permalinks" settings page first, to make sure that this doesn't already meet your needs.
17
 
@@ -19,6 +19,25 @@ This plugin is only useful for assigning custom permalinks for *individual* post
19
 
20
  > If anyone wants the different Structure Tags for their Post types or use symbols in the URLs So, use the [Permalinks Customizer](https://wordpress.org/plugins/permalinks-customizer/) which is a fork of this plugin and contains the enhancement of this plugin.
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  == Privacy Policy ==
23
 
24
  This plugin only collects the following information.
@@ -35,9 +54,45 @@ To have any kind of query please feel free to [contact us](https://www.customper
35
 
36
  == Filters ==
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  === Exclude permalink to be processed ===
39
 
40
- To exclude any Permalink to be processed with the plugin, add the filter looks like this:
 
41
  `
42
  function yasglobal_xml_sitemap_url( $permalink )
43
  {
@@ -50,12 +105,14 @@ function yasglobal_xml_sitemap_url( $permalink )
50
  add_filter( 'custom_permalinks_request_ignore', 'yasglobal_xml_sitemap_url' );
51
  `
52
 
53
- === Exclude PostType ===
 
 
54
 
55
- To exclude permalink from any post type so, just add the filter looks like this:
56
  `
57
  function yasglobal_exclude_post_types( $post_type )
58
  {
 
59
  if ( 'custompost' === $post_type ) {
60
  return '__true';
61
  }
@@ -65,11 +122,10 @@ function yasglobal_exclude_post_types( $post_type )
65
  add_filter( 'custom_permalinks_exclude_post_type', 'yasglobal_exclude_post_types' );
66
  `
67
 
68
- Note: `custom_permalinks_exclude_post_type` doesn't work on the posts permalink which has been created previously.
69
-
70
  === Exclude Posts ===
71
 
72
- To exclude permalink from any posts (based on ID, Template, etc), just add the filter looks like this:
 
73
  `
74
  function yasglobal_exclude_posts( $post )
75
  {
@@ -82,8 +138,6 @@ function yasglobal_exclude_posts( $post )
82
  add_filter( 'custom_permalinks_exclude_posts', 'yasglobal_exclude_posts' );
83
  `
84
 
85
- Note: `custom_permalinks_exclude_posts` doesn't wor k on the posts permalink which has been created previously.
86
-
87
  === Remove `like` query ===
88
 
89
  To remove `like` query to being work, add below-mentioned line in your theme `functions.php`:
@@ -93,12 +147,6 @@ add_filter( 'cp_remove_like_query', '__return_false' );
93
 
94
  Note: Use `custom_permalinks_like_query` filter if the URLs doesn't works for you after upgrading to `v1.2.9`.
95
 
96
- === Add `PATH_INFO` in `$_SERVER` Variable ===
97
-
98
- `
99
- add_filter( 'custom_permalinks_path_info', '__return_true' );
100
- `
101
-
102
  === Thanks for the Support ===
103
 
104
  I do not always provide active support for the Custom Permalinks plugin on the WordPress.org forums, as I have prioritized the email support.
@@ -125,6 +173,18 @@ This process defines you the steps to follow either you are installing through W
125
 
126
  == Changelog ==
127
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  = 1.6.2 - Aug 10, 2020 =
129
 
130
  * Bugs
@@ -153,39 +213,6 @@ This process defines you the steps to follow either you are installing through W
153
  * Add filter to exclude Custom Permalinks for certain posts (based on Post IDs, template, etc)
154
  * Optimized Code
155
 
156
- = 1.5.1 - Jun 11, 2019 =
157
-
158
- * Bug
159
- * Added additional check for [Call to undefined function pll_current_language](https://wordpress.org/support/topic/call-to-undefined-function-pll_current_language/)
160
-
161
- = 1.5.0 - Jun 04, 2019 =
162
-
163
- * Bugs
164
- * [Issue with Polylang Setting Hide Default Language](https://wordpress.org/support/topic/issue-with-polylang-setting-hide-default-language/)
165
- * Change deprecated actions with appropriate actions
166
-
167
- = 1.4.0 - Nov 08, 2018 =
168
-
169
- * Enhancements
170
- * Added Support for Gutenberg
171
- * Set meta_keys to be protected to stop duplication in Custom Fields
172
-
173
- = 1.3.0 - June 07, 2018 =
174
-
175
- * Enhancements
176
- * [Conflict with WPML](https://wordpress.org/support/topic/conflict-with-wpml-17/)
177
- * Avoid appending slashes and use trailingslashit instead
178
-
179
- = 1.2.24 - May 31, 2018 =
180
-
181
- * Bug
182
- * [FATAL ERROR when the administrator role not found](https://wordpress.org/support/topic/fatal-error-on-update-15/)
183
-
184
- = 1.2.23 - May 22, 2018 =
185
-
186
- * Enhancement
187
- * Added Privacy Policy Content for WordPress 4.9.6 and higher.
188
-
189
  = Earlier versions =
190
 
191
  * For the changelog of earlier versions, please refer to the separate changelog.txt file.
2
  Contributors: sasiddiqui, michaeltyson
3
  Tags: permalink, url, link, address, custom, redirect, custom post type, GDPR, GDPR Compliant
4
  Requires at least: 2.6
5
+ Tested up to: 5.5
6
+ Stable tag: 1.7.0
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl.html
9
 
11
 
12
  == Description ==
13
 
14
+ Lay out your site the way *you* want it. Set the URL of any post, page, tag or category to anything you want. Old permalinks will redirect properly to the new address. Custom Permalinks give you ultimate control over your site structure.
15
 
16
  > Be warned: *This plugin is not a replacement for WordPress's built-in permalink system*. Check your WordPress administration's "Permalinks" settings page first, to make sure that this doesn't already meet your needs.
17
 
19
 
20
  > If anyone wants the different Structure Tags for their Post types or use symbols in the URLs So, use the [Permalinks Customizer](https://wordpress.org/plugins/permalinks-customizer/) which is a fork of this plugin and contains the enhancement of this plugin.
21
 
22
+ === Unsupported Characters ===
23
+
24
+ Following characters are no longer allowed in the permalinks.
25
+
26
+ * `<`
27
+ * `>`
28
+ * `{`
29
+ * `}`
30
+ * `|`
31
+ * <code>`</code>
32
+ * `^`
33
+ * `\`
34
+ * `(`
35
+ * `)`
36
+ * `[`
37
+ * `]`
38
+
39
+ > Permalinks created previously using any of these characters will not be affected in anyway. However, new permalinks will not support the use of these characters as they are not considered to be safe.
40
+
41
  == Privacy Policy ==
42
 
43
  This plugin only collects the following information.
54
 
55
  == Filters ==
56
 
57
+ === Add `PATH_INFO` in `$_SERVER` Variable ===
58
+
59
+ `
60
+ add_filter( 'custom_permalinks_path_info', '__return_true' );
61
+ `
62
+
63
+ === Disable redirects ===
64
+
65
+ To disable complete redirects functionality provided by this plugin, add the filter that looks like this:
66
+
67
+ `
68
+ function yasglobal_avoid_redirect( $permalink )
69
+ {
70
+ return true;
71
+ }
72
+ add_filter( 'custom_permalinks_avoid_redirect', 'yasglobal_avoid_redirect' );
73
+ `
74
+
75
+ === Disable specific redirects ===
76
+
77
+ To disable any specific redirect to be processed by this plugin, add the filter that looks like this:
78
+
79
+ `
80
+ function yasglobal_avoid_redirect( $permalink )
81
+ {
82
+ // Replace 'testing-hello-world/' with the permalink you want to avoid
83
+ if ( 'testing-hello-world/' === $permalink ) {
84
+ return true;
85
+ }
86
+
87
+ return false;
88
+ }
89
+ add_filter( 'custom_permalinks_avoid_redirect', 'yasglobal_avoid_redirect' );
90
+ `
91
+
92
  === Exclude permalink to be processed ===
93
 
94
+ To exclude any Permalink to be processed by the plugin, add the filter that looks like this:
95
+
96
  `
97
  function yasglobal_xml_sitemap_url( $permalink )
98
  {
105
  add_filter( 'custom_permalinks_request_ignore', 'yasglobal_xml_sitemap_url' );
106
  `
107
 
108
+ === Exclude Post Type ===
109
+
110
+ To remove custom permalink **form** from any post type, add the filter that looks like this:
111
 
 
112
  `
113
  function yasglobal_exclude_post_types( $post_type )
114
  {
115
+ // Replace 'custompost' with your post type name
116
  if ( 'custompost' === $post_type ) {
117
  return '__true';
118
  }
122
  add_filter( 'custom_permalinks_exclude_post_type', 'yasglobal_exclude_post_types' );
123
  `
124
 
 
 
125
  === Exclude Posts ===
126
 
127
+ To exclude custom permalink **form** from any posts (based on ID, Template, etc), add the filter that looks like this:
128
+
129
  `
130
  function yasglobal_exclude_posts( $post )
131
  {
138
  add_filter( 'custom_permalinks_exclude_posts', 'yasglobal_exclude_posts' );
139
  `
140
 
 
 
141
  === Remove `like` query ===
142
 
143
  To remove `like` query to being work, add below-mentioned line in your theme `functions.php`:
147
 
148
  Note: Use `custom_permalinks_like_query` filter if the URLs doesn't works for you after upgrading to `v1.2.9`.
149
 
 
 
 
 
 
 
150
  === Thanks for the Support ===
151
 
152
  I do not always provide active support for the Custom Permalinks plugin on the WordPress.org forums, as I have prioritized the email support.
173
 
174
  == Changelog ==
175
 
176
+ = 1.7.0 - Aug 20, 2020 =
177
+
178
+ * Bugs
179
+ * [Paged NextGen Galleries Broken with Custom Permalinks 1.62](https://github.com/samiahmedsiddiqui/custom-permalinks/issues/38)
180
+ * [custom permalink issue with weglot](https://wordpress.org/support/topic/custom-permalink-issue-with-weglot/)
181
+ * [Permalinks reverting back to old ones](https://wordpress.org/support/topic/permalinks-reverting-back-to-old-ones/)
182
+ * [A problem with wrongly deleted permalinks](https://wordpress.org/support/topic/a-problem-with-wrongly-deleted-permalinks/)
183
+ * Enhancements
184
+ * [Enhanced security through characters restriction](https://github.com/samiahmedsiddiqui/custom-permalinks#unsupported-characters)
185
+ * Introduce filter to disable specific redirect(s) or complete functionality
186
+ * Automatic replacement of upper case letters to lower case
187
+
188
  = 1.6.2 - Aug 10, 2020 =
189
 
190
  * Bugs
213
  * Add filter to exclude Custom Permalinks for certain posts (based on Post IDs, template, etc)
214
  * Optimized Code
215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  = Earlier versions =
217
 
218
  * For the changelog of earlier versions, please refer to the separate changelog.txt file.