Intuitive Custom Post Order - Version 2.0.8

Version Description

  • Performance improvement for Admin. Refresh method( re-constructing all menu order) run on only active object's List page.
Download this release

Release Info

Developer hijiri
Plugin Icon 128x128 Intuitive Custom Post Order
Version 2.0.8
Comparing to
See all releases

Code changes from version 2.0.6 to 2.0.8

intuitive-custom-post-order.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Intuitive Custom Post Order
4
  Plugin URI: http://hijiriworld.com/web/plugins/intuitive-custom-post-order/
5
  Description: Intuitively, Order Items (Posts, Pages, and Custom Post Types) using a Drag and Drop Sortable JavaScript.
6
- Version: 2.0.6
7
  Author: hijiri
8
  Author URI: http://hijiriworld.com/web/
9
  */
@@ -54,7 +54,7 @@ class Hicpo
54
 
55
  add_action( 'admin_init', array( &$this, 'refresh' ) );
56
  add_action( 'admin_init', array( &$this, 'update_options') );
57
- add_action( 'init', array( &$this, 'enable_objects' ) );
58
 
59
  add_action( 'wp_ajax_update-menu-order', array( &$this, 'update_menu_order' ) );
60
 
@@ -122,17 +122,19 @@ class Hicpo
122
  require HICPO_DIR.'admin/settings.php';
123
  }
124
 
125
- function enable_objects()
126
- {
 
 
127
  $hicpo_options = get_option( 'hicpo_options' );
128
  $objects = $hicpo_options['objects'];
129
 
130
  if ( is_array( $objects ) ) {
131
- $active = false;
132
-
133
  // for Pages or Custom Post Types
134
  if ( isset($_GET['post_type']) ) {
135
- if ( in_array( $_GET['post_type'], $objects ) ) {
 
136
  $active = true;
137
  }
138
  // for Posts
@@ -142,48 +144,49 @@ class Hicpo
142
  $active = true;
143
  }
144
  }
145
-
146
- if ( $active ) {
147
- $this->load_script_css();
148
- }
149
  }
 
150
  }
151
 
152
  function load_script_css() {
153
- // load JavaScript
154
- wp_enqueue_script( 'jQuery' );
155
- wp_enqueue_script( 'jquery-ui-sortable' );
156
- wp_enqueue_script( 'hicpojs', HICPO_URL.'/js/hicpo.js', array( 'jquery' ), null, true );
157
- // load CSS
158
- wp_enqueue_style( 'hicpo', HICPO_URL.'/css/hicpo.css', array(), null );
 
 
159
  }
160
 
161
  function refresh()
162
  {
163
- // menu_orderを再構築する
164
- global $wpdb;
165
-
166
- $hicpo_options = get_option( 'hicpo_options' );
167
- $objects = $hicpo_options['objects'];
168
-
169
- if ( is_array( $objects ) ) {
170
- foreach( $objects as $object) {
171
- $sql = "SELECT
172
- ID
173
- FROM
174
- $wpdb->posts
175
- WHERE
176
- post_type = '".$object."'
177
- AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
178
- ORDER BY
179
- menu_order ASC
180
- ";
181
-
182
- $results = $wpdb->get_results($sql);
183
-
184
- foreach( $results as $key => $result ) {
185
- // 新規追加した場合「menu_order=0」で登録されるため、常に1からはじまるように振っておく
186
- $wpdb->update( $wpdb->posts, array( 'menu_order' => $key+1 ), array( 'ID' => $result->ID ) );
 
 
187
  }
188
  }
189
  }
@@ -390,7 +393,7 @@ class Hicpo
390
  }
391
 
392
  if ( $active ) {
393
- if ( !isset( $wp_query->query['orderby'] ) || $wp_query->query['orderby'] == 'post_date' ) $wp_query->set( 'orderby', 'menu_order' );
394
  if ( !isset( $wp_query->query['order'] ) || $wp_query->query['order'] == 'DESC' ) $wp_query->set( 'order', 'ASC' );
395
  }
396
  }
3
  Plugin Name: Intuitive Custom Post Order
4
  Plugin URI: http://hijiriworld.com/web/plugins/intuitive-custom-post-order/
5
  Description: Intuitively, Order Items (Posts, Pages, and Custom Post Types) using a Drag and Drop Sortable JavaScript.
6
+ Version: 2.0.8
7
  Author: hijiri
8
  Author URI: http://hijiriworld.com/web/
9
  */
54
 
55
  add_action( 'admin_init', array( &$this, 'refresh' ) );
56
  add_action( 'admin_init', array( &$this, 'update_options') );
57
+ add_action( 'init', array( &$this, 'load_script_css' ) );
58
 
59
  add_action( 'wp_ajax_update-menu-order', array( &$this, 'update_menu_order' ) );
60
 
122
  require HICPO_DIR.'admin/settings.php';
123
  }
124
 
125
+ function _check_active_objects() {
126
+
127
+ $active = false;
128
+
129
  $hicpo_options = get_option( 'hicpo_options' );
130
  $objects = $hicpo_options['objects'];
131
 
132
  if ( is_array( $objects ) ) {
133
+ strstr( $_SERVER["REQUEST_URI"], 'wp-admin/post-new.php' );
 
134
  // for Pages or Custom Post Types
135
  if ( isset($_GET['post_type']) ) {
136
+ // not post new page
137
+ if ( in_array( $_GET['post_type'], $objects ) && !strstr( $_SERVER["REQUEST_URI"], 'wp-admin/post-new.php' ) ) {
138
  $active = true;
139
  }
140
  // for Posts
144
  $active = true;
145
  }
146
  }
 
 
 
 
147
  }
