@@ -26,21 +26,21 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | protected $value; |
| 28 | 28 | |
| 29 | - function __construct( $name = '', $field = array(), $curr_value = NULL ) { |
|
| 29 | + function __construct($name = '', $field = array(), $curr_value = NULL) { |
|
| 30 | 30 | |
| 31 | 31 | $this->name = $name; |
| 32 | 32 | |
| 33 | 33 | $defaults = self::get_field_defaults(); |
| 34 | 34 | |
| 35 | 35 | // Backward compatibility |
| 36 | - if( !empty( $field['choices'] ) ) { |
|
| 36 | + if (!empty($field['choices'])) { |
|
| 37 | 37 | $field['options'] = $field['choices']; |
| 38 | - unset( $field['choices'] ); |
|
| 38 | + unset($field['choices']); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $this->field = wp_parse_args( $field, $defaults ); |
|
| 41 | + $this->field = wp_parse_args($field, $defaults); |
|
| 42 | 42 | |
| 43 | - $this->value = is_null( $curr_value ) ? $this->field['value'] : $curr_value; |
|
| 43 | + $this->value = is_null($curr_value) ? $this->field['value'] : $curr_value; |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | function get_tooltip() { |
| 81 | - if( !function_exists('gform_tooltip') ) { |
|
| 81 | + if (!function_exists('gform_tooltip')) { |
|
| 82 | 82 | return NULL; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - return !empty( $this->field['tooltip'] ) ? ' '.gform_tooltip( $this->field['tooltip'] , false, true ) : NULL; |
|
| 85 | + return !empty($this->field['tooltip']) ? ' '.gform_tooltip($this->field['tooltip'], false, true) : NULL; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | * @return string |
| 91 | 91 | */ |
| 92 | 92 | function get_field_id() { |
| 93 | - if( isset( $this->field['id'] ) ) { |
|
| 94 | - return esc_attr( $this->field['id'] ); |
|
| 93 | + if (isset($this->field['id'])) { |
|
| 94 | + return esc_attr($this->field['id']); |
|
| 95 | 95 | } |
| 96 | - return esc_attr( sanitize_html_class( $this->name ) ); |
|
| 96 | + return esc_attr(sanitize_html_class($this->name)); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return string |
| 102 | 102 | */ |
| 103 | 103 | function get_field_label() { |
| 104 | - return esc_html( trim( $this->field['label'] ) ); |
|
| 104 | + return esc_html(trim($this->field['label'])); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | 114 | function get_field_left_label() { |
| 115 | - return ! empty( $this->field['left_label'] ) ? esc_html( trim( $this->field['left_label'] ) ) : NULL; |
|
| 115 | + return !empty($this->field['left_label']) ? esc_html(trim($this->field['left_label'])) : NULL; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @return string |
| 121 | 121 | */ |
| 122 | 122 | function get_label_class() { |
| 123 | - return 'gv-label-'. sanitize_html_class( $this->field['type'] ); |
|
| 123 | + return 'gv-label-'.sanitize_html_class($this->field['type']); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return string |
| 130 | 130 | */ |
| 131 | 131 | function get_field_desc() { |
| 132 | - return !empty( $this->field['desc'] ) ? '<span class="howto">'. $this->field['desc'] .'</span>' : ''; |
|
| 132 | + return !empty($this->field['desc']) ? '<span class="howto">'.$this->field['desc'].'</span>' : ''; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | function show_merge_tags() { |
| 141 | 141 | // Show the merge tags if the field is a list view |
| 142 | - $is_list = preg_match( '/_list-/ism', $this->name ); |
|
| 142 | + $is_list = preg_match('/_list-/ism', $this->name); |
|
| 143 | 143 | // Or is a single entry view |
| 144 | - $is_single = preg_match( '/single_/ism', $this->name ); |
|
| 144 | + $is_single = preg_match('/single_/ism', $this->name); |
|
| 145 | 145 | |
| 146 | - return ( $is_single || $is_list ); |
|
| 146 | + return ($is_single || $is_list); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
@@ -160,25 +160,25 @@ discard block |
||
| 160 | 160 | * important! Override this class if needed |
| 161 | 161 | * outputs the field setting html |
| 162 | 162 | */ |
| 163 | - function render_setting( $override_input = NULL ) { |
|
| 163 | + function render_setting($override_input = NULL) { |
|
| 164 | 164 | |
| 165 | - if( !empty( $this->field['full_width'] ) ) { ?> |
|
| 165 | + if (!empty($this->field['full_width'])) { ?> |
|
| 166 | 166 | <th scope="row" colspan="2"> |
| 167 | 167 | <div> |
| 168 | 168 | <label for="<?php echo $this->get_field_id(); ?>"> |
| 169 | - <?php echo $this->get_field_label() . $this->get_tooltip(); ?> |
|
| 169 | + <?php echo $this->get_field_label().$this->get_tooltip(); ?> |
|
| 170 | 170 | </label> |
| 171 | 171 | </div> |
| 172 | - <?php $this->render_input( $override_input ); ?> |
|
| 172 | + <?php $this->render_input($override_input); ?> |
|
| 173 | 173 | </th> |
| 174 | 174 | <?php } else { ?> |
| 175 | 175 | <th scope="row"> |
| 176 | 176 | <label for="<?php echo $this->get_field_id(); ?>"> |
| 177 | - <?php echo $this->get_field_label() . $this->get_tooltip(); ?> |
|
| 177 | + <?php echo $this->get_field_label().$this->get_tooltip(); ?> |
|
| 178 | 178 | </label> |
| 179 | 179 | </th> |
| 180 | 180 | <td> |
| 181 | - <?php $this->render_input( $override_input ); ?> |
|
| 181 | + <?php $this->render_input($override_input); ?> |
|
| 182 | 182 | </td> |
| 183 | 183 | <?php } |
| 184 | 184 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * important! Override this class |
| 189 | 189 | * outputs the input html part |
| 190 | 190 | */ |
| 191 | - function render_input( $override_input ) { |
|
| 191 | + function render_input($override_input) { |
|
| 192 | 192 | echo ''; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -12,12 +12,12 @@ 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 | |
| 19 | -if( ! class_exists( 'Gamajo_Template_Loader' ) ) { |
|
| 20 | - require( GRAVITYVIEW_DIR . 'includes/lib/class-gamajo-template-loader.php' ); |
|
| 19 | +if (!class_exists('Gamajo_Template_Loader')) { |
|
| 20 | + require(GRAVITYVIEW_DIR.'includes/lib/class-gamajo-template-loader.php'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | class GravityView_View extends Gamajo_Template_Loader { |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | * Construct the view object |
| 146 | 146 | * @param array $atts Associative array to set the data of |
| 147 | 147 | */ |
| 148 | - function __construct( $atts = array() ) { |
|
| 148 | + function __construct($atts = array()) { |
|
| 149 | 149 | |
| 150 | - $atts = wp_parse_args( $atts, array( |
|
| 150 | + $atts = wp_parse_args($atts, array( |
|
| 151 | 151 | 'form_id' => NULL, |
| 152 | 152 | 'view_id' => NULL, |
| 153 | 153 | 'fields' => NULL, |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | 'post_id' => NULL, |
| 156 | 156 | 'form' => NULL, |
| 157 | 157 | 'atts' => NULL, |
| 158 | - ) ); |
|
| 158 | + )); |
|
| 159 | 159 | |
| 160 | 160 | foreach ($atts as $key => $value) { |
| 161 | - if( is_null( $value ) ) { |
|
| 161 | + if (is_null($value)) { |
|
| 162 | 162 | continue; |
| 163 | 163 | } |
| 164 | 164 | $this->{$key} = $value; |
@@ -166,18 +166,18 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | |
| 168 | 168 | // Add granular overrides |
| 169 | - add_filter( $this->filter_prefix . '_get_template_part', array( $this, 'add_id_specific_templates' ), 10, 3 ); |
|
| 169 | + add_filter($this->filter_prefix.'_get_template_part', array($this, 'add_id_specific_templates'), 10, 3); |
|
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | // widget logic |
| 173 | - add_action( 'gravityview_before', array( $this, 'render_widget_hooks' ) ); |
|
| 174 | - add_action( 'gravityview_after', array( $this, 'render_widget_hooks' ) ); |
|
| 173 | + add_action('gravityview_before', array($this, 'render_widget_hooks')); |
|
| 174 | + add_action('gravityview_after', array($this, 'render_widget_hooks')); |
|
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | 177 | * Clear the current entry after the loop is done |
| 178 | 178 | * @since 1.7.3 |
| 179 | 179 | */ |
| 180 | - add_action( 'gravityview_footer', array( $this, 'clearCurrentEntry' ), 500 ); |
|
| 180 | + add_action('gravityview_footer', array($this, 'clearCurrentEntry'), 500); |
|
| 181 | 181 | |
| 182 | 182 | self::$instance = &$this; |
| 183 | 183 | } |
@@ -187,10 +187,10 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @return GravityView_View |
| 189 | 189 | */ |
| 190 | - static function getInstance( $passed_post = NULL ) { |
|
| 190 | + static function getInstance($passed_post = NULL) { |
|
| 191 | 191 | |
| 192 | - if( empty( self::$instance ) ) { |
|
| 193 | - self::$instance = new self( $passed_post ); |
|
| 192 | + if (empty(self::$instance)) { |
|
| 193 | + self::$instance = new self($passed_post); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | return self::$instance; |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | * @param string|null $key The key to a specific attribute of the current field |
| 201 | 201 | * @return array|mixed|null If $key is set and attribute exists at $key, return that. If not set, return NULL. Otherwise, return current field array |
| 202 | 202 | */ |
| 203 | - public function getCurrentField( $key = NULL ) { |
|
| 203 | + public function getCurrentField($key = NULL) { |
|
| 204 | 204 | |
| 205 | - if( !empty( $key ) ) { |
|
| 206 | - if( isset( $this->_current_field[ $key ] ) ) { |
|
| 207 | - return $this->_current_field[ $key ]; |
|
| 205 | + if (!empty($key)) { |
|
| 206 | + if (isset($this->_current_field[$key])) { |
|
| 207 | + return $this->_current_field[$key]; |
|
| 208 | 208 | } |
| 209 | 209 | return NULL; |
| 210 | 210 | } |
@@ -212,19 +212,19 @@ discard block |
||
| 212 | 212 | return $this->_current_field; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - public function setCurrentFieldSetting( $key, $value ) { |
|
| 215 | + public function setCurrentFieldSetting($key, $value) { |
|
| 216 | 216 | |
| 217 | - if( !empty( $this->_current_field ) ) { |
|
| 218 | - $this->_current_field['field_settings'][ $key ] = $value; |
|
| 217 | + if (!empty($this->_current_field)) { |
|
| 218 | + $this->_current_field['field_settings'][$key] = $value; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - public function getCurrentFieldSetting( $key ) { |
|
| 223 | + public function getCurrentFieldSetting($key) { |
|
| 224 | 224 | $settings = $this->getCurrentField('field_settings'); |
| 225 | 225 | |
| 226 | - if( $settings && !empty( $settings[ $key ] ) ) { |
|
| 227 | - return $settings[ $key ]; |
|
| 226 | + if ($settings && !empty($settings[$key])) { |
|
| 227 | + return $settings[$key]; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | return NULL; |
@@ -233,11 +233,11 @@ discard block |
||
| 233 | 233 | /** |
| 234 | 234 | * @param array $passed_field |
| 235 | 235 | */ |
| 236 | - public function setCurrentField( $passed_field ) { |
|
| 236 | + public function setCurrentField($passed_field) { |
|
| 237 | 237 | |
| 238 | 238 | $existing_field = $this->getCurrentField(); |
| 239 | 239 | |
| 240 | - $set_field = wp_parse_args( $passed_field, $existing_field ); |
|
| 240 | + $set_field = wp_parse_args($passed_field, $existing_field); |
|
| 241 | 241 | |
| 242 | 242 | $this->_current_field = $set_field; |
| 243 | 243 | |
@@ -252,11 +252,11 @@ discard block |
||
| 252 | 252 | * @param string|null $key The key to a specific field in the fields array |
| 253 | 253 | * @return array|mixed|null If $key is set and field exists at $key, return that. If not set, return NULL. Otherwise, return array of fields. |
| 254 | 254 | */ |
| 255 | - public function getAtts( $key = NULL ) { |
|
| 255 | + public function getAtts($key = NULL) { |
|
| 256 | 256 | |
| 257 | - if( !empty( $key ) ) { |
|
| 258 | - if( isset( $this->atts[ $key ] ) ) { |
|
| 259 | - return $this->atts[ $key ]; |
|
| 257 | + if (!empty($key)) { |
|
| 258 | + if (isset($this->atts[$key])) { |
|
| 259 | + return $this->atts[$key]; |
|
| 260 | 260 | } |
| 261 | 261 | return NULL; |
| 262 | 262 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | /** |
| 268 | 268 | * @param array $atts |
| 269 | 269 | */ |
| 270 | - public function setAtts( $atts ) { |
|
| 270 | + public function setAtts($atts) { |
|
| 271 | 271 | $this->atts = $atts; |
| 272 | 272 | } |
| 273 | 273 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | /** |
| 282 | 282 | * @param array $form |
| 283 | 283 | */ |
| 284 | - public function setForm( $form ) { |
|
| 284 | + public function setForm($form) { |
|
| 285 | 285 | $this->form = $form; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | /** |
| 296 | 296 | * @param int|null $post_id |
| 297 | 297 | */ |
| 298 | - public function setPostId( $post_id ) { |
|
| 298 | + public function setPostId($post_id) { |
|
| 299 | 299 | $this->post_id = $post_id; |
| 300 | 300 | } |
| 301 | 301 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | /** |
| 310 | 310 | * @param string $context |
| 311 | 311 | */ |
| 312 | - public function setContext( $context ) { |
|
| 312 | + public function setContext($context) { |
|
| 313 | 313 | $this->context = $context; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -317,12 +317,12 @@ discard block |
||
| 317 | 317 | * @param string|null $key The key to a specific field in the fields array |
| 318 | 318 | * @return array|mixed|null If $key is set and field exists at $key, return that. If not set, return NULL. Otherwise, return array of fields. |
| 319 | 319 | */ |
| 320 | - public function getFields( $key = null ) { |
|
| 320 | + public function getFields($key = null) { |
|
| 321 | 321 | |
| 322 | - $fields = empty( $this->fields ) ? NULL : $this->fields; |
|
| 322 | + $fields = empty($this->fields) ? NULL : $this->fields; |
|
| 323 | 323 | |
| 324 | - if( $fields && !empty( $key ) ) { |
|
| 325 | - $fields = isset( $fields[ $key ] ) ? $fields[ $key ] : NULL; |
|
| 324 | + if ($fields && !empty($key)) { |
|
| 325 | + $fields = isset($fields[$key]) ? $fields[$key] : NULL; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | return $fields; |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | /** |
| 332 | 332 | * @param array $fields |
| 333 | 333 | */ |
| 334 | - public function setFields( $fields ) { |
|
| 334 | + public function setFields($fields) { |
|
| 335 | 335 | $this->fields = $fields; |
| 336 | 336 | } |
| 337 | 337 | |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | * @param string $key The key to a specific field in the fields array |
| 340 | 340 | * @return array|mixed|null If $key is set and field exists at $key, return that. If not set, return NULL. Otherwise, return array of fields. |
| 341 | 341 | */ |
| 342 | - public function getField( $key ) { |
|
| 342 | + public function getField($key) { |
|
| 343 | 343 | |
| 344 | - if( !empty( $key ) ) { |
|
| 345 | - if( isset( $this->fields[ $key ] ) ) { |
|
| 346 | - return $this->fields[ $key ]; |
|
| 344 | + if (!empty($key)) { |
|
| 345 | + if (isset($this->fields[$key])) { |
|
| 346 | + return $this->fields[$key]; |
|
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
@@ -354,22 +354,22 @@ discard block |
||
| 354 | 354 | * @param string $key The key to a specific field in the fields array |
| 355 | 355 | * @param mixed $value The value to set for the field |
| 356 | 356 | */ |
| 357 | - public function setField( $key, $value ) { |
|
| 358 | - $this->fields[ $key ] = $value; |
|
| 357 | + public function setField($key, $value) { |
|
| 358 | + $this->fields[$key] = $value; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * @return int |
| 363 | 363 | */ |
| 364 | 364 | public function getViewId() { |
| 365 | - return absint( $this->view_id ); |
|
| 365 | + return absint($this->view_id); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | /** |
| 369 | 369 | * @param int $view_id |
| 370 | 370 | */ |
| 371 | - public function setViewId( $view_id ) { |
|
| 372 | - $this->view_id = intval( $view_id ); |
|
| 371 | + public function setViewId($view_id) { |
|
| 372 | + $this->view_id = intval($view_id); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | /** |
| 383 | 383 | * @param int $form_id |
| 384 | 384 | */ |
| 385 | - public function setFormId( $form_id ) { |
|
| 385 | + public function setFormId($form_id) { |
|
| 386 | 386 | $this->form_id = $form_id; |
| 387 | 387 | } |
| 388 | 388 | |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | /** |
| 397 | 397 | * @param array $entries |
| 398 | 398 | */ |
| 399 | - public function setEntries( $entries ) { |
|
| 399 | + public function setEntries($entries) { |
|
| 400 | 400 | $this->entries = $entries; |
| 401 | 401 | } |
| 402 | 402 | |
@@ -410,8 +410,8 @@ discard block |
||
| 410 | 410 | /** |
| 411 | 411 | * @param int $total_entries |
| 412 | 412 | */ |
| 413 | - public function setTotalEntries( $total_entries ) { |
|
| 414 | - $this->total_entries = intval( $total_entries ); |
|
| 413 | + public function setTotalEntries($total_entries) { |
|
| 414 | + $this->total_entries = intval($total_entries); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | /** |
| 425 | 425 | * @param array $paging |
| 426 | 426 | */ |
| 427 | - public function setPaging( $paging ) { |
|
| 427 | + public function setPaging($paging) { |
|
| 428 | 428 | $this->paging = $paging; |
| 429 | 429 | } |
| 430 | 430 | |
@@ -446,25 +446,25 @@ discard block |
||
| 446 | 446 | $page_size = $paging['page_size']; |
| 447 | 447 | $total = $this->getTotalEntries(); |
| 448 | 448 | |
| 449 | - if ( empty( $total ) ) { |
|
| 450 | - do_action( 'gravityview_log_debug', __METHOD__ . ': No entries. Returning empty array.' ); |
|
| 449 | + if (empty($total)) { |
|
| 450 | + do_action('gravityview_log_debug', __METHOD__.': No entries. Returning empty array.'); |
|
| 451 | 451 | |
| 452 | 452 | return array(); |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - $first = empty( $offset ) ? 1 : $offset + 1; |
|
| 455 | + $first = empty($offset) ? 1 : $offset + 1; |
|
| 456 | 456 | |
| 457 | 457 | // If the page size + starting entry is larger than total, the total is the max. |
| 458 | - $last = ( $offset + $page_size > $total ) ? $total : $offset + $page_size; |
|
| 458 | + $last = ($offset + $page_size > $total) ? $total : $offset + $page_size; |
|
| 459 | 459 | |
| 460 | 460 | /** |
| 461 | 461 | * @filter `gravityview_pagination_counts` Modify the displayed pagination numbers |
| 462 | 462 | * @since 1.13 |
| 463 | 463 | * @param array $counts Array with $first, $last, $total numbers in that order |
| 464 | 464 | */ |
| 465 | - list( $first, $last, $total ) = apply_filters( 'gravityview_pagination_counts', array( $first, $last, $total ) ); |
|
| 465 | + list($first, $last, $total) = apply_filters('gravityview_pagination_counts', array($first, $last, $total)); |
|
| 466 | 466 | |
| 467 | - return array( 'first' => (int) $first, 'last' => (int) $last, 'total' => (int) $total ); |
|
| 467 | + return array('first' => (int)$first, 'last' => (int)$last, 'total' => (int)$total); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | /** |
| 478 | 478 | * @param array $sorting |
| 479 | 479 | */ |
| 480 | - public function setSorting( $sorting ) { |
|
| 480 | + public function setSorting($sorting) { |
|
| 481 | 481 | $this->sorting = $sorting; |
| 482 | 482 | } |
| 483 | 483 | |
@@ -486,9 +486,9 @@ discard block |
||
| 486 | 486 | */ |
| 487 | 487 | public function getBackLinkLabel() { |
| 488 | 488 | |
| 489 | - $back_link_label = GravityView_API::replace_variables( $this->back_link_label, $this->getForm(), $this->getCurrentEntry() ); |
|
| 489 | + $back_link_label = GravityView_API::replace_variables($this->back_link_label, $this->getForm(), $this->getCurrentEntry()); |
|
| 490 | 490 | |
| 491 | - $back_link_label = do_shortcode( $back_link_label ); |
|
| 491 | + $back_link_label = do_shortcode($back_link_label); |
|
| 492 | 492 | |
| 493 | 493 | return $back_link_label; |
| 494 | 494 | } |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | /** |
| 497 | 497 | * @param string $back_link_label |
| 498 | 498 | */ |
| 499 | - public function setBackLinkLabel( $back_link_label ) { |
|
| 499 | + public function setBackLinkLabel($back_link_label) { |
|
| 500 | 500 | $this->back_link_label = $back_link_label; |
| 501 | 501 | } |
| 502 | 502 | |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | /** |
| 511 | 511 | * @param boolean $hide_until_searched |
| 512 | 512 | */ |
| 513 | - public function setHideUntilSearched( $hide_until_searched ) { |
|
| 513 | + public function setHideUntilSearched($hide_until_searched) { |
|
| 514 | 514 | $this->hide_until_searched = $hide_until_searched; |
| 515 | 515 | } |
| 516 | 516 | |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | /** |
| 525 | 525 | * @param string $template_part_slug |
| 526 | 526 | */ |
| 527 | - public function setTemplatePartSlug( $template_part_slug ) { |
|
| 527 | + public function setTemplatePartSlug($template_part_slug) { |
|
| 528 | 528 | $this->template_part_slug = $template_part_slug; |
| 529 | 529 | } |
| 530 | 530 | |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | /** |
| 539 | 539 | * @param string $template_part_name |
| 540 | 540 | */ |
| 541 | - public function setTemplatePartName( $template_part_name ) { |
|
| 541 | + public function setTemplatePartName($template_part_name) { |
|
| 542 | 542 | $this->template_part_name = $template_part_name; |
| 543 | 543 | } |
| 544 | 544 | |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | */ |
| 549 | 549 | public function getCurrentEntry() { |
| 550 | 550 | |
| 551 | - if( in_array( $this->getContext(), array( 'edit', 'single') ) ) { |
|
| 551 | + if (in_array($this->getContext(), array('edit', 'single'))) { |
|
| 552 | 552 | $entries = $this->getEntries(); |
| 553 | 553 | $entry = $entries[0]; |
| 554 | 554 | } else { |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | /** @since 1.16 Fixes DataTables empty entry issue */ |
| 559 | - if ( empty( $entry ) && ! empty( $this->_current_field['entry'] ) ) { |
|
| 559 | + if (empty($entry) && !empty($this->_current_field['entry'])) { |
|
| 560 | 560 | $entry = $this->_current_field['entry']; |
| 561 | 561 | } |
| 562 | 562 | |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | * @param array $current_entry |
| 568 | 568 | * @return void |
| 569 | 569 | */ |
| 570 | - public function setCurrentEntry( $current_entry ) { |
|
| 570 | + public function setCurrentEntry($current_entry) { |
|
| 571 | 571 | $this->_current_entry = $current_entry; |
| 572 | 572 | } |
| 573 | 573 | |
@@ -589,9 +589,9 @@ discard block |
||
| 589 | 589 | * |
| 590 | 590 | * @return string|null |
| 591 | 591 | */ |
| 592 | - public function renderZone( $zone = '', $atts = array() ) { |
|
| 592 | + public function renderZone($zone = '', $atts = array()) { |
|
| 593 | 593 | |
| 594 | - if( empty( $zone ) ) { |
|
| 594 | + if (empty($zone)) { |
|
| 595 | 595 | do_action('gravityview_log_error', 'GravityView_View[renderZone] No zone defined.'); |
| 596 | 596 | return NULL; |
| 597 | 597 | } |
@@ -604,32 +604,32 @@ discard block |
||
| 604 | 604 | 'hide_empty' => $this->getAtts('hide_empty'), |
| 605 | 605 | ); |
| 606 | 606 | |
| 607 | - $final_atts = wp_parse_args( $atts, $defaults ); |
|
| 607 | + $final_atts = wp_parse_args($atts, $defaults); |
|
| 608 | 608 | |
| 609 | 609 | $output = ''; |
| 610 | 610 | |
| 611 | 611 | $final_atts['zone_id'] = "{$final_atts['context']}_{$final_atts['slug']}-{$zone}"; |
| 612 | 612 | |
| 613 | - $fields = $this->getField( $final_atts['zone_id'] ); |
|
| 613 | + $fields = $this->getField($final_atts['zone_id']); |
|
| 614 | 614 | |
| 615 | 615 | // Backward compatibility |
| 616 | - if( 'table' === $this->getTemplatePartSlug() ) { |
|
| 616 | + if ('table' === $this->getTemplatePartSlug()) { |
|
| 617 | 617 | /** |
| 618 | 618 | * Modify the fields displayed in the table |
| 619 | 619 | * @var array |
| 620 | 620 | */ |
| 621 | - $fields = apply_filters("gravityview_table_cells", $fields, $this ); |
|
| 621 | + $fields = apply_filters("gravityview_table_cells", $fields, $this); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - if( empty( $fields ) ) { |
|
| 624 | + if (empty($fields)) { |
|
| 625 | 625 | return NULL; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | $field_output = ''; |
| 629 | - foreach ( $fields as $field ) { |
|
| 629 | + foreach ($fields as $field) { |
|
| 630 | 630 | $final_atts['field'] = $field; |
| 631 | 631 | |
| 632 | - $field_output .= gravityview_field_output( $final_atts ); |
|
| 632 | + $field_output .= gravityview_field_output($final_atts); |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /** |
@@ -638,17 +638,17 @@ discard block |
||
| 638 | 638 | * @since 1.7.6 |
| 639 | 639 | * @param boolean $hide_empty_zone Default: false |
| 640 | 640 | */ |
| 641 | - if( empty( $field_output ) && apply_filters( 'gravityview/render/hide-empty-zone', false ) ) { |
|
| 641 | + if (empty($field_output) && apply_filters('gravityview/render/hide-empty-zone', false)) { |
|
| 642 | 642 | return NULL; |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 646 | - $output .= '<div class="'.gravityview_sanitize_html_class( $final_atts['wrapper_class'] ).'">'; |
|
| 645 | + if (!empty($final_atts['wrapper_class'])) { |
|
| 646 | + $output .= '<div class="'.gravityview_sanitize_html_class($final_atts['wrapper_class']).'">'; |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | $output .= $field_output; |
| 650 | 650 | |
| 651 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 651 | + if (!empty($final_atts['wrapper_class'])) { |
|
| 652 | 652 | $output .= '</div>'; |
| 653 | 653 | } |
| 654 | 654 | |
@@ -666,24 +666,24 @@ discard block |
||
| 666 | 666 | * @see Gamajo_Template_Loader::locate_template() |
| 667 | 667 | * @return null|string NULL: Template not found; String: path to template |
| 668 | 668 | */ |
| 669 | - function locate_template( $template_names, $load = false, $require_once = true ) { |
|
| 669 | + function locate_template($template_names, $load = false, $require_once = true) { |
|
| 670 | 670 | |
| 671 | - if( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 671 | + if (is_string($template_names) && isset($this->located_templates[$template_names])) { |
|
| 672 | 672 | |
| 673 | - $located = $this->located_templates[ $template_names ]; |
|
| 673 | + $located = $this->located_templates[$template_names]; |
|
| 674 | 674 | |
| 675 | 675 | } else { |
| 676 | 676 | |
| 677 | 677 | // Set $load to always false so we handle it here. |
| 678 | - $located = parent::locate_template( $template_names, false, $require_once ); |
|
| 678 | + $located = parent::locate_template($template_names, false, $require_once); |
|
| 679 | 679 | |
| 680 | - if( is_string( $template_names ) ) { |
|
| 681 | - $this->located_templates[ $template_names ] = $located; |
|
| 680 | + if (is_string($template_names)) { |
|
| 681 | + $this->located_templates[$template_names] = $located; |
|
| 682 | 682 | } |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | - if ( $load && $located ) { |
|
| 686 | - load_template( $located, $require_once ); |
|
| 685 | + if ($load && $located) { |
|
| 686 | + load_template($located, $require_once); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | return $located; |
@@ -694,8 +694,8 @@ discard block |
||
| 694 | 694 | * @param string $name Key for the data retrieval. |
| 695 | 695 | * @return mixed|null The stored data. |
| 696 | 696 | */ |
| 697 | - public function __get( $name ) { |
|
| 698 | - if( isset( $this->{$name} ) ) { |
|
| 697 | + public function __get($name) { |
|
| 698 | + if (isset($this->{$name} )) { |
|
| 699 | 699 | return $this->{$name}; |
| 700 | 700 | } else { |
| 701 | 701 | return NULL; |
@@ -719,47 +719,47 @@ discard block |
||
| 719 | 719 | * |
| 720 | 720 | * @return array $templates Modified template array, merged with existing $templates values |
| 721 | 721 | */ |
| 722 | - function add_id_specific_templates( $templates, $slug, $name ) { |
|
| 722 | + function add_id_specific_templates($templates, $slug, $name) { |
|
| 723 | 723 | |
| 724 | 724 | $additional = array(); |
| 725 | 725 | |
| 726 | 726 | // form-19-table-body.php |
| 727 | - $additional[] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 727 | + $additional[] = sprintf('form-%d-%s-%s.php', $this->getFormId(), $slug, $name); |
|
| 728 | 728 | |
| 729 | 729 | // view-3-table-body.php |
| 730 | - $additional[] = sprintf( 'view-%d-%s-%s.php', $this->getViewId(), $slug, $name ); |
|
| 730 | + $additional[] = sprintf('view-%d-%s-%s.php', $this->getViewId(), $slug, $name); |
|
| 731 | 731 | |
| 732 | - if( $this->getPostId() ) { |
|
| 732 | + if ($this->getPostId()) { |
|
| 733 | 733 | |
| 734 | 734 | // page-19-table-body.php |
| 735 | - $additional[] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 735 | + $additional[] = sprintf('page-%d-%s-%s.php', $this->getPostId(), $slug, $name); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | // Combine with existing table-body.php and table.php |
| 739 | - $templates = array_merge( $additional, $templates ); |
|
| 739 | + $templates = array_merge($additional, $templates); |
|
| 740 | 740 | |
| 741 | - do_action( 'gravityview_log_debug', '[add_id_specific_templates] List of Template Files', $templates ); |
|
| 741 | + do_action('gravityview_log_debug', '[add_id_specific_templates] List of Template Files', $templates); |
|
| 742 | 742 | |
| 743 | 743 | return $templates; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | // Load the template |
| 747 | - public function render( $slug, $name, $require_once = true ) { |
|
| 747 | + public function render($slug, $name, $require_once = true) { |
|
| 748 | 748 | |
| 749 | - $this->setTemplatePartSlug( $slug ); |
|
| 749 | + $this->setTemplatePartSlug($slug); |
|
| 750 | 750 | |
| 751 | - $this->setTemplatePartName( $name ); |
|
| 751 | + $this->setTemplatePartName($name); |
|
| 752 | 752 | |
| 753 | - $template_file = $this->get_template_part( $slug, $name, false ); |
|
| 753 | + $template_file = $this->get_template_part($slug, $name, false); |
|
| 754 | 754 | |
| 755 | - do_action( 'gravityview_log_debug', '[render] Rendering Template File', $template_file ); |
|
| 755 | + do_action('gravityview_log_debug', '[render] Rendering Template File', $template_file); |
|
| 756 | 756 | |
| 757 | - if( !empty( $template_file) ) { |
|
| 757 | + if (!empty($template_file)) { |
|
| 758 | 758 | |
| 759 | - if ( $require_once ) { |
|
| 760 | - require_once( $template_file ); |
|
| 759 | + if ($require_once) { |
|
| 760 | + require_once($template_file); |
|
| 761 | 761 | } else { |
| 762 | - require( $template_file ); |
|
| 762 | + require($template_file); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | } |
@@ -769,19 +769,19 @@ discard block |
||
| 769 | 769 | * |
| 770 | 770 | * @param $view_id |
| 771 | 771 | */ |
| 772 | - public function render_widget_hooks( $view_id ) { |
|
| 772 | + public function render_widget_hooks($view_id) { |
|
| 773 | 773 | |
| 774 | - if( empty( $view_id ) || 'single' == gravityview_get_context() ) { |
|
| 775 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Not rendering widgets; single entry' ); |
|
| 774 | + if (empty($view_id) || 'single' == gravityview_get_context()) { |
|
| 775 | + do_action('gravityview_log_debug', __METHOD__.' - Not rendering widgets; single entry'); |
|
| 776 | 776 | return; |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | - $view_data = gravityview_get_current_view_data( $view_id ); |
|
| 779 | + $view_data = gravityview_get_current_view_data($view_id); |
|
| 780 | 780 | |
| 781 | 781 | // get View widget configuration |
| 782 | 782 | $widgets = (array)$view_data['widgets']; |
| 783 | 783 | |
| 784 | - switch( current_filter() ) { |
|
| 784 | + switch (current_filter()) { |
|
| 785 | 785 | default: |
| 786 | 786 | case 'gravityview_before': |
| 787 | 787 | $zone = 'header'; |
@@ -795,10 +795,10 @@ discard block |
||
| 795 | 795 | * Filter widgets not in the current zone |
| 796 | 796 | * @since 1.16 |
| 797 | 797 | */ |
| 798 | - foreach( $widgets as $key => $widget ) { |
|
| 798 | + foreach ($widgets as $key => $widget) { |
|
| 799 | 799 | // The widget isn't in the current zone |
| 800 | - if( false === strpos( $key, $zone ) ) { |
|
| 801 | - unset( $widgets[ $key ] ); |
|
| 800 | + if (false === strpos($key, $zone)) { |
|
| 801 | + unset($widgets[$key]); |
|
| 802 | 802 | } |
| 803 | 803 | } |
| 804 | 804 | |
@@ -806,37 +806,37 @@ discard block |
||
| 806 | 806 | * Prevent output if no widgets to show. |
| 807 | 807 | * @since 1.16 |
| 808 | 808 | */ |
| 809 | - if ( empty( $widgets ) ) { |
|
| 810 | - do_action( 'gravityview_log_debug', sprintf( 'No widgets for View #%s', $view_id ) ); |
|
| 809 | + if (empty($widgets)) { |
|
| 810 | + do_action('gravityview_log_debug', sprintf('No widgets for View #%s', $view_id)); |
|
| 811 | 811 | return; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | // Prevent being called twice |
| 815 | - if( did_action( $zone.'_'.$view_id.'_widgets' ) ) { |
|
| 816 | - do_action( 'gravityview_log_debug', sprintf( '%s - Not rendering %s; already rendered', __METHOD__ , $zone.'_'.$view_id.'_widgets' ) ); |
|
| 815 | + if (did_action($zone.'_'.$view_id.'_widgets')) { |
|
| 816 | + do_action('gravityview_log_debug', sprintf('%s - Not rendering %s; already rendered', __METHOD__, $zone.'_'.$view_id.'_widgets')); |
|
| 817 | 817 | return; |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | $rows = GravityView_Plugin::get_default_widget_areas(); |
| 821 | 821 | |
| 822 | 822 | // TODO: Move to sep. method, use an action instead |
| 823 | - wp_enqueue_style( 'gravityview_default_style' ); |
|
| 823 | + wp_enqueue_style('gravityview_default_style'); |
|
| 824 | 824 | |
| 825 | 825 | // TODO Convert to partials |
| 826 | 826 | ?> |
| 827 | 827 | <div class="gv-grid"> |
| 828 | 828 | <?php |
| 829 | - foreach( $rows as $row ) { |
|
| 830 | - foreach( $row as $col => $areas ) { |
|
| 829 | + foreach ($rows as $row) { |
|
| 830 | + foreach ($row as $col => $areas) { |
|
| 831 | 831 | $column = ($col == '2-2') ? '1-2 gv-right' : $col.' gv-left'; |
| 832 | 832 | ?> |
| 833 | - <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
|
| 833 | + <div class="gv-grid-col-<?php echo esc_attr($column); ?>"> |
|
| 834 | 834 | <?php |
| 835 | - if( !empty( $areas ) ) { |
|
| 836 | - foreach( $areas as $area ) { |
|
| 837 | - if( !empty( $widgets[ $zone .'_'. $area['areaid'] ] ) ) { |
|
| 838 | - foreach( $widgets[ $zone .'_'. $area['areaid'] ] as $widget ) { |
|
| 839 | - do_action( "gravityview_render_widget_{$widget['id']}", $widget ); |
|
| 835 | + if (!empty($areas)) { |
|
| 836 | + foreach ($areas as $area) { |
|
| 837 | + if (!empty($widgets[$zone.'_'.$area['areaid']])) { |
|
| 838 | + foreach ($widgets[$zone.'_'.$area['areaid']] as $widget) { |
|
| 839 | + do_action("gravityview_render_widget_{$widget['id']}", $widget); |
|
| 840 | 840 | } |
| 841 | 841 | } |
| 842 | 842 | } |
@@ -852,8 +852,8 @@ discard block |
||
| 852 | 852 | * Prevent widgets from being called twice. |
| 853 | 853 | * Checking for loop_start prevents themes and plugins that pre-process shortcodes from triggering the action before displaying. Like, ahem, the Divi theme and WordPress SEO plugin |
| 854 | 854 | */ |
| 855 | - if( did_action( 'loop_start' ) ) { |
|
| 856 | - do_action( $zone.'_'.$view_id.'_widgets' ); |
|
| 855 | + if (did_action('loop_start')) { |
|
| 856 | + do_action($zone.'_'.$view_id.'_widgets'); |
|
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | 859 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | var $is_numeric = true; |
| 16 | 16 | |
| 17 | - var $search_operators = array( 'is', 'isnot' ); |
|
| 17 | + var $search_operators = array('is', 'isnot'); |
|
| 18 | 18 | |
| 19 | 19 | var $group = 'pricing'; |
| 20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * GravityView_Field_Payment_Amount constructor. |
| 25 | 25 | */ |
| 26 | 26 | public function __construct() { |
| 27 | - $this->label = esc_attr__( 'Transaction ID', 'gravityview' ); |
|
| 27 | + $this->label = esc_attr__('Transaction ID', 'gravityview'); |
|
| 28 | 28 | parent::__construct(); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | var $is_numeric = true; |
| 16 | 16 | |
| 17 | - var $search_operators = array( 'is', 'isnot' ); |
|
| 17 | + var $search_operators = array('is', 'isnot'); |
|
| 18 | 18 | |
| 19 | 19 | var $group = 'pricing'; |
| 20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * GravityView_Field_Payment_Amount constructor. |
| 25 | 25 | */ |
| 26 | 26 | public function __construct() { |
| 27 | - $this->label = esc_attr__( 'Currency', 'gravityview' ); |
|
| 27 | + $this->label = esc_attr__('Currency', 'gravityview'); |
|
| 28 | 28 | parent::__construct(); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -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 = gravityview_get_form( $form_id ); |
|
| 1090 | + $form = gravityview_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,12 +1371,12 @@ 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 = array() ) { |
|
| 1374 | + public function is_field_sortable($field_id = '', $form = array()) { |
|
| 1375 | 1375 | |
| 1376 | 1376 | $field_type = $field_id; |
| 1377 | 1377 | |
| 1378 | - if( is_numeric( $field_id ) ) { |
|
| 1379 | - $field = GFFormsModel::get_field( $form, $field_id ); |
|
| 1378 | + if (is_numeric($field_id)) { |
|
| 1379 | + $field = GFFormsModel::get_field($form, $field_id); |
|
| 1380 | 1380 | $field_type = $field->type; |
| 1381 | 1381 | } |
| 1382 | 1382 | |
@@ -1392,13 +1392,13 @@ discard block |
||
| 1392 | 1392 | * @param string $field_type Field type to check whether the field is sortable |
| 1393 | 1393 | * @param array $form Gravity Forms form |
| 1394 | 1394 | */ |
| 1395 | - $not_sortable = apply_filters( 'gravityview/sortable/field_blacklist', $not_sortable, $field_type, $form ); |
|
| 1395 | + $not_sortable = apply_filters('gravityview/sortable/field_blacklist', $not_sortable, $field_type, $form); |
|
| 1396 | 1396 | |
| 1397 | - if ( in_array( $field_type, $not_sortable ) ) { |
|
| 1397 | + if (in_array($field_type, $not_sortable)) { |
|
| 1398 | 1398 | return false; |
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
| 1401 | + return apply_filters("gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters("gravityview/sortable/field_{$field_id}", true, $form)); |
|
| 1402 | 1402 | |
| 1403 | 1403 | } |
| 1404 | 1404 | |
@@ -8,6 +8,6 @@ |
||
| 8 | 8 | |
| 9 | 9 | $gravityview_view = GravityView_View::getInstance(); |
| 10 | 10 | |
| 11 | -extract( $gravityview_view->getCurrentField() ); |
|
| 11 | +extract($gravityview_view->getCurrentField()); |
|
| 12 | 12 | |
| 13 | -echo GVCommon::format_date( $value, 'format=' . rgar( $field_settings, 'date_display' ) ); |
|
| 14 | 13 | \ No newline at end of file |
| 14 | +echo GVCommon::format_date($value, 'format='.rgar($field_settings, 'date_display')); |
|
| 15 | 15 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | private function add_hooks() { |
| 21 | 21 | |
| 22 | 22 | /** @see GFCommon::replace_variables_prepopulate **/ |
| 23 | - add_filter( 'gform_replace_merge_tags', array( 'GravityView_Merge_Tags', 'replace_gv_merge_tags' ), 10, 7 ); |
|
| 23 | + add_filter('gform_replace_merge_tags', array('GravityView_Merge_Tags', 'replace_gv_merge_tags'), 10, 7); |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param bool $esc_html Pass return value through `esc_html()` |
| 42 | 42 | * @return string Text with variables maybe replaced |
| 43 | 43 | */ |
| 44 | - public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) { |
|
| 44 | + public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true) { |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * @param[in] array $form GF Form array |
| 54 | 54 | * @param[in] array $entry GF Entry array |
| 55 | 55 | */ |
| 56 | - $do_replace_variables = apply_filters( 'gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry ); |
|
| 56 | + $do_replace_variables = apply_filters('gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry); |
|
| 57 | 57 | |
| 58 | - if ( strpos( $text, '{' ) === false || ! $do_replace_variables ) { |
|
| 58 | + if (strpos($text, '{') === false || !$do_replace_variables) { |
|
| 59 | 59 | return $text; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @internal Reported to GF Support on 12/3 |
| 66 | 66 | */ |
| 67 | - $form['title'] = isset( $form['title'] ) ? $form['title'] : ''; |
|
| 68 | - $form['id'] = isset( $form['id'] ) ? $form['id'] : ''; |
|
| 69 | - $form['fields'] = isset( $form['fields'] ) ? $form['fields'] : array(); |
|
| 67 | + $form['title'] = isset($form['title']) ? $form['title'] : ''; |
|
| 68 | + $form['id'] = isset($form['id']) ? $form['id'] : ''; |
|
| 69 | + $form['fields'] = isset($form['fields']) ? $form['fields'] : array(); |
|
| 70 | 70 | |
| 71 | - return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html ); |
|
| 71 | + return GFCommon::replace_variables($text, $form, $entry, $url_encode, $esc_html); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return mixed |
| 88 | 88 | */ |
| 89 | - public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
| 89 | + public static function replace_gv_merge_tags($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false) { |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * This prevents the gform_replace_merge_tags filter from being called twice, as defined in: |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | * @see GFCommon::replace_variables_prepopulate() |
| 95 | 95 | * @todo Remove eventually: Gravity Forms fixed this issue in 1.9.14 |
| 96 | 96 | */ |
| 97 | - if( false === $form ) { |
|
| 97 | + if (false === $form) { |
|
| 98 | 98 | return $text; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $text = self::replace_get_variables( $text, $form, $entry, $url_encode ); |
|
| 101 | + $text = self::replace_get_variables($text, $form, $entry, $url_encode); |
|
| 102 | 102 | |
| 103 | 103 | return $text; |
| 104 | 104 | } |
@@ -115,21 +115,21 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @return int|string If timestamp requested, timestamp int. Otherwise, string output. |
| 117 | 117 | */ |
| 118 | - public static function format_date( $date_created = '', $property = '' ) { |
|
| 118 | + public static function format_date($date_created = '', $property = '') { |
|
| 119 | 119 | |
| 120 | 120 | // Expand all modifiers, skipping escaped colons. str_replace worked better than preg_split( "/(?<!\\):/" ) |
| 121 | - $exploded = explode( ':', str_replace( '\:', '|COLON|', $property ) ); |
|
| 121 | + $exploded = explode(':', str_replace('\:', '|COLON|', $property)); |
|
| 122 | 122 | |
| 123 | 123 | $atts = array( |
| 124 | - 'format' => self::get_format_from_modifiers( $exploded, false ), |
|
| 125 | - 'human' => in_array( 'human', $exploded ), // {date_created:human} |
|
| 126 | - 'diff' => in_array( 'diff', $exploded ), // {date_created:diff} |
|
| 127 | - 'raw' => in_array( 'raw', $exploded ), // {date_created:raw} |
|
| 128 | - 'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp} |
|
| 129 | - 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
| 124 | + 'format' => self::get_format_from_modifiers($exploded, false), |
|
| 125 | + 'human' => in_array('human', $exploded), // {date_created:human} |
|
| 126 | + 'diff' => in_array('diff', $exploded), // {date_created:diff} |
|
| 127 | + 'raw' => in_array('raw', $exploded), // {date_created:raw} |
|
| 128 | + 'timestamp' => in_array('timestamp', $exploded), // {date_created:timestamp} |
|
| 129 | + 'time' => in_array('time', $exploded), // {date_created:time} |
|
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | - $formatted_date = GVCommon::format_date( $date_created, $atts ); |
|
| 132 | + $formatted_date = GVCommon::format_date($date_created, $atts); |
|
| 133 | 133 | |
| 134 | 134 | return $formatted_date; |
| 135 | 135 | } |
@@ -147,16 +147,16 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return string If format is found, the passed format. Otherwise, the backup. |
| 149 | 149 | */ |
| 150 | - private static function get_format_from_modifiers( $exploded, $backup = '' ) { |
|
| 150 | + private static function get_format_from_modifiers($exploded, $backup = '') { |
|
| 151 | 151 | |
| 152 | 152 | $return = $backup; |
| 153 | 153 | |
| 154 | - $format_key_index = array_search( 'format', $exploded ); |
|
| 154 | + $format_key_index = array_search('format', $exploded); |
|
| 155 | 155 | |
| 156 | 156 | // If there's a "format:[php date format string]" date format, grab it |
| 157 | - if ( false !== $format_key_index && isset( $exploded[ $format_key_index + 1 ] ) ) { |
|
| 157 | + if (false !== $format_key_index && isset($exploded[$format_key_index + 1])) { |
|
| 158 | 158 | // Return escaped colons placeholder |
| 159 | - $return = str_replace( '|COLON|', ':', $exploded[ $format_key_index + 1 ] ); |
|
| 159 | + $return = str_replace('|COLON|', ':', $exploded[$format_key_index + 1]); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | return $return; |
@@ -183,22 +183,22 @@ discard block |
||
| 183 | 183 | * @param array $entry Entry array |
| 184 | 184 | * @param bool $url_encode Whether to URL-encode output |
| 185 | 185 | */ |
| 186 | - public static function replace_get_variables( $text, $form = array(), $entry = array(), $url_encode = false ) { |
|
| 186 | + public static function replace_get_variables($text, $form = array(), $entry = array(), $url_encode = false) { |
|
| 187 | 187 | |
| 188 | 188 | // Is there is {get:[xyz]} merge tag? |
| 189 | - preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER ); |
|
| 189 | + preg_match_all("/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER); |
|
| 190 | 190 | |
| 191 | 191 | // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user) |
| 192 | - if( empty( $matches ) ) { |
|
| 192 | + if (empty($matches)) { |
|
| 193 | 193 | return $text; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - foreach ( $matches as $match ) { |
|
| 196 | + foreach ($matches as $match) { |
|
| 197 | 197 | |
| 198 | 198 | $full_tag = $match[0]; |
| 199 | 199 | $property = $match[1]; |
| 200 | 200 | |
| 201 | - $value = stripslashes_deep( rgget( $property ) ); |
|
| 201 | + $value = stripslashes_deep(rgget($property)); |
|
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | 204 | * @filter `gravityview/merge_tags/get/glue/` Modify the glue used to convert an array of `{get}` values from an array to string |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | * @param[in,out] string $glue String used to `implode()` $_GET values Default: ', ' |
| 207 | 207 | * @param[in] string $property The current name of the $_GET parameter being combined |
| 208 | 208 | */ |
| 209 | - $glue = apply_filters( 'gravityview/merge_tags/get/glue/', ', ', $property ); |
|
| 209 | + $glue = apply_filters('gravityview/merge_tags/get/glue/', ', ', $property); |
|
| 210 | 210 | |
| 211 | - $value = is_array( $value ) ? implode( $glue, $value ) : $value; |
|
| 211 | + $value = is_array($value) ? implode($glue, $value) : $value; |
|
| 212 | 212 | |
| 213 | - $value = $url_encode ? urlencode( $value ) : $value; |
|
| 213 | + $value = $url_encode ? urlencode($value) : $value; |
|
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * @filter `gravityview/merge_tags/get/esc_html/{url parameter name}` Disable esc_html() from running on `{get}` merge tag |
@@ -220,9 +220,9 @@ discard block |
||
| 220 | 220 | * @since 1.15 |
| 221 | 221 | * @param bool $esc_html Whether to esc_html() the value. Default: `true` |
| 222 | 222 | */ |
| 223 | - $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
| 223 | + $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/'.$property, true); |
|
| 224 | 224 | |
| 225 | - $value = $esc_html ? esc_html( $value ) : $value; |
|
| 225 | + $value = $esc_html ? esc_html($value) : $value; |
|
| 226 | 226 | |
| 227 | 227 | /** |
| 228 | 228 | * @filter `gravityview/merge_tags/get/esc_html/{url parameter name}` Modify the value of the `{get}` replacement before being used |
@@ -231,12 +231,12 @@ discard block |
||
| 231 | 231 | * @param[in] array $form Gravity Forms form array |
| 232 | 232 | * @param[in] array $entry Entry array |
| 233 | 233 | */ |
| 234 | - $value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
| 234 | + $value = apply_filters('gravityview/merge_tags/get/value/'.$property, $value, $text, $form, $entry); |
|
| 235 | 235 | |
| 236 | - $text = str_replace( $full_tag, $value, $text ); |
|
| 236 | + $text = str_replace($full_tag, $value, $text); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - unset( $value, $glue, $matches ); |
|
| 239 | + unset($value, $glue, $matches); |
|
| 240 | 240 | |
| 241 | 241 | return $text; |
| 242 | 242 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 15 | +if (!defined('ABSPATH')) exit; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * GravityView_Welcome Class |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | * @since 1.0 |
| 35 | 35 | */ |
| 36 | 36 | public function __construct() { |
| 37 | - add_action( 'admin_menu', array( $this, 'admin_menus'), 200 ); |
|
| 38 | - add_action( 'admin_head', array( $this, 'admin_head' ) ); |
|
| 39 | - add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
| 40 | - add_filter( 'gravityview_is_admin_page', array( $this, 'is_dashboard_page'), 10, 2 ); |
|
| 37 | + add_action('admin_menu', array($this, 'admin_menus'), 200); |
|
| 38 | + add_action('admin_head', array($this, 'admin_head')); |
|
| 39 | + add_action('admin_init', array($this, 'welcome')); |
|
| 40 | + add_filter('gravityview_is_admin_page', array($this, 'is_dashboard_page'), 10, 2); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -57,27 +57,27 @@ discard block |
||
| 57 | 57 | __('Getting Started', 'gravityview'), |
| 58 | 58 | $this->minimum_capability, |
| 59 | 59 | 'gv-getting-started', |
| 60 | - array( $this, 'getting_started_screen' ) |
|
| 60 | + array($this, 'getting_started_screen') |
|
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | 63 | // Changelog Page |
| 64 | 64 | add_submenu_page( |
| 65 | 65 | 'edit.php?post_type=gravityview', |
| 66 | - __( 'Changelog', 'gravityview' ), |
|
| 67 | - __( 'Changelog', 'gravityview' ), |
|
| 66 | + __('Changelog', 'gravityview'), |
|
| 67 | + __('Changelog', 'gravityview'), |
|
| 68 | 68 | $this->minimum_capability, |
| 69 | 69 | 'gv-changelog', |
| 70 | - array( $this, 'changelog_screen' ) |
|
| 70 | + array($this, 'changelog_screen') |
|
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | 73 | // Credits Page |
| 74 | 74 | add_submenu_page( |
| 75 | 75 | 'edit.php?post_type=gravityview', |
| 76 | - __( 'Credits', 'gravityview' ), |
|
| 77 | - __( 'Credits', 'gravityview' ), |
|
| 76 | + __('Credits', 'gravityview'), |
|
| 77 | + __('Credits', 'gravityview'), |
|
| 78 | 78 | $this->minimum_capability, |
| 79 | 79 | 'gv-credits', |
| 80 | - array( $this, 'credits_screen' ) |
|
| 80 | + array($this, 'credits_screen') |
|
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | 83 | } |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | public function is_dashboard_page($is_page = false, $hook = NULL) { |
| 91 | 91 | global $plugin_page; |
| 92 | 92 | |
| 93 | - if($is_page) { return $is_page; } |
|
| 93 | + if ($is_page) { return $is_page; } |
|
| 94 | 94 | |
| 95 | - return in_array( $plugin_page, array( 'gv-about', 'gv-credits', 'gv-getting-started' ) ); |
|
| 95 | + return in_array($plugin_page, array('gv-about', 'gv-credits', 'gv-getting-started')); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | public function admin_head() { |
| 106 | 106 | global $plugin_page; |
| 107 | 107 | |
| 108 | - remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-credits' ); |
|
| 109 | - remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-changelog' ); |
|
| 108 | + remove_submenu_page('edit.php?post_type=gravityview', 'gv-credits'); |
|
| 109 | + remove_submenu_page('edit.php?post_type=gravityview', 'gv-changelog'); |
|
| 110 | 110 | |
| 111 | - if( !$this->is_dashboard_page() ) { return; } |
|
| 111 | + if (!$this->is_dashboard_page()) { return; } |
|
| 112 | 112 | |
| 113 | 113 | ?> |
| 114 | 114 | <style type="text/css" media="screen"> |
@@ -139,23 +139,23 @@ discard block |
||
| 139 | 139 | global $plugin_page; |
| 140 | 140 | |
| 141 | 141 | // Don't fetch -beta, etc. |
| 142 | - list( $display_version ) = explode( '-', GravityView_Plugin::version ); |
|
| 142 | + list($display_version) = explode('-', GravityView_Plugin::version); |
|
| 143 | 143 | |
| 144 | - $selected = !empty( $plugin_page ) ? $plugin_page : 'gv-getting-started'; |
|
| 144 | + $selected = !empty($plugin_page) ? $plugin_page : 'gv-getting-started'; |
|
| 145 | 145 | ?> |
| 146 | 146 | |
| 147 | - <h1><img class="alignleft" src="<?php echo plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ); ?>" width="100" height="132" /><?php printf( esc_html__( 'Welcome to GravityView %s', 'gravityview' ), $display_version ); ?></h1> |
|
| 148 | - <div class="about-text"><?php esc_html_e( 'Thank you for installing GravityView. Beautifully display your Gravity Forms entries.', 'gravityview' ); ?></div> |
|
| 147 | + <h1><img class="alignleft" src="<?php echo plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE); ?>" width="100" height="132" /><?php printf(esc_html__('Welcome to GravityView %s', 'gravityview'), $display_version); ?></h1> |
|
| 148 | + <div class="about-text"><?php esc_html_e('Thank you for installing GravityView. Beautifully display your Gravity Forms entries.', 'gravityview'); ?></div> |
|
| 149 | 149 | |
| 150 | 150 | <h2 class="nav-tab-wrapper clear"> |
| 151 | - <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-getting-started', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
| 152 | - <?php _e( "Getting Started", 'gravityview' ); ?> |
|
| 151 | + <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'gv-getting-started', 'post_type' => 'gravityview'), 'edit.php'))); ?>"> |
|
| 152 | + <?php _e("Getting Started", 'gravityview'); ?> |
|
| 153 | 153 | </a> |
| 154 | - <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-changelog', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
| 155 | - <?php _e( "List of Changes", 'gravityview' ); ?> |
|
| 154 | + <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'gv-changelog', 'post_type' => 'gravityview'), 'edit.php'))); ?>"> |
|
| 155 | + <?php _e("List of Changes", 'gravityview'); ?> |
|
| 156 | 156 | </a> |
| 157 | - <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-credits', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
| 158 | - <?php _e( 'Credits', 'gravityview' ); ?> |
|
| 157 | + <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'gv-credits', 'post_type' => 'gravityview'), 'edit.php'))); ?>"> |
|
| 158 | + <?php _e('Credits', 'gravityview'); ?> |
|
| 159 | 159 | </a> |
| 160 | 160 | </h2> |
| 161 | 161 | <?php |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | <div class="last-feature"> |
| 207 | 207 | <h2>Embed Views in Posts & Pages</h2> |
| 208 | - <p><img src="<?php echo plugins_url( 'assets/images/screenshots/add-view-button.png', GRAVITYVIEW_FILE ); ?>" class="gv-welcome-screenshots" height="35" width="97" />Views don’t need to be embedded in a post or page, but you can if you want. Embed Views using the "Add View" button above your content editor.</p> |
|
| 208 | + <p><img src="<?php echo plugins_url('assets/images/screenshots/add-view-button.png', GRAVITYVIEW_FILE); ?>" class="gv-welcome-screenshots" height="35" width="97" />Views don’t need to be embedded in a post or page, but you can if you want. Embed Views using the "Add View" button above your content editor.</p> |
|
| 209 | 209 | </div> |
| 210 | 210 | |
| 211 | 211 | </div> |
| 212 | 212 | |
| 213 | 213 | <div class="feature-section clear"> |
| 214 | 214 | <h2>Configure Multiple Entry, Single Entry, and Edit Entry Layouts</h2> |
| 215 | - <p><img src="<?php echo plugins_url( 'assets/images/screenshots/add-field.png', GRAVITYVIEW_FILE ); ?>" alt="Add a field dialog box" class="gv-welcome-screenshots" />You can configure what fields are displayed in <strong>Multiple Entry</strong>, <strong>Single Entry</strong>, and <strong>Edit Entry</strong> modes. These can be configured by clicking on the tabs in "View Configuration."</p> |
|
| 215 | + <p><img src="<?php echo plugins_url('assets/images/screenshots/add-field.png', GRAVITYVIEW_FILE); ?>" alt="Add a field dialog box" class="gv-welcome-screenshots" />You can configure what fields are displayed in <strong>Multiple Entry</strong>, <strong>Single Entry</strong>, and <strong>Edit Entry</strong> modes. These can be configured by clicking on the tabs in "View Configuration."</p> |
|
| 216 | 216 | |
| 217 | 217 | <ul class="ul-disc"> |
| 218 | 218 | <li>Click "+ Add Field" to add a field to a zone</li> |
@@ -256,13 +256,13 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | <div class="feature-section col two-col" style="margin:0; padding: 0;"> |
| 258 | 258 | <div class="col col-1"> |
| 259 | - <div class="media-container" style="min-height:81px; border: none;"><img src="<?php echo plugins_url( 'assets/images/screenshots/pricing-merge-tags.jpg', GRAVITYVIEW_FILE ); ?>" alt="Pricing merge tags"></div> |
|
| 259 | + <div class="media-container" style="min-height:81px; border: none;"><img src="<?php echo plugins_url('assets/images/screenshots/pricing-merge-tags.jpg', GRAVITYVIEW_FILE); ?>" alt="Pricing merge tags"></div> |
|
| 260 | 260 | <h4 class="higher">Pricing Merge Tags</h4> |
| 261 | 261 | <p>GravityView now offers better support for pricing Merge Tags to show details about orers. <a href="http://docs.gravityview.co/article/76-merge-tags">Read more about the Merge Tags</a>.</p> |
| 262 | 262 | </div> |
| 263 | 263 | |
| 264 | 264 | <div class="col col-2 last-feature"> |
| 265 | - <div class="media-container" style="margin-top: 2em; min-height:80px;"><img src="<?php echo plugins_url( 'assets/images/screenshots/developing-future.jpg', GRAVITYVIEW_FILE ); ?>" alt="Developing the Future"></div> |
|
| 265 | + <div class="media-container" style="margin-top: 2em; min-height:80px;"><img src="<?php echo plugins_url('assets/images/screenshots/developing-future.jpg', GRAVITYVIEW_FILE); ?>" alt="Developing the Future"></div> |
|
| 266 | 266 | <h4 class="higher">Laying the Groundwork</h4> |
| 267 | 267 | <p>We’re working on a great new View Builder to make it easier than ever to configure View layouts. This release includes lots of behind-the-scenes changes.</p> |
| 268 | 268 | </div> |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | |
| 479 | 479 | <?php $this->tabs(); ?> |
| 480 | 480 | |
| 481 | - <p class="about-description"><?php _e( 'GravityView is brought to you by:', 'gravityview' ); ?></p> |
|
| 481 | + <p class="about-description"><?php _e('GravityView is brought to you by:', 'gravityview'); ?></p> |
|
| 482 | 482 | |
| 483 | 483 | <div class="feature-section col two-col"> |
| 484 | 484 | |
@@ -486,14 +486,14 @@ discard block |
||
| 486 | 486 | <h2>Zack Katz</h2> |
| 487 | 487 | <h4 style="font-weight:0; margin-top:0">Project Lead & Developer</h4> |
| 488 | 488 | <p></p> |
| 489 | - <p><img style="float:left; margin: 0 15px 10px 0;" src="<?php echo plugins_url( 'assets/images/zack.jpg', GRAVITYVIEW_FILE ); ?>" width="94" height="94" />Zack has been developing integrations with Gravity Forms since 2009. He is the President of Katz Web Services and lives with his wife (and cat) in Denver, Colorado.</p> |
|
| 489 | + <p><img style="float:left; margin: 0 15px 10px 0;" src="<?php echo plugins_url('assets/images/zack.jpg', GRAVITYVIEW_FILE); ?>" width="94" height="94" />Zack has been developing integrations with Gravity Forms since 2009. He is the President of Katz Web Services and lives with his wife (and cat) in Denver, Colorado.</p> |
|
| 490 | 490 | <p><a href="https://katz.co">View Zack’s website</a></p> |
| 491 | 491 | </div> |
| 492 | 492 | |
| 493 | 493 | <div class="col last-feature"> |
| 494 | 494 | <h2>Luis Godinho</h2> |
| 495 | 495 | <h4 style="font-weight:0; margin-top:0">Developer & Support</h4> |
| 496 | - <p><img style="margin: 0 15px 10px 0;" class="alignleft avatar" src="<?php echo plugins_url( 'assets/images/luis.jpg', GRAVITYVIEW_FILE ); ?>" width="94" height="94" />Luis is a WordPress developer passionate about WordPress. He is a co-founder and partner of GOMO, a digital agency located in Lisbon, Portugal.</p> |
|
| 496 | + <p><img style="margin: 0 15px 10px 0;" class="alignleft avatar" src="<?php echo plugins_url('assets/images/luis.jpg', GRAVITYVIEW_FILE); ?>" width="94" height="94" />Luis is a WordPress developer passionate about WordPress. He is a co-founder and partner of GOMO, a digital agency located in Lisbon, Portugal.</p> |
|
| 497 | 497 | <p><a href="http://tinygod.pt">View Luis’s website</a></p> |
| 498 | 498 | </div> |
| 499 | 499 | |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | <div class="feature-section"> |
| 505 | 505 | <div> |
| 506 | - <h2><?php esc_attr_e( 'Contributors', 'gravityview' ); ?></h2> |
|
| 506 | + <h2><?php esc_attr_e('Contributors', 'gravityview'); ?></h2> |
|
| 507 | 507 | |
| 508 | 508 | <ul class="wp-people-group"> |
| 509 | 509 | <li class="wp-person">Bengali translation by <a href="https://www.transifex.com/accounts/profile/tareqhi/">@tareqhi</a></li> |
@@ -524,8 +524,8 @@ discard block |
||
| 524 | 524 | <li class="wp-person">Code contributions by <a href="https://github.com/ryanduff">@ryanduff</a> and <a href="https://github.com/dmlinn">@dmlinn</a></li> |
| 525 | 525 | </ul> |
| 526 | 526 | |
| 527 | - <h4><?php esc_attr_e( 'Want to contribute?', 'gravityview' ); ?></h4> |
|
| 528 | - <p><?php echo sprintf( esc_attr__( 'If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview'), '<a href="https://github.com/katzwebservices/GravityView">', '</a>' ); ?></p> |
|
| 527 | + <h4><?php esc_attr_e('Want to contribute?', 'gravityview'); ?></h4> |
|
| 528 | + <p><?php echo sprintf(esc_attr__('If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview'), '<a href="https://github.com/katzwebservices/GravityView">', '</a>'); ?></p> |
|
| 529 | 529 | </div> |
| 530 | 530 | </div> |
| 531 | 531 | |
@@ -565,34 +565,34 @@ discard block |
||
| 565 | 565 | global $plugin_page; |
| 566 | 566 | |
| 567 | 567 | // Bail if we're just editing the plugin |
| 568 | - if( $plugin_page === 'plugin-editor.php' ) { return; } |
|
| 568 | + if ($plugin_page === 'plugin-editor.php') { return; } |
|
| 569 | 569 | |
| 570 | 570 | // Bail if no activation redirect |
| 571 | - if ( ! get_transient( '_gv_activation_redirect' ) ) { return; } |
|
| 571 | + if (!get_transient('_gv_activation_redirect')) { return; } |
|
| 572 | 572 | |
| 573 | 573 | // Delete the redirect transient |
| 574 | - delete_transient( '_gv_activation_redirect' ); |
|
| 574 | + delete_transient('_gv_activation_redirect'); |
|
| 575 | 575 | |
| 576 | - $upgrade = get_option( 'gv_version_upgraded_from' ); |
|
| 576 | + $upgrade = get_option('gv_version_upgraded_from'); |
|
| 577 | 577 | |
| 578 | 578 | // Don't do anything if they've already seen the new version info |
| 579 | - if( $upgrade === GravityView_Plugin::version ) { |
|
| 579 | + if ($upgrade === GravityView_Plugin::version) { |
|
| 580 | 580 | return; |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | // Add "Upgraded From" Option |
| 584 | - update_option( 'gv_version_upgraded_from', GravityView_Plugin::version ); |
|
| 584 | + update_option('gv_version_upgraded_from', GravityView_Plugin::version); |
|
| 585 | 585 | |
| 586 | 586 | // Bail if activating from network, or bulk |
| 587 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { return; } |
|
| 587 | + if (is_network_admin() || isset($_GET['activate-multi'])) { return; } |
|
| 588 | 588 | |
| 589 | 589 | // First time install |
| 590 | - if( ! $upgrade ) { |
|
| 591 | - wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-getting-started' ) ); exit; |
|
| 590 | + if (!$upgrade) { |
|
| 591 | + wp_safe_redirect(admin_url('edit.php?post_type=gravityview&page=gv-getting-started')); exit; |
|
| 592 | 592 | } |
| 593 | 593 | // Update |
| 594 | 594 | else { |
| 595 | - wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-changelog' ) ); exit; |
|
| 595 | + wp_safe_redirect(admin_url('edit.php?post_type=gravityview&page=gv-changelog')); exit; |
|
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | 598 | } |
@@ -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,18 +25,18 @@ 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 | 33 | // Only get_form_meta is cached. ::facepalm:: |
| 34 | - if ( class_exists( 'RGFormsModel' ) ) { |
|
| 35 | - return GFFormsModel::get_form_meta( $form_id ); |
|
| 34 | + if (class_exists('RGFormsModel')) { |
|
| 35 | + return GFFormsModel::get_form_meta($form_id); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if ( class_exists( 'GFAPI' ) ) { |
|
| 39 | - return GFAPI::get_form( $form_id ); |
|
| 38 | + if (class_exists('GFAPI')) { |
|
| 39 | + return GFAPI::get_form($form_id); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | return false; |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities |
| 57 | 57 | */ |
| 58 | - public static function has_cap( $caps = '', $object_id = null, $user_id = null ) { |
|
| 59 | - return GravityView_Roles_Capabilities::has_cap( $caps, $object_id, $user_id ); |
|
| 58 | + public static function has_cap($caps = '', $object_id = null, $user_id = null) { |
|
| 59 | + return GravityView_Roles_Capabilities::has_cap($caps, $object_id, $user_id); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | * @param array|GF_Fields $field Gravity Forms field or array |
| 68 | 68 | * @return array Array version of $field |
| 69 | 69 | */ |
| 70 | - public static function get_field_array( $field ) { |
|
| 70 | + public static function get_field_array($field) { |
|
| 71 | 71 | |
| 72 | - if ( class_exists( 'GF_Fields' ) ) { |
|
| 72 | + if (class_exists('GF_Fields')) { |
|
| 73 | 73 | |
| 74 | - $field_object = GF_Fields::create( $field ); |
|
| 74 | + $field_object = GF_Fields::create($field); |
|
| 75 | 75 | |
| 76 | 76 | // Convert the field object in 1.9 to an array for backward compatibility |
| 77 | - $field_array = get_object_vars( $field_object ); |
|
| 77 | + $field_array = get_object_vars($field_object); |
|
| 78 | 78 | |
| 79 | 79 | } else { |
| 80 | 80 | $field_array = $field; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @return array Array of Views as `WP_Post`. Empty array if none found. |
| 95 | 95 | */ |
| 96 | - public static function get_all_views( $args = array() ) { |
|
| 96 | + public static function get_all_views($args = array()) { |
|
| 97 | 97 | |
| 98 | 98 | $default_params = array( |
| 99 | 99 | 'post_type' => 'gravityview', |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | 'post_status' => 'publish', |
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | - $params = wp_parse_args( $args, $default_params ); |
|
| 104 | + $params = wp_parse_args($args, $default_params); |
|
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * @filter `gravityview/get_all_views/params` Modify the parameters sent to get all views. |
| 108 | 108 | * @param[in,out] array $params Array of parameters to pass to `get_posts()` |
| 109 | 109 | */ |
| 110 | - $views_params = apply_filters( 'gravityview/get_all_views/params', $params ); |
|
| 110 | + $views_params = apply_filters('gravityview/get_all_views/params', $params); |
|
| 111 | 111 | |
| 112 | - $views = get_posts( $views_params ); |
|
| 112 | + $views = get_posts($views_params); |
|
| 113 | 113 | |
| 114 | 114 | return $views; |
| 115 | 115 | } |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | * @param int|string $entry_slug Entry slug |
| 121 | 121 | * @return array Gravity Forms form array |
| 122 | 122 | */ |
| 123 | - public static function get_form_from_entry_id( $entry_slug ) { |
|
| 123 | + public static function get_form_from_entry_id($entry_slug) { |
|
| 124 | 124 | |
| 125 | - $entry = self::get_entry( $entry_slug, true ); |
|
| 125 | + $entry = self::get_entry($entry_slug, true); |
|
| 126 | 126 | |
| 127 | - $form = self::get_form( $entry['form_id'] ); |
|
| 127 | + $form = self::get_form($entry['form_id']); |
|
| 128 | 128 | |
| 129 | 129 | return $form; |
| 130 | 130 | } |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return bool|GF_Field[] |
| 140 | 140 | */ |
| 141 | - public static function has_product_field( $form = array() ) { |
|
| 141 | + public static function has_product_field($form = array()) { |
|
| 142 | 142 | |
| 143 | - $product_fields = apply_filters( 'gform_product_field_types', array( 'option', 'quantity', 'product', 'total', 'shipping', 'calculation', 'price' ) ); |
|
| 143 | + $product_fields = apply_filters('gform_product_field_types', array('option', 'quantity', 'product', 'total', 'shipping', 'calculation', 'price')); |
|
| 144 | 144 | |
| 145 | - $fields = GFAPI::get_fields_by_type( $form, $product_fields ); |
|
| 145 | + $fields = GFAPI::get_fields_by_type($form, $product_fields); |
|
| 146 | 146 | |
| 147 | - return empty( $fields ) ? false : $fields; |
|
| 147 | + return empty($fields) ? false : $fields; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param string $slug The entry slug, as returned by GravityView_API::get_entry_slug() |
| 155 | 155 | * @return int|null The entry ID, if exists; `NULL` if not |
| 156 | 156 | */ |
| 157 | - public static function get_entry_id_from_slug( $slug ) { |
|
| 157 | + public static function get_entry_id_from_slug($slug) { |
|
| 158 | 158 | global $wpdb; |
| 159 | 159 | |
| 160 | 160 | $search_criteria = array( |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | 'page_size' => 1, |
| 174 | 174 | ); |
| 175 | 175 | |
| 176 | - $results = GFAPI::get_entries( 0, $search_criteria, null, $paging ); |
|
| 176 | + $results = GFAPI::get_entries(0, $search_criteria, null, $paging); |
|
| 177 | 177 | |
| 178 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
| 178 | + $result = (!empty($results) && !empty($results[0]['id'])) ? $results[0]['id'] : null; |
|
| 179 | 179 | |
| 180 | 180 | return $result; |
| 181 | 181 | } |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public static function get_forms() { |
| 192 | 192 | $forms = array(); |
| 193 | - if ( class_exists( 'GFAPI' ) ) { |
|
| 193 | + if (class_exists('GFAPI')) { |
|
| 194 | 194 | $gf_forms = GFAPI::get_forms(); |
| 195 | - foreach ( $gf_forms as $form ) { |
|
| 195 | + foreach ($gf_forms as $form) { |
|
| 196 | 196 | $forms[] = array( |
| 197 | 197 | 'id' => $form['id'], |
| 198 | 198 | 'title' => $form['title'], |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | * @param string|array $form_id (default: '') or $form object |
| 210 | 210 | * @return array |
| 211 | 211 | */ |
| 212 | - public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
|
| 212 | + public static function get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true) { |
|
| 213 | 213 | |
| 214 | - if ( ! is_array( $form ) ) { |
|
| 215 | - $form = self::get_form( $form ); |
|
| 214 | + if (!is_array($form)) { |
|
| 215 | + $form = self::get_form($form); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $fields = array(); |
@@ -222,56 +222,56 @@ discard block |
||
| 222 | 222 | $has_poll_fields = false; |
| 223 | 223 | |
| 224 | 224 | // If GF_Field exists, we're using GF 1.9+, where add_default_properties has been deprecated. |
| 225 | - if ( false === class_exists( 'GF_Field' ) && $add_default_properties ) { |
|
| 226 | - $form = RGFormsModel::add_default_properties( $form ); |
|
| 225 | + if (false === class_exists('GF_Field') && $add_default_properties) { |
|
| 226 | + $form = RGFormsModel::add_default_properties($form); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( $form ) { |
|
| 230 | - foreach ( $form['fields'] as $field ) { |
|
| 231 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
| 232 | - $fields[ $field['id'] ] = array( |
|
| 233 | - 'label' => rgar( $field, 'label' ), |
|
| 229 | + if ($form) { |
|
| 230 | + foreach ($form['fields'] as $field) { |
|
| 231 | + if ($include_parent_field || empty($field['inputs'])) { |
|
| 232 | + $fields[$field['id']] = array( |
|
| 233 | + 'label' => rgar($field, 'label'), |
|
| 234 | 234 | 'parent' => null, |
| 235 | - 'type' => rgar( $field, 'type' ), |
|
| 236 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
| 237 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
| 235 | + 'type' => rgar($field, 'type'), |
|
| 236 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
| 237 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
| 238 | 238 | ); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
| 242 | - foreach ( $field['inputs'] as $input ) { |
|
| 241 | + if ($add_default_properties && !empty($field['inputs'])) { |
|
| 242 | + foreach ($field['inputs'] as $input) { |
|
| 243 | 243 | /** |
| 244 | 244 | * @hack |
| 245 | 245 | * In case of email/email confirmation, the input for email has the same id as the parent field |
| 246 | 246 | */ |
| 247 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
| 247 | + if ('email' == rgar($field, 'type') && false === strpos($input['id'], '.')) { |
|
| 248 | 248 | continue; |
| 249 | 249 | } |
| 250 | - $fields[ (string)$input['id'] ] = array( |
|
| 251 | - 'label' => rgar( $input, 'label' ), |
|
| 252 | - 'customLabel' => rgar( $input, 'customLabel' ), |
|
| 250 | + $fields[(string)$input['id']] = array( |
|
| 251 | + 'label' => rgar($input, 'label'), |
|
| 252 | + 'customLabel' => rgar($input, 'customLabel'), |
|
| 253 | 253 | 'parent' => $field, |
| 254 | - 'type' => rgar( $field, 'type' ), |
|
| 255 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
| 256 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
| 254 | + 'type' => rgar($field, 'type'), |
|
| 255 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
| 256 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
| 257 | 257 | ); |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** @since 1.14 */ |
| 262 | - if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) { |
|
| 262 | + if ('list' === $field['type'] && !empty($field['enableColumns'])) { |
|
| 263 | 263 | |
| 264 | - foreach ( (array)$field['choices'] as $key => $input ) { |
|
| 264 | + foreach ((array)$field['choices'] as $key => $input) { |
|
| 265 | 265 | |
| 266 | - $input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key} |
|
| 266 | + $input_id = sprintf('%d.%d', $field['id'], $key); // {field_id}.{column_key} |
|
| 267 | 267 | |
| 268 | - $fields[ $input_id ] = array( |
|
| 269 | - 'label' => rgar( $input, 'text' ), |
|
| 268 | + $fields[$input_id] = array( |
|
| 269 | + 'label' => rgar($input, 'text'), |
|
| 270 | 270 | 'customLabel' => '', |
| 271 | 271 | 'parent' => $field, |
| 272 | - 'type' => rgar( $field, 'type' ), |
|
| 273 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
| 274 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
| 272 | + 'type' => rgar($field, 'type'), |
|
| 273 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
| 274 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
| 275 | 275 | ); |
| 276 | 276 | } |
| 277 | 277 | } |
@@ -279,27 +279,27 @@ discard block |
||
| 279 | 279 | /** |
| 280 | 280 | * @since 1.8 |
| 281 | 281 | */ |
| 282 | - if( 'quiz' === $field['type'] ) { |
|
| 282 | + if ('quiz' === $field['type']) { |
|
| 283 | 283 | $has_quiz_fields = true; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
| 287 | 287 | * @since 1.8 |
| 288 | 288 | */ |
| 289 | - if( 'poll' === $field['type'] ) { |
|
| 289 | + if ('poll' === $field['type']) { |
|
| 290 | 290 | $has_poll_fields = true; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 293 | + if (GFCommon::is_product_field($field['type'])) { |
|
| 294 | 294 | $has_product_fields = true; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | 298 | * @hack Version 1.9 |
| 299 | 299 | */ |
| 300 | - $field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field; |
|
| 300 | + $field_for_is_post_field = class_exists('GF_Fields') ? (object)$field : (array)$field; |
|
| 301 | 301 | |
| 302 | - if ( GFCommon::is_post_field( $field_for_is_post_field ) ) { |
|
| 302 | + if (GFCommon::is_post_field($field_for_is_post_field)) { |
|
| 303 | 303 | $has_post_fields = true; |
| 304 | 304 | } |
| 305 | 305 | } |
@@ -308,19 +308,19 @@ discard block |
||
| 308 | 308 | /** |
| 309 | 309 | * @since 1.7 |
| 310 | 310 | */ |
| 311 | - if ( $has_post_fields ) { |
|
| 311 | + if ($has_post_fields) { |
|
| 312 | 312 | $fields['post_id'] = array( |
| 313 | - 'label' => __( 'Post ID', 'gravityview' ), |
|
| 313 | + 'label' => __('Post ID', 'gravityview'), |
|
| 314 | 314 | 'type' => 'post_id', |
| 315 | 315 | ); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if ( $has_product_fields ) { |
|
| 318 | + if ($has_product_fields) { |
|
| 319 | 319 | |
| 320 | - $payment_fields = GravityView_Fields::get_all( 'pricing' ); |
|
| 320 | + $payment_fields = GravityView_Fields::get_all('pricing'); |
|
| 321 | 321 | |
| 322 | - foreach ( $payment_fields as $payment_field ) { |
|
| 323 | - if( isset( $fields["{$payment_field->name}"] ) ) { |
|
| 322 | + foreach ($payment_fields as $payment_field) { |
|
| 323 | + if (isset($fields["{$payment_field->name}"])) { |
|
| 324 | 324 | continue; |
| 325 | 325 | } |
| 326 | 326 | $fields["{$payment_field->name}"] = array( |
@@ -334,27 +334,27 @@ discard block |
||
| 334 | 334 | /** |
| 335 | 335 | * @since 1.8 |
| 336 | 336 | */ |
| 337 | - if( $has_quiz_fields ) { |
|
| 337 | + if ($has_quiz_fields) { |
|
| 338 | 338 | |
| 339 | - $fields['gquiz_score'] = array( |
|
| 340 | - 'label' => __( 'Quiz Score Total', 'gravityview' ), |
|
| 339 | + $fields['gquiz_score'] = array( |
|
| 340 | + 'label' => __('Quiz Score Total', 'gravityview'), |
|
| 341 | 341 | 'type' => 'quiz_score', |
| 342 | - 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
|
| 342 | + 'desc' => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'), |
|
| 343 | 343 | ); |
| 344 | 344 | $fields['gquiz_percent'] = array( |
| 345 | - 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
|
| 345 | + 'label' => __('Quiz Percentage Grade', 'gravityview'), |
|
| 346 | 346 | 'type' => 'quiz_percent', |
| 347 | - 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
|
| 347 | + 'desc' => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'), |
|
| 348 | 348 | ); |
| 349 | - $fields['gquiz_grade'] = array( |
|
| 350 | - 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
|
| 349 | + $fields['gquiz_grade'] = array( |
|
| 350 | + 'label' => __('Quiz Letter Grade', 'gravityview'), |
|
| 351 | 351 | 'type' => 'quiz_grade', |
| 352 | - 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
|
| 352 | + 'desc' => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'), |
|
| 353 | 353 | ); |
| 354 | 354 | $fields['gquiz_is_pass'] = array( |
| 355 | - 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
|
| 355 | + 'label' => __('Quiz Pass/Fail', 'gravityview'), |
|
| 356 | 356 | 'type' => 'quiz_is_pass', |
| 357 | - 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
|
| 357 | + 'desc' => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'), |
|
| 358 | 358 | ); |
| 359 | 359 | } |
| 360 | 360 | |
@@ -367,15 +367,15 @@ discard block |
||
| 367 | 367 | * @param string $form_id (default: '') |
| 368 | 368 | * @return array |
| 369 | 369 | */ |
| 370 | - public static function get_entry_meta( $form_id, $only_default_column = true ) { |
|
| 370 | + public static function get_entry_meta($form_id, $only_default_column = true) { |
|
| 371 | 371 | |
| 372 | - $extra_fields = GFFormsModel::get_entry_meta( $form_id ); |
|
| 372 | + $extra_fields = GFFormsModel::get_entry_meta($form_id); |
|
| 373 | 373 | |
| 374 | 374 | $fields = array(); |
| 375 | 375 | |
| 376 | - foreach ( $extra_fields as $key => $field ){ |
|
| 377 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
| 378 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
| 376 | + foreach ($extra_fields as $key => $field) { |
|
| 377 | + if (!empty($only_default_column) && !empty($field['is_default_column'])) { |
|
| 378 | + $fields[$key] = array('label' => $field['label'], 'type' => 'entry_meta'); |
|
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | |
@@ -391,13 +391,13 @@ discard block |
||
| 391 | 391 | * @since 1.1.6 |
| 392 | 392 | * @return array|void Array of entry IDs. Void if Gravity Forms isn't active. |
| 393 | 393 | */ |
| 394 | - public static function get_entry_ids( $form_id, $search_criteria = array() ) { |
|
| 394 | + public static function get_entry_ids($form_id, $search_criteria = array()) { |
|
| 395 | 395 | |
| 396 | - if ( ! class_exists( 'GFFormsModel' ) ) { |
|
| 396 | + if (!class_exists('GFFormsModel')) { |
|
| 397 | 397 | return; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - return GFFormsModel::search_lead_ids( $form_id, $search_criteria ); |
|
| 400 | + return GFFormsModel::search_lead_ids($form_id, $search_criteria); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /** |
@@ -409,33 +409,33 @@ discard block |
||
| 409 | 409 | * @param array $form_ids array Gravity Forms form IDs |
| 410 | 410 | * @return array |
| 411 | 411 | */ |
| 412 | - public static function calculate_get_entries_criteria( $passed_criteria = array(), $form_ids = array() ) { |
|
| 412 | + public static function calculate_get_entries_criteria($passed_criteria = array(), $form_ids = array()) { |
|
| 413 | 413 | |
| 414 | 414 | $search_criteria_defaults = array( |
| 415 | 415 | 'search_criteria' => null, |
| 416 | 416 | 'sorting' => null, |
| 417 | 417 | 'paging' => null, |
| 418 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
| 418 | + 'cache' => (isset($passed_criteria['cache']) ? $passed_criteria['cache'] : true), |
|
| 419 | 419 | ); |
| 420 | 420 | |
| 421 | - $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
|
| 421 | + $criteria = wp_parse_args($passed_criteria, $search_criteria_defaults); |
|
| 422 | 422 | |
| 423 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
| 424 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 423 | + if (!empty($criteria['search_criteria']['field_filters'])) { |
|
| 424 | + foreach ($criteria['search_criteria']['field_filters'] as &$filter) { |
|
| 425 | 425 | |
| 426 | - if ( ! is_array( $filter ) ) { |
|
| 426 | + if (!is_array($filter)) { |
|
| 427 | 427 | continue; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // By default, we want searches to be wildcard for each field. |
| 431 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 431 | + $filter['operator'] = empty($filter['operator']) ? 'contains' : $filter['operator']; |
|
| 432 | 432 | |
| 433 | 433 | /** |
| 434 | 434 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
| 435 | 435 | * @param string $operator Existing search operator |
| 436 | 436 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 437 | 437 | */ |
| 438 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 438 | + $filter['operator'] = apply_filters('gravityview_search_operator', $filter['operator'], $filter); |
|
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | |
@@ -443,32 +443,32 @@ discard block |
||
| 443 | 443 | * Prepare date formats to be in Gravity Forms DB format; |
| 444 | 444 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
| 445 | 445 | */ |
| 446 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
| 446 | + foreach (array('start_date', 'end_date') as $key) { |
|
| 447 | 447 | |
| 448 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
| 448 | + if (!empty($criteria['search_criteria'][$key])) { |
|
| 449 | 449 | |
| 450 | 450 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
| 451 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
| 451 | + $date = date_create($criteria['search_criteria'][$key]); |
|
| 452 | 452 | |
| 453 | - if ( $date ) { |
|
| 453 | + if ($date) { |
|
| 454 | 454 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
| 455 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 455 | + $criteria['search_criteria'][$key] = $date->format('Y-m-d H:i:s'); |
|
| 456 | 456 | } else { |
| 457 | 457 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
| 458 | - unset( $criteria['search_criteria'][ $key ] ); |
|
| 458 | + unset($criteria['search_criteria'][$key]); |
|
| 459 | 459 | |
| 460 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
| 460 | + do_action('gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][$key]); |
|
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | |
| 466 | 466 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
| 467 | - if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
| 467 | + if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry()) { |
|
| 468 | 468 | $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
| 469 | - } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
|
| 470 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
|
| 471 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
| 469 | + } elseif ('delete' === RGForms::get('action')) { |
|
| 470 | + $criteria['context_view_id'] = isset($_GET['view_id']) ? $_GET['view_id'] : null; |
|
| 471 | + } elseif (!isset($criteria['context_view_id'])) { |
|
| 472 | 472 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
| 473 | 473 | $criteria['context_view_id'] = null; |
| 474 | 474 | } |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | * @param array $form_ids Forms to search |
| 480 | 480 | * @param int $view_id ID of the view being used to search |
| 481 | 481 | */ |
| 482 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
| 482 | + $criteria = apply_filters('gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id']); |
|
| 483 | 483 | |
| 484 | 484 | return (array)$criteria; |
| 485 | 485 | |
@@ -497,35 +497,35 @@ discard block |
||
| 497 | 497 | * @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) |
| 498 | 498 | * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays |
| 499 | 499 | */ |
| 500 | - public static function get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { |
|
| 500 | + public static function get_entries($form_ids = null, $passed_criteria = null, &$total = null) { |
|
| 501 | 501 | |
| 502 | 502 | // Filter the criteria before query (includes Adv Filter) |
| 503 | - $criteria = self::calculate_get_entries_criteria( $passed_criteria, $form_ids ); |
|
| 503 | + $criteria = self::calculate_get_entries_criteria($passed_criteria, $form_ids); |
|
| 504 | 504 | |
| 505 | - do_action( 'gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria ); |
|
| 505 | + do_action('gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria); |
|
| 506 | 506 | |
| 507 | 507 | // Return value |
| 508 | 508 | $return = null; |
| 509 | 509 | |
| 510 | 510 | /** Reduce # of database calls */ |
| 511 | - add_filter( 'gform_is_encrypted_field', '__return_false' ); |
|
| 511 | + add_filter('gform_is_encrypted_field', '__return_false'); |
|
| 512 | 512 | |
| 513 | - if ( ! empty( $criteria['cache'] ) ) { |
|
| 513 | + if (!empty($criteria['cache'])) { |
|
| 514 | 514 | |
| 515 | - $Cache = new GravityView_Cache( $form_ids, $criteria ); |
|
| 515 | + $Cache = new GravityView_Cache($form_ids, $criteria); |
|
| 516 | 516 | |
| 517 | - if ( $entries = $Cache->get() ) { |
|
| 517 | + if ($entries = $Cache->get()) { |
|
| 518 | 518 | |
| 519 | 519 | // Still update the total count when using cached results |
| 520 | - if ( ! is_null( $total ) ) { |
|
| 521 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
| 520 | + if (!is_null($total)) { |
|
| 521 | + $total = GFAPI::count_entries($form_ids, $criteria['search_criteria']); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | $return = $entries; |
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - if ( is_null( $return ) && class_exists( 'GFAPI' ) && ( is_numeric( $form_ids ) || is_array( $form_ids ) ) ) { |
|
| 528 | + if (is_null($return) && class_exists('GFAPI') && (is_numeric($form_ids) || is_array($form_ids))) { |
|
| 529 | 529 | |
| 530 | 530 | /** |
| 531 | 531 | * @filter `gravityview_pre_get_entries` Define entries to be used before GFAPI::get_entries() is called |
@@ -535,24 +535,24 @@ discard block |
||
| 535 | 535 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
| 536 | 536 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
| 537 | 537 | */ |
| 538 | - $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
|
| 538 | + $entries = apply_filters('gravityview_before_get_entries', null, $criteria, $passed_criteria, $total); |
|
| 539 | 539 | |
| 540 | 540 | // No entries returned from gravityview_before_get_entries |
| 541 | - if( is_null( $entries ) ) { |
|
| 541 | + if (is_null($entries)) { |
|
| 542 | 542 | |
| 543 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
| 543 | + $entries = GFAPI::get_entries($form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total); |
|
| 544 | 544 | |
| 545 | - if ( is_wp_error( $entries ) ) { |
|
| 546 | - do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
|
| 545 | + if (is_wp_error($entries)) { |
|
| 546 | + do_action('gravityview_log_error', $entries->get_error_message(), $entries); |
|
| 547 | 547 | |
| 548 | 548 | return false; |
| 549 | 549 | } |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
| 552 | + if (!empty($criteria['cache']) && isset($Cache)) { |
|
| 553 | 553 | |
| 554 | 554 | // Cache results |
| 555 | - $Cache->set( $entries, 'entries' ); |
|
| 555 | + $Cache->set($entries, 'entries'); |
|
| 556 | 556 | |
| 557 | 557 | } |
| 558 | 558 | |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | /** Remove filter added above */ |
| 563 | - remove_filter( 'gform_is_encrypted_field', '__return_false' ); |
|
| 563 | + remove_filter('gform_is_encrypted_field', '__return_false'); |
|
| 564 | 564 | |
| 565 | 565 | /** |
| 566 | 566 | * @filter `gravityview_entries` Modify the array of entries returned to GravityView after it has been fetched from the cache or from `GFAPI::get_entries()`. |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
| 570 | 570 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
| 571 | 571 | */ |
| 572 | - $return = apply_filters( 'gravityview_entries', $return, $criteria, $passed_criteria, $total ); |
|
| 572 | + $return = apply_filters('gravityview_entries', $return, $criteria, $passed_criteria, $total); |
|
| 573 | 573 | |
| 574 | 574 | return $return; |
| 575 | 575 | } |
@@ -586,15 +586,15 @@ discard block |
||
| 586 | 586 | * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true. {@since 1.14} |
| 587 | 587 | * @return array|boolean |
| 588 | 588 | */ |
| 589 | - public static function get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) { |
|
| 589 | + public static function get_entry($entry_slug, $force_allow_ids = false, $check_entry_display = true) { |
|
| 590 | 590 | |
| 591 | - if ( class_exists( 'GFAPI' ) && ! empty( $entry_slug ) ) { |
|
| 591 | + if (class_exists('GFAPI') && !empty($entry_slug)) { |
|
| 592 | 592 | |
| 593 | 593 | /** |
| 594 | 594 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
| 595 | 595 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
| 596 | 596 | */ |
| 597 | - $custom_slug = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
| 597 | + $custom_slug = apply_filters('gravityview_custom_entry_slug', false); |
|
| 598 | 598 | |
| 599 | 599 | /** |
| 600 | 600 | * @filter `gravityview_custom_entry_slug_allow_id` When using a custom slug, allow access to the entry using the original slug (the Entry ID). |
@@ -602,38 +602,38 @@ discard block |
||
| 602 | 602 | * - If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`) |
| 603 | 603 | * @param boolean $custom_slug_id_access True: allow accessing the slug by ID; False: only use the slug passed to the method. |
| 604 | 604 | */ |
| 605 | - $custom_slug_id_access = $force_allow_ids || apply_filters( 'gravityview_custom_entry_slug_allow_id', false ); |
|
| 605 | + $custom_slug_id_access = $force_allow_ids || apply_filters('gravityview_custom_entry_slug_allow_id', false); |
|
| 606 | 606 | |
| 607 | 607 | /** |
| 608 | 608 | * If we're using custom entry slugs, we do a meta value search |
| 609 | 609 | * instead of doing a straightup ID search. |
| 610 | 610 | */ |
| 611 | - if ( $custom_slug ) { |
|
| 611 | + if ($custom_slug) { |
|
| 612 | 612 | |
| 613 | - $entry_id = self::get_entry_id_from_slug( $entry_slug ); |
|
| 613 | + $entry_id = self::get_entry_id_from_slug($entry_slug); |
|
| 614 | 614 | |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | // If custom slug is off, search using the entry ID |
| 618 | 618 | // ID allow ID access is on, also use entry ID as a backup |
| 619 | - if ( empty( $custom_slug ) || ! empty( $custom_slug_id_access ) ) { |
|
| 619 | + if (empty($custom_slug) || !empty($custom_slug_id_access)) { |
|
| 620 | 620 | // Search for IDs matching $entry_slug |
| 621 | 621 | $entry_id = $entry_slug; |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - if ( empty( $entry_id ) ) { |
|
| 624 | + if (empty($entry_id)) { |
|
| 625 | 625 | return false; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | // fetch the entry |
| 629 | - $entry = GFAPI::get_entry( $entry_id ); |
|
| 629 | + $entry = GFAPI::get_entry($entry_id); |
|
| 630 | 630 | |
| 631 | - if( $check_entry_display ) { |
|
| 631 | + if ($check_entry_display) { |
|
| 632 | 632 | // Is the entry allowed |
| 633 | - $entry = self::check_entry_display( $entry ); |
|
| 633 | + $entry = self::check_entry_display($entry); |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - return is_wp_error( $entry ) ? false : $entry; |
|
| 636 | + return is_wp_error($entry) ? false : $entry; |
|
| 637 | 637 | |
| 638 | 638 | } |
| 639 | 639 | |
@@ -657,51 +657,51 @@ discard block |
||
| 657 | 657 | * |
| 658 | 658 | * @return bool True: matches, false: not matches |
| 659 | 659 | */ |
| 660 | - public static function matches_operation( $val1, $val2, $operation ) { |
|
| 660 | + public static function matches_operation($val1, $val2, $operation) { |
|
| 661 | 661 | |
| 662 | 662 | $value = false; |
| 663 | 663 | |
| 664 | - if( 'context' === $val1 ) { |
|
| 664 | + if ('context' === $val1) { |
|
| 665 | 665 | |
| 666 | - $matching_contexts = array( $val2 ); |
|
| 666 | + $matching_contexts = array($val2); |
|
| 667 | 667 | |
| 668 | 668 | // We allow for non-standard contexts. |
| 669 | - switch( $val2 ) { |
|
| 669 | + switch ($val2) { |
|
| 670 | 670 | // Check for either single or edit |
| 671 | 671 | case 'singular': |
| 672 | - $matching_contexts = array( 'single', 'edit' ); |
|
| 672 | + $matching_contexts = array('single', 'edit'); |
|
| 673 | 673 | break; |
| 674 | 674 | // Use multiple as alias for directory for consistency |
| 675 | 675 | case 'multiple': |
| 676 | - $matching_contexts = array( 'directory' ); |
|
| 676 | + $matching_contexts = array('directory'); |
|
| 677 | 677 | break; |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - $val1 = in_array( gravityview_get_context(), $matching_contexts ) ? $val2 : false; |
|
| 680 | + $val1 = in_array(gravityview_get_context(), $matching_contexts) ? $val2 : false; |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - switch ( $operation ) { |
|
| 683 | + switch ($operation) { |
|
| 684 | 684 | case 'equals': |
| 685 | - $value = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
| 685 | + $value = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
| 686 | 686 | break; |
| 687 | 687 | case 'greater_than_or_is': |
| 688 | 688 | case 'greater_than_or_equals': |
| 689 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
| 690 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'greater_than' ); |
|
| 691 | - $value = ( $is || $gt ); |
|
| 689 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
| 690 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'greater_than'); |
|
| 691 | + $value = ($is || $gt); |
|
| 692 | 692 | break; |
| 693 | 693 | case 'less_than_or_is': |
| 694 | 694 | case 'less_than_or_equals': |
| 695 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
| 696 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'less_than' ); |
|
| 697 | - $value = ( $is || $gt ); |
|
| 695 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
| 696 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'less_than'); |
|
| 697 | + $value = ($is || $gt); |
|
| 698 | 698 | break; |
| 699 | 699 | case 'not_contains': |
| 700 | - $contains = GFFormsModel::matches_operation( $val1, $val2, 'contains' ); |
|
| 701 | - $value = ! $contains; |
|
| 700 | + $contains = GFFormsModel::matches_operation($val1, $val2, 'contains'); |
|
| 701 | + $value = !$contains; |
|
| 702 | 702 | break; |
| 703 | 703 | default: |
| 704 | - $value = GFFormsModel::matches_operation( $val1, $val2, $operation ); |
|
| 704 | + $value = GFFormsModel::matches_operation($val1, $val2, $operation); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | return $value; |
@@ -719,41 +719,41 @@ discard block |
||
| 719 | 719 | * @param array $entry Gravity Forms Entry object |
| 720 | 720 | * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter) |
| 721 | 721 | */ |
| 722 | - public static function check_entry_display( $entry ) { |
|
| 722 | + public static function check_entry_display($entry) { |
|
| 723 | 723 | |
| 724 | - if ( ! $entry || is_wp_error( $entry ) ) { |
|
| 725 | - do_action( 'gravityview_log_debug', __METHOD__ . ' Entry was not found.', $entry ); |
|
| 724 | + if (!$entry || is_wp_error($entry)) { |
|
| 725 | + do_action('gravityview_log_debug', __METHOD__.' Entry was not found.', $entry); |
|
| 726 | 726 | return false; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - if ( empty( $entry['form_id'] ) ) { |
|
| 730 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
|
| 729 | + if (empty($entry['form_id'])) { |
|
| 730 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry); |
|
| 731 | 731 | return false; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | $criteria = self::calculate_get_entries_criteria(); |
| 735 | 735 | |
| 736 | 736 | // Make sure the current View is connected to the same form as the Entry |
| 737 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
| 738 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
| 739 | - $context_form_id = gravityview_get_form_id( $context_view_id ); |
|
| 740 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
| 741 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
| 737 | + if (!empty($criteria['context_view_id'])) { |
|
| 738 | + $context_view_id = intval($criteria['context_view_id']); |
|
| 739 | + $context_form_id = gravityview_get_form_id($context_view_id); |
|
| 740 | + if (intval($context_form_id) !== intval($entry['form_id'])) { |
|
| 741 | + do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id']), $criteria['context_view_id']); |
|
| 742 | 742 | return false; |
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
| 747 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
|
| 746 | + if (empty($criteria['search_criteria']) || !is_array($criteria['search_criteria'])) { |
|
| 747 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria); |
|
| 748 | 748 | return $entry; |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | $search_criteria = $criteria['search_criteria']; |
| 752 | - unset( $criteria ); |
|
| 752 | + unset($criteria); |
|
| 753 | 753 | |
| 754 | 754 | // check entry status |
| 755 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
| 756 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
| 755 | + if (array_key_exists('status', $search_criteria) && $search_criteria['status'] != $entry['status']) { |
|
| 756 | + do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status']), $search_criteria); |
|
| 757 | 757 | return false; |
| 758 | 758 | } |
| 759 | 759 | |
@@ -761,53 +761,53 @@ discard block |
||
| 761 | 761 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
| 762 | 762 | |
| 763 | 763 | // field_filters |
| 764 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
| 765 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
|
| 764 | + if (empty($search_criteria['field_filters']) || !is_array($search_criteria['field_filters'])) { |
|
| 765 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria); |
|
| 766 | 766 | return $entry; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | $filters = $search_criteria['field_filters']; |
| 770 | - unset( $search_criteria ); |
|
| 770 | + unset($search_criteria); |
|
| 771 | 771 | |
| 772 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
| 773 | - unset( $filters['mode'] ); |
|
| 772 | + $mode = array_key_exists('mode', $filters) ? strtolower($filters['mode']) : 'all'; |
|
| 773 | + unset($filters['mode']); |
|
| 774 | 774 | |
| 775 | - $form = self::get_form( $entry['form_id'] ); |
|
| 775 | + $form = self::get_form($entry['form_id']); |
|
| 776 | 776 | |
| 777 | - foreach ( $filters as $filter ) { |
|
| 777 | + foreach ($filters as $filter) { |
|
| 778 | 778 | |
| 779 | - if ( ! isset( $filter['key'] ) ) { |
|
| 779 | + if (!isset($filter['key'])) { |
|
| 780 | 780 | continue; |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | $k = $filter['key']; |
| 784 | 784 | |
| 785 | - if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
|
| 786 | - $field_value = $entry[ $k ]; |
|
| 785 | + if (in_array($k, array('created_by', 'payment_status'))) { |
|
| 786 | + $field_value = $entry[$k]; |
|
| 787 | 787 | $field = null; |
| 788 | 788 | } else { |
| 789 | - $field = self::get_field( $form, $k ); |
|
| 790 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 789 | + $field = self::get_field($form, $k); |
|
| 790 | + $field_value = GFFormsModel::get_lead_field_value($entry, $field); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
| 794 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
| 793 | + $operator = isset($filter['operator']) ? strtolower($filter['operator']) : 'is'; |
|
| 794 | + $is_value_match = GFFormsModel::is_value_match($field_value, $filter['value'], $operator, $field); |
|
| 795 | 795 | |
| 796 | 796 | // verify if we are already free to go! |
| 797 | - if ( ! $is_value_match && 'all' === $mode ) { |
|
| 798 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter ); |
|
| 797 | + if (!$is_value_match && 'all' === $mode) { |
|
| 798 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter); |
|
| 799 | 799 | return false; |
| 800 | - } elseif ( $is_value_match && 'any' === $mode ) { |
|
| 800 | + } elseif ($is_value_match && 'any' === $mode) { |
|
| 801 | 801 | return $entry; |
| 802 | 802 | } |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | // at this point, if in ALL mode, then entry is approved - all conditions were met. |
| 806 | 806 | // Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved |
| 807 | - if ( 'all' === $mode ) { |
|
| 807 | + if ('all' === $mode) { |
|
| 808 | 808 | return $entry; |
| 809 | 809 | } else { |
| 810 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 810 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters); |
|
| 811 | 811 | return false; |
| 812 | 812 | } |
| 813 | 813 | |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | * |
| 833 | 833 | * @return int|null|string Formatted date based on the original date |
| 834 | 834 | */ |
| 835 | - public static function format_date( $date_string = '', $args = array() ) { |
|
| 835 | + public static function format_date($date_string = '', $args = array()) { |
|
| 836 | 836 | |
| 837 | 837 | $default_atts = array( |
| 838 | 838 | 'raw' => false, |
@@ -843,39 +843,39 @@ discard block |
||
| 843 | 843 | 'time' => false, |
| 844 | 844 | ); |
| 845 | 845 | |
| 846 | - $atts = wp_parse_args( $args, $default_atts ); |
|
| 846 | + $atts = wp_parse_args($args, $default_atts); |
|
| 847 | 847 | |
| 848 | 848 | /** |
| 849 | 849 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 850 | 850 | * @see GFCommon::format_date() for original code |
| 851 | 851 | */ |
| 852 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
| 853 | - $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
|
| 852 | + $date_gmt_time = mysql2date('G', $date_string); |
|
| 853 | + $date_local_timestamp = GFCommon::get_local_timestamp($date_gmt_time); |
|
| 854 | 854 | |
| 855 | - $format = rgar( $atts, 'format' ); |
|
| 856 | - $is_human = ! empty( $atts['human'] ); |
|
| 857 | - $is_diff = ! empty( $atts['diff'] ); |
|
| 858 | - $is_raw = ! empty( $atts['raw'] ); |
|
| 859 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
| 860 | - $include_time = ! empty( $atts['time'] ); |
|
| 855 | + $format = rgar($atts, 'format'); |
|
| 856 | + $is_human = !empty($atts['human']); |
|
| 857 | + $is_diff = !empty($atts['diff']); |
|
| 858 | + $is_raw = !empty($atts['raw']); |
|
| 859 | + $is_timestamp = !empty($atts['timestamp']); |
|
| 860 | + $include_time = !empty($atts['time']); |
|
| 861 | 861 | |
| 862 | 862 | // If we're using time diff, we want to have a different default format |
| 863 | - if( empty( $format ) ) { |
|
| 864 | - $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
|
| 863 | + if (empty($format)) { |
|
| 864 | + $format = $is_diff ? esc_html__('%s ago', 'gravityview') : get_option('date_format'); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | // If raw was specified, don't modify the stored value |
| 868 | - if ( $is_raw ) { |
|
| 868 | + if ($is_raw) { |
|
| 869 | 869 | $formatted_date = $date_string; |
| 870 | - } elseif( $is_timestamp ) { |
|
| 870 | + } elseif ($is_timestamp) { |
|
| 871 | 871 | $formatted_date = $date_local_timestamp; |
| 872 | - } elseif ( $is_diff ) { |
|
| 873 | - $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
|
| 872 | + } elseif ($is_diff) { |
|
| 873 | + $formatted_date = sprintf($format, human_time_diff($date_gmt_time)); |
|
| 874 | 874 | } else { |
| 875 | - $formatted_date = GFCommon::format_date( $date_string, $is_human, $format, $include_time ); |
|
| 875 | + $formatted_date = GFCommon::format_date($date_string, $is_human, $format, $include_time); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - unset( $format, $is_diff, $is_human, $is_timestamp, $is_raw, $date_gmt_time, $date_local_timestamp, $default_atts ); |
|
| 878 | + unset($format, $is_diff, $is_human, $is_timestamp, $is_raw, $date_gmt_time, $date_local_timestamp, $default_atts); |
|
| 879 | 879 | |
| 880 | 880 | return $formatted_date; |
| 881 | 881 | } |
@@ -888,14 +888,14 @@ discard block |
||
| 888 | 888 | * @param string $field_id |
| 889 | 889 | * @return string |
| 890 | 890 | */ |
| 891 | - public static function get_field_label( $form = array(), $field_id = '' ) { |
|
| 891 | + public static function get_field_label($form = array(), $field_id = '') { |
|
| 892 | 892 | |
| 893 | - if ( empty( $form ) || empty( $field_id ) ) { |
|
| 893 | + if (empty($form) || empty($field_id)) { |
|
| 894 | 894 | return ''; |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - $field = self::get_field( $form, $field_id ); |
|
| 898 | - return isset( $field['label'] ) ? $field['label'] : ''; |
|
| 897 | + $field = self::get_field($form, $field_id); |
|
| 898 | + return isset($field['label']) ? $field['label'] : ''; |
|
| 899 | 899 | |
| 900 | 900 | } |
| 901 | 901 | |
@@ -912,9 +912,9 @@ discard block |
||
| 912 | 912 | * @param string|int $field_id |
| 913 | 913 | * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist |
| 914 | 914 | */ |
| 915 | - public static function get_field( $form, $field_id ) { |
|
| 916 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 917 | - return GFFormsModel::get_field( $form, $field_id ); |
|
| 915 | + public static function get_field($form, $field_id) { |
|
| 916 | + if (class_exists('GFFormsModel')) { |
|
| 917 | + return GFFormsModel::get_field($form, $field_id); |
|
| 918 | 918 | } else { |
| 919 | 919 | return null; |
| 920 | 920 | } |
@@ -930,16 +930,16 @@ discard block |
||
| 930 | 930 | * @param WP_Post $post WordPress post object |
| 931 | 931 | * @return boolean True: yep, GravityView; No: not! |
| 932 | 932 | */ |
| 933 | - public static function has_gravityview_shortcode( $post = null ) { |
|
| 934 | - if ( ! is_a( $post, 'WP_Post' ) ) { |
|
| 933 | + public static function has_gravityview_shortcode($post = null) { |
|
| 934 | + if (!is_a($post, 'WP_Post')) { |
|
| 935 | 935 | return false; |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | - if ( 'gravityview' === get_post_type( $post ) ) { |
|
| 938 | + if ('gravityview' === get_post_type($post)) { |
|
| 939 | 939 | return true; |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | - return self::has_shortcode_r( $post->post_content, 'gravityview' ) ? true : false; |
|
| 942 | + return self::has_shortcode_r($post->post_content, 'gravityview') ? true : false; |
|
| 943 | 943 | |
| 944 | 944 | } |
| 945 | 945 | |
@@ -950,27 +950,27 @@ discard block |
||
| 950 | 950 | * @param string $content Content to check whether there's a shortcode |
| 951 | 951 | * @param string $tag Current shortcode tag |
| 952 | 952 | */ |
| 953 | - public static function has_shortcode_r( $content, $tag = 'gravityview' ) { |
|
| 954 | - if ( false === strpos( $content, '[' ) ) { |
|
| 953 | + public static function has_shortcode_r($content, $tag = 'gravityview') { |
|
| 954 | + if (false === strpos($content, '[')) { |
|
| 955 | 955 | return false; |
| 956 | 956 | } |
| 957 | 957 | |
| 958 | - if ( shortcode_exists( $tag ) ) { |
|
| 958 | + if (shortcode_exists($tag)) { |
|
| 959 | 959 | |
| 960 | 960 | $shortcodes = array(); |
| 961 | 961 | |
| 962 | - preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
|
| 963 | - if ( empty( $matches ) ){ |
|
| 962 | + preg_match_all('/'.get_shortcode_regex().'/s', $content, $matches, PREG_SET_ORDER); |
|
| 963 | + if (empty($matches)) { |
|
| 964 | 964 | return false; |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | - foreach ( $matches as $shortcode ) { |
|
| 968 | - if ( $tag === $shortcode[2] ) { |
|
| 967 | + foreach ($matches as $shortcode) { |
|
| 968 | + if ($tag === $shortcode[2]) { |
|
| 969 | 969 | |
| 970 | 970 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 971 | 971 | $shortcodes[] = $shortcode; |
| 972 | 972 | |
| 973 | - } else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 973 | + } else if (isset($shortcode[5]) && $result = self::has_shortcode_r($shortcode[5], $tag)) { |
|
| 974 | 974 | $shortcodes = $result; |
| 975 | 975 | } |
| 976 | 976 | } |
@@ -994,7 +994,7 @@ discard block |
||
| 994 | 994 | * |
| 995 | 995 | * @return array Array with view details, as returned by get_posts() |
| 996 | 996 | */ |
| 997 | - public static function get_connected_views( $form_id, $args = array() ) { |
|
| 997 | + public static function get_connected_views($form_id, $args = array()) { |
|
| 998 | 998 | |
| 999 | 999 | $defaults = array( |
| 1000 | 1000 | 'post_type' => 'gravityview', |
@@ -1003,9 +1003,9 @@ discard block |
||
| 1003 | 1003 | 'meta_value' => (int)$form_id, |
| 1004 | 1004 | ); |
| 1005 | 1005 | |
| 1006 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1006 | + $args = wp_parse_args($args, $defaults); |
|
| 1007 | 1007 | |
| 1008 | - $views = get_posts( $args ); |
|
| 1008 | + $views = get_posts($args); |
|
| 1009 | 1009 | |
| 1010 | 1010 | return $views; |
| 1011 | 1011 | } |
@@ -1017,8 +1017,8 @@ discard block |
||
| 1017 | 1017 | * |
| 1018 | 1018 | * @return string ID of the connected Form, if exists. Empty string if not. |
| 1019 | 1019 | */ |
| 1020 | - public static function get_meta_form_id( $view_id ) { |
|
| 1021 | - return get_post_meta( $view_id, '_gravityview_form_id', true ); |
|
| 1020 | + public static function get_meta_form_id($view_id) { |
|
| 1021 | + return get_post_meta($view_id, '_gravityview_form_id', true); |
|
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | /** |
@@ -1030,8 +1030,8 @@ discard block |
||
| 1030 | 1030 | * |
| 1031 | 1031 | * @return string GravityView_Template::template_id value. Empty string if not. |
| 1032 | 1032 | */ |
| 1033 | - public static function get_meta_template_id( $view_id ) { |
|
| 1034 | - return get_post_meta( $view_id, '_gravityview_directory_template', true ); |
|
| 1033 | + public static function get_meta_template_id($view_id) { |
|
| 1034 | + return get_post_meta($view_id, '_gravityview_directory_template', true); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | |
@@ -1042,15 +1042,15 @@ discard block |
||
| 1042 | 1042 | * @param int $post_id View ID |
| 1043 | 1043 | * @return array Associative array of settings with plugin defaults used if not set by the View |
| 1044 | 1044 | */ |
| 1045 | - public static function get_template_settings( $post_id ) { |
|
| 1045 | + public static function get_template_settings($post_id) { |
|
| 1046 | 1046 | |
| 1047 | - $settings = get_post_meta( $post_id, '_gravityview_template_settings', true ); |
|
| 1047 | + $settings = get_post_meta($post_id, '_gravityview_template_settings', true); |
|
| 1048 | 1048 | |
| 1049 | - if ( class_exists( 'GravityView_View_Data' ) ) { |
|
| 1049 | + if (class_exists('GravityView_View_Data')) { |
|
| 1050 | 1050 | |
| 1051 | 1051 | $defaults = GravityView_View_Data::get_default_args(); |
| 1052 | 1052 | |
| 1053 | - return wp_parse_args( (array)$settings, $defaults ); |
|
| 1053 | + return wp_parse_args((array)$settings, $defaults); |
|
| 1054 | 1054 | |
| 1055 | 1055 | } |
| 1056 | 1056 | |
@@ -1067,12 +1067,12 @@ discard block |
||
| 1067 | 1067 | * @param string $key Key for the setting |
| 1068 | 1068 | * @return mixed|null Setting value, or NULL if not set. |
| 1069 | 1069 | */ |
| 1070 | - public static function get_template_setting( $post_id, $key ) { |
|
| 1070 | + public static function get_template_setting($post_id, $key) { |
|
| 1071 | 1071 | |
| 1072 | - $settings = self::get_template_settings( $post_id ); |
|
| 1072 | + $settings = self::get_template_settings($post_id); |
|
| 1073 | 1073 | |
| 1074 | - if ( isset( $settings[ $key ] ) ) { |
|
| 1075 | - return $settings[ $key ]; |
|
| 1074 | + if (isset($settings[$key])) { |
|
| 1075 | + return $settings[$key]; |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | return null; |
@@ -1108,8 +1108,8 @@ discard block |
||
| 1108 | 1108 | * @param int $post_id View ID |
| 1109 | 1109 | * @return array Multi-array of fields with first level being the field zones. See code comment. |
| 1110 | 1110 | */ |
| 1111 | - public static function get_directory_fields( $post_id ) { |
|
| 1112 | - return get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
|
| 1111 | + public static function get_directory_fields($post_id) { |
|
| 1112 | + return get_post_meta($post_id, '_gravityview_directory_fields', true); |
|
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | 1115 | |
@@ -1120,25 +1120,25 @@ discard block |
||
| 1120 | 1120 | * @param int $formid Form ID |
| 1121 | 1121 | * @return string html |
| 1122 | 1122 | */ |
| 1123 | - public static function get_sortable_fields( $formid, $current = '' ) { |
|
| 1124 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1123 | + public static function get_sortable_fields($formid, $current = '') { |
|
| 1124 | + $output = '<option value="" '.selected('', $current, false).'>'.esc_html__('Default', 'gravityview').'</option>'; |
|
| 1125 | 1125 | |
| 1126 | - if ( empty( $formid ) ) { |
|
| 1126 | + if (empty($formid)) { |
|
| 1127 | 1127 | return $output; |
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | - $fields = self::get_sortable_fields_array( $formid ); |
|
| 1130 | + $fields = self::get_sortable_fields_array($formid); |
|
| 1131 | 1131 | |
| 1132 | - if ( ! empty( $fields ) ) { |
|
| 1132 | + if (!empty($fields)) { |
|
| 1133 | 1133 | |
| 1134 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
|
| 1134 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('list', 'textarea'), null); |
|
| 1135 | 1135 | |
| 1136 | - foreach ( $fields as $id => $field ) { |
|
| 1137 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1136 | + foreach ($fields as $id => $field) { |
|
| 1137 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
| 1138 | 1138 | continue; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1141 | + $output .= '<option value="'.$id.'" '.selected($id, $current, false).'>'.esc_attr($field['label']).'</option>'; |
|
| 1142 | 1142 | } |
| 1143 | 1143 | } |
| 1144 | 1144 | |
@@ -1156,27 +1156,27 @@ discard block |
||
| 1156 | 1156 | * |
| 1157 | 1157 | * @return array |
| 1158 | 1158 | */ |
| 1159 | - public static function get_sortable_fields_array( $formid, $blacklist = array( 'list', 'textarea' ) ) { |
|
| 1159 | + public static function get_sortable_fields_array($formid, $blacklist = array('list', 'textarea')) { |
|
| 1160 | 1160 | |
| 1161 | 1161 | // Get fields with sub-inputs and no parent |
| 1162 | - $fields = self::get_form_fields( $formid, true, false ); |
|
| 1162 | + $fields = self::get_form_fields($formid, true, false); |
|
| 1163 | 1163 | |
| 1164 | 1164 | $date_created = array( |
| 1165 | 1165 | 'date_created' => array( |
| 1166 | 1166 | 'type' => 'date_created', |
| 1167 | - 'label' => __( 'Date Created', 'gravityview' ), |
|
| 1167 | + 'label' => __('Date Created', 'gravityview'), |
|
| 1168 | 1168 | ), |
| 1169 | 1169 | ); |
| 1170 | 1170 | |
| 1171 | 1171 | $fields = $date_created + $fields; |
| 1172 | 1172 | |
| 1173 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
|
| 1173 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', $blacklist, NULL); |
|
| 1174 | 1174 | |
| 1175 | 1175 | // TODO: Convert to using array_filter |
| 1176 | - foreach( $fields as $id => $field ) { |
|
| 1176 | + foreach ($fields as $id => $field) { |
|
| 1177 | 1177 | |
| 1178 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1179 | - unset( $fields[ $id ] ); |
|
| 1178 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
| 1179 | + unset($fields[$id]); |
|
| 1180 | 1180 | } |
| 1181 | 1181 | } |
| 1182 | 1182 | |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | * @param array $fields Sub-set of GF form fields that are sortable |
| 1187 | 1187 | * @param int $formid The Gravity Forms form ID that the fields are from |
| 1188 | 1188 | */ |
| 1189 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1189 | + $fields = apply_filters('gravityview/common/sortable_fields', $fields, $formid); |
|
| 1190 | 1190 | |
| 1191 | 1191 | return $fields; |
| 1192 | 1192 | } |
@@ -1197,15 +1197,15 @@ discard block |
||
| 1197 | 1197 | * @param mixed $field_id Field ID or Field array |
| 1198 | 1198 | * @return string field type |
| 1199 | 1199 | */ |
| 1200 | - public static function get_field_type( $form = null, $field_id = '' ) { |
|
| 1200 | + public static function get_field_type($form = null, $field_id = '') { |
|
| 1201 | 1201 | |
| 1202 | - if ( ! empty( $field_id ) && ! is_array( $field_id ) ) { |
|
| 1203 | - $field = self::get_field( $form, $field_id ); |
|
| 1202 | + if (!empty($field_id) && !is_array($field_id)) { |
|
| 1203 | + $field = self::get_field($form, $field_id); |
|
| 1204 | 1204 | } else { |
| 1205 | 1205 | $field = $field_id; |
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | - return class_exists( 'RGFormsModel' ) ? RGFormsModel::get_input_type( $field ) : ''; |
|
| 1208 | + return class_exists('RGFormsModel') ? RGFormsModel::get_input_type($field) : ''; |
|
| 1209 | 1209 | |
| 1210 | 1210 | } |
| 1211 | 1211 | |
@@ -1216,17 +1216,17 @@ discard block |
||
| 1216 | 1216 | * @param int|array $field field key or field array |
| 1217 | 1217 | * @return boolean |
| 1218 | 1218 | */ |
| 1219 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1219 | + public static function is_field_numeric($form = null, $field = '') { |
|
| 1220 | 1220 | |
| 1221 | - if ( ! is_array( $form ) && ! is_array( $field ) ) { |
|
| 1222 | - $form = self::get_form( $form ); |
|
| 1221 | + if (!is_array($form) && !is_array($field)) { |
|
| 1222 | + $form = self::get_form($form); |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | // If entry meta, it's a string. Otherwise, numeric |
| 1226 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1226 | + if (!is_numeric($field) && is_string($field)) { |
|
| 1227 | 1227 | $type = $field; |
| 1228 | 1228 | } else { |
| 1229 | - $type = self::get_field_type( $form, $field ); |
|
| 1229 | + $type = self::get_field_type($form, $field); |
|
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | 1232 | /** |
@@ -1234,16 +1234,16 @@ discard block |
||
| 1234 | 1234 | * @since 1.5.2 |
| 1235 | 1235 | * @param array $numeric_types Fields that are numeric. Default: `[ number, time ]` |
| 1236 | 1236 | */ |
| 1237 | - $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
|
| 1237 | + $numeric_types = apply_filters('gravityview/common/numeric_types', array('number', 'time')); |
|
| 1238 | 1238 | |
| 1239 | 1239 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1240 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1241 | - if( true === $gv_field->is_numeric ) { |
|
| 1240 | + if ($gv_field = GravityView_Fields::get($type)) { |
|
| 1241 | + if (true === $gv_field->is_numeric) { |
|
| 1242 | 1242 | $numeric_types[] = $gv_field->is_numeric; |
| 1243 | 1243 | } |
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | - $return = in_array( $type, $numeric_types ); |
|
| 1246 | + $return = in_array($type, $numeric_types); |
|
| 1247 | 1247 | |
| 1248 | 1248 | return $return; |
| 1249 | 1249 | } |
@@ -1262,19 +1262,19 @@ discard block |
||
| 1262 | 1262 | * |
| 1263 | 1263 | * @return string Content, encrypted |
| 1264 | 1264 | */ |
| 1265 | - public static function js_encrypt( $content, $message = '' ) { |
|
| 1265 | + public static function js_encrypt($content, $message = '') { |
|
| 1266 | 1266 | |
| 1267 | 1267 | $output = $content; |
| 1268 | 1268 | |
| 1269 | - if ( ! class_exists( 'StandalonePHPEnkoder' ) ) { |
|
| 1270 | - include_once( GRAVITYVIEW_DIR . 'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php' ); |
|
| 1269 | + if (!class_exists('StandalonePHPEnkoder')) { |
|
| 1270 | + include_once(GRAVITYVIEW_DIR.'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php'); |
|
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | - if ( class_exists( 'StandalonePHPEnkoder' ) ) { |
|
| 1273 | + if (class_exists('StandalonePHPEnkoder')) { |
|
| 1274 | 1274 | |
| 1275 | 1275 | $enkoder = new StandalonePHPEnkoder; |
| 1276 | 1276 | |
| 1277 | - $message = empty( $message ) ? __( 'Email hidden; Javascript is required.', 'gravityview' ) : $message; |
|
| 1277 | + $message = empty($message) ? __('Email hidden; Javascript is required.', 'gravityview') : $message; |
|
| 1278 | 1278 | |
| 1279 | 1279 | /** |
| 1280 | 1280 | * @filter `gravityview/phpenkoder/msg` Modify the message shown when Javascript is disabled and an encrypted email field is displayed |
@@ -1282,9 +1282,9 @@ discard block |
||
| 1282 | 1282 | * @param string $message Existing message |
| 1283 | 1283 | * @param string $content Content to encrypt |
| 1284 | 1284 | */ |
| 1285 | - $enkoder->enkode_msg = apply_filters( 'gravityview/phpenkoder/msg', $message, $content ); |
|
| 1285 | + $enkoder->enkode_msg = apply_filters('gravityview/phpenkoder/msg', $message, $content); |
|
| 1286 | 1286 | |
| 1287 | - $output = $enkoder->enkode( $content ); |
|
| 1287 | + $output = $enkoder->enkode($content); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | |
| 1290 | 1290 | return $output; |
@@ -1301,25 +1301,25 @@ discard block |
||
| 1301 | 1301 | * |
| 1302 | 1302 | * @author rubo77 at https://gist.github.com/rubo77/6821632 |
| 1303 | 1303 | **/ |
| 1304 | - public static function gv_parse_str( $string, &$result ) { |
|
| 1305 | - if ( empty( $string ) ) { |
|
| 1304 | + public static function gv_parse_str($string, &$result) { |
|
| 1305 | + if (empty($string)) { |
|
| 1306 | 1306 | return false; |
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | $result = array(); |
| 1310 | 1310 | |
| 1311 | 1311 | // find the pairs "name=value" |
| 1312 | - $pairs = explode( '&', $string ); |
|
| 1312 | + $pairs = explode('&', $string); |
|
| 1313 | 1313 | |
| 1314 | - foreach ( $pairs as $pair ) { |
|
| 1314 | + foreach ($pairs as $pair) { |
|
| 1315 | 1315 | // use the original parse_str() on each element |
| 1316 | - parse_str( $pair, $params ); |
|
| 1316 | + parse_str($pair, $params); |
|
| 1317 | 1317 | |
| 1318 | - $k = key( $params ); |
|
| 1319 | - if ( ! isset( $result[ $k ] ) ) { |
|
| 1318 | + $k = key($params); |
|
| 1319 | + if (!isset($result[$k])) { |
|
| 1320 | 1320 | $result += $params; |
| 1321 | - } elseif ( array_key_exists( $k, $params ) && is_array( $params[ $k ] ) ) { |
|
| 1322 | - $result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] ); |
|
| 1321 | + } elseif (array_key_exists($k, $params) && is_array($params[$k])) { |
|
| 1322 | + $result[$k] = self::array_merge_recursive_distinct($result[$k], $params[$k]); |
|
| 1323 | 1323 | } |
| 1324 | 1324 | } |
| 1325 | 1325 | return true; |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | * |
| 1342 | 1342 | * @return string HTML output of anchor link. If empty $href, returns NULL |
| 1343 | 1343 | */ |
| 1344 | - public static function get_link_html( $href = '', $anchor_text = '', $atts = array() ) { |
|
| 1344 | + public static function get_link_html($href = '', $anchor_text = '', $atts = array()) { |
|
| 1345 | 1345 | |
| 1346 | 1346 | // Supported attributes for anchor tags. HREF left out intentionally. |
| 1347 | 1347 | $allowed_atts = array( |
@@ -1377,31 +1377,31 @@ discard block |
||
| 1377 | 1377 | * @filter `gravityview/get_link/allowed_atts` Modify the attributes that are allowed to be used in generating links |
| 1378 | 1378 | * @param array $allowed_atts Array of attributes allowed |
| 1379 | 1379 | */ |
| 1380 | - $allowed_atts = apply_filters( 'gravityview/get_link/allowed_atts', $allowed_atts ); |
|
| 1380 | + $allowed_atts = apply_filters('gravityview/get_link/allowed_atts', $allowed_atts); |
|
| 1381 | 1381 | |
| 1382 | 1382 | // Make sure the attributes are formatted as array |
| 1383 | - $passed_atts = wp_parse_args( $atts ); |
|
| 1383 | + $passed_atts = wp_parse_args($atts); |
|
| 1384 | 1384 | |
| 1385 | 1385 | // Make sure the allowed attributes are only the ones in the $allowed_atts list |
| 1386 | - $final_atts = shortcode_atts( $allowed_atts, $passed_atts ); |
|
| 1386 | + $final_atts = shortcode_atts($allowed_atts, $passed_atts); |
|
| 1387 | 1387 | |
| 1388 | 1388 | // Remove attributes with empty values |
| 1389 | - $final_atts = array_filter( $final_atts ); |
|
| 1389 | + $final_atts = array_filter($final_atts); |
|
| 1390 | 1390 | |
| 1391 | 1391 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1392 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1392 | + if (empty($final_atts['href']) && !empty($href)) { |
|
| 1393 | 1393 | $final_atts['href'] = $href; |
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1396 | + $final_atts['href'] = esc_url_raw($href); |
|
| 1397 | 1397 | |
| 1398 | 1398 | // For each attribute, generate the code |
| 1399 | 1399 | $output = ''; |
| 1400 | - foreach ( $final_atts as $attr => $value ) { |
|
| 1401 | - $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
|
| 1400 | + foreach ($final_atts as $attr => $value) { |
|
| 1401 | + $output .= sprintf(' %s="%s"', $attr, esc_attr($value)); |
|
| 1402 | 1402 | } |
| 1403 | 1403 | |
| 1404 | - $output = '<a'. $output .'>'. $anchor_text .'</a>'; |
|
| 1404 | + $output = '<a'.$output.'>'.$anchor_text.'</a>'; |
|
| 1405 | 1405 | |
| 1406 | 1406 | return $output; |
| 1407 | 1407 | } |
@@ -1420,14 +1420,14 @@ discard block |
||
| 1420 | 1420 | * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk> |
| 1421 | 1421 | * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com> |
| 1422 | 1422 | */ |
| 1423 | - public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { |
|
| 1423 | + public static function array_merge_recursive_distinct(array &$array1, array &$array2) { |
|
| 1424 | 1424 | $merged = $array1; |
| 1425 | 1425 | |
| 1426 | - foreach ( $array2 as $key => &$value ) { |
|
| 1427 | - if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
|
| 1428 | - $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
|
| 1426 | + foreach ($array2 as $key => &$value) { |
|
| 1427 | + if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { |
|
| 1428 | + $merged[$key] = self::array_merge_recursive_distinct($merged[$key], $value); |
|
| 1429 | 1429 | } else { |
| 1430 | - $merged[ $key ] = $value; |
|
| 1430 | + $merged[$key] = $value; |
|
| 1431 | 1431 | } |
| 1432 | 1432 | } |
| 1433 | 1433 | |
@@ -1441,26 +1441,26 @@ discard block |
||
| 1441 | 1441 | * @param array $args Arguments to modify the user query. See get_users() {@since 1.14} |
| 1442 | 1442 | * @return array Array of WP_User objects. |
| 1443 | 1443 | */ |
| 1444 | - public static function get_users( $context = 'change_entry_creator', $args = array() ) { |
|
| 1444 | + public static function get_users($context = 'change_entry_creator', $args = array()) { |
|
| 1445 | 1445 | |
| 1446 | 1446 | $default_args = array( |
| 1447 | 1447 | 'number' => 2000, |
| 1448 | 1448 | 'orderby' => 'display_name', |
| 1449 | 1449 | 'order' => 'ASC', |
| 1450 | - 'fields' => array( 'ID', 'display_name', 'user_login', 'user_nicename' ) |
|
| 1450 | + 'fields' => array('ID', 'display_name', 'user_login', 'user_nicename') |
|
| 1451 | 1451 | ); |
| 1452 | 1452 | |
| 1453 | 1453 | // Merge in the passed arg |
| 1454 | - $get_users_settings = wp_parse_args( $args, $default_args ); |
|
| 1454 | + $get_users_settings = wp_parse_args($args, $default_args); |
|
| 1455 | 1455 | |
| 1456 | 1456 | /** |
| 1457 | 1457 | * @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 |
| 1458 | 1458 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1459 | 1459 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1460 | 1460 | */ |
| 1461 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1461 | + $get_users_settings = apply_filters('gravityview/get_users/'.$context, apply_filters('gravityview_change_entry_creator_user_parameters', $get_users_settings)); |
|
| 1462 | 1462 | |
| 1463 | - return get_users( $get_users_settings ); |
|
| 1463 | + return get_users($get_users_settings); |
|
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | 1466 | |
@@ -1472,8 +1472,8 @@ discard block |
||
| 1472 | 1472 | * |
| 1473 | 1473 | * @return string |
| 1474 | 1474 | */ |
| 1475 | - public static function generate_notice( $notice, $class = '' ) { |
|
| 1476 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1475 | + public static function generate_notice($notice, $class = '') { |
|
| 1476 | + return '<div class="gv-notice '.gravityview_sanitize_html_class($class).'">'.$notice.'</div>'; |
|
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | 1479 | |
@@ -1495,6 +1495,6 @@ discard block |
||
| 1495 | 1495 | * |
| 1496 | 1496 | * @return string HTML output of anchor link. If empty $href, returns NULL |
| 1497 | 1497 | */ |
| 1498 | -function gravityview_get_link( $href = '', $anchor_text = '', $atts = array() ) { |
|
| 1499 | - return GVCommon::get_link_html( $href, $anchor_text, $atts ); |
|
| 1498 | +function gravityview_get_link($href = '', $anchor_text = '', $atts = array()) { |
|
| 1499 | + return GVCommon::get_link_html($href, $anchor_text, $atts); |
|
| 1500 | 1500 | } |