diff --git a/plugin.php b/plugin.php index fe60d3a..84e7e15 100644 --- a/plugin.php +++ b/plugin.php @@ -49,7 +49,7 @@ if ( !class_exists('CognitoFormsPlugin') ) { add_action($action, array($this, $action)); } - // Registers tinyMCE filters + // Registers plug-in filters private function addFilters($filters) { foreach($filters as $filter) add_filter($filter, array($this, $filter)); @@ -60,6 +60,11 @@ if ( !class_exists('CognitoFormsPlugin') ) { $this->addActions(self::$actions); } + public function init() { + // Initialize Gutenberg Block + $this->block_init(); + } + // Initialize plug-in public function admin_init() { if(!current_user_can('edit_posts') && !current_user_can('edit_pages')) return; @@ -77,17 +82,8 @@ if ( !class_exists('CognitoFormsPlugin') ) { delete_option('cognito_organization'); } - // Add tinyMCE plug-in - if(get_user_option('rich_editing') == 'true') { - $this->addfilters(array( - 'mce_buttons', - 'mce_external_plugins' - )); - } - } - - public function init() { - $this->block_init(); + // Initialize TinyMCE Plugin + $this->tinymce_init(); } // Initialize block @@ -131,16 +127,26 @@ if ( !class_exists('CognitoFormsPlugin') ) { ) ); } - // Set up tinyMCE buttons + // Initialize classic editor (TinyMCE) + public function tinymce_init() { + if(get_user_option('rich_editing') == 'true') { + $this->addFilters(array( + 'mce_buttons', + 'mce_external_plugins' + )); + } + } + + // Set up TinyMCE buttons public function mce_buttons($buttons) { array_push($buttons, '|', 'cognito'); return $buttons; } - // Initialize tinyMCE plug-in - public function mce_external_plugins($plugins) { - $plugins['cognito'] = plugin_dir_url( __FILE__ ) . 'tinymce/plugin.js'; - return $plugins; + // Initialize TinyMCE plug-in + public function mce_external_plugins( $plugin_array ) { + $plugin_array['cognito_mce_plugin'] = plugins_url( '/tinymce/plugin.js', __FILE__ ); + return $plugin_array; } // Initialize administration menu (left-bar) @@ -162,5 +168,6 @@ if ( !class_exists('CognitoFormsPlugin') ) { include 'templates/options.php'; } } + new CognitoFormsPlugin; } diff --git a/tinymce/cogicon.ico b/tinymce/cogicon.ico deleted file mode 100755 index 62b50ba..0000000 Binary files a/tinymce/cogicon.ico and /dev/null differ diff --git a/tinymce/cogicon.png b/tinymce/cogicon.png new file mode 100644 index 0000000..279ebd9 Binary files /dev/null and b/tinymce/cogicon.png differ diff --git a/tinymce/dialog.php b/tinymce/dialog.php old mode 100755 new mode 100644 index 448343a..8c82a4e --- a/tinymce/dialog.php +++ b/tinymce/dialog.php @@ -15,89 +15,54 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - ?> +?> + - - - - - - - - Cognito Forms - - - - - - -
-

Embed a Form

-
- -
- -
-
- + top.tinymce.activeEditor.windowManager.close(); + } + + diff --git a/tinymce/plugin.js b/tinymce/plugin.js index 72198b5..ef075eb 100755 --- a/tinymce/plugin.js +++ b/tinymce/plugin.js @@ -1,24 +1,32 @@ -(function(){ - tinymce.create('tinymce.plugins.cognito', { - init : function(ed, url) { - ed.addCommand('cognito_embed_window', function() { - ed.windowManager.open({ - file : url + '/dialog.php', - width : 400, - height : 160, - inline: 1 - }, { plugin_url : url, ajax_url: ajaxurl }); - }); - - ed.addButton('cognito', { - title : 'Cognito Forms', - cmd : 'cognito_embed_window', - image : url + '/cogicon.ico' - }); - } - }); - - tinymce.PluginManager.add('cognito', tinymce.plugins.cognito); - -})() - +( function() { + tinymce.create( 'tinymce.plugins.cognito_mce_plugin', { + getInfo: function() { + return { + longname: 'Cognito Forms', + author: 'cognitoapps', + authorurl: 'https://cognitoforms.com', + infourl: 'https://cognitoforms.com', + version: "2.0", + }; + }, + init: function( editor, url ) { + editor.addCommand( 'cognito_embed_window', function() { + editor.windowManager.open( { + title: 'Cognito Forms', + url: url + '/dialog.php', + width: 500, + height: 500, + } ); + } ); + + editor.addButton( 'cognito', { + title: 'Cognito Forms', + cmd: 'cognito_embed_window', + image: url + '/cogicon.png', + } ); + }, + } ); + + tinymce.PluginManager.add( 'cognito_mce_plugin', tinymce.plugins.cognito_mce_plugin ); +} )(); +