Changeset 2248759
- Timestamp:
- 02/22/2020 03:21:55 PM (6 years ago)
- Location:
- platformly/trunk
- Files:
-
- 7 edited
-
css/editor_btn.css (modified) (1 diff)
-
inc/ply.btn.php (modified) (12 diffs)
-
js/editor_btn.js (modified) (1 diff)
-
js/ply_add_link_functions.js (modified) (6 diffs)
-
js/ply_editor_btn_functions.js (modified) (2 diffs)
-
platformly.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
platformly/trunk/css/editor_btn.css
r2024659 r2248759 133 133 margin-right: -13px; 134 134 } 135 136 #ply-dialog-link-settings { 137 display: none; 138 padding: 5px 10px 10px 10px; 139 font-weight: bold; 140 border-top: 1px solid #dfdfdf; 141 position: relative; 142 } 143 #ply-dialog-link-settings table { 144 margin: 0px auto; 145 } 146 #ply-link-text-error, 147 #ply-link-url-error { 148 display: none; 149 font-weight: 300; 150 } -
platformly/trunk/inc/ply.btn.php
r2208564 r2248759 10 10 </div> 11 11 <script type="text/javascript"> 12 <?php if(!empty($projectCodeInclude) && !empty($projectCode)): ?> 13 var plyProjectMsg = "A code from Project '<span class='ply-project-name'></span>' is being used on this site."; 14 var plyProjectId = '<?php echo $projectCode['ply_project_id'] ?>'; 15 <?php else: ?> 16 var plyProjectMsg = 'You must include a Platform.ly project code within your site, please <a href="<?php echo get_admin_url(null, 'admin.php?page=ply') ?>">"click here"</a> to do it now.'; 17 var plyProjectId = 0; 18 <?php endif; ?> 12 <?php if(!empty($projectCodeInclude) && !empty($projectCode)): ?> 13 var plyProjectMsg = "A code from Project '<span class='ply-project-name'></span>' is being used on this site."; 14 var plyProjectId = '<?php echo $projectCode['ply_project_id'] ?>'; 15 <?php else: ?> 16 var plyProjectMsg = 'You must include a Platform.ly project code within your site, please <a href="<?php echo get_admin_url(null, 'admin.php?page=ply') ?>">"click here"</a> to do it now.'; 17 var plyProjectId = 0; 18 <?php endif; ?> 19 var editInElementor = <?php echo isEditInElementor() ? 'true' : 'false'; ?>; 20 var siteUrl = '<?php echo home_url(); ?>'; 21 19 22 jQuery(function ($) { 20 23 // initalise the dialog … … 28 31 resizable: false, 29 32 closeOnEscape: true, 30 maxHeight: 5 00,33 maxHeight: 550, 31 34 dialogClass: "ply-dialog-editor", 32 35 position: { … … 34 37 at: "center", 35 38 of: window 39 }, 40 close: function () { 41 $('#ply-dialog-link-settings').hide(); 36 42 }, 37 43 open: function () { … … 52 58 $('.ui-dialog-titlebar-close').addClass('ui-button'); 53 59 $('.ply-dialog-editor .ui-dialog-buttonpane').before('<div id="ply-dialog-footer"></div>'); 60 $('#ply-dialog-footer').after('<div id="ply-dialog-link-settings"></div>'); 54 61 }, 55 62 buttons: [{ … … 62 69 enteredUrl = jQuery('.chosenCustomLink:checked').data('mainlink') + '?' + (($("#trc1").val() != '') ? '&c1=' + $("#trc1").val() : '') + (($("#trc2").val() != '') ? '&c2=' + $("#trc2").val() : '') + (($("#trc3").val() != '') ? '&c3=' + $("#trc3").val() : '') + (($("#trc4").val() != '') ? '&c4=' + $("#trc4").val() : ''); 63 70 } 71 64 72 if(plySelectedWord.value.start == plySelectedWord.value.end){ 65 73 var newElement = wp.richText.insert(plySelectedWord.value, enteredUrl); … … 69 77 type: 'core/link', 70 78 attributes: { 71 url: enteredUrl ,79 url: enteredUrl 72 80 } 73 81 })); … … 76 84 type: 'core/link', 77 85 attributes: { 78 url: enteredUrl ,86 url: enteredUrl 79 87 } 80 88 })); … … 119 127 var action = selectedEvent.find('.existing-action span').text(); 120 128 var eventCode = "<script type='text/javascript'>plyt('"+action.replace(/[^a-zA-Z0-9_ ]/gi, "")+"', '"+description.replace(/[^a-zA-Z0-9_ ]/gi, "")+"','"+encodeURIComponent(id)+"');<\/script>"; 121 insertedBlock = wp.blocks.createBlock('core/html', { 122 content: eventCode, 123 }); 124 wp.data.dispatch('core/editor').insertBlocks(insertedBlock, 0); 129 130 if(typeof wp.richText !== 'undefined'){ 131 // Using WP blocks editor 132 insertedBlock = wp.blocks.createBlock('core/html', { 133 content: eventCode 134 }); 135 wp.data.dispatch('core/editor').insertBlocks(insertedBlock, 0); 136 } else if(typeof window.tinymce !== 'undefined' && !tinymce.activeEditor.isHidden()) { 137 // Using TinyMCE editor 138 tinymce.activeEditor.insertContent(eventCode); 139 } 125 140 closePlyDialog(); 126 141 }else{ … … 133 148 text: "Add on Link Click", 134 149 click: function() { 150 var link_text, link_url = siteUrl; 151 // Validate link settings 152 if (jQuery('#ply-dialog-link-settings').css('display') !== 'none') { 153 if (jQuery('#ply_dialog_link_text').val() === '') { 154 jQuery('#ply-link-text-error').show(); 155 return; 156 } 157 if (jQuery('#ply_dialog_link_url').val() === '') { 158 jQuery('#ply-link-url-error').show(); 159 return; 160 } 161 link_text = jQuery('#ply_dialog_link_text').val(); 162 link_url = jQuery('#ply_dialog_link_url').val(); 163 } 164 135 165 var id = jQuery('.chosenEvent:checked').val(); 136 166 if(typeof id !== 'undefined' && id.length > 0){ … … 139 169 var action = selectedEvent.find('.existing-action span').text(); 140 170 var eventCodeClick = "plyt('"+action.replace(/[^a-zA-Z0-9_ ]/gi, "")+"', '"+description.replace(/[^a-zA-Z0-9_ ]/gi, "")+"','"+encodeURIComponent(id)+"');"; 141 if(Object.keys(plySelectedWord).length > 0){ 142 var activeLink = wp.richText.getActiveFormat(plySelectedWord.value, 'core/link'); 143 var attributes = { 144 url: 'javascript:;', 171 172 if(typeof wp.richText !== 'undefined'){ 173 if(Object.keys(plySelectedWord).length > 0){ 174 var activeLink = wp.richText.getActiveFormat(plySelectedWord.value, 'core/link'); 175 var attributes = { 176 url: link_url, 145 177 onclick: eventCodeClick 146 } 147 if(typeof activeLink !== 'undefined'){ 148 attributes.url = activeLink.attributes.url; 149 if(typeof activeLink.attributes.target !== 'undefined'){ 150 attributes.target = activeLink.attributes.target; 151 } 152 } 153 plySelectedWord.onChange(wp.richText.applyFormat(plySelectedWord.value, { 154 type: 'core/link', 155 attributes: attributes 156 })); 157 }else if(Object.keys(plyEventButton).length > 0){ 158 plyEventButton.setAttributes({onclick: eventCodeClick}); 178 }; 179 180 if(typeof activeLink !== 'undefined'){ 181 attributes.url = activeLink.attributes.url; 182 if(typeof activeLink.attributes.target !== 'undefined'){ 183 attributes.target = activeLink.attributes.target; 184 } 185 } 186 187 plySelectedWord.onChange(wp.richText.applyFormat(plySelectedWord.value, { 188 type: 'core/link', 189 attributes: attributes 190 })); 191 } else if(Object.keys(plyEventButton).length > 0){ 192 plyEventButton.setAttributes({onclick: eventCodeClick}); 193 } 194 } else { 195 if (typeof window.tinymce !== 'undefined' && !tinymce.activeEditor.isHidden()) { 196 var selectedText = tinymce.activeEditor.selection.getContent(); 197 if (selectedText.length < 1) { 198 selectedText = link_text; 199 } 200 201 // Check if editing not in Elementor 202 if (elementor === 'undefined') { 203 tinymce.activeEditor.insertContent('<a href="javascript:;" onclick="eventCodeClick">' + selectedText + '</a>'); 204 } else { 205 var a_id = 'a_plyt_'+id, 206 linkTag = '<a href="'+link_url+'" target="_blank" id="' + a_id + '">' + selectedText + '</a>', 207 scriptTag = '<script type="text/javascript">jQuery("#' + a_id + '").on("click", function() {' + eventCodeClick + '})<\/script>'; 208 tinymce.activeEditor.insertContent(linkTag + scriptTag); 209 } 210 } else { 211 var selectedText = getSelected(); 212 if (selectedText.length < 1) { 213 selectedText = link_text; 214 } 215 QTags.insertContent('<a href="' + link_url + '" onclick="' + eventCodeClick + '">' + selectedText + '</a>'); 216 } 159 217 } 160 218 closePlyDialog(); … … 197 255 text: "Remove Event", 198 256 click: function(){ 199 //console.log(plyEventButton);200 257 delete plyEventButton.attributes.onclick; 201 258 closePlyDialog(); … … 211 268 }); 212 269 }); 270 271 <?php if (isEditInElementor()): ?> 272 elementor.hooks.addAction( 'panel/open_editor/widget/text-editor', function( panel, model, view ) { 273 setTimeout(function() { 274 elementorEditorAddButton(); 275 }, 500); 276 } ); 277 <?php else: ?> 213 278 QTags.addButton('platform_ly_link', 'Platform.ly', showPlyDialogOptions); 214 279 <?php endif; ?> 280 215 281 function getBlockDOMNode(clientId){ 216 282 document.querySelector('[data-block="' + clientId + '"]'); 217 283 } 284 285 function elementorEditorAddButton() { 286 // get an instance of the editor 287 var editor = tinymce.activeEditor; //or tinymce.editors[0], or loop, whatever 288 var plyButtonName = 'platform_ly_link'; 289 290 if (editor.buttons.hasOwnProperty(plyButtonName)) { 291 return; 292 } 293 294 //add a button to the editor buttons 295 editor.addButton(plyButtonName, { 296 title: 'Add Platform.ly Link', 297 icon: 'icon platform_ly_link_button', 298 onclick: function () { 299 showPlyDialogOptions(); 300 } 301 }); 302 //the button now becomes 303 var button=editor.buttons[plyButtonName]; 304 //find the buttongroup in the toolbar found in the panel of the theme 305 var bg=editor.theme.panel.find('toolbar buttongroup')[0]; 306 //without this, the buttons look weird after that 307 bg._lastRepaintRect=bg._layoutRect; 308 //append the button to the group 309 bg.append(button); 310 } 218 311 </script> 219 -
platformly/trunk/js/editor_btn.js
r2024659 r2248759 1 1 (function() { 2 2 tinymce.PluginManager.add('platform_ly_link', function( editor, url ) { 3 console.log('tinymce.PluginManager.add'); 4 3 5 editor.addButton('platform_ly_link', { 4 6 title: 'Add Platform.ly Link', -
platformly/trunk/js/ply_add_link_functions.js
r2208564 r2248759 55 55 }); 56 56 }); 57 jQuery('#ply-add-link-dialog').dialog({width: '600px'}) .position({ my: "center", at: "center", of: window });57 jQuery('#ply-add-link-dialog').dialog({width: '600px'}); // .position({ my: "center", at: "center", of: window }); 58 58 } 59 59 }); … … 86 86 </table>'; 87 87 jQuery('#ply-add-link-dialog').html(table); 88 jQuery('#ply-add-link-dialog').dialog('widget') .position({ my: "center", at: "center", of: window });88 jQuery('#ply-add-link-dialog').dialog('widget'); // .position({ my: "center", at: "center", of: window }); 89 89 jQuery('.ui-dialog-buttonpane button:contains("Add Link")').button().show(); 90 90 }else{ … … 113 113 } 114 114 function showPlyDialogOptions(){ 115 if(typeof wp.richText === 'undefined' ){115 if(typeof wp.richText === 'undefined' && typeof elementor === 'undefined'){ 116 116 jQuery('#ply-add-link-dialog').dialog('open'); 117 117 get_ply_tracking_links(); 118 118 }else{ 119 119 jQuery('#ply-add-link-dialog').dialog('open'); 120 jQuery('#ply-add-link-dialog').dialog({width: '600px'}) .position({ my: "center", at: "center", of: window });120 jQuery('#ply-add-link-dialog').dialog({width: '600px'}); // .position({ my: "center", at: "center", of: window }); 121 121 var options = '<div id="ply-block-btns"><div class="ply-btn-etitor-block" onclick="get_ply_tracking_links()">Add a tracking link</div><div class="ply-btn-etitor-block" onclick="get_ply_projects()">Add an event</div></div>'; 122 122 jQuery('#ply-add-link-dialog').html(options); … … 188 188 var table = '<table id="links_table_toggle">\n\ 189 189 <thead>\n\ 190 <th style="width: 40px;">Select</th>\n\190 <th style="width: 40px;">Select</th>\n\ 191 191 <th>Date</th>\n\ 192 192 <th>Action</th>\n\ … … 212 212 jQuery('.ui-dialog-buttonpane button:contains("Add on Link Click")').button().show(); 213 213 jQuery('.ui-dialog-buttonpane button:contains("Copy Code")').button().show(); 214 215 // Check if no text selected 216 if (elementor !== 'undefined' && typeof window.tinymce !== 'undefined' && !tinymce.activeEditor.isHidden()) { 217 var selectedText = tinymce.activeEditor.selection.getContent(); 218 if (selectedText.length === 0) { 219 var ply_link_settings = '<div style="text-align: center;padding: 5px;">Add new link</div>\n\ 220 <table><tbody>\n\ 221 <tr><td style="padding: 5px;text-align: right;">Text</td><td style="width: 300px;"><input id="ply_dialog_link_text" type="text" onkeypress="jQuery(\'#ply-link-text-error\').hide();" placeholder="Click this one" required></td></tr>\n\ 222 <tr id="ply-link-text-error"><td></td><td style="color: red">This field is required</td></tr>\n\ 223 <tr><td style="padding: 5px;text-align: right;">URL</td><td style="width: 300px;"><input id="ply_dialog_link_url" type="text" onkeypress="jQuery(\'#ply-link-url-error\').hide();" placeholder="' + siteUrl + '" required></td></tr>\n\ 224 <tr id="ply-link-url-error"><td></td><td style="color: red">This field is required</td></tr>\n\ 225 </tbody></table>'; 226 jQuery('#ply-dialog-link-settings').html(ply_link_settings); 227 jQuery('#ply-dialog-link-settings').show(); 228 } 229 } 214 230 }else{ 215 231 jQuery('#ply-add-link-dialog #ply-events-block').html("<div id='ply-default-event-msg'>You haven't created an Event for this project yet.</div>"); 216 232 } 217 jQuery('#ply-add-link-dialog').dialog({width: '600px'}) .position({ my: "center", at: "center", of: window });233 jQuery('#ply-add-link-dialog').dialog({width: '600px'}); // .position({ my: "center", at: "center", of: window }); 218 234 } 219 235 }); … … 221 237 function showPlyDialogOnlyEventOptions(){ 222 238 jQuery('#ply-add-link-dialog').dialog('open'); 223 jQuery('#ply-add-link-dialog').dialog({width: '600px'}).position({ my: "center", at: "center", of: window }); 224 //console.log(plyEventButton); 239 jQuery('#ply-add-link-dialog').dialog({width: '600px'}); // .position({ my: "center", at: "center", of: window }); 225 240 if(typeof plyEventButton.attributes.onclick !== 'undefined' && plyEventButton.attributes.onclick != ''){ 226 241 jQuery('.ui-dialog-buttonpane button:contains("Edit Event")').button().show(); 227 242 jQuery('.ui-dialog-buttonpane button:contains("Remove Event")').button().show(); 228 243 jQuery('#ply-add-link-dialog').html("There's existing event for this button. Choose one of the following action."); 229 jQuery('#ply-add-link-dialog').dialog({width: '600px'}) .position({ my: "center", at: "center", of: window });244 jQuery('#ply-add-link-dialog').dialog({width: '600px'}); // .position({ my: "center", at: "center", of: window }); 230 245 }else{ 231 246 get_ply_projects(); -
platformly/trunk/js/ply_editor_btn_functions.js
r2024659 r2248759 5 5 ); 6 6 */ 7 var iconEl = el('span',{className: 'platform_ly_link_button_new'},8 el('i',{9 className: 'platform_ly_link_button',10 })11 );7 var iconEl = el('span',{className: 'platform_ly_link_button_new'}, 8 el('i',{ 9 className: 'platform_ly_link_button' 10 }) 11 ); 12 12 13 13 wp.richText.registerFormatType('platform-ly/link', { 14 title: 'Platform Link',15 tagName: 'a',16 attributes: {17 url: 'href',18 onclick: 'onclick',19 target: 'target',20 },21 className: 'platform-ly-link',22 edit: function( props ) {14 title: 'Platform Link', 15 tagName: 'a', 16 attributes: { 17 url: 'href', 18 onclick: 'onclick', 19 target: 'target' 20 }, 21 className: 'platform-ly-link', 22 edit: function( props ) { 23 23 var selectedBlock = wp.data.select("core/editor").getSelectedBlock(); 24 24 if(selectedBlock.name != 'core/button'){ 25 return wp.element.createElement(wp.editor.RichTextToolbarButton, {26 icon: iconEl,27 title: 'Add Platform.ly Link',28 onClick: function() {29 plySelectedWord = props;30 plyEventButton = {};31 showPlyDialogOptions();32 //add_platform_ly_link();33 /*props.onChange( wp.richText.toggleFormat( props.value, {type: 'platform-ly/link', attributes: {34 url: '#test',35 } } ) );*/36 },37 isActive: props.isActive, 38 });25 return wp.element.createElement(wp.editor.RichTextToolbarButton, { 26 icon: iconEl, 27 title: 'Add Platform.ly Link', 28 onClick: function() { 29 plySelectedWord = props; 30 plyEventButton = {}; 31 showPlyDialogOptions(); 32 //add_platform_ly_link(); 33 /*props.onChange( wp.richText.toggleFormat( props.value, {type: 'platform-ly/link', attributes: { 34 url: '#test', 35 } } ) );*/ 36 }, 37 isActive: props.isActive 38 }); 39 39 }else{ 40 40 return []; 41 41 } 42 }, 42 } 43 43 }); 44 44 function withClientIdClassName(settings, name){ … … 49 49 source: "attribute", 50 50 type: "string" 51 } 51 }; 52 52 } 53 53 return settings; -
platformly/trunk/platformly.php
r2208564 r2248759 4 4 Plugin Name: Platform.ly Official 5 5 Description: Platform.ly plugin is the easiest way to setup your optins and pages that your created with Platform.ly. After building your optin or page with our interactive WYSIWYG builders, you can set them up to show on your site with just a couple of clicks. 6 Version: 1.6 6 Version: 1.6.1 7 7 Author: Platform.ly 8 8 Author URI: https://www.platform.ly/ … … 387 387 } 388 388 389 add_action('admin_head', 'add_mce_platform_ly_link');390 391 389 function platform_ly_editor_css(){ 392 390 wp_enqueue_style('ply_styles', plugin_dir_url(__FILE__) . "css/ply_styles.css"); … … 394 392 } 395 393 396 add_action('admin_enqueue_scripts', 'platform_ly_editor_css'); 394 function add_mce_platform_ly_link_to_elementor_editor(){ 395 platform_ly_editor_css(); 396 add_mce_platform_ly_link(); 397 } 398 399 /** 400 * Check if the user is currently editing using Elementor 401 * @return boolean 402 */ 403 function isEditInElementor() { 404 $path = parse_url($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], PHP_URL_PATH); 405 if (strpos($path, 'post.php') !== false && isset($_GET['action']) && $_GET['action'] === 'elementor') { 406 return true; 407 } else { 408 return false; 409 } 410 } 411 412 if (isEditInElementor()) { 413 add_action('elementor/editor/before_enqueue_scripts', 'add_mce_platform_ly_link_to_elementor_editor'); 414 } else { 415 add_action('admin_enqueue_scripts', 'platform_ly_editor_css'); 416 add_action('admin_head', 'add_mce_platform_ly_link'); 417 } 397 418 398 419 function platform_ly_set_project_code(){ -
platformly/trunk/readme.txt
r2208564 r2248759 78 78 == Upgrade Notice == 79 79 80 = 1.6.1 = 81 - Integration with Elementor plugin 82 80 83 = 1.6 = 81 84 - Fixed jQuery issues
Note: See TracChangeset
for help on using the changeset viewer.