Custom Permalinks - Version 1.2.22

Version Description

  • May 16, 2018 =

    • Enhancement
    • Added Capabilities to view the Permalinks Page
    • Bug
    • Fixed cp_remove_like_query Filter issue
Download this release

Release Info

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

Code changes from version 1.2.21 to 1.2.22

admin/class-custom-permalinks-admin.php CHANGED
@@ -23,20 +23,20 @@ class Custom_Permalinks_Admin {
23
  * @return void
24
  */
25
  public function admin_menu() {
26
- add_menu_page( 'Custom Permalinks', 'Custom Permalinks', 'administrator',
27
  'cp-post-permalinks', array( $this,'posttype_permalinks' ),
28
  'dashicons-admin-links'
29
  );
30
  add_submenu_page( 'cp-post-permalinks', 'PostTypes Permalinks',
31
- 'PostTypes Permalinks', 'administrator', 'cp-post-permalinks',
32
  array( $this, 'posttype_permalinks' )
33
  );
34
  add_submenu_page( 'cp-post-permalinks', 'Category Permalinks',
35
- 'Category Permalinks', 'administrator', 'cp-category-permalinks',
36
  array( $this, 'category_permalinks' )
37
  );
38
  add_submenu_page( 'cp-post-permalinks', 'About Custom Permalinks',
39
- 'About CP', 'administrator', 'cp-about-plugins',
40
  array( $this, 'about_plugin' )
41
  );
42
  }
23
  * @return void
24
  */
25
  public function admin_menu() {
26
+ add_menu_page( 'Custom Permalinks', 'Custom Permalinks', 'cp_view_post_permalinks',
27
  'cp-post-permalinks', array( $this,'posttype_permalinks' ),
28
  'dashicons-admin-links'
29
  );
30
  add_submenu_page( 'cp-post-permalinks', 'PostTypes Permalinks',
31
+ 'PostTypes Permalinks', 'cp_view_post_permalinks', 'cp-post-permalinks',
32
  array( $this, 'posttype_permalinks' )
33
  );
34
  add_submenu_page( 'cp-post-permalinks', 'Category Permalinks',
35
+ 'Category Permalinks', 'cp_view_category_permalinks', 'cp-category-permalinks',
36
  array( $this, 'category_permalinks' )
37
  );
38
  add_submenu_page( 'cp-post-permalinks', 'About Custom Permalinks',
39
+ 'About CP', 'install_plugins', 'cp-about-plugins',
40
  array( $this, 'about_plugin' )
41
  );
42
  }
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.2.21
7
  * Author: Sami Ahmed Siddiqui
8
  * Author URI: https://www.custompermalinks.com/
9
  * Donate link: https://www.paypal.me/yasglobal
@@ -64,7 +64,7 @@ class Custom_Permalinks {
64
  }
65
 
66
  if ( ! defined( 'CUSTOM_PERMALINKS_PLUGIN_VERSION' ) ) {
67
- define( 'CUSTOM_PERMALINKS_PLUGIN_VERSION', '1.2.21' );
68
  }
69
 
70
  if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
@@ -101,9 +101,24 @@ class Custom_Permalinks {
101
  CUSTOM_PERMALINKS_PATH . 'admin/class-custom-permalinks-admin.php'
102
  );
103
  new Custom_Permalinks_Admin();
 
 
104
  }
105
  }
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  /**
108
  * Loads the plugin language files
109
  *
@@ -112,6 +127,11 @@ class Custom_Permalinks {
112
  * @return void
113
  */
114
  public function load_textdomain() {
 
 
 
 
 
115
  load_plugin_textdomain( 'custom-permalinks', FALSE,
116
  basename( dirname( CUSTOM_PERMALINKS_FILE ) ) . '/languages/'
117
  );
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.2.22
7
  * Author: Sami Ahmed Siddiqui
8
  * Author URI: https://www.custompermalinks.com/
9
  * Donate link: https://www.paypal.me/yasglobal
64
  }
65
 
66
  if ( ! defined( 'CUSTOM_PERMALINKS_PLUGIN_VERSION' ) ) {
67
+ define( 'CUSTOM_PERMALINKS_PLUGIN_VERSION', '1.2.22' );
68
  }
69
 
70
  if ( ! defined( 'CUSTOM_PERMALINKS_PATH' ) ) {
101
  CUSTOM_PERMALINKS_PATH . 'admin/class-custom-permalinks-admin.php'
102
  );
