最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Custom plugin activation error

programmeradmin1浏览0评论

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();
  }
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论