@@ -5,21 +5,21 @@ discard block |
||
5 | 5 | function __construct() { |
6 | 6 | |
7 | 7 | //get field options |
8 | - add_action( 'wp_ajax_gv_field_options', array( $this, 'get_field_options' ) ); |
|
8 | + add_action('wp_ajax_gv_field_options', array($this, 'get_field_options')); |
|
9 | 9 | |
10 | 10 | // get available fields |
11 | - add_action( 'wp_ajax_gv_available_fields', array( $this, 'get_available_fields_html' ) ); |
|
11 | + add_action('wp_ajax_gv_available_fields', array($this, 'get_available_fields_html')); |
|
12 | 12 | |
13 | 13 | // get active areas |
14 | - add_action( 'wp_ajax_gv_get_active_areas', array( $this, 'get_active_areas' ) ); |
|
14 | + add_action('wp_ajax_gv_get_active_areas', array($this, 'get_active_areas')); |
|
15 | 15 | |
16 | 16 | // get preset fields |
17 | - add_action( 'wp_ajax_gv_get_preset_fields', array( $this, 'get_preset_fields_config' ) ); |
|
17 | + add_action('wp_ajax_gv_get_preset_fields', array($this, 'get_preset_fields_config')); |
|
18 | 18 | |
19 | 19 | // get preset fields |
20 | - add_action( 'wp_ajax_gv_set_preset_form', array( $this, 'create_preset_form' ) ); |
|
20 | + add_action('wp_ajax_gv_set_preset_form', array($this, 'create_preset_form')); |
|
21 | 21 | |
22 | - add_action( 'wp_ajax_gv_sortable_fields_form', array( $this, 'get_sortable_fields' ) ); |
|
22 | + add_action('wp_ajax_gv_sortable_fields_form', array($this, 'get_sortable_fields')); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -30,17 +30,17 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool |
32 | 32 | */ |
33 | - private function _exit( $mixed = NULL ) { |
|
33 | + private function _exit($mixed = NULL) { |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Don't exit if we're running test suite. |
37 | 37 | * @since 1.15 |
38 | 38 | */ |
39 | - if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) { |
|
39 | + if (defined('DOING_GRAVITYVIEW_TESTS') && DOING_GRAVITYVIEW_TESTS) { |
|
40 | 40 | return $mixed; |
41 | 41 | } |
42 | 42 | |
43 | - exit( $mixed ); |
|
43 | + exit($mixed); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** -------- AJAX ---------- */ |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | */ |
52 | 52 | function check_ajax_nonce() { |
53 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) { |
|
54 | - $this->_exit( false ); |
|
53 | + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxviews')) { |
|
54 | + $this->_exit(false); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -67,20 +67,20 @@ discard block |
||
67 | 67 | //check nonce |
68 | 68 | $this->check_ajax_nonce(); |
69 | 69 | |
70 | - $context = isset($_POST['context']) ? esc_attr( $_POST['context'] ) : 'directory'; |
|
70 | + $context = isset($_POST['context']) ? esc_attr($_POST['context']) : 'directory'; |
|
71 | 71 | |
72 | 72 | // If Form was changed, JS sends form ID, if start fresh, JS sends template_id |
73 | - if( !empty( $_POST['form_id'] ) ) { |
|
74 | - do_action( 'gravityview_render_available_fields', (int) $_POST['form_id'], $context ); |
|
73 | + if (!empty($_POST['form_id'])) { |
|
74 | + do_action('gravityview_render_available_fields', (int)$_POST['form_id'], $context); |
|
75 | 75 | $this->_exit(); |
76 | - } elseif( !empty( $_POST['template_id'] ) ) { |
|
77 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
78 | - do_action( 'gravityview_render_available_fields', $form, $context ); |
|
76 | + } elseif (!empty($_POST['template_id'])) { |
|
77 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
78 | + do_action('gravityview_render_available_fields', $form, $context); |
|
79 | 79 | $this->_exit(); |
80 | 80 | } |
81 | 81 | |
82 | 82 | //if everything fails.. |
83 | - $this->_exit( false ); |
|
83 | + $this->_exit(false); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -94,21 +94,21 @@ discard block |
||
94 | 94 | function get_active_areas() { |
95 | 95 | $this->check_ajax_nonce(); |
96 | 96 | |
97 | - if( empty( $_POST['template_id'] ) ) { |
|
98 | - $this->_exit( false ); |
|
97 | + if (empty($_POST['template_id'])) { |
|
98 | + $this->_exit(false); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | ob_start(); |
102 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true ); |
|
102 | + do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true); |
|
103 | 103 | $response['directory'] = ob_get_clean(); |
104 | 104 | |
105 | 105 | ob_start(); |
106 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true ); |
|
106 | + do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true); |
|
107 | 107 | $response['single'] = ob_get_clean(); |
108 | 108 | |
109 | - $response = array_map( 'gravityview_strip_whitespace', $response ); |
|
109 | + $response = array_map('gravityview_strip_whitespace', $response); |
|
110 | 110 | |
111 | - $this->_exit( json_encode( $response ) ); |
|
111 | + $this->_exit(json_encode($response)); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -119,49 +119,49 @@ discard block |
||
119 | 119 | |
120 | 120 | $this->check_ajax_nonce(); |
121 | 121 | |
122 | - if( empty( $_POST['template_id'] ) ) { |
|
123 | - $this->_exit( false ); |
|
122 | + if (empty($_POST['template_id'])) { |
|
123 | + $this->_exit(false); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // get the fields xml config file for this specific preset |
127 | - $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] ); |
|
127 | + $preset_fields_path = apply_filters('gravityview_template_fieldsxml', array(), $_POST['template_id']); |
|
128 | 128 | // import fields |
129 | - if( !empty( $preset_fields_path ) ) { |
|
130 | - $presets = $this->import_fields( $preset_fields_path ); |
|
129 | + if (!empty($preset_fields_path)) { |
|
130 | + $presets = $this->import_fields($preset_fields_path); |
|
131 | 131 | } else { |
132 | - $presets = array( 'widgets' => array(), 'fields' => array() ); |
|
132 | + $presets = array('widgets' => array(), 'fields' => array()); |
|
133 | 133 | } |
134 | 134 | |
135 | - $template_id = esc_attr( $_POST['template_id'] ); |
|
135 | + $template_id = esc_attr($_POST['template_id']); |
|
136 | 136 | |
137 | 137 | // template areas |
138 | - $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
|
139 | - $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
138 | + $template_areas_directory = apply_filters('gravityview_template_active_areas', array(), $template_id, 'directory'); |
|
139 | + $template_areas_single = apply_filters('gravityview_template_active_areas', array(), $template_id, 'single'); |
|
140 | 140 | |
141 | 141 | // widget areas |
142 | 142 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
143 | 143 | |
144 | 144 | ob_start(); |
145 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] ); |
|
145 | + do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets']); |
|
146 | 146 | $response['header'] = ob_get_clean(); |
147 | 147 | |
148 | 148 | ob_start(); |
149 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] ); |
|
149 | + do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets']); |
|
150 | 150 | $response['footer'] = ob_get_clean(); |
151 | 151 | |
152 | 152 | ob_start(); |
153 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] ); |
|
153 | + do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields']); |
|
154 | 154 | $response['directory'] = ob_get_clean(); |
155 | 155 | |
156 | 156 | ob_start(); |
157 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] ); |
|
157 | + do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields']); |
|
158 | 158 | $response['single'] = ob_get_clean(); |
159 | 159 | |
160 | - $response = array_map( 'gravityview_strip_whitespace', $response ); |
|
160 | + $response = array_map('gravityview_strip_whitespace', $response); |
|
161 | 161 | |
162 | - do_action( 'gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response ); |
|
162 | + do_action('gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response); |
|
163 | 163 | |
164 | - $this->_exit( json_encode( $response ) ); |
|
164 | + $this->_exit(json_encode($response)); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -173,26 +173,26 @@ discard block |
||
173 | 173 | |
174 | 174 | $this->check_ajax_nonce(); |
175 | 175 | |
176 | - if( empty( $_POST['template_id'] ) ) { |
|
177 | - do_action( 'gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.' ); |
|
178 | - $this->_exit( false ); |
|
176 | + if (empty($_POST['template_id'])) { |
|
177 | + do_action('gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.'); |
|
178 | + $this->_exit(false); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | // get the xml for this specific template_id |
182 | - $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] ); |
|
182 | + $preset_form_xml_path = apply_filters('gravityview_template_formxml', '', $_POST['template_id']); |
|
183 | 183 | |
184 | 184 | // import form |
185 | - $form = $this->import_form( $preset_form_xml_path ); |
|
185 | + $form = $this->import_form($preset_form_xml_path); |
|
186 | 186 | |
187 | 187 | // get the form ID |
188 | - if( false === $form ) { |
|
188 | + if (false === $form) { |
|
189 | 189 | // send error to user |
190 | - do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int) $_POST['template_id'] ); |
|
190 | + do_action('gravityview_log_error', '[create_preset_form] Error importing form for template id: '.(int)$_POST['template_id']); |
|
191 | 191 | |
192 | - $this->_exit( false ); |
|
192 | + $this->_exit(false); |
|
193 | 193 | } |
194 | 194 | |
195 | - $this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' ); |
|
195 | + $this->_exit('<option value="'.esc_attr($form['id']).'" selected="selected">'.esc_html($form['title']).'</option>'); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
@@ -202,24 +202,24 @@ discard block |
||
202 | 202 | * @param string $xml_or_json_path Path to form XML or JSON file |
203 | 203 | * @return int|bool Imported form ID or false |
204 | 204 | */ |
205 | - function import_form( $xml_or_json_path = '' ) { |
|
205 | + function import_form($xml_or_json_path = '') { |
|
206 | 206 | |
207 | - do_action( 'gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path ); |
|
207 | + do_action('gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path); |
|
208 | 208 | |
209 | - if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) { |
|
210 | - do_action( 'gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path ); |
|
209 | + if (empty($xml_or_json_path) || !class_exists('GFExport') || !file_exists($xml_or_json_path)) { |
|
210 | + do_action('gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path); |
|
211 | 211 | return false; |
212 | 212 | } |
213 | 213 | |
214 | 214 | // import form |
215 | 215 | $forms = ''; |
216 | - $count = GFExport::import_file( $xml_or_json_path, $forms ); |
|
216 | + $count = GFExport::import_file($xml_or_json_path, $forms); |
|
217 | 217 | |
218 | - do_action( 'gravityview_log_debug', '[import_form] Importing form (Result)', $count ); |
|
219 | - do_action( 'gravityview_log_debug', '[import_form] Importing form (Form) ', $forms ); |
|
218 | + do_action('gravityview_log_debug', '[import_form] Importing form (Result)', $count); |
|
219 | + do_action('gravityview_log_debug', '[import_form] Importing form (Form) ', $forms); |
|
220 | 220 | |
221 | - if( $count != 1 || empty( $forms[0]['id'] ) ) { |
|
222 | - do_action( 'gravityview_log_error', '[import_form] Form Import Failed!' ); |
|
221 | + if ($count != 1 || empty($forms[0]['id'])) { |
|
222 | + do_action('gravityview_log_error', '[import_form] Form Import Failed!'); |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
@@ -238,26 +238,26 @@ discard block |
||
238 | 238 | function get_field_options() { |
239 | 239 | $this->check_ajax_nonce(); |
240 | 240 | |
241 | - if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) { |
|
242 | - do_action( 'gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ' ); |
|
243 | - $this->_exit( false ); |
|
241 | + if (empty($_POST['template']) || empty($_POST['area']) || empty($_POST['field_id']) || empty($_POST['field_type'])) { |
|
242 | + do_action('gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. '); |
|
243 | + $this->_exit(false); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // Fix apostrophes added by JSON response |
247 | - $_post = array_map( 'stripslashes_deep', $_POST ); |
|
247 | + $_post = array_map('stripslashes_deep', $_POST); |
|
248 | 248 | |
249 | 249 | // Sanitize |
250 | - $_post = array_map( 'esc_attr', $_post ); |
|
250 | + $_post = array_map('esc_attr', $_post); |
|
251 | 251 | |
252 | 252 | // The GF type of field: `product`, `name`, `creditcard`, `id`, `text` |
253 | - $input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL; |
|
254 | - $context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL; |
|
253 | + $input_type = isset($_post['input_type']) ? esc_attr($_post['input_type']) : NULL; |
|
254 | + $context = isset($_post['context']) ? esc_attr($_post['context']) : NULL; |
|
255 | 255 | |
256 | - $response = GravityView_Render_Settings::render_field_options( $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context ); |
|
256 | + $response = GravityView_Render_Settings::render_field_options($_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context); |
|
257 | 257 | |
258 | - $response = gravityview_strip_whitespace( $response ); |
|
258 | + $response = gravityview_strip_whitespace($response); |
|
259 | 259 | |
260 | - $this->_exit( $response ); |
|
260 | + $this->_exit($response); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -274,23 +274,23 @@ discard block |
||
274 | 274 | $form = ''; |
275 | 275 | |
276 | 276 | // if form id is set, use it, else, get form from preset |
277 | - if( !empty( $_POST['form_id'] ) ) { |
|
277 | + if (!empty($_POST['form_id'])) { |
|
278 | 278 | |
279 | - $form = (int) $_POST['form_id']; |
|
279 | + $form = (int)$_POST['form_id']; |
|
280 | 280 | |
281 | 281 | } |
282 | 282 | // get form from preset |
283 | - elseif( !empty( $_POST['template_id'] ) ) { |
|
283 | + elseif (!empty($_POST['template_id'])) { |
|
284 | 284 | |
285 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
285 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
286 | 286 | |
287 | 287 | } |
288 | 288 | |
289 | - $response = gravityview_get_sortable_fields( $form ); |
|
289 | + $response = gravityview_get_sortable_fields($form); |
|
290 | 290 | |
291 | - $response = gravityview_strip_whitespace( $response ); |
|
291 | + $response = gravityview_strip_whitespace($response); |
|
292 | 292 | |
293 | - $this->_exit( $response ); |
|
293 | + $this->_exit($response); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -298,35 +298,35 @@ discard block |
||
298 | 298 | * @param string $template_id Preset template |
299 | 299 | * |
300 | 300 | */ |
301 | - static function pre_get_form_fields( $template_id = '') { |
|
301 | + static function pre_get_form_fields($template_id = '') { |
|
302 | 302 | |
303 | - if( empty( $template_id ) ) { |
|
304 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Template ID not set.' ); |
|
303 | + if (empty($template_id)) { |
|
304 | + do_action('gravityview_log_error', __METHOD__.' - Template ID not set.'); |
|
305 | 305 | return false; |
306 | 306 | } else { |
307 | - $form_file = apply_filters( 'gravityview_template_formxml', '', $template_id ); |
|
308 | - if( !file_exists( $form_file ) ) { |
|
309 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset ['. $template_id .']. File not found. file: ' . $form_file ); |
|
307 | + $form_file = apply_filters('gravityview_template_formxml', '', $template_id); |
|
308 | + if (!file_exists($form_file)) { |
|
309 | + do_action('gravityview_log_error', __METHOD__.' - Importing Form Fields for preset ['.$template_id.']. File not found. file: '.$form_file); |
|
310 | 310 | return false; |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | // Load xml parser (from GravityForms) |
315 | - if( class_exists( 'GFCommon' ) ) { |
|
316 | - $xml_parser = GFCommon::get_base_path() . '/xml.php'; |
|
315 | + if (class_exists('GFCommon')) { |
|
316 | + $xml_parser = GFCommon::get_base_path().'/xml.php'; |
|
317 | 317 | } else { |
318 | - $xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php'; |
|
318 | + $xml_parser = trailingslashit(WP_PLUGIN_DIR).'gravityforms/xml.php'; |
|
319 | 319 | } |
320 | 320 | |
321 | - if( file_exists( $xml_parser ) ) { |
|
322 | - require_once( $xml_parser ); |
|
321 | + if (file_exists($xml_parser)) { |
|
322 | + require_once($xml_parser); |
|
323 | 323 | } else { |
324 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Gravity Forms XML Parser not found.', $xml_parser ); |
|
324 | + do_action('gravityview_log_debug', __METHOD__.' - Gravity Forms XML Parser not found.', $xml_parser); |
|
325 | 325 | return false; |
326 | 326 | } |
327 | 327 | |
328 | 328 | // load file |
329 | - $xmlstr = file_get_contents( $form_file ); |
|
329 | + $xmlstr = file_get_contents($form_file); |
|
330 | 330 | |
331 | 331 | $options = array( |
332 | 332 | "page" => array("unserialize_as_array" => true), |
@@ -345,21 +345,21 @@ discard block |
||
345 | 345 | $xml = new RGXML($options); |
346 | 346 | $forms = $xml->unserialize($xmlstr); |
347 | 347 | |
348 | - if( !$forms ) { |
|
349 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); |
|
348 | + if (!$forms) { |
|
349 | + do_action('gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. Error importing file. (File)', $form_file); |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
353 | + if (!empty($forms[0]) && is_array($forms[0])) { |
|
354 | 354 | $form = $forms[0]; |
355 | 355 | } |
356 | 356 | |
357 | - if( empty( $form ) ) { |
|
358 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
|
357 | + if (empty($form)) { |
|
358 | + do_action('gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms); |
|
359 | 359 | return false; |
360 | 360 | } |
361 | 361 | |
362 | - do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); |
|
362 | + do_action('gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. (Form)', $form); |
|
363 | 363 | |
364 | 364 | return $form; |
365 | 365 | |
@@ -371,46 +371,46 @@ discard block |
||
371 | 371 | * @param string $file path to file |
372 | 372 | * @return array Fields config array (unserialized) |
373 | 373 | */ |
374 | - function import_fields( $file ) { |
|
374 | + function import_fields($file) { |
|
375 | 375 | |
376 | - if( empty( $file ) || !file_exists( $file ) ) { |
|
377 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file ); |
|
376 | + if (empty($file) || !file_exists($file)) { |
|
377 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file); |
|
378 | 378 | return false; |
379 | 379 | } |
380 | 380 | |
381 | - if( !class_exists('WXR_Parser') ) { |
|
382 | - include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php'; |
|
381 | + if (!class_exists('WXR_Parser')) { |
|
382 | + include_once GRAVITYVIEW_DIR.'includes/lib/xml-parsers/parsers.php'; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | $parser = new WXR_Parser(); |
386 | - $presets = $parser->parse( $file ); |
|
386 | + $presets = $parser->parse($file); |
|
387 | 387 | |
388 | - if(is_wp_error( $presets )) { |
|
389 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets ); |
|
388 | + if (is_wp_error($presets)) { |
|
389 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets); |
|
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | |
393 | - if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) { |
|
394 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file ); |
|
393 | + if (empty($presets['posts'][0]['postmeta']) && !is_array($presets['posts'][0]['postmeta'])) { |
|
394 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file); |
|
395 | 395 | return false; |
396 | 396 | } |
397 | 397 | |
398 | - do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta'] ); |
|
398 | + do_action('gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta']); |
|
399 | 399 | |
400 | 400 | $fields = $widgets = array(); |
401 | - foreach( $presets['posts'][0]['postmeta'] as $meta ) { |
|
401 | + foreach ($presets['posts'][0]['postmeta'] as $meta) { |
|
402 | 402 | switch ($meta['key']) { |
403 | 403 | case '_gravityview_directory_fields': |
404 | - $fields = maybe_unserialize( $meta['value'] ); |
|
404 | + $fields = maybe_unserialize($meta['value']); |
|
405 | 405 | break; |
406 | 406 | case '_gravityview_directory_widgets': |
407 | - $widgets = maybe_unserialize( $meta['value'] ); |
|
407 | + $widgets = maybe_unserialize($meta['value']); |
|
408 | 408 | break; |
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
412 | - do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields ); |
|
413 | - do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets ); |
|
412 | + do_action('gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields); |
|
413 | + do_action('gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets); |
|
414 | 414 | |
415 | 415 | return array( |
416 | 416 | 'fields' => $fields, |
@@ -23,36 +23,36 @@ discard block |
||
23 | 23 | * @param boolean $force_show_label Whether to always show the label, regardless of field settings |
24 | 24 | * @return string |
25 | 25 | */ |
26 | - public static function field_label( $field, $entry = array(), $force_show_label = false ) { |
|
26 | + public static function field_label($field, $entry = array(), $force_show_label = false) { |
|
27 | 27 | $gravityview_view = GravityView_View::getInstance(); |
28 | 28 | |
29 | 29 | $form = $gravityview_view->getForm(); |
30 | 30 | |
31 | 31 | $label = ''; |
32 | 32 | |
33 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
33 | + if (!empty($field['show_label']) || $force_show_label) { |
|
34 | 34 | |
35 | 35 | $label = $field['label']; |
36 | 36 | |
37 | 37 | // Support Gravity Forms 1.9+ |
38 | - if( class_exists( 'GF_Field' ) ) { |
|
38 | + if (class_exists('GF_Field')) { |
|
39 | 39 | |
40 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
40 | + $field_object = RGFormsModel::get_field($form, $field['id']); |
|
41 | 41 | |
42 | - if( $field_object ) { |
|
42 | + if ($field_object) { |
|
43 | 43 | |
44 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
44 | + $input = GFFormsModel::get_input($field_object, $field['id']); |
|
45 | 45 | |
46 | 46 | // This is a complex field, with labels on a per-input basis |
47 | - if( $input ) { |
|
47 | + if ($input) { |
|
48 | 48 | |
49 | 49 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
50 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
50 | + $label = !empty($input['customLabel']) ? $input['customLabel'] : $input['label']; |
|
51 | 51 | |
52 | 52 | } else { |
53 | 53 | |
54 | 54 | // This is a field with one label |
55 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
55 | + $label = $field_object->get_field_label(true, $field['label']); |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
64 | - if ( !empty( $field['custom_label'] ) ) { |
|
64 | + if (!empty($field['custom_label'])) { |
|
65 | 65 | |
66 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
66 | + $label = self::replace_variables($field['custom_label'], $form, $entry); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param[in,out] string $appended_content Content you can add after a label. Empty by default. |
73 | 73 | * @param[in] array $field GravityView field array |
74 | 74 | */ |
75 | - $label .= apply_filters( 'gravityview_render_after_label', '', $field ); |
|
75 | + $label .= apply_filters('gravityview_render_after_label', '', $field); |
|
76 | 76 | |
77 | 77 | } // End $field['show_label'] |
78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param[in] array $form Gravity Forms form array |
85 | 85 | * @param[in] array $entry Gravity Forms entry array |
86 | 86 | */ |
87 | - $label = apply_filters( 'gravityview/template/field_label', $label, $field, $form, $entry ); |
|
87 | + $label = apply_filters('gravityview/template/field_label', $label, $field, $form, $entry); |
|
88 | 88 | |
89 | 89 | return $label; |
90 | 90 | } |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @param array $entry GF Entry array |
100 | 100 | * @return string Text with variables maybe replaced |
101 | 101 | */ |
102 | - public static function replace_variables($text, $form, $entry ) { |
|
103 | - return GravityView_Merge_Tags::replace_variables( $text, $form, $entry ); |
|
102 | + public static function replace_variables($text, $form, $entry) { |
|
103 | + return GravityView_Merge_Tags::replace_variables($text, $form, $entry); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -113,19 +113,19 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string|null If not empty, string in $format format. Otherwise, null. |
115 | 115 | */ |
116 | - public static function field_width( $field, $format = '%d%%' ) { |
|
116 | + public static function field_width($field, $format = '%d%%') { |
|
117 | 117 | |
118 | 118 | $width = NULL; |
119 | 119 | |
120 | - if( !empty( $field['width'] ) ) { |
|
121 | - $width = absint( $field['width'] ); |
|
120 | + if (!empty($field['width'])) { |
|
121 | + $width = absint($field['width']); |
|
122 | 122 | |
123 | 123 | // If using percentages, limit to 100% |
124 | - if( '%d%%' === $format && $width > 100 ) { |
|
124 | + if ('%d%%' === $format && $width > 100) { |
|
125 | 125 | $width = 100; |
126 | 126 | } |
127 | 127 | |
128 | - $width = sprintf( $format, $width ); |
|
128 | + $width = sprintf($format, $width); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | return $width; |
@@ -139,38 +139,38 @@ discard block |
||
139 | 139 | * @param mixed $field |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - public static function field_class( $field, $form = NULL, $entry = NULL ) { |
|
142 | + public static function field_class($field, $form = NULL, $entry = NULL) { |
|
143 | 143 | $gravityview_view = GravityView_View::getInstance(); |
144 | 144 | |
145 | 145 | $classes = array(); |
146 | 146 | |
147 | - if( !empty( $field['custom_class'] ) ) { |
|
147 | + if (!empty($field['custom_class'])) { |
|
148 | 148 | |
149 | 149 | $custom_class = $field['custom_class']; |
150 | 150 | |
151 | - if( !empty( $entry ) ) { |
|
151 | + if (!empty($entry)) { |
|
152 | 152 | |
153 | 153 | // We want the merge tag to be formatted as a class. The merge tag may be |
154 | 154 | // replaced by a multiple-word value that should be output as a single class. |
155 | 155 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
156 | 156 | add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
157 | 157 | |
158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
158 | + $custom_class = self::replace_variables($custom_class, $form, $entry); |
|
159 | 159 | |
160 | 160 | // And then we want life to return to normal |
161 | 161 | remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
162 | 162 | } |
163 | 163 | |
164 | 164 | // And now we want the spaces to be handled nicely. |
165 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
165 | + $classes[] = gravityview_sanitize_html_class($custom_class); |
|
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | - if(!empty($field['id'])) { |
|
170 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
169 | + if (!empty($field['id'])) { |
|
170 | + if (!empty($form) && !empty($form['id'])) { |
|
171 | 171 | $form_id = '-'.$form['id']; |
172 | 172 | } else { |
173 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
173 | + $form_id = $gravityview_view->getFormId() ? '-'.$gravityview_view->getFormId() : ''; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
@@ -191,21 +191,21 @@ discard block |
||
191 | 191 | * @param array $entry Gravity Forms entry array |
192 | 192 | * @return string Sanitized unique HTML `id` attribute for the field |
193 | 193 | */ |
194 | - public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
|
194 | + public static function field_html_attr_id($field, $form = array(), $entry = array()) { |
|
195 | 195 | $gravityview_view = GravityView_View::getInstance(); |
196 | 196 | $id = $field['id']; |
197 | 197 | |
198 | - if ( ! empty( $id ) ) { |
|
199 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
200 | - $form_id = '-' . $form['id']; |
|
198 | + if (!empty($id)) { |
|
199 | + if (!empty($form) && !empty($form['id'])) { |
|
200 | + $form_id = '-'.$form['id']; |
|
201 | 201 | } else { |
202 | - $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
202 | + $form_id = $gravityview_view->getFormId() ? '-'.$gravityview_view->getFormId() : ''; |
|
203 | 203 | } |
204 | 204 | |
205 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
205 | + $id = 'gv-field'.$form_id.'-'.$field['id']; |
|
206 | 206 | } |
207 | 207 | |
208 | - return esc_attr( $id ); |
|
208 | + return esc_attr($id); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | * @param integer $field |
218 | 218 | * @return null|string |
219 | 219 | */ |
220 | - public static function field_value( $entry, $field_settings, $format = 'html' ) { |
|
220 | + public static function field_value($entry, $field_settings, $format = 'html') { |
|
221 | 221 | |
222 | - if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
222 | + if (empty($entry['form_id']) || empty($field_settings['id'])) { |
|
223 | 223 | return NULL; |
224 | 224 | } |
225 | 225 | |
226 | 226 | $gravityview_view = GravityView_View::getInstance(); |
227 | 227 | |
228 | - if( class_exists( 'GFCache' ) ) { |
|
228 | + if (class_exists('GFCache')) { |
|
229 | 229 | /** |
230 | 230 | * Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run. |
231 | 231 | * |
@@ -240,18 +240,18 @@ discard block |
||
240 | 240 | * @param boolean false Tell Gravity Forms not to store this as a transient |
241 | 241 | * @param int 0 Time to store the value. 0 is maximum amount of time possible. |
242 | 242 | */ |
243 | - GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0 ); |
|
243 | + GFCache::set("GFFormsModel::get_lead_field_value_".$entry["id"]."_".$field_settings["id"], false, false, 0); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | $field_id = $field_settings['id']; |
247 | 247 | |
248 | 248 | $form = $gravityview_view->getForm(); |
249 | 249 | |
250 | - $field = gravityview_get_field( $form, $field_id ); |
|
250 | + $field = gravityview_get_field($form, $field_id); |
|
251 | 251 | |
252 | 252 | $field_type = RGFormsModel::get_input_type($field); |
253 | 253 | |
254 | - if( $field_type ) { |
|
254 | + if ($field_type) { |
|
255 | 255 | $field_type = $field['type']; |
256 | 256 | $value = RGFormsModel::get_lead_field_value($entry, $field); |
257 | 257 | } else { |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | |
267 | 267 | $display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format); |
268 | 268 | |
269 | - if( $errors = ob_get_clean() ) { |
|
270 | - do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors ); |
|
269 | + if ($errors = ob_get_clean()) { |
|
270 | + do_action('gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form); |
274 | 274 | |
275 | 275 | // prevent the use of merge_tags for non-admin fields |
276 | - if( !empty( $field['adminOnly'] ) ) { |
|
277 | - $display_value = self::replace_variables( $display_value, $form, $entry ); |
|
276 | + if (!empty($field['adminOnly'])) { |
|
277 | + $display_value = self::replace_variables($display_value, $form, $entry); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | // Check whether the field exists in /includes/fields/{$field_type}.php |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $field_exists = $gravityview_view->locate_template("fields/{$field_type}.php"); |
283 | 283 | |
284 | 284 | // Set the field data to be available in the templates |
285 | - $gravityview_view->setCurrentField( array( |
|
285 | + $gravityview_view->setCurrentField(array( |
|
286 | 286 | 'form' => $form, |
287 | 287 | 'field_id' => $field_id, |
288 | 288 | 'field' => $field, |
@@ -294,13 +294,13 @@ discard block |
||
294 | 294 | 'field_type' => $field_type, /** {@since 1.6} **/ |
295 | 295 | )); |
296 | 296 | |
297 | - if( $field_exists ) { |
|
297 | + if ($field_exists) { |
|
298 | 298 | |
299 | - do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_exists ) ); |
|
299 | + do_action('gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_exists)); |
|
300 | 300 | |
301 | 301 | ob_start(); |
302 | 302 | |
303 | - load_template( $field_exists, false ); |
|
303 | + load_template($field_exists, false); |
|
304 | 304 | |
305 | 305 | $output = ob_get_clean(); |
306 | 306 | |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example. |
320 | 320 | * |
321 | 321 | */ |
322 | - if( !empty( $field_settings['show_as_link'] ) ) { |
|
322 | + if (!empty($field_settings['show_as_link'])) { |
|
323 | 323 | |
324 | - $link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' ); |
|
324 | + $link_atts = empty($field_settings['new_window']) ? array() : array('target' => '_blank'); |
|
325 | 325 | |
326 | - $output = self::entry_link_html( $entry, $output, $link_atts, $field_settings ); |
|
326 | + $output = self::entry_link_html($entry, $output, $link_atts, $field_settings); |
|
327 | 327 | |
328 | 328 | } |
329 | 329 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param array $entry The GF entry array |
335 | 335 | * @param array $field_settings Settings for the particular GV field |
336 | 336 | */ |
337 | - $output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
337 | + $output = apply_filters('gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField()); |
|
338 | 338 | |
339 | 339 | /** |
340 | 340 | * @filter `gravityview_field_entry_value` Modify the field value output for all field types |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param array $field_settings Settings for the particular GV field |
344 | 344 | * @param array $field_data {@since 1.6} |
345 | 345 | */ |
346 | - $output = apply_filters( 'gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
346 | + $output = apply_filters('gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField()); |
|
347 | 347 | |
348 | 348 | return $output; |
349 | 349 | } |
@@ -357,18 +357,18 @@ discard block |
||
357 | 357 | * @param array $entry Gravity Forms entry array |
358 | 358 | * @param array $field_settings Array of field settings. Optional, but passed to the `gravityview_field_entry_link` filter |
359 | 359 | */ |
360 | - public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) { |
|
360 | + public static function entry_link_html($entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array()) { |
|
361 | 361 | |
362 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
362 | + if (empty($entry) || !is_array($entry) || !isset($entry['id'])) { |
|
363 | 363 | |
364 | - do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry ); |
|
364 | + do_action('gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry); |
|
365 | 365 | |
366 | 366 | return NULL; |
367 | 367 | } |
368 | 368 | |
369 | - $href = self::entry_link( $entry ); |
|
369 | + $href = self::entry_link($entry); |
|
370 | 370 | |
371 | - $link = gravityview_get_link( $href, $anchor_text, $passed_tag_atts ); |
|
371 | + $link = gravityview_get_link($href, $anchor_text, $passed_tag_atts); |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * @filter `gravityview_field_entry_link` Modify the link HTML |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * @param array $entry The GF entry array |
378 | 378 | * @param array $field_settings Settings for the particular GV field |
379 | 379 | */ |
380 | - $output = apply_filters( 'gravityview_field_entry_link', $link, $href, $entry, $field_settings ); |
|
380 | + $output = apply_filters('gravityview_field_entry_link', $link, $href, $entry, $field_settings); |
|
381 | 381 | |
382 | 382 | return $output; |
383 | 383 | } |
@@ -392,11 +392,11 @@ discard block |
||
392 | 392 | |
393 | 393 | $is_search = false; |
394 | 394 | |
395 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
395 | + if ($gravityview_view && ($gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search)) { |
|
396 | 396 | $is_search = true; |
397 | 397 | } |
398 | 398 | |
399 | - if($is_search) { |
|
399 | + if ($is_search) { |
|
400 | 400 | $output = __('This search returned no results.', 'gravityview'); |
401 | 401 | } else { |
402 | 402 | $output = __('No entries match your request.', 'gravityview'); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @param string $output The existing "No Entries" text |
408 | 408 | * @param boolean $is_search Is the current page a search result, or just a multiple entries screen? |
409 | 409 | */ |
410 | - $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search); |
|
410 | + $output = apply_filters('gravitview_no_entries_text', $output, $is_search); |
|
411 | 411 | |
412 | 412 | return $wpautop ? wpautop($output) : $output; |
413 | 413 | } |
@@ -421,42 +421,42 @@ discard block |
||
421 | 421 | * @param boolean $add_query_args Add pagination and sorting arguments |
422 | 422 | * @return string Permalink to multiple entries view |
423 | 423 | */ |
424 | - public static function directory_link( $post_id = NULL, $add_query_args = true ) { |
|
424 | + public static function directory_link($post_id = NULL, $add_query_args = true) { |
|
425 | 425 | global $post; |
426 | 426 | |
427 | 427 | $gravityview_view = GravityView_View::getInstance(); |
428 | 428 | |
429 | - if( empty( $post_id ) ) { |
|
429 | + if (empty($post_id)) { |
|
430 | 430 | |
431 | 431 | $post_id = false; |
432 | 432 | |
433 | 433 | // DataTables passes the Post ID |
434 | - if( defined('DOING_AJAX') && DOING_AJAX ) { |
|
434 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
435 | 435 | |
436 | - $post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false; |
|
436 | + $post_id = isset($_POST['post_id']) ? (int)$_POST['post_id'] : false; |
|
437 | 437 | |
438 | 438 | } else { |
439 | 439 | |
440 | 440 | // The Post ID has been passed via the shortcode |
441 | - if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
441 | + if (!empty($gravityview_view) && $gravityview_view->getPostId()) { |
|
442 | 442 | |
443 | 443 | $post_id = $gravityview_view->getPostId(); |
444 | 444 | |
445 | 445 | } else { |
446 | 446 | |
447 | 447 | // This is a GravityView post type |
448 | - if( GravityView_frontend::getInstance()->is_gravityview_post_type ) { |
|
448 | + if (GravityView_frontend::getInstance()->is_gravityview_post_type) { |
|
449 | 449 | |
450 | - $post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID; |
|
450 | + $post_id = isset($gravityview_view) ? $gravityview_view->getViewId() : $post->ID; |
|
451 | 451 | |
452 | 452 | } else { |
453 | 453 | |
454 | 454 | // This is an embedded GravityView; use the embedded post's ID as the base. |
455 | - if( GravityView_frontend::getInstance()->post_has_shortcode && is_a( $post, 'WP_Post' ) ) { |
|
455 | + if (GravityView_frontend::getInstance()->post_has_shortcode && is_a($post, 'WP_Post')) { |
|
456 | 456 | |
457 | 457 | $post_id = $post->ID; |
458 | 458 | |
459 | - } elseif( $gravityview_view->getViewId() ) { |
|
459 | + } elseif ($gravityview_view->getViewId()) { |
|
460 | 460 | |
461 | 461 | // The GravityView has been embedded in a widget or in a template, and |
462 | 462 | // is not in the current content. Thus, we defer to the View's own ID. |
@@ -471,39 +471,39 @@ discard block |
||
471 | 471 | } |
472 | 472 | |
473 | 473 | // No post ID, get outta here. |
474 | - if( empty( $post_id ) ) { |
|
474 | + if (empty($post_id)) { |
|
475 | 475 | return NULL; |
476 | 476 | } |
477 | 477 | |
478 | 478 | // If we've saved the permalink in memory, use it |
479 | 479 | // @since 1.3 |
480 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
480 | + $link = wp_cache_get('gv_directory_link_'.$post_id); |
|
481 | 481 | |
482 | - if( empty( $link ) ) { |
|
482 | + if (empty($link)) { |
|
483 | 483 | |
484 | - $link = get_permalink( $post_id ); |
|
484 | + $link = get_permalink($post_id); |
|
485 | 485 | |
486 | 486 | // If not yet saved, cache the permalink. |
487 | 487 | // @since 1.3 |
488 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
488 | + wp_cache_set('gv_directory_link_'.$post_id, $link); |
|
489 | 489 | |
490 | 490 | } |
491 | 491 | |
492 | 492 | // Deal with returning to proper pagination for embedded views |
493 | - if( $link && $add_query_args ) { |
|
493 | + if ($link && $add_query_args) { |
|
494 | 494 | |
495 | 495 | $args = array(); |
496 | 496 | |
497 | - if( $pagenum = rgget('pagenum') ) { |
|
498 | - $args['pagenum'] = intval( $pagenum ); |
|
497 | + if ($pagenum = rgget('pagenum')) { |
|
498 | + $args['pagenum'] = intval($pagenum); |
|
499 | 499 | } |
500 | 500 | |
501 | - if( $sort = rgget('sort') ) { |
|
501 | + if ($sort = rgget('sort')) { |
|
502 | 502 | $args['sort'] = $sort; |
503 | 503 | $args['dir'] = rgget('dir'); |
504 | 504 | } |
505 | 505 | |
506 | - $link = add_query_arg( $args, $link ); |
|
506 | + $link = add_query_arg($args, $link); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | return $link; |
@@ -520,10 +520,10 @@ discard block |
||
520 | 520 | * @param array $entry Entry data passed to provide additional information when generating the hash. Optional - don't rely on it being available. |
521 | 521 | * @return string Hashed unique value for entry |
522 | 522 | */ |
523 | - private static function get_custom_entry_slug( $id, $entry = array() ) { |
|
523 | + private static function get_custom_entry_slug($id, $entry = array()) { |
|
524 | 524 | |
525 | 525 | // Generate an unique hash to use as the default value |
526 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
526 | + $slug = substr(wp_hash($id, 'gravityview'.$id), 0, 8); |
|
527 | 527 | |
528 | 528 | /** |
529 | 529 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -531,14 +531,14 @@ discard block |
||
531 | 531 | * @param string $id The entry ID |
532 | 532 | * @param array $entry Entry data array. May be empty. |
533 | 533 | */ |
534 | - $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
|
534 | + $slug = apply_filters('gravityview_entry_slug', $slug, $id, $entry); |
|
535 | 535 | |
536 | 536 | // Make sure we have something - use the original ID as backup. |
537 | - if( empty( $slug ) ) { |
|
537 | + if (empty($slug)) { |
|
538 | 538 | $slug = $id; |
539 | 539 | } |
540 | 540 | |
541 | - return sanitize_title( $slug ); |
|
541 | + return sanitize_title($slug); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * @param array $entry Gravity Forms Entry array, optional. Used only to provide data to customize the `gravityview_entry_slug` filter |
553 | 553 | * @return string Unique slug ID, passed through `sanitize_title()` |
554 | 554 | */ |
555 | - public static function get_entry_slug( $id_or_string, $entry = array() ) { |
|
555 | + public static function get_entry_slug($id_or_string, $entry = array()) { |
|
556 | 556 | |
557 | 557 | /** |
558 | 558 | * Default: use the entry ID as the unique identifier |
@@ -563,32 +563,32 @@ discard block |
||
563 | 563 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
564 | 564 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
565 | 565 | */ |
566 | - $custom = apply_filters('gravityview_custom_entry_slug', false ); |
|
566 | + $custom = apply_filters('gravityview_custom_entry_slug', false); |
|
567 | 567 | |
568 | 568 | // If we're using custom slug... |
569 | - if ( $custom ) { |
|
569 | + if ($custom) { |
|
570 | 570 | |
571 | 571 | // Get the entry hash |
572 | - $hash = self::get_custom_entry_slug( $id_or_string, $entry ); |
|
572 | + $hash = self::get_custom_entry_slug($id_or_string, $entry); |
|
573 | 573 | |
574 | 574 | // See if the entry already has a hash set |
575 | - $value = gform_get_meta( $id_or_string, 'gravityview_unique_id' ); |
|
575 | + $value = gform_get_meta($id_or_string, 'gravityview_unique_id'); |
|
576 | 576 | |
577 | 577 | // If it does have a hash set, and the hash is expected, use it. |
578 | 578 | // This check allows users to change the hash structure using the |
579 | 579 | // gravityview_entry_hash filter and have the old hashes expire. |
580 | - if( empty( $value ) || $value !== $hash ) { |
|
580 | + if (empty($value) || $value !== $hash) { |
|
581 | 581 | |
582 | - gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash ); |
|
582 | + gform_update_meta($id_or_string, 'gravityview_unique_id', $hash); |
|
583 | 583 | |
584 | 584 | } |
585 | 585 | |
586 | 586 | $slug = $hash; |
587 | 587 | |
588 | - unset( $value, $hash ); |
|
588 | + unset($value, $hash); |
|
589 | 589 | } |
590 | 590 | |
591 | - return sanitize_title( $slug ); |
|
591 | + return sanitize_title($slug); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -599,18 +599,18 @@ discard block |
||
599 | 599 | * @param $entry array Gravity Forms entry object |
600 | 600 | * @param $form array Gravity Forms form object |
601 | 601 | */ |
602 | - public static function entry_create_custom_slug( $entry, $form ) { |
|
602 | + public static function entry_create_custom_slug($entry, $form) { |
|
603 | 603 | /** |
604 | 604 | * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta |
605 | 605 | * @param boolean $custom Should we process the custom entry slug? |
606 | 606 | */ |
607 | - $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
608 | - if( $custom ) { |
|
607 | + $custom = apply_filters('gravityview_custom_entry_slug', false); |
|
608 | + if ($custom) { |
|
609 | 609 | // create the gravityview_unique_id and save it |
610 | 610 | |
611 | 611 | // Get the entry hash |
612 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
613 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
612 | + $hash = self::get_custom_entry_slug($entry['id'], $entry); |
|
613 | + gform_update_meta($entry['id'], 'gravityview_unique_id', $hash); |
|
614 | 614 | |
615 | 615 | } |
616 | 616 | } |
@@ -625,55 +625,55 @@ discard block |
||
625 | 625 | * @param boolean $add_directory_args True: Add args to help return to directory; False: only include args required to get to entry {@since 1.7.3} |
626 | 626 | * @return string Link to the entry with the directory parent slug |
627 | 627 | */ |
628 | - public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) { |
|
628 | + public static function entry_link($entry, $post_id = NULL, $add_directory_args = true) { |
|
629 | 629 | |
630 | - if( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
631 | - $entry = GVCommon::get_entry( $entry ); |
|
632 | - } else if( empty( $entry ) ) { |
|
630 | + if (!empty($entry) && !is_array($entry)) { |
|
631 | + $entry = GVCommon::get_entry($entry); |
|
632 | + } else if (empty($entry)) { |
|
633 | 633 | $entry = GravityView_frontend::getInstance()->getEntry(); |
634 | 634 | } |
635 | 635 | |
636 | 636 | // Second parameter used to be passed as $field; this makes sure it's not an array |
637 | - if( !is_numeric( $post_id ) ) { |
|
637 | + if (!is_numeric($post_id)) { |
|
638 | 638 | $post_id = NULL; |
639 | 639 | } |
640 | 640 | |
641 | 641 | // Get the permalink to the View |
642 | - $directory_link = self::directory_link( $post_id, false ); |
|
642 | + $directory_link = self::directory_link($post_id, false); |
|
643 | 643 | |
644 | 644 | // No post ID? Get outta here. |
645 | - if( empty( $directory_link ) ) { |
|
645 | + if (empty($directory_link)) { |
|
646 | 646 | return ''; |
647 | 647 | } |
648 | 648 | |
649 | 649 | $query_arg_name = GravityView_Post_Types::get_entry_var_name(); |
650 | 650 | |
651 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
651 | + $entry_slug = self::get_entry_slug($entry['id'], $entry); |
|
652 | 652 | |
653 | - if( get_option('permalink_structure') && !is_preview() ) { |
|
653 | + if (get_option('permalink_structure') && !is_preview()) { |
|
654 | 654 | |
655 | 655 | $args = array(); |
656 | 656 | |
657 | - $directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/'. $entry_slug .'/'; |
|
657 | + $directory_link = trailingslashit($directory_link).$query_arg_name.'/'.$entry_slug.'/'; |
|
658 | 658 | |
659 | 659 | } else { |
660 | 660 | |
661 | - $args = array( $query_arg_name => $entry_slug ); |
|
661 | + $args = array($query_arg_name => $entry_slug); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
665 | 665 | * @since 1.7.3 |
666 | 666 | */ |
667 | - if( $add_directory_args ) { |
|
667 | + if ($add_directory_args) { |
|
668 | 668 | |
669 | - if( !empty( $_GET['pagenum'] ) ) { |
|
670 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
669 | + if (!empty($_GET['pagenum'])) { |
|
670 | + $args['pagenum'] = intval($_GET['pagenum']); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
674 | 674 | * @since 1.7 |
675 | 675 | */ |
676 | - if( $sort = rgget('sort') ) { |
|
676 | + if ($sort = rgget('sort')) { |
|
677 | 677 | $args['sort'] = $sort; |
678 | 678 | $args['dir'] = rgget('dir'); |
679 | 679 | } |
@@ -685,11 +685,11 @@ discard block |
||
685 | 685 | * has the view id so that Advanced Filters can be applied correctly when rendering the single view |
686 | 686 | * @see GravityView_frontend::get_context_view_id() |
687 | 687 | */ |
688 | - if( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
|
688 | + if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views()) { |
|
689 | 689 | $args['gvid'] = gravityview_get_view_id(); |
690 | 690 | } |
691 | 691 | |
692 | - return add_query_arg( $args, $directory_link ); |
|
692 | + return add_query_arg($args, $directory_link); |
|
693 | 693 | |
694 | 694 | } |
695 | 695 | |
@@ -699,54 +699,54 @@ discard block |
||
699 | 699 | |
700 | 700 | // inside loop functions |
701 | 701 | |
702 | -function gv_label( $field, $entry = NULL ) { |
|
703 | - return GravityView_API::field_label( $field, $entry ); |
|
702 | +function gv_label($field, $entry = NULL) { |
|
703 | + return GravityView_API::field_label($field, $entry); |
|
704 | 704 | } |
705 | 705 | |
706 | -function gv_class( $field, $form = NULL, $entry = array() ) { |
|
707 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
706 | +function gv_class($field, $form = NULL, $entry = array()) { |
|
707 | + return GravityView_API::field_class($field, $form, $entry); |
|
708 | 708 | } |
709 | 709 | |
710 | -function gv_container_class( $class = '' ) { |
|
710 | +function gv_container_class($class = '') { |
|
711 | 711 | |
712 | 712 | $default = ' gv-container'; |
713 | 713 | |
714 | - if( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
714 | + if (GravityView_View::getInstance()->isHideUntilSearched()) { |
|
715 | 715 | $default .= ' hidden'; |
716 | 716 | } |
717 | 717 | |
718 | - $class = apply_filters( 'gravityview/render/container/class', $class . $default ); |
|
718 | + $class = apply_filters('gravityview/render/container/class', $class.$default); |
|
719 | 719 | |
720 | - $class = gravityview_sanitize_html_class( $class ); |
|
720 | + $class = gravityview_sanitize_html_class($class); |
|
721 | 721 | |
722 | 722 | echo $class; |
723 | 723 | } |
724 | 724 | |
725 | -function gv_value( $entry, $field ) { |
|
725 | +function gv_value($entry, $field) { |
|
726 | 726 | |
727 | - $value = GravityView_API::field_value( $entry, $field ); |
|
727 | + $value = GravityView_API::field_value($entry, $field); |
|
728 | 728 | |
729 | - if( $value === '') { |
|
729 | + if ($value === '') { |
|
730 | 730 | /** |
731 | 731 | * @filter `gravityview_empty_value` What to display when a field is empty |
732 | 732 | * @param string $value (empty string) |
733 | 733 | */ |
734 | - $value = apply_filters( 'gravityview_empty_value', '' ); |
|
734 | + $value = apply_filters('gravityview_empty_value', ''); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | return $value; |
738 | 738 | } |
739 | 739 | |
740 | -function gv_directory_link( $post = NULL, $add_pagination = true ) { |
|
741 | - return GravityView_API::directory_link( $post, $add_pagination ); |
|
740 | +function gv_directory_link($post = NULL, $add_pagination = true) { |
|
741 | + return GravityView_API::directory_link($post, $add_pagination); |
|
742 | 742 | } |
743 | 743 | |
744 | -function gv_entry_link( $entry, $post_id = NULL ) { |
|
745 | - return GravityView_API::entry_link( $entry, $post_id ); |
|
744 | +function gv_entry_link($entry, $post_id = NULL) { |
|
745 | + return GravityView_API::entry_link($entry, $post_id); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | function gv_no_results($wpautop = true) { |
749 | - return GravityView_API::no_results( $wpautop ); |
|
749 | + return GravityView_API::no_results($wpautop); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | /** |
@@ -758,21 +758,21 @@ discard block |
||
758 | 758 | |
759 | 759 | $href = gv_directory_link(); |
760 | 760 | |
761 | - if( empty( $href ) ) { return NULL; } |
|
761 | + if (empty($href)) { return NULL; } |
|
762 | 762 | |
763 | 763 | // calculate link label |
764 | 764 | $gravityview_view = GravityView_View::getInstance(); |
765 | 765 | |
766 | - $label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __( '← Go back', 'gravityview' ); |
|
766 | + $label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __('← Go back', 'gravityview'); |
|
767 | 767 | |
768 | 768 | /** |
769 | 769 | * @filter `gravityview_go_back_label` Modify the back link text |
770 | 770 | * @since 1.0.9 |
771 | 771 | * @param string $label Existing label text |
772 | 772 | */ |
773 | - $label = apply_filters( 'gravityview_go_back_label', $label ); |
|
773 | + $label = apply_filters('gravityview_go_back_label', $label); |
|
774 | 774 | |
775 | - $link = gravityview_get_link( $href, esc_html( $label ), array( |
|
775 | + $link = gravityview_get_link($href, esc_html($label), array( |
|
776 | 776 | 'data-viewid' => $gravityview_view->getViewId() |
777 | 777 | )); |
778 | 778 | |
@@ -791,9 +791,9 @@ discard block |
||
791 | 791 | * @param string $display_value The value generated by Gravity Forms |
792 | 792 | * @return string Value |
793 | 793 | */ |
794 | -function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
|
794 | +function gravityview_get_field_value($entry, $field_id, $display_value) { |
|
795 | 795 | |
796 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
796 | + if (floatval($field_id) === floor(floatval($field_id))) { |
|
797 | 797 | |
798 | 798 | // For the complete field value as generated by Gravity Forms |
799 | 799 | return $display_value; |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | } else { |
802 | 802 | |
803 | 803 | // For one part of the address (City, ZIP, etc.) |
804 | - return isset( $entry[ $field_id ] ) ? $entry[ $field_id ] : ''; |
|
804 | + return isset($entry[$field_id]) ? $entry[$field_id] : ''; |
|
805 | 805 | |
806 | 806 | } |
807 | 807 | |
@@ -817,48 +817,48 @@ discard block |
||
817 | 817 | * @param string $taxonomy Type of term (`post_tag` or `category`) |
818 | 818 | * @return string CSV of linked terms |
819 | 819 | */ |
820 | -function gravityview_convert_value_to_term_list( $value, $taxonomy = 'post_tag' ) { |
|
820 | +function gravityview_convert_value_to_term_list($value, $taxonomy = 'post_tag') { |
|
821 | 821 | |
822 | 822 | $output = array(); |
823 | 823 | |
824 | - $terms = explode( ', ', $value ); |
|
824 | + $terms = explode(', ', $value); |
|
825 | 825 | |
826 | - foreach ($terms as $term_name ) { |
|
826 | + foreach ($terms as $term_name) { |
|
827 | 827 | |
828 | 828 | // If we're processing a category, |
829 | - if( $taxonomy === 'category' ) { |
|
829 | + if ($taxonomy === 'category') { |
|
830 | 830 | |
831 | 831 | // Use rgexplode to prevent errors if : doesn't exist |
832 | - list( $term_name, $term_id ) = rgexplode( ':', $value, 2 ); |
|
832 | + list($term_name, $term_id) = rgexplode(':', $value, 2); |
|
833 | 833 | |
834 | 834 | // The explode was succesful; we have the category ID |
835 | - if( !empty( $term_id )) { |
|
836 | - $term = get_term_by( 'id', $term_id, $taxonomy ); |
|
835 | + if (!empty($term_id)) { |
|
836 | + $term = get_term_by('id', $term_id, $taxonomy); |
|
837 | 837 | } else { |
838 | 838 | // We have to fall back to the name |
839 | - $term = get_term_by( 'name', $term_name, $taxonomy ); |
|
839 | + $term = get_term_by('name', $term_name, $taxonomy); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | } else { |
843 | 843 | // Use the name of the tag to get the full term information |
844 | - $term = get_term_by( 'name', $term_name, $taxonomy ); |
|
844 | + $term = get_term_by('name', $term_name, $taxonomy); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | // There's still a tag/category here. |
848 | - if( $term ) { |
|
848 | + if ($term) { |
|
849 | 849 | |
850 | - $term_link = get_term_link( $term, $taxonomy ); |
|
850 | + $term_link = get_term_link($term, $taxonomy); |
|
851 | 851 | |
852 | 852 | // If there was an error, continue to the next term. |
853 | - if ( is_wp_error( $term_link ) ) { |
|
853 | + if (is_wp_error($term_link)) { |
|
854 | 854 | continue; |
855 | 855 | } |
856 | 856 | |
857 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
857 | + $output[] = gravityview_get_link($term_link, esc_html($term->name)); |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | |
861 | - return implode(', ', $output ); |
|
861 | + return implode(', ', $output); |
|
862 | 862 | } |
863 | 863 | |
864 | 864 | /** |
@@ -868,12 +868,12 @@ discard block |
||
868 | 868 | * @param string $taxonomy Taxonomy of term to fetch. |
869 | 869 | * @return string String with terms |
870 | 870 | */ |
871 | -function gravityview_get_the_term_list( $post_id, $link = true, $taxonomy = 'post_tag' ) { |
|
871 | +function gravityview_get_the_term_list($post_id, $link = true, $taxonomy = 'post_tag') { |
|
872 | 872 | |
873 | - $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
|
873 | + $output = get_the_term_list($post_id, $taxonomy, NULL, ', '); |
|
874 | 874 | |
875 | - if( empty( $link ) ) { |
|
876 | - return strip_tags( $output); |
|
875 | + if (empty($link)) { |
|
876 | + return strip_tags($output); |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | return $output; |
@@ -892,17 +892,17 @@ discard block |
||
892 | 892 | $fe = GravityView_frontend::getInstance(); |
893 | 893 | |
894 | 894 | // Solve problem when loading content via admin-ajax.php |
895 | - if( ! $fe->getGvOutputData() ) { |
|
895 | + if (!$fe->getGvOutputData()) { |
|
896 | 896 | |
897 | - do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' ); |
|
897 | + do_action('gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.'); |
|
898 | 898 | |
899 | 899 | $fe->parse_content(); |
900 | 900 | } |
901 | 901 | |
902 | 902 | // Make 100% sure that we're dealing with a properly called situation |
903 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
903 | + if (!is_a($fe->getGvOutputData(), 'GravityView_View_Data')) { |
|
904 | 904 | |
905 | - do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() ); |
|
905 | + do_action('gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData()); |
|
906 | 906 | |
907 | 907 | return array(); |
908 | 908 | } |
@@ -916,18 +916,18 @@ discard block |
||
916 | 916 | * @see GravityView_View_Data::get_view() |
917 | 917 | * @return array View data with `id`, `view_id`, `form_id`, `template_id`, `atts`, `fields`, `widgets`, `form` keys. |
918 | 918 | */ |
919 | -function gravityview_get_current_view_data( $view_id = 0 ) { |
|
919 | +function gravityview_get_current_view_data($view_id = 0) { |
|
920 | 920 | |
921 | 921 | $fe = GravityView_frontend::getInstance(); |
922 | 922 | |
923 | - if( ! $fe->getGvOutputData() ) { return array(); } |
|
923 | + if (!$fe->getGvOutputData()) { return array(); } |
|
924 | 924 | |
925 | 925 | // If not set, grab the current view ID |
926 | - if( empty( $view_id ) ) { |
|
926 | + if (empty($view_id)) { |
|
927 | 927 | $view_id = $fe->get_context_view_id(); |
928 | 928 | } |
929 | 929 | |
930 | - return $fe->getGvOutputData()->get_view( $view_id ); |
|
930 | + return $fe->getGvOutputData()->get_view($view_id); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | // Templates' hooks |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | * @action `gravityview_before` Display content before a View. Used to render widget areas. Rendered outside the View container `<div>` |
937 | 937 | * @param int $view_id The ID of the View being displayed |
938 | 938 | */ |
939 | - do_action( 'gravityview_before', gravityview_get_view_id() ); |
|
939 | + do_action('gravityview_before', gravityview_get_view_id()); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | function gravityview_header() { |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | * @action `gravityview_header` Prepend content to the View container `<div>` |
945 | 945 | * @param int $view_id The ID of the View being displayed |
946 | 946 | */ |
947 | - do_action( 'gravityview_header', gravityview_get_view_id() ); |
|
947 | + do_action('gravityview_header', gravityview_get_view_id()); |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | function gravityview_footer() { |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | * @action `gravityview_after` Display content after a View. Used to render footer widget areas. Rendered outside the View container `<div>` |
953 | 953 | * @param int $view_id The ID of the View being displayed |
954 | 954 | */ |
955 | - do_action( 'gravityview_footer', gravityview_get_view_id() ); |
|
955 | + do_action('gravityview_footer', gravityview_get_view_id()); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | function gravityview_after() { |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | * @action `gravityview_after` Append content to the View container `<div>` |
961 | 961 | * @param int $view_id The ID of the View being displayed |
962 | 962 | */ |
963 | - do_action( 'gravityview_after', gravityview_get_view_id() ); |
|
963 | + do_action('gravityview_after', gravityview_get_view_id()); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
@@ -986,13 +986,13 @@ discard block |
||
986 | 986 | * The Edit Entry functionality overrides this value. |
987 | 987 | * @param boolean $is_edit_entry |
988 | 988 | */ |
989 | - $is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false ); |
|
989 | + $is_edit_entry = apply_filters('gravityview_is_edit_entry', false); |
|
990 | 990 | |
991 | - if( $is_edit_entry ) { |
|
991 | + if ($is_edit_entry) { |
|
992 | 992 | $context = 'edit'; |
993 | - } else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
993 | + } else if (class_exists('GravityView_frontend') && $single = GravityView_frontend::is_single_entry()) { |
|
994 | 994 | $context = 'single'; |
995 | - } else if( class_exists( 'GravityView_View' ) ) { |
|
995 | + } else if (class_exists('GravityView_View')) { |
|
996 | 996 | $context = GravityView_View::getInstance()->getContext(); |
997 | 997 | } |
998 | 998 | |
@@ -1017,18 +1017,18 @@ discard block |
||
1017 | 1017 | * @param string $gv_class Field class to add to the output HTML |
1018 | 1018 | * @return array Array of file output, with `file_path` and `html` keys (see comments above) |
1019 | 1019 | */ |
1020 | -function gravityview_get_files_array( $value, $gv_class = '' ) { |
|
1020 | +function gravityview_get_files_array($value, $gv_class = '') { |
|
1021 | 1021 | /** @define "GRAVITYVIEW_DIR" "../" */ |
1022 | 1022 | |
1023 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
1024 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
1023 | + if (!class_exists('GravityView_Field')) { |
|
1024 | + include_once(GRAVITYVIEW_DIR.'includes/fields/class-gravityview-field.php'); |
|
1025 | 1025 | } |
1026 | 1026 | |
1027 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1028 | - include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' ); |
|
1027 | + if (!class_exists('GravityView_Field_FileUpload')) { |
|
1028 | + include_once(GRAVITYVIEW_DIR.'includes/fields/fileupload.php'); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | - return GravityView_Field_FileUpload::get_files_array( $value, $gv_class ); |
|
1031 | + return GravityView_Field_FileUpload::get_files_array($value, $gv_class); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | /** |
@@ -1042,16 +1042,16 @@ discard block |
||
1042 | 1042 | * @param string $address Address |
1043 | 1043 | * @return string URL of link to map of address |
1044 | 1044 | */ |
1045 | -function gravityview_get_map_link( $address ) { |
|
1045 | +function gravityview_get_map_link($address) { |
|
1046 | 1046 | |
1047 | - $address_qs = str_replace( array( '<br />', "\n" ), ' ', $address ); // Replace \n with spaces |
|
1048 | - $address_qs = urlencode( $address_qs ); |
|
1047 | + $address_qs = str_replace(array('<br />', "\n"), ' ', $address); // Replace \n with spaces |
|
1048 | + $address_qs = urlencode($address_qs); |
|
1049 | 1049 | |
1050 | 1050 | $url = "https://maps.google.com/maps?q={$address_qs}"; |
1051 | 1051 | |
1052 | - $link_text = esc_html__( 'Map It', 'gravityview' ); |
|
1052 | + $link_text = esc_html__('Map It', 'gravityview'); |
|
1053 | 1053 | |
1054 | - $link = gravityview_get_link( $url, $link_text, 'class=map-it-link' ); |
|
1054 | + $link = gravityview_get_link($url, $link_text, 'class=map-it-link'); |
|
1055 | 1055 | |
1056 | 1056 | /** |
1057 | 1057 | * @filter `gravityview_map_link` Modify the map link generated. You can use a different mapping service, for example. |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | * @param[in] string $address Address to generate link for |
1060 | 1060 | * @param[in] string $url URL generated by the function |
1061 | 1061 | */ |
1062 | - $link = apply_filters( 'gravityview_map_link', $link, $address, $url ); |
|
1062 | + $link = apply_filters('gravityview_map_link', $link, $address, $url); |
|
1063 | 1063 | |
1064 | 1064 | return $link; |
1065 | 1065 | } |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | * @param array $passed_args Associative array with field data. `field` and `form` are required. |
1081 | 1081 | * @return string Field output. If empty value and hide empty is true, return empty. |
1082 | 1082 | */ |
1083 | -function gravityview_field_output( $passed_args ) { |
|
1083 | +function gravityview_field_output($passed_args) { |
|
1084 | 1084 | $defaults = array( |
1085 | 1085 | 'entry' => null, |
1086 | 1086 | 'field' => null, |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | 'zone_id' => null, |
1093 | 1093 | ); |
1094 | 1094 | |
1095 | - $args = wp_parse_args( $passed_args, $defaults ); |
|
1095 | + $args = wp_parse_args($passed_args, $defaults); |
|
1096 | 1096 | |
1097 | 1097 | /** |
1098 | 1098 | * @filter `gravityview/field_output/args` Modify the args before generation begins |
@@ -1100,15 +1100,15 @@ discard block |
||
1100 | 1100 | * @param array $args Associative array; `field` and `form` is required. |
1101 | 1101 | * @param array $passed_args Original associative array with field data. `field` and `form` are required. |
1102 | 1102 | */ |
1103 | - $args = apply_filters( 'gravityview/field_output/args', $args, $passed_args ); |
|
1103 | + $args = apply_filters('gravityview/field_output/args', $args, $passed_args); |
|
1104 | 1104 | |
1105 | 1105 | // Required fields. |
1106 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
1107 | - do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args ); |
|
1106 | + if (empty($args['field']) || empty($args['form'])) { |
|
1107 | + do_action('gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args); |
|
1108 | 1108 | return ''; |
1109 | 1109 | } |
1110 | 1110 | |
1111 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
1111 | + $entry = empty($args['entry']) ? array() : $args['entry']; |
|
1112 | 1112 | |
1113 | 1113 | /** |
1114 | 1114 | * Create the content variables for replacing. |
@@ -1124,36 +1124,36 @@ discard block |
||
1124 | 1124 | 'field_id' => '', |
1125 | 1125 | ); |
1126 | 1126 | |
1127 | - $context['value'] = gv_value( $entry, $args['field'] ); |
|
1127 | + $context['value'] = gv_value($entry, $args['field']); |
|
1128 | 1128 | |
1129 | 1129 | // If the value is empty and we're hiding empty, return empty. |
1130 | - if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
1130 | + if ($context['value'] === '' && !empty($args['hide_empty'])) { |
|
1131 | 1131 | return ''; |
1132 | 1132 | } |
1133 | 1133 | |
1134 | - if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
1135 | - $context['value'] = wpautop( $context['value'] ); |
|
1134 | + if ($context['value'] !== '' && !empty($args['wpautop'])) { |
|
1135 | + $context['value'] = wpautop($context['value']); |
|
1136 | 1136 | } |
1137 | 1137 | |
1138 | 1138 | // Get width setting, if exists |
1139 | - $context['width'] = GravityView_API::field_width( $args['field'] ); |
|
1139 | + $context['width'] = GravityView_API::field_width($args['field']); |
|
1140 | 1140 | |
1141 | 1141 | // If replacing with CSS inline formatting, let's do it. |
1142 | - $context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' ); |
|
1142 | + $context['width:style'] = GravityView_API::field_width($args['field'], 'width:'.$context['width'].'%;'); |
|
1143 | 1143 | |
1144 | 1144 | // Grab the Class using `gv_class` |
1145 | - $context['class'] = gv_class( $args['field'], $args['form'], $entry ); |
|
1146 | - $context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry ); |
|
1145 | + $context['class'] = gv_class($args['field'], $args['form'], $entry); |
|
1146 | + $context['field_id'] = GravityView_API::field_html_attr_id($args['field'], $args['form'], $entry); |
|
1147 | 1147 | |
1148 | 1148 | // Get field label if needed |
1149 | - if ( ! empty( $args['label_markup'] ) ) { |
|
1150 | - $context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] ); |
|
1149 | + if (!empty($args['label_markup'])) { |
|
1150 | + $context['label'] = str_replace(array('{{label}}', '{{ label }}'), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup']); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | // Default Label value |
1154 | - $context['label_value'] = gv_label( $args['field'], $entry ); |
|
1154 | + $context['label_value'] = gv_label($args['field'], $entry); |
|
1155 | 1155 | |
1156 | - if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){ |
|
1156 | + if (empty($context['label']) && !empty($context['label_value'])) { |
|
1157 | 1157 | $context['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
1158 | 1158 | } |
1159 | 1159 | |
@@ -1163,37 +1163,37 @@ discard block |
||
1163 | 1163 | * @param string $markup The HTML for the markup |
1164 | 1164 | * @param array $args All args for the field output |
1165 | 1165 | */ |
1166 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args ); |
|
1166 | + $html = apply_filters('gravityview/field_output/pre_html', $args['markup'], $args); |
|
1167 | 1167 | |
1168 | 1168 | /** |
1169 | 1169 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
1170 | 1170 | * @since 1.11 |
1171 | 1171 | * @param string $open_tag Open tag for template content placeholders. Default: `{{` |
1172 | 1172 | */ |
1173 | - $open_tag = apply_filters( 'gravityview/field_output/open_tag', '{{', $args ); |
|
1173 | + $open_tag = apply_filters('gravityview/field_output/open_tag', '{{', $args); |
|
1174 | 1174 | |
1175 | 1175 | /** |
1176 | 1176 | * @filter `gravityview/field_output/close_tag` Modify the closing tags for the template content placeholders |
1177 | 1177 | * @since 1.11 |
1178 | 1178 | * @param string $close_tag Close tag for template content placeholders. Default: `}}` |
1179 | 1179 | */ |
1180 | - $close_tag = apply_filters( 'gravityview/field_output/close_tag', '}}', $args ); |
|
1180 | + $close_tag = apply_filters('gravityview/field_output/close_tag', '}}', $args); |
|
1181 | 1181 | |
1182 | 1182 | /** |
1183 | 1183 | * Loop through each of the tags to replace and replace both `{{tag}}` and `{{ tag }}` with the values |
1184 | 1184 | * @since 1.11 |
1185 | 1185 | */ |
1186 | - foreach ( $context as $tag => $value ) { |
|
1186 | + foreach ($context as $tag => $value) { |
|
1187 | 1187 | |
1188 | 1188 | // If the tag doesn't exist just skip it |
1189 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
1189 | + if (false === strpos($html, $open_tag.$tag.$close_tag) && false === strpos($html, $open_tag.' '.$tag.' '.$close_tag)) { |
|
1190 | 1190 | continue; |
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | // Array to search |
1194 | 1194 | $search = array( |
1195 | - $open_tag . $tag . $close_tag, |
|
1196 | - $open_tag . ' ' . $tag . ' ' . $close_tag, |
|
1195 | + $open_tag.$tag.$close_tag, |
|
1196 | + $open_tag.' '.$tag.' '.$close_tag, |
|
1197 | 1197 | ); |
1198 | 1198 | |
1199 | 1199 | /** |
@@ -1202,26 +1202,26 @@ discard block |
||
1202 | 1202 | * @param string $value The content to be shown instead of the {{tag}} placeholder |
1203 | 1203 | * @param array $args Arguments passed to the function |
1204 | 1204 | */ |
1205 | - $value = apply_filters( 'gravityview/field_output/context/' . $tag, $value, $args ); |
|
1205 | + $value = apply_filters('gravityview/field_output/context/'.$tag, $value, $args); |
|
1206 | 1206 | |
1207 | 1207 | // Finally do the replace |
1208 | - $html = str_replace( $search, $value, $html ); |
|
1208 | + $html = str_replace($search, $value, $html); |
|
1209 | 1209 | } |
1210 | 1210 | |
1211 | 1211 | /** |
1212 | 1212 | * @todo Depricate `gravityview_field_output` |
1213 | 1213 | */ |
1214 | - $html = apply_filters( 'gravityview_field_output', $html, $args ); |
|
1214 | + $html = apply_filters('gravityview_field_output', $html, $args); |
|
1215 | 1215 | |
1216 | 1216 | /** |
1217 | 1217 | * @filter `gravityview/field_output/html` Modify field HTML output |
1218 | 1218 | * @param string $html Existing HTML output |
1219 | 1219 | * @param array $args Arguments passed to the function |
1220 | 1220 | */ |
1221 | - $html = apply_filters( 'gravityview/field_output/html', $html, $args ); |
|
1221 | + $html = apply_filters('gravityview/field_output/html', $html, $args); |
|
1222 | 1222 | |
1223 | 1223 | // Just free up a tiny amount of memory |
1224 | - unset( $value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag ); |
|
1224 | + unset($value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag); |
|
1225 | 1225 | |
1226 | 1226 | return $html; |
1227 | 1227 | } |
@@ -1239,18 +1239,18 @@ discard block |
||
1239 | 1239 | * |
1240 | 1240 | * @return string html attribute or empty string |
1241 | 1241 | */ |
1242 | -function gv_selected( $value, $current, $echo = true, $type = 'selected' ) { |
|
1242 | +function gv_selected($value, $current, $echo = true, $type = 'selected') { |
|
1243 | 1243 | |
1244 | 1244 | $output = ''; |
1245 | - if( is_array( $current ) ) { |
|
1246 | - if( in_array( $value, $current ) ) { |
|
1247 | - $output = __checked_selected_helper( true, true, false, $type ); |
|
1245 | + if (is_array($current)) { |
|
1246 | + if (in_array($value, $current)) { |
|
1247 | + $output = __checked_selected_helper(true, true, false, $type); |
|
1248 | 1248 | } |
1249 | 1249 | } else { |
1250 | - $output = __checked_selected_helper( $value, $current, false, $type ); |
|
1250 | + $output = __checked_selected_helper($value, $current, false, $type); |
|
1251 | 1251 | } |
1252 | 1252 | |
1253 | - if( $echo ) { |
|
1253 | + if ($echo) { |
|
1254 | 1254 | echo $output; |
1255 | 1255 | } |
1256 | 1256 |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | * @since 1.13.1 |
33 | 33 | * @var array Columns in the database for leads |
34 | 34 | */ |
35 | - private $lead_db_columns = array( 'id', 'form_id', 'post_id', 'date_created', 'is_starred', 'is_read', 'ip', 'source_url', 'user_agent', 'currency', 'payment_status', 'payment_date', 'payment_amount', 'transaction_id', 'is_fulfilled', 'created_by', 'transaction_type', 'status' ); |
|
35 | + private $lead_db_columns = array('id', 'form_id', 'post_id', 'date_created', 'is_starred', 'is_read', 'ip', 'source_url', 'user_agent', 'currency', 'payment_status', 'payment_date', 'payment_amount', 'transaction_id', 'is_fulfilled', 'created_by', 'transaction_type', 'status'); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * |
39 | 39 | * @param array|int $form_ids Form ID or array of form IDs used in a request |
40 | 40 | * @param array $args Extra request parameters used to generate the query. This is used to generate the unique transient key. |
41 | 41 | */ |
42 | - function __construct( $form_ids = NULL, $args = array() ) { |
|
42 | + function __construct($form_ids = NULL, $args = array()) { |
|
43 | 43 | |
44 | 44 | $this->add_hooks(); |
45 | 45 | |
46 | - if ( ! is_null( $form_ids ) ) { |
|
46 | + if (!is_null($form_ids)) { |
|
47 | 47 | |
48 | 48 | $this->form_ids = $form_ids; |
49 | 49 | |
@@ -59,31 +59,31 @@ discard block |
||
59 | 59 | function add_hooks() { |
60 | 60 | |
61 | 61 | // Schedule cleanup of expired transients |
62 | - add_action( 'wp', array( $this, 'schedule_transient_cleanup' ) ); |
|
62 | + add_action('wp', array($this, 'schedule_transient_cleanup')); |
|
63 | 63 | |
64 | 64 | // Hook in to the scheduled cleanup, if scheduled |
65 | - add_action( 'gravityview-expired-transients', array( $this, 'delete_expired_transients' ) ); |
|
65 | + add_action('gravityview-expired-transients', array($this, 'delete_expired_transients')); |
|
66 | 66 | |
67 | 67 | // Trigger this when you need to prevent any results from being cached with forms that have been modified |
68 | - add_action( 'gravityview_clear_form_cache', array( $this, 'blacklist_add' ) ); |
|
68 | + add_action('gravityview_clear_form_cache', array($this, 'blacklist_add')); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @since 1.14 |
72 | 72 | */ |
73 | - add_action( 'gravityview_clear_entry_cache', array( $this, 'entry_status_changed' ) ); |
|
73 | + add_action('gravityview_clear_entry_cache', array($this, 'entry_status_changed')); |
|
74 | 74 | |
75 | - add_action( 'gform_after_update_entry', array( $this, 'entry_updated' ), 10, 2 ); |
|
75 | + add_action('gform_after_update_entry', array($this, 'entry_updated'), 10, 2); |
|
76 | 76 | |
77 | - add_action( 'gform_entry_created', array( $this, 'entry_created' ), 10, 2 ); |
|
77 | + add_action('gform_entry_created', array($this, 'entry_created'), 10, 2); |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @see RGFormsModel::update_lead_property() Trigger when any entry property changes |
81 | 81 | */ |
82 | - foreach( $this->lead_db_columns as $column ) { |
|
83 | - add_action( 'gform_update_' . $column, array( $this, 'entry_status_changed' ), 10, 3 ); |
|
82 | + foreach ($this->lead_db_columns as $column) { |
|
83 | + add_action('gform_update_'.$column, array($this, 'entry_status_changed'), 10, 3); |
|
84 | 84 | } |
85 | 85 | |
86 | - add_action( 'gform_delete_lead', array( $this, 'entry_status_changed' ), 10 ); |
|
86 | + add_action('gform_delete_lead', array($this, 'entry_status_changed'), 10); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -99,22 +99,22 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return void |
101 | 101 | */ |
102 | - public function entry_status_changed( $lead_id, $property_value = '', $previous_value = '' ) { |
|
102 | + public function entry_status_changed($lead_id, $property_value = '', $previous_value = '') { |
|
103 | 103 | |
104 | 104 | /** @var array $entry */ |
105 | - $entry = GFAPI::get_entry( $lead_id ); |
|
105 | + $entry = GFAPI::get_entry($lead_id); |
|
106 | 106 | |
107 | - if ( is_wp_error( $entry ) ) { |
|
107 | + if (is_wp_error($entry)) { |
|
108 | 108 | |
109 | 109 | /** @var WP_Error $entry */ |
110 | - do_action( 'gravityview_log_error', __METHOD__ . ' Could not retrieve entry ' . $lead_id . ' to delete it: ' . $entry->get_error_message() ); |
|
110 | + do_action('gravityview_log_error', __METHOD__.' Could not retrieve entry '.$lead_id.' to delete it: '.$entry->get_error_message()); |
|
111 | 111 | |
112 | 112 | return; |
113 | 113 | } |
114 | 114 | |
115 | - do_action( 'gravityview_log_debug', __METHOD__ . ' adding form ' . $entry['form_id'] . ' to blacklist because entry #' . $lead_id . ' was deleted', array( 'value' => $property_value, 'previous' => $previous_value ) ); |
|
115 | + do_action('gravityview_log_debug', __METHOD__.' adding form '.$entry['form_id'].' to blacklist because entry #'.$lead_id.' was deleted', array('value' => $property_value, 'previous' => $previous_value)); |
|
116 | 116 | |
117 | - $this->blacklist_add( $entry['form_id'] ); |
|
117 | + $this->blacklist_add($entry['form_id']); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | - public function entry_updated( $form, $lead_id ) { |
|
128 | + public function entry_updated($form, $lead_id) { |
|
129 | 129 | |
130 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form ' . $form['id'] . ' to blacklist because entry #' . $lead_id . ' was updated' ); |
|
130 | + do_action('gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form '.$form['id'].' to blacklist because entry #'.$lead_id.' was updated'); |
|
131 | 131 | |
132 | - $this->blacklist_add( $form['id'] ); |
|
132 | + $this->blacklist_add($form['id']); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return void |
144 | 144 | */ |
145 | - public function entry_created( $entry, $form ) { |
|
145 | + public function entry_created($entry, $form) { |
|
146 | 146 | |
147 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_created] adding form ' . $form['id'] . ' to blacklist because entry #' . $entry['id'] . ' was created' ); |
|
147 | + do_action('gravityview_log_debug', 'GravityView_Cache[entry_created] adding form '.$form['id'].' to blacklist because entry #'.$entry['id'].' was created'); |
|
148 | 148 | |
149 | - $this->blacklist_add( $form['id'] ); |
|
149 | + $this->blacklist_add($form['id']); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return string Prefix for the cache string used in set_key() |
158 | 158 | */ |
159 | - protected function get_cache_key_prefix( $form_ids = NULL ) { |
|
159 | + protected function get_cache_key_prefix($form_ids = NULL) { |
|
160 | 160 | |
161 | - if ( is_null( $form_ids ) ) { |
|
161 | + if (is_null($form_ids)) { |
|
162 | 162 | $form_ids = $this->form_ids; |
163 | 163 | } |
164 | 164 | |
165 | 165 | // Normally just one form, but supports multiple forms |
166 | 166 | // |
167 | 167 | // Array of IDs 12, 5, 14 would result in `f-12f-5f-14` |
168 | - $forms = 'f:' . implode( '&f:', (array) $form_ids ); |
|
168 | + $forms = 'f:'.implode('&f:', (array)$form_ids); |
|
169 | 169 | |
170 | 170 | // Prefix for transient keys |
171 | 171 | // Now the prefix would be: `gv-cache-f-12f-5f-14` |
172 | - return 'gv-cache-' . $forms . '-'; |
|
172 | + return 'gv-cache-'.$forms.'-'; |
|
173 | 173 | |
174 | 174 | } |
175 | 175 | |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | protected function set_key() { |
180 | 180 | |
181 | 181 | // Don't set key if no forms have been set. |
182 | - if ( empty( $this->form_ids ) ) { |
|
182 | + if (empty($this->form_ids)) { |
|
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
186 | - $key = $this->get_cache_key_prefix() . sha1( serialize( $this->args ) ); |
|
186 | + $key = $this->get_cache_key_prefix().sha1(serialize($this->args)); |
|
187 | 187 | |
188 | 188 | // The transient name column can handle up to 64 characters. |
189 | 189 | // The `_transient_timeout_` prefix that is prepended to the string is 11 characters. |
190 | 190 | // 64 - 19 = 45 |
191 | 191 | // We make sure the key isn't too long or else WP doesn't store data. |
192 | - $this->key = substr( $key, 0, 45 ); |
|
192 | + $this->key = substr($key, 0, 45); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -210,24 +210,24 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return boolean False if value was not updated and true if value was updated. |
212 | 212 | */ |
213 | - public function blacklist_add( $form_ids ) { |
|
213 | + public function blacklist_add($form_ids) { |
|
214 | 214 | |
215 | - $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
|
215 | + $blacklist = get_option(self::BLACKLIST_OPTION_NAME, array()); |
|
216 | 216 | |
217 | - $form_ids = is_array( $form_ids ) ? $form_ids : array( $form_ids ); |
|
217 | + $form_ids = is_array($form_ids) ? $form_ids : array($form_ids); |
|
218 | 218 | |
219 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_add] Adding form IDs to cache blacklist', array( |
|
219 | + do_action('gravityview_log_debug', 'GravityView_Cache[blacklist_add] Adding form IDs to cache blacklist', array( |
|
220 | 220 | '$form_ids' => $form_ids, |
221 | 221 | '$blacklist' => $blacklist |
222 | - ) ); |
|
222 | + )); |
|
223 | 223 | |
224 | 224 | // Add the passed form IDs |
225 | - $blacklist = array_merge( $blacklist, $form_ids ); |
|
225 | + $blacklist = array_merge($blacklist, $form_ids); |
|
226 | 226 | |
227 | 227 | // Don't duplicate |
228 | - $blacklist = array_unique( $blacklist ); |
|
228 | + $blacklist = array_unique($blacklist); |
|
229 | 229 | |
230 | - return update_option( self::BLACKLIST_OPTION_NAME, $blacklist ); |
|
230 | + return update_option(self::BLACKLIST_OPTION_NAME, $blacklist); |
|
231 | 231 | |
232 | 232 | } |
233 | 233 | |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return boolean Whether the removal was successful |
240 | 240 | */ |
241 | - public function blacklist_remove( $form_ids ) { |
|
241 | + public function blacklist_remove($form_ids) { |
|
242 | 242 | |
243 | - $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
|
243 | + $blacklist = get_option(self::BLACKLIST_OPTION_NAME, array()); |
|
244 | 244 | |
245 | - $updated_list = array_diff( $blacklist, (array) $form_ids ); |
|
245 | + $updated_list = array_diff($blacklist, (array)$form_ids); |
|
246 | 246 | |
247 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array( |
|
247 | + do_action('gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array( |
|
248 | 248 | '$form_ids' => $form_ids, |
249 | 249 | '$blacklist' => $blacklist, |
250 | 250 | '$updated_list' => $updated_list |
251 | - ) ); |
|
251 | + )); |
|
252 | 252 | |
253 | - return update_option( self::BLACKLIST_OPTION_NAME, $updated_list ); |
|
253 | + return update_option(self::BLACKLIST_OPTION_NAME, $updated_list); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -261,25 +261,25 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return [type] [description] |
263 | 263 | */ |
264 | - function in_blacklist( $form_ids = NULL ) { |
|
264 | + function in_blacklist($form_ids = NULL) { |
|
265 | 265 | |
266 | - $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
|
266 | + $blacklist = get_option(self::BLACKLIST_OPTION_NAME, array()); |
|
267 | 267 | |
268 | 268 | // Use object var if exists |
269 | - $form_ids = is_null( $form_ids ) ? $this->form_ids : $form_ids; |
|
269 | + $form_ids = is_null($form_ids) ? $this->form_ids : $form_ids; |
|
270 | 270 | |
271 | - if ( empty( $form_ids ) ) { |
|
271 | + if (empty($form_ids)) { |
|
272 | 272 | |
273 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[in_blacklist] Did not add form to blacklist; empty form ID', $form_ids ); |
|
273 | + do_action('gravityview_log_debug', 'GravityView_Cache[in_blacklist] Did not add form to blacklist; empty form ID', $form_ids); |
|
274 | 274 | |
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | |
278 | - foreach ( (array) $form_ids as $form_id ) { |
|
278 | + foreach ((array)$form_ids as $form_id) { |
|
279 | 279 | |
280 | - if ( in_array( $form_id, $blacklist ) ) { |
|
280 | + if (in_array($form_id, $blacklist)) { |
|
281 | 281 | |
282 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[in_blacklist] Form #' . esc_attr( $form_id ) . ' is in the cache blacklist' ); |
|
282 | + do_action('gravityview_log_debug', 'GravityView_Cache[in_blacklist] Form #'.esc_attr($form_id).' is in the cache blacklist'); |
|
283 | 283 | |
284 | 284 | return true; |
285 | 285 | } |
@@ -296,35 +296,35 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return mixed False: Not using cache or cache was a WP_Error object; NULL: no results found; Mixed: cache value |
298 | 298 | */ |
299 | - public function get( $key = NULL ) { |
|
299 | + public function get($key = NULL) { |
|
300 | 300 | |
301 | - $key = is_null( $key ) ? $this->key : $key; |
|
301 | + $key = is_null($key) ? $this->key : $key; |
|
302 | 302 | |
303 | - if ( ! $this->use_cache() ) { |
|
303 | + if (!$this->use_cache()) { |
|
304 | 304 | |
305 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Not using cached results because of GravityView_Cache->use_cache() results' ); |
|
305 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Not using cached results because of GravityView_Cache->use_cache() results'); |
|
306 | 306 | |
307 | 307 | return false; |
308 | 308 | } |
309 | 309 | |
310 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Fetching request with transient key ' . $key ); |
|
310 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Fetching request with transient key '.$key); |
|
311 | 311 | |
312 | - $result = get_transient( $key ); |
|
312 | + $result = get_transient($key); |
|
313 | 313 | |
314 | - if ( is_wp_error( $result ) ) { |
|
314 | + if (is_wp_error($result)) { |
|
315 | 315 | |
316 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Fetching request resulted in error:', $result ); |
|
316 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Fetching request resulted in error:', $result); |
|
317 | 317 | |
318 | 318 | return false; |
319 | 319 | |
320 | - } elseif ( $result ) { |
|
320 | + } elseif ($result) { |
|
321 | 321 | |
322 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Cached results found for transient key ' . $key ); |
|
322 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Cached results found for transient key '.$key); |
|
323 | 323 | |
324 | 324 | return $result; |
325 | 325 | } |
326 | 326 | |
327 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] No cached results found for transient key ' . $key ); |
|
327 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] No cached results found for transient key '.$key); |
|
328 | 328 | |
329 | 329 | return NULL; |
330 | 330 | |
@@ -338,24 +338,24 @@ discard block |
||
338 | 338 | * @param [type] $content [description] |
339 | 339 | * @param [type] $filter_name Name used to modify the cache time. Will be set to `gravityview_cache_time_{$filter_name}`. |
340 | 340 | */ |
341 | - public function set( $content, $filter_name = '' ) { |
|
341 | + public function set($content, $filter_name = '') { |
|
342 | 342 | |
343 | 343 | // Don't cache empty results |
344 | - if ( ! empty( $content ) ) { |
|
344 | + if (!empty($content)) { |
|
345 | 345 | |
346 | 346 | /** |
347 | 347 | * @filter `gravityview_cache_time_{$filter_name}` Modify the cache time for a type of cache |
348 | 348 | * @param int $time_in_seconds Default: `DAY_IN_SECONDS` |
349 | 349 | */ |
350 | - $cache_time = (int) apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS ); |
|
350 | + $cache_time = (int)apply_filters('gravityview_cache_time_'.$filter_name, DAY_IN_SECONDS); |
|
351 | 351 | |
352 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key ' . $this->key . ' for ' . $cache_time . ' seconds' ); |
|
352 | + do_action('gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key '.$this->key.' for '.$cache_time.' seconds'); |
|
353 | 353 | |
354 | - return set_transient( $this->key, $content, $cache_time ); |
|
354 | + return set_transient($this->key, $content, $cache_time); |
|
355 | 355 | |
356 | 356 | } |
357 | 357 | |
358 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Cache not set; content is empty' ); |
|
358 | + do_action('gravityview_log_debug', 'GravityView_Cache[set] Cache not set; content is empty'); |
|
359 | 359 | |
360 | 360 | return false; |
361 | 361 | |
@@ -371,39 +371,39 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return [type] [description] |
373 | 373 | */ |
374 | - public function delete( $form_ids = NULL ) { |
|
374 | + public function delete($form_ids = NULL) { |
|
375 | 375 | global $wpdb; |
376 | 376 | |
377 | 377 | // Use object var if exists |
378 | - $form_ids = is_null( $form_ids ) ? $this->form_ids : $form_ids; |
|
378 | + $form_ids = is_null($form_ids) ? $this->form_ids : $form_ids; |
|
379 | 379 | |
380 | - if ( empty( $form_ids ) ) { |
|
381 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[delete] Did not delete cache; empty form IDs' ); |
|
380 | + if (empty($form_ids)) { |
|
381 | + do_action('gravityview_log_debug', 'GravityView_Cache[delete] Did not delete cache; empty form IDs'); |
|
382 | 382 | |
383 | 383 | return; |
384 | 384 | } |
385 | 385 | |
386 | - foreach ( (array) $form_ids as $form_id ) { |
|
386 | + foreach ((array)$form_ids as $form_id) { |
|
387 | 387 | |
388 | - $key = $this->get_cache_key_prefix( $form_id ); |
|
388 | + $key = $this->get_cache_key_prefix($form_id); |
|
389 | 389 | |
390 | 390 | // WordPress 4.0+ |
391 | - if ( is_callable( array( $wpdb, 'esc_like' ) ) ) { |
|
392 | - $key = $wpdb->esc_like( $key ); |
|
391 | + if (is_callable(array($wpdb, 'esc_like'))) { |
|
392 | + $key = $wpdb->esc_like($key); |
|
393 | 393 | } else { |
394 | - $key = like_escape( $key ); |
|
394 | + $key = like_escape($key); |
|
395 | 395 | } |
396 | 396 | |
397 | - $key = "%" . $key . "%"; |
|
397 | + $key = "%".$key."%"; |
|
398 | 398 | |
399 | - $sql = $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE `option_name` LIKE %s", $key ); |
|
399 | + $sql = $wpdb->prepare("DELETE FROM {$wpdb->options} WHERE `option_name` LIKE %s", $key); |
|
400 | 400 | |
401 | - $result = $wpdb->query( $sql ); |
|
401 | + $result = $wpdb->query($sql); |
|
402 | 402 | |
403 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[delete] Deleting cache for form #' . $form_id, array( |
|
403 | + do_action('gravityview_log_debug', 'GravityView_Cache[delete] Deleting cache for form #'.$form_id, array( |
|
404 | 404 | $sql, |
405 | - sprintf( 'Deleted results: %d', $result ) |
|
406 | - ) ); |
|
405 | + sprintf('Deleted results: %d', $result) |
|
406 | + )); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | } |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | * @filter `gravityview_cleanup_transients` Override GravityView cleanup of transients by setting this to false |
422 | 422 | * @param boolean $cleanup Whether to run the GravityView auto-cleanup of transients. Default: `true` |
423 | 423 | */ |
424 | - $cleanup = apply_filters( 'gravityview_cleanup_transients', true ); |
|
424 | + $cleanup = apply_filters('gravityview_cleanup_transients', true); |
|
425 | 425 | |
426 | - if ( ! $cleanup ) { |
|
426 | + if (!$cleanup) { |
|
427 | 427 | return; |
428 | 428 | } |
429 | 429 | |
430 | - if ( ! wp_next_scheduled( 'gravityview-expired-transients' ) ) { |
|
431 | - wp_schedule_event( time(), 'daily', 'gravityview-expired-transients' ); |
|
430 | + if (!wp_next_scheduled('gravityview-expired-transients')) { |
|
431 | + wp_schedule_event(time(), 'daily', 'gravityview-expired-transients'); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | $threshold = time() - 60; |
454 | 454 | |
455 | 455 | // get table name for options on specified blog |
456 | - $table = $wpdb->get_blog_prefix( $blog_id ) . 'options'; |
|
456 | + $table = $wpdb->get_blog_prefix($blog_id).'options'; |
|
457 | 457 | |
458 | 458 | // delete expired transients, using the paired timeout record to find them |
459 | 459 | $sql = " |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | and t1.option_value < '$threshold' |
465 | 465 | "; |
466 | 466 | |
467 | - $num_results = $wpdb->query( $sql ); |
|
467 | + $num_results = $wpdb->query($sql); |
|
468 | 468 | |
469 | 469 | // delete orphaned transient expirations |
470 | 470 | // also delete NextGEN Gallery 2.x display cache timeout aliases |
@@ -479,9 +479,9 @@ discard block |
||
479 | 479 | and option_value < '$threshold' |
480 | 480 | "; |
481 | 481 | |
482 | - $num_results += $wpdb->query( $sql ); |
|
482 | + $num_results += $wpdb->query($sql); |
|
483 | 483 | |
484 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[delete_expired_transients] Deleted ' . $num_results . ' expired transient records from the database' ); |
|
484 | + do_action('gravityview_log_debug', 'GravityView_Cache[delete_expired_transients] Deleted '.$num_results.' expired transient records from the database'); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -495,11 +495,11 @@ discard block |
||
495 | 495 | |
496 | 496 | $use_cache = true; |
497 | 497 | |
498 | - if ( GVCommon::has_cap( 'edit_gravityviews' ) ) { |
|
498 | + if (GVCommon::has_cap('edit_gravityviews')) { |
|
499 | 499 | |
500 | - if ( isset( $_GET['cache'] ) || isset( $_GET['nocache'] ) ) { |
|
500 | + if (isset($_GET['cache']) || isset($_GET['nocache'])) { |
|
501 | 501 | |
502 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL' ); |
|
502 | + do_action('gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL'); |
|
503 | 503 | |
504 | 504 | $use_cache = false; |
505 | 505 | } |
@@ -507,13 +507,13 @@ discard block |
||
507 | 507 | } |
508 | 508 | |
509 | 509 | // Has the form been flagged as having changed items in it? |
510 | - if ( $this->in_blacklist() ) { |
|
510 | + if ($this->in_blacklist()) { |
|
511 | 511 | |
512 | 512 | // Delete caches for all items with form IDs XYZ |
513 | - $this->delete( $this->form_ids ); |
|
513 | + $this->delete($this->form_ids); |
|
514 | 514 | |
515 | 515 | // Remove the form from |
516 | - $this->blacklist_remove( $this->form_ids ); |
|
516 | + $this->blacklist_remove($this->form_ids); |
|
517 | 517 | |
518 | 518 | } |
519 | 519 | |
@@ -524,9 +524,9 @@ discard block |
||
524 | 524 | * @param[out,in] boolean $use_cache Previous setting |
525 | 525 | * @param[out] GravityView_Cache $this The GravityView_Cache object |
526 | 526 | */ |
527 | - $use_cache = apply_filters( 'gravityview_use_cache', $use_cache, $this ); |
|
527 | + $use_cache = apply_filters('gravityview_use_cache', $use_cache, $this); |
|
528 | 528 | |
529 | - return (boolean) $use_cache; |
|
529 | + return (boolean)$use_cache; |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | /** If this file is called directly, abort. */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | 18 | |
@@ -25,17 +25,17 @@ discard block |
||
25 | 25 | * @param mixed $form_id |
26 | 26 | * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms |
27 | 27 | */ |
28 | - public static function get_form( $form_id ) { |
|
29 | - if ( empty( $form_id ) ) { |
|
28 | + public static function get_form($form_id) { |
|
29 | + if (empty($form_id)) { |
|
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | - if ( class_exists( 'GFAPI' ) ) { |
|
34 | - return GFAPI::get_form( $form_id ); |
|
33 | + if (class_exists('GFAPI')) { |
|
34 | + return GFAPI::get_form($form_id); |
|
35 | 35 | } |
36 | 36 | |
37 | - if ( class_exists( 'RGFormsModel' ) ) { |
|
38 | - return RGFormsModel::get_form( $form_id ); |
|
37 | + if (class_exists('RGFormsModel')) { |
|
38 | + return RGFormsModel::get_form($form_id); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return false; |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities |
56 | 56 | */ |
57 | - public static function has_cap( $caps = '', $object_id = null, $user_id = null ) { |
|
58 | - return GravityView_Roles_Capabilities::has_cap( $caps, $object_id, $user_id ); |
|
57 | + public static function has_cap($caps = '', $object_id = null, $user_id = null) { |
|
58 | + return GravityView_Roles_Capabilities::has_cap($caps, $object_id, $user_id); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * @param array|GF_Fields $field Gravity Forms field or array |
67 | 67 | * @return array Array version of $field |
68 | 68 | */ |
69 | - public static function get_field_array( $field ) { |
|
69 | + public static function get_field_array($field) { |
|
70 | 70 | |
71 | - if ( class_exists( 'GF_Fields' ) ) { |
|
71 | + if (class_exists('GF_Fields')) { |
|
72 | 72 | |
73 | - $field_object = GF_Fields::create( $field ); |
|
73 | + $field_object = GF_Fields::create($field); |
|
74 | 74 | |
75 | 75 | // Convert the field object in 1.9 to an array for backward compatibility |
76 | - $field_array = get_object_vars( $field_object ); |
|
76 | + $field_array = get_object_vars($field_object); |
|
77 | 77 | |
78 | 78 | } else { |
79 | 79 | $field_array = $field; |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * @filter `gravityview/get_all_views/params` Modify the parameters sent to get all views. |
101 | 101 | * @param[in,out] array $params Array of parameters to pass to `get_posts()` |
102 | 102 | */ |
103 | - $views_params = apply_filters( 'gravityview/get_all_views/params', $params ); |
|
103 | + $views_params = apply_filters('gravityview/get_all_views/params', $params); |
|
104 | 104 | |
105 | - $views = get_posts( $views_params ); |
|
105 | + $views = get_posts($views_params); |
|
106 | 106 | |
107 | 107 | return $views; |
108 | 108 | } |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | * @param int|string $entry_slug Entry slug |
114 | 114 | * @return array Gravity Forms form array |
115 | 115 | */ |
116 | - public static function get_form_from_entry_id( $entry_slug ) { |
|
116 | + public static function get_form_from_entry_id($entry_slug) { |
|
117 | 117 | |
118 | - $entry = self::get_entry( $entry_slug, true ); |
|
118 | + $entry = self::get_entry($entry_slug, true); |
|
119 | 119 | |
120 | - $form = self::get_form( $entry['form_id'] ); |
|
120 | + $form = self::get_form($entry['form_id']); |
|
121 | 121 | |
122 | 122 | return $form; |
123 | 123 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param string $slug The entry slug, as returned by GravityView_API::get_entry_slug() |
130 | 130 | * @return int|null The entry ID, if exists; `NULL` if not |
131 | 131 | */ |
132 | - public static function get_entry_id_from_slug( $slug ) { |
|
132 | + public static function get_entry_id_from_slug($slug) { |
|
133 | 133 | global $wpdb; |
134 | 134 | |
135 | 135 | $search_criteria = array( |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | 'page_size' => 1, |
149 | 149 | ); |
150 | 150 | |
151 | - $results = GFAPI::get_entries( 0, $search_criteria, null, $paging ); |
|
151 | + $results = GFAPI::get_entries(0, $search_criteria, null, $paging); |
|
152 | 152 | |
153 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
153 | + $result = (!empty($results) && !empty($results[0]['id'])) ? $results[0]['id'] : null; |
|
154 | 154 | |
155 | 155 | return $result; |
156 | 156 | } |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | * @return array (id, title) |
165 | 165 | */ |
166 | 166 | public static function get_forms() { |
167 | - if ( class_exists( 'RGFormsModel' ) ) { |
|
168 | - $gf_forms = RGFormsModel::get_forms( null, 'title' ); |
|
167 | + if (class_exists('RGFormsModel')) { |
|
168 | + $gf_forms = RGFormsModel::get_forms(null, 'title'); |
|
169 | 169 | $forms = array(); |
170 | - foreach ( $gf_forms as $form ) { |
|
171 | - $forms[] = array( 'id' => $form->id, 'title' => $form->title ); |
|
170 | + foreach ($gf_forms as $form) { |
|
171 | + $forms[] = array('id' => $form->id, 'title' => $form->title); |
|
172 | 172 | } |
173 | 173 | return $forms; |
174 | 174 | } |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | * @param string|array $form_id (default: '') or $form object |
183 | 183 | * @return array |
184 | 184 | */ |
185 | - public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
|
185 | + public static function get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true) { |
|
186 | 186 | |
187 | - if ( ! is_array( $form ) ) { |
|
188 | - $form = self::get_form( $form ); |
|
187 | + if (!is_array($form)) { |
|
188 | + $form = self::get_form($form); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | $fields = array(); |
@@ -195,56 +195,56 @@ discard block |
||
195 | 195 | $has_poll_fields = false; |
196 | 196 | |
197 | 197 | // If GF_Field exists, we're using GF 1.9+, where add_default_properties has been deprecated. |
198 | - if ( false === class_exists( 'GF_Field' ) && $add_default_properties ) { |
|
199 | - $form = RGFormsModel::add_default_properties( $form ); |
|
198 | + if (false === class_exists('GF_Field') && $add_default_properties) { |
|
199 | + $form = RGFormsModel::add_default_properties($form); |
|
200 | 200 | } |
201 | 201 | |
202 | - if ( $form ) { |
|
203 | - foreach ( $form['fields'] as $field ) { |
|
204 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
205 | - $fields[ $field['id'] ] = array( |
|
206 | - 'label' => rgar( $field, 'label' ), |
|
202 | + if ($form) { |
|
203 | + foreach ($form['fields'] as $field) { |
|
204 | + if ($include_parent_field || empty($field['inputs'])) { |
|
205 | + $fields[$field['id']] = array( |
|
206 | + 'label' => rgar($field, 'label'), |
|
207 | 207 | 'parent' => null, |
208 | - 'type' => rgar( $field, 'type' ), |
|
209 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
210 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
208 | + 'type' => rgar($field, 'type'), |
|
209 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
210 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
211 | 211 | ); |
212 | 212 | } |
213 | 213 | |
214 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
215 | - foreach ( $field['inputs'] as $input ) { |
|
214 | + if ($add_default_properties && !empty($field['inputs'])) { |
|
215 | + foreach ($field['inputs'] as $input) { |
|
216 | 216 | /** |
217 | 217 | * @hack |
218 | 218 | * In case of email/email confirmation, the input for email has the same id as the parent field |
219 | 219 | */ |
220 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
220 | + if ('email' == rgar($field, 'type') && false === strpos($input['id'], '.')) { |
|
221 | 221 | continue; |
222 | 222 | } |
223 | - $fields[ (string)$input['id'] ] = array( |
|
224 | - 'label' => rgar( $input, 'label' ), |
|
225 | - 'customLabel' => rgar( $input, 'customLabel' ), |
|
223 | + $fields[(string)$input['id']] = array( |
|
224 | + 'label' => rgar($input, 'label'), |
|
225 | + 'customLabel' => rgar($input, 'customLabel'), |
|
226 | 226 | 'parent' => $field, |
227 | - 'type' => rgar( $field, 'type' ), |
|
228 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
229 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
227 | + 'type' => rgar($field, 'type'), |
|
228 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
229 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
230 | 230 | ); |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
234 | 234 | /** @since 1.14 */ |
235 | - if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) { |
|
235 | + if ('list' === $field['type'] && !empty($field['enableColumns'])) { |
|
236 | 236 | |
237 | - foreach ( (array)$field['choices'] as $key => $input ) { |
|
237 | + foreach ((array)$field['choices'] as $key => $input) { |
|
238 | 238 | |
239 | - $input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key} |
|
239 | + $input_id = sprintf('%d.%d', $field['id'], $key); // {field_id}.{column_key} |
|
240 | 240 | |
241 | - $fields[ $input_id ] = array( |
|
242 | - 'label' => rgar( $input, 'text' ), |
|
241 | + $fields[$input_id] = array( |
|
242 | + 'label' => rgar($input, 'text'), |
|
243 | 243 | 'customLabel' => '', |
244 | 244 | 'parent' => $field, |
245 | - 'type' => rgar( $field, 'type' ), |
|
246 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
247 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
245 | + 'type' => rgar($field, 'type'), |
|
246 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
247 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
248 | 248 | ); |
249 | 249 | } |
250 | 250 | } |
@@ -252,27 +252,27 @@ discard block |
||
252 | 252 | /** |
253 | 253 | * @since 1.8 |
254 | 254 | */ |
255 | - if( 'quiz' === $field['type'] ) { |
|
255 | + if ('quiz' === $field['type']) { |
|
256 | 256 | $has_quiz_fields = true; |
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
260 | 260 | * @since 1.8 |
261 | 261 | */ |
262 | - if( 'poll' === $field['type'] ) { |
|
262 | + if ('poll' === $field['type']) { |
|
263 | 263 | $has_poll_fields = true; |
264 | 264 | } |
265 | 265 | |
266 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
266 | + if (GFCommon::is_product_field($field['type'])) { |
|
267 | 267 | $has_product_fields = true; |
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
271 | 271 | * @hack Version 1.9 |
272 | 272 | */ |
273 | - $field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field; |
|
273 | + $field_for_is_post_field = class_exists('GF_Fields') ? (object)$field : (array)$field; |
|
274 | 274 | |
275 | - if ( GFCommon::is_post_field( $field_for_is_post_field ) ) { |
|
275 | + if (GFCommon::is_post_field($field_for_is_post_field)) { |
|
276 | 276 | $has_post_fields = true; |
277 | 277 | } |
278 | 278 | } |
@@ -281,47 +281,47 @@ discard block |
||
281 | 281 | /** |
282 | 282 | * @since 1.7 |
283 | 283 | */ |
284 | - if ( $has_post_fields ) { |
|
284 | + if ($has_post_fields) { |
|
285 | 285 | $fields['post_id'] = array( |
286 | - 'label' => __( 'Post ID', 'gravityview' ), |
|
286 | + 'label' => __('Post ID', 'gravityview'), |
|
287 | 287 | 'type' => 'post_id', |
288 | 288 | ); |
289 | 289 | } |
290 | 290 | |
291 | - if ( $has_product_fields ) { |
|
291 | + if ($has_product_fields) { |
|
292 | 292 | |
293 | 293 | $fields['payment_status'] = array( |
294 | - 'label' => __( 'Payment Status', 'gravityview' ), |
|
294 | + 'label' => __('Payment Status', 'gravityview'), |
|
295 | 295 | 'type' => 'payment_status', |
296 | 296 | ); |
297 | 297 | |
298 | 298 | $fields['payment_date'] = array( |
299 | - 'label' => __( 'Payment Date', 'gravityview' ), |
|
299 | + 'label' => __('Payment Date', 'gravityview'), |
|
300 | 300 | 'type' => 'payment_date', |
301 | 301 | ); |
302 | 302 | |
303 | 303 | $fields['payment_amount'] = array( |
304 | - 'label' => __( 'Payment Amount', 'gravityview' ), |
|
304 | + 'label' => __('Payment Amount', 'gravityview'), |
|
305 | 305 | 'type' => 'payment_amount', |
306 | 306 | ); |
307 | 307 | |
308 | 308 | $fields['payment_method'] = array( |
309 | - 'label' => __( 'Payment Method', 'gravityview' ), |
|
309 | + 'label' => __('Payment Method', 'gravityview'), |
|
310 | 310 | 'type' => 'payment_method', |
311 | 311 | ); |
312 | 312 | |
313 | 313 | $fields['is_fulfilled'] = array( |
314 | - 'label' => __( 'Is Fulfilled', 'gravityview' ), |
|
314 | + 'label' => __('Is Fulfilled', 'gravityview'), |
|
315 | 315 | 'type' => 'is_fulfilled', |
316 | 316 | ); |
317 | 317 | |
318 | 318 | $fields['transaction_id'] = array( |
319 | - 'label' => __( 'Transaction ID', 'gravityview' ), |
|
319 | + 'label' => __('Transaction ID', 'gravityview'), |
|
320 | 320 | 'type' => 'transaction_id', |
321 | 321 | ); |
322 | 322 | |
323 | 323 | $fields['transaction_type'] = array( |
324 | - 'label' => __( 'Transaction Type', 'gravityview' ), |
|
324 | + 'label' => __('Transaction Type', 'gravityview'), |
|
325 | 325 | 'type' => 'transaction_type', |
326 | 326 | ); |
327 | 327 | |
@@ -330,27 +330,27 @@ discard block |
||
330 | 330 | /** |
331 | 331 | * @since 1.8 |
332 | 332 | */ |
333 | - if( $has_quiz_fields ) { |
|
333 | + if ($has_quiz_fields) { |
|
334 | 334 | |
335 | - $fields['gquiz_score'] = array( |
|
336 | - 'label' => __( 'Quiz Score Total', 'gravityview' ), |
|
335 | + $fields['gquiz_score'] = array( |
|
336 | + 'label' => __('Quiz Score Total', 'gravityview'), |
|
337 | 337 | 'type' => 'quiz_score', |
338 | - 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
|
338 | + 'desc' => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'), |
|
339 | 339 | ); |
340 | 340 | $fields['gquiz_percent'] = array( |
341 | - 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
|
341 | + 'label' => __('Quiz Percentage Grade', 'gravityview'), |
|
342 | 342 | 'type' => 'quiz_percent', |
343 | - 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
|
343 | + 'desc' => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'), |
|
344 | 344 | ); |
345 | - $fields['gquiz_grade'] = array( |
|
346 | - 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
|
345 | + $fields['gquiz_grade'] = array( |
|
346 | + 'label' => __('Quiz Letter Grade', 'gravityview'), |
|
347 | 347 | 'type' => 'quiz_grade', |
348 | - 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
|
348 | + 'desc' => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'), |
|
349 | 349 | ); |
350 | 350 | $fields['gquiz_is_pass'] = array( |
351 | - 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
|
351 | + 'label' => __('Quiz Pass/Fail', 'gravityview'), |
|
352 | 352 | 'type' => 'quiz_is_pass', |
353 | - 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
|
353 | + 'desc' => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'), |
|
354 | 354 | ); |
355 | 355 | } |
356 | 356 | |
@@ -364,15 +364,15 @@ discard block |
||
364 | 364 | * @param string $form_id (default: '') |
365 | 365 | * @return array |
366 | 366 | */ |
367 | - public static function get_entry_meta( $form_id, $only_default_column = true ) { |
|
367 | + public static function get_entry_meta($form_id, $only_default_column = true) { |
|
368 | 368 | |
369 | - $extra_fields = GFFormsModel::get_entry_meta( $form_id ); |
|
369 | + $extra_fields = GFFormsModel::get_entry_meta($form_id); |
|
370 | 370 | |
371 | 371 | $fields = array(); |
372 | 372 | |
373 | - foreach ( $extra_fields as $key => $field ){ |
|
374 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
375 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
373 | + foreach ($extra_fields as $key => $field) { |
|
374 | + if (!empty($only_default_column) && !empty($field['is_default_column'])) { |
|
375 | + $fields[$key] = array('label' => $field['label'], 'type' => 'entry_meta'); |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | * @since 1.1.6 |
389 | 389 | * @return array Array of entry IDs |
390 | 390 | */ |
391 | - public static function get_entry_ids( $form_id, $search_criteria = array() ) { |
|
391 | + public static function get_entry_ids($form_id, $search_criteria = array()) { |
|
392 | 392 | |
393 | - if ( ! class_exists( 'GFFormsModel' ) ) { |
|
393 | + if (!class_exists('GFFormsModel')) { |
|
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | - return GFFormsModel::search_lead_ids( $form_id, $search_criteria ); |
|
397 | + return GFFormsModel::search_lead_ids($form_id, $search_criteria); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -406,33 +406,33 @@ discard block |
||
406 | 406 | * @param null $form_ids array Gravity Forms form IDs |
407 | 407 | * @return array|mixed|void |
408 | 408 | */ |
409 | - public static function calculate_get_entries_criteria( $passed_criteria = null, $form_ids = null ) { |
|
409 | + public static function calculate_get_entries_criteria($passed_criteria = null, $form_ids = null) { |
|
410 | 410 | |
411 | 411 | $search_criteria_defaults = array( |
412 | 412 | 'search_criteria' => null, |
413 | 413 | 'sorting' => null, |
414 | 414 | 'paging' => null, |
415 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
415 | + 'cache' => (isset($passed_criteria['cache']) ? $passed_criteria['cache'] : true), |
|
416 | 416 | ); |
417 | 417 | |
418 | - $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
|
418 | + $criteria = wp_parse_args($passed_criteria, $search_criteria_defaults); |
|
419 | 419 | |
420 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
421 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
420 | + if (!empty($criteria['search_criteria']['field_filters'])) { |
|
421 | + foreach ($criteria['search_criteria']['field_filters'] as &$filter) { |
|
422 | 422 | |
423 | - if ( ! is_array( $filter ) ) { |
|
423 | + if (!is_array($filter)) { |
|
424 | 424 | continue; |
425 | 425 | } |
426 | 426 | |
427 | 427 | // By default, we want searches to be wildcard for each field. |
428 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
428 | + $filter['operator'] = empty($filter['operator']) ? 'contains' : $filter['operator']; |
|
429 | 429 | |
430 | 430 | /** |
431 | 431 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
432 | 432 | * @param string $operator Existing search operator |
433 | 433 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
434 | 434 | */ |
435 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
435 | + $filter['operator'] = apply_filters('gravityview_search_operator', $filter['operator'], $filter); |
|
436 | 436 | } |
437 | 437 | } |
438 | 438 | |
@@ -440,32 +440,32 @@ discard block |
||
440 | 440 | * Prepare date formats to be in Gravity Forms DB format; |
441 | 441 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
442 | 442 | */ |
443 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
443 | + foreach (array('start_date', 'end_date') as $key) { |
|
444 | 444 | |
445 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
445 | + if (!empty($criteria['search_criteria'][$key])) { |
|
446 | 446 | |
447 | 447 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
448 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
448 | + $date = date_create($criteria['search_criteria'][$key]); |
|
449 | 449 | |
450 | - if ( $date ) { |
|
450 | + if ($date) { |
|
451 | 451 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
452 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
452 | + $criteria['search_criteria'][$key] = $date->format('Y-m-d H:i:s'); |
|
453 | 453 | } else { |
454 | 454 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
455 | - unset( $criteria['search_criteria'][ $key ] ); |
|
455 | + unset($criteria['search_criteria'][$key]); |
|
456 | 456 | |
457 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
457 | + do_action('gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][$key]); |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
462 | 462 | |
463 | 463 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
464 | - if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->single_entry ) { |
|
464 | + if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->single_entry) { |
|
465 | 465 | $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
466 | - } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
|
467 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
|
468 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
466 | + } elseif ('delete' === RGForms::get('action')) { |
|
467 | + $criteria['context_view_id'] = isset($_GET['view_id']) ? $_GET['view_id'] : null; |
|
468 | + } elseif (!isset($criteria['context_view_id'])) { |
|
469 | 469 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
470 | 470 | $criteria['context_view_id'] = null; |
471 | 471 | } |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @param array $form_ids Forms to search |
477 | 477 | * @param int $view_id ID of the view being used to search |
478 | 478 | */ |
479 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
479 | + $criteria = apply_filters('gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id']); |
|
480 | 480 | |
481 | 481 | return $criteria; |
482 | 482 | |
@@ -494,32 +494,32 @@ discard block |
||
494 | 494 | * @param mixed &$total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate the total count. (default: null) |
495 | 495 | * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays |
496 | 496 | */ |
497 | - public static function get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { |
|
497 | + public static function get_entries($form_ids = null, $passed_criteria = null, &$total = null) { |
|
498 | 498 | |
499 | 499 | // Filter the criteria before query (includes Adv Filter) |
500 | - $criteria = self::calculate_get_entries_criteria( $passed_criteria, $form_ids ); |
|
500 | + $criteria = self::calculate_get_entries_criteria($passed_criteria, $form_ids); |
|
501 | 501 | |
502 | - do_action( 'gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria ); |
|
502 | + do_action('gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria); |
|
503 | 503 | |
504 | 504 | // Return value |
505 | 505 | $return = null; |
506 | 506 | |
507 | - if ( ! empty( $criteria['cache'] ) ) { |
|
507 | + if (!empty($criteria['cache'])) { |
|
508 | 508 | |
509 | - $Cache = new GravityView_Cache( $form_ids, $criteria ); |
|
509 | + $Cache = new GravityView_Cache($form_ids, $criteria); |
|
510 | 510 | |
511 | - if ( $entries = $Cache->get() ) { |
|
511 | + if ($entries = $Cache->get()) { |
|
512 | 512 | |
513 | 513 | // Still update the total count when using cached results |
514 | - if ( ! is_null( $total ) ) { |
|
515 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
514 | + if (!is_null($total)) { |
|
515 | + $total = GFAPI::count_entries($form_ids, $criteria['search_criteria']); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | $return = $entries; |
519 | 519 | } |
520 | 520 | } |
521 | 521 | |
522 | - if ( is_null( $return ) && class_exists( 'GFAPI' ) && ( is_numeric( $form_ids ) || is_array( $form_ids ) ) ) { |
|
522 | + if (is_null($return) && class_exists('GFAPI') && (is_numeric($form_ids) || is_array($form_ids))) { |
|
523 | 523 | |
524 | 524 | /** |
525 | 525 | * @filter `gravityview_pre_get_entries` Define entries to be used before GFAPI::get_entries() is called |
@@ -529,24 +529,24 @@ discard block |
||
529 | 529 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
530 | 530 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
531 | 531 | */ |
532 | - $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
|
532 | + $entries = apply_filters('gravityview_before_get_entries', null, $criteria, $passed_criteria, $total); |
|
533 | 533 | |
534 | 534 | // No entries returned from gravityview_before_get_entries |
535 | - if( is_null( $entries ) ) { |
|
535 | + if (is_null($entries)) { |
|
536 | 536 | |
537 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
537 | + $entries = GFAPI::get_entries($form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total); |
|
538 | 538 | |
539 | - if ( is_wp_error( $entries ) ) { |
|
540 | - do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
|
539 | + if (is_wp_error($entries)) { |
|
540 | + do_action('gravityview_log_error', $entries->get_error_message(), $entries); |
|
541 | 541 | |
542 | 542 | return false; |
543 | 543 | } |
544 | 544 | } |
545 | 545 | |
546 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
546 | + if (!empty($criteria['cache']) && isset($Cache)) { |
|
547 | 547 | |
548 | 548 | // Cache results |
549 | - $Cache->set( $entries, 'entries' ); |
|
549 | + $Cache->set($entries, 'entries'); |
|
550 | 550 | |
551 | 551 | } |
552 | 552 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
561 | 561 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
562 | 562 | */ |
563 | - $return = apply_filters( 'gravityview_entries', $return, $criteria, $passed_criteria, $total ); |
|
563 | + $return = apply_filters('gravityview_entries', $return, $criteria, $passed_criteria, $total); |
|
564 | 564 | |
565 | 565 | return $return; |
566 | 566 | } |
@@ -577,15 +577,15 @@ discard block |
||
577 | 577 | * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true. {@since 1.14} |
578 | 578 | * @return array|boolean |
579 | 579 | */ |
580 | - public static function get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) { |
|
580 | + public static function get_entry($entry_slug, $force_allow_ids = false, $check_entry_display = true) { |
|
581 | 581 | |
582 | - if ( class_exists( 'GFAPI' ) && ! empty( $entry_slug ) ) { |
|
582 | + if (class_exists('GFAPI') && !empty($entry_slug)) { |
|
583 | 583 | |
584 | 584 | /** |
585 | 585 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
586 | 586 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
587 | 587 | */ |
588 | - $custom_slug = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
588 | + $custom_slug = apply_filters('gravityview_custom_entry_slug', false); |
|
589 | 589 | |
590 | 590 | /** |
591 | 591 | * @filter `gravityview_custom_entry_slug_allow_id` When using a custom slug, allow access to the entry using the original slug (the Entry ID). |
@@ -593,38 +593,38 @@ discard block |
||
593 | 593 | * - If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`) |
594 | 594 | * @param boolean $custom_slug_id_access True: allow accessing the slug by ID; False: only use the slug passed to the method. |
595 | 595 | */ |
596 | - $custom_slug_id_access = $force_allow_ids || apply_filters( 'gravityview_custom_entry_slug_allow_id', false ); |
|
596 | + $custom_slug_id_access = $force_allow_ids || apply_filters('gravityview_custom_entry_slug_allow_id', false); |
|
597 | 597 | |
598 | 598 | /** |
599 | 599 | * If we're using custom entry slugs, we do a meta value search |
600 | 600 | * instead of doing a straightup ID search. |
601 | 601 | */ |
602 | - if ( $custom_slug ) { |
|
602 | + if ($custom_slug) { |
|
603 | 603 | |
604 | - $entry_id = self::get_entry_id_from_slug( $entry_slug ); |
|
604 | + $entry_id = self::get_entry_id_from_slug($entry_slug); |
|
605 | 605 | |
606 | 606 | } |
607 | 607 | |
608 | 608 | // If custom slug is off, search using the entry ID |
609 | 609 | // ID allow ID access is on, also use entry ID as a backup |
610 | - if ( empty( $custom_slug ) || ! empty( $custom_slug_id_access ) ) { |
|
610 | + if (empty($custom_slug) || !empty($custom_slug_id_access)) { |
|
611 | 611 | // Search for IDs matching $entry_slug |
612 | 612 | $entry_id = $entry_slug; |
613 | 613 | } |
614 | 614 | |
615 | - if ( empty( $entry_id ) ) { |
|
615 | + if (empty($entry_id)) { |
|
616 | 616 | return false; |
617 | 617 | } |
618 | 618 | |
619 | 619 | // fetch the entry |
620 | - $entry = GFAPI::get_entry( $entry_id ); |
|
620 | + $entry = GFAPI::get_entry($entry_id); |
|
621 | 621 | |
622 | - if( $check_entry_display ) { |
|
622 | + if ($check_entry_display) { |
|
623 | 623 | // Is the entry allowed |
624 | - $entry = self::check_entry_display( $entry ); |
|
624 | + $entry = self::check_entry_display($entry); |
|
625 | 625 | } |
626 | 626 | |
627 | - return is_wp_error( $entry ) ? false : $entry; |
|
627 | + return is_wp_error($entry) ? false : $entry; |
|
628 | 628 | |
629 | 629 | } |
630 | 630 | |
@@ -648,51 +648,51 @@ discard block |
||
648 | 648 | * |
649 | 649 | * @return bool True: matches, false: not matches |
650 | 650 | */ |
651 | - public static function matches_operation( $val1, $val2, $operation ) { |
|
651 | + public static function matches_operation($val1, $val2, $operation) { |
|
652 | 652 | |
653 | 653 | $value = false; |
654 | 654 | |
655 | - if( 'context' === $val1 ) { |
|
655 | + if ('context' === $val1) { |
|
656 | 656 | |
657 | - $matching_contexts = array( $val2 ); |
|
657 | + $matching_contexts = array($val2); |
|
658 | 658 | |
659 | 659 | // We allow for non-standard contexts. |
660 | - switch( $val2 ) { |
|
660 | + switch ($val2) { |
|
661 | 661 | // Check for either single or edit |
662 | 662 | case 'singular': |
663 | - $matching_contexts = array( 'single', 'edit' ); |
|
663 | + $matching_contexts = array('single', 'edit'); |
|
664 | 664 | break; |
665 | 665 | // Use multiple as alias for directory for consistency |
666 | 666 | case 'multiple': |
667 | - $matching_contexts = array( 'directory' ); |
|
667 | + $matching_contexts = array('directory'); |
|
668 | 668 | break; |
669 | 669 | } |
670 | 670 | |
671 | - $val1 = in_array( gravityview_get_context(), $matching_contexts ) ? $val2 : false; |
|
671 | + $val1 = in_array(gravityview_get_context(), $matching_contexts) ? $val2 : false; |
|
672 | 672 | } |
673 | 673 | |
674 | - switch ( $operation ) { |
|
674 | + switch ($operation) { |
|
675 | 675 | case 'equals': |
676 | - $value = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
676 | + $value = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
677 | 677 | break; |
678 | 678 | case 'greater_than_or_is': |
679 | 679 | case 'greater_than_or_equals': |
680 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
681 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'greater_than' ); |
|
682 | - $value = ( $is || $gt ); |
|
680 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
681 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'greater_than'); |
|
682 | + $value = ($is || $gt); |
|
683 | 683 | break; |
684 | 684 | case 'less_than_or_is': |
685 | 685 | case 'less_than_or_equals': |
686 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
687 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'less_than' ); |
|
688 | - $value = ( $is || $gt ); |
|
686 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
687 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'less_than'); |
|
688 | + $value = ($is || $gt); |
|
689 | 689 | break; |
690 | 690 | case 'not_contains': |
691 | - $contains = GFFormsModel::matches_operation( $val1, $val2, 'contains' ); |
|
692 | - $value = ! $contains; |
|
691 | + $contains = GFFormsModel::matches_operation($val1, $val2, 'contains'); |
|
692 | + $value = !$contains; |
|
693 | 693 | break; |
694 | 694 | default: |
695 | - $value = GFFormsModel::matches_operation( $val1, $val2, $operation ); |
|
695 | + $value = GFFormsModel::matches_operation($val1, $val2, $operation); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | return $value; |
@@ -709,31 +709,31 @@ discard block |
||
709 | 709 | * @param array $entry Gravity Forms Entry object |
710 | 710 | * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter) |
711 | 711 | */ |
712 | - public static function check_entry_display( $entry ) { |
|
712 | + public static function check_entry_display($entry) { |
|
713 | 713 | |
714 | - if ( ! $entry || is_wp_error( $entry ) ) { |
|
715 | - do_action( 'gravityview_log_debug', __METHOD__ . ' Entry was not found.', $entry ); |
|
714 | + if (!$entry || is_wp_error($entry)) { |
|
715 | + do_action('gravityview_log_debug', __METHOD__.' Entry was not found.', $entry); |
|
716 | 716 | return false; |
717 | 717 | } |
718 | 718 | |
719 | - if ( empty( $entry['form_id'] ) ) { |
|
720 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
|
719 | + if (empty($entry['form_id'])) { |
|
720 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry); |
|
721 | 721 | return false; |
722 | 722 | } |
723 | 723 | |
724 | 724 | $criteria = self::calculate_get_entries_criteria(); |
725 | 725 | |
726 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
727 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
|
726 | + if (empty($criteria['search_criteria']) || !is_array($criteria['search_criteria'])) { |
|
727 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria); |
|
728 | 728 | return $entry; |
729 | 729 | } |
730 | 730 | |
731 | 731 | $search_criteria = $criteria['search_criteria']; |
732 | - unset( $criteria ); |
|
732 | + unset($criteria); |
|
733 | 733 | |
734 | 734 | // check entry status |
735 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
736 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
735 | + if (array_key_exists('status', $search_criteria) && $search_criteria['status'] != $entry['status']) { |
|
736 | + do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status']), $search_criteria); |
|
737 | 737 | return false; |
738 | 738 | } |
739 | 739 | |
@@ -741,53 +741,53 @@ discard block |
||
741 | 741 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
742 | 742 | |
743 | 743 | // field_filters |
744 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
745 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
|
744 | + if (empty($search_criteria['field_filters']) || !is_array($search_criteria['field_filters'])) { |
|
745 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria); |
|
746 | 746 | return $entry; |
747 | 747 | } |
748 | 748 | |
749 | 749 | $filters = $search_criteria['field_filters']; |
750 | - unset( $search_criteria ); |
|
750 | + unset($search_criteria); |
|
751 | 751 | |
752 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
753 | - unset( $filters['mode'] ); |
|
752 | + $mode = array_key_exists('mode', $filters) ? strtolower($filters['mode']) : 'all'; |
|
753 | + unset($filters['mode']); |
|
754 | 754 | |
755 | - $form = self::get_form( $entry['form_id'] ); |
|
755 | + $form = self::get_form($entry['form_id']); |
|
756 | 756 | |
757 | - foreach ( $filters as $filter ) { |
|
757 | + foreach ($filters as $filter) { |
|
758 | 758 | |
759 | - if ( ! isset( $filter['key'] ) ) { |
|
759 | + if (!isset($filter['key'])) { |
|
760 | 760 | continue; |
761 | 761 | } |
762 | 762 | |
763 | 763 | $k = $filter['key']; |
764 | 764 | |
765 | - if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
|
766 | - $field_value = $entry[ $k ]; |
|
765 | + if (in_array($k, array('created_by', 'payment_status'))) { |
|
766 | + $field_value = $entry[$k]; |
|
767 | 767 | $field = null; |
768 | 768 | } else { |
769 | - $field = self::get_field( $form, $k ); |
|
770 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
769 | + $field = self::get_field($form, $k); |
|
770 | + $field_value = GFFormsModel::get_lead_field_value($entry, $field); |
|
771 | 771 | } |
772 | 772 | |
773 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
774 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
773 | + $operator = isset($filter['operator']) ? strtolower($filter['operator']) : 'is'; |
|
774 | + $is_value_match = GFFormsModel::is_value_match($field_value, $filter['value'], $operator, $field); |
|
775 | 775 | |
776 | 776 | // verify if we are already free to go! |
777 | - if ( ! $is_value_match && 'all' === $mode ) { |
|
778 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter ); |
|
777 | + if (!$is_value_match && 'all' === $mode) { |
|
778 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter); |
|
779 | 779 | return false; |
780 | - } elseif ( $is_value_match && 'any' === $mode ) { |
|
780 | + } elseif ($is_value_match && 'any' === $mode) { |
|
781 | 781 | return $entry; |
782 | 782 | } |
783 | 783 | } |
784 | 784 | |
785 | 785 | // at this point, if in ALL mode, then entry is approved - all conditions were met. |
786 | 786 | // Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved |
787 | - if ( 'all' === $mode ) { |
|
787 | + if ('all' === $mode) { |
|
788 | 788 | return $entry; |
789 | 789 | } else { |
790 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
790 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters); |
|
791 | 791 | return false; |
792 | 792 | } |
793 | 793 | |
@@ -802,14 +802,14 @@ discard block |
||
802 | 802 | * @param string $field_id |
803 | 803 | * @return string |
804 | 804 | */ |
805 | - public static function get_field_label( $form = array(), $field_id = '' ) { |
|
805 | + public static function get_field_label($form = array(), $field_id = '') { |
|
806 | 806 | |
807 | - if ( empty( $form ) || empty( $field_id ) ) { |
|
807 | + if (empty($form) || empty($field_id)) { |
|
808 | 808 | return ''; |
809 | 809 | } |
810 | 810 | |
811 | - $field = self::get_field( $form, $field_id ); |
|
812 | - return isset( $field['label'] ) ? $field['label'] : ''; |
|
811 | + $field = self::get_field($form, $field_id); |
|
812 | + return isset($field['label']) ? $field['label'] : ''; |
|
813 | 813 | |
814 | 814 | } |
815 | 815 | |
@@ -826,9 +826,9 @@ discard block |
||
826 | 826 | * @param string|int $field_id |
827 | 827 | * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist |
828 | 828 | */ |
829 | - public static function get_field( $form, $field_id ) { |
|
830 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
831 | - return GFFormsModel::get_field( $form, $field_id ); |
|
829 | + public static function get_field($form, $field_id) { |
|
830 | + if (class_exists('GFFormsModel')) { |
|
831 | + return GFFormsModel::get_field($form, $field_id); |
|
832 | 832 | } else { |
833 | 833 | return null; |
834 | 834 | } |
@@ -844,16 +844,16 @@ discard block |
||
844 | 844 | * @param WP_Post $post WordPress post object |
845 | 845 | * @return boolean True: yep, GravityView; No: not! |
846 | 846 | */ |
847 | - public static function has_gravityview_shortcode( $post = null ) { |
|
848 | - if ( ! is_a( $post, 'WP_Post' ) ) { |
|
847 | + public static function has_gravityview_shortcode($post = null) { |
|
848 | + if (!is_a($post, 'WP_Post')) { |
|
849 | 849 | return false; |
850 | 850 | } |
851 | 851 | |
852 | - if ( 'gravityview' === get_post_type( $post ) ) { |
|
852 | + if ('gravityview' === get_post_type($post)) { |
|
853 | 853 | return true; |
854 | 854 | } |
855 | 855 | |
856 | - return self::has_shortcode_r( $post->post_content, 'gravityview' ) ? true : false; |
|
856 | + return self::has_shortcode_r($post->post_content, 'gravityview') ? true : false; |
|
857 | 857 | |
858 | 858 | } |
859 | 859 | |
@@ -864,27 +864,27 @@ discard block |
||
864 | 864 | * @param string $content Content to check whether there's a shortcode |
865 | 865 | * @param string $tag Current shortcode tag |
866 | 866 | */ |
867 | - public static function has_shortcode_r( $content, $tag = 'gravityview' ) { |
|
868 | - if ( false === strpos( $content, '[' ) ) { |
|
867 | + public static function has_shortcode_r($content, $tag = 'gravityview') { |
|
868 | + if (false === strpos($content, '[')) { |
|
869 | 869 | return false; |
870 | 870 | } |
871 | 871 | |
872 | - if ( shortcode_exists( $tag ) ) { |
|
872 | + if (shortcode_exists($tag)) { |
|
873 | 873 | |
874 | 874 | $shortcodes = array(); |
875 | 875 | |
876 | - preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
|
877 | - if ( empty( $matches ) ){ |
|
876 | + preg_match_all('/'.get_shortcode_regex().'/s', $content, $matches, PREG_SET_ORDER); |
|
877 | + if (empty($matches)) { |
|
878 | 878 | return false; |
879 | 879 | } |
880 | 880 | |
881 | - foreach ( $matches as $shortcode ) { |
|
882 | - if ( $tag === $shortcode[2] ) { |
|
881 | + foreach ($matches as $shortcode) { |
|
882 | + if ($tag === $shortcode[2]) { |
|
883 | 883 | |
884 | 884 | // Changed this to $shortcode instead of true so we get the parsed atts. |
885 | 885 | $shortcodes[] = $shortcode; |
886 | 886 | |
887 | - } else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
887 | + } else if (isset($shortcode[5]) && $result = self::has_shortcode_r($shortcode[5], $tag)) { |
|
888 | 888 | $shortcodes = $result; |
889 | 889 | } |
890 | 890 | } |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | * |
909 | 909 | * @return array Array with view details, as returned by get_posts() |
910 | 910 | */ |
911 | - public static function get_connected_views( $form_id, $args = array() ) { |
|
911 | + public static function get_connected_views($form_id, $args = array()) { |
|
912 | 912 | |
913 | 913 | $defaults = array( |
914 | 914 | 'post_type' => 'gravityview', |
@@ -917,9 +917,9 @@ discard block |
||
917 | 917 | 'meta_value' => (int)$form_id, |
918 | 918 | ); |
919 | 919 | |
920 | - $args = wp_parse_args( $args, $defaults ); |
|
920 | + $args = wp_parse_args($args, $defaults); |
|
921 | 921 | |
922 | - $views = get_posts( $args ); |
|
922 | + $views = get_posts($args); |
|
923 | 923 | |
924 | 924 | return $views; |
925 | 925 | } |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | * |
932 | 932 | * @return string ID of the connected Form, if exists. Empty string if not. |
933 | 933 | */ |
934 | - public static function get_meta_form_id( $view_id ) { |
|
935 | - return get_post_meta( $view_id, '_gravityview_form_id', true ); |
|
934 | + public static function get_meta_form_id($view_id) { |
|
935 | + return get_post_meta($view_id, '_gravityview_form_id', true); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | /** |
@@ -944,8 +944,8 @@ discard block |
||
944 | 944 | * |
945 | 945 | * @return string GravityView_Template::template_id value. Empty string if not. |
946 | 946 | */ |
947 | - public static function get_meta_template_id( $view_id ) { |
|
948 | - return get_post_meta( $view_id, '_gravityview_directory_template', true ); |
|
947 | + public static function get_meta_template_id($view_id) { |
|
948 | + return get_post_meta($view_id, '_gravityview_directory_template', true); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | |
@@ -956,15 +956,15 @@ discard block |
||
956 | 956 | * @param int $post_id View ID |
957 | 957 | * @return array Associative array of settings with plugin defaults used if not set by the View |
958 | 958 | */ |
959 | - public static function get_template_settings( $post_id ) { |
|
959 | + public static function get_template_settings($post_id) { |
|
960 | 960 | |
961 | - $settings = get_post_meta( $post_id, '_gravityview_template_settings', true ); |
|
961 | + $settings = get_post_meta($post_id, '_gravityview_template_settings', true); |
|
962 | 962 | |
963 | - if ( class_exists( 'GravityView_View_Data' ) ) { |
|
963 | + if (class_exists('GravityView_View_Data')) { |
|
964 | 964 | |
965 | 965 | $defaults = GravityView_View_Data::get_default_args(); |
966 | 966 | |
967 | - return wp_parse_args( (array)$settings, $defaults ); |
|
967 | + return wp_parse_args((array)$settings, $defaults); |
|
968 | 968 | |
969 | 969 | } |
970 | 970 | |
@@ -981,12 +981,12 @@ discard block |
||
981 | 981 | * @param string $key Key for the setting |
982 | 982 | * @return mixed|null Setting value, or NULL if not set. |
983 | 983 | */ |
984 | - public static function get_template_setting( $post_id, $key ) { |
|
984 | + public static function get_template_setting($post_id, $key) { |
|
985 | 985 | |
986 | - $settings = self::get_template_settings( $post_id ); |
|
986 | + $settings = self::get_template_settings($post_id); |
|
987 | 987 | |
988 | - if ( isset( $settings[ $key ] ) ) { |
|
989 | - return $settings[ $key ]; |
|
988 | + if (isset($settings[$key])) { |
|
989 | + return $settings[$key]; |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | return null; |
@@ -1022,8 +1022,8 @@ discard block |
||
1022 | 1022 | * @param int $post_id View ID |
1023 | 1023 | * @return array Multi-array of fields with first level being the field zones. See code comment. |
1024 | 1024 | */ |
1025 | - public static function get_directory_fields( $post_id ) { |
|
1026 | - return get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
|
1025 | + public static function get_directory_fields($post_id) { |
|
1026 | + return get_post_meta($post_id, '_gravityview_directory_fields', true); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | |
@@ -1034,25 +1034,25 @@ discard block |
||
1034 | 1034 | * @param int $formid Form ID |
1035 | 1035 | * @return string html |
1036 | 1036 | */ |
1037 | - public static function get_sortable_fields( $formid, $current = '' ) { |
|
1038 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1037 | + public static function get_sortable_fields($formid, $current = '') { |
|
1038 | + $output = '<option value="" '.selected('', $current, false).'>'.esc_html__('Default', 'gravityview').'</option>'; |
|
1039 | 1039 | |
1040 | - if ( empty( $formid ) ) { |
|
1040 | + if (empty($formid)) { |
|
1041 | 1041 | return $output; |
1042 | 1042 | } |
1043 | 1043 | |
1044 | - $fields = self::get_sortable_fields_array( $formid ); |
|
1044 | + $fields = self::get_sortable_fields_array($formid); |
|
1045 | 1045 | |
1046 | - if ( ! empty( $fields ) ) { |
|
1046 | + if (!empty($fields)) { |
|
1047 | 1047 | |
1048 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
|
1048 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('list', 'textarea'), null); |
|
1049 | 1049 | |
1050 | - foreach ( $fields as $id => $field ) { |
|
1051 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1050 | + foreach ($fields as $id => $field) { |
|
1051 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
1052 | 1052 | continue; |
1053 | 1053 | } |
1054 | 1054 | |
1055 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1055 | + $output .= '<option value="'.$id.'" '.selected($id, $current, false).'>'.esc_attr($field['label']).'</option>'; |
|
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | |
@@ -1070,27 +1070,27 @@ discard block |
||
1070 | 1070 | * |
1071 | 1071 | * @return array |
1072 | 1072 | */ |
1073 | - public static function get_sortable_fields_array( $formid, $blacklist = array( 'list', 'textarea' ) ) { |
|
1073 | + public static function get_sortable_fields_array($formid, $blacklist = array('list', 'textarea')) { |
|
1074 | 1074 | |
1075 | 1075 | // Get fields with sub-inputs and no parent |
1076 | - $fields = self::get_form_fields( $formid, true, false ); |
|
1076 | + $fields = self::get_form_fields($formid, true, false); |
|
1077 | 1077 | |
1078 | 1078 | $date_created = array( |
1079 | 1079 | 'date_created' => array( |
1080 | 1080 | 'type' => 'date_created', |
1081 | - 'label' => __( 'Date Created', 'gravityview' ), |
|
1081 | + 'label' => __('Date Created', 'gravityview'), |
|
1082 | 1082 | ), |
1083 | 1083 | ); |
1084 | 1084 | |
1085 | 1085 | $fields = $date_created + $fields; |
1086 | 1086 | |
1087 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
|
1087 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', $blacklist, NULL); |
|
1088 | 1088 | |
1089 | 1089 | // TODO: Convert to using array_filter |
1090 | - foreach( $fields as $id => $field ) { |
|
1090 | + foreach ($fields as $id => $field) { |
|
1091 | 1091 | |
1092 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1093 | - unset( $fields[ $id ] ); |
|
1092 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
1093 | + unset($fields[$id]); |
|
1094 | 1094 | } |
1095 | 1095 | } |
1096 | 1096 | |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | * @param array $fields Sub-set of GF form fields that are sortable |
1101 | 1101 | * @param int $formid The Gravity Forms form ID that the fields are from |
1102 | 1102 | */ |
1103 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1103 | + $fields = apply_filters('gravityview/common/sortable_fields', $fields, $formid); |
|
1104 | 1104 | |
1105 | 1105 | return $fields; |
1106 | 1106 | } |
@@ -1111,15 +1111,15 @@ discard block |
||
1111 | 1111 | * @param mixed $field_id Field ID or Field array |
1112 | 1112 | * @return string field type |
1113 | 1113 | */ |
1114 | - public static function get_field_type( $form = null, $field_id = '' ) { |
|
1114 | + public static function get_field_type($form = null, $field_id = '') { |
|
1115 | 1115 | |
1116 | - if ( ! empty( $field_id ) && ! is_array( $field_id ) ) { |
|
1117 | - $field = self::get_field( $form, $field_id ); |
|
1116 | + if (!empty($field_id) && !is_array($field_id)) { |
|
1117 | + $field = self::get_field($form, $field_id); |
|
1118 | 1118 | } else { |
1119 | 1119 | $field = $field_id; |
1120 | 1120 | } |
1121 | 1121 | |
1122 | - return class_exists( 'RGFormsModel' ) ? RGFormsModel::get_input_type( $field ) : ''; |
|
1122 | + return class_exists('RGFormsModel') ? RGFormsModel::get_input_type($field) : ''; |
|
1123 | 1123 | |
1124 | 1124 | } |
1125 | 1125 | |
@@ -1130,22 +1130,22 @@ discard block |
||
1130 | 1130 | * @param int|array $field field key or field array |
1131 | 1131 | * @return boolean |
1132 | 1132 | */ |
1133 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1133 | + public static function is_field_numeric($form = null, $field = '') { |
|
1134 | 1134 | |
1135 | 1135 | /** |
1136 | 1136 | * @filter `gravityview/common/numeric_types` What types of fields are numeric? |
1137 | 1137 | * @since 1.5.2 |
1138 | 1138 | * @param array $numeric_types Fields that are numeric. Default: `[ number, time ]` |
1139 | 1139 | */ |
1140 | - $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
|
1140 | + $numeric_types = apply_filters('gravityview/common/numeric_types', array('number', 'time')); |
|
1141 | 1141 | |
1142 | - if ( ! is_array( $form ) && ! is_array( $field ) ) { |
|
1143 | - $form = self::get_form( $form ); |
|
1142 | + if (!is_array($form) && !is_array($field)) { |
|
1143 | + $form = self::get_form($form); |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | - $type = self::get_field_type( $form, $field ); |
|
1146 | + $type = self::get_field_type($form, $field); |
|
1147 | 1147 | |
1148 | - return in_array( $type, $numeric_types ); |
|
1148 | + return in_array($type, $numeric_types); |
|
1149 | 1149 | |
1150 | 1150 | } |
1151 | 1151 | |
@@ -1163,19 +1163,19 @@ discard block |
||
1163 | 1163 | * |
1164 | 1164 | * @return string Content, encrypted |
1165 | 1165 | */ |
1166 | - public static function js_encrypt( $content, $message = '' ) { |
|
1166 | + public static function js_encrypt($content, $message = '') { |
|
1167 | 1167 | |
1168 | 1168 | $output = $content; |
1169 | 1169 | |
1170 | - if ( ! class_exists( 'StandalonePHPEnkoder' ) ) { |
|
1171 | - include_once( GRAVITYVIEW_DIR . 'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php' ); |
|
1170 | + if (!class_exists('StandalonePHPEnkoder')) { |
|
1171 | + include_once(GRAVITYVIEW_DIR.'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php'); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | - if ( class_exists( 'StandalonePHPEnkoder' ) ) { |
|
1174 | + if (class_exists('StandalonePHPEnkoder')) { |
|
1175 | 1175 | |
1176 | 1176 | $enkoder = new StandalonePHPEnkoder; |
1177 | 1177 | |
1178 | - $message = empty( $message ) ? __( 'Email hidden; Javascript is required.', 'gravityview' ) : $message; |
|
1178 | + $message = empty($message) ? __('Email hidden; Javascript is required.', 'gravityview') : $message; |
|
1179 | 1179 | |
1180 | 1180 | /** |
1181 | 1181 | * @filter `gravityview/phpenkoder/msg` Modify the message shown when Javascript is disabled and an encrypted email field is displayed |
@@ -1183,9 +1183,9 @@ discard block |
||
1183 | 1183 | * @param string $message Existing message |
1184 | 1184 | * @param string $content Content to encrypt |
1185 | 1185 | */ |
1186 | - $enkoder->enkode_msg = apply_filters( 'gravityview/phpenkoder/msg', $message, $content ); |
|
1186 | + $enkoder->enkode_msg = apply_filters('gravityview/phpenkoder/msg', $message, $content); |
|
1187 | 1187 | |
1188 | - $output = $enkoder->enkode( $content ); |
|
1188 | + $output = $enkoder->enkode($content); |
|
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | return $output; |
@@ -1202,25 +1202,25 @@ discard block |
||
1202 | 1202 | * |
1203 | 1203 | * @author rubo77 at https://gist.github.com/rubo77/6821632 |
1204 | 1204 | **/ |
1205 | - public static function gv_parse_str( $string, &$result ) { |
|
1206 | - if ( empty( $string ) ) { |
|
1205 | + public static function gv_parse_str($string, &$result) { |
|
1206 | + if (empty($string)) { |
|
1207 | 1207 | return false; |
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | $result = array(); |
1211 | 1211 | |
1212 | 1212 | // find the pairs "name=value" |
1213 | - $pairs = explode( '&', $string ); |
|
1213 | + $pairs = explode('&', $string); |
|
1214 | 1214 | |
1215 | - foreach ( $pairs as $pair ) { |
|
1215 | + foreach ($pairs as $pair) { |
|
1216 | 1216 | // use the original parse_str() on each element |
1217 | - parse_str( $pair, $params ); |
|
1217 | + parse_str($pair, $params); |
|
1218 | 1218 | |
1219 | - $k = key( $params ); |
|
1220 | - if ( ! isset( $result[ $k ] ) ) { |
|
1219 | + $k = key($params); |
|
1220 | + if (!isset($result[$k])) { |
|
1221 | 1221 | $result += $params; |
1222 | - } elseif ( array_key_exists( $k, $params ) && is_array( $params[ $k ] ) ) { |
|
1223 | - $result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] ); |
|
1222 | + } elseif (array_key_exists($k, $params) && is_array($params[$k])) { |
|
1223 | + $result[$k] = self::array_merge_recursive_distinct($result[$k], $params[$k]); |
|
1224 | 1224 | } |
1225 | 1225 | } |
1226 | 1226 | return true; |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | * |
1243 | 1243 | * @return string HTML output of anchor link. If empty $href, returns NULL |
1244 | 1244 | */ |
1245 | - public static function get_link_html( $href = '', $anchor_text = '', $atts = array() ) { |
|
1245 | + public static function get_link_html($href = '', $anchor_text = '', $atts = array()) { |
|
1246 | 1246 | |
1247 | 1247 | // Supported attributes for anchor tags. HREF left out intentionally. |
1248 | 1248 | $allowed_atts = array( |
@@ -1278,31 +1278,31 @@ discard block |
||
1278 | 1278 | * @filter `gravityview/get_link/allowed_atts` Modify the attributes that are allowed to be used in generating links |
1279 | 1279 | * @param array $allowed_atts Array of attributes allowed |
1280 | 1280 | */ |
1281 | - $allowed_atts = apply_filters( 'gravityview/get_link/allowed_atts', $allowed_atts ); |
|
1281 | + $allowed_atts = apply_filters('gravityview/get_link/allowed_atts', $allowed_atts); |
|
1282 | 1282 | |
1283 | 1283 | // Make sure the attributes are formatted as array |
1284 | - $passed_atts = wp_parse_args( $atts ); |
|
1284 | + $passed_atts = wp_parse_args($atts); |
|
1285 | 1285 | |
1286 | 1286 | // Make sure the allowed attributes are only the ones in the $allowed_atts list |
1287 | - $final_atts = shortcode_atts( $allowed_atts, $passed_atts ); |
|
1287 | + $final_atts = shortcode_atts($allowed_atts, $passed_atts); |
|
1288 | 1288 | |
1289 | 1289 | // Remove attributes with empty values |
1290 | - $final_atts = array_filter( $final_atts ); |
|
1290 | + $final_atts = array_filter($final_atts); |
|
1291 | 1291 | |
1292 | 1292 | // If the href wasn't passed as an attribute, use the value passed to the function |
1293 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1293 | + if (empty($final_atts['href']) && !empty($href)) { |
|
1294 | 1294 | $final_atts['href'] = $href; |
1295 | 1295 | } |
1296 | 1296 | |
1297 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1297 | + $final_atts['href'] = esc_url_raw($href); |
|
1298 | 1298 | |
1299 | 1299 | // For each attribute, generate the code |
1300 | 1300 | $output = ''; |
1301 | - foreach ( $final_atts as $attr => $value ) { |
|
1302 | - $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
|
1301 | + foreach ($final_atts as $attr => $value) { |
|
1302 | + $output .= sprintf(' %s="%s"', $attr, esc_attr($value)); |
|
1303 | 1303 | } |
1304 | 1304 | |
1305 | - $output = '<a'. $output .'>'. $anchor_text .'</a>'; |
|
1305 | + $output = '<a'.$output.'>'.$anchor_text.'</a>'; |
|
1306 | 1306 | |
1307 | 1307 | return $output; |
1308 | 1308 | } |
@@ -1321,14 +1321,14 @@ discard block |
||
1321 | 1321 | * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk> |
1322 | 1322 | * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com> |
1323 | 1323 | */ |
1324 | - public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { |
|
1324 | + public static function array_merge_recursive_distinct(array &$array1, array &$array2) { |
|
1325 | 1325 | $merged = $array1; |
1326 | 1326 | |
1327 | - foreach ( $array2 as $key => &$value ) { |
|
1328 | - if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
|
1329 | - $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
|
1327 | + foreach ($array2 as $key => &$value) { |
|
1328 | + if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { |
|
1329 | + $merged[$key] = self::array_merge_recursive_distinct($merged[$key], $value); |
|
1330 | 1330 | } else { |
1331 | - $merged[ $key ] = $value; |
|
1331 | + $merged[$key] = $value; |
|
1332 | 1332 | } |
1333 | 1333 | } |
1334 | 1334 | |
@@ -1342,26 +1342,26 @@ discard block |
||
1342 | 1342 | * @param array $args Arguments to modify the user query. See get_users() {@since 1.14} |
1343 | 1343 | * @return array Array of WP_User objects. |
1344 | 1344 | */ |
1345 | - public static function get_users( $context = 'change_entry_creator', $args = array() ) { |
|
1345 | + public static function get_users($context = 'change_entry_creator', $args = array()) { |
|
1346 | 1346 | |
1347 | 1347 | $default_args = array( |
1348 | 1348 | 'number' => 2000, |
1349 | 1349 | 'orderby' => 'display_name', |
1350 | 1350 | 'order' => 'ASC', |
1351 | - 'fields' => array( 'ID', 'display_name', 'user_login', 'user_nicename' ) |
|
1351 | + 'fields' => array('ID', 'display_name', 'user_login', 'user_nicename') |
|
1352 | 1352 | ); |
1353 | 1353 | |
1354 | 1354 | // Merge in the passed arg |
1355 | - $get_users_settings = wp_parse_args( $args, $default_args ); |
|
1355 | + $get_users_settings = wp_parse_args($args, $default_args); |
|
1356 | 1356 | |
1357 | 1357 | /** |
1358 | 1358 | * @filter `gravityview/get_users/{$context}` There are issues with too many users using [get_users()](http://codex.wordpress.org/Function_Reference/get_users) where it breaks the select. We try to keep it at a reasonable number. \n |
1359 | 1359 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1360 | 1360 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1361 | 1361 | */ |
1362 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1362 | + $get_users_settings = apply_filters('gravityview/get_users/'.$context, apply_filters('gravityview_change_entry_creator_user_parameters', $get_users_settings)); |
|
1363 | 1363 | |
1364 | - return get_users( $get_users_settings ); |
|
1364 | + return get_users($get_users_settings); |
|
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | |
@@ -1373,8 +1373,8 @@ discard block |
||
1373 | 1373 | * |
1374 | 1374 | * @return string |
1375 | 1375 | */ |
1376 | - public static function generate_notice( $notice, $class = '' ) { |
|
1377 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1376 | + public static function generate_notice($notice, $class = '') { |
|
1377 | + return '<div class="gv-notice '.gravityview_sanitize_html_class($class).'">'.$notice.'</div>'; |
|
1378 | 1378 | } |
1379 | 1379 | |
1380 | 1380 | |
@@ -1396,6 +1396,6 @@ discard block |
||
1396 | 1396 | * |
1397 | 1397 | * @return string HTML output of anchor link. If empty $href, returns NULL |
1398 | 1398 | */ |
1399 | -function gravityview_get_link( $href = '', $anchor_text = '', $atts = array() ) { |
|
1400 | - return GVCommon::get_link_html( $href, $anchor_text, $atts ); |
|
1399 | +function gravityview_get_link($href = '', $anchor_text = '', $atts = array()) { |
|
1400 | + return GVCommon::get_link_html($href, $anchor_text, $atts); |
|
1401 | 1401 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** If this file is called directly, abort. */ |
4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | +if (!defined('ABSPATH')) { |
|
5 | 5 | die; |
6 | 6 | } |
7 | 7 | |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @param null $passed_post |
17 | 17 | */ |
18 | - private function __construct( $passed_post = NULL ) { |
|
18 | + private function __construct($passed_post = NULL) { |
|
19 | 19 | |
20 | - if( !empty( $passed_post ) ) { |
|
20 | + if (!empty($passed_post)) { |
|
21 | 21 | |
22 | - $id_or_id_array = $this->maybe_get_view_id( $passed_post ); |
|
22 | + $id_or_id_array = $this->maybe_get_view_id($passed_post); |
|
23 | 23 | |
24 | - if( !empty( $id_or_id_array ) ) { |
|
25 | - $this->add_view( $id_or_id_array ); |
|
24 | + if (!empty($id_or_id_array)) { |
|
25 | + $this->add_view($id_or_id_array); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public function has_multiple_views() { |
35 | 35 | |
36 | 36 | //multiple views |
37 | - return count( $this->get_views() ) > 1 ? true : false; |
|
37 | + return count($this->get_views()) > 1 ? true : false; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -52,37 +52,37 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return int|null|array ID of the View. If there are multiple views in the content, array of IDs parsed. |
54 | 54 | */ |
55 | - public function maybe_get_view_id( $passed_post ) { |
|
55 | + public function maybe_get_view_id($passed_post) { |
|
56 | 56 | |
57 | 57 | $ids = array(); |
58 | 58 | |
59 | - if( ! empty( $passed_post ) ) { |
|
59 | + if (!empty($passed_post)) { |
|
60 | 60 | |
61 | - if( is_numeric( $passed_post ) ) { |
|
62 | - $passed_post = get_post( $passed_post ); |
|
61 | + if (is_numeric($passed_post)) { |
|
62 | + $passed_post = get_post($passed_post); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Convert WP_Posts into WP_Posts[] array |
66 | - if( $passed_post instanceof WP_Post ) { |
|
67 | - $passed_post = array( $passed_post ); |
|
66 | + if ($passed_post instanceof WP_Post) { |
|
67 | + $passed_post = array($passed_post); |
|
68 | 68 | } |
69 | 69 | |
70 | - if( is_array( $passed_post ) ) { |
|
70 | + if (is_array($passed_post)) { |
|
71 | 71 | |
72 | - foreach ( $passed_post as &$post) { |
|
73 | - if( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
72 | + foreach ($passed_post as &$post) { |
|
73 | + if ((get_post_type($post) === 'gravityview')) { |
|
74 | 74 | $ids[] = $post->ID; |
75 | - } else{ |
|
75 | + } else { |
|
76 | 76 | // Parse the Post Content |
77 | - $id = $this->parse_post_content( $post->post_content ); |
|
78 | - if( $id ) { |
|
79 | - $ids = array_merge( $ids, (array) $id ); |
|
77 | + $id = $this->parse_post_content($post->post_content); |
|
78 | + if ($id) { |
|
79 | + $ids = array_merge($ids, (array)$id); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Parse the Post Meta |
83 | - $id = $this->parse_post_meta( $post->ID ); |
|
84 | - if( $id ) { |
|
85 | - $ids = array_merge( $ids, (array) $id ); |
|
83 | + $id = $this->parse_post_meta($post->ID); |
|
84 | + if ($id) { |
|
85 | + $ids = array_merge($ids, (array)$id); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -90,33 +90,33 @@ discard block |
||
90 | 90 | |
91 | 91 | } else { |
92 | 92 | |
93 | - if ( is_string( $passed_post ) ) { |
|
93 | + if (is_string($passed_post)) { |
|
94 | 94 | |
95 | - $id = $this->parse_post_content( $passed_post ); |
|
96 | - if( $id ) { |
|
97 | - $ids = array_merge( $ids, (array) $id ); |
|
95 | + $id = $this->parse_post_content($passed_post); |
|
96 | + if ($id) { |
|
97 | + $ids = array_merge($ids, (array)$id); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } else { |
101 | - $id = $this->get_id_from_atts( $passed_post ); |
|
102 | - $ids[] = intval( $id ); |
|
101 | + $id = $this->get_id_from_atts($passed_post); |
|
102 | + $ids[] = intval($id); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - if( empty($ids) ) { |
|
107 | + if (empty($ids)) { |
|
108 | 108 | return NULL; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // If it's just one ID, return that. |
112 | 112 | // Otherwise, return array of IDs |
113 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
113 | + return (sizeof($ids) === 1) ? $ids[0] : $ids; |
|
114 | 114 | } |
115 | 115 | |
116 | - public static function getInstance( $passed_post = NULL ) { |
|
116 | + public static function getInstance($passed_post = NULL) { |
|
117 | 117 | |
118 | - if( empty( self::$instance ) ) { |
|
119 | - self::$instance = new GravityView_View_Data( $passed_post ); |
|
118 | + if (empty(self::$instance)) { |
|
119 | + self::$instance = new GravityView_View_Data($passed_post); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return self::$instance; |
@@ -126,25 +126,25 @@ discard block |
||
126 | 126 | return $this->views; |
127 | 127 | } |
128 | 128 | |
129 | - function get_view( $view_id, $atts = NULL ) { |
|
129 | + function get_view($view_id, $atts = NULL) { |
|
130 | 130 | |
131 | - if( ! is_numeric( $view_id) ) { |
|
132 | - do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) ); |
|
131 | + if (!is_numeric($view_id)) { |
|
132 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id)); |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Backup: the view hasn't been fetched yet. Doing it now. |
137 | - if ( ! isset( $this->views[ $view_id ] ) ) { |
|
138 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) ); |
|
139 | - return $this->add_view( $view_id, $atts ); |
|
137 | + if (!isset($this->views[$view_id])) { |
|
138 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id)); |
|
139 | + return $this->add_view($view_id, $atts); |
|
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $this->views[ $view_id ] ) ) { |
|
143 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) ); |
|
142 | + if (empty($this->views[$view_id])) { |
|
143 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id)); |
|
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | |
147 | - return $this->views[ $view_id ]; |
|
147 | + return $this->views[$view_id]; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @return bool True if the post exists; otherwise, false. |
157 | 157 | * @since 1.0.0 |
158 | 158 | */ |
159 | - function view_exists( $view_id ) { |
|
160 | - return is_string( get_post_status( $view_id ) ); |
|
159 | + function view_exists($view_id) { |
|
160 | + return is_string(get_post_status($view_id)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -168,56 +168,56 @@ discard block |
||
168 | 168 | * @param array|string $atts Combine other attributes (eg. from shortcode) with the view settings (optional) |
169 | 169 | * @return type |
170 | 170 | */ |
171 | - function add_view( $view_id, $atts = NULL ) { |
|
171 | + function add_view($view_id, $atts = NULL) { |
|
172 | 172 | |
173 | 173 | // Handle array of IDs |
174 | - if( is_array( $view_id ) ) { |
|
175 | - foreach( $view_id as $id ) { |
|
174 | + if (is_array($view_id)) { |
|
175 | + foreach ($view_id as $id) { |
|
176 | 176 | |
177 | - $this->add_view( $id, $atts ); |
|
177 | + $this->add_view($id, $atts); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | return $this->views; |
181 | 181 | } |
182 | 182 | |
183 | 183 | // The view has been set already; returning stored view. |
184 | - if ( !empty( $this->views[ $view_id ] ) ) { |
|
185 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) ); |
|
186 | - return $this->views[ $view_id ]; |
|
184 | + if (!empty($this->views[$view_id])) { |
|
185 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id)); |
|
186 | + return $this->views[$view_id]; |
|
187 | 187 | } |
188 | 188 | |
189 | - if( ! $this->view_exists( $view_id ) ) { |
|
190 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) ); |
|
189 | + if (!$this->view_exists($view_id)) { |
|
190 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id)); |
|
191 | 191 | return false; |
192 | 192 | } |
193 | 193 | |
194 | - $form_id = gravityview_get_form_id( $view_id ); |
|
194 | + $form_id = gravityview_get_form_id($view_id); |
|
195 | 195 | |
196 | - if( empty( $form_id ) ) { |
|
196 | + if (empty($form_id)) { |
|
197 | 197 | |
198 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) ); |
|
198 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id)); |
|
199 | 199 | |
200 | 200 | return false; |
201 | 201 | } |
202 | 202 | |
203 | 203 | // Get the settings for the View ID |
204 | - $view_settings = gravityview_get_template_settings( $view_id ); |
|
204 | + $view_settings = gravityview_get_template_settings($view_id); |
|
205 | 205 | |
206 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings ); |
|
206 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings); |
|
207 | 207 | |
208 | 208 | // Merge the view settings with the defaults |
209 | - $view_defaults = wp_parse_args( $view_settings, self::get_default_args() ); |
|
209 | + $view_defaults = wp_parse_args($view_settings, self::get_default_args()); |
|
210 | 210 | |
211 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
211 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults); |
|
212 | 212 | |
213 | - if( ! empty( $atts ) && is_array( $atts ) ) { |
|
213 | + if (!empty($atts) && is_array($atts)) { |
|
214 | 214 | |
215 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
215 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts); |
|
216 | 216 | |
217 | 217 | // Get the settings from the shortcode and merge them with defaults. |
218 | - $atts = shortcode_atts( $view_defaults, $atts ); |
|
218 | + $atts = shortcode_atts($view_defaults, $atts); |
|
219 | 219 | |
220 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
220 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts); |
|
221 | 221 | |
222 | 222 | } else { |
223 | 223 | |
@@ -226,24 +226,24 @@ discard block |
||
226 | 226 | |
227 | 227 | } |
228 | 228 | |
229 | - unset( $atts['id'], $view_defaults, $view_settings ); |
|
229 | + unset($atts['id'], $view_defaults, $view_settings); |
|
230 | 230 | |
231 | 231 | $data = array( |
232 | 232 | 'id' => $view_id, |
233 | 233 | 'view_id' => $view_id, |
234 | 234 | 'form_id' => $form_id, |
235 | - 'template_id' => gravityview_get_template_id( $view_id ), |
|
235 | + 'template_id' => gravityview_get_template_id($view_id), |
|
236 | 236 | 'atts' => $atts, |
237 | - 'fields' => $this->get_fields( $view_id ), |
|
238 | - 'widgets' => get_post_meta( $view_id, '_gravityview_directory_widgets', true ), |
|
239 | - 'form' => gravityview_get_form( $form_id ), |
|
237 | + 'fields' => $this->get_fields($view_id), |
|
238 | + 'widgets' => get_post_meta($view_id, '_gravityview_directory_widgets', true), |
|
239 | + 'form' => gravityview_get_form($form_id), |
|
240 | 240 | ); |
241 | 241 | |
242 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data ); |
|
242 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data); |
|
243 | 243 | |
244 | - $this->views[ $view_id ] = $data; |
|
244 | + $this->views[$view_id] = $data; |
|
245 | 245 | |
246 | - return $this->views[ $view_id ]; |
|
246 | + return $this->views[$view_id]; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | * @param int $view_id View ID |
254 | 254 | * @return array Array of fields as passed by `gravityview_get_directory_fields()` |
255 | 255 | */ |
256 | - function get_fields( $view_id ) { |
|
256 | + function get_fields($view_id) { |
|
257 | 257 | |
258 | - $dir_fields = gravityview_get_directory_fields( $view_id ); |
|
259 | - do_action( 'gravityview_log_debug', '[render_view] Fields: ', $dir_fields ); |
|
258 | + $dir_fields = gravityview_get_directory_fields($view_id); |
|
259 | + do_action('gravityview_log_debug', '[render_view] Fields: ', $dir_fields); |
|
260 | 260 | |
261 | 261 | // remove fields according to visitor visibility permissions (if logged-in) |
262 | - $dir_fields = $this->filter_fields( $dir_fields ); |
|
263 | - do_action( 'gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields ); |
|
262 | + $dir_fields = $this->filter_fields($dir_fields); |
|
263 | + do_action('gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields); |
|
264 | 264 | |
265 | 265 | return $dir_fields; |
266 | 266 | } |
@@ -272,18 +272,18 @@ discard block |
||
272 | 272 | * @param array $dir_fields |
273 | 273 | * @return array |
274 | 274 | */ |
275 | - private function filter_fields( $dir_fields ) { |
|
275 | + private function filter_fields($dir_fields) { |
|
276 | 276 | |
277 | - if( empty( $dir_fields ) || !is_array( $dir_fields ) ) { |
|
277 | + if (empty($dir_fields) || !is_array($dir_fields)) { |
|
278 | 278 | return $dir_fields; |
279 | 279 | } |
280 | 280 | |
281 | - foreach( $dir_fields as $area => $fields ) { |
|
281 | + foreach ($dir_fields as $area => $fields) { |
|
282 | 282 | |
283 | - foreach( (array)$fields as $uniqid => $properties ) { |
|
283 | + foreach ((array)$fields as $uniqid => $properties) { |
|
284 | 284 | |
285 | - if( $this->hide_field_check_conditions( $properties ) ) { |
|
286 | - unset( $dir_fields[ $area ][ $uniqid ] ); |
|
285 | + if ($this->hide_field_check_conditions($properties)) { |
|
286 | + unset($dir_fields[$area][$uniqid]); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | } |
@@ -301,31 +301,31 @@ discard block |
||
301 | 301 | * @param array $properties |
302 | 302 | * @return void|boolean (field should be hidden) or false (field should be presented) |
303 | 303 | */ |
304 | - private function hide_field_check_conditions( $properties ) { |
|
304 | + private function hide_field_check_conditions($properties) { |
|
305 | 305 | |
306 | 306 | // logged-in visibility |
307 | - if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) { |
|
307 | + if (!empty($properties['only_loggedin']) && !GVCommon::has_cap($properties['only_loggedin_cap'])) { |
|
308 | 308 | return true; |
309 | 309 | } |
310 | 310 | |
311 | 311 | return false; |
312 | 312 | } |
313 | 313 | |
314 | - function get_id_from_atts( $atts ) { |
|
314 | + function get_id_from_atts($atts) { |
|
315 | 315 | |
316 | - $atts = is_array( $atts ) ? $atts : shortcode_parse_atts( $atts ); |
|
316 | + $atts = is_array($atts) ? $atts : shortcode_parse_atts($atts); |
|
317 | 317 | |
318 | 318 | // Get the settings from the shortcode and merge them with defaults. |
319 | - $atts = wp_parse_args( $atts, self::get_default_args() ); |
|
319 | + $atts = wp_parse_args($atts, self::get_default_args()); |
|
320 | 320 | |
321 | - $view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL; |
|
321 | + $view_id = !empty($atts['view_id']) ? (int)$atts['view_id'] : NULL; |
|
322 | 322 | |
323 | - if( empty( $view_id ) && !empty( $atts['id'] ) ) { |
|
323 | + if (empty($view_id) && !empty($atts['id'])) { |
|
324 | 324 | $view_id = (int)$atts['id']; |
325 | 325 | } |
326 | 326 | |
327 | - if( empty( $view_id ) ) { |
|
328 | - do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
327 | + if (empty($view_id)) { |
|
328 | + do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts); |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
@@ -341,50 +341,50 @@ discard block |
||
341 | 341 | * @param string $content $post->post_content content |
342 | 342 | * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, NULL |
343 | 343 | */ |
344 | - function parse_post_content( $content ) { |
|
344 | + function parse_post_content($content) { |
|
345 | 345 | |
346 | 346 | /** |
347 | 347 | * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin |
348 | 348 | * @since 1.6 |
349 | 349 | */ |
350 | - if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) { |
|
350 | + if (!shortcode_exists('gravityview') && class_exists('GravityView_Shortcode')) { |
|
351 | 351 | new GravityView_Shortcode; |
352 | 352 | } |
353 | 353 | |
354 | - $shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' ); |
|
354 | + $shortcodes = gravityview_has_shortcode_r($content, 'gravityview'); |
|
355 | 355 | |
356 | - if( empty( $shortcodes ) ) { |
|
356 | + if (empty($shortcodes)) { |
|
357 | 357 | return NULL; |
358 | 358 | } |
359 | 359 | |
360 | - do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
360 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes); |
|
361 | 361 | |
362 | 362 | $ids = array(); |
363 | 363 | |
364 | 364 | foreach ($shortcodes as $key => $shortcode) { |
365 | 365 | |
366 | - $args = shortcode_parse_atts( $shortcode[3] ); |
|
366 | + $args = shortcode_parse_atts($shortcode[3]); |
|
367 | 367 | |
368 | - if( empty( $args['id'] ) ) { |
|
369 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); |
|
368 | + if (empty($args['id'])) { |
|
369 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID), $shortcode); |
|
370 | 370 | continue; |
371 | 371 | } |
372 | 372 | |
373 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args ); |
|
373 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args); |
|
374 | 374 | |
375 | 375 | // Store the View to the object for later fetching. |
376 | - $this->add_view( $args['id'], $args ); |
|
376 | + $this->add_view($args['id'], $args); |
|
377 | 377 | |
378 | 378 | $ids[] = $args['id']; |
379 | 379 | } |
380 | 380 | |
381 | - if( empty($ids) ) { |
|
381 | + if (empty($ids)) { |
|
382 | 382 | return NULL; |
383 | 383 | } |
384 | 384 | |
385 | 385 | // If it's just one ID, return that. |
386 | 386 | // Otherwise, return array of IDs |
387 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
387 | + return (sizeof($ids) === 1) ? $ids[0] : $ids; |
|
388 | 388 | |
389 | 389 | } |
390 | 390 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * @param int $post_id WP_Post ID |
396 | 396 | * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, or meta not parsed, NULL |
397 | 397 | */ |
398 | - private function parse_post_meta( $post_id ) { |
|
398 | + private function parse_post_meta($post_id) { |
|
399 | 399 | |
400 | 400 | /** |
401 | 401 | * @filter `gravityview/data/parse/meta_keys` Define meta keys to parse to check for GravityView shortcode content |
@@ -403,32 +403,32 @@ discard block |
||
403 | 403 | * @param[in,out] array $meta_keys Array of key values to check. If empty, do not check. Default: empty array |
404 | 404 | * @param[in] int $post_id ID of the post being checked |
405 | 405 | */ |
406 | - $meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id ); |
|
406 | + $meta_keys = (array)apply_filters('gravityview/data/parse/meta_keys', array(), $post_id); |
|
407 | 407 | |
408 | - if( empty( $meta_keys ) ) { |
|
408 | + if (empty($meta_keys)) { |
|
409 | 409 | return NULL; |
410 | 410 | } |
411 | 411 | |
412 | - do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys ); |
|
412 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys); |
|
413 | 413 | |
414 | 414 | $meta_content = ''; |
415 | 415 | |
416 | - foreach( $meta_keys as $key ) { |
|
417 | - $meta = get_post_meta( $post_id, $key , true ); |
|
418 | - if( ! is_string( $meta ) ) { |
|
416 | + foreach ($meta_keys as $key) { |
|
417 | + $meta = get_post_meta($post_id, $key, true); |
|
418 | + if (!is_string($meta)) { |
|
419 | 419 | continue; |
420 | 420 | } |
421 | - $meta_content .= $meta . ' '; |
|
421 | + $meta_content .= $meta.' '; |
|
422 | 422 | } |
423 | 423 | |
424 | - if( empty( $meta_content ) ) { |
|
425 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); |
|
424 | + if (empty($meta_content)) { |
|
425 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id), $meta_keys); |
|
426 | 426 | return NULL; |
427 | 427 | } |
428 | 428 | |
429 | - do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content ); |
|
429 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content); |
|
430 | 430 | |
431 | - return $this->parse_post_content( $meta_content ); |
|
431 | + return $this->parse_post_content($meta_content); |
|
432 | 432 | |
433 | 433 | } |
434 | 434 | |
@@ -444,61 +444,61 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return bool|WP_Error If valid, returns true. If invalid, returns WP_Error containing error message. |
446 | 446 | */ |
447 | - public static function is_valid_embed_id( $post_id = '', $view_id = '', $empty_is_valid = true ) { |
|
447 | + public static function is_valid_embed_id($post_id = '', $view_id = '', $empty_is_valid = true) { |
|
448 | 448 | |
449 | 449 | $message = NULL; |
450 | 450 | |
451 | 451 | // Not invalid if not set! |
452 | - if( empty( $post_id ) || empty( $view_id ) ) { |
|
452 | + if (empty($post_id) || empty($view_id)) { |
|
453 | 453 | |
454 | - if( $empty_is_valid ) { |
|
454 | + if ($empty_is_valid) { |
|
455 | 455 | return true; |
456 | 456 | } |
457 | 457 | |
458 | - $message = esc_html__( 'The ID is required.', 'gravityview' ); |
|
458 | + $message = esc_html__('The ID is required.', 'gravityview'); |
|
459 | 459 | } |
460 | 460 | |
461 | - if( ! $message ) { |
|
462 | - $status = get_post_status( $post_id ); |
|
461 | + if (!$message) { |
|
462 | + $status = get_post_status($post_id); |
|
463 | 463 | |
464 | 464 | // Nothing exists with that post ID. |
465 | - if ( ! is_numeric( $post_id ) ) { |
|
466 | - $message = esc_html__( 'You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview' ); |
|
465 | + if (!is_numeric($post_id)) { |
|
466 | + $message = esc_html__('You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview'); |
|
467 | 467 | |
468 | 468 | // @todo Convert to generic article about Embed IDs |
469 | - $message .= ' ' . gravityview_get_link( 'http://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
469 | + $message .= ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview'), 'target=_blank'); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
473 | - if( ! $message ) { |
|
473 | + if (!$message) { |
|
474 | 474 | |
475 | 475 | // Nothing exists with that post ID. |
476 | - if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) { |
|
477 | - $message = esc_html__( 'There is no post or page with that ID.', 'gravityview' ); |
|
476 | + if (empty($status) || in_array($status, array('revision', 'attachment'))) { |
|
477 | + $message = esc_html__('There is no post or page with that ID.', 'gravityview'); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | } |
481 | 481 | |
482 | - if( ! $message ) { |
|
483 | - $view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); |
|
482 | + if (!$message) { |
|
483 | + $view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id($post_id); |
|
484 | 484 | |
485 | 485 | // The post or page specified does not contain the shortcode. |
486 | - if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { |
|
487 | - $message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' ); |
|
486 | + if (false === in_array($view_id, (array)$view_ids_in_post)) { |
|
487 | + $message = sprintf(esc_html__('The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview'), '<br /><code>[gravityview id="'.intval($view_id).'"]</code>'); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | - if( ! $message ) { |
|
491 | + if (!$message) { |
|
492 | 492 | |
493 | 493 | // It's a View |
494 | - if( 'gravityview' === get_post_type( $post_id ) ) { |
|
495 | - $message = esc_html__( 'The ID is already a View.', 'gravityview' );; |
|
494 | + if ('gravityview' === get_post_type($post_id)) { |
|
495 | + $message = esc_html__('The ID is already a View.', 'gravityview'); ; |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | } |
499 | 499 | |
500 | - if( $message ) { |
|
501 | - return new WP_Error( 'invalid_embed_id', $message ); |
|
500 | + if ($message) { |
|
501 | + return new WP_Error('invalid_embed_id', $message); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | return true; |
@@ -510,13 +510,13 @@ discard block |
||
510 | 510 | * @param boolean $with_details Include details |
511 | 511 | * @return mixed|array If using $with_details, return array. Otherwise, mixed. |
512 | 512 | */ |
513 | - public static function get_default_arg( $key, $with_details = false ) { |
|
513 | + public static function get_default_arg($key, $with_details = false) { |
|
514 | 514 | |
515 | - $args = self::get_default_args( $with_details ); |
|
515 | + $args = self::get_default_args($with_details); |
|
516 | 516 | |
517 | - if( !isset( $args[ $key ] ) ) { return NULL; } |
|
517 | + if (!isset($args[$key])) { return NULL; } |
|
518 | 518 | |
519 | - return $args[ $key ]; |
|
519 | + return $args[$key]; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -535,13 +535,13 @@ discard block |
||
535 | 535 | * @param[out] array $options Array of values to use when generating select, multiselect, radio, or checkboxes fields |
536 | 536 | * @param[out] boolean $full_width True: Display the input and label together when rendering. False: Display label and input in separate columns when rendering. |
537 | 537 | */ |
538 | - public static function get_default_args( $with_details = false, $group = NULL ) { |
|
538 | + public static function get_default_args($with_details = false, $group = NULL) { |
|
539 | 539 | |
540 | 540 | /** |
541 | 541 | * @filter `gravityview_default_args` Modify the default settings for new Views |
542 | 542 | * @param[in,out] array $default_args Array of default args. |
543 | 543 | */ |
544 | - $default_settings = apply_filters( 'gravityview_default_args', array( |
|
544 | + $default_settings = apply_filters('gravityview_default_args', array( |
|
545 | 545 | 'id' => array( |
546 | 546 | 'label' => __('View ID', 'gravityview'), |
547 | 547 | 'type' => 'number', |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | 'show_in_shortcode' => true, |
560 | 560 | ), |
561 | 561 | 'lightbox' => array( |
562 | - 'label' => __( 'Enable lightbox for images', 'gravityview' ), |
|
562 | + 'label' => __('Enable lightbox for images', 'gravityview'), |
|
563 | 563 | 'type' => 'checkbox', |
564 | 564 | 'group' => 'default', |
565 | 565 | 'value' => 1, |
@@ -567,29 +567,29 @@ discard block |
||
567 | 567 | 'show_in_shortcode' => true, |
568 | 568 | ), |
569 | 569 | 'show_only_approved' => array( |
570 | - 'label' => __( 'Show only approved entries', 'gravityview' ), |
|
570 | + 'label' => __('Show only approved entries', 'gravityview'), |
|
571 | 571 | 'type' => 'checkbox', |
572 | 572 | 'group' => 'default', |
573 | 573 | 'value' => 0, |
574 | 574 | 'show_in_shortcode' => false, |
575 | 575 | ), |
576 | 576 | 'hide_until_searched' => array( |
577 | - 'label' => __( 'Hide View data until search is performed', 'gravityview' ), |
|
577 | + 'label' => __('Hide View data until search is performed', 'gravityview'), |
|
578 | 578 | 'type' => 'checkbox', |
579 | 579 | 'group' => 'default', |
580 | - 'tooltip' => __( 'When enabled it will only show any View entries after a search is performed.', 'gravityview' ), |
|
580 | + 'tooltip' => __('When enabled it will only show any View entries after a search is performed.', 'gravityview'), |
|
581 | 581 | 'value' => 0, |
582 | 582 | 'show_in_shortcode' => false, |
583 | 583 | ), |
584 | 584 | 'hide_empty' => array( |
585 | - 'label' => __( 'Hide empty fields', 'gravityview' ), |
|
585 | + 'label' => __('Hide empty fields', 'gravityview'), |
|
586 | 586 | 'group' => 'default', |
587 | 587 | 'type' => 'checkbox', |
588 | 588 | 'value' => 1, |
589 | 589 | 'show_in_shortcode' => false, |
590 | 590 | ), |
591 | 591 | 'user_edit' => array( |
592 | - 'label' => __( 'Allow User Edit', 'gravityview' ), |
|
592 | + 'label' => __('Allow User Edit', 'gravityview'), |
|
593 | 593 | 'group' => 'default', |
594 | 594 | 'desc' => __('Allow logged-in users to edit entries they created.', 'gravityview'), |
595 | 595 | 'value' => 0, |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | 'show_in_shortcode' => true, |
599 | 599 | ), |
600 | 600 | 'user_delete' => array( |
601 | - 'label' => __( 'Allow User Delete', 'gravityview' ), |
|
601 | + 'label' => __('Allow User Delete', 'gravityview'), |
|
602 | 602 | 'group' => 'default', |
603 | 603 | 'desc' => __('Allow logged-in users to delete entries they created.', 'gravityview'), |
604 | 604 | 'value' => 0, |
@@ -612,8 +612,8 @@ discard block |
||
612 | 612 | 'value' => '', |
613 | 613 | 'group' => 'sort', |
614 | 614 | 'options' => array( |
615 | - '' => __( 'Default', 'gravityview'), |
|
616 | - 'date_created' => __( 'Date Created', 'gravityview'), |
|
615 | + '' => __('Default', 'gravityview'), |
|
616 | + 'date_created' => __('Date Created', 'gravityview'), |
|
617 | 617 | ), |
618 | 618 | 'show_in_shortcode' => true, |
619 | 619 | ), |
@@ -630,19 +630,19 @@ discard block |
||
630 | 630 | 'show_in_shortcode' => true, |
631 | 631 | ), |
632 | 632 | 'sort_columns' => array( |
633 | - 'label' => __( 'Enable sorting by column', 'gravityview' ), |
|
634 | - 'left_label' => __( 'Column Sorting', 'gravityview' ), |
|
633 | + 'label' => __('Enable sorting by column', 'gravityview'), |
|
634 | + 'left_label' => __('Column Sorting', 'gravityview'), |
|
635 | 635 | 'type' => 'checkbox', |
636 | 636 | 'value' => false, |
637 | 637 | 'group' => 'sort', |
638 | 638 | 'tooltip' => NULL, |
639 | 639 | 'show_in_shortcode' => true, |
640 | - 'show_in_template' => array( 'default_table' ), |
|
640 | + 'show_in_template' => array('default_table'), |
|
641 | 641 | ), |
642 | 642 | 'start_date' => array( |
643 | 643 | 'label' => __('Filter by Start Date', 'gravityview'), |
644 | 644 | 'class' => 'gv-datepicker', |
645 | - 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
645 | + 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview'), |
|
646 | 646 | 'type' => 'text', |
647 | 647 | 'value' => '', |
648 | 648 | 'group' => 'filter', |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | 'end_date' => array( |
652 | 652 | 'label' => __('Filter by End Date', 'gravityview'), |
653 | 653 | 'class' => 'gv-datepicker', |
654 | - 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
654 | + 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview'), |
|
655 | 655 | 'type' => 'text', |
656 | 656 | 'value' => '', |
657 | 657 | 'group' => 'filter', |
@@ -711,12 +711,12 @@ discard block |
||
711 | 711 | )); |
712 | 712 | |
713 | 713 | // By default, we only want the key => value pairing, not the whole array. |
714 | - if( empty( $with_details ) ) { |
|
714 | + if (empty($with_details)) { |
|
715 | 715 | |
716 | 716 | $defaults = array(); |
717 | 717 | |
718 | - foreach( $default_settings as $key => $value ) { |
|
719 | - $defaults[ $key ] = $value['value']; |
|
718 | + foreach ($default_settings as $key => $value) { |
|
719 | + $defaults[$key] = $value['value']; |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | return $defaults; |
@@ -729,9 +729,9 @@ discard block |
||
729 | 729 | |
730 | 730 | // If the $group argument is set for the method, |
731 | 731 | // ignore any settings that aren't in that group. |
732 | - if( !empty( $group ) && is_string( $group ) ) { |
|
733 | - if( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
734 | - unset( $default_settings[ $key ] ); |
|
732 | + if (!empty($group) && is_string($group)) { |
|
733 | + if (empty($value['group']) || $value['group'] !== $group) { |
|
734 | + unset($default_settings[$key]); |
|
735 | 735 | } |
736 | 736 | } |
737 | 737 |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | function init() { |
22 | 22 | |
23 | 23 | $icon = is_admin() ? '<i class="icon gv-icon-astronaut-head"></i> ' : NULL; |
24 | - $this->title( $icon . __('GravityView', 'gravityview') ); |
|
24 | + $this->title($icon.__('GravityView', 'gravityview')); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | function get_warnings() { |
28 | 28 | |
29 | - if( is_null( $this->warnings ) ) { |
|
29 | + if (is_null($this->warnings)) { |
|
30 | 30 | $this->warnings = GravityView_Logging::get_errors(); |
31 | 31 | } |
32 | 32 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | function get_notices() { |
37 | 37 | |
38 | - if( is_null( $this->notices ) ) { |
|
38 | + if (is_null($this->notices)) { |
|
39 | 39 | $this->notices = GravityView_Logging::get_notices(); |
40 | 40 | } |
41 | 41 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * Should the panel be shown? If there are notices or warnings, yes. |
51 | 51 | * @return boolean true: show panel; false: hide panel |
52 | 52 | */ |
53 | - function set_visible( $visible = '' ) { |
|
54 | - $this->_visible = ( count( $this->get_notices() ) || count( $this->get_warnings() ) ); |
|
53 | + function set_visible($visible = '') { |
|
54 | + $this->_visible = (count($this->get_notices()) || count($this->get_warnings())); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -83,42 +83,42 @@ discard block |
||
83 | 83 | </style> |
84 | 84 | <div id='debug-bar-gravityview'>"; |
85 | 85 | |
86 | - $output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="alignright" alt="" width="100" height="132" />'; |
|
86 | + $output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE).'" class="alignright" alt="" width="100" height="132" />'; |
|
87 | 87 | |
88 | 88 | |
89 | 89 | $warnings = $this->get_warnings(); |
90 | 90 | $notices = $this->get_notices(); |
91 | 91 | |
92 | - if(count($warnings)) { |
|
92 | + if (count($warnings)) { |
|
93 | 93 | $output .= '<h3><span>'.__('Warnings', 'gravityview').'</span></h3>'; |
94 | 94 | $output .= '<ol>'; |
95 | - foreach ( $warnings as $key => $notice) { |
|
96 | - if(empty($notice['message'])) { continue; } |
|
97 | - $output .= '<li><a href="#'.sanitize_html_class( 'gv-warning-' . $key ).'">'.strip_tags($notice['message']).'</a></li>'; |
|
95 | + foreach ($warnings as $key => $notice) { |
|
96 | + if (empty($notice['message'])) { continue; } |
|
97 | + $output .= '<li><a href="#'.sanitize_html_class('gv-warning-'.$key).'">'.strip_tags($notice['message']).'</a></li>'; |
|
98 | 98 | } |
99 | 99 | $output .= '</ol><hr />'; |
100 | 100 | } |
101 | - if(count($notices)) { |
|
101 | + if (count($notices)) { |
|
102 | 102 | $output .= '<h3><span>'.__('Logs', 'gravityview').'</span></h3>'; |
103 | 103 | $output .= '<ol>'; |
104 | - foreach ( $notices as $key => $notice) { |
|
105 | - if(empty($notice['message'])) { continue; } |
|
106 | - $output .= '<li><a href="#'.sanitize_html_class( 'gv-notice-' . $key ).'">'.strip_tags($notice['message']).'</a></li>'; |
|
104 | + foreach ($notices as $key => $notice) { |
|
105 | + if (empty($notice['message'])) { continue; } |
|
106 | + $output .= '<li><a href="#'.sanitize_html_class('gv-notice-'.$key).'">'.strip_tags($notice['message']).'</a></li>'; |
|
107 | 107 | } |
108 | 108 | $output .= '</ol><hr />'; |
109 | 109 | } |
110 | 110 | |
111 | - if ( count( $warnings ) ) { |
|
111 | + if (count($warnings)) { |
|
112 | 112 | $output .= '<h3>Warnings</h3>'; |
113 | 113 | $output .= '<ol class="debug-bar-php-list">'; |
114 | - foreach ( $warnings as $key => $notice) { $output .= $this->render_item( $notice, 'gv-warning-' . $key ); } |
|
114 | + foreach ($warnings as $key => $notice) { $output .= $this->render_item($notice, 'gv-warning-'.$key); } |
|
115 | 115 | $output .= '</ol>'; |
116 | 116 | } |
117 | 117 | |
118 | - if ( count( $notices ) ) { |
|
118 | + if (count($notices)) { |
|
119 | 119 | $output .= '<h3>Notices</h3>'; |
120 | 120 | $output .= '<ol class="debug-bar-php-list">'; |
121 | - foreach ( $notices as $key => $notice) { $output .= $this->render_item( $notice, 'gv-notice-' . $key ); } |
|
121 | + foreach ($notices as $key => $notice) { $output .= $this->render_item($notice, 'gv-notice-'.$key); } |
|
122 | 122 | $output .= '</ol>'; |
123 | 123 | } |
124 | 124 | |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | * @return string Escaped HTML |
134 | 134 | */ |
135 | 135 | function esc_html_recursive($item) { |
136 | - if(is_object($item)) { |
|
137 | - foreach($item as $key => $value) { |
|
136 | + if (is_object($item)) { |
|
137 | + foreach ($item as $key => $value) { |
|
138 | 138 | $item->{$key} = $this->esc_html_recursive($value); |
139 | 139 | } |
140 | - } else if(is_array($item)) { |
|
141 | - foreach($item as $key => $value) { |
|
140 | + } else if (is_array($item)) { |
|
141 | + foreach ($item as $key => $value) { |
|
142 | 142 | $item[$key] = $this->esc_html_recursive($value); |
143 | 143 | } |
144 | 144 | } else { |
@@ -154,31 +154,31 @@ discard block |
||
154 | 154 | * @param string $anchor The anchor ID for the item |
155 | 155 | * @return string HTML output |
156 | 156 | */ |
157 | - function render_item( $notice, $anchor = '' ) { |
|
157 | + function render_item($notice, $anchor = '') { |
|
158 | 158 | |
159 | 159 | $output = ''; |
160 | 160 | |
161 | - if(!empty($notice['message'])) { |
|
162 | - $output .= '<a id="'.sanitize_html_class( $anchor ).'"></a>'; |
|
161 | + if (!empty($notice['message'])) { |
|
162 | + $output .= '<a id="'.sanitize_html_class($anchor).'"></a>'; |
|
163 | 163 | $output .= "<li class='debug-bar-php-notice'>"; |
164 | 164 | } |
165 | 165 | |
166 | 166 | $output .= '<div class="clear"></div>'; |
167 | 167 | |
168 | 168 | // Title |
169 | - $output .= '<div class="gravityview-debug-bar-title">'.esc_attr( $notice['message'] ).'</div>'; |
|
169 | + $output .= '<div class="gravityview-debug-bar-title">'.esc_attr($notice['message']).'</div>'; |
|
170 | 170 | |
171 | 171 | // Debugging Output |
172 | - if( empty( $notice['data'] ) ) { |
|
173 | - if( !is_null( $notice['data'] ) ) { |
|
174 | - $output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview' ).'</em>'; |
|
172 | + if (empty($notice['data'])) { |
|
173 | + if (!is_null($notice['data'])) { |
|
174 | + $output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview').'</em>'; |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | else { |
178 | - $output .= sprintf( '<pre>%s</pre>', print_r($this->esc_html_recursive( $notice['data'] ), true) ); |
|
178 | + $output .= sprintf('<pre>%s</pre>', print_r($this->esc_html_recursive($notice['data']), true)); |
|
179 | 179 | } |
180 | 180 | |
181 | - if(!empty($notice['message'])) { |
|
181 | + if (!empty($notice['message'])) { |
|
182 | 182 | $output .= '</li>'; |
183 | 183 | } |
184 | 184 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.7.4.1 |
21 | 21 | * @var array |
22 | 22 | */ |
23 | - private static $search_parameters = array( 'gv_search', 'gv_start', 'gv_end', 'gv_id', 'gv_by', 'filter_*' ); |
|
23 | + private static $search_parameters = array('gv_search', 'gv_start', 'gv_end', 'gv_id', 'gv_by', 'filter_*'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Is the currently viewed post a `gravityview` post type? |
@@ -85,18 +85,18 @@ discard block |
||
85 | 85 | private function __construct() {} |
86 | 86 | |
87 | 87 | private function initialize() { |
88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
89 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
88 | + add_action('wp', array($this, 'parse_content'), 11); |
|
89 | + add_action('template_redirect', array($this, 'set_entry_data'), 1); |
|
90 | 90 | |
91 | 91 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
92 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
|
92 | + add_action('wp_enqueue_scripts', array($this, 'add_scripts_and_styles'), 20); |
|
93 | 93 | |
94 | 94 | // Enqueue and print styles in the footer. Added 1 priorty so stuff gets printed at 10 priority. |
95 | - add_action( 'wp_print_footer_scripts', array( $this, 'add_scripts_and_styles' ), 1 ); |
|
95 | + add_action('wp_print_footer_scripts', array($this, 'add_scripts_and_styles'), 1); |
|
96 | 96 | |
97 | - add_filter( 'the_title', array( $this, 'single_entry_title' ), 1, 2 ); |
|
98 | - add_filter( 'the_content', array( $this, 'insert_view_in_content' ) ); |
|
99 | - add_filter( 'comments_open', array( $this, 'comments_open' ), 10, 2 ); |
|
97 | + add_filter('the_title', array($this, 'single_entry_title'), 1, 2); |
|
98 | + add_filter('the_content', array($this, 'insert_view_in_content')); |
|
99 | + add_filter('comments_open', array($this, 'comments_open'), 10, 2); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public static function getInstance() { |
107 | 107 | |
108 | - if ( empty( self::$instance ) ) { |
|
108 | + if (empty(self::$instance)) { |
|
109 | 109 | self::$instance = new self; |
110 | 110 | self::$instance->initialize(); |
111 | 111 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * @param GravityView_View_Data $gv_output_data |
125 | 125 | */ |
126 | - public function setGvOutputData( $gv_output_data ) { |
|
126 | + public function setGvOutputData($gv_output_data) { |
|
127 | 127 | $this->gv_output_data = $gv_output_data; |
128 | 128 | } |
129 | 129 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * @param boolean $is_search |
139 | 139 | */ |
140 | - public function setIsSearch( $is_search ) { |
|
140 | + public function setIsSearch($is_search) { |
|
141 | 141 | $this->is_search = $is_search; |
142 | 142 | } |
143 | 143 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * Sets the single entry ID and also the entry |
153 | 153 | * @param bool|int $single_entry |
154 | 154 | */ |
155 | - public function setSingleEntry( $single_entry ) { |
|
155 | + public function setSingleEntry($single_entry) { |
|
156 | 156 | |
157 | 157 | $this->single_entry = $single_entry; |
158 | 158 | |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | * Set the current entry |
170 | 170 | * @param array|int $entry Entry array or entry ID |
171 | 171 | */ |
172 | - public function setEntry( $entry ) { |
|
172 | + public function setEntry($entry) { |
|
173 | 173 | |
174 | - if ( ! is_array( $entry ) ) { |
|
175 | - $entry = GVCommon::get_entry( $entry ); |
|
174 | + if (!is_array($entry)) { |
|
175 | + $entry = GVCommon::get_entry($entry); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | $this->entry = $entry; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @param int $post_id |
190 | 190 | */ |
191 | - public function setPostId( $post_id ) { |
|
191 | + public function setPostId($post_id) { |
|
192 | 192 | $this->post_id = $post_id; |
193 | 193 | } |
194 | 194 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * @param boolean $post_has_shortcode |
204 | 204 | */ |
205 | - public function setPostHasShortcode( $post_has_shortcode ) { |
|
205 | + public function setPostHasShortcode($post_has_shortcode) { |
|
206 | 206 | $this->post_has_shortcode = $post_has_shortcode; |
207 | 207 | } |
208 | 208 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | /** |
217 | 217 | * @param boolean $is_gravityview_post_type |
218 | 218 | */ |
219 | - public function setIsGravityviewPostType( $is_gravityview_post_type ) { |
|
219 | + public function setIsGravityviewPostType($is_gravityview_post_type) { |
|
220 | 220 | $this->is_gravityview_post_type = $is_gravityview_post_type; |
221 | 221 | } |
222 | 222 | |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @param null $view_id |
229 | 229 | */ |
230 | - public function set_context_view_id( $view_id = null ) { |
|
230 | + public function set_context_view_id($view_id = null) { |
|
231 | 231 | |
232 | - if ( ! empty( $view_id ) ) { |
|
232 | + if (!empty($view_id)) { |
|
233 | 233 | |
234 | 234 | $this->context_view_id = $view_id; |
235 | 235 | |
236 | - } elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
236 | + } elseif (isset($_GET['gvid']) && $this->getGvOutputData()->has_multiple_views()) { |
|
237 | 237 | /** |
238 | 238 | * used on a has_multiple_views context |
239 | 239 | * @see GravityView_API::entry_link |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | */ |
242 | 242 | $this->context_view_id = $_GET['gvid']; |
243 | 243 | |
244 | - } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
245 | - $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
|
246 | - $this->context_view_id = array_pop( $array_keys ); |
|
247 | - unset( $array_keys ); |
|
244 | + } elseif (!$this->getGvOutputData()->has_multiple_views()) { |
|
245 | + $array_keys = array_keys($this->getGvOutputData()->get_views()); |
|
246 | + $this->context_view_id = array_pop($array_keys); |
|
247 | + unset($array_keys); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | } |
@@ -265,31 +265,31 @@ discard block |
||
265 | 265 | * @param array $wp Passed in the `wp` hook. Not used. |
266 | 266 | * @return void |
267 | 267 | */ |
268 | - function parse_content( $wp = array() ) { |
|
268 | + function parse_content($wp = array()) { |
|
269 | 269 | global $post; |
270 | 270 | |
271 | 271 | // If in admin and NOT AJAX request, get outta here. |
272 | - if ( GravityView_Plugin::is_admin() ) { |
|
272 | + if (GravityView_Plugin::is_admin()) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | 276 | // Calculate requested Views |
277 | - $this->setGvOutputData( GravityView_View_Data::getInstance( $post ) ); |
|
277 | + $this->setGvOutputData(GravityView_View_Data::getInstance($post)); |
|
278 | 278 | |
279 | 279 | // !important: we need to run this before getting single entry (to kick the advanced filter) |
280 | 280 | $this->set_context_view_id(); |
281 | 281 | |
282 | - $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
|
282 | + $this->setIsGravityviewPostType(get_post_type($post) === 'gravityview'); |
|
283 | 283 | |
284 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
285 | - $this->setPostId( $post_id ); |
|
286 | - $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
|
287 | - $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
|
284 | + $post_id = $this->getPostId() ? $this->getPostId() : (isset($post) ? $post->ID : null); |
|
285 | + $this->setPostId($post_id); |
|
286 | + $post_has_shortcode = !empty($post->post_content) ? gravityview_has_shortcode_r($post->post_content, 'gravityview') : false; |
|
287 | + $this->setPostHasShortcode($this->isGravityviewPostType() ? null : !empty($post_has_shortcode)); |
|
288 | 288 | |
289 | 289 | // check if the View is showing search results (only for multiple entries View) |
290 | - $this->setIsSearch( $this->is_searching() ); |
|
290 | + $this->setIsSearch($this->is_searching()); |
|
291 | 291 | |
292 | - unset( $entry, $post_id, $post_has_shortcode ); |
|
292 | + unset($entry, $post_id, $post_has_shortcode); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | */ |
298 | 298 | function set_entry_data() { |
299 | 299 | $entry_id = self::is_single_entry(); |
300 | - $this->setSingleEntry( $entry_id ); |
|
301 | - $this->setEntry( $entry_id ); |
|
300 | + $this->setSingleEntry($entry_id); |
|
301 | + $this->setEntry($entry_id); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -311,31 +311,31 @@ discard block |
||
311 | 311 | function is_searching() { |
312 | 312 | |
313 | 313 | // It's a single entry, not search |
314 | - if ( $this->getSingleEntry() ) { |
|
314 | + if ($this->getSingleEntry()) { |
|
315 | 315 | return false; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // No $_GET parameters |
319 | - if ( empty( $_GET ) || ! is_array( $_GET ) ) { |
|
319 | + if (empty($_GET) || !is_array($_GET)) { |
|
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | |
323 | 323 | // Remove empty values |
324 | - $get = array_filter( $_GET ); |
|
324 | + $get = array_filter($_GET); |
|
325 | 325 | |
326 | 326 | // If the $_GET parameters are empty, it's no search. |
327 | - if ( empty( $get ) ) { |
|
327 | + if (empty($get)) { |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | |
331 | - $search_keys = array_keys( $get ); |
|
331 | + $search_keys = array_keys($get); |
|
332 | 332 | |
333 | - $search_match = implode( '|', self::$search_parameters ); |
|
333 | + $search_match = implode('|', self::$search_parameters); |
|
334 | 334 | |
335 | - foreach ( $search_keys as $search_key ) { |
|
335 | + foreach ($search_keys as $search_key) { |
|
336 | 336 | |
337 | 337 | // Analyze the search key $_GET parameter and see if it matches known GV args |
338 | - if ( preg_match( '/(' . $search_match . ')/i', $search_key ) ) { |
|
338 | + if (preg_match('/('.$search_match.')/i', $search_key)) { |
|
339 | 339 | return true; |
340 | 340 | } |
341 | 341 | } |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | * @param int $passed_post_id Post ID |
351 | 351 | * @return string (modified) title |
352 | 352 | */ |
353 | - public function single_entry_title( $title, $passed_post_id = null ) { |
|
353 | + public function single_entry_title($title, $passed_post_id = null) { |
|
354 | 354 | global $post; |
355 | 355 | |
356 | 356 | // If this is the directory view, return. |
357 | - if ( ! $this->getSingleEntry() ) { |
|
357 | + if (!$this->getSingleEntry()) { |
|
358 | 358 | return $title; |
359 | 359 | } |
360 | 360 | |
@@ -365,44 +365,44 @@ discard block |
||
365 | 365 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
366 | 366 | * @param array $entry Current entry |
367 | 367 | */ |
368 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
368 | + $apply_outside_loop = apply_filters('gravityview/single/title/out_loop', in_the_loop(), $entry); |
|
369 | 369 | |
370 | - if ( ! $apply_outside_loop ) { |
|
370 | + if (!$apply_outside_loop) { |
|
371 | 371 | return $title; |
372 | 372 | } |
373 | 373 | |
374 | 374 | // User reported WooCommerce doesn't pass two args. |
375 | - if ( empty( $passed_post_id ) ) { |
|
375 | + if (empty($passed_post_id)) { |
|
376 | 376 | return $title; |
377 | 377 | } |
378 | 378 | |
379 | 379 | // Don't modify the title for anything other than the current view/post. |
380 | 380 | // This is true for embedded shortcodes and Views. |
381 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
381 | + if (is_object($post) && (int)$post->ID !== (int)$passed_post_id) { |
|
382 | 382 | return $title; |
383 | 383 | } |
384 | 384 | |
385 | 385 | $context_view_id = $this->get_context_view_id(); |
386 | 386 | |
387 | - if ( $this->getGvOutputData()->has_multiple_views() && ! empty( $context_view_id ) ) { |
|
388 | - $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
|
387 | + if ($this->getGvOutputData()->has_multiple_views() && !empty($context_view_id)) { |
|
388 | + $view_meta = $this->getGvOutputData()->get_view($context_view_id); |
|
389 | 389 | } else { |
390 | - foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
|
391 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
390 | + foreach ($this->getGvOutputData()->get_views() as $view_id => $view_data) { |
|
391 | + if (intval($view_data['form_id']) === intval($entry['form_id'])) { |
|
392 | 392 | $view_meta = $view_data; |
393 | 393 | break; |
394 | 394 | } |
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
398 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
398 | + if (!empty($view_meta['atts']['single_title'])) { |
|
399 | 399 | |
400 | 400 | $title = $view_meta['atts']['single_title']; |
401 | 401 | |
402 | 402 | // We are allowing HTML in the fields, so no escaping the output |
403 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
403 | + $title = GravityView_API::replace_variables($title, $view_meta['form'], $entry); |
|
404 | 404 | |
405 | - $title = do_shortcode( $title ); |
|
405 | + $title = do_shortcode($title); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | return $title; |
@@ -417,38 +417,38 @@ discard block |
||
417 | 417 | * @param mixed $content |
418 | 418 | * @return string Add the View output into View CPT content |
419 | 419 | */ |
420 | - public function insert_view_in_content( $content ) { |
|
420 | + public function insert_view_in_content($content) { |
|
421 | 421 | |
422 | 422 | // Plugins may run through the content in the header. WP SEO does this for its OpenGraph functionality. |
423 | - if ( ! did_action( 'loop_start' ) ) { |
|
423 | + if (!did_action('loop_start')) { |
|
424 | 424 | |
425 | - do_action( 'gravityview_log_debug', '[insert_view_in_content] Not processing yet: loop_start hasn\'t run yet. Current action:', current_filter() ); |
|
425 | + do_action('gravityview_log_debug', '[insert_view_in_content] Not processing yet: loop_start hasn\'t run yet. Current action:', current_filter()); |
|
426 | 426 | |
427 | 427 | return $content; |
428 | 428 | } |
429 | 429 | |
430 | 430 | // We don't want this filter to run infinite loop on any post content fields |
431 | - remove_filter( 'the_content', array( $this, 'insert_view_in_content' ) ); |
|
431 | + remove_filter('the_content', array($this, 'insert_view_in_content')); |
|
432 | 432 | |
433 | 433 | // Otherwise, this is called on the Views page when in Excerpt mode. |
434 | - if ( is_admin() ) { |
|
434 | + if (is_admin()) { |
|
435 | 435 | return $content; |
436 | 436 | } |
437 | 437 | |
438 | - if ( $this->isGravityviewPostType() ) { |
|
438 | + if ($this->isGravityviewPostType()) { |
|
439 | 439 | |
440 | 440 | /** @since 1.7.4 */ |
441 | - if ( is_preview() && ! gravityview_get_form_id( $this->post_id ) ) { |
|
442 | - $content .= __( 'When using a Start Fresh template, you must save the View before a Preview is available.', 'gravityview' ); |
|
441 | + if (is_preview() && !gravityview_get_form_id($this->post_id)) { |
|
442 | + $content .= __('When using a Start Fresh template, you must save the View before a Preview is available.', 'gravityview'); |
|
443 | 443 | } else { |
444 | - foreach ( $this->getGvOutputData()->get_views() as $view_id => $data ) { |
|
445 | - $content .= $this->render_view( array( 'id' => $view_id ) ); |
|
444 | + foreach ($this->getGvOutputData()->get_views() as $view_id => $data) { |
|
445 | + $content .= $this->render_view(array('id' => $view_id)); |
|
446 | 446 | } |
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
450 | 450 | // Add the filter back in |
451 | - add_filter( 'the_content', array( $this, 'insert_view_in_content' ) ); |
|
451 | + add_filter('the_content', array($this, 'insert_view_in_content')); |
|
452 | 452 | |
453 | 453 | return $content; |
454 | 454 | } |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | * @param int $post_id Post ID |
460 | 460 | * @return boolean |
461 | 461 | */ |
462 | - public function comments_open( $open, $post_id ) { |
|
462 | + public function comments_open($open, $post_id) { |
|
463 | 463 | |
464 | - if ( $this->isGravityviewPostType() ) { |
|
464 | + if ($this->isGravityviewPostType()) { |
|
465 | 465 | $open = false; |
466 | 466 | } |
467 | 467 | |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @param boolean $open Open or closed status |
472 | 472 | * @param int $post_id Post ID to set comment status for |
473 | 473 | */ |
474 | - $open = apply_filters( 'gravityview/comments_open', $open, $post_id ); |
|
474 | + $open = apply_filters('gravityview/comments_open', $open, $post_id); |
|
475 | 475 | |
476 | 476 | return $open; |
477 | 477 | } |
@@ -498,55 +498,55 @@ discard block |
||
498 | 498 | * |
499 | 499 | * @return string|null HTML output of a View, NULL if View isn't found |
500 | 500 | */ |
501 | - public function render_view( $passed_args ) { |
|
501 | + public function render_view($passed_args) { |
|
502 | 502 | |
503 | 503 | // validate attributes |
504 | - if ( empty( $passed_args['id'] ) ) { |
|
505 | - do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args ); |
|
504 | + if (empty($passed_args['id'])) { |
|
505 | + do_action('gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args); |
|
506 | 506 | return null; |
507 | 507 | } |
508 | 508 | |
509 | 509 | // Solve problem when loading content via admin-ajax.php |
510 | 510 | // @hack |
511 | - if ( ! $this->getGvOutputData() ) { |
|
511 | + if (!$this->getGvOutputData()) { |
|
512 | 512 | |
513 | - do_action( 'gravityview_log_error', '[render_view] gv_output_data not defined; parsing content.', $passed_args ); |
|
513 | + do_action('gravityview_log_error', '[render_view] gv_output_data not defined; parsing content.', $passed_args); |
|
514 | 514 | |
515 | 515 | $this->parse_content(); |
516 | 516 | } |
517 | 517 | |
518 | 518 | // Make 100% sure that we're dealing with a properly called situation |
519 | - if ( ! is_object( $this->getGvOutputData() ) || ! is_callable( array( $this->getGvOutputData(), 'get_view' ) ) ) { |
|
519 | + if (!is_object($this->getGvOutputData()) || !is_callable(array($this->getGvOutputData(), 'get_view'))) { |
|
520 | 520 | |
521 | - do_action( 'gravityview_log_error', '[render_view] gv_output_data not an object or get_view not callable.', $this->getGvOutputData() ); |
|
521 | + do_action('gravityview_log_error', '[render_view] gv_output_data not an object or get_view not callable.', $this->getGvOutputData()); |
|
522 | 522 | |
523 | 523 | return null; |
524 | 524 | } |
525 | 525 | |
526 | 526 | $view_id = $passed_args['id']; |
527 | 527 | |
528 | - $view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args ); |
|
528 | + $view_data = $this->getGvOutputData()->get_view($view_id, $passed_args); |
|
529 | 529 | |
530 | - do_action( 'gravityview_log_debug', '[render_view] View Data: ', $view_data ); |
|
530 | + do_action('gravityview_log_debug', '[render_view] View Data: ', $view_data); |
|
531 | 531 | |
532 | - do_action( 'gravityview_log_debug', '[render_view] Init View. Arguments: ', $passed_args ); |
|
532 | + do_action('gravityview_log_debug', '[render_view] Init View. Arguments: ', $passed_args); |
|
533 | 533 | |
534 | 534 | // The passed args were always winning, even if they were NULL. |
535 | 535 | // This prevents that. Filters NULL, FALSE, and empty strings. |
536 | - $passed_args = array_filter( $passed_args, 'strlen' ); |
|
536 | + $passed_args = array_filter($passed_args, 'strlen'); |
|
537 | 537 | |
538 | 538 | //Override shortcode args over View template settings |
539 | - $atts = wp_parse_args( $passed_args, $view_data['atts'] ); |
|
539 | + $atts = wp_parse_args($passed_args, $view_data['atts']); |
|
540 | 540 | |
541 | - do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts ); |
|
541 | + do_action('gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts); |
|
542 | 542 | |
543 | 543 | // It's password protected and you need to log in. |
544 | - if ( post_password_required( $view_id ) ) { |
|
544 | + if (post_password_required($view_id)) { |
|
545 | 545 | |
546 | - do_action( 'gravityview_log_error', sprintf( '[render_view] Returning: View %d is password protected.', $view_id ) ); |
|
546 | + do_action('gravityview_log_error', sprintf('[render_view] Returning: View %d is password protected.', $view_id)); |
|
547 | 547 | |
548 | 548 | // If we're in an embed or on an archive page, show the password form |
549 | - if ( get_the_ID() !== $view_id ) { |
|
549 | + if (get_the_ID() !== $view_id) { |
|
550 | 550 | return get_the_password_form(); |
551 | 551 | } |
552 | 552 | |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | * Don't render View if user isn't allowed to see it |
559 | 559 | * @since 1.15 |
560 | 560 | */ |
561 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
561 | + if (is_user_logged_in() && false === GVCommon::has_cap('read_gravityview', $view_id)) { |
|
562 | 562 | return null; |
563 | 563 | } |
564 | 564 | |
565 | - if( $this->isGravityviewPostType() ) { |
|
565 | + if ($this->isGravityviewPostType()) { |
|
566 | 566 | |
567 | 567 | /** |
568 | 568 | * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode? |
@@ -572,12 +572,12 @@ discard block |
||
572 | 572 | * @param[in,out] boolean `true`: allow Views to be accessible directly. `false`: Only allow Views to be embedded via shortcode. Default: `true` |
573 | 573 | * @param int $view_id The ID of the View currently being requested. `0` for general setting |
574 | 574 | */ |
575 | - $direct_access = apply_filters( 'gravityview_direct_access', true, $view_id ); |
|
575 | + $direct_access = apply_filters('gravityview_direct_access', true, $view_id); |
|
576 | 576 | |
577 | - $embed_only = ! empty( $atts['embed_only'] ); |
|
577 | + $embed_only = !empty($atts['embed_only']); |
|
578 | 578 | |
579 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
580 | - return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
579 | + if (!$direct_access || ($embed_only && !GVCommon::has_cap('read_private_gravityviews'))) { |
|
580 | + return __('You are not allowed to view this content.', 'gravityview'); |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | |
@@ -589,137 +589,137 @@ discard block |
||
589 | 589 | */ |
590 | 590 | global $gravityview_view; |
591 | 591 | |
592 | - $gravityview_view = new GravityView_View( $view_data ); |
|
592 | + $gravityview_view = new GravityView_View($view_data); |
|
593 | 593 | |
594 | - $post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId(); |
|
594 | + $post_id = !empty($atts['post_id']) ? intval($atts['post_id']) : $this->getPostId(); |
|
595 | 595 | |
596 | - $gravityview_view->setPostId( $post_id ); |
|
596 | + $gravityview_view->setPostId($post_id); |
|
597 | 597 | |
598 | - if ( ! $this->getSingleEntry() ) { |
|
598 | + if (!$this->getSingleEntry()) { |
|
599 | 599 | |
600 | 600 | // user requested Directory View |
601 | - do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' ); |
|
601 | + do_action('gravityview_log_debug', '[render_view] Executing Directory View'); |
|
602 | 602 | |
603 | 603 | //fetch template and slug |
604 | - $view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' ); |
|
604 | + $view_slug = apply_filters('gravityview_template_slug_'.$view_data['template_id'], 'table', 'directory'); |
|
605 | 605 | |
606 | - do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug ); |
|
606 | + do_action('gravityview_log_debug', '[render_view] View template slug: ', $view_slug); |
|
607 | 607 | |
608 | 608 | /** |
609 | 609 | * Disable fetching initial entries for views that don't need it (DataTables) |
610 | 610 | */ |
611 | - $get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true ); |
|
611 | + $get_entries = apply_filters('gravityview_get_view_entries_'.$view_slug, true); |
|
612 | 612 | |
613 | 613 | /** |
614 | 614 | * Hide View data until search is performed |
615 | 615 | * @since 1.5.4 |
616 | 616 | */ |
617 | - if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) { |
|
618 | - $gravityview_view->setHideUntilSearched( true ); |
|
617 | + if (!empty($atts['hide_until_searched']) && !$this->isSearch()) { |
|
618 | + $gravityview_view->setHideUntilSearched(true); |
|
619 | 619 | $get_entries = false; |
620 | 620 | } |
621 | 621 | |
622 | 622 | |
623 | - if ( $get_entries ) { |
|
623 | + if ($get_entries) { |
|
624 | 624 | |
625 | - if ( ! empty( $atts['sort_columns'] ) ) { |
|
625 | + if (!empty($atts['sort_columns'])) { |
|
626 | 626 | // add filter to enable column sorting |
627 | - add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 ); |
|
627 | + add_filter('gravityview/template/field_label', array($this, 'add_columns_sort_links'), 100, 3); |
|
628 | 628 | } |
629 | 629 | |
630 | - $view_entries = self::get_view_entries( $atts, $view_data['form_id'] ); |
|
630 | + $view_entries = self::get_view_entries($atts, $view_data['form_id']); |
|
631 | 631 | |
632 | - do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) ); |
|
632 | + do_action('gravityview_log_debug', sprintf('[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof($view_entries['entries']))); |
|
633 | 633 | |
634 | 634 | } else { |
635 | 635 | |
636 | - $view_entries = array( 'count' => null, 'entries' => null, 'paging' => null ); |
|
636 | + $view_entries = array('count' => null, 'entries' => null, 'paging' => null); |
|
637 | 637 | |
638 | - do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' ); |
|
638 | + do_action('gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false'); |
|
639 | 639 | } |
640 | 640 | |
641 | - $gravityview_view->setPaging( $view_entries['paging'] ); |
|
642 | - $gravityview_view->setContext( 'directory' ); |
|
643 | - $sections = array( 'header', 'body', 'footer' ); |
|
641 | + $gravityview_view->setPaging($view_entries['paging']); |
|
642 | + $gravityview_view->setContext('directory'); |
|
643 | + $sections = array('header', 'body', 'footer'); |
|
644 | 644 | |
645 | 645 | } else { |
646 | 646 | |
647 | 647 | // user requested Single Entry View |
648 | - do_action( 'gravityview_log_debug', '[render_view] Executing Single View' ); |
|
648 | + do_action('gravityview_log_debug', '[render_view] Executing Single View'); |
|
649 | 649 | |
650 | - do_action( 'gravityview_render_entry_'.$view_data['id'] ); |
|
650 | + do_action('gravityview_render_entry_'.$view_data['id']); |
|
651 | 651 | |
652 | 652 | $entry = $this->getEntry(); |
653 | 653 | |
654 | 654 | // You are not permitted to view this entry. |
655 | - if ( empty( $entry ) || ! self::is_entry_approved( $entry, $atts ) ) { |
|
655 | + if (empty($entry) || !self::is_entry_approved($entry, $atts)) { |
|
656 | 656 | |
657 | - do_action( 'gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.' ); |
|
657 | + do_action('gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.'); |
|
658 | 658 | |
659 | 659 | /** |
660 | 660 | * @since 1.6 |
661 | 661 | */ |
662 | - echo esc_attr( apply_filters( 'gravityview/render/entry/not_visible', __( 'You have attempted to view an entry that is not visible or may not exist.', 'gravityview' ) ) ); |
|
662 | + echo esc_attr(apply_filters('gravityview/render/entry/not_visible', __('You have attempted to view an entry that is not visible or may not exist.', 'gravityview'))); |
|
663 | 663 | |
664 | 664 | return null; |
665 | 665 | } |
666 | 666 | |
667 | 667 | // We're in single view, but the view being processed is not the same view the single entry belongs to. |
668 | 668 | // important: do not remove this as it prevents fake attempts of displaying entries from other views/forms |
669 | - if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) { |
|
670 | - do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id ); |
|
669 | + if ($this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id()) { |
|
670 | + do_action('gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '.$view_id); |
|
671 | 671 | return null; |
672 | 672 | } |
673 | 673 | |
674 | 674 | //fetch template and slug |
675 | - $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' ); |
|
676 | - do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug ); |
|
675 | + $view_slug = apply_filters('gravityview_template_slug_'.$view_data['template_id'], 'table', 'single'); |
|
676 | + do_action('gravityview_log_debug', '[render_view] View single template slug: ', $view_slug); |
|
677 | 677 | |
678 | 678 | //fetch entry detail |
679 | 679 | $view_entries['count'] = 1; |
680 | 680 | $view_entries['entries'][] = $entry; |
681 | - do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] ); |
|
681 | + do_action('gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries']); |
|
682 | 682 | |
683 | - $back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null; |
|
683 | + $back_link_label = isset($atts['back_link_label']) ? $atts['back_link_label'] : null; |
|
684 | 684 | |
685 | 685 | // set back link label |
686 | - $gravityview_view->setBackLinkLabel( $back_link_label ); |
|
687 | - $gravityview_view->setContext( 'single' ); |
|
688 | - $sections = array( 'single' ); |
|
686 | + $gravityview_view->setBackLinkLabel($back_link_label); |
|
687 | + $gravityview_view->setContext('single'); |
|
688 | + $sections = array('single'); |
|
689 | 689 | |
690 | 690 | } |
691 | 691 | |
692 | 692 | // add template style |
693 | - self::add_style( $view_data['template_id'] ); |
|
693 | + self::add_style($view_data['template_id']); |
|
694 | 694 | |
695 | 695 | // Prepare to render view and set vars |
696 | - $gravityview_view->setEntries( $view_entries['entries'] ); |
|
697 | - $gravityview_view->setTotalEntries( $view_entries['count'] ); |
|
696 | + $gravityview_view->setEntries($view_entries['entries']); |
|
697 | + $gravityview_view->setTotalEntries($view_entries['count']); |
|
698 | 698 | |
699 | 699 | // If Edit |
700 | - if ( 'edit' === gravityview_get_context() ) { |
|
700 | + if ('edit' === gravityview_get_context()) { |
|
701 | 701 | |
702 | - do_action( 'gravityview_log_debug', '[render_view] Edit Entry ' ); |
|
702 | + do_action('gravityview_log_debug', '[render_view] Edit Entry '); |
|
703 | 703 | |
704 | - do_action( 'gravityview_edit_entry', $this->getGvOutputData() ); |
|
704 | + do_action('gravityview_edit_entry', $this->getGvOutputData()); |
|
705 | 705 | |
706 | 706 | return ob_get_clean(); |
707 | 707 | |
708 | 708 | } else { |
709 | 709 | // finaly we'll render some html |
710 | - $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] ); |
|
710 | + $sections = apply_filters('gravityview_render_view_sections', $sections, $view_data['template_id']); |
|
711 | 711 | |
712 | - do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections ); |
|
713 | - foreach ( $sections as $section ) { |
|
714 | - do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' ); |
|
715 | - $gravityview_view->render( $view_slug, $section, false ); |
|
712 | + do_action('gravityview_log_debug', '[render_view] Sections to render: ', $sections); |
|
713 | + foreach ($sections as $section) { |
|
714 | + do_action('gravityview_log_debug', '[render_view] Rendering '.$section.' section.'); |
|
715 | + $gravityview_view->render($view_slug, $section, false); |
|
716 | 716 | } |
717 | 717 | } |
718 | 718 | |
719 | 719 | //@todo: check why we need the IF statement vs. print the view id always. |
720 | - if ( $this->isGravityviewPostType() || $this->isPostHasShortcode() ) { |
|
720 | + if ($this->isGravityviewPostType() || $this->isPostHasShortcode()) { |
|
721 | 721 | // Print the View ID to enable proper cookie pagination |
722 | - echo '<input type="hidden" class="gravityview-view-id" value="' . esc_attr( $view_id ) . '">'; |
|
722 | + echo '<input type="hidden" class="gravityview-view-id" value="'.esc_attr($view_id).'">'; |
|
723 | 723 | } |
724 | 724 | $output = ob_get_clean(); |
725 | 725 | |
@@ -741,23 +741,23 @@ discard block |
||
741 | 741 | * @param array $search_criteria Search being performed, if any |
742 | 742 | * @return array Modified `$search_criteria` array |
743 | 743 | */ |
744 | - public static function process_search_dates( $args, $search_criteria = array() ) { |
|
744 | + public static function process_search_dates($args, $search_criteria = array()) { |
|
745 | 745 | |
746 | 746 | $return_search_criteria = $search_criteria; |
747 | 747 | |
748 | - foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
748 | + foreach (array('start_date', 'end_date') as $key) { |
|
749 | 749 | |
750 | 750 | |
751 | 751 | // Is the start date or end date set in the view or shortcode? |
752 | 752 | // If so, we want to make sure that the search doesn't go outside the bounds defined. |
753 | - if ( ! empty( $args[ $key ] ) ) { |
|
753 | + if (!empty($args[$key])) { |
|
754 | 754 | |
755 | 755 | // Get a timestamp and see if it's a valid date format |
756 | - $date = strtotime( $args[ $key ] ); |
|
756 | + $date = strtotime($args[$key]); |
|
757 | 757 | |
758 | 758 | // The date was invalid |
759 | - if ( empty( $date ) ) { |
|
760 | - do_action( 'gravityview_log_error', __METHOD__ . ' Invalid ' . $key . ' date format: ' . $args[ $key ] ); |
|
759 | + if (empty($date)) { |
|
760 | + do_action('gravityview_log_error', __METHOD__.' Invalid '.$key.' date format: '.$args[$key]); |
|
761 | 761 | continue; |
762 | 762 | } |
763 | 763 | |
@@ -765,12 +765,12 @@ discard block |
||
765 | 765 | $datetime_format = 'Y-m-d H:i:s'; |
766 | 766 | $search_is_outside_view_bounds = false; |
767 | 767 | |
768 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
768 | + if (!empty($search_criteria[$key])) { |
|
769 | 769 | |
770 | - $search_date = strtotime( $search_criteria[ $key ] ); |
|
770 | + $search_date = strtotime($search_criteria[$key]); |
|
771 | 771 | |
772 | 772 | // The search is for entries before the start date defined by the settings |
773 | - switch ( $key ) { |
|
773 | + switch ($key) { |
|
774 | 774 | case 'end_date': |
775 | 775 | /** |
776 | 776 | * If the end date is formatted as 'Y-m-d', it should be formatted without hours and seconds |
@@ -780,28 +780,28 @@ discard block |
||
780 | 780 | * |
781 | 781 | * @see GFFormsModel::get_date_range_where |
782 | 782 | */ |
783 | - $datetime_format = gravityview_is_valid_datetime( $args[ $key ] ) ? 'Y-m-d' : 'Y-m-d H:i:s'; |
|
784 | - $search_is_outside_view_bounds = ( $search_date > $date ); |
|
783 | + $datetime_format = gravityview_is_valid_datetime($args[$key]) ? 'Y-m-d' : 'Y-m-d H:i:s'; |
|
784 | + $search_is_outside_view_bounds = ($search_date > $date); |
|
785 | 785 | break; |
786 | 786 | case 'start_date': |
787 | - $search_is_outside_view_bounds = ( $search_date < $date ); |
|
787 | + $search_is_outside_view_bounds = ($search_date < $date); |
|
788 | 788 | break; |
789 | 789 | } |
790 | 790 | } |
791 | 791 | |
792 | 792 | // If there is no search being performed, or if there is a search being performed that's outside the bounds |
793 | - if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
|
793 | + if (empty($search_criteria[$key]) || $search_is_outside_view_bounds) { |
|
794 | 794 | |
795 | 795 | // Then we override the search and re-set the start date |
796 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
796 | + $return_search_criteria[$key] = date_i18n($datetime_format, $date, true); |
|
797 | 797 | } |
798 | 798 | } |
799 | 799 | } |
800 | 800 | |
801 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
801 | + if (isset($return_search_criteria['start_date']) && isset($return_search_criteria['end_date'])) { |
|
802 | 802 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
803 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
804 | - do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria ); |
|
803 | + if (strtotime($return_search_criteria['start_date']) > strtotime($return_search_criteria['end_date'])) { |
|
804 | + do_action('gravityview_log_error', __METHOD__.' Invalid search: the start date is after the end date.', $return_search_criteria); |
|
805 | 805 | } |
806 | 806 | } |
807 | 807 | |
@@ -816,13 +816,13 @@ discard block |
||
816 | 816 | * @param array $search_criteria Search being performed, if any |
817 | 817 | * @return array Modified `$search_criteria` array |
818 | 818 | */ |
819 | - public static function process_search_only_approved( $args, $search_criteria ) { |
|
819 | + public static function process_search_only_approved($args, $search_criteria) { |
|
820 | 820 | |
821 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
822 | - $search_criteria['field_filters'][] = array( 'key' => 'is_approved', 'value' => 'Approved' ); |
|
821 | + if (!empty($args['show_only_approved'])) { |
|
822 | + $search_criteria['field_filters'][] = array('key' => 'is_approved', 'value' => 'Approved'); |
|
823 | 823 | $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
824 | 824 | |
825 | - do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria ); |
|
825 | + do_action('gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | return $search_criteria; |
@@ -842,16 +842,16 @@ discard block |
||
842 | 842 | * |
843 | 843 | * @return bool |
844 | 844 | */ |
845 | - public static function is_entry_approved( $entry, $args = array() ) { |
|
845 | + public static function is_entry_approved($entry, $args = array()) { |
|
846 | 846 | |
847 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
847 | + if (empty($entry['id']) || (array_key_exists('show_only_approved', $args) && !$args['show_only_approved'])) { |
|
848 | 848 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
849 | 849 | return true; |
850 | 850 | } |
851 | 851 | |
852 | - $is_approved = gform_get_meta( $entry['id'], 'is_approved' ); |
|
852 | + $is_approved = gform_get_meta($entry['id'], 'is_approved'); |
|
853 | 853 | |
854 | - if ( $is_approved ) { |
|
854 | + if ($is_approved) { |
|
855 | 855 | return true; |
856 | 856 | } |
857 | 857 | |
@@ -872,47 +872,47 @@ discard block |
||
872 | 872 | * @param int $form_id Gravity Forms form ID |
873 | 873 | * @return array Array of search parameters, formatted in Gravity Forms mode, using `status` key set to "active" by default, `field_filters` array with `key`, `value` and `operator` keys. |
874 | 874 | */ |
875 | - public static function get_search_criteria( $args, $form_id ) { |
|
875 | + public static function get_search_criteria($args, $form_id) { |
|
876 | 876 | |
877 | 877 | // Search Criteria |
878 | - $search_criteria = apply_filters( 'gravityview_fe_search_criteria', array( 'field_filters' => array() ), $form_id ); |
|
878 | + $search_criteria = apply_filters('gravityview_fe_search_criteria', array('field_filters' => array()), $form_id); |
|
879 | 879 | |
880 | 880 | $original_search_criteria = $search_criteria; |
881 | 881 | |
882 | - do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria ); |
|
882 | + do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria); |
|
883 | 883 | |
884 | 884 | // implicity search |
885 | - if ( ! empty( $args['search_value'] ) ) { |
|
885 | + if (!empty($args['search_value'])) { |
|
886 | 886 | |
887 | 887 | // Search operator options. Options: `is` or `contains` |
888 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
888 | + $operator = !empty($args['search_operator']) && in_array($args['search_operator'], array('is', 'isnot', '>', '<', 'contains')) ? $args['search_operator'] : 'contains'; |
|
889 | 889 | |
890 | 890 | $search_criteria['field_filters'][] = array( |
891 | - 'key' => rgget( 'search_field', $args ), // The field ID to search |
|
892 | - 'value' => esc_attr( $args['search_value'] ), // The value to search |
|
891 | + 'key' => rgget('search_field', $args), // The field ID to search |
|
892 | + 'value' => esc_attr($args['search_value']), // The value to search |
|
893 | 893 | 'operator' => $operator, |
894 | 894 | ); |
895 | 895 | } |
896 | 896 | |
897 | - if( $search_criteria !== $original_search_criteria ) { |
|
898 | - do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria ); |
|
897 | + if ($search_criteria !== $original_search_criteria) { |
|
898 | + do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria); |
|
899 | 899 | } |
900 | 900 | |
901 | 901 | // Handle setting date range |
902 | - $search_criteria = self::process_search_dates( $args, $search_criteria ); |
|
902 | + $search_criteria = self::process_search_dates($args, $search_criteria); |
|
903 | 903 | |
904 | - if( $search_criteria !== $original_search_criteria ) { |
|
905 | - do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria ); |
|
904 | + if ($search_criteria !== $original_search_criteria) { |
|
905 | + do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | // remove not approved entries |
909 | - $search_criteria = self::process_search_only_approved( $args, $search_criteria ); |
|
909 | + $search_criteria = self::process_search_only_approved($args, $search_criteria); |
|
910 | 910 | |
911 | 911 | /** |
912 | 912 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
913 | 913 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
914 | 914 | */ |
915 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
915 | + $search_criteria['status'] = apply_filters('gravityview_status', 'active', $args); |
|
916 | 916 | |
917 | 917 | return $search_criteria; |
918 | 918 | } |
@@ -946,29 +946,29 @@ discard block |
||
946 | 946 | * @param int $form_id Gravity Forms Form ID |
947 | 947 | * @return array Associative array with `count`, `entries`, and `paging` keys. `count` has the total entries count, `entries` is an array with Gravity Forms full entry data, `paging` is an array with `offset` and `page_size` keys |
948 | 948 | */ |
949 | - public static function get_view_entries( $args, $form_id ) { |
|
949 | + public static function get_view_entries($args, $form_id) { |
|
950 | 950 | |
951 | - do_action( 'gravityview_log_debug', '[get_view_entries] init' ); |
|
951 | + do_action('gravityview_log_debug', '[get_view_entries] init'); |
|
952 | 952 | // start filters and sorting |
953 | 953 | |
954 | 954 | /** |
955 | 955 | * Process search parameters |
956 | 956 | * @var array |
957 | 957 | */ |
958 | - $search_criteria = self::get_search_criteria( $args, $form_id ); |
|
958 | + $search_criteria = self::get_search_criteria($args, $form_id); |
|
959 | 959 | |
960 | 960 | // Paging & offset |
961 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : apply_filters( 'gravityview_default_page_size', 25 ); |
|
961 | + $page_size = !empty($args['page_size']) ? intval($args['page_size']) : apply_filters('gravityview_default_page_size', 25); |
|
962 | 962 | |
963 | 963 | if ( -1 === $page_size ) { |
964 | 964 | $page_size = PHP_INT_MAX; |
965 | 965 | } |
966 | 966 | |
967 | - if ( isset( $args['offset'] ) ) { |
|
968 | - $offset = intval( $args['offset'] ); |
|
967 | + if (isset($args['offset'])) { |
|
968 | + $offset = intval($args['offset']); |
|
969 | 969 | } else { |
970 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
971 | - $offset = ( $curr_page - 1 ) * $page_size; |
|
970 | + $curr_page = empty($_GET['pagenum']) ? 1 : intval($_GET['pagenum']); |
|
971 | + $offset = ($curr_page - 1) * $page_size; |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | $paging = array( |
@@ -976,16 +976,16 @@ discard block |
||
976 | 976 | 'page_size' => $page_size, |
977 | 977 | ); |
978 | 978 | |
979 | - do_action( 'gravityview_log_debug', '[get_view_entries] Paging: ', $paging ); |
|
979 | + do_action('gravityview_log_debug', '[get_view_entries] Paging: ', $paging); |
|
980 | 980 | |
981 | 981 | // Sorting |
982 | - $sorting = self::updateViewSorting( $args, $form_id ); |
|
982 | + $sorting = self::updateViewSorting($args, $form_id); |
|
983 | 983 | |
984 | 984 | $parameters = array( |
985 | 985 | 'search_criteria' => $search_criteria, |
986 | 986 | 'sorting' => $sorting, |
987 | 987 | 'paging' => $paging, |
988 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
988 | + 'cache' => isset($args['cache']) ? $args['cache'] : true, |
|
989 | 989 | ); |
990 | 990 | |
991 | 991 | /** |
@@ -1003,22 +1003,22 @@ discard block |
||
1003 | 1003 | * } |
1004 | 1004 | * @param int $form_id ID of Gravity Forms form |
1005 | 1005 | */ |
1006 | - $parameters = apply_filters( 'gravityview_get_entries', $parameters, $args, $form_id ); |
|
1006 | + $parameters = apply_filters('gravityview_get_entries', $parameters, $args, $form_id); |
|
1007 | 1007 | |
1008 | 1008 | /** |
1009 | 1009 | * @filter `gravityview_get_entries_{View ID}` Filter get entries criteria |
1010 | 1010 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
1011 | 1011 | * @param array $args View configuration args. |
1012 | 1012 | */ |
1013 | - $parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id ); |
|
1013 | + $parameters = apply_filters('gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id); |
|
1014 | 1014 | |
1015 | - do_action( 'gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters ); |
|
1015 | + do_action('gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters); |
|
1016 | 1016 | |
1017 | 1017 | //fetch entries |
1018 | 1018 | $count = 0; |
1019 | - $entries = gravityview_get_entries( $form_id, $parameters, $count ); |
|
1019 | + $entries = gravityview_get_entries($form_id, $parameters, $count); |
|
1020 | 1020 | |
1021 | - do_action( 'gravityview_log_debug', sprintf( '[get_view_entries] Get Entries. Found: %s entries', $count ), $entries ); |
|
1021 | + do_action('gravityview_log_debug', sprintf('[get_view_entries] Get Entries. Found: %s entries', $count), $entries); |
|
1022 | 1022 | |
1023 | 1023 | /** |
1024 | 1024 | * @filter `gravityview_view_entries` Filter the entries output to the View |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | * @param array $args View settings associative array |
1027 | 1027 | * @var array |
1028 | 1028 | */ |
1029 | - $entries = apply_filters( 'gravityview_view_entries', $entries, $args ); |
|
1029 | + $entries = apply_filters('gravityview_view_entries', $entries, $args); |
|
1030 | 1030 | |
1031 | 1031 | /** |
1032 | 1032 | * @filter `gravityview/view/entries` Filter the entries output to the View |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | * @param array $args View settings associative array |
1035 | 1035 | * @since 1.5.2 |
1036 | 1036 | */ |
1037 | - return apply_filters( 'gravityview/view/entries', compact( 'count', 'entries', 'paging' ), $args ); |
|
1037 | + return apply_filters('gravityview/view/entries', compact('count', 'entries', 'paging'), $args); |
|
1038 | 1038 | |
1039 | 1039 | } |
1040 | 1040 | |
@@ -1048,24 +1048,24 @@ discard block |
||
1048 | 1048 | * @param int $form_id The ID of the form used to sort |
1049 | 1049 | * @return array $sorting Array with `key`, `direction` and `is_numeric` keys |
1050 | 1050 | */ |
1051 | - public static function updateViewSorting( $args, $form_id ) { |
|
1051 | + public static function updateViewSorting($args, $form_id) { |
|
1052 | 1052 | $sorting = array(); |
1053 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' ); |
|
1054 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' ); |
|
1053 | + $sort_field_id = isset($_GET['sort']) ? $_GET['sort'] : rgar($args, 'sort_field'); |
|
1054 | + $sort_direction = isset($_GET['dir']) ? $_GET['dir'] : rgar($args, 'sort_direction'); |
|
1055 | 1055 | |
1056 | - $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
|
1056 | + $sort_field_id = self::_override_sorting_id_by_field_type($sort_field_id, $form_id); |
|
1057 | 1057 | |
1058 | - if ( ! empty( $sort_field_id ) ) { |
|
1058 | + if (!empty($sort_field_id)) { |
|
1059 | 1059 | $sorting = array( |
1060 | 1060 | 'key' => $sort_field_id, |
1061 | - 'direction' => strtolower( $sort_direction ), |
|
1062 | - 'is_numeric' => GVCommon::is_field_numeric( $form_id, $sort_field_id ) |
|
1061 | + 'direction' => strtolower($sort_direction), |
|
1062 | + 'is_numeric' => GVCommon::is_field_numeric($form_id, $sort_field_id) |
|
1063 | 1063 | ); |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - GravityView_View::getInstance()->setSorting( $sorting ); |
|
1066 | + GravityView_View::getInstance()->setSorting($sorting); |
|
1067 | 1067 | |
1068 | - do_action( 'gravityview_log_debug', '[updateViewSorting] Sort Criteria : ', $sorting ); |
|
1068 | + do_action('gravityview_log_debug', '[updateViewSorting] Sort Criteria : ', $sorting); |
|
1069 | 1069 | |
1070 | 1070 | return $sorting; |
1071 | 1071 | |
@@ -1085,17 +1085,17 @@ discard block |
||
1085 | 1085 | * |
1086 | 1086 | * @return string Possibly modified sorting ID |
1087 | 1087 | */ |
1088 | - private static function _override_sorting_id_by_field_type( $sort_field_id, $form_id ) { |
|
1088 | + private static function _override_sorting_id_by_field_type($sort_field_id, $form_id) { |
|
1089 | 1089 | |
1090 | - $form = GFAPI::get_form( $form_id ); |
|
1090 | + $form = GFAPI::get_form($form_id); |
|
1091 | 1091 | |
1092 | - $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
|
1092 | + $sort_field = GFFormsModel::get_field($form, $sort_field_id); |
|
1093 | 1093 | |
1094 | - switch ( $sort_field['type'] ) { |
|
1094 | + switch ($sort_field['type']) { |
|
1095 | 1095 | |
1096 | 1096 | case 'address': |
1097 | 1097 | // Sorting by full address |
1098 | - if ( floatval( $sort_field_id ) === floor( $sort_field_id ) ) { |
|
1098 | + if (floatval($sort_field_id) === floor($sort_field_id)) { |
|
1099 | 1099 | |
1100 | 1100 | /** |
1101 | 1101 | * Override how to sort when sorting address |
@@ -1106,9 +1106,9 @@ discard block |
||
1106 | 1106 | * @param string $sort_field_id Field used for sorting |
1107 | 1107 | * @param int $form_id GF Form ID |
1108 | 1108 | */ |
1109 | - $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
|
1109 | + $address_part = apply_filters('gravityview/sorting/address', 'city', $sort_field_id, $form_id); |
|
1110 | 1110 | |
1111 | - switch( strtolower( $address_part ) ){ |
|
1111 | + switch (strtolower($address_part)) { |
|
1112 | 1112 | case 'street': |
1113 | 1113 | $sort_field_id .= '.1'; |
1114 | 1114 | break; |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | break; |
1135 | 1135 | case 'name': |
1136 | 1136 | // Sorting by full name, not first, last, etc. |
1137 | - if ( floatval( $sort_field_id ) === floor( $sort_field_id ) ) { |
|
1137 | + if (floatval($sort_field_id) === floor($sort_field_id)) { |
|
1138 | 1138 | /** |
1139 | 1139 | * @filter `gravityview/sorting/full-name` Override how to sort when sorting full name. |
1140 | 1140 | * @since 1.7.4 |
@@ -1142,9 +1142,9 @@ discard block |
||
1142 | 1142 | * @param[in] string $sort_field_id Field used for sorting |
1143 | 1143 | * @param[in] int $form_id GF Form ID |
1144 | 1144 | */ |
1145 | - $name_part = apply_filters( 'gravityview/sorting/full-name', 'first', $sort_field_id, $form_id ); |
|
1145 | + $name_part = apply_filters('gravityview/sorting/full-name', 'first', $sort_field_id, $form_id); |
|
1146 | 1146 | |
1147 | - if ( 'last' === strtolower( $name_part ) ) { |
|
1147 | + if ('last' === strtolower($name_part)) { |
|
1148 | 1148 | $sort_field_id .= '.6'; |
1149 | 1149 | } else { |
1150 | 1150 | $sort_field_id .= '.3'; |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | * @param[in,out] string $name_part Field used for sorting |
1164 | 1164 | * @param[in] int $form_id GF Form ID |
1165 | 1165 | */ |
1166 | - $sort_field_id = apply_filters( 'gravityview/sorting/time', $sort_field_id, $form_id ); |
|
1166 | + $sort_field_id = apply_filters('gravityview/sorting/time', $sort_field_id, $form_id); |
|
1167 | 1167 | break; |
1168 | 1168 | } |
1169 | 1169 | |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | |
1179 | 1179 | $var_name = GravityView_Post_Types::get_entry_var_name(); |
1180 | 1180 | |
1181 | - $single_entry = get_query_var( $var_name ); |
|
1181 | + $single_entry = get_query_var($var_name); |
|
1182 | 1182 | |
1183 | 1183 | /** |
1184 | 1184 | * Modify the entry that is being displayed. |
@@ -1186,9 +1186,9 @@ discard block |
||
1186 | 1186 | * @internal Should only be used by things like the oEmbed functionality. |
1187 | 1187 | * @since 1.6 |
1188 | 1188 | */ |
1189 | - $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
|
1189 | + $single_entry = apply_filters('gravityview/is_single_entry', $single_entry); |
|
1190 | 1190 | |
1191 | - if ( empty( $single_entry ) ){ |
|
1191 | + if (empty($single_entry)) { |
|
1192 | 1192 | return false; |
1193 | 1193 | } else { |
1194 | 1194 | return $single_entry; |
@@ -1205,38 +1205,38 @@ discard block |
||
1205 | 1205 | public function add_scripts_and_styles() { |
1206 | 1206 | global $post, $posts; |
1207 | 1207 | // enqueue template specific styles |
1208 | - if ( $this->getGvOutputData() ) { |
|
1208 | + if ($this->getGvOutputData()) { |
|
1209 | 1209 | |
1210 | 1210 | $views = $this->getGvOutputData()->get_views(); |
1211 | 1211 | |
1212 | - foreach ( $views as $view_id => $data ) { |
|
1212 | + foreach ($views as $view_id => $data) { |
|
1213 | 1213 | |
1214 | 1214 | /** |
1215 | 1215 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
1216 | 1216 | * @since 1.15 |
1217 | 1217 | */ |
1218 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1218 | + if (is_user_logged_in() && false === GVCommon::has_cap('read_gravityview', $view_id)) { |
|
1219 | 1219 | continue; |
1220 | 1220 | } |
1221 | 1221 | |
1222 | 1222 | // By default, no thickbox |
1223 | - $js_dependencies = array( 'jquery', 'gravityview-jquery-cookie' ); |
|
1223 | + $js_dependencies = array('jquery', 'gravityview-jquery-cookie'); |
|
1224 | 1224 | $css_dependencies = array(); |
1225 | 1225 | |
1226 | 1226 | // If the thickbox is enqueued, add dependencies |
1227 | - if ( ! empty( $data['atts']['lightbox'] ) ) { |
|
1227 | + if (!empty($data['atts']['lightbox'])) { |
|
1228 | 1228 | |
1229 | 1229 | /** |
1230 | 1230 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
1231 | 1231 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
1232 | 1232 | */ |
1233 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1233 | + $js_dependencies[] = apply_filters('gravity_view_lightbox_script', 'thickbox'); |
|
1234 | 1234 | |
1235 | 1235 | /** |
1236 | 1236 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
1237 | 1237 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
1238 | 1238 | */ |
1239 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1239 | + $css_dependencies[] = apply_filters('gravity_view_lightbox_style', 'thickbox'); |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | /** |
@@ -1244,34 +1244,34 @@ discard block |
||
1244 | 1244 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
1245 | 1245 | * @since 1.15 |
1246 | 1246 | */ |
1247 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
1247 | + if (gravityview_view_has_single_checkbox_or_radio($data['form'], $data['fields'])) { |
|
1248 | 1248 | $css_dependencies[] = 'dashicons'; |
1249 | 1249 | } |
1250 | 1250 | |
1251 | - wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
|
1251 | + wp_register_script('gravityview-jquery-cookie', plugins_url('includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE), array('jquery'), GravityView_Plugin::version, true); |
|
1252 | 1252 | |
1253 | - $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
1253 | + $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1254 | 1254 | |
1255 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
1255 | + wp_register_script('gravityview-fe-view', plugins_url('assets/js/fe-views'.$script_debug.'.js', GRAVITYVIEW_FILE), apply_filters('gravityview_js_dependencies', $js_dependencies), GravityView_Plugin::version, true); |
|
1256 | 1256 | |
1257 | - wp_enqueue_script( 'gravityview-fe-view' ); |
|
1257 | + wp_enqueue_script('gravityview-fe-view'); |
|
1258 | 1258 | |
1259 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
1260 | - wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
|
1259 | + if (!empty($data['atts']['sort_columns'])) { |
|
1260 | + wp_enqueue_style('gravityview_font', plugins_url('assets/css/font.css', GRAVITYVIEW_FILE), $css_dependencies, GravityView_Plugin::version, 'all'); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | - wp_enqueue_style( 'gravityview_default_style', plugins_url( 'templates/css/gv-default-styles.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
|
1263 | + wp_enqueue_style('gravityview_default_style', plugins_url('templates/css/gv-default-styles.css', GRAVITYVIEW_FILE), $css_dependencies, GravityView_Plugin::version, 'all'); |
|
1264 | 1264 | |
1265 | - self::add_style( $data['template_id'] ); |
|
1265 | + self::add_style($data['template_id']); |
|
1266 | 1266 | |
1267 | 1267 | } |
1268 | 1268 | |
1269 | - if ( 'wp_print_footer_scripts' === current_filter() ) { |
|
1269 | + if ('wp_print_footer_scripts' === current_filter()) { |
|
1270 | 1270 | |
1271 | 1271 | $js_localization = array( |
1272 | 1272 | 'cookiepath' => COOKIEPATH, |
1273 | - 'clear' => _x( 'Clear', 'Clear all data from the form', 'gravityview' ), |
|
1274 | - 'reset' => _x( 'Reset', 'Reset the search form to the state that existed on page load', 'gravityview' ), |
|
1273 | + 'clear' => _x('Clear', 'Clear all data from the form', 'gravityview'), |
|
1274 | + 'reset' => _x('Reset', 'Reset the search form to the state that existed on page load', 'gravityview'), |
|
1275 | 1275 | ); |
1276 | 1276 | |
1277 | 1277 | /** |
@@ -1279,9 +1279,9 @@ discard block |
||
1279 | 1279 | * @param array $js_localization The data padded to the Javascript file |
1280 | 1280 | * @param array $views Array of View data arrays with View settings |
1281 | 1281 | */ |
1282 | - $js_localization = apply_filters( 'gravityview_js_localization', $js_localization, $views ); |
|
1282 | + $js_localization = apply_filters('gravityview_js_localization', $js_localization, $views); |
|
1283 | 1283 | |
1284 | - wp_localize_script( 'gravityview-fe-view', 'gvGlobals', $js_localization ); |
|
1284 | + wp_localize_script('gravityview-fe-view', 'gvGlobals', $js_localization); |
|
1285 | 1285 | } |
1286 | 1286 | } |
1287 | 1287 | } |
@@ -1290,15 +1290,15 @@ discard block |
||
1290 | 1290 | * Add template extra style if exists |
1291 | 1291 | * @param string $template_id |
1292 | 1292 | */ |
1293 | - public static function add_style( $template_id ) { |
|
1293 | + public static function add_style($template_id) { |
|
1294 | 1294 | |
1295 | - if ( ! empty( $template_id ) && wp_style_is( 'gravityview_style_' . $template_id, 'registered' ) ) { |
|
1296 | - do_action( 'gravityview_log_debug', sprintf( '[add_style] Adding extra template style for %s', $template_id ) ); |
|
1297 | - wp_enqueue_style( 'gravityview_style_' . $template_id ); |
|
1298 | - } elseif ( empty( $template_id ) ) { |
|
1299 | - do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' ); |
|
1295 | + if (!empty($template_id) && wp_style_is('gravityview_style_'.$template_id, 'registered')) { |
|
1296 | + do_action('gravityview_log_debug', sprintf('[add_style] Adding extra template style for %s', $template_id)); |
|
1297 | + wp_enqueue_style('gravityview_style_'.$template_id); |
|
1298 | + } elseif (empty($template_id)) { |
|
1299 | + do_action('gravityview_log_error', '[add_style] Cannot add template style; template_id is empty'); |
|
1300 | 1300 | } else { |
1301 | - do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) ); |
|
1301 | + do_action('gravityview_log_error', sprintf('[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id)); |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | } |
@@ -1317,17 +1317,17 @@ discard block |
||
1317 | 1317 | * |
1318 | 1318 | * @return string Field Label |
1319 | 1319 | */ |
1320 | - public function add_columns_sort_links( $label = '', $field, $form ) { |
|
1320 | + public function add_columns_sort_links($label = '', $field, $form) { |
|
1321 | 1321 | |
1322 | 1322 | /** |
1323 | 1323 | * Not a table-based template; don't add sort icons |
1324 | 1324 | * @since 1.12 |
1325 | 1325 | */ |
1326 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1326 | + if (!preg_match('/table/ism', GravityView_View::getInstance()->getTemplatePartSlug())) { |
|
1327 | 1327 | return $label; |
1328 | 1328 | } |
1329 | 1329 | |
1330 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
1330 | + if (!$this->is_field_sortable($field['id'], $form)) { |
|
1331 | 1331 | return $label; |
1332 | 1332 | } |
1333 | 1333 | |
@@ -1335,16 +1335,16 @@ discard block |
||
1335 | 1335 | |
1336 | 1336 | $class = 'gv-sort icon'; |
1337 | 1337 | |
1338 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
1338 | + $sort_field_id = self::_override_sorting_id_by_field_type($field['id'], $form['id']); |
|
1339 | 1339 | |
1340 | 1340 | $sort_args = array( |
1341 | 1341 | 'sort' => $field['id'], |
1342 | 1342 | 'dir' => 'asc', |
1343 | 1343 | ); |
1344 | 1344 | |
1345 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
1345 | + if (!empty($sorting['key']) && (string)$sort_field_id === (string)$sorting['key']) { |
|
1346 | 1346 | //toggle sorting direction. |
1347 | - if ( 'asc' === $sorting['direction'] ) { |
|
1347 | + if ('asc' === $sorting['direction']) { |
|
1348 | 1348 | $sort_args['dir'] = 'desc'; |
1349 | 1349 | $class .= ' gv-icon-sort-desc'; |
1350 | 1350 | } else { |
@@ -1355,9 +1355,9 @@ discard block |
||
1355 | 1355 | $class .= ' gv-icon-caret-up-down'; |
1356 | 1356 | } |
1357 | 1357 | |
1358 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
1358 | + $url = add_query_arg($sort_args, remove_query_arg(array('pagenum'))); |
|
1359 | 1359 | |
1360 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
1360 | + return '<a href="'.esc_url_raw($url).'" class="'.$class.'" ></a> '.$label; |
|
1361 | 1361 | |
1362 | 1362 | } |
1363 | 1363 | |
@@ -1371,10 +1371,10 @@ discard block |
||
1371 | 1371 | * |
1372 | 1372 | * @return bool True: Yes, field is sortable; False: not sortable |
1373 | 1373 | */ |
1374 | - public function is_field_sortable( $field_id = '', $form ) { |
|
1374 | + public function is_field_sortable($field_id = '', $form) { |
|
1375 | 1375 | |
1376 | - if( is_numeric( $field_id ) ) { |
|
1377 | - $field = GFFormsModel::get_field( $form, $field_id ); |
|
1376 | + if (is_numeric($field_id)) { |
|
1377 | + $field = GFFormsModel::get_field($form, $field_id); |
|
1378 | 1378 | $field_id = $field->type; |
1379 | 1379 | } |
1380 | 1380 | |
@@ -1390,13 +1390,13 @@ discard block |
||
1390 | 1390 | * Modify what fields should never be sortable. |
1391 | 1391 | * @since 1.7 |
1392 | 1392 | */ |
1393 | - $not_sortable = apply_filters( 'gravityview/sortable/field_blacklist', $not_sortable, $field_id, $form ); |
|
1393 | + $not_sortable = apply_filters('gravityview/sortable/field_blacklist', $not_sortable, $field_id, $form); |
|
1394 | 1394 | |
1395 | - if ( in_array( $field_id, $not_sortable ) ) { |
|
1395 | + if (in_array($field_id, $not_sortable)) { |
|
1396 | 1396 | return false; |
1397 | 1397 | } |
1398 | 1398 | |
1399 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1399 | + return apply_filters("gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters("gravityview/sortable/field_{$field_id}", true, $form)); |
|
1400 | 1400 | |
1401 | 1401 | } |
1402 | 1402 |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * @since 1.13 |
24 | 24 | */ |
25 | 25 | private function add_hooks() { |
26 | - add_action( 'add_admin_bar_menus', array( $this, 'remove_links' ), 80 ); |
|
27 | - add_action( 'admin_bar_menu', array( $this, 'add_links' ), 85 ); |
|
26 | + add_action('add_admin_bar_menus', array($this, 'remove_links'), 80); |
|
27 | + add_action('admin_bar_menu', array($this, 'add_links'), 85); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | |
56 | 56 | $entry_id = $this->gravityview_view->getSingleEntry(); |
57 | 57 | |
58 | - if ( $entry_id && GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ), $entry_id ) ) { |
|
58 | + if ($entry_id && GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_entries'), $entry_id)) { |
|
59 | 59 | |
60 | 60 | $entry = $this->gravityview_view->getEntry(); |
61 | 61 | |
62 | - $wp_admin_bar->add_menu( array( |
|
62 | + $wp_admin_bar->add_menu(array( |
|
63 | 63 | 'id' => 'edit-entry', |
64 | - 'title' => __( 'Edit Entry', 'gravityview' ), |
|
65 | - 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry['form_id'], $entry['id'] ) ) ), |
|
66 | - ) ); |
|
64 | + 'title' => __('Edit Entry', 'gravityview'), |
|
65 | + 'href' => esc_url_raw(admin_url(sprintf('admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry['form_id'], $entry['id']))), |
|
66 | + )); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** @var WP_Admin_Bar $wp_admin_bar */ |
79 | 79 | global $wp_admin_bar; |
80 | 80 | |
81 | - if( GVCommon::has_cap('edit_gravityviews') ) { |
|
81 | + if (GVCommon::has_cap('edit_gravityviews')) { |
|
82 | 82 | |
83 | 83 | $view_data = GravityView_View_Data::getInstance(); |
84 | 84 | |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | |
87 | 87 | // If there is a View embed, shor Edit View link. |
88 | 88 | // todo: Support multiple View embeds with a drop-down menu |
89 | - if ( ! $this->gravityview_view->isGravityviewPostType() && ! empty( $views ) && ! $view_data->has_multiple_views() ) { |
|
90 | - $view = reset( $views ); |
|
89 | + if (!$this->gravityview_view->isGravityviewPostType() && !empty($views) && !$view_data->has_multiple_views()) { |
|
90 | + $view = reset($views); |
|
91 | 91 | |
92 | - if( GVCommon::has_cap( 'edit_gravityview', $view['id'] ) ) { |
|
93 | - $wp_admin_bar->add_menu( array( |
|
92 | + if (GVCommon::has_cap('edit_gravityview', $view['id'])) { |
|
93 | + $wp_admin_bar->add_menu(array( |
|
94 | 94 | 'id' => 'edit-view', |
95 | - 'title' => __( 'Edit View', 'gravityview' ), |
|
96 | - 'href' => esc_url_raw( admin_url( sprintf( 'post.php?post=%d&action=edit', $view['id'] ) ) ), |
|
97 | - ) ); |
|
95 | + 'title' => __('Edit View', 'gravityview'), |
|
96 | + 'href' => esc_url_raw(admin_url(sprintf('post.php?post=%d&action=edit', $view['id']))), |
|
97 | + )); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | } |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | function remove_links() { |
109 | 109 | |
110 | 110 | // If we're on the single entry page, we don't want to cause confusion. |
111 | - if ( is_admin() || ( $this->gravityview_view->getSingleEntry() && ! $this->gravityview_view->isGravityviewPostType() ) ) { |
|
112 | - remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 ); |
|
111 | + if (is_admin() || ($this->gravityview_view->getSingleEntry() && !$this->gravityview_view->isGravityviewPostType())) { |
|
112 | + remove_action('admin_bar_menu', 'wp_admin_bar_edit_menu', 80); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | function __construct() { |
16 | 16 | |
17 | 17 | // Only run on Admin |
18 | - if ( !is_admin() ) { |
|
18 | + if (!is_admin()) { |
|
19 | 19 | return; |
20 | 20 | } |
21 | 21 | |
22 | 22 | // If the Duplicate Post plugin is active, don't run. |
23 | - if( defined('DUPLICATE_POST_CURRENT_VERSION') ) { |
|
23 | + if (defined('DUPLICATE_POST_CURRENT_VERSION')) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
@@ -33,18 +33,18 @@ discard block |
||
33 | 33 | * @return void |
34 | 34 | */ |
35 | 35 | private function add_hooks() { |
36 | - add_filter( 'post_row_actions', array( $this, 'make_duplicate_link_row' ), 10, 2 ); |
|
36 | + add_filter('post_row_actions', array($this, 'make_duplicate_link_row'), 10, 2); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Connect actions to functions |
40 | 40 | */ |
41 | - add_action( 'admin_action_duplicate_view', array( $this, 'save_as_new_view' ) ); |
|
42 | - add_action( 'admin_action_duplicate_view_as_draft', array( $this, 'save_as_new_view_draft' ) ); |
|
41 | + add_action('admin_action_duplicate_view', array($this, 'save_as_new_view')); |
|
42 | + add_action('admin_action_duplicate_view_as_draft', array($this, 'save_as_new_view_draft')); |
|
43 | 43 | |
44 | 44 | // Using our action hooks to copy meta fields |
45 | - add_action( 'gv_duplicate_view', array( $this, 'copy_view_meta_info' ), 10, 2 ); |
|
45 | + add_action('gv_duplicate_view', array($this, 'copy_view_meta_info'), 10, 2); |
|
46 | 46 | |
47 | - add_filter( 'gravityview_connected_form_links', array( $this, 'connected_form_links' ), 10, 2 ); |
|
47 | + add_filter('gravityview_connected_form_links', array($this, 'connected_form_links'), 10, 2); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return array If it's the All Views page, return unedited. Otherwise, add a link to create cloned draft of View |
57 | 57 | */ |
58 | - function connected_form_links( $links = array(), $form = array() ) { |
|
58 | + function connected_form_links($links = array(), $form = array()) { |
|
59 | 59 | /** @global WP_Post $post */ |
60 | 60 | global $post; |
61 | 61 | |
62 | 62 | // We only want to add Clone links to the Edit View metabox |
63 | - if( !$this->is_all_views_page() ) { |
|
63 | + if (!$this->is_all_views_page()) { |
|
64 | 64 | |
65 | - if( $duplicate_links = $this->make_duplicate_link_row( array(), $post ) ) { |
|
66 | - $links[] = '<span>' . $duplicate_links['edit_as_new_draft'] . '</span>'; |
|
65 | + if ($duplicate_links = $this->make_duplicate_link_row(array(), $post)) { |
|
66 | + $links[] = '<span>'.$duplicate_links['edit_as_new_draft'].'</span>'; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @since 1.6 |
90 | 90 | */ |
91 | - private function current_user_can_copy( $post ) { |
|
91 | + private function current_user_can_copy($post) { |
|
92 | 92 | |
93 | - $id = is_object( $post ) ? $post->ID : $post; |
|
93 | + $id = is_object($post) ? $post->ID : $post; |
|
94 | 94 | |
95 | 95 | // Can't edit this current View |
96 | - return GVCommon::has_cap( 'copy_gravityviews', $id ); |
|
96 | + return GVCommon::has_cap('copy_gravityviews', $id); |
|
97 | 97 | |
98 | 98 | } |
99 | 99 | |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | * @param string $status The post status |
105 | 105 | * @since 1.6 |
106 | 106 | */ |
107 | - private function create_duplicate( $post, $status = '' ) { |
|
107 | + private function create_duplicate($post, $status = '') { |
|
108 | 108 | |
109 | 109 | // We only want to clone Views |
110 | - if ( $post->post_type !== 'gravityview' ) { |
|
110 | + if ($post->post_type !== 'gravityview') { |
|
111 | 111 | return; |
112 | 112 | } |
113 | 113 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param string|null If string, the status to set for the new View. If empty, use existing View status. |
120 | 120 | * @param WP_Post $post View being cloned |
121 | 121 | */ |
122 | - $new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post ); |
|
122 | + $new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post); |
|
123 | 123 | |
124 | 124 | $new_view = array( |
125 | 125 | 'menu_order' => $post->menu_order, |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | 'post_mime_type' => $post->post_mime_type, |
132 | 132 | 'post_parent' => $post->post_parent, |
133 | 133 | 'post_password' => $post->post_password, |
134 | - 'post_status' => ( empty( $new_view_status ) ) ? $post->post_status : $new_view_status, |
|
134 | + 'post_status' => (empty($new_view_status)) ? $post->post_status : $new_view_status, |
|
135 | 135 | 'post_title' => $post->post_title, |
136 | 136 | 'post_type' => $post->post_type, |
137 | 137 | ); |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @param boolean $copy_date Whether the copy the date from the existing View. Default: `false` |
143 | 143 | * @param WP_Post $post View being cloned |
144 | 144 | */ |
145 | - $copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post ); |
|
145 | + $copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post); |
|
146 | 146 | |
147 | - if ( $copy_date ) { |
|
147 | + if ($copy_date) { |
|
148 | 148 | $new_view['post_date'] = $new_post_date = $post->post_date; |
149 | - $new_view['post_date_gmt'] = get_gmt_from_date( $new_post_date ); |
|
149 | + $new_view['post_date_gmt'] = get_gmt_from_date($new_post_date); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,15 +155,15 @@ discard block |
||
155 | 155 | * @param array $new_view Array of settings to be passed to wp_insert_post() |
156 | 156 | * @param WP_Post $post View being cloned |
157 | 157 | */ |
158 | - $new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post ); |
|
158 | + $new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post); |
|
159 | 159 | |
160 | 160 | // Magic happens here. |
161 | - $new_view_id = wp_insert_post( $new_view ); |
|
161 | + $new_view_id = wp_insert_post($new_view); |
|
162 | 162 | |
163 | 163 | // If the copy is published or scheduled, we have to set a proper slug. |
164 | - if ( $new_view_status == 'publish' || $new_view_status == 'future' ) { |
|
164 | + if ($new_view_status == 'publish' || $new_view_status == 'future') { |
|
165 | 165 | |
166 | - $view_name = wp_unique_post_slug( $post->post_name, $new_view_id, $new_view_status, $post->post_type, $post->post_parent ); |
|
166 | + $view_name = wp_unique_post_slug($post->post_name, $new_view_id, $new_view_status, $post->post_type, $post->post_parent); |
|
167 | 167 | |
168 | 168 | $new_view_name_array = array( |
169 | 169 | 'ID' => $new_view_id, |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | ); |
172 | 172 | |
173 | 173 | // Update the post into the database |
174 | - wp_update_post( $new_view_name_array ); |
|
174 | + wp_update_post($new_view_name_array); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | * @param int $new_view_id The ID of the newly created View |
182 | 182 | * @param WP_Post The View that was just cloned |
183 | 183 | */ |
184 | - do_action( 'gv_duplicate_view', $new_view_id, $post ); |
|
184 | + do_action('gv_duplicate_view', $new_view_id, $post); |
|
185 | 185 | |
186 | - delete_post_meta( $new_view_id, '_dp_original' ); |
|
186 | + delete_post_meta($new_view_id, '_dp_original'); |
|
187 | 187 | |
188 | - add_post_meta( $new_view_id, '_dp_original', $post->ID, false ); |
|
188 | + add_post_meta($new_view_id, '_dp_original', $post->ID, false); |
|
189 | 189 | |
190 | 190 | return $new_view_id; |
191 | 191 | } |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return void |
202 | 202 | */ |
203 | - public function copy_view_meta_info( $new_id, $post ) { |
|
203 | + public function copy_view_meta_info($new_id, $post) { |
|
204 | 204 | |
205 | - $post_meta_keys = get_post_custom_keys( $post->ID ); |
|
205 | + $post_meta_keys = get_post_custom_keys($post->ID); |
|
206 | 206 | |
207 | - if ( empty( $post_meta_keys ) ) { |
|
207 | + if (empty($post_meta_keys)) { |
|
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | - foreach ( $post_meta_keys as $meta_key ) { |
|
211 | + foreach ($post_meta_keys as $meta_key) { |
|
212 | 212 | |
213 | - $meta_values = get_post_custom_values( $meta_key, $post->ID ); |
|
213 | + $meta_values = get_post_custom_values($meta_key, $post->ID); |
|
214 | 214 | |
215 | - foreach ( $meta_values as $meta_value ) { |
|
215 | + foreach ($meta_values as $meta_value) { |
|
216 | 216 | |
217 | - $meta_value = maybe_unserialize( $meta_value ); |
|
217 | + $meta_value = maybe_unserialize($meta_value); |
|
218 | 218 | |
219 | - add_post_meta( $new_id, $meta_key, $meta_value ); |
|
219 | + add_post_meta($new_id, $meta_key, $meta_value); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | } |
@@ -228,22 +228,22 @@ discard block |
||
228 | 228 | * @param array $actions Row action links. Defaults are 'Edit', 'Quick Edit', 'Restore, 'Trash', 'Delete Permanently', 'Preview', and 'View' |
229 | 229 | * @param WP_Post $post |
230 | 230 | */ |
231 | - public function make_duplicate_link_row( $actions, $post ) { |
|
231 | + public function make_duplicate_link_row($actions, $post) { |
|
232 | 232 | |
233 | 233 | // Only process on GravityView Views |
234 | - if ( get_post_type( $post ) === 'gravityview' && $this->current_user_can_copy( $post ) ) { |
|
234 | + if (get_post_type($post) === 'gravityview' && $this->current_user_can_copy($post)) { |
|
235 | 235 | |
236 | - $clone_link = $this->get_clone_view_link( $post->ID, 'display', false ); |
|
237 | - $clone_text = __( 'Clone', 'gravityview' ); |
|
238 | - $clone_title = __( 'Clone this View', 'gravityview' ); |
|
236 | + $clone_link = $this->get_clone_view_link($post->ID, 'display', false); |
|
237 | + $clone_text = __('Clone', 'gravityview'); |
|
238 | + $clone_title = __('Clone this View', 'gravityview'); |
|
239 | 239 | |
240 | - $actions['clone'] = gravityview_get_link( $clone_link, $clone_text, 'title='.$clone_title ); |
|
240 | + $actions['clone'] = gravityview_get_link($clone_link, $clone_text, 'title='.$clone_title); |
|
241 | 241 | |
242 | - $clone_draft_link = $this->get_clone_view_link( $post->ID ); |
|
243 | - $clone_draft_text = $this->is_all_views_page() ? __( 'New Draft', 'gravityview' ) : __( 'Clone View', 'gravityview' ); |
|
244 | - $clone_draft_title = __( 'Copy as a new draft View', 'gravityview' ); |
|
242 | + $clone_draft_link = $this->get_clone_view_link($post->ID); |
|
243 | + $clone_draft_text = $this->is_all_views_page() ? __('New Draft', 'gravityview') : __('Clone View', 'gravityview'); |
|
244 | + $clone_draft_title = __('Copy as a new draft View', 'gravityview'); |
|
245 | 245 | |
246 | - $actions['edit_as_new_draft'] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title='.$clone_draft_title ); |
|
246 | + $actions['edit_as_new_draft'] = gravityview_get_link($clone_draft_link, esc_html($clone_draft_text), 'title='.$clone_draft_title); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | return $actions; |
@@ -259,31 +259,31 @@ discard block |
||
259 | 259 | * @param string $draft Optional, default to true |
260 | 260 | * @return string |
261 | 261 | */ |
262 | - private function get_clone_view_link( $id = 0, $context = 'display', $draft = true ) { |
|
262 | + private function get_clone_view_link($id = 0, $context = 'display', $draft = true) { |
|
263 | 263 | |
264 | 264 | // Make sure they have permission |
265 | - if ( false === $this->current_user_can_copy( $id ) ) { |
|
265 | + if (false === $this->current_user_can_copy($id)) { |
|
266 | 266 | return ''; |
267 | 267 | } |
268 | 268 | |
269 | 269 | // Verify the View exists |
270 | - if ( !$view = get_post( $id ) ) { |
|
270 | + if (!$view = get_post($id)) { |
|
271 | 271 | return ''; |
272 | 272 | } |
273 | 273 | |
274 | 274 | $action_name = $draft ? "duplicate_view_as_draft" : "duplicate_view"; |
275 | 275 | |
276 | - $action = '?action=' . $action_name . '&post=' . $view->ID; |
|
276 | + $action = '?action='.$action_name.'&post='.$view->ID; |
|
277 | 277 | |
278 | - if ( 'display' == $context ) { |
|
279 | - $action = esc_html( $action ); |
|
278 | + if ('display' == $context) { |
|
279 | + $action = esc_html($action); |
|
280 | 280 | } |
281 | 281 | |
282 | - $post_type_object = get_post_type_object( $view->post_type ); |
|
282 | + $post_type_object = get_post_type_object($view->post_type); |
|
283 | 283 | |
284 | 284 | /** If there's no gravityview post type for some reason, abort! */ |
285 | - if ( !$post_type_object ) { |
|
286 | - do_action( 'gravityview_log_error', __METHOD__ . ' No gravityview post type exists when trying to clone the View.', $view ); |
|
285 | + if (!$post_type_object) { |
|
286 | + do_action('gravityview_log_error', __METHOD__.' No gravityview post type exists when trying to clone the View.', $view); |
|
287 | 287 | return ''; |
288 | 288 | } |
289 | 289 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * @param int $view_id View ID |
295 | 295 | * @param string $context How to display the link. If "display", the URL is run through esc_html(). Default: `display` |
296 | 296 | */ |
297 | - $clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php". $action ), $view->ID, $context ); |
|
297 | + $clone_view_link = apply_filters('gravityview/duplicate-view/get_clone_view_link', admin_url("admin.php".$action), $view->ID, $context); |
|
298 | 298 | |
299 | 299 | return $clone_view_link; |
300 | 300 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return void |
309 | 309 | */ |
310 | 310 | public function save_as_new_view_draft() { |
311 | - $this->save_as_new_view( 'draft' ); |
|
311 | + $this->save_as_new_view('draft'); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -319,38 +319,38 @@ discard block |
||
319 | 319 | * @param string $status The status to set for the new View |
320 | 320 | * @return void |
321 | 321 | */ |
322 | - public function save_as_new_view( $status = '' ) { |
|
322 | + public function save_as_new_view($status = '') { |
|
323 | 323 | |
324 | - if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) ) ) { |
|
325 | - wp_die( __( 'No post to duplicate has been supplied!', 'gravityview' ) ); |
|
324 | + if (!(isset($_GET['post']) || isset($_POST['post']))) { |
|
325 | + wp_die(__('No post to duplicate has been supplied!', 'gravityview')); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | // Get the original post |
329 | - $id = ( isset( $_GET['post'] ) ? $_GET['post'] : $_POST['post'] ); |
|
329 | + $id = (isset($_GET['post']) ? $_GET['post'] : $_POST['post']); |
|
330 | 330 | |
331 | - if( ! $this->current_user_can_copy( $id ) ) { |
|
332 | - wp_die( __( 'You don\'t have permission to copy this View.', 'gravityview' ) ); |
|
331 | + if (!$this->current_user_can_copy($id)) { |
|
332 | + wp_die(__('You don\'t have permission to copy this View.', 'gravityview')); |
|
333 | 333 | } |
334 | 334 | |
335 | - $post = get_post( $id ); |
|
335 | + $post = get_post($id); |
|
336 | 336 | |
337 | 337 | // Copy the post and insert it |
338 | - if ( isset( $post ) && $post != NULL ) { |
|
338 | + if (isset($post) && $post != NULL) { |
|
339 | 339 | |
340 | - $new_id = $this->create_duplicate( $post, $status ); |
|
340 | + $new_id = $this->create_duplicate($post, $status); |
|
341 | 341 | |
342 | - if ( $status == '' ) { |
|
342 | + if ($status == '') { |
|
343 | 343 | // Redirect to the post list screen |
344 | - wp_redirect( admin_url( 'edit.php?post_type=' . $post->post_type ) ); |
|
344 | + wp_redirect(admin_url('edit.php?post_type='.$post->post_type)); |
|
345 | 345 | } else { |
346 | 346 | // Redirect to the edit screen for the new draft post |
347 | - wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_id ) ); |
|
347 | + wp_redirect(admin_url('post.php?action=edit&post='.$new_id)); |
|
348 | 348 | } |
349 | 349 | exit; |
350 | 350 | |
351 | 351 | } else { |
352 | 352 | |
353 | - wp_die( sprintf( esc_attr__( 'Copy creation failed, could not find original View with ID #%d', 'gravityview' ), $id ) ); |
|
353 | + wp_die(sprintf(esc_attr__('Copy creation failed, could not find original View with ID #%d', 'gravityview'), $id)); |
|
354 | 354 | |
355 | 355 | } |
356 | 356 | } |