Version Description
Download this release
Release Info
Developer | machothemes |
Plugin | Simple Custom Post Order |
Version | 2.3.9 |
Comparing to | |
See all releases |
Code changes from version 2.3.8 to 2.3.9
- readme.md +4 -1
- simple-custom-post-order.php +93 -49
readme.md
CHANGED
@@ -3,7 +3,7 @@ Contributors: colorlibplugins, silkalns
|
|
3 |
Tags: custom post order, post order, js post order, page order, posts order, category order, sort posts, sort pages, sort custom posts
|
4 |
Requires at least: 3.5.1
|
5 |
Tested up to: 5.0.0
|
6 |
-
Stable tag: 2.3.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -35,6 +35,9 @@ An answer to that question.
|
|
35 |
|
36 |
== Changelog ==
|
37 |
|
|
|
|
|
|
|
38 |
= Version 2.3.8 =
|
39 |
* Fixed white screen ( https://wordpress.org/support/topic/white-screen-after-upgrade-to-2-3-6/ )
|
40 |
|
3 |
Tags: custom post order, post order, js post order, page order, posts order, category order, sort posts, sort pages, sort custom posts
|
4 |
Requires at least: 3.5.1
|
5 |
Tested up to: 5.0.0
|
6 |
+
Stable tag: 2.3.9
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
35 |
|
36 |
== Changelog ==
|
37 |
|
38 |
+
= Version 2.3.9 =
|
39 |
+
* Added button to dismiss the admin notice
|
40 |
+
|
41 |
= Version 2.3.8 =
|
42 |
* Fixed white screen ( https://wordpress.org/support/topic/white-screen-after-upgrade-to-2-3-6/ )
|
43 |
|
simple-custom-post-order.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Simple Custom Post Order
|
5 |
Plugin URI: https://wordpress.org/plugins-wp/simple-custom-post-order/
|
6 |
Description: Order Items (Posts, Pages, and Custom Post Types) using a Drag and Drop Sortable JavaScript.
|
7 |
-
Version: 2.3.
|
8 |
Author: Colorlib
|
9 |
Author URI: https://colorlib.com/wp/
|
10 |
*/
|
@@ -43,6 +43,19 @@ class SCPO_Engine {
|
|
43 |
add_filter('get_terms', array($this, 'scporder_get_object_terms'), 10, 3);
|
44 |
|
45 |
add_action( 'admin_notices', array( $this, 'scporder_notice_not_checked' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
}
|
48 |
|
@@ -59,6 +72,12 @@ class SCPO_Engine {
|
|
59 |
return;
|
60 |
}
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
?>
|
63 |
<div class="notice scpo-notice" id="scpo-notice">
|
64 |
<img src="<?php echo esc_url( plugins_url( 'assets/logo.jpg', __FILE__ ) ); ?>" width="80">
|
@@ -68,6 +87,7 @@ class SCPO_Engine {
|
|
68 |
<p><?php esc_html_e( 'Thank you for installing our awesome plugin, in order to enable it you need to go to the settings page and select which custom post or taxonomy you want to order.', 'scporder' ); ?></p>
|
69 |
|
70 |
<p><a href="<?php echo admin_url( 'options-general.php?page=scporder-settings' ) ?>" class="button button-primary button-hero"><?php esc_html_e( 'Get started !', 'scporder' ); ?></a></p>
|
|
|
71 |
</div>
|
72 |
|
73 |
<style>
|
@@ -80,6 +100,30 @@ class SCPO_Engine {
|
|
80 |
position: relative;
|
81 |
}
|
82 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
<?php
|
84 |
}
|
85 |
|
@@ -149,19 +193,19 @@ class SCPO_Engine {
|
|
149 |
if (!empty($objects)) {
|
150 |
foreach ($objects as $object) {
|
151 |
$result = $wpdb->get_results("
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max)
|
157 |
continue;
|
158 |
|
159 |
$results = $wpdb->get_results("
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
foreach ($results as $key => $result) {
|
166 |
$wpdb->update($wpdb->posts, array('menu_order' => $key + 1), array('ID' => $result->ID));
|
167 |
}
|
@@ -171,21 +215,21 @@ class SCPO_Engine {
|
|
171 |
if (!empty($tags)) {
|
172 |
foreach ($tags as $taxonomy) {
|
173 |
$result = $wpdb->get_results("
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max)
|
180 |
continue;
|
181 |
|
182 |
$results = $wpdb->get_results("
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
foreach ($results as $key => $result) {
|
190 |
$wpdb->update($wpdb->terms, array('term_order' => $key + 1), array('term_id' => $result->term_id));
|
191 |
}
|
@@ -276,27 +320,27 @@ class SCPO_Engine {
|
|
276 |
if (!empty($objects)) {
|
277 |
foreach ($objects as $object) {
|
278 |
$result = $wpdb->get_results("
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max)
|
284 |
continue;
|
285 |
|
286 |
if ($object == 'page') {
|
287 |
$results = $wpdb->get_results("
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
} else {
|
294 |
$results = $wpdb->get_results("
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
}
|
301 |
foreach ($results as $key => $result) {
|
302 |
$wpdb->update($wpdb->posts, array('menu_order' => $key + 1), array('ID' => $result->ID));
|
@@ -307,21 +351,21 @@ class SCPO_Engine {
|
|
307 |
if (!empty($tags)) {
|
308 |
foreach ($tags as $taxonomy) {
|
309 |
$result = $wpdb->get_results("
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max)
|
316 |
continue;
|
317 |
|
318 |
$results = $wpdb->get_results("
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
foreach ($results as $key => $result) {
|
326 |
$wpdb->update($wpdb->terms, array('term_order' => $key + 1), array('term_id' => $result->term_id));
|
327 |
}
|
@@ -339,8 +383,8 @@ class SCPO_Engine {
|
|
339 |
return $where;
|
340 |
|
341 |
if (isset($post->post_type) && in_array($post->post_type, $objects)) {
|
342 |
-
|
343 |
-
|
344 |
return $where;
|
345 |
}
|
346 |
|
@@ -366,7 +410,7 @@ class SCPO_Engine {
|
|
366 |
|
367 |
if (isset($post->post_type) && in_array($post->post_type, $objects)) {
|
368 |
$where = preg_replace("/p.post_date > \'[0-9\-\s\:]+\'/i", "p.menu_order < '" . $post->menu_order . "'", $where);
|
369 |
-
|
370 |
return $where;
|
371 |
}
|
372 |
|
4 |
Plugin Name: Simple Custom Post Order
|
5 |
Plugin URI: https://wordpress.org/plugins-wp/simple-custom-post-order/
|
6 |
Description: Order Items (Posts, Pages, and Custom Post Types) using a Drag and Drop Sortable JavaScript.
|
7 |
+
Version: 2.3.9
|
8 |
Author: Colorlib
|
9 |
Author URI: https://colorlib.com/wp/
|
10 |
*/
|
43 |
add_filter('get_terms', array($this, 'scporder_get_object_terms'), 10, 3);
|
44 |
|
45 |
add_action( 'admin_notices', array( $this, 'scporder_notice_not_checked' ) );
|
46 |
+
add_action( 'wp_ajax_scporder_dismiss_notices', array( $this, 'dismiss_notices' ) );
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
public function dismiss_notices() {
|
51 |
+
|
52 |
+
if ( ! check_admin_referer( 'scporder_dismiss_notice', 'scporder_nonce' ) ) {
|
53 |
+
wp_die( 'nok' );
|
54 |
+
}
|
55 |
+
|
56 |
+
update_option( 'scporder_notice', '1' );
|
57 |
+
|
58 |
+
wp_die( 'ok' );
|
59 |
|
60 |
}
|
61 |
|
72 |
return;
|
73 |
}
|
74 |
|
75 |
+
$dismessed = get_option( 'scporder_notice', false );
|
76 |
+
|
77 |
+
if ( $dismessed ) {
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
|
81 |
?>
|
82 |
<div class="notice scpo-notice" id="scpo-notice">
|
83 |
<img src="<?php echo esc_url( plugins_url( 'assets/logo.jpg', __FILE__ ) ); ?>" width="80">
|
87 |
<p><?php esc_html_e( 'Thank you for installing our awesome plugin, in order to enable it you need to go to the settings page and select which custom post or taxonomy you want to order.', 'scporder' ); ?></p>
|
88 |
|
89 |
<p><a href="<?php echo admin_url( 'options-general.php?page=scporder-settings' ) ?>" class="button button-primary button-hero"><?php esc_html_e( 'Get started !', 'scporder' ); ?></a></p>
|
90 |
+
<button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'scporder' ); ?></span></button>
|
91 |
</div>
|
92 |
|
93 |
<style>
|
100 |
position: relative;
|
101 |
}
|
102 |
</style>
|
103 |
+
<script>
|
104 |
+
jQuery(document).ready(function(){
|
105 |
+
jQuery( '#scpo-notice .notice-dismiss' ).click(function( evt ){
|
106 |
+
evt.preventDefault();
|
107 |
+
|
108 |
+
console.log( 'asdasdas' );
|
109 |
+
|
110 |
+
var ajaxData = {
|
111 |
+
'action' : 'scporder_dismiss_notices',
|
112 |
+
'scporder_nonce' : '<?php echo wp_create_nonce( 'scporder_dismiss_notice' ) ?>'
|
113 |
+
}
|
114 |
+
|
115 |
+
jQuery.ajax({
|
116 |
+
url: "<?php echo admin_url('admin-ajax.php'); ?>",
|
117 |
+
method: "POST",
|
118 |
+
data: ajaxData,
|
119 |
+
dataType: "html"
|
120 |
+
}).done(function(){
|
121 |
+
jQuery("#scpo-notice").hide();
|
122 |
+
});
|
123 |
+
|
124 |
+
});
|
125 |
+
})
|
126 |
+
</script>
|
127 |
<?php
|
128 |
}
|
129 |
|
193 |
if (!empty($objects)) {
|
194 |
foreach ($objects as $object) {
|
195 |
$result = $wpdb->get_results("
|
196 |
+
SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min
|
197 |
+
FROM $wpdb->posts
|
198 |
+
WHERE post_type = '" . $object . "' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
|
199 |
+
");
|
200 |
if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max)
|
201 |
continue;
|
202 |
|
203 |
$results = $wpdb->get_results("
|
204 |
+
SELECT ID
|
205 |
+
FROM $wpdb->posts
|
206 |
+
WHERE post_type = '" . $object . "' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
|
207 |
+
ORDER BY menu_order ASC
|
208 |
+
");
|
209 |
foreach ($results as $key => $result) {
|
210 |
$wpdb->update($wpdb->posts, array('menu_order' => $key + 1), array('ID' => $result->ID));
|
211 |
}
|
215 |
if (!empty($tags)) {
|
216 |
foreach ($tags as $taxonomy) {
|
217 |
$result = $wpdb->get_results("
|
218 |
+
SELECT count(*) as cnt, max(term_order) as max, min(term_order) as min
|
219 |
+
FROM $wpdb->terms AS terms
|
220 |
+
INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id )
|
221 |
+
WHERE term_taxonomy.taxonomy = '" . $taxonomy . "'
|
222 |
+
");
|
223 |
if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max)
|
224 |
continue;
|
225 |
|
226 |
$results = $wpdb->get_results("
|
227 |
+
SELECT terms.term_id
|
228 |
+
FROM $wpdb->terms AS terms
|
229 |
+
INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id )
|
230 |
+
WHERE term_taxonomy.taxonomy = '" . $taxonomy . "'
|
231 |
+
ORDER BY term_order ASC
|
232 |
+
");
|
233 |
foreach ($results as $key => $result) {
|
234 |
$wpdb->update($wpdb->terms, array('term_order' => $key + 1), array('term_id' => $result->term_id));
|
235 |
}
|
320 |
if (!empty($objects)) {
|
321 |
foreach ($objects as $object) {
|
322 |
$result = $wpdb->get_results("
|
323 |
+
SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min
|
324 |
+
FROM $wpdb->posts
|
325 |
+
WHERE post_type = '" . $object . "' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
|
326 |
+
");
|
327 |
if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max)
|
328 |
continue;
|
329 |
|
330 |
if ($object == 'page') {
|
331 |
$results = $wpdb->get_results("
|
332 |
+
SELECT ID
|
333 |
+
FROM $wpdb->posts
|
334 |
+
WHERE post_type = '" . $object . "' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
|
335 |
+
ORDER BY post_title ASC
|
336 |
+
");
|
337 |
} else {
|
338 |
$results = $wpdb->get_results("
|
339 |
+
SELECT ID
|
340 |
+
FROM $wpdb->posts
|
341 |
+
WHERE post_type = '" . $object . "' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
|
342 |
+
ORDER BY post_date DESC
|
343 |
+
");
|
344 |
}
|
345 |
foreach ($results as $key => $result) {
|
346 |
$wpdb->update($wpdb->posts, array('menu_order' => $key + 1), array('ID' => $result->ID));
|
351 |
if (!empty($tags)) {
|
352 |
foreach ($tags as $taxonomy) {
|
353 |
$result = $wpdb->get_results("
|
354 |
+
SELECT count(*) as cnt, max(term_order) as max, min(term_order) as min
|
355 |
+
FROM $wpdb->terms AS terms
|
356 |
+
INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id )
|
357 |
+
WHERE term_taxonomy.taxonomy = '" . $taxonomy . "'
|
358 |
+
");
|
359 |
if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max)
|
360 |
continue;
|
361 |
|
362 |
$results = $wpdb->get_results("
|
363 |
+
SELECT terms.term_id
|
364 |
+
FROM $wpdb->terms AS terms
|
365 |
+
INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id )
|
366 |
+
WHERE term_taxonomy.taxonomy = '" . $taxonomy . "'
|
367 |
+
ORDER BY name ASC
|
368 |
+
");
|
369 |
foreach ($results as $key => $result) {
|
370 |
$wpdb->update($wpdb->terms, array('term_order' => $key + 1), array('term_id' => $result->term_id));
|
371 |
}
|
383 |
return $where;
|
384 |
|
385 |
if (isset($post->post_type) && in_array($post->post_type, $objects)) {
|
386 |
+
$where = preg_replace("/p.post_date < \'[0-9\-\s\:]+\'/i", "p.menu_order > '" . $post->menu_order . "'", $where);
|
387 |
+
}
|
388 |
return $where;
|
389 |
}
|
390 |
|
410 |
|
411 |
if (isset($post->post_type) && in_array($post->post_type, $objects)) {
|
412 |
$where = preg_replace("/p.post_date > \'[0-9\-\s\:]+\'/i", "p.menu_order < '" . $post->menu_order . "'", $where);
|
413 |
+
}
|
414 |
return $where;
|
415 |
}
|
416 |
|