diff --git a/includes/class-syndication-wp-rss-client.php b/includes/class-syndication-wp-rss-client.php index 22bfcca..5ae6dbf 100644 --- a/includes/class-syndication-wp-rss-client.php +++ b/includes/class-syndication-wp-rss-client.php @@ -43,6 +43,8 @@ function __construct( $site_ID ) { add_action( 'syn_post_pull_new_post', array( __CLASS__, 'save_tax' ), 10, 5 ); add_action( 'syn_post_pull_edit_post', array( __CLASS__, 'update_meta' ), 10, 5 ); add_action( 'syn_post_pull_edit_post', array( __CLASS__, 'update_tax' ), 10, 5 ); + + add_filter( 'syn_pull_new_post', array( __CLASS__, 'convert_video_html_to_shortcode' ) ); } public static function get_client_data() { @@ -354,4 +356,70 @@ public static function update_tax( $result, $post, $site, $transport_type, $clie } } } + + /** + * Detects video embed HTML on incoming posts and coverts to video shortcode + * + * @param array $post An array of post data + * @return array (Un)modified post data + */ + public function convert_video_html_to_shortcode( $post ) { + + // Look for the video embed HTML in the post content + $html_regex = "/[\s\S]*(
[\s\S]+