I am having a small issue where i need to call add_action method which is conditional.
Basically here, first checking whether the plugin active or not by admin_init action. If true then i need another add_action call from that action.

Please find the scenario what i am looking for:

        function check_some_other_plugin() {
            if ( is_plugin_active('some-plugin.php') ) {
                    //if true then vc_before_init action will run
                    add_action( 'vc_before_init', 'vc_master_home_slider' );
            }
        }
        add_action( 'admin_init', 'check_some_other_plugin' );

        function vc_master_home_slider() {
            //my stuff
        }

I will really appreciate if somebody answer me to find actual way to get rid of this issue.

1 Answer
1

just check inside the action ^^

add_action( 'vc_before_init', 'vc_master_home_slider' );

function vc_master_home_slider(){
  if(is_plugin_active('some-plugin.php'){
    //Do stuff.
  }
}

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *