/* | |
WordPressのテーマにおいて、テンプレート階層に基づきどのテンプレートファイルが使われているか書き出すコード。 | |
ただし、header.php や get_template_part などでインクルードされているファイルを除く。 | |
*/ | |
add_action('wp_footer', 'view_template_files'); | |
if ( !function_exists( 'view_template_files' ) ): | |
function view_template_files() { | |
if ( defined('WP_DEBUG') && WP_DEBUG ) { | |
global $template; | |
$template_name = basename( $template, '.php' ); | |
$template_dir = basename ( dirname( $template ) ); | |
$style_top = ( is_admin_bar_showing() ) ? "35px" : "0px"; | |
echo '<code style="position: fixed; top: ' . $style_top . '; right: 10px; z-index: 9999; background-color: rgba(255, 255, 255, 0.5); padding: 10px; color: #000000; border: solid 2px #000000; ">'; | |
echo "テーマのディレクトリ名:" . $template_dir; | |
echo " テンプレートファイル名:" . $template_name; | |
echo "</code>\n"; | |
} | |
} | |
endif; |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
説明漏れ。 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
gatespace
Jan 17, 2013
2013.1.16 @wokamoto さんのコードを元に、テンプレートファイル名とテーマフォルダを分かりやすく表記するようにしました。
https://gist.github.com/4553528
https://gist.github.com/4553584
2013.1.16 @wokamoto さんのコードを元に、テンプレートファイル名とテーマフォルダを分かりやすく表記するようにしました。 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
gatespace
Jan 17, 2013
@tekapo さんのコードを元にwp_footer にフックする用に変更しました。
https://gist.github.com/4529793
スタイルシート周りを調整しました。
@tekapo さんのコードを元にwp_footer にフックする用に変更しました。 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
wokamoto
Jan 22, 2013
if ( defined('WP_DEBUG') && WP_DEBUG )
の方が、安全じゃないですか?
定数 WP_DEBUG が定義されていない場合、動作が不安定になる気がします。
wokamoto
commented
Jan 22, 2013
if ( defined('WP_DEBUG') && WP_DEBUG ) の方が、安全じゃないですか? |
@wokamoto さん。ありがとうございます。反映しました。 |
説明漏れ。
コード読むと分かるかも知れませんが、if (WP_DEBUG) とあるように、WordPressをデバッグモードにしておく必要があります。