DataTables Inverted Filter
-
I have installed the DataTables Inverted Filter plugin. I’ve read all of the threads that pertain to this plugin. I don’t know what I need to enter into line 22 for [table id=4 /] with a URL slug of data-test to not show table data until searched.
<?php
/*
Plugin Name: TablePress Extension: DataTables Inverted Filter
Plugin URI: https://tablepress.org/extensions/datatables-inverted-filter/
Description: Custom Extension for TablePress to hide all rows initially (i.e. when the DataTables filter word is empty)
Version: 1.1
Author: Tobias B?thge
Author URI: https://tobias.baethge.com/
*//*
* See https://datatables.net/forums/discussion/14521/have-filter-return-no-rows-when-filter-string-is-empty#Item_1
*
* Adjust page slugs as necessary in the array below.
*//*
* Register necessary Plugin Filters.
*/
add_filter( ‘tablepress_all_datatables_commands’, ‘tablepress_datatables_inverted_filter’ );/**
* Add DataTables Inverted Filter JS code.
*
* @since 1.0
*
* @param array $commands The JS commands for the DataTables JS library.
* @return array Modified JS commands for the DataTables JS library.
*/
function tablepress_datatables_inverted_filter( $commands ) {
// Only use this functionality on these pages:
if ( ! is_page( array( ‘page-slug-1’, ‘page-slug-1’ ) ) ) {
return $commands;
}$commands = <<<JS
$.fn.dataTableExt.afnFiltering.push(
function( settings, data, dataIndex ) {
return ” !== settings.oPreviousSearch.sSearch;
}
);
{$commands}
$( ‘.dataTables_filter’ ).find( ‘input’ ).on( ‘keyup’, function() {
$( ‘.dataTables_wrapper’ ).find( ‘.tablepress’ ).toggle( ” !== $( this ).val() );
} ).keyup();
JS;return $commands;
}The page I need help with: [log in to see the link]
- The topic ‘DataTables Inverted Filter’ is closed to new replies.