148
+ if ( $active ) return true;
149
  }
150
 
151
  function load_script_css() {
152
+ if ( $this->_check_active_objects() ) {
153
+ // load JavaScript
154
+ wp_enqueue_script( 'jQuery' );
155
+ wp_enqueue_script( 'jquery-ui-sortable' );
156
+ wp_enqueue_script( 'hicpojs', HICPO_URL.'/js/hicpo.js', array( 'jquery' ), null, true );
157
+ // load CSS
158
+ wp_enqueue_style( 'hicpo', HICPO_URL.'/css/hicpo.css', array(), null );
159
+ }
160
  }
161
 
162
  function refresh()
163
  {
164
+ if ( $this->_check_active_objects() ) {
165
+ // menu_orderを再構築する
166
+ global $wpdb;
167
+
168
+ $hicpo_options = get_option( 'hicpo_options' );
169
+ $objects = $hicpo_options['objects'];
170
+
171
+ if ( is_array( $objects ) ) {
172
+ foreach( $objects as $object) {
173
+ $sql = "SELECT
174
+ ID
175
+ FROM
176
+ $wpdb->posts
177
+ WHERE
178
+ post_type = '".$object."'
179
+ AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
180
+ ORDER BY
181
+ menu_order ASC
182
+ ";
183
+
184
+ $results = $wpdb->get_results($sql);
185
+
186
+ foreach( $results as $key => $result ) {
187
+ // 新規追加した場合「menu_order=0」で登録されるため、常に1からはじまるように振っておく
188
+ $wpdb->update( $wpdb->posts, array( 'menu_order' => $key+1 ), array( 'ID' => $result->ID ) );
189
+ }
190
  }
191
  }
192
  }
393
  }
394
 
395
  if ( $active ) {
396
+ if ( !isset( $wp_query->query['orderby'] ) || $wp_query->query['orderby'] == 'date' ) $wp_query->set( 'orderby', 'menu_order' );
397
  if ( !isset( $wp_query->query['order'] ) || $wp_query->query['order'] == 'DESC' ) $wp_query->set( 'order', 'ASC' );
398
  }
399
  }
js/hicpo.js CHANGED
File without changes
lang/hicpo-sv_SE.mo ADDED
Binary file
lang/hicpo-sv_SE.po ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Intuitive Custom Post Order v2.0.6\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2013-11-23 17:40+0100\n"
7
+ "Last-Translator: Thomas Persson <info@ajfix.se>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Generator: Poedit 1.5.7\n"
14
+ "X-Poedit-SourceCharset: utf-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
16
+ "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
17
+ "X-Poedit-Basepath: ../\n"
18
+ "X-Textdomain-Support: yes\n"
19
+ "Language: sv_SE\n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+
22
+ # @ hicpo
23
+ #: admin/settings.php:12
24
+ msgid "Intuitive Custom Post Order Settings"
25
+ msgstr "Intuitive CPO Inst&auml;llningar"
26
+
27
+ # @ hicpo
28
+ #: admin/settings.php:17
29
+ msgid "Settings saved."
30
+ msgstr "Inst&auml;llningar sparade"
31
+
32
+ # @ hicpo
33
+ #: admin/settings.php:29
34
+ msgid "Sortable Objects"
35
+ msgstr "Sorteringsbara objekt"
36
+
37
+ # @ cptg
38
+ #: admin/settings.php:50
39
+ msgid "Update"
40
+ msgstr "Uppdatera"
41
+
42
+ # @ hicpo
43
+ #: intuitive-custom-post-order.php:117
44
+ msgid "Intuitive CPO"
45
+ msgstr "Intuitive CPO"
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Intuitive Custom Post Order ===
2
  Contributors: hijiri
3
  Tags: post order, posts order, order post, order posts, custom post type order
4
- Requires at least: 3.0.0
5
- Tested up to: 3.5.1
6
- Stable tag: 2.0.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -29,6 +29,17 @@ Excluding Custom Query which uses 'order' or 'orderby' parameters, in query_post
29
 
30
  == Changelog ==
31
 
 
 
 
 
 
 
 
 
 
 
 
32
  = 2.0.6 =
33
 
34
  * ver.2.0.5 fixed.
1
  === Intuitive Custom Post Order ===
2
  Contributors: hijiri
3
  Tags: post order, posts order, order post, order posts, custom post type order
4
+ Requires at least: 3.8.0
5
+ Tested up to: 3.8.0
6
+ Stable tag: 2.0.8
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
29
 
30
  == Changelog ==
31
 
32
+ = 2.0.8 =
33
+
34
+ * Performance improvement for Admin.
35
+ Refresh method( re-constructing all menu order) run on only active object's List page.
36
+
37
+ = 2.0.7 =
38
+
39
+ * Bug fixed.
40
+ for WordPress 3.8
41
+ * Add Swedish Translations.(by Thomas)
42
+
43
  = 2.0.6 =
44
 
45
  * ver.2.0.5 fixed.
screenshot-1.png CHANGED
File without changes