Permalink Manager Lite - Version 0.4.8

Version Description

  • Pagination bug - SQL formula fix (offset variable)
Download this release

Release Info

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

Code changes from version 0.4.7 to 0.4.8

README.txt CHANGED
@@ -5,7 +5,7 @@ License URI: http://www.gnu.org/licenses/gpl-2.0.html
5
  Tags: urls, permalinks, slugs, custom url, custom permalinks, uris, url, slug, permalink
6
  Requires at least: 4.0
7
  Tested up to: 4.6.1
8
- Stable tag: 0.4.7
9
 
10
  Permalink Manager allows you to control how the permalinks for custom post types are created & regenerate them.
11
 
@@ -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.7 =
86
  * Strict standards - fix for arrays with default values
87
 
5
  Tags: urls, permalinks, slugs, custom url, custom permalinks, uris, url, slug, permalink
6
  Requires at least: 4.0
7
  Tested up to: 4.6.1
8
+ Stable tag: 0.4.8
9
 
10
  Permalink Manager allows you to control how the permalinks for custom post types are created & regenerate them.
11
 
82
 
83
  == Changelog ==
84
 
85
+ = 0.4.8 =
86
+ * Pagination bug - SQL formula fix (offset variable)
87
+
88
  = 0.4.7 =
89
  * Strict standards - fix for arrays with default values
90
 
inc/permalink-manager-base-editor.php CHANGED
@@ -14,8 +14,7 @@ class Permalink_Manager_Base_Editor extends WP_List_Table {
14
 
15
  parent::__construct(array(
16
  'singular' => 'slug',
17
- 'plural' => 'slugs',
18
- 'ajax' => true
19
  ));
20
  }
21
 
