個人的には、あまり利用することはありませんが、メモ
/**
* テーマバージョン表示
*/
function version_num() {
if ( function_exists( 'wp_get_theme' ) ) {
$theme_data = wp_get_theme();
} else {
$theme_data = wp_get_theme( get_theme_file_path() . '/style.css' );
}
$current_version = $theme_data['Version'];
return $current_version;
};
使い方
CSS スタイルファイルを出力させる関数の場合
<?php wp_enqueue_style( $handle, $src, $deps, version_num(), $media ); ?>
$handle
名前
$src
get_theme_file_path() . '/css/style.css'
などcssファイルのパスを入れる
$deps
このcssファイルの前に入れるファイルがある場合は配列で指定
$media
初期値: ‘all’で問題なし
実際には・・・
<?php wp_enqueue_style( 'top', get_theme_file_path() . '/css/top.css', array(), version_num(), 'all' ); ?>
下記でもOKだけど、phpcsさんはエラーとしちゃう。(バージョンが書いていないから)
<?php wp_enqueue_style( 'top', get_theme_file_path() . '/css/top.css' ); ?>

