Advertisement
Guest User

Untitled

a guest
Sep 8th, 2012
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function send_to_editor(h) {
  2.     if (window.location == "http://example.com/wp-admin/admin.php?page=slidorion_menu_new") {
  3.         var source = h.match(/src=\".*\" alt/);
  4.         source = source[0].replace(/^src=\"/, "").replace(/" alt$/, "");
  5.         jQuery('#'+current_slidorion_slide).val(source);
  6.         jQuery('#img_preview_'+current_slidorion_slide).attr('src', source).css('background', 'none');
  7.         tb_remove();
  8.     } else {
  9.         var ed, mce = typeof(tinymce) != 'undefined', qt = typeof(QTags) != 'undefined';
  10.  
  11.         if ( !wpActiveEditor ) {
  12.             if ( mce && tinymce.activeEditor ) {
  13.                 ed = tinymce.activeEditor;
  14.                 wpActiveEditor = ed.id;
  15.             } else if ( !qt ) {
  16.                 return false;
  17.             }
  18.         } else if ( mce ) {
  19.             if ( tinymce.activeEditor && (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen') )
  20.                 ed = tinymce.activeEditor;
  21.             else
  22.                 ed = tinymce.get(wpActiveEditor);
  23.         }
  24.  
  25.         if ( ed && !ed.isHidden() ) {
  26.             // restore caret position on IE
  27.             if ( tinymce.isIE && ed.windowManager.insertimagebookmark )
  28.                 ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark);
  29.  
  30.             if ( h.indexOf('[caption') === 0 ) {
  31.                 if ( ed.wpSetImgCaption )
  32.                     h = ed.wpSetImgCaption(h);
  33.             } else if ( h.indexOf('[gallery') === 0 ) {
  34.                 if ( ed.plugins.wpgallery )
  35.                     h = ed.plugins.wpgallery._do_gallery(h);
  36.             } else if ( h.indexOf('[embed') === 0 ) {
  37.                 if ( ed.plugins.wordpress )
  38.                     h = ed.plugins.wordpress._setEmbed(h);
  39.             }
  40.  
  41.             ed.execCommand('mceInsertContent', false, h);
  42.         } else if ( qt ) {
  43.             QTags.insertContent(h);
  44.         } else {
  45.             document.getElementById(wpActiveEditor).value += h;
  46.         }
  47.  
  48.         try{tb_remove();}catch(e){};
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement