From 880632c44752ee2f3b401c9186d58888eddb67d0 Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Tue, 5 May 2015 12:05:08 +0100 Subject: [PATCH] 0.3 --- .gitmodules | 3 - lib/parsedown | 2 +- lib/parsedown-extra | 2 +- wp-common | 1 - wp-parsedown.php | 220 ++++---------------------------------------- 5 files changed, 19 insertions(+), 209 deletions(-) delete mode 160000 wp-common diff --git a/.gitmodules b/.gitmodules index 9ff7457..4ba1763 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "wp-common"] - path = wp-common - url = github:/petermolnar/wp-common [submodule "lib/parsedown"] path = lib/parsedown url = https://github.com/erusev/parsedown.git diff --git a/lib/parsedown b/lib/parsedown index e33ac1c..b9e5228 160000 --- a/lib/parsedown +++ b/lib/parsedown @@ -1 +1 @@ -Subproject commit e33ac1c56ea591f21b9cf2fa74356ef708d4e130 +Subproject commit b9e5228e92e5f5c17d7774cfb2de8e5e8362de1a diff --git a/lib/parsedown-extra b/lib/parsedown-extra index bcd3930..5829ab1 160000 --- a/lib/parsedown-extra +++ b/lib/parsedown-extra @@ -1 +1 @@ -Subproject commit bcd3930f7f10915e40513e1951a253f061d75463 +Subproject commit 5829ab17e68bd3f3c3da0633647b7874e5784385 diff --git a/wp-common b/wp-common deleted file mode 160000 index a2af50d..0000000 --- a/wp-common +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a2af50d2a60812c41e6539b17b310a43fd5535dc diff --git a/wp-parsedown.php b/wp-parsedown.php index ac13662..d78101c 100644 --- a/wp-parsedown.php +++ b/wp-parsedown.php @@ -12,225 +12,39 @@ License: GPLv3 if ( ! class_exists( 'WP_PARSEDOWN' ) ) : -/* get the plugin abstract class*/ -include_once ( dirname(__FILE__) . '/wp-common/plugin_abstract.php' ); include_once ( dirname(__FILE__) . '/lib/parsedown/Parsedown.php'); include_once ( dirname(__FILE__) . '/lib/parsedown-extra/ParsedownExtra.php'); /** * main wp-ghost class */ -class WP_PARSEDOWN extends PluginAbstract { - const key_save = 'saved'; - const key_delete = 'deleted'; - private $parsedown = null; +class WP_PARSEDOWN { - /** - * - */ - public function plugin_post_construct () { - $this->plugin_url = plugin_dir_url( __FILE__ ); - $this->plugin_dir = plugin_dir_path( __FILE__ ); - - $this->common_url = $this->plugin_url . self::common_slug; - $this->common_dir = $this->plugin_dir . self::common_slug; - - $this->admin_css_handle = $this->plugin_constant . '-admin-css'; - $this->admin_css_url = $this->common_url . 'wp-admin.css'; - - $this->parsedown = new ParsedownExtra(); + public function __construct () { + add_action( 'init', array(&$this,'init')); } - /** - * init hook function runs before admin panel hook, themeing and options read - */ - public function plugin_pre_init() { - - } - - /** - * additional init, steps that needs the plugin options - * - */ - public function plugin_post_init () { - /* display markdown */ - add_filter( 'the_content', array(&$this, 'markdown_on_the_fly'), 9 ); - + public function init () { remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); + add_filter( 'the_content', array( &$this, 'parsedown'), 8, 1 ); } - - /** - * activation hook function, to be extended - */ - public function plugin_activate() { - /* we leave this empty to avoid not detecting WP network correctly */ - } - - /** - * deactivation hook function, to be extended - */ - public function plugin_deactivate () { - } - - /** - * uninstall hook function, to be extended - */ - public function plugin_uninstall( $delete_options = true ) { - } - - /** - * extending admin init - * - */ - public function plugin_extend_admin_init () { - } - - /** - * admin help panel - */ - public function plugin_admin_help($contextual_help, $screen_id ) { - - /* add our page only if the screenid is correct */ - if ( strpos( $screen_id, $this->plugin_settings_page ) ) { - $contextual_help = __('

Please visit the official support forum of the plugin for help.

', $this->plugin_constant ); - } - - return $contextual_help; - } - - /** - * admin panel, the admin page displayed for plugin settings - */ - public function plugin_admin_panel() { - /** - * security, if somehow we're running without WordPress security functions - */ - if( ! function_exists( 'current_user_can' ) || ! current_user_can( 'manage_options' ) ){ - die( ); - } - ?> - -
- - - - plugin_donation_form(); - - /** - * if options were saved, display saved message - */ - if (isset($_GET[ self::key_save ]) && $_GET[ self::key_save ]=='true' || $this->status == 1) { ?> -

plugin_constant ) ?>

- status == 2) { ?> -

plugin_constant ) ?>

- - -

plugin_constant ), $this->plugin_name ) ; ?>

- -
- - plugin_constant ); ?> - - -
- plugin_constant ); ?> -
-
- -
-
- options['debug'],true); ?> /> - WP_DEBUG is enabled, notices and info level is displayed as well, otherwie only ERRORS are logged.', $this->plugin_constant); ?> -
-
-
-

- -

-
-
- options['debug'] ) || $this->options['debug'] != 1 ) - return false; - else - $this->utils->log ( $this->plugin_constant, $message, $log_level ); - } - - /** - * - */ - public function markdown_on_the_fly ( $markdown ) { + public function parsedown ( $markdown ) { $post = get_post(); - $this->log ( sprintf ( __('parsing post: %s', $this->plugin_constant), $post->ID ) ); - return $this->parsedown->text ( $markdown ); + + if ( defined( 'WP_DEBUG' ) && WP_DEBUG == true ) { + $message = sprintf ( __('parsing post: %s', $this->plugin_constant), $post->ID ); + error_log( __CLASS__ . ": " . $message ); + } + + $parsedown = new ParsedownExtra(); + $parsedown->setBreaksEnabled(true); + return $parsedown->text ( $markdown ); } } +$wp_parsedown = new WP_PARSEDOWN (); + endif; - - -$wp_parsedown_defaults = array ( - 'debug' => 0, -); - -$wp_parsedown = new WP_PARSEDOWN ( 'wp-parsedown', '0.1', 'WP-Parsedown', $wp_parsedown_defaults ); - - -?>