Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[WordPress] git 管理しているテーマでバージョンとして git のコミットIDをバージョン番号として使用するサンプル
<?php
$version = 'default';
$stylesheet_dir = get_stylesheet_directory();
if ( file_exists( $stylesheet_dir.'/.git/HEAD' ) ) {
$head = explode(' ', trim(file_get_contents($stylesheet_dir.'/.git/HEAD')) );
if ( isset($head[1]) && file_exists($stylesheet_dir.'/.git/'.$head[1]) ) {
$version = trim(file_get_contents($stylesheet_dir.'/.git/'.$head[1]));
}
}
define( 'THEME_VERSION', $version );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.