• Resolved Daniel

    (@damen02)


    Hi guys. Awesome plugin! thanks for doing it.

    I’m having some trimming on your content editor, in HTML mode.
    I need to publish an audio player, and works fine. But I need to avoid the download button.
    I found how to solve it, and works fine on normal WP pages and posts. But for some reason the code on your editor is being trimmed.

    Here is the code that works on pages:

    <audio controls controlsList="nodownload">
      <source src="xxx.mp3"" type="audio/mpeg">
    </audio>

    On your editor, after saving I get only this:

    <audio controls>
    </audio>

    Any suggestion? Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author NiteoThemes

    (@niteo)

    Howdy Daniel, hmm you are right – same thing happens on my development server.

    I played with the post HTML sanitation for a while, but I am unable to make it work, it always strips the custom tags even when I specifically allow them.

    Please hold on a little, I asked around on WordPress plugin development slack channel and I am eagerly waiting for a help or hint:)

    Anyway if I am able to make it work, it would have to wait for next update release, which is planned for someday in next week.

    Alex

    Plugin Author NiteoThemes

    (@niteo)

    OK, found the solution – I can make it to next update (about a week more or less).

    Or if you know how to edit plugin files, I can send you a code snippet what to change.

    Alex

    Thread Starter Daniel

    (@damen02)

    Hi Alex
    Thanks for your answers, and apologize for my delay.
    I know how to edit plugin files, if you tell me what file to edit, it will be great!
    We are on launching countdown 🙂

    Plugin Author NiteoThemes

    (@niteo)

    No problem 🙂

    Find and edit niteo-cmp.php file in plugin’s folder and search for “niteo_sanitize_html” function.

    replace:

    public function niteo_sanitize_html( $html ) {
    	global $allowedposttags;
    	return wp_kses( $html, $allowedposttags );
    }

    with:

    public function niteo_sanitize_html( $html ) {
    
    	if ( !current_user_can( 'unfiltered_html' ) ) {
           	$allowed = wp_kses_allowed_html( 'post' );
           	$html = wp_kses( $html, $allowed );
        }
    
        return $html;
    }

    this should do a trick – you must be logged in as administrator or editor to allows unfiltered HTML in editor 🙂

    Also I will include this change in next update so feel free to update CMP plugin to latest version anytime.

    Alex

    • This reply was modified 7 years, 11 months ago by NiteoThemes.
    Thread Starter Daniel

    (@damen02)

    Thanks Alex. I will test the code and let you know.

    Plugin Author NiteoThemes

    (@niteo)

    Resolved in 2.7 update

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

The topic ‘editor trimming HTML’ is closed to new replies.