Intuitive Custom Post Order - Version 3.0.4

Version Description

  • Your Query which uses the 'order' or 'orderby' parameters is preferred. In order to prefer the parameters of your query, You must use the 'WP_Query()' or 'query_posts()'. Excluded 'get_posts()'.
  • Fixed bug
    • Decision of Enabling Sortable JavaScript.
    • Initialize of menu_order of pages.( orderby=post_title, order=asc )
Download this release

Release Info

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

Code changes from version 2.0.0 to 3.0.4

README.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Intuitive Custom Post Order
2
+
3
+ <a href="http://hijiriworld.com/web/plugins/intuitive-custom-post-order/">Intuitive Custom Post Order</a> is WordPress Plugin that order items using a drag and drop sortable JavaScript.
4
+
5
+ ## Description
6
+
7
+ Intuitively, order items( Posts, Pages, and Custom Post Types, and Custom Taxonomies ) using a drag and drop sortable JavaScript.<br>
8
+ Configuration is unnecessary.<br>
9
+ You can do directly on default WordPress administration.
10
+
11
+ In addition, You can re-override the parameters of `orderby` and `order`, by using the `WP_Query` or `pre_get_posts` or `query_posts`.<br>
12
+ The `get_posts()` is excluded.
13
+
14
+ ## Installation
15
+
16
+ 1. Upload 'intuitive-custom-post-order' folder to the `/wp-content/plugins/` directory.
17
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
18
+ 3. Select sortable items from 'Intuitive CPT' menu in WordPress.
19
+
20
+ ## Documentation
21
+
22
+ * <a href="http://hijiriworld.com/web/plugins/intuitive-custom-post-order/">Plugin URI</a>
23
+ * <a href="https://wordpress.org/plugins/intuitive-custom-post-order/">WordPress Plugin Directory URI</a>
24
+
25
+ ## License
26
+
27
+ GPLv2 or later
admin/settings.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
 
3
- $hicpo_options = get_option('hicpo_options');
4
- $objects = $hicpo_options['objects'];
 
5
 
6
  ?>
7
 
@@ -9,12 +10,12 @@ $objects = $hicpo_options['objects'];
9
 
10
  <?php screen_icon( 'plugins' ); ?>
11
 
12
- <h2><?php _e('Intuitive Custom Post Order Settings', 'hicpo'); ?></h2>
13
 
14
  <?php if ( isset($_GET['msg'] )) : ?>
15
  <div id="message" class="updated below-h2">
16
- <?php if ( $_GET['msg'] == 'update') : ?>
17
- <p><?php _e('Settings saved.', 'hicpo'); ?></p>
18
  <?php endif; ?>
19
  </div>
20
  <?php endif; ?>
@@ -23,33 +24,85 @@ $objects = $hicpo_options['objects'];
23
 
24
  <?php if ( function_exists( 'wp_nonce_field' ) ) wp_nonce_field( 'nonce_hicpo' ); ?>
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  <table class="form-table">
27
- <tbody>
28
- <tr valign="top">
29
- <th scope="row"><label for="blogname"><?php _e('Sortable Objects', 'hicpo') ?></label></th>
30
- <td>
31
- <?php
32
- $post_types = get_post_types( array (
33
- 'public' => true
34
- ), 'objects' );
35
-
36
- foreach ($post_types as $post_type ) {
37
- if ( $post_type->name != 'attachment' ) {
38
- ?>
39
- <label><input type="checkbox" name="objects[]" value="<?php echo $post_type->name; ?>" <?php if ( isset($objects) && is_array($objects) ) { if ( in_array($post_type->name, $objects )) { echo 'checked="checked"'; } } ?> />&nbsp;<?php echo $post_type->label; ?></label><br />
40
- <?php
41
  }
42
- }
43
- ?>
44
- </td>
45
- </tr>
46
- </tbody>
47
  </table>
48
 
 
 
 
 
49
  <p class="submit">
50
- <input type="submit" class="button-primary" name="hicpo_submit" value="<?php _e('Update', 'cptg'); ?>" />
51
  </p>
52
 
53
  </form>
54
 
55
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ $hicpo_options = get_option( 'hicpo_options' );
4
+ $hicpo_objects = isset( $hicpo_options['objects'] ) ? $hicpo_options['objects'] : array();
5
+ $hicpo_tags = isset( $hicpo_options['tags'] ) ? $hicpo_options['tags'] : array();
6
 
7
  ?>
8
 
10
 
11
  <?php screen_icon( 'plugins' ); ?>
12
 
13
+ <h2><?php _e( 'Intuitive Custom Post Order Settings', 'hicpo' ); ?></h2>
14
 
15
  <?php if ( isset($_GET['msg'] )) : ?>
16
  <div id="message" class="updated below-h2">
17
+ <?php if ( $_GET['msg'] == 'update' ) : ?>
18
+ <p><?php _e( 'Settings saved.' ); ?></p>
19
  <?php endif; ?>
20
  </div>
21
  <?php endif; ?>
24
 
25
  <?php if ( function_exists( 'wp_nonce_field' ) ) wp_nonce_field( 'nonce_hicpo' ); ?>
26
 
27
+ <div id="hicpo_select_objects">
28
+
29
+ <table class="form-table">
30
+ <tbody>
31
+ <tr valign="top">
32
+ <th scope="row"><?php _e( 'Sortable Post Types', 'hicpo' ) ?></th>
33
+ <td>
34
+ <?php
35
+ $post_types = get_post_types( array (
36
+ 'show_ui' => true,
37
+ 'show_in_menu' => true,
38
+ ), 'objects' );
39
+
40
+ foreach ( $post_types as $post_type ) {
41
+ if ( $post_type->name == 'attachment' ) continue;
42
+ ?>
43
+ <label><input type="checkbox" name="objects[]" value="<?php echo $post_type->name; ?>" <?php if ( isset( $hicpo_objects ) && is_array( $hicpo_objects ) ) { if ( in_array( $post_type->name, $hicpo_objects ) ) { echo 'checked="checked"'; } } ?>>&nbsp;<?php echo $post_type->label; ?></label><br>
44
+ <?php
45
+ }
46
+ ?>
47
+ </td>
48
+ </tr>
49
+ </tbody>
50
+ </table>
51
+
52
+ </div>
53
+
54
+ <label><input type="checkbox" id="hicpo_allcheck_objects"> <?php _e( 'All Check', 'hicpo' ) ?></label>
55
+
56
+ <div id="hicpo_select_tags">
57
+
58
  <table class="form-table">
59
+ <tbody>
60
+ <tr valign="top">
61
+ <th scope="row"><?php _e( 'Sortable Taxonomies', 'hicpo' ) ?></th>
62
+ <td>
63
+ <?php
64
+ $taxonomies = get_taxonomies( array(
65
+ 'show_ui' => true,
66
+ ), 'objects' );
67
+
68
+ foreach( $taxonomies as $taxonomy ) {
69
+ if ( $taxonomy->name == 'post_format' ) continue;
70
+ ?>
71
+ <label><input type="checkbox" name="tags[]" value="<?php echo $taxonomy->name; ?>" <?php if ( isset( $hicpo_tags ) && is_array( $hicpo_tags ) ) { if ( in_array( $taxonomy->name, $hicpo_tags ) ) { echo 'checked="checked"'; } } ?>>&nbsp;<?php echo $taxonomy->label ?></label><br>
72
+ <?php
73
  }
