• Had the plugin profiler enabled, and it showed that Search Everything took most cpu-time.

    Changed the plugin, so it only loaded when needed, and the profiler became happy:

    function se_initialize_plugin($query) {
    global $SE;
    if (!isset($SE) && $query->is_search())
    $SE = new SearchEverything();
    }
    add_filter(‘parse_query’, ‘se_initialize_plugin’);

    function se_initialize_plugin_admin() {
    global $SE;
    if (is_admin())
    $SE = new SearchEverything();
    }
    add_action(‘wp_loaded’,’se_initialize_plugin_admin’);

    function se_global_head() {
    if (is_admin() || is_search())
    include(se_get_view(‘global_head’));
    }
    add_action(‘wp_head’, ‘se_global_head’);

    function se_enqueue_styles() {
    if (is_admin() || is_search())
    wp_enqueue_style(‘se-link-styles’, SE_PLUGIN_URL . ‘/static/css/se-styles.css’);
    }

    add_action(‘wp_enqueue_scripts’, ‘se_enqueue_styles’);

    https://wordpress.org/plugins/search-everything/

Viewing 1 replies (of 1 total)
  • Hey,

    thanks for publishing the code – hopefully someone else will find it useful too.

    Once again, thanks for taking the time for the feedback, take care and have a lovely day,

    Petra

Viewing 1 replies (of 1 total)

The topic ‘Only load when needed’ is closed to new replies.