103
  new Custom_Permalinks_Admin();
104
+
105
+ register_activation_hook( CUSTOM_PERMALINKS_FILE, array( 'Custom_Permalinks', 'plugin_activate' ) );
106
  }
107
  }
108
 
109
+ /**
110
+ * Loads the plugin language files
111
+ *
112
+ * @access public
113
+ * @since 1.2.22
114
+ * @return void
115
+ */
116
+ public static function plugin_activate() {
117
+ $role = get_role( 'administrator' );
118
+ $role->add_cap( 'cp_view_post_permalinks' );
119
+ $role->add_cap( 'cp_view_category_permalinks' );
120
+ }
121
+
122
  /**
123
  * Loads the plugin language files
124
  *
127
  * @return void
128
  */
129
  public function load_textdomain() {
130
+ $current_version = get_option( 'custom_permalinks_plugin_version', -1 );
131
+ if ( -1 === $current_version || CUSTOM_PERMALINKS_PLUGIN_VERSION < $current_version ) {
132
+ Custom_Permalinks::plugin_activate();
133
+ update_option( 'custom_permalinks_plugin_version', CUSTOM_PERMALINKS_PLUGIN_VERSION );
134
+ }
135
  load_plugin_textdomain( 'custom-permalinks', FALSE,
136
  basename( dirname( CUSTOM_PERMALINKS_FILE ) ) . '/languages/'
137
  );
frontend/class-custom-permalinks-frontend.php CHANGED
@@ -94,7 +94,7 @@ class Custom_Permalinks_Frontend {
94
  $posts = $wpdb->get_results( $sql );
95
 
96
  $remove_like_query = apply_filters( 'cp_remove_like_query', '__true' );
97
- if ( ! $posts && '__false' !== $remove_like_query ) {
98
  $sql = $wpdb->prepare( "SELECT p.ID, pm.meta_value, p.post_type, p.post_status FROM $wpdb->posts AS p " .
99
  " LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id) WHERE " .
100
  " meta_key = 'custom_permalink' AND meta_value != '' AND " .
94
  $posts = $wpdb->get_results( $sql );
95
 
96
  $remove_like_query = apply_filters( 'cp_remove_like_query', '__true' );
97
+ if ( ! $posts && '__true' === $remove_like_query ) {
98
  $sql = $wpdb->prepare( "SELECT p.ID, pm.meta_value, p.post_type, p.post_status FROM $wpdb->posts AS p " .
99
  " LEFT JOIN $wpdb->postmeta AS pm ON (p.ID = pm.post_id) WHERE " .
100
  " meta_key = 'custom_permalink' AND meta_value != '' AND " .
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/yasglobal
4
  Tags: permalink, url, link, address, custom, redirect, custom post type
5
  Requires at least: 2.6
6
  Tested up to: 4.9
7
- Stable tag: 1.2.21
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl.html
10
 
@@ -91,6 +91,14 @@ This process defines you the steps to follow either you are installing through W
91
 
92
  == Changelog ==
93
 
 
 
 
 
 
 
 
 
94
  = 1.2.21 - April 17, 2018 =
95
 
96
  * Bug
4
  Tags: permalink, url, link, address, custom, redirect, custom post type
5
  Requires at least: 2.6
6
  Tested up to: 4.9
7
+ Stable tag: 1.2.22
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl.html
10
 
91
 
92
  == Changelog ==
93
 
94
+ = 1.2.22 - May 16, 2018 =
95
+
96
+ * Enhancement
97
+ * Added Capabilities to view the Permalinks Page
98
+
99
+ * Bug
100
+ * Fixed cp_remove_like_query Filter issue
101
+
102
  = 1.2.21 - April 17, 2018 =
103
 
104
  * Bug
uninstall.php CHANGED
@@ -15,5 +15,9 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
15
  delete_post_meta_by_key( 'custom_permalink' );
16
  delete_option( 'custom_permalink_table' );
17
 
 
 
 
 
18
  // Clear any cached data that has been removed
19
  wp_cache_flush();
15
  delete_post_meta_by_key( 'custom_permalink' );
16
  delete_option( 'custom_permalink_table' );
17
 
18
+ $role = get_role( 'administrator' );
19
+ $role->remove_cap( 'cp_view_post_permalinks' );
20
+ $role->remove_cap( 'cp_view_category_permalinks' );
21
+
22
  // Clear any cached data that has been removed
23
  wp_cache_flush();