Custom Permalinks - Version 1.6.1

Version Description

  • Aug 10, 2020 =

    • Bugs
    • Avoid caching issue by adding version as suffix in CSS and JS files
Download this release

Release Info

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

Code changes from version 1.6.0 to 1.6.1

admin/class-custom-permalinks-about.php CHANGED
@@ -5,6 +5,10 @@
5
 
6
  class Custom_Permalinks_About
7
  {
 
 
 
 
8
 
9
  /**
10
  * Class constructor.
@@ -22,9 +26,10 @@ class Custom_Permalinks_About
22
  */
23
  private function more_plugins()
24
  {
 
25
  $plugin_url = plugins_url( '/admin', CUSTOM_PERMALINKS_FILE );
26
  $img_src = $plugin_url . '/images';
27
- wp_enqueue_style( 'style', $plugin_url . '/css/about-plugins.min.css' );
28
 
29
  $fivestar = '<span class="star">
30
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
5
 
6
  class Custom_Permalinks_About
7
  {
8
+ /*
9
+ * Css file suffix (version number with with extension)
10
+ */
11
+ private $css_file_suffix = '-' . CUSTOM_PERMALINKS_PLUGIN_VERSION . '.min.css';
12
 
13
  /**
14
  * Class constructor.
26
  */
27
  private function more_plugins()
28
  {
29
+ $filename = 'about-plugins' . $this->css_file_suffix;
30
  $plugin_url = plugins_url( '/admin', CUSTOM_PERMALINKS_FILE );
31
  $img_src = $plugin_url . '/images';
32
+ wp_enqueue_style( 'style', $plugin_url . '/css/' . $filename );
33
 
34
  $fivestar = '<span class="star">
35
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 53.867 53.867" width="15" height="15">
admin/class-custom-permalinks-updates.php CHANGED
@@ -6,23 +6,31 @@
6
  class Custom_Permalinks_Updates
7
  {
8
 
 
 
 
 
 
9
  /**
10
  * Initializes WordPress hooks.
11
  */
12
- function __construct()
13
  {
 
 
 
14
  $this->update_version_details();
15
  }
16
 
17
  /**
18
  * Fetch site details and sent it to CP.
19
  *
20
- * @since 2.0.0
21
  * @access private
22
  */
23
  private function update_version_details()
24
  {
25
- if ( function_exists( 'curl_init' ) === true ) {
26
  $admin_email = get_bloginfo( 'admin_email' );
27
  $curl_url = 'https://www.custompermalinks.com/plugin-update/';
28
  $site_name = get_bloginfo( 'name' );
@@ -30,7 +38,7 @@ class Custom_Permalinks_Updates
30
  $wp_version = get_bloginfo( 'version' );
31
 
32
  $updates = array(
33
- 'action' => 'install',
34
  'admin_email' => $admin_email,
35
  'plugin_version' => CUSTOM_PERMALINKS_PLUGIN_VERSION,
36
  'site_name' => $site_name,
6
  class Custom_Permalinks_Updates
7
  {
8
 
9
+ /*
10
+ * Check Whether Plugin gets activated or deactived.
11
+ */
12
+ private $method = 'install';
13
+
14
  /**
15
  * Initializes WordPress hooks.
16
  */
17
+ function __construct( $action )
18
  {
19
+ if ( $action && 'deactivate' === $action) {
20
+ $this->method = 'uninstall';
21
+ }
22
  $this->update_version_details();
23
  }
24
 
25
  /**
26
  * Fetch site details and sent it to CP.
27
  *
28
+ * @since 1.6.0
29
  * @access private
30
  */
31
  private function update_version_details()
32
  {
33
+ if ( true === function_exists( 'curl_init' ) ) {
34
  $admin_email = get_bloginfo( 'admin_email' );
35
  $curl_url = 'https://www.custompermalinks.com/plugin-update/';
36
  $site_name = get_bloginfo( 'name' );
38
  $wp_version = get_bloginfo( 'version' );
39
 
40
  $updates = array(
41
+ 'action' => $this->method,
42
  'admin_email' => $admin_email,
43
  'plugin_version' => CUSTOM_PERMALINKS_PLUGIN_VERSION,
44
  'site_name' => $site_name,
admin/css/{about-plugins.min.css → about-plugins-1.6.0.min.css} RENAMED
File without changes
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.0
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.0' );
55
  }
56
 
57
  if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
@@ -95,20 +95,27 @@ class Custom_Permalinks
95
  new Custom_Permalinks_Admin();
96
 
97
  register_activation_hook( CUSTOM_PERMALINKS_FILE,
98
- array( 'Custom_Permalinks', 'add_role_and_update_details' )
 
 
 
 
 
 
 
 
99
  );
100
  }
101
  }
102
 
103
  /**
104
  * Add role for the view post and category permalinks and by default assign
105
- * it to the administrator if administrator role exist. Also, update details
106
- * when plugin gets updated.
107
  *
108
  * @since 1.2.22
109
  * @access public
110
  */
111
- public static function add_role_and_update_details()
112
  {
113
  $admin_role = get_role( 'administrator' );
114
  $cp_role = get_role( 'custom_permalinks_manager' );
@@ -127,28 +134,35 @@ class Custom_Permalinks
127
  )
128
  );
129
  }
 
130
 
131
- if ( -1 === $current_version
132
- || $current_version < CUSTOM_PERMALINKS_PLUGIN_VERSION
133
- ) {
134
- Custom_Permalinks::update_details();
 
 
 
 
 
 
 
135
 
136
- update_option( 'custom_permalinks_plugin_version',
137
- CUSTOM_PERMALINKS_PLUGIN_VERSION
138
- );
139
- }
140
  }
141
 
142
  /**
143
- * Loads the plugin language files.
144
  *
145
- * @since 1.2.18
146
  * @access public
147
  */
148
- public function update_details()
149
  {
150
  require_once CUSTOM_PERMALINKS_PATH . 'admin/class-custom-permalinks-updates.php';
151
- new Custom_Permalinks_Updates();
152
  }
153
 
154
  /**
@@ -162,19 +176,13 @@ class Custom_Permalinks
162
  public function check_loaded_plugins()
163
  {
164
  if ( is_admin() ) {
165
- $cp_role = get_role( 'custom_permalinks_manager' );
166
  $current_version = get_option( 'custom_permalinks_plugin_version', -1 );
167
 
168
- if ( empty( $cp_role ) ) {
169
- Custom_Permalinks::add_role_and_update_details();
170
- } elseif ( -1 === $current_version
171
  || $current_version < CUSTOM_PERMALINKS_PLUGIN_VERSION
172
  ) {
173
- Custom_Permalinks::update_details();
174
-
175
- update_option( 'custom_permalinks_plugin_version',
176
- CUSTOM_PERMALINKS_PLUGIN_VERSION
177
- );
178
  }
179
  }
180
 
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.1
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.6.1' );
55
  }
56
 
57
  if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
95
  new Custom_Permalinks_Admin();
96
 
97
  register_activation_hook( CUSTOM_PERMALINKS_FILE,
98
+ array( 'Custom_Permalinks', 'add_roles' )
99
+ );
100
+
101
+ register_activation_hook( CUSTOM_PERMALINKS_FILE,
102
+ array( 'Custom_Permalinks', 'activate_details' )
103
+ );
104
+
105
+ register_deactivation_hook( CUSTOM_PERMALINKS_FILE,
106
+ array( 'Custom_Permalinks', 'deactivate_details' )
107
  );
108
  }
109
  }
110
 
111
  /**
112
  * Add role for the view post and category permalinks and by default assign
113
+ * it to the administrator if administrator role exist.
 
114
  *
115
  * @since 1.2.22
116
  * @access public
117
  */
118
+ public static function add_roles()
119
  {
120
  $admin_role = get_role( 'administrator' );
121
  $cp_role = get_role( 'custom_permalinks_manager' );
134
  )
135
  );
136
  }
137
+ }
138
 
139
+ /**
140
+ * Sent details when plugin gets activated / updated ans set installed
141
+ * version in options table.
142
+ *
143
+ * @since 1.6.1
144
+ * @access public
145
+ */
146
+ public static function activate_details()
147
+ {
148
+ require_once CUSTOM_PERMALINKS_PATH . 'admin/class-custom-permalinks-updates.php';
149
+ new Custom_Permalinks_Updates( 'activate' );
150
 
151
+ update_option( 'custom_permalinks_plugin_version',
152
+ CUSTOM_PERMALINKS_PLUGIN_VERSION
153
+ );
 
154
  }
155
 
156
  /**
157
+ * Sent details when plugin gets deactivated.
158
  *
159
+ * @since 1.6.1
160
  * @access public
161
  */
162
+ public function deactivate_details()
163
  {
164
  require_once CUSTOM_PERMALINKS_PATH . 'admin/class-custom-permalinks-updates.php';
165
+ new Custom_Permalinks_Updates( 'deactivate' );
166
  }
167
 
168
  /**
176
  public function check_loaded_plugins()
177
  {
178
  if ( is_admin() ) {
 
179
  $current_version = get_option( 'custom_permalinks_plugin_version', -1 );
180
 
181
+ if ( -1 === $current_version
 
 
182
  || $current_version < CUSTOM_PERMALINKS_PLUGIN_VERSION
183
  ) {
184
+ Custom_Permalinks::activate_details();
185
+ Custom_Permalinks::add_roles();
 
 
 
186
  }
187
  }
188
 
frontend/class-custom-permalinks-form.php CHANGED
@@ -6,6 +6,11 @@
6
  class Custom_Permalinks_Form
7
  {
8
 
 
 
 
 
 
9
  /*
10
  * Decide whether to show metabox or override WordPress default Permalink box.
11
  */
@@ -206,8 +211,8 @@ class Custom_Permalinks_Form
206
 
207
  if ( 'trash' !== $post->post_status ) {
208
  wp_enqueue_script( 'custom-permalinks-form',
209
- plugins_url( '/js/script-form.min.js', __FILE__ ), array(),
210
- false, true
211
  );
212
 
213
  $home_url = trailingslashit( home_url() );
@@ -279,8 +284,8 @@ class Custom_Permalinks_Form
279
  $disable_cp = $this->exclude_custom_permalinks( $post );
280
  if ( $disable_cp ) {
281
  wp_enqueue_script( 'custom-permalinks-form',
282
- plugins_url( '/js/script-form.min.js', __FILE__ ), array(),
283
- false, true
284
  );
285
 
286
  return;
@@ -440,7 +445,8 @@ class Custom_Permalinks_Form
440
  }
441
 
442
  wp_enqueue_script( 'custom-permalinks-form',
443
- plugins_url( '/js/script-form.min.js', __FILE__ ), array(), false, true
 
444
  );
445
  $postname_html = '';
446
  if ( isset( $postname ) && '' !== $postname ) {
6
  class Custom_Permalinks_Form
7
  {
8
 
9
+ /*
10
+ * JS file suffix (version number with with extension)
11
+ */
12
+ private $js_file_suffix = '-' . CUSTOM_PERMALINKS_PLUGIN_VERSION . '.min.js';
13
+
14
  /*
15
  * Decide whether to show metabox or override WordPress default Permalink box.
16
  */
211
 
212
  if ( 'trash' !== $post->post_status ) {
213
  wp_enqueue_script( 'custom-permalinks-form',
214
+ plugins_url( '/js/script-form' . $this->js_file_suffix, __FILE__ ),
215
+ array(), false, true
216
  );
217
 
218
  $home_url = trailingslashit( home_url() );
284
  $disable_cp = $this->exclude_custom_permalinks( $post );
285
  if ( $disable_cp ) {
286
  wp_enqueue_script( 'custom-permalinks-form',
287
+ plugins_url( '/js/script-form' . $this->js_file_suffix, __FILE__ ),
288
+ array(), false, true
289
  );
290
 
291
  return;
445
  }
446
 
447
  wp_enqueue_script( 'custom-permalinks-form',
448
+ plugins_url( '/js/script-form' . $this->js_file_suffix, __FILE__ ),
449
+ array(), false, true
450
  );
451
  $postname_html = '';
452
  if ( isset( $postname ) && '' !== $postname ) {
frontend/js/{script-form.min.js → script-form-1.6.0.min.js} RENAMED
File without changes
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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.0
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl.html
9
 
@@ -125,6 +125,11 @@ This process defines you the steps to follow either you are installing through W
125
 
126
  == Changelog ==
127
 
 
 
 
 
 
128
  = 1.6.0 - Aug 08, 2020 =
129
 
130
  * Bugs
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.1
7
  License: GPLv3
8
  License URI: https://www.gnu.org/licenses/gpl.html
9
 
125
 
126
  == Changelog ==
127
 
128
+ = 1.6.1 - Aug 10, 2020 =
129
+
130
+ * Bugs
131
+ * Avoid caching issue by adding version as suffix in CSS and JS files
132
+
133
  = 1.6.0 - Aug 08, 2020 =
134
 
135
  * Bugs
uninstall.php CHANGED
@@ -9,7 +9,7 @@
9
  */
10
 
11
  if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
12
- exit;
13
  }
14
 
15
  delete_post_meta_by_key( 'custom_permalink' );
@@ -17,16 +17,16 @@ delete_option( 'custom_permalink_table' );
17
 
18
  $role = get_role( 'administrator' );
19
  if ( ! empty( $role ) ) {
20
- $role->remove_cap( 'cp_view_post_permalinks' );
21
- $role->remove_cap( 'cp_view_category_permalinks' );
22
  }
23
 
24
  $role = get_role( 'custom_permalinks_manager' );
25
  if ( ! empty( $role ) ) {
26
- $role->remove_cap( 'cp_view_post_permalinks' );
27
- $role->remove_cap( 'cp_view_category_permalinks' );
28
 
29
- remove_role( 'custom_permalinks_manager' );
30
  }
31
 
32
  // Clear any cached data that has been removed
9
  */
10
 
11
  if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
12
+ exit;
13
  }
14
 
15
  delete_post_meta_by_key( 'custom_permalink' );
17
 
18
  $role = get_role( 'administrator' );
19
  if ( ! empty( $role ) ) {
20
+ $role->remove_cap( 'cp_view_post_permalinks' );
21
+ $role->remove_cap( 'cp_view_category_permalinks' );
22
  }
23
 
24
  $role = get_role( 'custom_permalinks_manager' );
25
  if ( ! empty( $role ) ) {
26
+ $role->remove_cap( 'cp_view_post_permalinks' );
27
+ $role->remove_cap( 'cp_view_category_permalinks' );
28
 
29
+ remove_role( 'custom_permalinks_manager' );
30
  }
31
 
32
  // Clear any cached data that has been removed