74
+ ?>
75
+ </td>
76
+ </tr>
77
+ </tbody>
 
78
  </table>
79
 
80
+ </div>
81
+
82
+ <label><input type="checkbox" id="hicpo_allcheck_tags"> <?php _e( 'All Check', 'hicpo' ) ?></label>
83
+
84
  <p class="submit">
85
+ <input type="submit" class="button-primary" name="hicpo_submit" value="<?php _e( 'Update', 'cptg' ); ?>">
86
  </p>
87
 
88
  </form>
89
 
90
+ </div>
91
+
92
+ <script>
93
+ (function($){
94
+
95
+ $("#hicpo_allcheck_objects").on('click', function(){
96
+ var items = $("#hicpo_select_objects input");
97
+ if ( $(this).is(':checked') ) $(items).prop('checked', true);
98
+ else $(items).prop('checked', false);
99
+ });
100
+
101
+ $("#hicpo_allcheck_tags").on('click', function(){
102
+ var items = $("#hicpo_select_tags input");
103
+ if ( $(this).is(':checked') ) $(items).prop('checked', true);
104
+ else $(items).prop('checked', false);
105
+ });
106
+
107
+ })(jQuery)
108
+ </script>
intuitive-custom-post-order.php CHANGED
@@ -2,150 +2,199 @@
2
  /*
3
  Plugin Name: Intuitive Custom Post Order
4
  Plugin URI: http://hijiriworld.com/web/plugins/intuitive-custom-post-order/
5
- Description: Intuitively, Order Posts (Posts, Pages, and Custom Post Types) using a Drag and Drop Sortable JavaScript.
6
- Version: 2.0.0
7
  Author: hijiri
8
  Author URI: http://hijiriworld.com/web/
 
 
9
  */
10
 
11
- /* Copyright 2013 hijiri
12
-
13
- This program is free software; you can redistribute it and/or modify
14
- it under the terms of the GNU General Public License, version 2, as
15
- published by the Free Software Foundation.
16
-
17
- This program is distributed in the hope that it will be useful,
18
- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- GNU General Public License for more details.
21
-
22
- You should have received a copy of the GNU General Public License
23
- along with this program; if not, write to the Free Software
24
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
 
27
- /***************************************************************
28
-
29
- Define
30
-
31
- ***************************************************************/
32
-
33
- define( 'HICPO_URL', plugins_url('', __FILE__) );
34
 
35
- define( 'HICPO_DIR', plugin_dir_path(__FILE__) );
36
-
37
- load_plugin_textdomain( 'hicpo', false, basename(dirname(__FILE__)).'/lang' );
38
-
39
- /***************************************************************
40
 
41
- Class & Method
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- ***************************************************************/
 
 
44
 
45
- $hicpo = new Hicpo();
46
 
47
  class Hicpo
