Migrate everything to Typescript & do lots of cleanup 🎉
This commit is contained in:
55
plugin.php
55
plugin.php
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
Plugin Name: Cognito Forms
|
||||
Plugin URI: http://wordpress.org/plugins/cognito-forms/
|
||||
Description: Cognito Forms is a free online form builder that integrates seemlessly with WordPress. Create contact forms, registrations forms, surveys, and more!
|
||||
Description: Cognito Forms is a free online form builder that integrates seamlessly with WordPress. Create contact forms, registrations forms, surveys, and more!
|
||||
Version: 2.0.0
|
||||
Author: Cognito Apps
|
||||
Author URI: https://www.cognitoforms.com
|
||||
@@ -30,11 +30,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Block Initializer.
|
||||
*/
|
||||
require_once plugin_dir_path( __FILE__ ) . 'src/init.php';
|
||||
|
||||
/**
|
||||
* The Plugin
|
||||
*/
|
||||
@@ -44,7 +39,8 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
||||
// Initialization actions
|
||||
private static $actions = array(
|
||||
'admin_init',
|
||||
'admin_menu'
|
||||
'admin_menu',
|
||||
'init'
|
||||
);
|
||||
|
||||
// Registers plug-in actions
|
||||
@@ -90,6 +86,51 @@ if ( !class_exists('CognitoFormsPlugin') ) {
|
||||
}
|
||||
}
|
||||
|
||||
public function init() {
|
||||
$this->block_init();
|
||||
}
|
||||
|
||||
// Initialize block
|
||||
public function block_init() {
|
||||
$dir = dirname( __FILE__ );
|
||||
|
||||
$asset_file = include( plugin_dir_path( __FILE__ ) . 'dist/index.asset.php');
|
||||
|
||||
// Register global block styles
|
||||
wp_register_style(
|
||||
'cognito-block-global-css', // Handle.
|
||||
plugins_url( 'dist/style.css', __FILE__ ),
|
||||
is_admin() ? array( 'wp-editor' ) : null, // Dependency to include the CSS after it.
|
||||
null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: File modification time.
|
||||
);
|
||||
|
||||
// Register block editor script for backend
|
||||
wp_register_script(
|
||||
'cognito-block-editor-js',
|
||||
plugins_url( 'dist/index.js', __FILE__ ),
|
||||
$asset_file['dependencies'],
|
||||
$asset_file['version']
|
||||
);
|
||||
|
||||
// Register block editor styles for backend.
|
||||
wp_register_style(
|
||||
'cognito-block-editor-css', // Handle.
|
||||
plugins_url( 'dist/editor.css', __FILE__ ), // Block editor CSS.
|
||||
array( 'wp-edit-blocks' ), // Dependency to include the CSS after it.
|
||||
null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
|
||||
);
|
||||
|
||||
register_block_type(
|
||||
'cognito-forms/cognito-embed', array(
|
||||
// Enqueue global block styles on both frontend and backend
|
||||
'style' => 'cognito-block-global-css',
|
||||
// Enqueue block js in the editor only
|
||||
'editor_script' => 'cognito-block-editor-js',
|
||||
// Enqueue editor block styles in the editor only
|
||||
'editor_style' => 'cognito-block-editor-css'
|
||||
) );
|
||||
}
|
||||
|
||||
// Set up tinyMCE buttons
|
||||
public function mce_buttons($buttons) {
|
||||
array_push($buttons, '|', 'cognito');
|
||||
|
Reference in New Issue
Block a user