1 | <?php |
||
14 | abstract class Request { |
||
15 | 64 | public function __construct() { |
|
17 | |||
18 | /** |
||
19 | * Check if WordPress is_admin(), and make sure not DOING_AJAX. |
||
20 | * |
||
21 | * @return boolean |
||
22 | */ |
||
23 | 15 | public static function is_admin() { |
|
29 | |||
30 | /** |
||
31 | * This is the frontend. |
||
32 | * |
||
33 | * @return boolean True or false. |
||
34 | */ |
||
35 | public static function is_frontend() { |
||
38 | |||
39 | /** |
||
40 | * Is this the Add Media / From URL preview request? |
||
41 | * |
||
42 | * Will not work in WordPress 4.8+ |
||
43 | * |
||
44 | * @return boolean |
||
45 | */ |
||
46 | 2 | public static function is_add_oembed_preview() { |
|
50 | |||
51 | /** |
||
52 | * Is this an AJAX call in progress? |
||
53 | * |
||
54 | * @return boolean |
||
55 | */ |
||
56 | 2 | public static function is_ajax() { |
|
59 | |||
60 | /** |
||
61 | * Is this a REST request? Call after parse_request. |
||
62 | * |
||
63 | * @return boolean |
||
64 | */ |
||
65 | public static function is_rest() { |
||
68 | |||
69 | /** |
||
70 | * The current $post is a View, no? |
||
71 | * |
||
72 | * @api |
||
73 | * @since 2.0 |
||
74 | * @todo tests |
||
75 | * |
||
76 | * @return \GV\View|false The view requested or false |
||
77 | */ |
||
78 | 56 | public function is_view() { |
|
85 | |||
86 | /** |
||
87 | * Is this an edit entry request? |
||
88 | * |
||
89 | * @api |
||
90 | * @since 2.0 |
||
91 | * @todo tests |
||
92 | * |
||
93 | * @return \GV\GF_Entry|false The entry requested or false. |
||
94 | */ |
||
95 | 7 | public function is_entry() { |
|
103 | |||
104 | /** |
||
105 | * Check whether this an edit entry request. |
||
106 | * |
||
107 | * @api |
||
108 | * @since 2.0 |
||
109 | * @todo tests |
||
110 | * |
||
111 | * @return \GV\Entry|false The entry requested or false. |
||
112 | */ |
||
113 | 5 | public function is_edit_entry() { |
|
124 | |||
125 | /** |
||
126 | * Check whether this an entry search request. |
||
127 | * |
||
128 | * @api |
||
129 | * @since 2.0 |
||
130 | * @todo implementation |
||
131 | * |
||
132 | * @return boolean True if this is a search request. |
||
133 | */ |
||
134 | 6 | public function is_search() { |
|
148 | |||
149 | /** |
||
150 | * Calculate whether the $_REQUEST has a GravityView field |
||
151 | * |
||
152 | * @internal |
||
153 | * @todo Roll into the future Search refactor |
||
154 | * |
||
155 | * @since 2.0.7 |
||
156 | * |
||
157 | * @param array $get $_POST or $_GET array |
||
158 | * |
||
159 | * @return bool True: GravityView-formatted field detected; False: not detected |
||
160 | */ |
||
161 | 5 | private function _has_field_key( $get ) { |
|
183 | } |
||
184 | |||
190 |
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.