From fc2f9df23ca8a69b92f4616c0eb9287e953d5439 Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Sat, 22 Jan 2022 22:17:27 -0500 Subject: [PATCH] Classic editor support --- plugin.php | 41 ++++++++------ tinymce/cogicon.ico | Bin 1150 -> 0 bytes tinymce/cogicon.png | Bin 0 -> 4046 bytes tinymce/dialog.php | 129 ++++++++++++++++---------------------------- tinymce/plugin.js | 56 ++++++++++--------- 5 files changed, 103 insertions(+), 123 deletions(-) delete mode 100755 tinymce/cogicon.ico create mode 100644 tinymce/cogicon.png mode change 100755 => 100644 tinymce/dialog.php 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 62b50ba6b9e6f2037e3a270a7dabef1d4ded8c47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1150 zcmZ{jOK4L;6ox12&P@?~EL`-JTDA3o6>L>R1wkp+rdp+^uYFz^80Pvvl8tO0Vi>4kNN zebm`MN%x*d>A{N__1pGDl;P>BWY1i3+-1F_{1SS5MG^C|yd$+7%9Ga7$3CseM`{W*&B(BxK=4bAPsd69s z=hA6Yr=K`?BkZbnSwFvn36fw6q*#CC<^-iPRUaF>i>?O0PQ&+q%H0-T7A&V zS|)94x%a!#ml5urcRVBO4@I)n_hgzlkM=Wz`VIOv@|QLv2V(iGnn4XvXK)>Tp{tL7 zQ8H!Kz$c(iA#W7qS=Jtqd*7a;Q~FEr75M!wK8(?!H?8fEz31Am z73uj~2m)TqJ6*cD@tD=Ky}co7>hklMnILb+Ou()IYVXAuzXJSTr$8@ahmnUEjDNs) z1-QW|cny{Td8gO{&N261v|yeEe1F=3+N%QNrD|U4Qrc^EuzY`K0N=|}p~BcEglE1G Uw;UE~TpY}PwZ^eutAy140|l}o*Z=?k diff --git a/tinymce/cogicon.png b/tinymce/cogicon.png new file mode 100644 index 0000000000000000000000000000000000000000..279ebd94d5812c3758417ef806ebdd049aed75b3 GIT binary patch literal 4046 zcmV;<4>9nGP)c)JMq`Y|G(OUpn8q|3 zf?8{^*7}IuY892n`a%VKP*!Si9LL-mhV^u0qTA`>IEFcvXarNxO z{r1JO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3nW4qu2?u1F1SaY(M8~62BYl)~$%+|4bD09bG%9Z2$lO07*qoM6N<$f_JT~ A`~Uy| literal 0 HcmV?d00001 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 ); +} )(); +