• Hi, I’m using the functions below to highlight search results of the standard WordPress search.
    After installing Bento 1.8.1 it appeared to be broken. A rollback to 1.8.0 restored the function.

    The problem seems to be in the function ‘highlight_results_css()’ (bold).
    The last ‘}’ is marked as an error.

    Please can you have a look in it?

    Thank you!

    function highlight_results($text){
    if(is_search()){
    $keys = implode(‘|’, explode(‘ ‘, get_search_query()));
    $text = preg_replace(‘/(‘ . $keys .’)/iu’, ‘<span class=”search-highlight”>\0</span>’, $text);
    }
    return $text;
    }
    add_filter(‘the_content’, ‘highlight_results’);

    function highlight_results_css() {
    ?>
    <style>
    .search-highlight { background-color:#FF0; font-weight:bold; }
    </style>
    <?php
    }

    add_action(‘wp_head’,’highlight_results_css’);

    function bbp_tinymce_paste_plain_text( $plugins = array() ) {
    $plugins[] = ‘paste’;
    return $plugins;
    }
    add_filter( ‘bbp_get_tiny_mce_plugins’, ‘bbp_tinymce_paste_plain_text’ );

Viewing 4 replies - 1 through 4 (of 4 total)
  • Theme Author satoristudio

    (@satoristudio)

    Hello Theo,

    thank you for choosing Bento!

    To the best of our judgement, there are no changes in ver 1.8.1 that could directly produce this issue (yet I might be wrong, of course). In any case, could you please provide some additional details about the problem at hand – namely, where are the custom functions inserted, how does the full error message look on the front end, and how the front end is affected by the issue overall (white screen of death / just the notice / something specific breaks). Thanks for your patience!

    Thread Starter theojager

    (@theojager)

    Thanks for your confirmation that in version 1.8.1 no changes have been applied that would cause the behavior I experienced.
    So, I created a clone of my site, removed the custom functions at the end of functions.php, updated the theme and inserted the custom functions again.
    The file was updated correctly (previous times saving the file gave a syntax error).
    Just upgraded my production site and also there it’s working again.
    The difference with my previous attempts: I removed now the custom functions before upgrading the theme.

    Thanks again!

    • This reply was modified 6 years, 8 months ago by theojager.
    Theme Author satoristudio

    (@satoristudio)

    To clarify – did the error message only show when upgrading the theme without removing the custom functions? did I understand correctly that at the moment your website is running without displaying the notices?

    In case you were inserting the custom functions directly into the theme’s main functions.php file, I strongly recommend using a child theme for custom functions or function overrides instead – this way there’ll be much less risk of issues during upgrades.

    Thread Starter theojager

    (@theojager)

    Yes, the error was only shown after the upgrade with the modified functions.php file.
    Yes, the site is now running correctly, even with the custom functions.

    I agree that I should use a child theme and this error helps to change my approach. Thanks for reminding me to it ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bento 1.8.1 seems to break a custom function’ is closed to new replies.