1 | <?php |
||
7 | class GravityView_Field_Entry_Approval extends GravityView_Field { |
||
8 | |||
9 | var $name = 'entry_approval'; |
||
10 | |||
11 | var $is_searchable = true; |
||
12 | |||
13 | var $is_sortable = true; |
||
14 | |||
15 | var $is_numeric = true; |
||
16 | |||
17 | var $group = 'gravityview'; |
||
18 | |||
19 | var $contexts = array( 'single', 'multiple' ); |
||
20 | |||
21 | public function __construct() { |
||
31 | |||
32 | /** |
||
33 | * Remove unused settings for the approval field |
||
34 | * |
||
35 | * @since 1.19 |
||
36 | * |
||
37 | * @param array $field_options |
||
38 | * @param string $template_id |
||
39 | * @param string $field_id |
||
40 | * @param string $context |
||
41 | * @param string $input_type |
||
42 | * |
||
43 | * @return array |
||
44 | */ |
||
45 | function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
||
55 | |||
56 | /** |
||
57 | * Add filters and actions for the field |
||
58 | * |
||
59 | * @since 1.19 |
||
60 | * |
||
61 | * @return void |
||
62 | */ |
||
63 | private function add_hooks() { |
||
77 | |||
78 | /** |
||
79 | * @filter `gravityview/template/field_label` Modify field label output |
||
80 | * |
||
81 | * @since 1.19 |
||
82 | * |
||
83 | * @param string $html Existing HTML output |
||
84 | * @param array $args Arguments passed to the function |
||
85 | * |
||
86 | * @return string Empty string if user doesn't have the `gravityview_moderate_entries` cap; field HTML otherwise |
||
87 | */ |
||
88 | public function maybe_prevent_field_render( $html, $args ) { |
||
97 | |||
98 | /** |
||
99 | * Modify search to use `is_approved` meta key to sort, instead of `entry_approval` |
||
100 | * |
||
101 | * @param array $parameters Search parameters used to generate GF search |
||
102 | * |
||
103 | * @return array Same parameters, but if sorting by `entry_approval`, changed to `is_approved` |
||
104 | */ |
||
105 | public function modify_search_parameters( $parameters ) { |
||
113 | |||
114 | /** |
||
115 | * Register the field approval script and style |
||
116 | * |
||
117 | * @since 1.19 |
||
118 | * |
||
119 | * @return void |
||
120 | */ |
||
121 | function register_scripts_and_styles() { |
||
146 | |||
147 | /** |
||
148 | * Register the field approval script and output the localized text JS variables |
||
149 | * @since 1.19 |
||
150 | * @return void |
||
151 | */ |
||
152 | public function enqueue_and_localize_script() { |
||
170 | |||
171 | /** |
||
172 | * Add Fields to the field list |
||
173 | * |
||
174 | * @since 1.19 |
||
175 | * |
||
176 | * @param array $entry_default_fields Array of fields shown by default |
||
177 | * @param string|array $form form_ID or form object |
||
178 | * @param string $context Either 'single', 'directory', 'header', 'footer' |
||
179 | * |
||
180 | * @return array |
||
181 | */ |
||
182 | public function filter_gravityview_entry_default_field( $entry_default_fields, $form, $context ) { |
||
194 | |||
195 | /** |
||
196 | * Get the anchor text for a link, based on the current status |
||
197 | * |
||
198 | * @since 1.19 |
||
199 | * @uses GravityView_Entry_Approval_Status::get_string() |
||
200 | * |
||
201 | * @param string $approved_status Status string or key |
||
202 | * |
||
203 | * @return false|string False if string doesn't exist, otherwise the "label" for the status |
||
204 | */ |
||
205 | public static function get_anchor_text( $approved_status = '' ) { |
||
208 | |||
209 | /** |
||
210 | * Get the title attribute for a link, based on the current status |
||
211 | * |
||
212 | * @since 1.19 |
||
213 | * @uses GravityView_Entry_Approval_Status::get_string() |
||
214 | * |
||
215 | * @param int|string $approved_status Status string or key |
||
216 | * |
||
217 | * @return false|string |
||
218 | */ |
||
219 | public static function get_title_attr( $approved_status ) { |
||
222 | |||
223 | /** |
||
224 | * Get the CSS class for a link, based on the current status |
||
225 | * |
||
226 | * @param int|string $approved_status Status string or key |
||
227 | * |
||
228 | * @return string CSS class, sanitized using esc_attr() |
||
229 | */ |
||
230 | public static function get_css_class( $approved_status ) { |
||
236 | } |
||
237 | |||
239 |
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.