以前のエントリーで紹介した『Jetpack』のフォーム機能。サクッとサイト内に実装できて便利なんですが、困ったことに body セクション内にCSSへのリンクを作ってしまうことが発覚しました。
(@msngさんありがとう)
これはなんかムズムズする仕様なので、head セクションに押し込むことにします。お約束の「ご利用は計画的に」の技術情報ですのでお含み置きを。
問題の link タグは jetpack/modules/contact-form/grunion-contact-form.php で生成されていて、692~700行目あたりにヒントが書いてあります。
/* Can be dequeued by placing the following in wp-content/themes/yourtheme/functions.php
*
* function remove_grunion_style() {
* wp_deregister_style('grunion.css');
* }
* add_action('wp_print_styles', 'remove_grunion_style');
*/
wp_register_style('grunion.css', GRUNION_PLUGIN_URL . 'css/grunion.css');
ということで、これを参考に functions.php にこんな感じで追記しました。
[2012.4.26 10:00追記 初出のコードにtypoがありましたので修正]
function my_jetpack_style() {
if ( !is_admin() && defined( 'GRUNION_PLUGIN_URL' ) ) {
function my_remove_style() {
wp_deregister_style( 'grunion.css' );
}
add_action( 'wp_print_styles', 'my_remove_style' );
function my_register_style() {
wp_register_style( 'grunion', GRUNION_PLUGIN_URL . 'css/grunion.css' );
wp_print_styles( 'grunion' );
}
add_action( 'wp_head', 'my_register_style' );
}
}
add_action( 'after_setup_theme', 'my_jetpack_style' );
コメントを残す