Skip to content

Commit

Permalink
Inline Comments: Strip 'data-incom' attribute during post save.
Browse files Browse the repository at this point in the history
We're stripping the 'data-incom' attribute at the server level to fix
issues with WA Fronted.

See #41.
  • Loading branch information
r-a-y committed Oct 25, 2015
1 parent 016c1d7 commit 9b66cb5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions includes/hooks-inline-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,24 @@ function cacsp_update_comment_references( $post_id ) {

}
add_action( 'save_post', 'cacsp_update_comment_references' );

/**
* Strip the 'data-incom' attribute from paper content.
*
* Inline Comments adds a 'data-incom' attribute to the content. When a
* frontend editor is enabled, this attribute should not be saved into the DB
* as it interferes with comment positioning.
*
* @param array $retval Post data.
* @param array $post Post attributes.
* @return array
*/
function cacsp_inline_comments_strip_data_incom_attribute( $retval, $post ) {
if ( 'cacsp_paper' !== $post['post_type'] ) {
return $retval;
}

$retval['post_content'] = preg_replace('/(<[^>]+) data-incom=".*?"/i', '$1', $retval['post_content'] );
return $retval;
}
add_filter( 'wp_insert_post_data', 'cacsp_inline_comments_strip_data_incom_attribute', 10, 2 );

0 comments on commit 9b66cb5

Please sign in to comment.