define_constants(); register_activation_hook( __FILE__, array( $this, 'activate' ) ); if ( ! $this->is_gutenberg_active() ) { $this->dependency_error(); return; } add_action( 'plugins_loaded', array( $this, 'init_plugin' ) ); } /** * Initializes the acepress-blocks() class * Checks for an existing acepress-blocks() instance */ public static function instance() { if ( is_null( self::$_instance ) ) { self::$_instance = new self(); } return self::$_instance; } /** * Define the constants * * @return void */ public function define_constants() { define( 'acepress_Blocks_VERSION', $this->version ); define( 'acepress_ROOT_FILE', __FILE__ ); define( 'acepress_ROOT_PATH', plugin_dir_path( __FILE__ ) ); } /** * Initialize the plugin * * @return void */ public function init_plugin() { $this->includes(); } /** * Check if Gutenberg is active * * @since 0.1.0 * * @return boolean */ public function is_gutenberg_active() { return function_exists( 'register_block_type' ); } /** * Placeholder for activation function */ public function activate() { $installed = get_option( 'acepress_Blocks_installed' ); if ( ! $installed ) { update_option( 'acepress_Blocks_installed', time() ); } update_option( 'acepress_Blocks_version', acepress_Blocks_VERSION ); } /** * Include the required files * * @return void */ public function includes() { require_once __DIR__ . '/includes/Blocks.php'; new AcepressBlocks(); } /** * Admin notice for no EDD or WC */ public function dependency_error() { if ( ! current_user_can( 'manage_options' ) ) { return; } echo '
'; echo '

acepress-blocks Blocks requires Gutenberg plugin installed or WordPress 5.0.

'; echo '
'; } } Acepress::instance();