Support » Plugin: LuckyWP Table of Contents » PHP 8 compatibility

  • protohominid

    (@protohominid)


    I’m testing my site with PHP 8.1 and it seems the LuckyWP Table of Contents plugin is throwing a fatal error. When I disable the plugin the site loads normally. This is from my debug log with the plugin enabled (server path deleted for security):

    [20-Sep-2022 17:58:16 UTC] PHP Fatal error:  Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, no array or string given in /public_html/wp-includes/class-wp-hook.php:307
    Stack trace:
    #0 /public_html/wp-includes/plugin.php(191): WP_Hook->apply_filters()
    #1 /public_html/wp-content/plugins/luckywp-table-of-contents/front/Front.php(49): apply_filters()
    #2 /public_html/wp-content/plugins/luckywp-table-of-contents/front/Toc.php(305): luckywp\tableOfContents\front\Front->enqueueAssets()
    #3 /public_html/wp-content/plugins/luckywp-table-of-contents/plugin/Shortcode.php(198): luckywp\tableOfContents\front\Toc::render()
    #4 [internal function]: luckywp\tableOfContents\plugin\Shortcode->luckywp\tableOfContents\plugin\{closure}()
    #5 /public_html/wp-content/plugins/luckywp-table-of-contents/plugin/Shortcode.php(199): preg_replace_callback()
    #6 /public_html/wp-includes/class-wp-hook.php(307): luckywp\tableOfContents\plugin\Shortcode->theContent()
    #7 /public_html/wp-includes/plugin.php(191): WP_Hook->apply_filters()
    #8 /public_html/wp-includes/post-template.php(253): apply_filters()
    #9 /public_html/wp-content/themes/nm2021/single.php(17): the_content()
    #10 /public_html/wp-includes/template-loader.php(106): include('/home/...')
    #11 /public_html/wp-blog-header.php(19): require_once('/home/...')
    #12 /public_html/index.php(17): require('/home/...')
    #13 {main}
      thrown in /public_html/wp-includes/class-wp-hook.php on line 307
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter protohominid

    (@protohominid)

    Answering my own question here…

    The issue was this function that I had added to my theme’s functions.php file:

    add_filter( 'lwptoc_enqueue_style', false );

    I was trying to prevent the plugin’s default stylesheet from loading. Does anyone know the proper way to do that without angering the php8 gods?

    Hi, you could try and exclude using a plugin like Asset Cleanup. This is what I use.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.