TInyMCE object Tag stripped

I’m not 100% sure, but this problem seems related to the unfiltered_html capability restriction.

unfiltered_html

  • Since 2.0
  • Allows user to post HTML markup or even
    JavaScript code in pages, posts, and comments.
  • Note: Enabling this
    option for untrusted users may result in their posting malicious or
    poorly formatted code.

An easy fix (and probably a solution even if the issue in not of capabilities) is to make a shortcode to handle the object insertion.

This example is for inserting a SoundCloud iframe, but easily adaptable to the object tag.

add_shortcode('soundcloud', 'soundcloud_shortcode_maker');

function soundcloud_shortcode_maker($atts, $content = null) {
    $output="<iframe width="".$atts['width'].'" height="'.$atts['height'].'" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=".urlencode($atts["url']).'&amp;'.myUrlEncode($atts['params']).'"></iframe>';   
    return $output;
}

function myUrlEncode($string) {
    $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
    $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "https://wordpress.stackexchange.com/", "?", "%", "#", "[", "]");
    return str_replace($entities, $replacements, urlencode($string));
}

The function myUrlEncode is just a helper in this specific SoundCloud case, but I’ll leave it here just in case…