Need to unhook the GSE plugin from over-writing default WP search box

Hi folks
trying to 'optimize' use of the GSE plugin for one of our sites (not multisite, but our corp. portal). Basically we're having the search results load on the theme search page. However the plugin is a bit messy when making search box on single/template pages as it adds a number of js calls (and even got an adsense call when we don't use AdSense and are using PAID version of CSE ad-free), with simple search box. Plugin ALSO fully over-rides the default WP search box (if we don't use the widget for plugin), by adding all the Google JS which is not needed. So, I basically just put in a dumb search box in text field to get the 'clean' iteration. Ideally however, the plugin should *not* over-ride the default WP search box for those who don't need all the js loaded from Google on EVERY page of the site (!),. Bad for speed, optimization and bloats the page size/time. In a perfect world,. what we'd love to have is *only* the code active which does the internal redirect to the WP > search to > GSE, and NOTHING else, since that also works wonderfully with a normal URL search via browser window, which ultimately is all we really want. Hope that made sense.

If nothing, else a filter to disable the over-write of WP default search would help! If not possible we'll just roll our own, and then ponder perhaps extracting just the functions from plugin that do the GSE redirect (hint: would make good how-to for blog post!). Basically the redirect to the GSE is the magic trick for us.

- or, section of plugin code I can delete (we have no issue hacking code/core, as this is our corp site, not client project, and all auto updates and WPMU main plugin OFF after reg/auth.). THANKS :slight_smile:

  • neotrope

    Hi
    also need to de-enguque these for all pages except the search page; or delete for all pages and I can manually add to search template

    <link rel='stylesheet' id='CGSStyle-css' target='_blank' href='https://mysite.ooo/wire/assets/plugins/custom-google-search/style/cgs-style.css' type='text/css' media='all' />
    <link rel='stylesheet' id='CGSStyle_popup_theme-css' target='_blank' href='https://mysite.ooo/wire/assets/plugins/custom-google-search/style/popup_themes/flick/custom.css' type='text/css' media='all' />

    again - terribly inefficient to load all this stuff on EVERY page when not needed; not using the popup from setting should de-enqueue the popup css by default , right ?

    Thanks!

    FYI, just removing the js from google for your default CSE box cut the page size almost 200kb (!) .. seriously.

  • neotrope

    Hi, okay - was able to simply cut out the calls to the css elements from the plugin core code, then simply use normal text box to implement optimized search box without loading all the Google JS

    e.g.,
    <div class="textwidget"></div>
    </div><div id="search-2" class="widget widget_search"><h4 class="widgettitle">Search News Archive</h4><form method="get" id="searchform" action="https://mysite.ooo/wire/">
    <i class="fa fa-search icon-search"></i>
    <input type="text" name="s" id="s" placeholder="Search" />

    </form></div>
    <div class="clearfix">

    So, upshot. You might want to revisit some "optimization" for the plugin on the next go-round.

    For me, for now, I'm all sorted :slight_smile:

  • Adam Czajczyk

    Hello neotrope,

    I hope you're well today and thank you for your posts.

    I'm sorry I wasn't able to reach this thread before you posted your solution. As you mentioned that you don't mind "hacking" plugin's core files, this surely will work for you.

    I think removing plugin's CSS may be better with an wp_dequeue() WP function like this:

    wp_dequeue_style('CGSStyle');
    wp_dequeue_style('CGSStyle_popup_theme');
    wp_dequeue_style('CGSHideButton');

    However, some JS scripts are indeed "hard-coded" into the plugin so your way may be the only way to go here. Please note however that the plugin wasn't built with paid/premium version of CSE in mind so I think that's the reason it's putting all those calls there without even checking if they're necessary.

    That said, I agree it would benefit from some optimization and a built in support for premium Google Custom Search would be a great feature, therefore I'm moving this thread to our "Features and Feedback" forum which is followed by developers. I'm not able to give you any ETA on this but it will not remain unnoticed.

    In case you have any further questions/suggestions or needed any further help, let me know please and I'll be happy to assist.

    Best regards,
    Adam

  • neotrope

    Hi, thanks for getting back to me on a Saturday. :slight_smile:

    I know many of these plugins are designed for "everybody under all uses" kind of stuff, and we're kind of advanced users, who often take the "everyman" stuff then do some tweaks, as in this case.

    Definitely some toggles for not overwriting the default WP search box would be good, as well as being aware of the slight difference in the PAID version (such as on a business/corp site).

    Mostly it was the 200k of Google stuff loading for a simple search box where it wasn't needed for the sidebar when target was search page for results vs inline in sidebar or popup, that was throwing me. :slight_smile:

    It's all good now, so we can call this "resolved" for all intents and purposes.

    SO, thanks for moving to the 'feedback' (vs bitching) topic :wink:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.