@@ -96,37 +95,38 @@ class Permalink_Manager_Base_Editor extends WP_List_Table {
96
  * Prepare the items for the table to process
97
  */
98
  public function prepare_items() {
 
 
99
  $columns = $this->get_columns();
100
  $hidden = $this->get_hidden_columns();
101
  $sortable = $this->get_sortable_columns();
102
- $currentPage = $this->get_pagenum();
103
-
104
- global $wpdb;
105
 
106
  // Load options and fields
107
  $saved_options = get_option('permalink-manager');
 
108
  $screen_options_fields = $this->screen_options_fields;
109
  $per_page = isset($saved_options['per_page']) ? $saved_options['per_page'] : $screen_options_fields['per_page']['default'];
110
 
111
  // Load all post types
112
- $data = Permalink_Manager_Helper_Functions::get_post_types_array('full');
113
 
114
  // Attachments are excluded
115
- unset($data['attachment']);
116
 
117
  // Will be used in pagination settings
118
- $total_items = count($data);
119
 
120
  // SQL query parameters
121
  $order = (isset($_REQUEST['order']) && in_array($_REQUEST['order'], array('asc', 'desc'))) ? $_REQUEST['order'] : 'desc';
122
  $orderby = (isset($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'ID';
123
- $offset = ($currentPage - 1) * $per_page;
124
 
125
  // Sort posts and count all posts
126
- usort( $data, array( &$this, 'sort_data' ) );
127
 
128
  // Pagination
129
- $sliced_data = array_slice($data, $offset, $per_page);
130
 
131
  $this->set_pagination_args( array(
132
  'total_items' => $total_items,
@@ -134,9 +134,9 @@ class Permalink_Manager_Base_Editor extends WP_List_Table {
134
  ));
135
 
136
  $this->_column_headers = array($columns, $hidden, $sortable);
137
- $this->items = $sliced_data;
138
  }
139
-
140
  /**
141
  * This variable is assigned in permalink-manager.php before prepare_items() function is triggered, see permalinks_table_html() function
142
  */
14
 
15
  parent::__construct(array(
16
  'singular' => 'slug',
17
+ 'plural' => 'slugs'
 
18
  ));
19
  }
20
 
95
  * Prepare the items for the table to process
96
  */
97
  public function prepare_items() {
98
+ global $wpdb;
99
+
100
  $columns = $this->get_columns();
101
  $hidden = $this->get_hidden_columns();
102
  $sortable = $this->get_sortable_columns();
103
+ $current_page = $this->get_pagenum();
 
 
104
 
105
  // Load options and fields
106
  $saved_options = get_option('permalink-manager');
107
+ $saved_options = isset($saved_options['screen-options']) ? $saved_options['screen-options'] : array();
108
  $screen_options_fields = $this->screen_options_fields;
109
  $per_page = isset($saved_options['per_page']) ? $saved_options['per_page'] : $screen_options_fields['per_page']['default'];
110
 
111
  // Load all post types
112
+ $all_data = Permalink_Manager_Helper_Functions::get_post_types_array('full');
113
 
114
  // Attachments are excluded
115
+ unset($all_data['attachment']);
116
 
117
  // Will be used in pagination settings
118
+ $total_items = count($all_data);
119
 
120
  // SQL query parameters
121
  $order = (isset($_REQUEST['order']) && in_array($_REQUEST['order'], array('asc', 'desc'))) ? $_REQUEST['order'] : 'desc';
122
  $orderby = (isset($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'ID';
123
+ $offset = ($current_page - 1) * $per_page;
124
 
125
  // Sort posts and count all posts
126
+ usort( $all_data, array( &$this, 'sort_data' ) );
127
 
128
  // Pagination
129
+ $data = array_slice($all_data, $offset, $per_page);
130
 
131
  $this->set_pagination_args( array(
132
  'total_items' => $total_items,
134
  ));
135
 
136
  $this->_column_headers = array($columns, $hidden, $sortable);
137
+ $this->items = $data;
138
  }
139
+
140
  /**
141
  * This variable is assigned in permalink-manager.php before prepare_items() function is triggered, see permalinks_table_html() function
142
  */
inc/permalink-manager-editor.php CHANGED
@@ -14,8 +14,7 @@ class Permalink_Manager_Editor extends WP_List_Table {
14
 
15
  parent::__construct(array(
16
  'singular' => 'slug',
17
- 'plural' => 'slugs',
18
- 'ajax' => true
19
  ));
20
  }
21
 
@@ -121,12 +120,12 @@ class Permalink_Manager_Editor extends WP_List_Table {
121
  * Prepare the items for the table to process
122
  */
123
  public function prepare_items() {
 
 
124
  $columns = $this->get_columns();
125
  $hidden = $this->get_hidden_columns();
126
  $sortable = $this->get_sortable_columns();
127
- $currentPage = $this->get_pagenum();
128
-
129
- global $wpdb;
130
 
131
  // Load options and fields
132
  $saved_options = get_option('permalink-manager');
@@ -144,19 +143,22 @@ class Permalink_Manager_Editor extends WP_List_Table {
144
  // SQL query parameters
145
  $order = (isset($_REQUEST['order']) && in_array($_REQUEST['order'], array('asc', 'desc'))) ? $_REQUEST['order'] : 'desc';
146
  $orderby = (isset($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'ID';
147
- $offset = ($currentPage - 1) * $per_page;
148
 
149
  // Grab posts from database
150
- $sql_query = "SELECT * FROM {$wpdb->posts} WHERE post_status IN ($post_statuses) AND post_type IN ($post_types) ORDER BY $orderby $order LIMIT $per_page OFFSET $offset";
151
- $data = $wpdb->get_results($sql_query, ARRAY_A);
 
 
 
 
 
 
152
 
153
  // Debug SQL query
154
- $debug_txt = "<textarea style=\"width:100%;height:300px\">{$sql_query} \n\nOffset: {$offset} \nPage: {$currentPage}\nPer page: {$per_page} \nTotal: {$total_items}</textarea>";
155
  if(isset($_REQUEST['debug_editor_sql'])) { wp_die($debug_txt); }
156
 
157
- // Sort posts and count all posts
158
- usort( $data, array( &$this, 'sort_data' ) );
159
-
160
  $this->set_pagination_args( array(
161
  'total_items' => $total_items,
162
  'per_page' => $per_page
@@ -165,7 +167,7 @@ class Permalink_Manager_Editor extends WP_List_Table {
165
  $this->_column_headers = array($columns, $hidden, $sortable);
166
  $this->items = $data;
167
  }
168
-
169
  /**
170
  * This variable is assigned in permalink-manager.php before prepare_items() function is triggered, see permalinks_table_html() function
171
  */
14
 
15
  parent::__construct(array(
16
  'singular' => 'slug',
17
+ 'plural' => 'slugs'
 
18
  ));
19
  }
20
 
120
  * Prepare the items for the table to process
121
  */
122
  public function prepare_items() {
123
+ global $wpdb;
124
+
125
  $columns = $this->get_columns();
126
  $hidden = $this->get_hidden_columns();
127
  $sortable = $this->get_sortable_columns();
128
+ $current_page = $this->get_pagenum();
 
 
129
 
130
  // Load options and fields
131
  $saved_options = get_option('permalink-manager');
143
  // SQL query parameters
144
  $order = (isset($_REQUEST['order']) && in_array($_REQUEST['order'], array('asc', 'desc'))) ? $_REQUEST['order'] : 'desc';
145
  $orderby = (isset($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'ID';
146
+ $offset = ($current_page - 1) * $per_page;
147
 
148
  // Grab posts from database
149
+ //$sql_query = "SELECT * FROM {$wpdb->posts} WHERE post_status IN ($post_statuses) AND post_type IN ($post_types) ORDER BY $orderby $order LIMIT $per_page OFFSET $offset";
150
+ $sql_query = "SELECT * FROM {$wpdb->posts} WHERE post_status IN ($post_statuses) AND post_type IN ($post_types) ORDER BY $orderby $order";
151
+ $all_data = $wpdb->get_results($sql_query, ARRAY_A);
152
+
153
+ // Sort posts and count all posts
154
+ usort( $all_data, array( &$this, 'sort_data' ) );
155
+
156
+ $data = array_slice($all_data, $offset, $per_page);
157
 
158
  // Debug SQL query
159
+ $debug_txt = "<textarea style=\"width:100%;height:300px\">{$sql_query} \n\nOffset: {$offset} \nPage: {$current_page}\nPer page: {$per_page} \nTotal: {$total_items}</textarea>";
160
  if(isset($_REQUEST['debug_editor_sql'])) { wp_die($debug_txt); }
161
 
 
 
 
162
  $this->set_pagination_args( array(
163
  'total_items' => $total_items,
164
  'per_page' => $per_page
167
  $this->_column_headers = array($columns, $hidden, $sortable);
168
  $this->items = $data;
169
  }
170
+
171
  /**
172
  * This variable is assigned in permalink-manager.php before prepare_items() function is triggered, see permalinks_table_html() function
173
  */
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.7
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.7' );
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' );
@@ -562,7 +562,7 @@ class Permalink_Manager_Class {
562
  }
563
 
564
  // Debug mode
565
- if(isset($_REQUEST['debug_url']) && $_REQUEST['debug_url'] == true) {
566
  $debug_info['old_query_vars'] = $old_query;
567
  $debug_info['new_query_vars'] = $query;
568
  //$debug_info['request'] = "{$protocol}{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
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
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.8' );
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' );
562
  }
563
 
564
  // Debug mode
565
+ if(isset($_REQUEST['debug_url'])) {
566
  $debug_info['old_query_vars'] = $old_query;
567
  $debug_info['new_query_vars'] = $query;
568
  //$debug_info['request'] = "{$protocol}{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";