forked from monkblog/theme-manager
/
example.php
67 lines (47 loc) · 1.87 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
require_once 'vendor/autoload.php';
$basePath = null;
$requiredFields = [ 'display_name', 'version', 'license', ];
/**
* Via new Class
*/
//Bootstrapping theme php files if autoload.php file is present
( new \ThemeManager\Starter )->bootstrapAutoload();
//OR via helper
theme_manager_starter()->bootstrapAutoload();
//Via new
$themeManager = new \ThemeManager\ThemeManager( (new \ThemeManager\Starter)->start() );
//Optionally pass in initial base path
$themeManager = new \ThemeManager\ThemeManager( (new \ThemeManager\Starter)->start( __DIR__ . '/path/to/themes/' ) );
//Optional Required Field(s)
$themeManager = new \ThemeManager\ThemeManager( ( new \ThemeManager\Starter )->start( $basePath, $requiredFields ) );
//Via Theme Manager Starter Helper
$themeManager = new \ThemeManager\ThemeManager( theme_manager_starter()->start() );
// Exception On Invalid
$themeManager = new \ThemeManager\ThemeManager( theme_manager_starter()->start( $basePath, $requiredFields, true ) );
/**
* Via Helper
*/
$themeManager = theme_manager();
//Optionally pass in initial base path
$themeManager = theme_manager( __DIR__ . '/path/to/themes/' );
//Optional Required Field(s)
$themeManager = theme_manager( $basePath, $requiredFields );
// Exception On Invalid
$themeManager = theme_manager( $basePath, $requiredFields, true );
//ThemeCollection
$allThemes = $themeManager->all();
//Returns bool
$myThemeExists = $themeManager->themeExists( 'theme-name' ) ? 'yes' : 'nope';
//Theme Obj or null
$myTheme = $themeManager->getTheme( 'theme-name' );
//Array
$myThemeInfo = $myTheme->getInfo();
//Array of strings
$themeNames = $themeManager->getAllThemeNames();
//First Theme Obj
$firstTheme = $allThemes->first();
//Last Theme Obj
$lastTheme = $allThemes->last();
//Add another location of themes to the ThemeManager
$themeManager->addThemeLocation( __DIR__ . '/path/to/alternative/themes-folder' );