From 706bce0c23943c82d102c67a09e18dac32c66207 Mon Sep 17 00:00:00 2001 From: Vova Feldman Date: Mon, 10 Oct 2016 20:03:27 -0400 Subject: [PATCH 1/3] Instead of injecting the markdown editor for all post types, inject only in the supported post types. The relevant use case is that we are using markdown only for our documentation section ('docs' CPT), and we want to keep the rich editor for our pages/posts. --- wp-markdown-editor.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/wp-markdown-editor.php b/wp-markdown-editor.php index 200d870..2c5d3ea 100644 --- a/wp-markdown-editor.php +++ b/wp-markdown-editor.php @@ -33,8 +33,8 @@ class WpMarkdownEditor private function __construct() { // Activation / Deactivation hooks - register_activation_hook(__FILE__, array($this, 'plugin_activation')); - register_deactivation_hook(__FILE__, array($this, 'plugin_deactivation')); +// register_activation_hook(__FILE__, array($this, 'plugin_activation')); +// register_deactivation_hook(__FILE__, array($this, 'plugin_deactivation')); // Load markdown editor add_action('admin_enqueue_scripts', array($this, 'enqueue_stuffs')); @@ -68,7 +68,11 @@ function enqueue_stuffs() return; } - wp_enqueue_script('simplemde-js', $this->plugin_url('/simplemde/simplemde.min.js')); + if (!post_type_supports( get_post_type(), WPCom_Markdown::POST_TYPE_SUPPORT )){ + return; + } + + wp_enqueue_script('simplemde-js', $this->plugin_url('/simplemde/simplemde.min.js')); wp_enqueue_style('simplemde-css', $this->plugin_url('/simplemde/simplemde.min.css')); wp_enqueue_style('custom-css', $this->plugin_url('/style.css')); } @@ -111,6 +115,10 @@ function init_editor() return; } + if (!post_type_supports( get_post_type(), WPCom_Markdown::POST_TYPE_SUPPORT )){ + return; + } + echo '