オリジナルテーマ「my-theme」の作成のため、my-themeフォルダにstyle.cssとindexphpを格納した場合、style.cssの記述方法を、WP_Themeクラスをコールして確認する、
WP_Themeクラスをコールする
WP_Theme は wp-includes/class-wp-theme.php にて定義されているクラスで、開発者がテーマを扱うインターフェイスを提供します。
クラスリファレンス/WP Theme
index.phpに記述する。
$theme = new WP_THEME('my-theme', __DIR__ . '/..');
var_dump($theme);
ブラウザに表示される。
C:XXXX\public\wp-content\themes\my-theme\index.php:4:
object(WP_Theme)[4693]
public 'update' => boolean false
private 'theme_root' => string 'C:XXXX\public\wp-content\themes\my-theme/..' (length=69)
private 'headers' =>
array (size=13)
'Name' => string '私のテーマ' (length=15)
'ThemeURI' => string '' (length=0)
'Description' => string '' (length=0)
'Author' => string '' (length=0)
'AuthorURI' => string '' (length=0)
'Version' => string '' (length=0)
'Template' => string '' (length=0)
'Status' => string '' (length=0)
'Tags' => string '' (length=0)
'TextDomain' => string '' (length=0)
'DomainPath' => string '' (length=0)
'RequiresWP' => string '' (length=0)
'RequiresPHP' => string '' (length=0)
private 'headers_sanitized' => null
private 'name_translated' => null
private 'errors' => null
private 'stylesheet' => string 'my-theme' (length=8)
private 'template' => string 'my-theme' (length=8)
private 'parent' => null
private 'theme_root_uri' => null
private 'textdomain_loaded' => null
private 'cache_hash' => string 'XXXXX' (length=32)
wp-includes/class-wp-theme.php 引用。
final class WP_Theme implements ArrayAccess {
private static $file_headers = array(
'Name' => 'Theme Name',
'ThemeURI' => 'Theme URI',
'Description' => 'Description',
'Author' => 'Author',
'AuthorURI' => 'Author URI',
'Version' => 'Version',
'Template' => 'Template',
'Status' => 'Status',
'Tags' => 'Tags',
'TextDomain' => 'Text Domain',
'DomainPath' => 'Domain Path',
);
private static $default_themes = array(
'classic' => 'WordPress Classic',
'default' => 'WordPress Default',
'twentyten' => 'Twenty Ten',
'twentyeleven' => 'Twenty Eleven',
'twentytwelve' => 'Twenty Twelve',
'twentythirteen' => 'Twenty Thirteen',
'twentyfourteen' => 'Twenty Fourteen',
);
private static $tag_map = array(
'fixed-width' => 'fixed-layout',
'flexible-width' => 'fluid-layout',
);
private $theme_root;
private $headers = array();
private $headers_sanitized;
private $name_translated;
private $errors;
private $stylesheet;
private $template;
private $parent;
private $theme_root_uri;
private $textdomain_loaded;
private $cache_hash;
private static $persistently_cache;
private static $cache_expiration = 1800;