Support » Plugin: Easy Table of Contents » Alternate Headings Bug

  • I noticed that “Alternate Headings” does not work in the current version of the plugin.

    In easy-table-of-contents.php file you replace the title and save new in $toc variable.

    if ( @preg_match( ‘/^’ . $original_heading . ‘$/imU’, strip_tags( $toc[ $i ][0] ) ) ) {
    //$matches[ $i ][0] = str_replace( $original_heading, $alt_heading, $matches[ $i ][0] );
    $toc[ $i ][0] = $alt_heading;
    }

    https://i.imgur.com/RLjeLJf.png

    Then you use $matches variable to print the $title
    https://i.imgur.com/GpygN1K.png
    ——–

    Maybe it depends on the version of PHP and in some versions when changing the $toc – changes $matches, but I think that this is the wrong approach.
    https://i.imgur.com/LxRJkAf.png

    ——–

    And thanks for the plugin, very useful, except this little bug.

    • This topic was modified 4 months, 2 weeks ago by  sdelfi.
Viewing 1 replies (of 1 total)
  • But my hack did not work, because incorrectly formed anchor (I have it custom, modified through hook – ez_toc_url_anchor_target)

    I was helped by the following change

    $title = strip_tags( apply_filters( ‘ez_toc_title’, $matches[ $i ][0] ), apply_filters( ‘ez_toc_title_allowable_tags’, ” ) );

    to

    $title = strip_tags( apply_filters( ‘ez_toc_title’, $toc[ $i ][0] ), apply_filters( ‘ez_toc_title_allowable_tags’, ” ) );

    After change https://i.imgur.com/RZDQ70n.png

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