• I’ve edited a quiz plugin to get the report content added as a post. The problem is that when it’s added, some of the content necessary to achieve what I’m after gets stripped out.

    I’m trying to do a tabbed layout instead of paginated – using:

    <ul class="uk-tabs" data-uk-tabs="{content:'#report_content'}">... </ul>

    but the

    data-uk-tabs="{content:'#report_content'}"

    is getting stripped out.

    Here’s the wp_insert_post() code I’m using (the stripped content is within $output):

    wp_insert_post( array(
    		'post_title' => $exam->name.' Report',
    		'post_type' 	=> 'my-reports',
    		'post_name'	 => $taking_id,
    		'comment_status' => 'closed',
    		'ping_status' => 'closed',
    		'post_content' => $output,
    		'post_status' => 'private',
    		'post_author' => $user_id,
    		'menu_order' => 0,
    		'comment_status' => 'open',
    		'post_category' => array(43),
    		'page_template' => 'single-my-reports.php'
    ));

    I’ve done a quick test by commenting out

    //$postarr = sanitize_post($postarr, 'db');

    in post.php, but if there’s a safer way by just making an exception for “{connect:’#somediv’,’param’:’xyz…} I’d prefer to go that route.

    Or can I disable sanitize just for the post insert above by removing and then re-adding it?

    Thanks,
    Scott

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Scott McCulloch

    (@sinemac)

    What’s the danger of placing

    kses_remove_filters();

    and

    kses_init_filters();

    on either side of that wp_insert_post() query?

    Thread Starter Scott McCulloch

    (@sinemac)

    In case anyone else comes across this post looking to solve the same problem, here’s the ultimate solution I found – courtesy of:
    http://mawaha.com/allowing-data-attributes-in-wordpress-posts/

    function allow_data_uk_tab($allowed, $context){
    
    	if (is_array($context))
    	{
    	    return $allowed;
    	}
    
    	if ($context === 'post')
    	{
    	    $allowed['ul']['data-uk-tabs'] = true;
    	}
    
    	return $allowed;
    }
    add_filter('wp_kses_allowed_html', 'allow_data_uk_tab', 10, 2);

    Seems to work just fine.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Any way to add exceptions for sanitize_post() ?’ is closed to new replies.