I am having this error and I cannot understand where the problem is.
I am learning plugin development and I am trying to create an OOP plugin to facilitate myself during development.
When I try to activate my custom plugin I get this error:
What I am doing wrong?
-- Main plugin file --
defined('ABSPATH') or die('(ಠ_ಠ)┌∩┐ NOPE!'); // or any other WP related stuff like add_action
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require_once(__DIR__ . '/vendor/autoload.php');
}
function activate_oop_plugin(){
\WPlugin\Core\Activate::activate();
}
register_activation_hook(__FILE__, 'activate_oop_plugin');
function deactivate_oop_plugin(){
\WPlugin\Core\Deactivate::deactivate();
}
register_deactivation_hook(__FILE__, 'deactivate_oop_plugin');
\WPlugin\Init::register_services();
-- Activate file --
namespace WPlugin\Core;
use WPlugin\Controllers\BaseController;
class Activate extends BaseController
{
public static function activate()
{
flush_rewrite_rules();
$default = array();
if (!get_option('test_plugin')) {
update_option('test_plugin', $default);
}
if (!get_option('test_plugin_cpt')) {
update_option('test_plugin_cpt', $default);
}
}
}
-- Deactivate file --
namespace WPlugin\Core;
class Deactivate{
public static function deactivate(){
flush_rewrite_rules();
}
}