Can NOT get functions to work… in child theme or otherwise

  • BarryL

    #5801

    I am trying to get the following functions into the graphene theme – these are functions I have used HUNDREDS of times elsewhere without issue. I have tried inserting into functions.php, theme-functions.php, child theme functions.php – nothing but error message seen below. Be advised I HAVE tried it both with and without enclosing in ?php statements (searched this forum a ton before posting this).

    The functions:

    add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
    add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

    add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );

    function my_deregister_javascript() {
    if ( !is_page('contact') ) {
    wp_deregister_script( 'contact-form-7' );
    }
    }
    add_action( 'wp_print_styles', 'my_deregister_styles', 100 );

    function my_deregister_styles() {
    if ( !is_page('contact') ) {
    wp_deregister_style( 'contact-form-7' );
    }
    }
    add_filter('bwp_minify_style_ignore', 'exclude_my_css');
    function exclude_my_css($excluded)
    {
    $excluded = array('sociablecss','admin-bar');
    return $excluded;
    }

    This is the error message (seems to be related to the first request):

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘_remove_script_version’ was given in /home/etc…/html/etc./wp-includes/plugin.php on line 170

    What might I be missing (and please – no reference to opening and closing php statement – doing that just loads the code above as compressed text)

    Prasanna SP

    #32700

    Where is _remove_script_version function located?

    BarryL

    #32701

    Awww heck, I forgot to copy the code for that over.

    For those that care, these little bits deregister unnecessary code from loading on the bulk of your site (contact-form-7 plugin is notoriously wasteful).

    Anyway, the missing code (s/h/b above the first two filter calls…)

    function _remove_script_version( $src ){
    $parts = explode( '?', $src );
    return $parts[0];
    }

    Call this one resolved, sorry for wasting your time…. Put it in child theme / functions.php with the surrounding ?php/ ? etc. and it worked like a charm.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.