I'm trying to create a link/button inside a wordpress site which starts a plugin if you click on it (in my case it should make a cookie banner appear). I'm completely new to this so I'm not 100% sure which function actually starts the cookie banner but i assume it's function func_wp_vue()inside the main.php. The main.php looks like this:
<?php
function func_load_vuescripts() {
wp_register_script('wp_js', plugin_dir_url( __FILE__ ).'dist/js/app.js', [], '1.0.0', true);
wp_register_script('wp_js1', plugin_dir_url( __FILE__ ).'dist/js/chunk-vendors.js', true);
wp_register_style('wp_css', plugin_dir_url( __FILE__ ).'dist/css/app.css', true);
wp_register_style('wp_css1', plugin_dir_url( __FILE__ ).'dist/css/chunk-vendors.css', true);
}
add_action('wp_enqueue_scripts', 'func_load_vuescripts');
function func_wp_vue(){
wp_enqueue_script('wp_js');
wp_enqueue_script('wp_js1');
wp_enqueue_style('wp_css');
wp_enqueue_style('wp_css1');
$str = "<div id='app'>"
.""
."</div>";
return $str;
}
add_shortcode( 'cookie', 'func_wp_vue' );
The plugin is uploaded and loads on the site but i would like to manually activate the cookie banner again if i click on the link/button.
I tried to implement it with<p><a href="wp-content/plugins/cookie/main.php">Click me</a></p> into the wordpress site but just get this error:
Fatal error: Uncaught Error: Call to undefined function add_action() in /home/www/wordpress-cookie/wp-content/plugins/cookie/main.php:16 Stack trace: #0 {main} thrown in /home/www/wordpress-cookie/wp-content/plugins/cookie/main.php on line 16
Any help is appreciated!