• Resolved tproli

    (@tproli)


    Hi,

    just encountered an issue where a “disabled” shortcode could have been beneficial.

    For example, having multiple tables on a page which need to be toggled on/off periodically. If the user could add disabled=”true” to remove it temporarily, it would be nice, not having to remove it entirely. Of course this is mainly for the admin editor, in templates it’s easier to toggle on/off.

    I can do it if you don’t have time and create a PR at GitHub.

    Thanks!

    https://www.ads-software.com/plugins/tablepress/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    I don’t really think that this is something that should go into the main plugin, as only very few people will ever need it. Instead, this can achieved with just a little bit of custom code, that is added either to the “functions.php” of the theme or a small new plugin file:

    add_filter( 'tablepress_table_not_found_message', 'tablepress_prevent_table_not_found_message_for_disabled_tables', 10, 2 );
    function tablepress_prevent_table_not_found_message_for_disabled_tables( $message, $table_id ) {
    	if ( empty( $table_id ) ) {
    		$message = '';
    	}
    	return $message;
    }

    After that, you could change the Shortcode from

    [table id=123 /]

    to

    [table disabled_id=123 /]

    to hide it.

    Regards,
    Tobias

    Thread Starter tproli

    (@tproli)

    Thanks, just tried and worked!

    I’m still not 100% convinced that it’s a feature that shouldn’t go into the core but you surely know it better than me ??

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    This is the first request about a feature like this that I remember, so there’s definitely not much interest from the majority of users ??

    Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Feature request: shortcode "disabled"’ is closed to new replies.