Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions simple-custom-post-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']))
Expand All @@ -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;
Expand Down Expand Up @@ -676,4 +685,4 @@ function scporder_uninstall_db() {
$result = $wpdb->query($query);
}
delete_option('scporder_install');
}
}