Freesoul Deactivate Plugins for Developers

Adding Custom AJAX Actions to FDP Settings

If you want to register the AJAX actions of your plugin or theme within the FDP interface, use the eos_dp_integration_action_plugins filter as shown in the following example:

add_filter( 'eos_dp_integration_action_plugins','my_plugin_add_fdp_integration' );
// Add custom ajax actions to the FDP Actions Settings Pages.
function my_plugin_add_fdp_integration( $args ){
    $args['my-plugin'] = array(
        'is_active' => defined( 'MY_CUSTOM_PLUGIN_VERSION' ),
        'ajax_actions' => array(
            'my_action_example_name' => array( 'description' => __( 'Example of action description','my-textdomain' ) ),
            'my_action_other_example_name' => array( 'description' => __( 'Other example of action descriptionn','my-textdomain' ) ), )
    );
    return $args;
}

 

The is_active key should return true when your plugin or theme is active. In the example above, we used defined( 'MY_CUSTOM_PLUGIN_VERSION' ), assuming this constant is defined within your plugin.

Alternatively, you can use function_exists(), class_exists(), or any other method that confirms your specific software is running.

In the example, 'my_action_example_name' represents the action hook used to register your AJAX function. If you are following this pattern, your AJAX callback should be registered as follows:

 

add_action( 'wp_ajax_my_action_example_name','my_action_example_name' );

function my_action_example_name(){

    //Your code...

}

 

 

Once registered, your actions will appear in the FDP settings as shown in the following image:

If you are a plugin author, including this code allows you to troubleshoot AJAX issues more effectively. If users experience conflicts with your plugin’s AJAX actions, FDP makes it easy to selectively deactivate other plugins to isolate the problem.

Checking if a Plugin is Globally Active Programmatically

You can determine if a plugin is globally active using the FDP helper function fdp_is_plugin_globally_active( $plugin ).

Example:

$plugin = ‘woocommerce/woocommerce.php’;

if( function_exists( 'fdp_is_plugin_globally_active' ) && fdp_is_plugin_globally_active( $plugin ) ){
    // Your code here.
}

 

The $plugin variable must be the path to the plugin’s main file relative to the WordPress plugins directory.