diff --git a/simple-custom-post-order.php b/simple-custom-post-order.php index 22fd989..20b0862 100644 --- a/simple-custom-post-order.php +++ b/simple-custom-post-order.php @@ -64,9 +64,9 @@ function __construct() { add_filter('get_next_post_sort', array($this, 'scporder_next_post_sort')); add_filter('get_terms_orderby', array($this, 'scporder_get_terms_orderby'), 10, 3); - add_filter('wp_get_object_terms', array($this, 'scporder_get_object_terms'), 10, 3); - add_filter('get_terms', array($this, 'scporder_get_object_terms'), 10, 3); - + add_filter('wp_get_object_terms', array($this, 'scporder_get_object_terms'), 10, 4); + add_filter('get_terms', array($this, 'scporder_get_terms'), 10, 3); + add_action( 'admin_notices', array( $this, 'scporder_notice_not_checked' ) ); add_action( 'wp_ajax_scporder_dismiss_notices', array( $this, 'dismiss_notices' ) ); @@ -237,7 +237,6 @@ public function refresh() { $tags = $this->get_scporder_options_tags(); if (!empty($objects)) { - foreach ($objects as $object) { $result = $wpdb->get_results(" SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min @@ -535,6 +534,9 @@ public function scporder_get_terms_orderby($orderby, $args) { if (is_admin()) return $orderby; + if (isset($args['include']) && isset($args['orderby']) && 'include' === $args['orderby']) + return $orderby; + $tags = $this->get_scporder_options_tags(); if (!isset($args['taxonomy'])) @@ -558,12 +560,19 @@ public function scporder_get_terms_orderby($orderby, $args) { return $orderby; } - public function scporder_get_object_terms($terms) { + public function scporder_get_object_terms($terms, $object_ids, $taxonomies, $args) { + return $this->scporder_get_terms($terms, $taxonomies, $args); + } + + public function scporder_get_terms($terms, $taxonomies, $args) { $tags = $this->get_scporder_options_tags(); if (is_admin() && isset($_GET['orderby'])) return $terms; + if (isset($args['include']) && isset($args['orderby']) && 'include' === $args['orderby']) + return $terms; + foreach ($terms as $key => $term) { if (is_object($term) && isset($term->taxonomy)) { $taxonomy = $term->taxonomy; @@ -676,4 +685,4 @@ function scporder_uninstall_db() { $result = $wpdb->query($query); } delete_option('scporder_install'); -} \ No newline at end of file +}