Permalink Manager Lite - Version 0.4.1

Version Description

  • Hotfix for "Edit Post" URI input (the URIs were reseted after "Update" button was pressed).
Download this release

Release Info

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

Code changes from version 0.4 to 0.4.1

README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mbis
3
  Tags: urls, permalinks, slugs, custom url, custom permalinks, uris, url, slug, permalink
4
  Requires at least: 4.0
5
  Tested up to: 4.5.3
6
- Stable tag: 0.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -82,6 +82,9 @@ After the plugin is installed you can access its dashboard from this page: `Tool
82
 
83
  == Changelog ==
84
 
 
 
 
85
  = 0.4 =
86
  * Rewrite rules are no longer used (SQL queries are optimized). The plugin uses now 'request' filter to detect the page/post that should be loaded instead.
87
  * Now full URI (including slug) is editable.
3
  Tags: urls, permalinks, slugs, custom url, custom permalinks, uris, url, slug, permalink
4
  Requires at least: 4.0
5
  Tested up to: 4.5.3
6
+ Stable tag: 0.4.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
82
 
83
  == Changelog ==
84
 
85
+ = 0.4.1 =
86
+ * Hotfix for "Edit Post" URI input (the URIs were reseted after "Update" button was pressed).
87
+
88
  = 0.4 =
89
  * Rewrite rules are no longer used (SQL queries are optimized). The plugin uses now 'request' filter to detect the page/post that should be loaded instead.
90
  * Now full URI (including slug) is editable.
inc/permalink-manager-helper-functions.php CHANGED
@@ -156,22 +156,26 @@ class Permalink_Manager_Helper_Functions extends Permalink_Manager_Class {
156
  }
157
 
158
  static function get_uri($post_id, $get_default = false, $remove_slug = true) {
159
- // Load all bases & post
160
- $all_uris = get_option('permalink-manager-uris');
161
- $all_permastructures = get_option('permalink-manager-permastructs');
162
- $options = get_option('permalink-manager');
163
 
 
164
  $post = isset($post_id->post_type) ? $post_id : get_post($post_id);
165
  $post_id = $post->ID;
166
  $post_type = $post->post_type;
167
  $post_name = $post->post_name;
168
 
 
 
 
 
 
169
  if($get_default) {
170
 
171
- if($all_permastructures) {
172
- $permastruct = isset($all_permastructures[$post_type]) ? $all_permastructures[$post_type] : Permalink_Manager_Helper_Functions::get_default_permastruct($post_type);
 
 
173
  } else {
174
- $permastruct = isset($options['base-editor'][$post_type]) ? $options['base-editor'][$post_type] : Permalink_Manager_Helper_Functions::get_default_permastruct($post_type);
175
  }
176
 
177
  // Get options
156
  }
157
 
158
  static function get_uri($post_id, $get_default = false, $remove_slug = true) {
 
 
 
 
159
 
160
+ // Load all bases & post
161
  $post = isset($post_id->post_type) ? $post_id : get_post($post_id);
162
  $post_id = $post->ID;
163
  $post_type = $post->post_type;
164
  $post_name = $post->post_name;
165
 
166
+ $all_uris = get_option('permalink-manager-uris');
167
+ $all_permastructures = get_option('permalink-manager-permastructs');
168
+ $options = get_option('permalink-manager');
169
+ $default_permastruct = Permalink_Manager_Helper_Functions::get_default_permastruct($post_type);
170
+
171
  if($get_default) {
172
 
173
+ if($get_default === 'native') {
174
+ $permastruct = $default_permastruct;
175
+ } else if($all_permastructures) {
176
+ $permastruct = isset($all_permastructures[$post_type]) ? $all_permastructures[$post_type] : $default_permastruct;
177
  } else {
178
+ $permastruct = isset($options['base-editor'][$post_type]) ? $options['base-editor'][$post_type] : $default_permastruct;
179
  }
180
 
181
  // Get options
permalink-manager.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Permalink Manager
5
  * Plugin URI: http://maciejbis.net/
6
  * Description: A simple tool that allows to mass update of slugs that are used to build permalinks for Posts, Pages and Custom Post Types.
7
- * Version: 0.4
8
  * Author: Maciej Bis
9
  * Author URI: http://maciejbis.net/
10
  * License: GPL-2.0+
@@ -20,7 +20,7 @@ if ( ! defined( 'WPINC' ) ) {
20
 
21
  // Define the directories used to load plugin files.
22
  define( 'PERMALINK_MANAGER_PLUGIN_NAME', 'permalink-manager' );
23
- define( 'PERMALINK_MANAGER_VERSION', '0.4' );
24
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit( dirname( __FILE__ ) ) );
25
  define( 'PERMALINK_MANAGER_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) );
26
  define( 'PERMALINK_MANAGER_WEBSITE', 'http://maciejbis.net' );
@@ -567,7 +567,10 @@ class Permalink_Manager_Class {
567
  if($post->post_status == 'trash') return;
568
 
569
  $uris = $this->permalink_manager_uris;
570
- $old_default_uri = trim(str_replace(home_url("/"), "", get_permalink($post_id)), "/");
 
 
 
571
  $new_default_uri = Permalink_Manager_Helper_Functions::get_uri($post, true);
572
  $new_uri = '';
573
 
@@ -576,7 +579,7 @@ class Permalink_Manager_Class {
576
  $new_uri = trim($_POST['custom_uri'], "/");
577
  }
578
 
579
- // A little hack
580
  $new_uri = ($new_uri) ? $new_uri : $new_default_uri;
581
 
582
  // Do not store default values
@@ -585,6 +588,8 @@ class Permalink_Manager_Class {
585
  } else if ($new_uri != $old_default_uri) {
586
  $uris[$post_id] = $new_uri;
587
  }
 
 
588
  update_option('permalink-manager-uris', $uris);
589
  }
590
 
4
  * Plugin Name: Permalink Manager
5
  * Plugin URI: http://maciejbis.net/
6
  * Description: A simple tool that allows to mass update of slugs that are used to build permalinks for Posts, Pages and Custom Post Types.
7
+ * Version: 0.4.1
8
  * Author: Maciej Bis
9
  * Author URI: http://maciejbis.net/
10
  * License: GPL-2.0+
20
 
21
  // Define the directories used to load plugin files.
22
  define( 'PERMALINK_MANAGER_PLUGIN_NAME', 'permalink-manager' );
23
+ define( 'PERMALINK_MANAGER_VERSION', '0.4.1' );
24
  define( 'PERMALINK_MANAGER_DIR', untrailingslashit( dirname( __FILE__ ) ) );
25
  define( 'PERMALINK_MANAGER_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) );
26
  define( 'PERMALINK_MANAGER_WEBSITE', 'http://maciejbis.net' );
567
  if($post->post_status == 'trash') return;
568
 
569
  $uris = $this->permalink_manager_uris;
570
+
571
+ $old_default_uri = Permalink_Manager_Helper_Functions::get_uri($post, 'native');
572
+ $old_uri = (isset($uris[$post_id])) ? $uris[$post_id] : $old_default_uri;
573
+
574
  $new_default_uri = Permalink_Manager_Helper_Functions::get_uri($post, true);
575
  $new_uri = '';
576
 
579
  $new_uri = trim($_POST['custom_uri'], "/");
580
  }
581
 
582
+ // A little hack (if user removes whole URI from input)
583
  $new_uri = ($new_uri) ? $new_uri : $new_default_uri;
584
 
585
  // Do not store default values
588
  } else if ($new_uri != $old_default_uri) {
589
  $uris[$post_id] = $new_uri;
590
  }
591
+
592
+
593
  update_option('permalink-manager-uris', $uris);
594
  }
595