Changeset 707957
- Timestamp:
- 05/04/2013 06:06:44 PM (13 years ago)
- Location:
- wp-hatena-notation/trunk
- Files:
-
- 6 edited
-
WP/Hatena/Notation.php (modified) (5 diffs)
-
WP/Hatena/Notation/Migration.php (modified) (1 diff)
-
WP/Hatena/Notation/Options.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
views/options.php (modified) (1 diff)
-
wp-hatena-notation.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-hatena-notation/trunk/WP/Hatena/Notation.php
r706689 r707957 31 31 32 32 /** 33 * Enable wpautop filter 34 * @var bool 35 */ 36 protected $wpautop = false; 37 38 /** 33 39 * Constructor 34 40 * … … 49 55 add_action('admin_init', array($this, 'onAdminInit')); 50 56 add_action('the_post', array($this, 'onThePost')); 57 add_filter('the_content', array($this, 'onTheContent')); 58 59 // Remove wpautop 60 if ($this->option('Renderer.linebreak_method') !== 'wordpress') { 61 $this->wpautop = remove_filter('the_content', 'wpautop'); 62 } 51 63 } 52 64 … … 69 81 * 70 82 * @param string $content 71 * @param mixed $post Optional, Post ID or Post object72 83 * @return string 73 84 */ 74 public function render($content, $post = null) { 75 if ($post) { 76 $post = get_post($post); 77 if (!$this->Config->isEnabled($post->ID)) { 78 return $content; 79 } 80 } 85 public function render($content) { 81 86 return $this->Renderer->render(HatenaSyntax::parse($content)); 82 87 } … … 85 90 * Enabled post? 86 91 * 87 * @param $post_id92 * @param WP_Post $post 88 93 * @return bool 89 94 */ 90 public function enabled($post_id, $enabled = 1) { 95 public function enabled($post, $enabled = 1) { 96 $post = get_post($post); 97 91 98 if (count(func_get_args()) === 2) { 92 return $this->Config->saveEnabled($post _id, $enabled);99 return $this->Config->saveEnabled($post->ID, $enabled); 93 100 } 94 return $this->Config->isEnabled($post_id); 101 102 return $this->Config->isEnabled($post->ID); 95 103 } 96 104 … … 121 129 public function onThePost($post) { 122 130 global $page, $pages; 123 $content = preg_replace('/<!--more(.*?)?-->/', '====', $pages[$page - 1]); 124 $pages[$page - 1] = $this->render($content, $post); 131 132 if ($this->enabled($post)) { 133 $content = preg_replace('/<!--more(.*?)?-->/', '====', $pages[$page - 1]); 134 $pages[$page - 1] = $this->render($content); 135 } 136 } 137 138 /** 139 * Hook on the_content 140 * 141 * @param string $content 142 * @return string 143 */ 144 public function onTheContent($content) { 145 $post = get_post(); 146 147 if (!$this->wpautop || $this->enabled($post)) { 148 return $content; 149 } 150 151 return wpautop($content); 125 152 } 126 153 } -
wp-hatena-notation/trunk/WP/Hatena/Notation/Migration.php
r707817 r707957 77 77 } 78 78 79 $context->option('Config.per_post _default', true);79 $context->option('Config.per_post', true); 80 80 } 81 81 -
wp-hatena-notation/trunk/WP/Hatena/Notation/Options.php
r706689 r707957 44 44 $this->options['Renderer'] += array( 45 45 'headerlevel' => 3, 46 'linebreak_method' => 'w ordpress',46 'linebreak_method' => 'wpautop', 47 47 'link_target_blank' => true, 48 48 'title_expires' => 90, -
wp-hatena-notation/trunk/readme.txt
r707817 r707957 42 42 == Changelog == 43 43 44 = 2.0.3 = 45 * 改行の扱いで「何もしない」以外を選んだ場合`wpautop`フィルタを無効化 46 44 47 = 2.0.2 = 45 48 * HTMLが全てエスケープされる不具合を修正 46 * マイグレーション時に「はてな記法を使用」のデフォルトが不使用になる不具合を修正47 49 48 50 = 2.0.1 = -
wp-hatena-notation/trunk/views/options.php
r706689 r707957 47 47 <td> 48 48 <select name="<?php echo $this->fieldName('Renderer.linebreak_method'); ?>"> 49 <option value="wpautop"<?php if ($options->Renderer->linebreak_method === 'wpautop'): ?> selected="selected"<?php endif; ?>>wpautop関数を適用(推奨)</option> 49 50 <option value="wordpress"<?php if ($options->Renderer->linebreak_method === 'wordpress'): ?> selected="selected"<?php endif; ?>>何もしない(WordPressの改行ルールに従う)</option> 50 <option value="wpautop"<?php if ($options->Renderer->linebreak_method === 'wpautop'): ?> selected="selected"<?php endif; ?>>wpautop関数を適用</option> 51 <option value="plugin"<?php if ($options->Renderer->linebreak_method === 'plugin'): ?> selected="selected"<?php endif; ?>>改行を全てpとして扱う</option> 51 <option value="plugin"<?php if ($options->Renderer->linebreak_method === 'plugin'): ?> selected="selected"<?php endif; ?>>改行を全てpとして扱う(廃止予定)</option> 52 52 </select> 53 53 <p class="description"><code><p></code>や<code><br></code>を挿入する方法を指定します。</p> -
wp-hatena-notation/trunk/wp-hatena-notation.php
r707803 r707957 4 4 Plugin URI: https://github.com/rewish/wp-hatena-notation 5 5 Description: あなたのWordPressに「はてな記法」を導入します。 6 Version: 2.0. 26 Version: 2.0.3 7 7 Author: rewish 8 8 Author URI: https://github.com/rewish
Note: See TracChangeset
for help on using the changeset viewer.