1 | <?php |
||
5 | class Feature |
||
6 | { |
||
7 | |||
8 | private static $initialFile = 'functions.php'; |
||
9 | private static $features = []; |
||
10 | |||
11 | /** |
||
12 | * Gets all options for a feature. |
||
13 | * |
||
14 | * Returns all parameters passed to `add_theme_support` in the lib/Init.php file. |
||
15 | * |
||
16 | * @since 0.1.0 |
||
17 | * |
||
18 | * @param string $feature Name of the feature. |
||
19 | * |
||
20 | * @return array|null Returns an array of options or null if the feature wasn't found. |
||
21 | */ |
||
22 | public static function getOptions($feature) |
||
27 | |||
28 | /** |
||
29 | * Gets single option for a feature. |
||
30 | * |
||
31 | * Returns a single parameter passed to `add_theme_support` in the lib/Init.php file using the key (starting with 0) of that option. |
||
32 | * |
||
33 | * @since 0.1.0 |
||
34 | * |
||
35 | * @param string $feature Name of the feature. |
||
36 | * @param string $key The option key. |
||
37 | * |
||
38 | * @return mixed|null Returns the option or null if the option / the feature doesn't exist. |
||
39 | */ |
||
40 | public static function getOption($feature, $key) |
||
45 | |||
46 | /** |
||
47 | * Gets the absolute path of a feature. |
||
48 | * |
||
49 | * @since 0.1.0 |
||
50 | * |
||
51 | * @param string $feature Name of the feature. |
||
52 | * |
||
53 | * @return string|null Returns the path or null if the feature doesn't exist. |
||
54 | */ |
||
55 | public static function getDir($feature) |
||
60 | |||
61 | /** |
||
62 | * Registers a feature. |
||
63 | * |
||
64 | * @since 0.1.0 |
||
65 | * |
||
66 | * @param string $feature Name of the feature. |
||
67 | * @param string $basePath The feature base path. |
||
68 | * @param array $options An array of options. Optional. |
||
69 | * |
||
70 | * @return boolean |
||
71 | */ |
||
72 | public static function register($feature, $basePath, $options = []) |
||
102 | |||
103 | /** |
||
104 | * Checks if a feature is already registered. |
||
105 | * |
||
106 | * @since 0.1.0 |
||
107 | * |
||
108 | * @param string $name The feature name. |
||
109 | * |
||
110 | * @return boolean |
||
111 | */ |
||
112 | public static function isRegistered($name) |
||
116 | |||
117 | /** |
||
118 | * Gets a registered feature. |
||
119 | * |
||
120 | * @since 0.1.0 |
||
121 | * |
||
122 | * @param string $name Name of the feature. |
||
123 | * |
||
124 | * @return array|boolean Returns an array with feature options and its directory or false if the feature is not registered. |
||
125 | */ |
||
126 | public static function getFeature($name) |
||
133 | |||
134 | /** |
||
135 | * Gets all registered features. |
||
136 | * |
||
137 | * @since 0.1.0 |
||
138 | * |
||
139 | * @return array Array of features with their options and directory. |
||
140 | */ |
||
141 | public static function getFeatures() |
||
145 | |||
146 | /** |
||
147 | * Sets the initial file to be required for a feature. |
||
148 | * |
||
149 | * @since 0.1.0 |
||
150 | * |
||
151 | * @param string $fileName File name or path relative to a feature's directory. |
||
152 | */ |
||
153 | public static function setInitialFile($fileName) |
||
157 | } |
||
158 |