WordPress (admin) posts search GET request filter
I wrote up a plugin that adds a column to the posts, page table (list) in the WordPress Admin panel.
Each row has additional input fields (checkboxes) - allow_comments, allow_pings. These checkboxes are used to update comment_status
and ping_status
with tick on checkbox via AJAX call.
Problem begins when I have big load of posts and do a search in the search field, all of my input fields (checkboxes) gets added to the search and if there's a lot then the request URI becomes too long to send and apache errors with 50x Error.
How can I prevent WordPress from including my input fields in the search request?
At the moment I disable on search submit checkboxes to avoid them to be added to the GET Reqest, but maybe there is a better solution?
/**
* Show checkbox Allow pings for post type
* @param $column_name
*/
function jepc_add_pings_column_table_content($column_name) {
global $post;
if ($column_name == 'allow_pings') {
echo "input class=\"editable_ping_comment prevent-submit\" data-type=\"ping\" name=\"allow_ping[]\" type=\"checkbox\" value=\"" . $post-ID . "\"" . ($post-ping_status == 'open' ? ' checked="checked"' : '') . " /";
echo "div id=\"result_ping_" . $post-ID . "\" style=\"display: none;\"" . __('Updating...', 'jepc') . "/div";
}
}
add_action('manage_posts_custom_column', 'jepc_add_pings_column_table_content', 10, 2);
Javascript
/**
* Disabling checkboxes not to be includes in search get request
*/
$('#posts-filter').submit( function() {
$('.prevent-submit').attr('disabled', true);
});