WordPressプラグイン「Custom Field Template」のDatePicker日本語化
Custom Field Templateプラグインのdate picker部分の日本語化してみた。しかもほぼこちらの方が書いていることを参考にさせてもらいながらです。
WPプラグイン「Custom Field Template」
こちらの方のプラグインを使わせていただいてます。すごい・・・使いやすい・・・感謝です。
Custom Field Template plugin | WordPressで企業ウェブサイト作成・商用ホームページ制作 WordPress Go Go
カスタムフィールドを追加しやすくするプラグインです。感動。
それで、いちばん感動したのが、datePickerがポップアップしてきた時です。カスタムフィールドテンプレートオプションのテンプレートコンテンツにこうかくと、textfield が datepickerになります。細やか。見事。
[schedule] label = 展示会の日にちを入力してください。(例:2011/01/26) type = text date = true dateFormat = yyyy/mm/dd
日本語化が必要なところ
調べてみると、2つのjsライブラリについて設定を書き換える必要がありそうでした。
- Index of /assets/jquery/datePicker
- Google Code Archive - Long-term storage for Google Code Project Hosting.
date.jsに加筆協力したKelvin Luck氏が、datePicker作った人みたい。自分で作ったメソッドをライブラリで多用している模様( dateFormat, asString...)。コラボってる様がカッコイイ。
修正するところ
2点あります。
1. jsファイルを追加
楽かなと思い、設定外部ファイルを作りました。自分サーバでホストしてありますのでよければ使ってください。
datePicker.setting.js
これを、Custom Field Templateのプラグインフォルダに追加します。(/wordpress/wp-content/plugins/custom-field-templateらへん)
2. 設定jsを読み込み
プラグインファイルcustom-field-template.phpを編集します。(/wordpress/wp-content/plugins/custom-field-template/custom-field-template.phpの519行目らへん)
function custom_field_template_admin_scripts() { if ( !defined('WP_PLUGIN_DIR') ) $plugin_dir = str_replace( ABSPATH, '', dirname(__FILE__) ); else $plugin_dir = dirname( plugin_basename(__FILE__) ); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-form' ); wp_enqueue_script( 'date', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/date.js', array('jquery') ); wp_enqueue_script( 'bgiframe', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.bgiframe.js', array('jquery') ) ; wp_enqueue_script( 'datePicker', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.datePicker.js', array('jquery') ); wp_enqueue_script( 'datePickerSettings', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/datePicker.setting.js', array('jquery') ); wp_enqueue_script( 'textarearesizer', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.textarearesizer.js', array('jquery') ); if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') || $post->post_type=='page' ) : wp_enqueue_script( 'editor' ); endif; }
修正後
こんなになりました。
「翌月」とかは、ホバーしてるときのツールチップ用みたいです。
不具合等あったら教えてください。
感謝
js設定の書き換えはこちらのかたのソースを使わせていただきました。ありがとうございます!
http://sleeping-snow.blogspot.com/2009/06/httpwww_9467.html