Last active
December 8, 2021 18:24
-
-
Save hakikz/f2d2515ca911bc7a4d83eaf5ec9924b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ed.addButton('button_green', { | |
title: 'Add span', | |
image: '../wp-includes/images/smilies/icon_mrgreen.gif', | |
cmd: 'button_green_cmd' | |
}); | |
ed.addCommand('button_green_cmd', function () { | |
var data = { | |
title: 'Default Title', | |
limit: 10 | |
} | |
ed.windowManager.open({ | |
title: 'Save A Comment', | |
data: data, | |
width: 600, | |
height: 340, | |
body: [ | |
{ | |
name: 'title', | |
type: 'textbox', | |
label: 'Title', | |
value: data.title, | |
onchange: function() { data.title = this.value(); } | |
}, | |
{ | |
name: 'comment', | |
type: 'textbox', | |
label: 'Comment', | |
value: data.title, | |
minHeight: 200, | |
multiline: true, | |
onchange: function() { data.title = this.value(); } | |
}, | |
{ | |
name: 'name', | |
type: 'listbox', | |
label: 'Display Name', | |
values: [ | |
{ | |
value: 10, | |
text: '10' | |
}, | |
{ | |
value: 9, | |
text: '9' | |
}, | |
{ | |
value: 8, | |
text: '8' | |
}, | |
{ | |
value: 7, | |
text: '7' | |
}, | |
{ | |
value: 6, | |
text: '6' | |
}, | |
{ | |
value: 5, | |
text: '5' | |
}, | |
], | |
onchange: function() { data.title = this.value(); } | |
} | |
], | |
onSubmit: function(e) { | |
var shortcode = '[shortcode3'; | |
data = tinymce.extend(data, e.data); | |
shortcode += ' title="' + data.title + '"'; | |
shortcode += ' limit="' + data.limit + '"'; | |
shortcode += ']'; | |
console.log("I am fired!"); | |
// tinymce.execCommand('mceInsertContent', false, shortcode); | |
} | |
}); | |
}); | |
//https://www.johnrussell.dev/blog/2014/07/wordpress-editor-custom-buttons-dialog-windows/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment