/* Import plugin specific language pack */
tinyMCE.importPluginLanguagePack('wordpress', '');
function TinyMCE_wordpress_initInstance(inst) {
if (!tinyMCE.settings['wordpress_skip_plugin_css'])
tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/wordpress/wordpress.css");
}
function TinyMCE_wordpress_getControlHTML(control_name) {
switch (control_name) {
case "wordpress":
var titleMore = tinyMCE.getLang('lang_wordpress_more_button');
var titlePage = tinyMCE.getLang('lang_wordpress_page_button');
var titleHelp = tinyMCE.getLang('lang_wordpress_help_button');
var buttons = '
';
// Add this to the buttons var to put the Page button into the toolbar.
// '
';
return buttons;
}
return '';
}
function TinyMCE_wordpress_parseAttributes(attribute_string) {
var attributeName = "";
var attributeValue = "";
var withInName;
var withInValue;
var attributes = new Array();
var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
var titleText = tinyMCE.getLang('lang_wordpress_more');
var titleTextPage = tinyMCE.getLang('lang_wordpress_page');
if (attribute_string == null || attribute_string.length < 2)
return null;
withInName = withInValue = false;
for (var i=0; i';
tinyMCE.execCommand("mceInsertContent",true,html);
tinyMCE.selectedInstance.repaint();
return true;
}
// Pass to next handler in chain
return false;
}
function TinyMCE_wordpress_cleanup(type, content) {
switch (type) {
case "insert_to_editor":
var startPos = 0;
var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
var altPage = tinyMCE.getLang('lang_wordpress_page_alt');
// Parse all tags and replace them with images
while ((startPos = content.indexOf('', startPos)) != -1) {
// Insert image
var contentAfter = content.substring(startPos + 11);
content = content.substring(0, startPos);
content += '
';
content += contentAfter;
startPos++;
}
var startPos = 0;
// Parse all tags and replace them with images
while ((startPos = content.indexOf('', startPos)) != -1) {
// Insert image
var contentAfter = content.substring(startPos + 15);
content = content.substring(0, startPos);
content += '
';
content += contentAfter;
startPos++;
}
// It's supposed to be WYSIWYG, right?
content = content.replace(new RegExp('&', 'g'), '&');
break;
case "get_from_editor":
// Parse all img tags and replace them with
var startPos = -1;
while ((startPos = content.indexOf('
', startPos);
var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));
if (attribs['class'] == "mce_plugin_wordpress_more") {
endPos += 2;
var embedHTML = '';
// Insert embed/object chunk
chunkBefore = content.substring(0, startPos);
chunkAfter = content.substring(endPos);
content = chunkBefore + embedHTML + chunkAfter;
}
if (attribs['class'] == "mce_plugin_wordpress_page") {
endPos += 2;
var embedHTML = '';
// Insert embed/object chunk
chunkBefore = content.substring(0, startPos);
chunkAfter = content.substring(endPos);
content = chunkBefore + embedHTML + chunkAfter;
}
}
// If it says & in the WYSIWYG editor, it should say & in the html.
content = content.replace(new RegExp('&', 'g'), '&');
content = content.replace(new RegExp(' ', 'g'), ' ');
// Remove anonymous, empty paragraphs.
content = content.replace(new RegExp('
(\\s| )*
', 'mg'), ''); // Handle table badness. content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>'); content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>'); content = content.replace(new RegExp('(td|th)>.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '$1><$2>'); content = content.replace(new RegExp('.*?<(tr|/table)>', 'mg'), '<$1>'); content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(]+>.*?)
', 'mg'), '$1'); // Decode the ampersands of time. content = content.replace(new RegExp('&', 'g'), '&'); // Get it ready for wpautop. content = content.replace(new RegExp('[\\s]*[\\s]*', 'mgi'), ''); content = content.replace(new RegExp('[\\s]*
[\\s]*', 'mgi'), '\n\n'); content = content.replace(new RegExp('\\n\\s*\\n\\s*\\n*', 'mgi'), '\n\n'); content = content.replace(new RegExp('\\s*]+>.*
)', 'mg'), '\n$1'); // Trim any whitespace content = content.replace(new RegExp('^\\s*', ''), ''); content = content.replace(new RegExp('\\s*$', ''), ''); // Hope. return content; }