Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Forum: Plugins
    In reply to: Podcasting 1.0 Plugin

    Absolutely. I don’t mind if you include the code – it’s here for anyone to benefit from 🙂

    Forum: Plugins
    In reply to: Podcasting 1.0 Plugin

    Sorry – I left my alerts and extra debugs that were commented out in the last post. Just remove the alert(…) lines (two of them iirc) and the // comment lines from inside the new function.

    Forum: Plugins
    In reply to: Podcasting 1.0 Plugin

    I’ve modified this plugin to add support for both the code view editor or the WYSIWYG text editor using some of the information from the link suggested by gcrocker (thanks btw).

    Here’s the code that I’ve added / modified to make it work (I had to hack the window.opener sections of the JS as well as the id’s used within the pages – there’s probably a better way but this is a quick fix…sorry). Enjoy:

    Added the following lines:

    add_action('admin_footer', 'insert_podcast_editor_js');
    // Insert JavaScript to insert [podcast]url[/podcast] into editor or code view
    function insert_podcast_editor_js() {
    	?>
    
    	<script language="javascript" type="text/javascript">
    	// Insert myValue (podcast special url string) into an editor window
    	function insertPodcastString(myValue) {
    		if(document.getElementById('mce_editor_0')){
    			alert('inside if mce_editor_0');
    			window.tinyMCE.execCommand("mceInsertContent",true,myValue);
    		} else {
    			if(document.getElementById('content')){
    				alert('inside else, found id by content');
    				document.getElementById('content').value += myValue;
    			}
    			//alert('inside else for window.tinyMCE');
    			//insertAtCursor(window.opener.document.post.content, myValue);
    		}
    	}
    
    	// Insert text into the WP regular editor window
    	function insertAtCursor(myField, myValue) {
    		//IE support
    		if (document.selection && !window.opera) {
    			myField.focus();
    			sel = window.document.selection.createRange();
    			sel.text = myValue;
    		}
    		//MOZILLA/NETSCAPE/OPERA support
    		else if (myField.selectionStart || myField.selectionStart == '0') {
    			var startPos = myField.selectionStart;
    			var endPos = myField.selectionEnd;
    			myField.value = myField.value.substring(0, startPos)
    			+ myValue
    			+ myField.value.substring(endPos, myField.value.length);
    		} else {
    			myField.value += myValue;
    		}
    	}
    	</script>	
    
    	<?php
    }

    Changed this snippet:
    onClick="document.getElementById('content').value += '\n\n [podcast]<?php echo trim($enclosure_value[0]); ?>[/podcast] />
    to:
    onClick="insertPodcastString('[podcast]<?php echo trim($enclosure_value[0]); ?>[/podcast]')" />

    If this code doesn’t work properly (I’m guessing it won’t with PHP tags and all….) then shoot me an e-mail or I’ll repost with a paste link.

Viewing 3 replies - 1 through 3 (of 3 total)