48
  {
49
  function __construct()
50
  {
51
- register_activation_hook( __FILE__, array( &$this, 'hicpo_install') );
52
 
53
- add_action( 'admin_menu', array( &$this, 'admin_menu') );
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
  }
61
 
62
- function hicpo_install()
63
  {
64
- if ( !get_option('hicpo_options') ) {
65
-
66
- $post_types = get_post_types( array (
67
- 'public' => true
68
- ), 'objects' );
69
-
70
- foreach ($post_types as $post_type ) {
71
- $init_objects[] = $post_type->name;
72
- }
73
- $input_options = array( 'objects' => $init_objects );
74
-
75
- update_option( 'hicpo_options', $input_options );
76
  }
 
77
  }
78
-
79
  function admin_menu()
80
  {
81
- add_utility_page( __('Intuitive CPO', 'hicpo'), __('Intuitive CPO', 'hicpo'), 'manage_options', 'hicpo-settings', array( &$this,'admin_page' ));
82
  }
83
 
84
  function admin_page()
85
  {
86
  require HICPO_DIR.'admin/settings.php';
87
  }
88
-
89
- function enable_objects()
90
  {
91
- $hicpo_options = get_option( 'hicpo_options' );
92
- $objects = $hicpo_options['objects'];
93
-
94
  $active = false;
95
 
96
- // for Pages or Custom Post Types
97
- if ( isset($_GET['post_type']) ) {
98
- if ( in_array( $_GET['post_type'], $objects ) ) {
 
 
 
 
 
 
 
99
  $active = true;
100
  }
101
- // for Posts
102
- } else {
103
- $post_list = strstr( $_SERVER["REQUEST_URI"], 'wp-admin/edit.php' );
104
- if ( $post_list && in_array( 'post', $objects ) ) {
105
  $active = true;
106
  }
107
  }
108
 
109
- if ( $active ) {
110
- $this->load_script_css();
 
 
111
  }
 
 
112
  }
113
-
114
- function load_script_css() {
115
- // load JavaScript
116
- wp_enqueue_script( 'jQuery' );
117
- wp_enqueue_script( 'jquery-ui-sortable' );
118
- wp_enqueue_script( 'hicpojs', HICPO_URL.'/js/hicpo.js', array( 'jquery' ), null, true );
119
- // load CSS
120
- wp_enqueue_style( 'hicpo', HICPO_URL.'/css/hicpo.css', array(), null );
 
 
121
  }
122
-
123
  function refresh()
124
  {
125
- // menu_orderを再構築する
126
  global $wpdb;
 
 
127
 
128
- $hicpo_options = get_option( 'hicpo_options' );
129
- $objects = $hicpo_options['objects'];
130
-
131
- foreach( $objects as $object) {
132
- $sql = "SELECT
133
- ID,
134
- menu_order
135
- FROM
136
- $wpdb->posts
137
- WHERE
138
- post_type = '".$object."'
139
- AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
140
- ORDER BY
141
- menu_order ASC
142
- ";
143
-
144
- $results = $wpdb->get_results($sql);
145
-
146
- foreach( $results as $key => $result ) {
147
- // 新規追加した場合「menu_order=0」で登録されるため、常に1からはじまるように振っておく
148
- $wpdb->update( $wpdb->posts, array( 'menu_order' => $key+1 ), array( 'ID' => $result->ID ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  }
150
  }
151
  }
@@ -153,160 +202,319 @@ class Hicpo
153
  function update_menu_order()
154
  {
155
  global $wpdb;
 
 
156
 
157
- parse_str($_POST['order'], $data);
158
-
159
- if ( is_array($data) ) {
160
 
161
- // ページに含まれる記事のIDをすべて取得
162
- $id_arr = array();
163
- foreach( $data as $key => $values ) {
164
- foreach( $values as $position => $id ) {
165
- $id_arr[] = $id;
166
- }
167
  }
168
-
169
- // ページに含まれる記事のmenu_orderをすべて取得
170
- $menu_order_arr = array();
171
- foreach( $id_arr as $key => $id ) {
172
- $results = $wpdb->get_results("SELECT menu_order FROM $wpdb->posts WHERE ID = ".$id);
173
- foreach( $results as $result ) {
174
- $menu_order_arr[] = $result->menu_order;
175
- }
176
  }
177
- // menu_order配列をソート(キーと値の相関関係は維持しない)
178
- sort($menu_order_arr);
179
-
180
- foreach( $data as $key => $values ) {
181
- foreach( $values as $position => $id ) {
182
- $wpdb->update( $wpdb->posts, array( 'menu_order' => $menu_order_arr[$position] ), array( 'ID' => $id ) );
183
- }
 
184
  }
185
  }
186
  }
187
 
188
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
  function update_options()
191
  {
192
- if ( isset( $_POST['hicpo_submit'] ) ) {
193
 
194
- check_admin_referer( 'nonce_hicpo' );
195
 
196
- $input_options = array( 'objects' => $_POST['objects'] );
197
 
198
- update_option( 'hicpo_options', $input_options );
199
- wp_redirect( 'admin.php?page=hicpo-settings&msg=update' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  }
 
 
201
  }
202
- }
203
-
204
- /***************************************************************
205
-
206
- output filter hook
207
-
208
- ***************************************************************/
209
-
210
- add_filter( 'pre_get_posts', 'hicpo_filter_active' );
211
-
212
- function hicpo_filter_active( $wp_query )
213
- {
214
- // get_postsの場合 suppress_filters=true となる為、フィルタリングを有効にする
215
- if ( isset($wp_query->query['suppress_filters']) ) $wp_query->query['suppress_filters'] = false;
216
- if ( isset($wp_query->query_vars['suppress_filters']) ) $wp_query->query_vars['suppress_filters'] = false;
217
- return $wp_query;
218
- }
219
-
220
- add_filter( 'pre_get_posts', 'hicpo_pre_get_posts' );
221
-
222
- function hicpo_pre_get_posts( $wp_query )
223
- {
224
- $hicpo_options = get_option('hicpo_options');
225
- $objects = $hicpo_options['objects'];
226
-
227
- // for Admin ---------------------------------------------------------------
228
 
229
- if ( is_admin() && !defined( 'DOING_AJAX' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
230
 
231
- // post_type=post or page or custom post type
232
- // adminの場合、post_tyope=postも渡される
233
- if ( isset( $wp_query->query['post_type'] ) ) {
234
- if ( in_array( $wp_query->query['post_type'], $objects ) ) {
235
- $wp_query->set( 'orderby', 'menu_order' );
236
- $wp_query->set( 'order', 'ASC' );
237
- }
 
 
238
  }
 
 
239
 
240
- // for Template ------------------------------------------------------------
 
 
 
 
 
 
 
 
 
 
 
 
241
 
242
- } else {
 
 
243
 
244
- $active = false;
 
245
 
246
- // postsのWordpressループ ----------------
 
 
 
 
 
 
 
 
 
247
 
248
- // $wp_query->queryが空配列の場合
249
- // WordPressループでもposts以外はpost_typeが渡される
 
 
 
 
 
 
250
 
251
- if ( empty( $wp_query->query ) ) {
252
- if ( in_array( 'post', $objects ) ) {
253
- $active = true;
 
 
 
 
 
254
  }
255
- } else {
256
-
257
- // get_posts() ----------------------
258
 
259
- // 完全な判別ではないが、suppress_filtersパラメータの有無で判別
260
- // get_posts()の場合、post_type, orderby, orderパラメータは必ず渡される
 
261
 
262
- if ( isset($wp_query->query['suppress_filters']) ) {
263
-
264
- // post_type判定
265
- if ( is_array( $wp_query->query['post_type'] ) ) {
266
- $post_types = $wp_query->query['post_type'];
267
- foreach( $post_types as $post_type ) {
268
- if ( in_array( $post_type, $objects ) ) {
269
- $active = true;
270
- }
271
- }
272
- } else {
273
  if ( in_array( $wp_query->query['post_type'], $objects ) ) {
274
  $active = true;
275
  }
276
  }
277
-
278
- // query_posts() or WP_Query()
279
  } else {
280
-
281
- // post_typeが指定されている場合
282
- if ( isset( $wp_query->query['post_type'] ) ) {
283
-
284
- // post_type判定
285
- if ( is_array( $wp_query->query['post_type'] ) ) {
286
- $post_types = $wp_query->query['post_type'];
287
- foreach( $post_types as $post_type ) {
288
- if ( in_array( $post_type, $objects ) ) {
289
- $active = true;
290
- }
291
- }
292
- } else {
293
- if ( in_array( $wp_query->query['post_type'], $objects ) ) {
294
- $active = true;
295
- }
296
- }
297
- // post_typeが指定されてい場合はpost_type=post
298
- } else {
299
- if ( in_array( 'post', $objects ) ) {
300
- $active = true;
301
- }
302
  }
303
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  }
305
 
306
- if ( $active ) {
307
- if ( !isset( $wp_query->query['orderby'] ) || $wp_query->query['orderby'] == 'post_date' ) $wp_query->set( 'orderby', 'menu_order' );
308
- if ( !isset( $wp_query->query['order'] ) || $wp_query->query['order'] == 'DESC' ) $wp_query->set( 'order', 'ASC' );
309
- }
310
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  }
 
312
  ?>
2
  /*
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 and Custom Taxonomies) using a Drag and Drop Sortable JavaScript.
6
+ Version: 3.0.4
7
  Author: hijiri
8
  Author URI: http://hijiriworld.com/web/
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  */
12
 
13
+ /**
14
+ * Define
 
 
 
 
 
 
 
 
 
 
 
 
15
  */
16
 
17
+ define( 'HICPO_URL', plugins_url( '', __FILE__ ) );
18
+ define( 'HICPO_DIR', plugin_dir_path( __FILE__ ) );
19
+ load_plugin_textdomain( 'hicpo', false, basename( dirname( __FILE__ ) ).'/lang' );
 
 
 
 
20
 
21
+ /**
22
+ * Uninstall hook
23
+ */
 
 
24
 
25
+ register_uninstall_hook( __FILE__, 'hicpo_uninstall' );
26
+ function hicpo_uninstall()
27
+ {
28
+ global $wpdb;
29
+ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
30
+ $curr_blog = $wpdb->blogid;
31
+ $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
32
+ foreach( $blogids as $blog_id ) {
33
+ switch_to_blog( $blog_id );
34
+ hicpo_uninstall_db();
35
+ }
36
+ switch_to_blog( $curr_blog );
37
+ } else {
38
+ hicpo_uninstall_db();
39
+ }
40
+ }
41
+ function hicpo_uninstall_db()
42
+ {
43
+ global $wpdb;
44
+ $result = $wpdb->query( "DESCRIBE $wpdb->terms `term_order`" );
45
+ if ( $result ){
46
+ $query = "ALTER TABLE $wpdb->terms DROP `term_order`";
47
+ $result = $wpdb->query( $query );
48
+ }
49
+ delete_option( 'hicpo_activation' );
50
+ }
51
 
52
+ /**
53
+ * Class & Method
54
+ */
55
 
56
+ $hicpo = new Hicpo();
57
 
58
  class Hicpo
59
  {
60
  function __construct()
61
  {
62
+ if ( !get_option( 'hicpo_activation' ) ) $this->hicpo_activation();
63
 
64
+ add_action( 'admin_menu', array( $this, 'admin_menu') );
65
 
66
+ add_action( 'admin_init', array( $this, 'refresh' ) );
 
 
67
 
68
+ add_action( 'admin_init', array( $this, 'update_options') );
69
+ add_action( 'admin_init', array( $this, 'load_script_css' ) );
70
+
71
+ // sortable ajax action
72
+ add_action( 'wp_ajax_update-menu-order', array( $this, 'update_menu_order' ) );
73
+ add_action( 'wp_ajax_update-menu-order-tags', array( $this, 'update_menu_order_tags' ) );
74
+
75
+ // reorder post types
76
+ add_action( 'pre_get_posts', array( $this, 'hicpo_pre_get_posts' ) );
77
+
78
+ add_filter( 'get_previous_post_where', array( $this, 'hicpo_previous_post_where' ) );
79
+ add_filter( 'get_previous_post_sort', array( $this, 'hicpo_previous_post_sort' ) );
80
+ add_filter( 'get_next_post_where', array( $this, 'hocpo_next_post_where' ) );
81
+ add_filter( 'get_next_post_sort', array( $this, 'hicpo_next_post_sort' ) );
82
+
83
+ // reorder taxonomies
84
+ add_filter( 'get_terms_orderby', array( $this, 'hicpo_get_terms_orderby' ), 10, 3 );
85
+ add_filter( 'wp_get_object_terms', array( $this, 'hicpo_get_object_terms' ), 10, 3 );
86
+ add_filter( 'get_terms', array( $this, 'hicpo_get_object_terms' ), 10, 3 );
87
  }
88
 
89
+ function hicpo_activation()
90
  {
91
+ global $wpdb;
92
+ $result = $wpdb->query( "DESCRIBE $wpdb->terms `term_order`" );
93
+ if ( !$result ) {
94
+ $query = "ALTER TABLE $wpdb->terms ADD `term_order` INT( 4 ) NULL DEFAULT '0'";
95
+ $result = $wpdb->query( $query );
 
 
 
 
 
 
 
96
  }
97
+ update_option( 'hicpo_activation', 1 );
98
  }
99
+
100
  function admin_menu()
101
  {
102
+ add_options_page( __( 'Intuitive CPO', 'hicpo' ), __( 'Intuitive CPO', 'hicpo' ), 'manage_options', 'hicpo-settings', array( $this,'admin_page' ) );
103
  }
104
 
105
  function admin_page()
106
  {
107
  require HICPO_DIR.'admin/settings.php';
108
  }
109
+
110
+ function _check_load_script_css()
111
  {
 
 
 
112
  $active = false;
113
 
114
+ $objects = $this->get_hicpo_options_objects();
115
+ $tags = $this->get_hicpo_options_tags();
116
+
117
+ if ( empty( $objects ) && empty( $tags ) ) return false;
118
+
119
+ // exclude (sorting, addnew page, edit page)
120
+ if ( isset( $_GET['orderby'] ) || strstr( $_SERVER['REQUEST_URI'], 'action=edit' ) || strstr( $_SERVER['REQUEST_URI'], 'wp-admin/post-new.php' ) ) return false;
121
+
122
+ if ( !empty( $objects ) ) {
123
+ if ( isset( $_GET['post_type'] ) && !isset( $_GET['taxonomy'] ) && in_array( $_GET['post_type'], $objects ) ) { // if page or custom post types
124
  $active = true;
125
  }
126
+ if ( !isset( $_GET['post_type'] ) && strstr( $_SERVER['REQUEST_URI'], 'wp-admin/edit.php' ) && in_array( 'post', $objects ) ) { // if post
 
 
 
127
  $active = true;
128
  }
129
  }
130
 
131
+ if ( !empty( $tags ) ) {
132
+ if ( isset( $_GET['taxonomy'] ) && in_array( $_GET['taxonomy'], $tags ) ) {
133
+ $active = true;
134
+ }
135
  }
136
+
137
+ return $active;
138
  }
139
+
140
+ function load_script_css()
141
+ {
142
+ if ( $this->_check_load_script_css() ) {
143
+ wp_enqueue_script( 'jquery' );
144
+ wp_enqueue_script( 'jquery-ui-sortable' );
145
+ wp_enqueue_script( 'hicpojs', HICPO_URL.'/js/hicpo.js', array( 'jquery' ), null, true );
146
+
147
+ wp_enqueue_style( 'hicpo', HICPO_URL.'/css/hicpo.css', array(), null );
148
+ }
149
  }
150
+
151
  function refresh()
152
  {
 
153
  global $wpdb;
154
+ $objects = $this->get_hicpo_options_objects();
155
+ $tags = $this->get_hicpo_options_tags();
156
 
157
+ if ( !empty( $objects ) ) {
158
+ foreach( $objects as $object) {
159
+ $result = $wpdb->get_results( "
160
+ SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min
161
+ FROM $wpdb->posts
162
+ WHERE post_type = '".$object."' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
163
+ " );
164
+ if ( $result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max ) continue;
165
+
166
+ $results = $wpdb->get_results( "
167
+ SELECT ID
168
+ FROM $wpdb->posts
169
+ WHERE post_type = '".$object."' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
170
+ ORDER BY menu_order ASC
171
+ " );
172
+ foreach( $results as $key => $result ) {
173
+ $wpdb->update( $wpdb->posts, array( 'menu_order' => $key+1 ), array( 'ID' => $result->ID ) );
174
+ }
175
+ }
176
+ }
177
+
178
+ if ( !empty( $tags ) ) {
179
+ foreach( $tags as $taxonomy ) {
180
+ $result = $wpdb->get_results( "
181
+ SELECT count(*) as cnt, max(term_order) as max, min(term_order) as min
182
+ FROM $wpdb->terms AS terms
183
+ INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id )
184
+ WHERE term_taxonomy.taxonomy = '".$taxonomy."'
185
+ " );
186
+ if ( $result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max ) continue;
187
+
188
+ $results = $wpdb->get_results( "
189
+ SELECT terms.term_id
190
+ FROM $wpdb->terms AS terms
191
+ INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id )
192
+ WHERE term_taxonomy.taxonomy = '".$taxonomy."'
193
+ ORDER BY term_order ASC
194
+ " );
195
+ foreach( $results as $key => $result ) {
196
+ $wpdb->update( $wpdb->terms, array( 'term_order' => $key+1 ), array( 'term_id' => $result->term_id ) );
197
+ }
198
  }
199
  }
200
  }
202
  function update_menu_order()
203
  {
204
  global $wpdb;
205
+
206
+ parse_str( $_POST['order'], $data );
207
 
208
+ if ( !is_array( $data ) ) return false;
 
 
209
 
210
+ // get objects per now page
211
+ $id_arr = array();
212
+ foreach( $data as $key => $values ) {
213
+ foreach( $values as $position => $id ) {
214
+ $id_arr[] = $id;
 
215
  }
216
+ }
217
+
218
+ // get menu_order of objects per now page
219
+ $menu_order_arr = array();
220
+ foreach( $id_arr as $key => $id ) {
221
+ $results = $wpdb->get_results( "SELECT menu_order FROM $wpdb->posts WHERE ID = ".intval( $id ) );
222
+ foreach( $results as $result ) {
223
+ $menu_order_arr[] = $result->menu_order;
224
  }
225
+ }
226
+
227
+ // maintains key association = no
228
+ sort( $menu_order_arr );
229
+
230
+ foreach( $data as $key => $values ) {
231
+ foreach( $values as $position => $id ) {
232
+ $wpdb->update( $wpdb->posts, array( 'menu_order' => $menu_order_arr[$position] ), array( 'ID' => intval( $id ) ) );
233
  }
234
  }
235
  }
236
 
237
+ function update_menu_order_tags()
238
+ {
239
+ global $wpdb;
240
+
241
+ parse_str( $_POST['order'], $data );
242
+
243
+ if ( !is_array( $data ) ) return false;
244
+
245
+ $id_arr = array();
246
+ foreach( $data as $key => $values ) {
247
+ foreach( $values as $position => $id ) {
248
+ $id_arr[] = $id;
249
+ }
250
+ }
251
+
252
+ $menu_order_arr = array();
253
+ foreach( $id_arr as $key => $id ) {
254
+ $results = $wpdb->get_results( "SELECT term_order FROM $wpdb->terms WHERE term_id = ".intval( $id ) );
255
+ foreach( $results as $result ) {
256
+ $menu_order_arr[] = $result->term_order;
257
+ }
258
+ }
259
+ sort( $menu_order_arr );
260
+
261
+ foreach( $data as $key => $values ) {
262
+ foreach( $values as $position => $id ) {
263
+ $wpdb->update( $wpdb->terms, array( 'term_order' => $menu_order_arr[$position] ), array( 'term_id' => intval( $id ) ) );
264
+ }
265
+ }
266
+ }
267
+
268
+ /**
269
+ * はじめて有効化されたオブジェクトは、ディフォルトの order に従って menu_order セットする
270
+ *
271
+ * post_type: orderby=post_date, order=desc
272
+ * taxonomy: orderby=name, order=asc
273
+ *
274
+ * 判定は: アイテム数が 0 以上で order 値がひとつもセットされていないオブジェクト
275
+ */
276
 
277
  function update_options()
278
  {
279
+ global $wpdb;
280
 
281
+ if ( !isset( $_POST['hicpo_submit'] ) ) return false;
282
 
283
+ check_admin_referer( 'nonce_hicpo' );
284
 
285
+ $input_options = array();
286
+ $input_options['objects'] = isset( $_POST['objects'] ) ? $_POST['objects'] : '';
287
+ $input_options['tags'] = isset( $_POST['tags'] ) ? $_POST['tags'] : '';
288
+
289
+ update_option( 'hicpo_options', $input_options );
290
+
291
+ $objects = $this->get_hicpo_options_objects();
292
+ $tags = $this->get_hicpo_options_tags();
293
+
294
+ if ( !empty( $objects ) ) {
295
+ foreach( $objects as $object ) {
296
+ $result = $wpdb->get_results( "
297
+ SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min
298
+ FROM $wpdb->posts
299
+ WHERE post_type = '".$object."' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
300
+ " );
301
+ if ( $result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max ) continue;
302
+
303
+ if ( $object == 'page' ) {
304
+ $results = $wpdb->get_results( "
305
+ SELECT ID
306
+ FROM $wpdb->posts
307
+ WHERE post_type = '".$object."' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
308
+ ORDER BY post_title ASC
309
+ " );
310
+ } else {
311
+ $results = $wpdb->get_results( "
312
+ SELECT ID
313
+ FROM $wpdb->posts
314
+ WHERE post_type = '".$object."' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
315
+ ORDER BY post_date DESC
316
+ " );
317
+ }
318
+ foreach( $results as $key => $result ) {
319
+ $wpdb->update( $wpdb->posts, array( 'menu_order' => $key+1 ), array( 'ID' => $result->ID ) );
320
+ }
321
+ }
322
+ }
323
+
324
+ if ( !empty( $tags ) ) {
325
+ foreach( $tags as $taxonomy ) {
326
+ $result = $wpdb->get_results( "
327
+ SELECT count(*) as cnt, max(term_order) as max, min(term_order) as min
328
+ FROM $wpdb->terms AS terms
329
+ INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id )
330
+ WHERE term_taxonomy.taxonomy = '".$taxonomy."'
331
+ " );
332
+ if ( $result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max ) continue;
333
+
334
+ $results = $wpdb->get_results( "
335
+ SELECT terms.term_id
336
+ FROM $wpdb->terms AS terms
337
+ INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id )
338
+ WHERE term_taxonomy.taxonomy = '".$taxonomy."'
339
+ ORDER BY name ASC
340
+ " );
341
+ foreach( $results as $key => $result ) {
342
+ $wpdb->update( $wpdb->terms, array( 'term_order' => $key+1 ), array( 'term_id' => $result->term_id ) );
343
+ }
344
+ }
345
  }
346
+
347
+ wp_redirect( 'admin.php?page=hicpo-settings&msg=update' );
348
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
 
350
+ function hicpo_previous_post_where( $where )
351
+ {
352
+ global $post;
353
+
354
+ $objects = $this->get_hicpo_options_objects();
355
+ if ( empty( $objects ) ) return $where;
356
+
357
+ if ( isset( $post->post_type ) && in_array( $post->post_type, $objects ) ) {
358
+ $current_menu_order = $post->menu_order;
359
+ $where = "WHERE p.menu_order > '".$current_menu_order."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish'";
360
+ }
361
+ return $where;
362
+ }
363
 
364
+ function hicpo_previous_post_sort( $orderby )
365
+ {
366
+ global $post;
367
+
368
+ $objects = $this->get_hicpo_options_objects();
369
+ if ( empty( $objects ) ) return $orderby;
370
+
371
+ if ( isset( $post->post_type ) && in_array( $post->post_type, $objects ) ) {
372
+ $orderby = 'ORDER BY p.menu_order ASC LIMIT 1';
373
  }
374
+ return $orderby;
375
+ }
376
 
377
+ function hocpo_next_post_where( $where )
378
+ {
379
+ global $post;
380
+
381
+ $objects = $this->get_hicpo_options_objects();
382
+ if ( empty( $objects ) ) return $where;
383
+
384
+ if ( isset( $post->post_type ) && in_array( $post->post_type, $objects ) ) {
385
+ $current_menu_order = $post->menu_order;
386
+ $where = "WHERE p.menu_order < '".$current_menu_order."' AND p.post_type = '". $post->post_type ."' AND p.post_status = 'publish'";
387
+ }
388
+ return $where;
389
+ }
390
 
391
+ function hicpo_next_post_sort( $orderby )
392
+ {
393
+ global $post;
394
 
395
+ $objects = $this->get_hicpo_options_objects();
396
+ if ( empty( $objects ) ) return $orderby;
397
 
398
+ if ( isset( $post->post_type ) && in_array( $post->post_type, $objects ) ) {
399
+ $orderby = 'ORDER BY p.menu_order DESC LIMIT 1';
400
+ }
401
+ return $orderby;
402
+ }
403
+
404
+ function hicpo_pre_get_posts( $wp_query )
405
+ {
406
+ $objects = $this->get_hicpo_options_objects();
407
+ if ( empty( $objects ) ) return false;
408
 
409
+ /**
410
+ * for Admin
411
+ *
412
+ * @default
413
+ * post cpt: [order] => null(desc) [orderby] => null(date)
414
+ * page: [order] => asc [orderby] => menu_order title
415
+ *
416
+ */
417
 
418
+ if ( is_admin() ) {
419
+
420
+ // adminの場合 $wp_query->query['post_type']=post も渡される
421
+ if ( isset( $wp_query->query['post_type'] ) && !isset( $_GET['orderby'] ) ) {
422
+ if ( in_array( $wp_query->query['post_type'], $objects ) ) {
423
+ $wp_query->set( 'orderby', 'menu_order' );
424
+ $wp_query->set( 'order', 'ASC' );
425
+ }
426
  }
 
 
 
427
 
428
+ /**
429
+ * for Front End
430
+ */
431
 
432
+ } else {
433
+
434
+ $active = false;
435
+
436
+ // page or custom post types
437
+ if ( isset( $wp_query->query['post_type'] ) ) {
438
+ // exclude array()
439
+ if ( !is_array( $wp_query->query['post_type'] ) ) {
 
 
 
440
  if ( in_array( $wp_query->query['post_type'], $objects ) ) {
441
  $active = true;
442
  }
443
  }
444
+ // post
 
445
  } else {
446
+ if ( in_array( 'post', $objects ) ) {
447
+ $active = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
  }
449
+ }
450
+
451
+ if ( !$active ) return false;
452
+
453
+ // get_posts()
454
+ if ( isset( $wp_query->query['suppress_filters'] ) ) {
455
+ if ( $wp_query->get( 'orderby' ) == 'date' ) $wp_query->set( 'orderby', 'menu_order' );
456
+ if ( $wp_query->get( 'order' ) == 'DESC' ) $wp_query->set( 'order', 'ASC' );
457
+ // WP_Query( contain main_query )
458
+ } else {
459
+ if ( !$wp_query->get( 'orderby' ) ) $wp_query->set( 'orderby', 'menu_order' );
460
+ if ( !$wp_query->get( 'order' ) ) $wp_query->set( 'order', 'ASC' );
461
+ }
462
+ }
463
+ }
464
+
465
+ function hicpo_get_terms_orderby( $orderby, $args )
466
+ {
467
+ if ( is_admin() ) return $orderby;
468
+
469
+ $tags = $this->get_hicpo_options_tags();
470
+
471
+ if( !isset( $args['taxonomy'] ) ) return $orderby;
472
+
473
+ $taxonomy = $args['taxonomy'];
474
+ if ( !in_array( $taxonomy, $tags ) ) return $orderby;
475
+
476
+ $orderby = 't.term_order';
477
+ return $orderby;
478
+ }
479
+
480
+ function hicpo_get_object_terms( $terms )
481
+ {
482
+ $tags = $this->get_hicpo_options_tags();
483
+
484
+ if ( is_admin() && isset( $_GET['orderby'] ) ) return $terms;
485
+
486
+ foreach( $terms as $key => $term ) {
487
+ if ( is_object( $term ) && isset( $term->taxonomy ) ) {
488
+ $taxonomy = $term->taxonomy;
489
+ if ( !in_array( $taxonomy, $tags ) ) return $terms;
490
+ } else {
491
+ return $terms;
492
+ }
493
  }
494
 
495
+ usort( $terms, array( $this, 'taxcmp' ) );
496
+ return $terms;
497
+ }
498
+
499
+ function taxcmp( $a, $b )
500
+ {
501
+ if ( $a->term_order == $b->term_order ) return 0;
502
+ return ( $a->term_order < $b->term_order ) ? -1 : 1;
503
+ }
504
+
505
+ function get_hicpo_options_objects()
506
+ {
507
+ $hicpo_options = get_option( 'hicpo_options' ) ? get_option( 'hicpo_options' ) : array();
508
+ $objects = isset( $hicpo_options['objects'] ) && is_array( $hicpo_options['objects'] ) ? $hicpo_options['objects'] : array();
509
+ return $objects;
510
+ }
511
+ function get_hicpo_options_tags()
512
+ {
513
+ $hicpo_options = get_option( 'hicpo_options' ) ? get_option( 'hicpo_options' ) : array();
514
+ $tags = isset( $hicpo_options['tags'] ) && is_array( $hicpo_options['tags'] ) ? $hicpo_options['tags'] : array();
515
+ return $tags;
516
+ }
517
+
518
  }
519
+
520
  ?>
js/hicpo.js CHANGED
@@ -1,21 +1,40 @@
1
- jQuery(document).ready(function() {
2
- jQuery("#the-list").sortable({
 
 
 
3
  'items': 'tr',
4
  'axis': 'y',
5
  'helper': fixHelper,
6
  'update' : function(e, ui) {
7
- jQuery.post( ajaxurl, {
8
  action: 'update-menu-order',
9
- order: jQuery("#the-list").sortable("serialize"),
10
  });
11
  }
12
  });
13
- //jQuery("#the-list").disableSelection();
14
- });
15
-
16
- var fixHelper = function(e, ui) {
17
- ui.children().children().each(function() {
18
- jQuery(this).width(jQuery(this).width());
 
 
 
 
 
 
 
 
19
  });
20
- return ui;
21
- };
 
 
 
 
 
 
 
 
1
+ (function($){
2
+
3
+ // posts
4
+
5
+ $('table.posts #the-list, table.pages #the-list').sortable({
6
  'items': 'tr',
7
  'axis': 'y',
8
  'helper': fixHelper,
9
  'update' : function(e, ui) {
10
+ $.post( ajaxurl, {
11
  action: 'update-menu-order',
12
+ order: $('#the-list').sortable('serialize'),
13
  });
14
  }
15
  });
16
+ //$("#the-list").disableSelection();
17
+
18
+ // tags
19
+
20
+ $('table.tags #the-list').sortable({
21
+ 'items': 'tr',
22
+ 'axis': 'y',
23
+ 'helper': fixHelper,
24
+ 'update' : function(e, ui) {
25
+ $.post( ajaxurl, {
26
+ action: 'update-menu-order-tags',
27
+ order: $('#the-list').sortable('serialize'),
28
+ });
29
+ }
30
  });
31
+ //$("#the-list").disableSelection();
32
+
33
+ var fixHelper = function(e, ui) {
34
+ ui.children().children().each(function() {
35
+ $(this).width($(this).width());
36
+ });
37
+ return ui;
38
+ };
39
+
40
+ })(jQuery)
lang/default.pot CHANGED
@@ -1,26 +1,44 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: \n"
4
- "POT-Creation-Date: 2013-02-28 17:44+0900\n"
5
- "PO-Revision-Date: 2013-02-28 17:45+0900\n"
6
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
7
- "Language-Team: LANGUAGE <LL@li.org>\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
 
 
11
 
12
- #: admin/settings.php:12
 
 
 
 
13
  msgid "Intuitive Custom Post Order Settings"
14
  msgstr ""
15
 
16
- #: admin/settings.php:17
17
  msgid "Settings saved."
18
  msgstr ""
19
 
20
- #: admin/settings.php:29
21
- msgid "Sortable Objects"
 
 
 
 
 
 
 
 
 
 
 
 
22
  msgstr ""
23
 
24
- #: admin/settings.php:50
25
  msgid "Update"
26
  msgstr ""
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: \n"
4
+ "POT-Creation-Date: 2015-01-26 21:02+0900\n"
5
+ "PO-Revision-Date: 2015-01-26 21:02+0900\n"
6
+ "Last-Translator: hijiri <hijiriworld@gmail.com>\n"
7
+ "Language-Team: \n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.7\n"
12
+ "X-Poedit-KeywordsList: __;_e\n"
13
 
14
+ #: intuitive-custom-post-order/intuitive-custom-post-order.php:140
15
+ msgid "Intuitive CPO"
16
+ msgstr ""
17
+
18
+ #: intuitive-custom-post-order/admin/settings.php:12
19
  msgid "Intuitive Custom Post Order Settings"
20
  msgstr ""
21
 
22
+ #: intuitive-custom-post-order/admin/settings.php:17
23
  msgid "Settings saved."
24
  msgstr ""
25
 
26
+ #: intuitive-custom-post-order/admin/settings.php:31
27
+ msgid "Sortable Post Types"
28
+ msgstr ""
29
+
30
+ #: intuitive-custom-post-order/admin/settings.php:53
31
+ msgid "All Check"
32
+ msgstr ""
33
+
34
+ #: intuitive-custom-post-order/admin/settings.php:60
35
+ msgid "Sortable Taxonomies"
36
+ msgstr ""
37
+
38
+ #: intuitive-custom-post-order/admin/settings.php:62
39
+ msgid "Custom Taxonomies Order becomes always effective."
40
  msgstr ""
41
 
42
+ #: intuitive-custom-post-order/admin/settings.php:71
43
  msgid "Update"
44
  msgstr ""
lang/hicpo-ja.mo ADDED
Binary file
lang/hicpo-ja.po ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "POT-Creation-Date: 2015-01-26 21:02+0900\n"
5
+ "PO-Revision-Date: 2015-01-26 21:05+0900\n"
6
+ "Last-Translator: hijiri <hijiriworld@gmail.com>\n"
7
+ "Language-Team: \n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.7\n"
12
+ "X-Poedit-KeywordsList: __;_e\n"
13
+
14
+ #: intuitive-custom-post-order/intuitive-custom-post-order.php:140
15
+ msgid "Intuitive CPO"
16
+ msgstr "並び替え設定"
17
+
18
+ #: intuitive-custom-post-order/admin/settings.php:12
19
+ msgid "Intuitive Custom Post Order Settings"
20
+ msgstr "並び替え設定"
21
+
22
+ #: intuitive-custom-post-order/admin/settings.php:17
23
+ msgid "Settings saved."
24
+ msgstr ""
25
+
26
+ #: intuitive-custom-post-order/admin/settings.php:31
27
+ msgid "Sortable Post Types"
28
+ msgstr "並び替える投稿タイプ"
29
+
30
+ #: intuitive-custom-post-order/admin/settings.php:53
31
+ msgid "All Check"
32
+ msgstr "すべて選択"
33
+
34
+ #: intuitive-custom-post-order/admin/settings.php:60
35
+ msgid "Sortable Taxonomies"
36
+ msgstr "並び替えるカスタム分類"
37
+
38
+ #: intuitive-custom-post-order/admin/settings.php:62
39
+ msgid "Custom Taxonomies Order becomes always effective."
40
+ msgstr "カスタム分類は常に並び替えが有効になります。"
41
+
42
+ #: intuitive-custom-post-order/admin/settings.php:71
43
+ msgid "Update"
44
+ msgstr ""
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,34 +1,160 @@
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.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
- Intuitively, Order posts(posts, any custom post types) using a Drag and Drop Sortable JavaScript.
11
 
12
  == Description ==
13
 
14
- Intuitively, Order posts(posts, any custom post types) using a Drag and Drop Sortable JavaScript.
15
- Configuration is unnecessary.
16
  You can do directly on default WordPress administration.
17
 
18
- Excluding custom query which uses 'order' or 'orderby' parameters, in 'get_posts' or 'query_posts' and so on.
 
 
 
19
 
20
  == Installation ==
21
 
22
- 1. Upload 'intuitive-custom-post-order' folder to the `/wp-content/plugins/` directory
23
- 2. Activate the plugin through the 'Plugins' menu in WordPress
24
- 3. (Optional) Navigate to the Intuitive CPT Menu
25
 
26
  == Screenshots ==
27
 
28
- 1. Order items
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  == Changelog ==
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  = 2.0.0 =
33
 
34
  * Select Sortable Objects. (Posts, Pages, and Custom Post Types)
@@ -37,7 +163,6 @@ Excluding custom query which uses 'order' or 'orderby' parameters, in 'get_posts
37
  * In Paging, it's all activated normaly. So, 'screen-per-page' is User like.
38
  * In Lists which sorted any category(Category, Tag, Taxonomy), it's all activated normaly.
39
  * Support Child posts and Child pages. When you sort any item, Relation of parent item between it's child items is maintained.
40
- * Bug fixed
41
 
42
  = 1.2.1 =
43
 
@@ -52,7 +177,7 @@ Excluding custom query which uses 'order' or 'orderby' parameters, in 'get_posts
52
 
53
  = 1.1.1 =
54
 
55
- * Bug fixed
56
 
57
  = 1.1.0 =
58
 
@@ -61,4 +186,10 @@ Excluding custom query which uses 'order' or 'orderby' parameters, in 'get_posts
61
 
62
  = 1.0.0 =
63
 
64
- Initial Release
 
 
 
 
 
 
1
  === Intuitive Custom Post Order ===
2
  Contributors: hijiri
3
+ Tags: post order, posts order, order post, order posts, custom post type order, custom taxonomy order
4
+ Requires at least: 3.5.0
5
+ Tested up to: 4.2.2
6
+ Stable tag: 3.0.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
+ Intuitively, order items( Posts, Pages, and Custom Post Types, and Custom Taxonomies ) using a drag and drop sortable JavaScript.
11
 
12
  == Description ==
13
 
14
+ Intuitively, order items( Posts, Pages, and Custom Post Types, and Custom Taxonomies ) using a drag and drop sortable JavaScript.<br>
15
+ Configuration is unnecessary.<br>
16
  You can do directly on default WordPress administration.
17
 
18
+ In addition, You can re-override the parameters of 'orderby' and 'order', by using the 'WP_Query' or 'pre_get_posts' or 'query_posts()'.<br>
19
+ The 'get_posts()' is excluded.
20
+
21
+ This Plugin published on <a href="https://github.com/hijiriworld/intuitive-custom-post-order">GitHub.</a>
22
 
23
  == Installation ==
24
 
25
+ 1. Upload 'intuitive-custom-post-order' folder to the `/wp-content/plugins/` directory.
26
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
27
+ 3. Select sortable items from 'Intuitive CPT' menu in WordPress.
28
 
29
  == Screenshots ==
30
 
31
+ 1. Reorder post
32
+ 2. Reorder taxonomy
33
+ 3. Settings
34
+
35
+ == Frequently Asked Questions ==
36
+
37
+ = How to re-override the parameters of 'orderby' and 'order' =
38
+
39
+ <strong>Sub query</strong>
40
+
41
+ By using the 'WP_Query', you can re-override the parameters.
42
+
43
+ * WP_Query
44
+
45
+ `
46
+ <?php $query = new WP_Query( array(
47
+ 'orderby' => 'date',
48
+ 'order' => 'DESC',
49
+ ) ) ?>
50
+ `
51
+
52
+ <strong>Main query</strong>
53
+
54
+ By using the 'pre_get_posts' action hook or 'query_posts()', you can re-override the parameters.
55
+
56
+ * pre_get_posts
57
+
58
+ `
59
+ function my_filter( $query )
60
+ {
61
+ if ( is_admin() || !$query->is_main_query() ) return;
62
+ if ( is_home() ) {
63
+ $query->set( 'orderby', 'date' );
64
+ $query->set( 'order', 'DESC' );
65
+ return;
66
+ }
67
+ }
68
+ add_action( 'pre_get_posts', 'my_filter' );
69
+ `
70
+
71
+ * query_posts()
72
+
73
+ `
74
+ <?php query_posts( array(
75
+ 'orderby' => 'rand'
76
+ ) ); ?>
77
+ `
78
 
79
  == Changelog ==
80
 
81
+
82
+ = 3.0.4 =
83
+
84
+ * Your Query which uses the 'order' or 'orderby' parameters is preferred.
85
+ In order to prefer the parameters of your query, You must use the 'WP_Query()' or 'query_posts()'.
86
+ Excluded 'get_posts()'.
87
+ * Fixed bug
88
+ - Decision of Enabling Sortable JavaScript.
89
+ - Initialize of menu_order of pages.( orderby=post_title, order=asc )
90
+
91
+ = 3.0.3 =
92
+
93
+ * Performance improvement for Activation.
94
+ * Add Initialize of Custom Taxonomy Order.
95
+ * Fixed bug of refresh method.
96
+ * Overwirting orderby, order improved.(Thanks @newash and @anriettec)
97
+
98
+ = 3.0.1 & 3.0.2 =
99
+
100
+ * Fixed bug
101
+
102
+ = 3.0.0 =
103
+
104
+ * Support the Custom Taxonomy Order!!
105
+ ( wp_list_categories, get_categories, the_terms, the_tags, get_terms, get_the_terms, get_the_term_list, the_category, wp_dropdown_categories, the_taxonomies )
106
+ * Suuport the sorting in admin UI.
107
+ While having sorted, Drag and Drop Sortable Javascript don't run.
108
+ * Support non public objects( show_ui=true, show_in_menu=true )
109
+ * Add Japanese Translations.
110
+
111
+ = 2.1.0 =
112
+
113
+ * Fixed bug: Custom Query which uses 'order' or 'orderby' parameters is preferred.
114
+ * It does not depend on the designation manner of arguments( Parameters ).
115
+ ( $args = 'orderby=&order=' or $args = array( 'orderby' => '', 'order' => '' ) )
116
+ * The trouble which exists in 2.0.7, 2.0.8, 2.0.9 was improved!
117
+ * From 2.0.6 please update in 2.1.0.
118
+
119
+ = 2.0.9 =
120
+
121
+ * Performance improvement for Admin.
122
+ Fatal performance problem was improved dramatically.
123
+ * Fixed bug: Attachment objects are not broken.
124
+ * Fixed bug: Alert warning on the multisite was solved.
125
+ * Fixed bug: First when enabling items, 'menu order' of items are not broken.
126
+ * Custom Query which uses 'order' or 'orderby' parameters is preferred.
127
+
128
+ = 2.0.8 =
129
+
130
+ * Performance improvement for Admin.
131
+ Refresh method( re-constructing all menu order) run on only active object's List page.
132
+
133
+ = 2.0.7 =
134
+
135
+ * Fixed bug: for WordPress 3.8
136
+ * Add Swedish Translations.(by Thomas)
137
+
138
+ = 2.0.6 =
139
+
140
+ * ver.2.0.5 fixed.
141
+
142
+ = 2.0.5 =
143
+
144
+ * Support 'next_post_link()' and 'previous_post_link()'(single to single).
145
+
146
+ = 2.0.4 =
147
+
148
+ * Fixed bug
149
+
150
+ = 2.0.3 =
151
+
152
+ * Intuitive CPO Settings Page was moved to Settings menu.
153
+
154
+ = 2.0.2 =
155
+
156
+ * Fixed bug
157
+
158
  = 2.0.0 =
159
 
160
  * Select Sortable Objects. (Posts, Pages, and Custom Post Types)
163
  * In Paging, it's all activated normaly. So, 'screen-per-page' is User like.
164
  * In Lists which sorted any category(Category, Tag, Taxonomy), it's all activated normaly.
165
  * Support Child posts and Child pages. When you sort any item, Relation of parent item between it's child items is maintained.
 
166
 
167
  = 1.2.1 =
168
 
177
 
178
  = 1.1.1 =
179
 
180
+ * Fixed bug
181
 
182
  = 1.1.0 =
183
 
186
 
187
  = 1.0.0 =
188
 
189
+ Initial Release
190
+
191
+ == Upgrade Notice ==
192
+
193
+ = 3.0.3 =
194
+
195
+ Expand Database Table: wp_terms.
screenshot-1.png DELETED
Binary file