diff --git a/.gitignore b/.gitignore index 0fb8616..73b34f4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ !*.* .DS_Store + +tmp/* diff --git a/classes/LBRY_Network_Parser.php b/classes/LBRY_Network_Parser.php index 54a51a5..5847de4 100644 --- a/classes/LBRY_Network_Parser.php +++ b/classes/LBRY_Network_Parser.php @@ -15,7 +15,26 @@ class LBRY_Network_Parser public function __construct() { + // COMBAK: Composer is not safe in a wordpress environment. May have to write our own package. require_once LBRY_ABSPATH . 'vendor/autoload.php'; - $this->converter = new HtmlConverter(); + $this->converter = new HtmlConverter(array( + 'strip_tags' => true + )); + add_action('save_post', array($this, 'convert_to_markdown')); + } + + public function convert_to_markdown($post_id) + { + $post = get_post($post_id); + $title = '

' . $post->post_title . '

'; + + $featured_image = get_the_post_thumbnail($post); + + $content = $title; + $content .= $featured_image . '
'; + $content .= apply_filters('the_content', get_post($post_id)->post_content); + $converted = $this->converter->convert($content); + + return $converted; } }