diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 5a389264c..5ddb712d8 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -87,7 +87,7 @@ tinyMCE.init({ textarea_trigger : "title", width : "100%", theme : "advanced", - theme_advanced_buttons1 : "bold,italic,strikethrough,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,image,emotions,separator,undo,redo,wordpress,code", + theme_advanced_buttons1 : "bold,italic,strikethrough,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,image,emotions,separator,wordpress,separator,undo,redo,code", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", @@ -99,8 +99,9 @@ tinyMCE.init({ theme_advanced_resize_horizontal : false, entity_encoding : "raw", relative_urls : false, + remove_script_host : false, valid_elements : "a[href|title],strong/b,em/i,strike,u,p[class|align],ol,ul,li,br,img[class|src|alt|title|width|height|align],sub,sup,blockquote,table[border=0|cellspacing|cellpadding|width|height|class|align],tr[class|rowspan|width|height|align|valign],td[dir|class|colspan|rowspan|width|height|align|valign],div[dir|class|align],span[class|align],pre[class],address,h1[class|align],h2[class|align],h3[class|align],h4[class|align],h5[class|align],h6[class|align],hr", - plugins : "autosave, contextmenu" + plugins : "contextmenu,wordpress" }); diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js index 0547fb022..522617d52 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js @@ -9,7 +9,7 @@ function TinyMCE_wordpress_initInstance(inst) { function TinyMCE_wordpress_getControlHTML(control_name) { switch (control_name) { case "wordpress": - return ''; + return ''; } return ""; @@ -65,58 +65,58 @@ function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interfa return elm.getAttribute(name) ? elm.getAttribute(name) : ""; } - // Handle commands - switch (command) { + // Handle commands + switch (command) { case "mcewordpressmore": - var name = ""; + var flag = ""; var template = new Array(); var inst = tinyMCE.getInstanceById(editor_id); var focusElm = inst.getFocusElement(); // Is selection a image if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { - name = getAttrib(focusElm, 'name'); + flag = getAttrib(focusElm, 'class'); - if (name != 'mce_plugin_wordpress_more') // Not a wordpress + if (flag != 'mce_plugin_wordpress_more') // Not a wordpress return true; action = "update"; } html = '' - + ''; - tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.execCommand("mceInsertContent",true,html); tinyMCE.selectedInstance.repaint(); return true; case "mcewordpresspage": - var name = ""; + var flag = ""; var template = new Array(); var inst = tinyMCE.getInstanceById(editor_id); var focusElm = inst.getFocusElement(); // Is selection a image if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { - name = getAttrib(focusElm, 'name'); + flag = getAttrib(focusElm, 'name'); - if (name != 'mce_plugin_wordpress_page') // Not a wordpress + if (flag != 'mce_plugin_wordpress_page') // Not a wordpress return true; action = "update"; } html = '' - + ''; - tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.execCommand("mceInsertContent",true,html); tinyMCE.selectedInstance.repaint(); return true; - } + } - // Pass to next handler in chain - return false; + // Pass to next handler in chain + return false; } function TinyMCE_wordpress_cleanup(type, content) { @@ -130,9 +130,9 @@ function TinyMCE_wordpress_cleanup(type, content) { // Insert image var contentAfter = content.substring(startPos + 11); content = content.substring(0, startPos); - content += '', startPos); var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos)); - if (attribs['name'] == "mce_plugin_wordpress_more") { + if (attribs['class'] == "mce_plugin_wordpress_more") { endPos += 2; var embedHTML = ''; @@ -170,7 +170,7 @@ function TinyMCE_wordpress_cleanup(type, content) { chunkAfter = content.substring(endPos); content = chunkBefore + embedHTML + chunkAfter; } - if (attribs['name'] == "mce_plugin_wordpress_page") { + if (attribs['class'] == "mce_plugin_wordpress_page") { endPos += 2; var embedHTML = ''; @@ -181,6 +181,14 @@ function TinyMCE_wordpress_cleanup(type, content) { content = chunkBefore + embedHTML + chunkAfter; } } + + // Handle TinyMCE weirdness without messing up the core + //alert("Content before TinyMCE_wordpress_cleanup\n\n'"+content+"'"); + + // Strip any trailing
and whitespace. + content = content.replace(new RegExp('
[ \t]*$', ''), ''); + + //alert("Content after TinyMCE_wordpress_cleanup\n\n'"+content+"'"); break; } @@ -200,11 +208,11 @@ function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_le return; do { - if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_more') == 0) + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0) tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected'); - if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_page') == 0) + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0) tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected'); } while ((node = node.parentNode)); return true; -} +} \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js index 0547fb022..522617d52 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js @@ -9,7 +9,7 @@ function TinyMCE_wordpress_initInstance(inst) { function TinyMCE_wordpress_getControlHTML(control_name) { switch (control_name) { case "wordpress": - return ''; + return ''; } return ""; @@ -65,58 +65,58 @@ function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interfa return elm.getAttribute(name) ? elm.getAttribute(name) : ""; } - // Handle commands - switch (command) { + // Handle commands + switch (command) { case "mcewordpressmore": - var name = ""; + var flag = ""; var template = new Array(); var inst = tinyMCE.getInstanceById(editor_id); var focusElm = inst.getFocusElement(); // Is selection a image if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { - name = getAttrib(focusElm, 'name'); + flag = getAttrib(focusElm, 'class'); - if (name != 'mce_plugin_wordpress_more') // Not a wordpress + if (flag != 'mce_plugin_wordpress_more') // Not a wordpress return true; action = "update"; } html = '' - + ''; - tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.execCommand("mceInsertContent",true,html); tinyMCE.selectedInstance.repaint(); return true; case "mcewordpresspage": - var name = ""; + var flag = ""; var template = new Array(); var inst = tinyMCE.getInstanceById(editor_id); var focusElm = inst.getFocusElement(); // Is selection a image if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { - name = getAttrib(focusElm, 'name'); + flag = getAttrib(focusElm, 'name'); - if (name != 'mce_plugin_wordpress_page') // Not a wordpress + if (flag != 'mce_plugin_wordpress_page') // Not a wordpress return true; action = "update"; } html = '' - + ''; - tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.execCommand("mceInsertContent",true,html); tinyMCE.selectedInstance.repaint(); return true; - } + } - // Pass to next handler in chain - return false; + // Pass to next handler in chain + return false; } function TinyMCE_wordpress_cleanup(type, content) { @@ -130,9 +130,9 @@ function TinyMCE_wordpress_cleanup(type, content) { // Insert image var contentAfter = content.substring(startPos + 11); content = content.substring(0, startPos); - content += '', startPos); var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos)); - if (attribs['name'] == "mce_plugin_wordpress_more") { + if (attribs['class'] == "mce_plugin_wordpress_more") { endPos += 2; var embedHTML = ''; @@ -170,7 +170,7 @@ function TinyMCE_wordpress_cleanup(type, content) { chunkAfter = content.substring(endPos); content = chunkBefore + embedHTML + chunkAfter; } - if (attribs['name'] == "mce_plugin_wordpress_page") { + if (attribs['class'] == "mce_plugin_wordpress_page") { endPos += 2; var embedHTML = ''; @@ -181,6 +181,14 @@ function TinyMCE_wordpress_cleanup(type, content) { content = chunkBefore + embedHTML + chunkAfter; } } + + // Handle TinyMCE weirdness without messing up the core + //alert("Content before TinyMCE_wordpress_cleanup\n\n'"+content+"'"); + + // Strip any trailing
and whitespace. + content = content.replace(new RegExp('
[ \t]*$', ''), ''); + + //alert("Content after TinyMCE_wordpress_cleanup\n\n'"+content+"'"); break; } @@ -200,11 +208,11 @@ function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_le return; do { - if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_more') == 0) + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0) tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected'); - if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_page') == 0) + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0) tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected'); } while ((node = node.parentNode)); return true; -} +} \ No newline at end of file