Non-static method error – jQuery Vertical Accordion Menu plugin – WordPress

I’ve been using the jQuery Vertical Accordion Menu plugin for quite some time now but when I updated to WordPress 4.1 the plugin throws an error message that looks like the screenshot provided here.

I think I’ve located it to the dcwp_jquery_accordion.php since it doesn’t display the error when those lines are commented out.
What is the correct way to use the add_action?

Read More

Thanks!

Best regards,
Marcus

function dc_jqaccordion(){
    global $registered_skins;

    if(!is_admin()){

        // Header styles
//      add_action( 'init', array('dc_jqaccordion', 'header') );

        // Shortcodes
        add_shortcode( 'dcwp-jquery-accordion', 'dcwp_dc_jqaccordion_shortcode' );
    }
//  add_action( 'wp_footer', array('dc_jqaccordion', 'footer') );

    $registered_skins = array();

Related posts

Leave a Reply

2 comments

  1. The issue in my case was that the functions needed to be public static function instead of just function

    The plugin works now.
    Thanks @mmk

  2. The correct way to use add_action() is like so:

    add_action('the_action_you_want_to_target','your_function');
    function your_function(){
        //your code goes here
    }
    

    if you want to enqueue scripts you can do it in using another add_action() like so:

    add_action('wp_enqueue_scripts','My_Stylesheets_and_Scripts'); 
    function My_Stylesheets_and_Scripts(){
     wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
    }
    

    The true part means the script will get enqueued in the footer. false renders the script in the header.