「Simple Tags」のカスタマイズ

投稿日:

 WordPressのプラグイン「Simple Tags」を愛用している。記事に含まれるキー・ワードで自動的にタグをつけることも可能だ。しかし、いつもいつもこの「自動タグ機能」を使いたいわけでもない。なので、ほとんどの場合、記事を新規作成した時の「□ Disable auto tags ?」のチェックボックスを「☑」(チェック)にして、機能をオフにする。ところが、これが毎回毎回なのが気に食わない。この機能のデフォルトが「非checked」だからだ。実に面倒である。

 そこで、プラグイン・エディタで該当部分を書き直してしまうことにした。

 プラグイン内を片っ端から検索してみたところ、「simple-tags/inc/class.admin.post.php」がその部分を生成していることが分かった。

 その中に、

		// Auto terms for this CPT ?
		if ( (int) SimpleTags_Plugin::get_option_value( 'active_autotags' ) === 1 && isset( $auto_options[ $post->post_type ] ) && ! empty( $auto_options[ $post->post_type ] ) ) {
			$meta_value = get_post_meta( $post->ID, '_exclude_autotags', true );
			echo '<p>' . "\n";
			echo '<label><input type="checkbox" name="exclude_autotags" value="true"  ' . checked( $meta_value, true, false ) . ' /> ' . __( 'Disable auto tags ?', 'simpletags' ) . '</label><br />' . "\n";
			echo '</p>' . "\n";
			echo '<input type="hidden" name="_meta_autotags" value="true" />';
		}

……という箇所があるのだが、これを

		// Auto terms for this CPT ?
		if ( (int) SimpleTags_Plugin::get_option_value( 'active_autotags' ) === 1 && isset( $auto_options[ $post->post_type ] ) && ! empty( $auto_options[ $post->post_type ] ) ) {
			$meta_value = get_post_meta( $post->ID, '_exclude_autotags', true );
			echo '<p>' . "\n";
			// echo '<label><input type="checkbox" name="exclude_autotags" value="true"  ' . checked( $meta_value, true, false ) . ' /> ' . __( 'Disable auto tags ?', 'simpletags' ) . '</label><br />' . "\n";
			echo '<label><input type="checkbox" name="exclude_autotags" value="true" checked="checked" ' . checked( $meta_value, true, false ) . ' /> ' . __( 'Disable auto tags ?', 'simpletags' ) . '</label><br />' . "\n";
			echo '</p>' . "\n";
			echo '<input type="hidden" name="_meta_autotags" value="true" />';
		}

……と、下線赤字のように書き足したわけである。さて、うまく作動するかな?……。