1 | <?php |
||
14 | class Classy { |
||
15 | |||
16 | /** |
||
17 | * Singleton instance of plugin |
||
18 | * |
||
19 | * @var Classy |
||
20 | * @since 0.1.0 |
||
21 | */ |
||
22 | protected static $single_instance = null; |
||
23 | |||
24 | /** |
||
25 | * Creates or returns an instance of this class. |
||
26 | * |
||
27 | * @since 0.1.0 |
||
28 | * @return Classy A single instance of this class. |
||
29 | */ |
||
30 | public static function get_instance() { |
||
41 | |||
42 | /** |
||
43 | * Define the core functionality of the them. |
||
44 | * |
||
45 | * Set the theme name and the theme version that can be used throughout the theme. |
||
46 | * |
||
47 | * @since 1.0.0 |
||
48 | */ |
||
49 | protected function __construct() { |
||
62 | |||
63 | /** |
||
64 | * Function to define constants |
||
65 | * |
||
66 | * @param string |
||
67 | * @param string |
||
68 | */ |
||
69 | private function define( $name, $value ) { |
||
78 | |||
79 | /** |
||
80 | * Defines plugin constants |
||
81 | * |
||
82 | * @since 1.0.0 |
||
83 | * @access private |
||
84 | */ |
||
85 | private function define_constants() { |
||
98 | |||
99 | /** |
||
100 | * Include core files that are responsible for theme render |
||
101 | */ |
||
102 | private function include_core_files() { |
||
140 | |||
141 | /** |
||
142 | * Include theme Object-Orienter models |
||
143 | */ |
||
144 | private function include_models() { |
||
159 | |||
160 | /** |
||
161 | * Init Theme Configuration |
||
162 | */ |
||
163 | private function init_config() { |
||
168 | |||
169 | /** |
||
170 | * Filters registed templates and ads custom theme templates |
||
171 | * |
||
172 | * @return array |
||
173 | */ |
||
174 | |||
175 | public function filter_templates($page_templates = array(), $object = null, $post = null) { |
||
182 | |||
183 | /** |
||
184 | * Returns theme config variable |
||
185 | * |
||
186 | * @param string $name |
||
187 | * @return any |
||
188 | */ |
||
189 | public static function get_config_var($name) { |
||
198 | |||
199 | /** |
||
200 | * Returns theme textdomain |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | public static function textdomain() { |
||
211 | |||
212 | /** |
||
213 | * Performs template render. |
||
214 | * If there is $template attribute presented, it will render requested template. |
||
215 | * If it's not it will try to find necessary template based on $wp_query |
||
216 | * |
||
217 | * @param string|null $template template path in blade format, ex: single, layout.default, single.partials.slider and etc |
||
218 | * @param array|null $data Additional params |
||
219 | * @return void |
||
220 | */ |
||
221 | public static function render($template = null, $data = null) { |
||
252 | |||
253 | /** |
||
254 | * Alias for ClassyHelper::get_archives_title() |
||
255 | * Returns page title for archive page. |
||
256 | * Example: Archives, Author: John Doe, Tag: Lorem Ipsum |
||
257 | * |
||
258 | * @return string |
||
259 | */ |
||
260 | public static function archives_title() { |
||
265 | |||
266 | |||
267 | /** |
||
268 | * Returns posts |
||
269 | * |
||
270 | * @param mixed $args Array of query args |
||
271 | * @param string $return_type ClassyPost/object/id |
||
272 | * @return mixed |
||
273 | */ |
||
274 | public static function get_posts($args = false, $return_type = 'ClassyPost') { |
||
304 | |||
305 | /** |
||
306 | * Returns post |
||
307 | * |
||
308 | * @param mixed $args Array of query args |
||
309 | * @param string $return_type ClassyPost/object/id |
||
310 | * @return mixed |
||
311 | */ |
||
312 | public static function get_post($args = false, $return_type = 'ClassyPost') { |
||
321 | |||
322 | /** |
||
323 | * @param array $prefs |
||
324 | * @return array mixed |
||
325 | */ |
||
326 | public static function get_pagination( $prefs = array() ) { |
||
384 | |||
385 | } |
||
386 | |||
406 | $classy = get_theme_framework(); |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.