I'm developing a wordpress plugin for a project. I'm expected to manage other plugins in this plugin. For example, I will be able to install Akismet over my plugin. I have done things like install, activating, deactivating. But I could not delete the plugin.
I can also delete direct attachment files, but I don't want to. I should use as many wordpress functions as possible.
delete_plugins('litespeed-cache/litespeed-cache.php')
This function does not work. I tried to integrate this function, but it was very complicated. Can you help me?
--EDİT--
I'm sorry, I didn't pay attention. There is another problem right now. I wrote a new plugin and it worked fine when I added the following code.
register_activation_hook( __FILE__, 'index' );
function index() {
delete_plugins( [
'litespeed-cache/litespeed-cache.php',
] );
}
But it didn't work on my own plugin.
add_action('exampleUninstallPlugin','exampleUninstallPlugin');
function exampleUninstallPlugin($plugins){
delete_plugins($plugins);
}
add_action( 'rest_api_init', 'customTestFunction' );
function customTestFunction() {
register_rest_route( 'turhost/rest', '/api', array(
'methods' => 'POST',
'callback' => 'show_fields'
) );
}
function show_fields( $request ) {
$parameters = json_decode( base64_decode( $request->get_param( 'data' ) ), true );
if ( $parameters['action'] == "uninstallInstalledPlugin" ) {
do_action('turhostUninstallPlugin',[
'litespeed-cache/litespeed-cache.php'
]);
}
}