Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post. Great to hear that you switched to TablePress ??
    Yes, that should be possible, and this should be the adjusted code:

    <?php
    /*
    Plugin Name: TablePress Extension: Alter sorting classes for Northwave
    Version: 1.0
    Author: Tobias B?thge
    */
    add_filter( 'tablepress_js_frontend_command', 'tablepress_alter_sorting_classes_northwave', 10, 5 );
    function tablepress_alter_sorting_classes_northwave( $command, $html_id, $parameters, $table_id, $js_options ) {
    	if ( 1 != $table_id )
    	return $command;
    
    	$command .= "setTimeout(function() {
    		jQuery('.tablepress-id-1').find('th').removeClass('sorting_asc sorting_desc').addClass('sorting').filter('.column-6').addClass('sorting_desc');
    	}, 400)";
    
    	return $command;
    }

    You might just have to adjust the table IDs again.

    Regards,
    Tobias

    Thread Starter Northwave

    (@northwave)

    Great, thanks!

    I tested directly modifying the code in my current wptr-alter-sorting-classes.php, but there it didn’t work.
    So, I presume that I have to create a new file named i.e. “tablepress-alter-sorting-classes.php”, and save the file in “/wp-content/plugins/tablepress-alter-sorting-classes/” folder. And then after that, activate the “new” plugin “TablePress Extension: Alter sorting classes” in WordPress admin area. And then it hopefully should work as before…

    I also noticed that you have left out two parameters from the function, that is $js_command and $tablesorter_script. These aren’t needed anymore?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for testing. After checking the code again, I noticed that I forgot one change. Please replace the line

    add_filter( 'tablepress_js_frontend_command', 'tablepress_alter_sorting_classes_northwave', 10, 5 );

    from the code with

    add_filter( 'tablepress_datatables_command', 'tablepress_alter_sorting_classes_northwave', 10, 5 );

    Putting this in a new file with a new name shouldn’t be necessary for it to work, but for naming consistency, it’s a good idea. That way, you see where the plugin belongs to just from it’s name, in the future.

    And yes, those two parameters that I left out are no longer necessary.

    Regards,
    Tobias

    Thread Starter Northwave

    (@northwave)

    Hi,

    tested and now it works like a charm ??
    Thanks again!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    great! ?? Thanks for the confirmation!

    Best wishes,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Multiple column sort and bgcolor change’ is closed to new replies.