Create shared actions for admin and users with plugin bolierplate

OK. So the solution for now is to add an action to the admin_post method in the boilerplate $this->loader->add_action( ‘admin_post_generate_reservation’, $plugin_shared, ‘generate_reservation_file’ ); and then in the shared class public function generate_reservation_file(){ //code here } the link in the front and backend <a href=”https://wordpress.stackexchange.com/questions/248775/<?php echo esc_url( admin_url(“admin-post.php’) ); ?>?action=generate_reservation&id=<?php echo $_GET[‘profil’] ?>” target=”_blank”><strong>text</strong></a>

Define a url for an email confirmation from within a plugin

Insert in your functions.php file the following code function order_confirm_token() { if(isset($_GET[‘myconfirmation’])) { $confirmation_token = $_GET[‘myconfirmation’]; // Do something with token } } add_action(‘init’, ‘order_confirm_token’); Then when you send the user the email to confirm the email direct them to the home page like this: www.example.com/?myconfirmation=TOKENCODE

Ajax functionality not being called under wordpress plugin

Syntax error comes from your js file that is containing php code. You don’t need this part to be in the js file and need to be in a php file. <?php function form_ajax_process_request() { if( isset( $_POST[“post_var”] ) ) { $response = $_POST[“post_var”]; echo $response; die(); } } add_action(‘wp_ajax_form_response’,’form_ajax_process_request’); add_action(‘wp_ajax_nopriv_form_response’,’form_ajax_process_request’); ?> This part need … Read more

Singleton plugin activation; create database

There is an error here. You’ve not declared _register_hooks() method. And I instantiated the class like below- global $p; if(empty($p)){ $p = plugin::getInstance(); $p->activate(); } And it worked. For your case that has not worked cause WordPress uses a variable with name $plugin in its life cycle. And your code checks it’s empty or not. … Read more