Is there a way to programmatically enable a plugin?

Question

<?php

    namespace wppluginbasic;

    class Basic extends hgwordpressAbstractPlugin
    {

    public function register()
    {

        add_action('wp_ajax_simple_ajax2', array($this, 'onBasicFunc'));
        add_action('wp_ajax_nopriv_simple_ajax2', array($this, 'onBasicFunc'));

    }

    public function onBasicFunc()
    {
        $data = $_REQUEST; // retrieve your submitted data

        wp_send_json($_REQUEST); // return the processed data to the browser as json

        die();
    }
}

The above doesn’t work when I try to call it from the frontend, but if I put the content inside functions.php it works as expected. I am guessing it’s because I didn’t enable the plugin, but is there a way to programatically enable it? My plugin is just supposed to be something that returns a result when doing an ajax call.

0
saro 2 months 2021-05-20T18:18:43-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse