Last active
November 24, 2015 03:22
-
-
Save wokamoto/048b93a4c87b86b184d6 to your computer and use it in GitHub Desktop.
[WordPress] git 管理しているテーマでバージョンとして git のコミットIDをバージョン番号として使用するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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