diff --git a/Gruntfile.js b/Gruntfile.js
index 8694040..7c1d414 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -3,10 +3,10 @@ module.exports = function(grunt) {
grunt.initConfig({
exec: {
phpcs_plugin: {
- cmd: 'phpcs --standard=WordPress *.php'
+ cmd: 'phpcs --standard=WordPress-Core markdown.php --report-width=200 -s'
},
phpcs_src: {
- cmd: 'phpcs --standard=PSR2 src'
+ cmd: 'phpcs --standard=PSR2 src --report-width=200 -s'
}
},
compass: {
diff --git a/markdown.php b/markdown.php
index 3621c84..7e6c3ba 100644
--- a/markdown.php
+++ b/markdown.php
@@ -1,415 +1,417 @@
-[gfm] and support PHP-Markdown by using shortcode [markdown]
- Author: makoto_kw
- Author URI: http://makotokw.com/
- License: MIT
- */
-
-class WP_GFM
-{
- const NAME = 'WP_GFM';
- const VERSION = '0.7.3';
- const DEFAULT_RENDER_URL = 'https://api.github.com/markdown/raw';
-
- // google-code-prettify: https://code.google.com/p/google-code-prettify/
- const FENCED_CODE_BLOCKS_TEMPLATE_FOR_GOOGLE_CODE_PRETTIFY = '
{{codeblock}}'; - - public $agent = ''; - public $url = ''; - public $has_converter = false; - public $gfm_options = array(); - - static function get_instance() { - static $plugin = null; - if ( ! $plugin ) { - $plugin = new WP_GFM(); - } - return $plugin; - } - - private function __construct() { - $this->agent = self::NAME . '/' . self::VERSION; - $this->url = plugins_url( '', __FILE__ ); - - $this->gfm_options = wp_parse_args( - (array) get_option( 'gfm' ), - array( - 'general_ad' => false, - 'php_md_always_convert' => false, - 'php_md_use_autolink' => false, - 'php_md_fenced_code_blocks_template' => self::FENCED_CODE_BLOCKS_TEMPLATE_FOR_GOOGLE_CODE_PRETTIFY, - 'render_url' => self::DEFAULT_RENDER_URL, - ) - ); - - if ( is_admin() ) { - add_action( 'admin_init', array( $this, 'admin_init' ) ); - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); - add_action( 'admin_print_footer_scripts', array( $this, 'admin_quicktags' ) ); - } else { - add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_styles' ) ); - } - } - - function wp_enqueue_styles() { - wp_enqueue_style( 'wp-gfm', $this->url . '/css/markdown.css', array(), self::VERSION ); - } - - function php_markdown_init() { - if ( class_exists( '\Gfm\Markdown\Extra' ) ) { - $this->has_converter = true; - \Gfm\Markdown\Extra::setElementCssPrefix( 'wp-gfm-' ); - \Gfm\Markdown\Extra::$useAutoLinkExtras = $this->gfm_options['php_md_use_autolink'] == true; - \Gfm\Markdown\Extra::$fencedCodeBlocksTemplate = $this->gfm_options['php_md_fenced_code_blocks_template']; - } - - if ( $this->gfm_options['php_md_always_convert'] ) { - add_action( 'the_content', array( $this, 'force_convert' ), 7 ); - } else { - add_action( 'the_content', array( $this, 'the_content' ), 7 ); - } - - if ( $this->gfm_options['general_ad'] ) { - add_action( 'the_content', array( $this, 'the_content_ad' ), 8 ); - } - - add_shortcode( 'embed_markdown', array( $this, 'shortcode_embed_markdown' ) ); - add_filter( 'pre_comment_content', array( $this, 'pre_comment_content' ), 5 ); - } - - function admin_init() { - register_setting( 'gfm_option_group', 'gfm_array', array( $this, 'option_sanitize_gfm' ) ); - - add_settings_section( - 'setting_section_general', - 'General', - array( $this, 'setting_section_general' ), - 'gfm-setting-admin' - ); - - add_settings_field( - 'general_ad', - '', - array( $this, 'create_gfm_general_ad_field' ), - 'gfm-setting-admin', - 'setting_section_general' - ); - - add_settings_section( - 'setting_section_php_markdown', - 'PHP Markdown', - array( $this, 'print_section_php_markdown' ), - 'gfm-setting-admin' - ); - - add_settings_field( - 'php_md_always_convert', - '', - array( $this, 'create_gfm_php_md_always_convert_field' ), - 'gfm-setting-admin', - 'setting_section_php_markdown' - ); - - add_settings_field( - 'php_md_use_autolink', - '', - array( $this, 'create_gfm_php_md_use_autolink_field' ), - 'gfm-setting-admin', - 'setting_section_php_markdown' - ); - - add_settings_field( - 'php_md_fenced_code_blocks_template', - 'Fenced Code Blocks Template', - array( $this, 'create_gfm_php_md_fenced_code_blocks_template_field' ), - 'gfm-setting-admin', - 'setting_section_php_markdown' - ); - - add_settings_section( - 'setting_section_gfm', - 'GitHub Flavored Markdown', - array( $this, 'print_section_gfm' ), - 'gfm-setting-admin' - ); - - add_settings_field( - 'render_url', - 'Render URL', - array( $this, 'create_gfm_render_url_field' ), - 'gfm-setting-admin', - 'setting_section_gfm' - ); - } - - function admin_menu() { - if ( function_exists( 'add_options_page' ) ) { - add_options_page( - 'GFM Plugin Settings', - 'WP GFM', - 'manage_options', - 'wp-gfm', - array( $this, 'options_page' ) - ); - } - } - - function options_page() { - ?> -
The plugin converts content even if it is not surrounded by [markdown]
'; - } - - function create_gfm_php_md_use_autolink_field() { - echo 'gfm_options['php_md_use_autolink'], false ) . ' /> Use AutoLink'; - } - - function create_gfm_php_md_fenced_code_blocks_template_field() { - $value = esc_attr( $this->gfm_options['php_md_fenced_code_blocks_template'] ); - echo '' - . ''
- . '{{lang}}, {{title}}, {{codeblock}}
'
- . 'For google-code-prettify: ' . esc_attr( self::FENCED_CODE_BLOCKS_TEMPLATE_FOR_GOOGLE_CODE_PRETTIFY ) . '
'
- . '
[markdown]
+ Author: makoto_kw
+ Author URI: http://makotokw.com/
+ License: MIT
+ */
+
+class WP_GFM
+{
+ const NAME = 'WP_GFM';
+ const VERSION = '0.8';
+ const DEFAULT_RENDER_URL = 'https://api.github.com/markdown/raw';
+
+ // google-code-prettify: https://code.google.com/p/google-code-prettify/
+ const FENCED_CODE_BLOCKS_TEMPLATE_FOR_GOOGLE_CODE_PRETTIFY = '{{codeblock}}'; + + public $agent = ''; + public $url = ''; + public $has_converter = false; + public $gfm_options = array(); + + static function get_instance() { + static $plugin = null; + if ( ! $plugin ) { + $plugin = new WP_GFM(); + } + return $plugin; + } + + private function __construct() { + $this->agent = self::NAME . '/' . self::VERSION; + $this->url = plugins_url( '', __FILE__ ); + + $this->gfm_options = wp_parse_args( + (array) get_option( 'gfm' ), + array( + 'general_ad' => false, + 'php_md_always_convert' => false, + 'php_md_use_autolink' => false, + 'php_md_fenced_code_blocks_template' => self::FENCED_CODE_BLOCKS_TEMPLATE_FOR_GOOGLE_CODE_PRETTIFY, + 'render_url' => self::DEFAULT_RENDER_URL, + ) + ); + + if ( is_admin() ) { + add_action( 'admin_init', array( $this, 'admin_init' ) ); + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); + add_action( 'admin_print_footer_scripts', array( $this, 'admin_quicktags' ) ); + } else { + add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_styles' ) ); + } + } + + function wp_enqueue_styles() { + wp_enqueue_style( 'wp-gfm', $this->url . '/css/markdown.css', array(), self::VERSION ); + } + + function php_markdown_init() { + if ( class_exists( '\Gfm\Markdown\Extra' ) ) { + $this->has_converter = true; + \Gfm\Markdown\Extra::setElementCssPrefix( 'wp-gfm-' ); + // @codingStandardsIgnoreStart + \Gfm\Markdown\Extra::$useAutoLinkExtras = true == $this->gfm_options['php_md_use_autolink']; + \Gfm\Markdown\Extra::$fencedCodeBlocksTemplate = $this->gfm_options['php_md_fenced_code_blocks_template']; + // @codingStandardsIgnoreEnd + } + + if ( $this->gfm_options['php_md_always_convert'] ) { + add_action( 'the_content', array( $this, 'force_convert' ), 7 ); + } else { + add_action( 'the_content', array( $this, 'the_content' ), 7 ); + } + + if ( $this->gfm_options['general_ad'] ) { + add_action( 'the_content', array( $this, 'the_content_ad' ), 8 ); + } + + add_shortcode( 'embed_markdown', array( $this, 'shortcode_embed_markdown' ) ); + add_filter( 'pre_comment_content', array( $this, 'pre_comment_content' ), 5 ); + } + + function admin_init() { + register_setting( 'gfm_option_group', 'gfm_array', array( $this, 'option_sanitize_gfm' ) ); + + add_settings_section( + 'setting_section_general', + 'General', + array( $this, 'setting_section_general' ), + 'gfm-setting-admin' + ); + + add_settings_field( + 'general_ad', + '', + array( $this, 'create_gfm_general_ad_field' ), + 'gfm-setting-admin', + 'setting_section_general' + ); + + add_settings_section( + 'setting_section_php_markdown', + 'PHP Markdown', + array( $this, 'print_section_php_markdown' ), + 'gfm-setting-admin' + ); + + add_settings_field( + 'php_md_always_convert', + '', + array( $this, 'create_gfm_php_md_always_convert_field' ), + 'gfm-setting-admin', + 'setting_section_php_markdown' + ); + + add_settings_field( + 'php_md_use_autolink', + '', + array( $this, 'create_gfm_php_md_use_autolink_field' ), + 'gfm-setting-admin', + 'setting_section_php_markdown' + ); + + add_settings_field( + 'php_md_fenced_code_blocks_template', + 'Fenced Code Blocks Template', + array( $this, 'create_gfm_php_md_fenced_code_blocks_template_field' ), + 'gfm-setting-admin', + 'setting_section_php_markdown' + ); + + add_settings_section( + 'setting_section_gfm', + 'GitHub Flavored Markdown', + array( $this, 'print_section_gfm' ), + 'gfm-setting-admin' + ); + + add_settings_field( + 'render_url', + 'Render URL', + array( $this, 'create_gfm_render_url_field' ), + 'gfm-setting-admin', + 'setting_section_gfm' + ); + } + + function admin_menu() { + if ( function_exists( 'add_options_page' ) ) { + add_options_page( + 'GFM Plugin Settings', + 'WP GFM', + 'manage_options', + 'wp-gfm', + array( $this, 'options_page' ) + ); + } + } + + function options_page() { + ?> +
The plugin converts content even if it is not surrounded by [markdown]
'; + } + + function create_gfm_php_md_use_autolink_field() { + echo 'gfm_options['php_md_use_autolink'], false ) . ' /> Use AutoLink'; + } + + function create_gfm_php_md_fenced_code_blocks_template_field() { + $value = esc_attr( $this->gfm_options['php_md_fenced_code_blocks_template'] ); + echo '' + . ''
+ . '{{lang}}, {{title}}, {{codeblock}}
'
+ . 'For google-code-prettify: ' . esc_attr( self::FENCED_CODE_BLOCKS_TEMPLATE_FOR_GOOGLE_CODE_PRETTIFY ) . '
'
+ . '