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 | * Defines plugin constants |
||
65 | * |
||
66 | * @since 1.0.0 |
||
67 | * @access private |
||
68 | */ |
||
69 | private function define_constants() { |
||
82 | |||
83 | /** |
||
84 | * Include core files that are responsible for theme render |
||
85 | */ |
||
86 | private function include_core_files() { |
||
124 | |||
125 | /** |
||
126 | * Include theme Object-Orienter models |
||
127 | */ |
||
128 | private function include_models() { |
||
142 | |||
143 | /** |
||
144 | * Init Theme Configuration |
||
145 | */ |
||
146 | private function init_config() { |
||
151 | |||
152 | /** |
||
153 | * Filters registered templates and adds custom theme templates. |
||
154 | * |
||
155 | * @param array $page_templates Available WordPress templates. |
||
156 | * |
||
157 | * @return array |
||
158 | */ |
||
159 | public function filter_templates( $page_templates = array() ) { |
||
166 | |||
167 | /** |
||
168 | * Returns theme config variable. |
||
169 | * |
||
170 | * @param string $name Variable's name. |
||
171 | * |
||
172 | * @return mixed|bool Return false if variable not found. |
||
173 | */ |
||
174 | public static function get_config_var( $name ) { |
||
181 | |||
182 | /** |
||
183 | * Returns theme textdomain |
||
184 | * |
||
185 | * @return string |
||
186 | */ |
||
187 | public static function textdomain() { |
||
194 | |||
195 | /** |
||
196 | * Performs view render. |
||
197 | * If there is $view attribute presented, it will render requested view. |
||
198 | * If it's not it will try to find necessary view based on $wp_query |
||
199 | * |
||
200 | * @param string|null $view view path in blade format, ex: single, layout.default, single.partials.slider and etc |
||
201 | * @param array|null $data Additional params |
||
202 | * @return void |
||
203 | */ |
||
204 | public static function render( $view = null, $data = null ) { |
||
234 | |||
235 | /** |
||
236 | * Alias for ClassyHelper::get_archives_title() |
||
237 | * Returns page title for archive page. |
||
238 | * Example: Archives, Author: John Doe, Tag: Lorem Ipsum |
||
239 | * |
||
240 | * @return string |
||
241 | */ |
||
242 | public static function archives_title() { |
||
247 | |||
248 | |||
249 | /** |
||
250 | * Returns posts |
||
251 | * |
||
252 | * @param mixed $args Array of query args |
||
253 | * @param string $return object/id/ClassyPost |
||
254 | * @return mixed |
||
255 | */ |
||
256 | public static function get_posts( $args = false, $return = 'ClassyPost' ) { |
||
284 | |||
285 | |||
286 | /** |
||
287 | * Returns post |
||
288 | * |
||
289 | * @param mixed $args Array of query args |
||
290 | * @param string $return_type ClassyPost/object/id |
||
291 | * @return mixed |
||
292 | */ |
||
293 | public static function get_post( $args = false, $return_type = 'ClassyPost' ) { |
||
302 | |||
303 | /** |
||
304 | * @param array $prefs |
||
305 | * @return array mixed |
||
306 | */ |
||
307 | public static function get_pagination( $prefs = array() ) { |
||
365 | } |
||
366 | |||
387 |
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.