子テーマを作成する時など、いまどのテンプレートファイルを読み込んでるのかをヘッダーの上に表示する。
あくまでもデバッグ用なので、終わったら消して(無効化)して下さい。
function header_get_page_template(){
global $template;
$temp_path = str_replace( get_theme_root() ,'', $template );
echo 'Template Path: ';
echo $temp_path . '<br>';
}
add_filter('wp_head', 'header_get_page_template');
また、wp-contentのthemesの中の読込んだファイルをフッターに表示するツールも作ってみました。
add_action( 'wp_footer', 'trace_included_files' );
function trace_included_files() {
// echo php_uname()."<br>";
// echo PHP_OS."<br>";
// Const
// $delimiter = '\\'; // For Windows
$delimiter = DIRECTORY_SEPARATOR;
// Site Dir
$site_dir = ABSPATH;
$site_dir = str_replace("/", "\\", $site_dir );
// Get Themes Dir
$theme_dir = get_stylesheet_directory();
$theme_dir = str_replace("/", "\\", $theme_dir );
$plugin_dir = WP_PLUGIN_DIR;
$plugin_dir = str_replace("/", "\\", $plugin_dir );
// Get All include Files
$include_files = get_included_files();
$dir_arrays = array();
foreach ($include_files as $key => $value) {
$include_path = pathinfo($value);
$include_dir = $include_path['dirname'];
$short_value = str_replace($site_dir, '', $value);
$short_value_array = pathinfo($short_value);
$short_value_args = explode($delimiter, $short_value_array['dirname']);
$short_value_temp['dirname'] = $short_value_args;
$short_value_temp['basename'] = $short_value_array['basename'];
array_push($dir_arrays, $short_value_temp);
// Sapalete Full Dir
$each_dir_name = explode( $delimiter, $include_dir);
}
echo '<table border=1>';
echo '<tr><th>[Path]</th><th>[File]</th></tr>';
foreach ($dir_arrays as $dir_array) {
if (($dir_array['dirname'][0] === 'wp-content')
AND ($dir_array['dirname'][1] === 'themes')) {
echo '<tr>';
echo '<td>';
$dir_array_basename = null;
$dir_array_basenames = $dir_array['dirname'];
foreach ($dir_array_basenames as $dir_array_key => $dir_array_value ) {
if ($dir_array_key != 0) { echo '/'; }
echo $dir_array_value;
}
echo '<td>';
echo $dir_array['basename'];
echo '</td>';
echo '</tr>';
}
}
echo '</table>';
}
表示条件を変えたい場合は、49行目の条件を変えてみてください。

コメントを残す
コメントを投稿するにはログインしてください。