Plugin clashing with AJAX requests
-
Hi there,
I’m having an issue using this plugin alongside AJAX requests which use custom orderby parameters.
The scporder_pre_get_posts function checks is_admin(), which always returns true for AJAX requests, then rewrites the orderby parameter.
The plugin should also check that the $wp_query->query[‘orderby’] parameter is set when the wp_doing_ajax() function returns true, so that AJAX requests aren’t overwritten by the plugin.
function scporder_pre_get_posts($wp_query) { $objects = $this->get_scporder_options_objects(); if (empty($objects)) return false; if (wp_doing_ajax()) { if (isset($wp_query->query['post_type']) && !isset($wp_query->query['orderby'])) { if (in_array($wp_query->query['post_type'], $objects)) { $wp_query->set('orderby', 'menu_order'); $wp_query->set('order', 'ASC'); } } } else if (is_admin()) { if (isset($wp_query->query['post_type']) && !isset($_GET['orderby'])) { if (in_array($wp_query->query['post_type'], $objects)) { $wp_query->set('orderby', 'menu_order'); $wp_query->set('order', 'ASC'); } } } ...
- The topic ‘Plugin clashing with AJAX requests’ is closed to new replies.