@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | // hold widget View options |
52 | 52 | private $widget_options; |
53 | 53 | |
54 | - function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) { |
|
54 | + function __construct( $widget_label, $widget_id, $defaults = array(), $settings = array() ) { |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * The shortcode name is set to the lowercase name of the widget class, unless overridden by the class specifying a different value for $shortcode_name |
59 | 59 | * @var string |
60 | 60 | */ |
61 | - $this->shortcode_name = !isset( $this->shortcode_name ) ? strtolower( get_class($this) ) : $this->shortcode_name; |
|
61 | + $this->shortcode_name = ! isset( $this->shortcode_name ) ? strtolower( get_class( $this ) ) : $this->shortcode_name; |
|
62 | 62 | |
63 | 63 | $this->widget_label = $widget_label; |
64 | 64 | $this->widget_id = $widget_id; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $this->settings = wp_parse_args( $settings, $this->settings ); |
70 | 70 | |
71 | 71 | // register widgets to be listed in the View Configuration |
72 | - add_filter( 'gravityview_register_directory_widgets', array( $this, 'register_widget') ); |
|
72 | + add_filter( 'gravityview_register_directory_widgets', array( $this, 'register_widget' ) ); |
|
73 | 73 | |
74 | 74 | // widget options |
75 | 75 | add_filter( 'gravityview_template_widget_options', array( $this, 'assign_widget_options' ), 10, 3 ); |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | add_action( "gravityview_render_widget_{$widget_id}", array( $this, 'render_frontend' ), 10, 1 ); |
79 | 79 | |
80 | 80 | // register shortcodes |
81 | - add_action( 'wp', array( $this, 'add_shortcode') ); |
|
81 | + add_action( 'wp', array( $this, 'add_shortcode' ) ); |
|
82 | 82 | |
83 | 83 | // Use shortcodes in text widgets. |
84 | - add_filter('widget_text', array( $this, 'maybe_do_shortcode' ) ); |
|
84 | + add_filter( 'widget_text', array( $this, 'maybe_do_shortcode' ) ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | * @param boolean $enable_custom_class False by default. Return true if you want to enable. |
100 | 100 | * @param GravityView_Widget $this Current instance of GravityView_Widget |
101 | 101 | */ |
102 | - $enable_custom_class = apply_filters('gravityview/widget/enable_custom_class', false, $this ); |
|
102 | + $enable_custom_class = apply_filters( 'gravityview/widget/enable_custom_class', false, $this ); |
|
103 | 103 | |
104 | - if( $enable_custom_class ) { |
|
104 | + if ( $enable_custom_class ) { |
|
105 | 105 | |
106 | - $settings['custom_class'] = array( |
|
106 | + $settings[ 'custom_class' ] = array( |
|
107 | 107 | 'type' => 'text', |
108 | 108 | 'label' => __( 'Custom CSS Class:', 'gravityview' ), |
109 | - 'desc' => __( 'This class will be added to the widget container', 'gravityview'), |
|
109 | + 'desc' => __( 'This class will be added to the widget container', 'gravityview' ), |
|
110 | 110 | 'value' => '', |
111 | 111 | 'merge_tags' => true, |
112 | 112 | ); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return array|null Settings array; NULL if not set |
129 | 129 | */ |
130 | 130 | public function get_settings() { |
131 | - return !empty( $this->settings ) ? $this->settings : NULL; |
|
131 | + return ! empty( $this->settings ) ? $this->settings : NULL; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | public function get_setting( $key ) { |
140 | 140 | $setting = NULL; |
141 | 141 | |
142 | - if( isset( $this->settings ) && is_array( $this->settings ) ) { |
|
142 | + if ( isset( $this->settings ) && is_array( $this->settings ) ) { |
|
143 | 143 | $setting = isset( $this->settings[ $key ] ) ? $this->settings[ $key ] : NULL; |
144 | 144 | } |
145 | 145 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | function maybe_do_shortcode( $text, $widget = NULL ) { |
156 | 156 | |
157 | - if( !empty( $this->shortcode_name ) && has_shortcode( $text, $this->shortcode_name ) ) { |
|
157 | + if ( ! empty( $this->shortcode_name ) && has_shortcode( $text, $this->shortcode_name ) ) { |
|
158 | 158 | return do_shortcode( $text ); |
159 | 159 | } |
160 | 160 | |
@@ -183,26 +183,26 @@ discard block |
||
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
186 | - if( empty( $this->shortcode_name ) ) { return; } |
|
186 | + if ( empty( $this->shortcode_name ) ) { return; } |
|
187 | 187 | |
188 | 188 | // If the widget shouldn't output on single entries, don't show it |
189 | - if( empty( $this->show_on_single ) && class_exists('GravityView_frontend') && GravityView_frontend::is_single_entry() ) { |
|
190 | - do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: Skipping; set to not run on single entry.', get_class($this)) ); |
|
189 | + if ( empty( $this->show_on_single ) && class_exists( 'GravityView_frontend' ) && GravityView_frontend::is_single_entry() ) { |
|
190 | + do_action( 'gravityview_log_debug', sprintf( '%s[add_shortcode]: Skipping; set to not run on single entry.', get_class( $this ) ) ); |
|
191 | 191 | |
192 | 192 | add_shortcode( $this->shortcode_name, '__return_null' ); |
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
196 | 196 | |
197 | - if( !has_gravityview_shortcode( $post ) ) { |
|
197 | + if ( ! has_gravityview_shortcode( $post ) ) { |
|
198 | 198 | |
199 | - do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class($this)) ); |
|
199 | + do_action( 'gravityview_log_debug', sprintf( '%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class( $this ) ) ); |
|
200 | 200 | |
201 | 201 | add_shortcode( $this->shortcode_name, '__return_null' ); |
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
205 | - add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode') ); |
|
205 | + add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode' ) ); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | function register_widget( $widgets ) { |
214 | 214 | $widgets[ $this->widget_id ] = array( |
215 | - 'label' => $this->widget_label , |
|
215 | + 'label' => $this->widget_label, |
|
216 | 216 | 'description' => $this->widget_description, |
217 | 217 | 'subtitle' => $this->widget_subtitle, |
218 | 218 | ); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function assign_widget_options( $options = array(), $template = '', $widget = '' ) { |
231 | 231 | |
232 | - if( $this->widget_id === $widget ) { |
|
232 | + if ( $this->widget_id === $widget ) { |
|
233 | 233 | $options = array_merge( $options, $this->settings ); |
234 | 234 | } |
235 | 235 | |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return void |
244 | 244 | */ |
245 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
245 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
246 | 246 | // to be defined by child class |
247 | - if( !$this->pre_render_frontend() ) { |
|
247 | + if ( ! $this->pre_render_frontend() ) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | 250 | } |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | public function pre_render_frontend() { |
257 | 257 | $gravityview_view = GravityView_View::getInstance(); |
258 | 258 | |
259 | - if( empty( $gravityview_view ) ) { |
|
260 | - do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this)) ); |
|
259 | + if ( empty( $gravityview_view ) ) { |
|
260 | + do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class( $this ) ) ); |
|
261 | 261 | return false; |
262 | 262 | } |
263 | 263 | |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | */ |
269 | 269 | $hide_until_search = apply_filters( 'gravityview/widget/hide_until_searched', $gravityview_view->hide_until_searched, $this ); |
270 | 270 | |
271 | - if( $hide_until_search ) { |
|
272 | - do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: Hide View data until search is performed', get_class($this)) ); |
|
271 | + if ( $hide_until_search ) { |
|
272 | + do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: Hide View data until search is performed', get_class( $this ) ) ); |
|
273 | 273 | return false; |
274 | 274 | } |
275 | 275 |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | private function __construct() {} |
86 | 86 | |
87 | 87 | private function initialize() { |
88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
91 | 91 | |
92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -236,15 +236,15 @@ discard block |
||
236 | 236 | |
237 | 237 | $this->context_view_id = $view_id; |
238 | 238 | |
239 | - } elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
239 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
240 | 240 | /** |
241 | 241 | * used on a has_multiple_views context |
242 | 242 | * @see GravityView_API::entry_link |
243 | 243 | * @see GravityView_View_Data::getInstance()->has_multiple_views() |
244 | 244 | */ |
245 | - $this->context_view_id = $_GET['gvid']; |
|
245 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
246 | 246 | |
247 | - } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
247 | + } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
248 | 248 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
249 | 249 | $this->context_view_id = array_pop( $array_keys ); |
250 | 250 | unset( $array_keys ); |
@@ -279,24 +279,24 @@ discard block |
||
279 | 279 | global $wp_rewrite; |
280 | 280 | |
281 | 281 | $is_front_page = ( $query->is_home || $query->is_page ); |
282 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
283 | - $front_page_id = get_option('page_on_front'); |
|
282 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
283 | + $front_page_id = get_option( 'page_on_front' ); |
|
284 | 284 | |
285 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
285 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
286 | 286 | |
287 | 287 | // Force to be an array, potentially a query string ( entry=16 ) |
288 | 288 | $_query = wp_parse_args( $query->query ); |
289 | 289 | |
290 | 290 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
291 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
292 | - unset( $_query['pagename'] ); |
|
291 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
292 | + unset( $_query[ 'pagename' ] ); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | // this is where will break from core wordpress |
296 | 296 | $ignore = array( 'preview', 'page', 'paged', 'cpage' ); |
297 | 297 | $endpoints = rgobj( $wp_rewrite, 'endpoints' ); |
298 | - foreach ( (array) $endpoints as $endpoint ) { |
|
299 | - $ignore[] = $endpoint[1]; |
|
298 | + foreach ( (array)$endpoints as $endpoint ) { |
|
299 | + $ignore[ ] = $endpoint[ 1 ]; |
|
300 | 300 | } |
301 | 301 | unset( $endpoints ); |
302 | 302 | |
@@ -306,21 +306,21 @@ discard block |
||
306 | 306 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
307 | 307 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
308 | 308 | |
309 | - $qv =& $query->query_vars; |
|
309 | + $qv = & $query->query_vars; |
|
310 | 310 | |
311 | 311 | // Prevent redirect when on the single entry endpoint |
312 | - if( self::is_single_entry() ) { |
|
312 | + if ( self::is_single_entry() ) { |
|
313 | 313 | add_filter( 'redirect_canonical', '__return_false' ); |
314 | 314 | } |
315 | 315 | |
316 | 316 | $query->is_page = true; |
317 | 317 | $query->is_home = false; |
318 | - $qv['page_id'] = $front_page_id; |
|
318 | + $qv[ 'page_id' ] = $front_page_id; |
|
319 | 319 | |
320 | 320 | // Correct <!--nextpage--> for page_on_front |
321 | - if ( ! empty( $qv['paged'] ) ) { |
|
322 | - $qv['page'] = $qv['paged']; |
|
323 | - unset( $qv['paged'] ); |
|
321 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
322 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
323 | + unset( $qv[ 'paged' ] ); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | |
354 | 354 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
355 | 355 | |
356 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
356 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
357 | 357 | $this->setPostId( $post_id ); |
358 | 358 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
359 | 359 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | |
390 | 390 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
391 | 391 | |
392 | - if( 'post' === $search_method ) { |
|
392 | + if ( 'post' === $search_method ) { |
|
393 | 393 | $get = $_POST; |
394 | 394 | } else { |
395 | 395 | $get = $_GET; |
@@ -445,20 +445,20 @@ discard block |
||
445 | 445 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
446 | 446 | * @param array $entry Current entry |
447 | 447 | */ |
448 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
448 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
449 | 449 | |
450 | 450 | if ( ! $apply_outside_loop ) { |
451 | 451 | return $title; |
452 | 452 | } |
453 | 453 | |
454 | 454 | // User reported WooCommerce doesn't pass two args. |
455 | - if ( empty( $passed_post_id ) ) { |
|
455 | + if ( empty( $passed_post_id ) ) { |
|
456 | 456 | return $title; |
457 | 457 | } |
458 | 458 | |
459 | 459 | // Don't modify the title for anything other than the current view/post. |
460 | 460 | // This is true for embedded shortcodes and Views. |
461 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
461 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
462 | 462 | return $title; |
463 | 463 | } |
464 | 464 | |
@@ -468,19 +468,19 @@ discard block |
||
468 | 468 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
469 | 469 | } else { |
470 | 470 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
471 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
471 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
472 | 472 | $view_meta = $view_data; |
473 | 473 | break; |
474 | 474 | } |
475 | 475 | } |
476 | 476 | } |
477 | 477 | |
478 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
478 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
479 | 479 | |
480 | - $title = $view_meta['atts']['single_title']; |
|
480 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
481 | 481 | |
482 | 482 | // We are allowing HTML in the fields, so no escaping the output |
483 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
483 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
484 | 484 | |
485 | 485 | $title = do_shortcode( $title ); |
486 | 486 | } |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | } |
517 | 517 | |
518 | 518 | // Only render in the loop. Fixes issues with the_content filter being applied in places like the sidebar |
519 | - if( ! in_the_loop() ) { |
|
519 | + if ( ! in_the_loop() ) { |
|
520 | 520 | return $content; |
521 | 521 | } |
522 | 522 | |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | |
585 | 585 | $context = GravityView_View::getInstance()->getContext(); |
586 | 586 | |
587 | - switch( $context ) { |
|
587 | + switch ( $context ) { |
|
588 | 588 | case 'directory': |
589 | 589 | $tab = __( 'Multiple Entries', 'gravityview' ); |
590 | 590 | break; |
@@ -598,9 +598,9 @@ discard block |
||
598 | 598 | } |
599 | 599 | |
600 | 600 | |
601 | - $title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
601 | + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
602 | 602 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) ); |
603 | - $action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); |
|
603 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
|
604 | 604 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
605 | 605 | |
606 | 606 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | public function render_view( $passed_args ) { |
634 | 634 | |
635 | 635 | // validate attributes |
636 | - if ( empty( $passed_args['id'] ) ) { |
|
636 | + if ( empty( $passed_args[ 'id' ] ) ) { |
|
637 | 637 | do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args ); |
638 | 638 | return null; |
639 | 639 | } |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | return null; |
656 | 656 | } |
657 | 657 | |
658 | - $view_id = $passed_args['id']; |
|
658 | + $view_id = $passed_args[ 'id' ]; |
|
659 | 659 | |
660 | 660 | $view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args ); |
661 | 661 | |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | $passed_args = array_filter( $passed_args, 'strlen' ); |
669 | 669 | |
670 | 670 | //Override shortcode args over View template settings |
671 | - $atts = wp_parse_args( $passed_args, $view_data['atts'] ); |
|
671 | + $atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] ); |
|
672 | 672 | |
673 | 673 | do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts ); |
674 | 674 | |
@@ -691,14 +691,14 @@ discard block |
||
691 | 691 | * @since 1.15 |
692 | 692 | * @since 1.17.2 Added check for if a user has no caps but is logged in (member of multisite, but not any site). Treat as if logged-out. |
693 | 693 | */ |
694 | - if( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
694 | + if ( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
695 | 695 | |
696 | 696 | do_action( 'gravityview_log_debug', sprintf( '%s Returning: View %d is not visible by current user.', __METHOD__, $view_id ) ); |
697 | 697 | |
698 | 698 | return null; |
699 | 699 | } |
700 | 700 | |
701 | - if( $this->isGravityviewPostType() ) { |
|
701 | + if ( $this->isGravityviewPostType() ) { |
|
702 | 702 | |
703 | 703 | /** |
704 | 704 | * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode? |
@@ -710,9 +710,9 @@ discard block |
||
710 | 710 | */ |
711 | 711 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view_id ); |
712 | 712 | |
713 | - $embed_only = ! empty( $atts['embed_only'] ); |
|
713 | + $embed_only = ! empty( $atts[ 'embed_only' ] ); |
|
714 | 714 | |
715 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
715 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
716 | 716 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
717 | 717 | } |
718 | 718 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | |
728 | 728 | $gravityview_view = new GravityView_View( $view_data ); |
729 | 729 | |
730 | - $post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId(); |
|
730 | + $post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : $this->getPostId(); |
|
731 | 731 | |
732 | 732 | $gravityview_view->setPostId( $post_id ); |
733 | 733 | |
@@ -737,20 +737,20 @@ discard block |
||
737 | 737 | do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' ); |
738 | 738 | |
739 | 739 | //fetch template and slug |
740 | - $view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' ); |
|
740 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'directory' ); |
|
741 | 741 | |
742 | 742 | do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug ); |
743 | 743 | |
744 | 744 | /** |
745 | 745 | * Disable fetching initial entries for views that don't need it (DataTables) |
746 | 746 | */ |
747 | - $get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true ); |
|
747 | + $get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true ); |
|
748 | 748 | |
749 | 749 | /** |
750 | 750 | * Hide View data until search is performed |
751 | 751 | * @since 1.5.4 |
752 | 752 | */ |
753 | - if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) { |
|
753 | + if ( ! empty( $atts[ 'hide_until_searched' ] ) && ! $this->isSearch() ) { |
|
754 | 754 | $gravityview_view->setHideUntilSearched( true ); |
755 | 755 | $get_entries = false; |
756 | 756 | } |
@@ -758,23 +758,23 @@ discard block |
||
758 | 758 | |
759 | 759 | if ( $get_entries ) { |
760 | 760 | |
761 | - if ( ! empty( $atts['sort_columns'] ) ) { |
|
761 | + if ( ! empty( $atts[ 'sort_columns' ] ) ) { |
|
762 | 762 | // add filter to enable column sorting |
763 | - add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 ); |
|
763 | + add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 ); |
|
764 | 764 | } |
765 | 765 | |
766 | - $view_entries = self::get_view_entries( $atts, $view_data['form_id'] ); |
|
766 | + $view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] ); |
|
767 | 767 | |
768 | - do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) ); |
|
768 | + do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) ); |
|
769 | 769 | |
770 | 770 | } else { |
771 | 771 | |
772 | 772 | $view_entries = array( 'count' => null, 'entries' => null, 'paging' => null ); |
773 | 773 | |
774 | - do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' ); |
|
774 | + do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' ); |
|
775 | 775 | } |
776 | 776 | |
777 | - $gravityview_view->setPaging( $view_entries['paging'] ); |
|
777 | + $gravityview_view->setPaging( $view_entries[ 'paging' ] ); |
|
778 | 778 | $gravityview_view->setContext( 'directory' ); |
779 | 779 | $sections = array( 'header', 'body', 'footer' ); |
780 | 780 | |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | * @action `gravityview_render_entry_{View ID}` Before rendering a single entry for a specific View ID |
789 | 789 | * @since 1.17 |
790 | 790 | */ |
791 | - do_action( 'gravityview_render_entry_'.$view_data['id'] ); |
|
791 | + do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] ); |
|
792 | 792 | |
793 | 793 | $entry = $this->getEntry(); |
794 | 794 | |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | do_action( 'gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.' ); |
799 | 799 | |
800 | 800 | // Only display warning once when multiple Views are embedded |
801 | - if( $view_id !== (int) GravityView_frontend::get_context_view_id() ) { |
|
801 | + if ( $view_id !== (int)GravityView_frontend::get_context_view_id() ) { |
|
802 | 802 | ob_end_clean(); |
803 | 803 | return null; |
804 | 804 | } |
@@ -822,21 +822,21 @@ discard block |
||
822 | 822 | // We're in single view, but the view being processed is not the same view the single entry belongs to. |
823 | 823 | // important: do not remove this as it prevents fake attempts of displaying entries from other views/forms |
824 | 824 | if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) { |
825 | - 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 ); |
|
825 | + 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 ); |
|
826 | 826 | ob_end_clean(); |
827 | 827 | return null; |
828 | 828 | } |
829 | 829 | |
830 | 830 | //fetch template and slug |
831 | - $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' ); |
|
831 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'single' ); |
|
832 | 832 | do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug ); |
833 | 833 | |
834 | 834 | //fetch entry detail |
835 | - $view_entries['count'] = 1; |
|
836 | - $view_entries['entries'][] = $entry; |
|
837 | - do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] ); |
|
835 | + $view_entries[ 'count' ] = 1; |
|
836 | + $view_entries[ 'entries' ][ ] = $entry; |
|
837 | + do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] ); |
|
838 | 838 | |
839 | - $back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null; |
|
839 | + $back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null; |
|
840 | 840 | |
841 | 841 | // set back link label |
842 | 842 | $gravityview_view->setBackLinkLabel( $back_link_label ); |
@@ -846,11 +846,11 @@ discard block |
||
846 | 846 | } |
847 | 847 | |
848 | 848 | // add template style |
849 | - self::add_style( $view_data['template_id'] ); |
|
849 | + self::add_style( $view_data[ 'template_id' ] ); |
|
850 | 850 | |
851 | 851 | // Prepare to render view and set vars |
852 | - $gravityview_view->setEntries( $view_entries['entries'] ); |
|
853 | - $gravityview_view->setTotalEntries( $view_entries['count'] ); |
|
852 | + $gravityview_view->setEntries( $view_entries[ 'entries' ] ); |
|
853 | + $gravityview_view->setTotalEntries( $view_entries[ 'count' ] ); |
|
854 | 854 | |
855 | 855 | // If Edit |
856 | 856 | if ( 'edit' === gravityview_get_context() ) { |
@@ -863,11 +863,11 @@ discard block |
||
863 | 863 | |
864 | 864 | } else { |
865 | 865 | // finaly we'll render some html |
866 | - $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] ); |
|
866 | + $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data[ 'template_id' ] ); |
|
867 | 867 | |
868 | 868 | do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections ); |
869 | 869 | foreach ( $sections as $section ) { |
870 | - do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' ); |
|
870 | + do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' ); |
|
871 | 871 | $gravityview_view->render( $view_slug, $section, false ); |
872 | 872 | } |
873 | 873 | } |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | $datetime_format = 'Y-m-d H:i:s'; |
922 | 922 | $search_is_outside_view_bounds = false; |
923 | 923 | |
924 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
924 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
925 | 925 | |
926 | 926 | $search_date = strtotime( $search_criteria[ $key ] ); |
927 | 927 | |
@@ -949,14 +949,14 @@ discard block |
||
949 | 949 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
950 | 950 | |
951 | 951 | // Then we override the search and re-set the start date |
952 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
952 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
953 | 953 | } |
954 | 954 | } |
955 | 955 | } |
956 | 956 | |
957 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
957 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
958 | 958 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
959 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
959 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
960 | 960 | do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria ); |
961 | 961 | } |
962 | 962 | } |
@@ -975,19 +975,19 @@ discard block |
||
975 | 975 | public static function process_search_only_approved( $args, $search_criteria ) { |
976 | 976 | |
977 | 977 | /** @since 1.19 */ |
978 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
978 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
979 | 979 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries; showing all approval statuses' ); |
980 | 980 | return $search_criteria; |
981 | 981 | } |
982 | 982 | |
983 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
983 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
984 | 984 | |
985 | - $search_criteria['field_filters'][] = array( |
|
985 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
986 | 986 | 'key' => GravityView_Entry_Approval::meta_key, |
987 | 987 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
988 | 988 | ); |
989 | 989 | |
990 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
990 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
991 | 991 | |
992 | 992 | do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria ); |
993 | 993 | } |
@@ -1014,18 +1014,18 @@ discard block |
||
1014 | 1014 | */ |
1015 | 1015 | public static function is_entry_approved( $entry, $args = array() ) { |
1016 | 1016 | |
1017 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
1017 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
1018 | 1018 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
1019 | 1019 | return true; |
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | /** @since 1.19 */ |
1023 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
1023 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
1024 | 1024 | do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries, so entry is approved for viewing' ); |
1025 | 1025 | return true; |
1026 | 1026 | } |
1027 | 1027 | |
1028 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
1028 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
1029 | 1029 | |
1030 | 1030 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
1031 | 1031 | } |
@@ -1059,26 +1059,26 @@ discard block |
||
1059 | 1059 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria ); |
1060 | 1060 | |
1061 | 1061 | // implicity search |
1062 | - if ( ! empty( $args['search_value'] ) ) { |
|
1062 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
1063 | 1063 | |
1064 | 1064 | // Search operator options. Options: `is` or `contains` |
1065 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
1065 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
1066 | 1066 | |
1067 | - $search_criteria['field_filters'][] = array( |
|
1067 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
1068 | 1068 | 'key' => rgget( 'search_field', $args ), // The field ID to search |
1069 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
1069 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
1070 | 1070 | 'operator' => $operator, |
1071 | 1071 | ); |
1072 | 1072 | } |
1073 | 1073 | |
1074 | - if( $search_criteria !== $original_search_criteria ) { |
|
1074 | + if ( $search_criteria !== $original_search_criteria ) { |
|
1075 | 1075 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria ); |
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | // Handle setting date range |
1079 | 1079 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
1080 | 1080 | |
1081 | - if( $search_criteria !== $original_search_criteria ) { |
|
1081 | + if ( $search_criteria !== $original_search_criteria ) { |
|
1082 | 1082 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria ); |
1083 | 1083 | } |
1084 | 1084 | |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
1090 | 1090 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
1091 | 1091 | */ |
1092 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
1092 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
1093 | 1093 | |
1094 | 1094 | return $search_criteria; |
1095 | 1095 | } |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | 'search_criteria' => $search_criteria, |
1141 | 1141 | 'sorting' => self::updateViewSorting( $args, $form_id ), |
1142 | 1142 | 'paging' => $paging, |
1143 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
1143 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
1144 | 1144 | ); |
1145 | 1145 | |
1146 | 1146 | /** |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
1166 | 1166 | * @param array $args View configuration args. |
1167 | 1167 | */ |
1168 | - $parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id ); |
|
1168 | + $parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id ); |
|
1169 | 1169 | |
1170 | 1170 | do_action( 'gravityview_log_debug', __METHOD__ . ': $parameters passed to gravityview_get_entries(): ', $parameters ); |
1171 | 1171 | |
@@ -1211,16 +1211,16 @@ discard block |
||
1211 | 1211 | $default_page_size = apply_filters( 'gravityview_default_page_size', 25 ); |
1212 | 1212 | |
1213 | 1213 | // Paging & offset |
1214 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size; |
|
1214 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size; |
|
1215 | 1215 | |
1216 | 1216 | if ( -1 === $page_size ) { |
1217 | 1217 | $page_size = PHP_INT_MAX; |
1218 | 1218 | } |
1219 | 1219 | |
1220 | - if ( isset( $args['offset'] ) ) { |
|
1221 | - $offset = intval( $args['offset'] ); |
|
1220 | + if ( isset( $args[ 'offset' ] ) ) { |
|
1221 | + $offset = intval( $args[ 'offset' ] ); |
|
1222 | 1222 | } else { |
1223 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
1223 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
1224 | 1224 | $offset = ( $curr_page - 1 ) * $page_size; |
1225 | 1225 | } |
1226 | 1226 | |
@@ -1245,8 +1245,8 @@ discard block |
||
1245 | 1245 | */ |
1246 | 1246 | public static function updateViewSorting( $args, $form_id ) { |
1247 | 1247 | $sorting = array(); |
1248 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' ); |
|
1249 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' ); |
|
1248 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' ); |
|
1249 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' ); |
|
1250 | 1250 | |
1251 | 1251 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
1252 | 1252 | |
@@ -1286,11 +1286,11 @@ discard block |
||
1286 | 1286 | |
1287 | 1287 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
1288 | 1288 | |
1289 | - if( ! $sort_field ) { |
|
1289 | + if ( ! $sort_field ) { |
|
1290 | 1290 | return $sort_field_id; |
1291 | 1291 | } |
1292 | 1292 | |
1293 | - switch ( $sort_field['type'] ) { |
|
1293 | + switch ( $sort_field[ 'type' ] ) { |
|
1294 | 1294 | |
1295 | 1295 | case 'address': |
1296 | 1296 | // Sorting by full address |
@@ -1307,7 +1307,7 @@ discard block |
||
1307 | 1307 | */ |
1308 | 1308 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
1309 | 1309 | |
1310 | - switch( strtolower( $address_part ) ){ |
|
1310 | + switch ( strtolower( $address_part ) ) { |
|
1311 | 1311 | case 'street': |
1312 | 1312 | $sort_field_id .= '.1'; |
1313 | 1313 | break; |
@@ -1392,7 +1392,7 @@ discard block |
||
1392 | 1392 | */ |
1393 | 1393 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
1394 | 1394 | |
1395 | - if ( empty( $single_entry ) ){ |
|
1395 | + if ( empty( $single_entry ) ) { |
|
1396 | 1396 | return false; |
1397 | 1397 | } else { |
1398 | 1398 | return $single_entry; |
@@ -1419,7 +1419,7 @@ discard block |
||
1419 | 1419 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
1420 | 1420 | * @since 1.15 |
1421 | 1421 | */ |
1422 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1422 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1423 | 1423 | continue; |
1424 | 1424 | } |
1425 | 1425 | |
@@ -1428,19 +1428,19 @@ discard block |
||
1428 | 1428 | $css_dependencies = array(); |
1429 | 1429 | |
1430 | 1430 | // If the thickbox is enqueued, add dependencies |
1431 | - if ( ! empty( $data['atts']['lightbox'] ) ) { |
|
1431 | + if ( ! empty( $data[ 'atts' ][ 'lightbox' ] ) ) { |
|
1432 | 1432 | |
1433 | 1433 | /** |
1434 | 1434 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
1435 | 1435 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
1436 | 1436 | */ |
1437 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1437 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1438 | 1438 | |
1439 | 1439 | /** |
1440 | 1440 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
1441 | 1441 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
1442 | 1442 | */ |
1443 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1443 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1444 | 1444 | } |
1445 | 1445 | |
1446 | 1446 | /** |
@@ -1448,25 +1448,25 @@ discard block |
||
1448 | 1448 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
1449 | 1449 | * @since 1.15 |
1450 | 1450 | */ |
1451 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
1452 | - $css_dependencies[] = 'dashicons'; |
|
1451 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
1452 | + $css_dependencies[ ] = 'dashicons'; |
|
1453 | 1453 | } |
1454 | 1454 | |
1455 | 1455 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
1456 | 1456 | |
1457 | 1457 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
1458 | 1458 | |
1459 | - 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 ); |
|
1459 | + 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 ); |
|
1460 | 1460 | |
1461 | 1461 | wp_enqueue_script( 'gravityview-fe-view' ); |
1462 | 1462 | |
1463 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
1463 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
1464 | 1464 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | $this->enqueue_default_style( $css_dependencies ); |
1468 | 1468 | |
1469 | - self::add_style( $data['template_id'] ); |
|
1469 | + self::add_style( $data[ 'template_id' ] ); |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | if ( 'wp_print_footer_scripts' === current_filter() ) { |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | } elseif ( empty( $template_id ) ) { |
1529 | 1529 | do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' ); |
1530 | 1530 | } else { |
1531 | - do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) ); |
|
1531 | + do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) ); |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | } |
@@ -1553,11 +1553,11 @@ discard block |
||
1553 | 1553 | * Not a table-based template; don't add sort icons |
1554 | 1554 | * @since 1.12 |
1555 | 1555 | */ |
1556 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1556 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1557 | 1557 | return $label; |
1558 | 1558 | } |
1559 | 1559 | |
1560 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
1560 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
1561 | 1561 | return $label; |
1562 | 1562 | } |
1563 | 1563 | |
@@ -1565,29 +1565,29 @@ discard block |
||
1565 | 1565 | |
1566 | 1566 | $class = 'gv-sort'; |
1567 | 1567 | |
1568 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
1568 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
1569 | 1569 | |
1570 | 1570 | $sort_args = array( |
1571 | - 'sort' => $field['id'], |
|
1571 | + 'sort' => $field[ 'id' ], |
|
1572 | 1572 | 'dir' => 'asc', |
1573 | 1573 | ); |
1574 | 1574 | |
1575 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
1575 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
1576 | 1576 | //toggle sorting direction. |
1577 | - if ( 'asc' === $sorting['direction'] ) { |
|
1578 | - $sort_args['dir'] = 'desc'; |
|
1577 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
1578 | + $sort_args[ 'dir' ] = 'desc'; |
|
1579 | 1579 | $class .= ' gv-icon-sort-desc'; |
1580 | 1580 | } else { |
1581 | - $sort_args['dir'] = 'asc'; |
|
1581 | + $sort_args[ 'dir' ] = 'asc'; |
|
1582 | 1582 | $class .= ' gv-icon-sort-asc'; |
1583 | 1583 | } |
1584 | 1584 | } else { |
1585 | 1585 | $class .= ' gv-icon-caret-up-down'; |
1586 | 1586 | } |
1587 | 1587 | |
1588 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
1588 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
1589 | 1589 | |
1590 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
1590 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
1591 | 1591 | |
1592 | 1592 | } |
1593 | 1593 | |
@@ -1605,7 +1605,7 @@ discard block |
||
1605 | 1605 | |
1606 | 1606 | $field_type = $field_id; |
1607 | 1607 | |
1608 | - if( is_numeric( $field_id ) ) { |
|
1608 | + if ( is_numeric( $field_id ) ) { |
|
1609 | 1609 | $field = GFFormsModel::get_field( $form, $field_id ); |
1610 | 1610 | $field_type = $field->type; |
1611 | 1611 | } |
@@ -1628,7 +1628,7 @@ discard block |
||
1628 | 1628 | return false; |
1629 | 1629 | } |
1630 | 1630 | |
1631 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1631 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1632 | 1632 | |
1633 | 1633 | } |
1634 | 1634 |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | continue; |
72 | 72 | } |
73 | 73 | |
74 | - if ( is_numeric( $shortcode->atts['id'] ) ) { |
|
75 | - $views->append( View::by_id( $shortcode->atts['id'] ) ); |
|
74 | + if ( is_numeric( $shortcode->atts[ 'id' ] ) ) { |
|
75 | + $views->append( View::by_id( $shortcode->atts[ 'id' ] ) ); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | continue; |
103 | 103 | } |
104 | 104 | |
105 | - if ( is_numeric( $shortcode->atts['id'] ) ) { |
|
106 | - $views->append( View::by_id( $shortcode->atts['id'] ) ); |
|
105 | + if ( is_numeric( $shortcode->atts[ 'id' ] ) ) { |
|
106 | + $views->append( View::by_id( $shortcode->atts[ 'id' ] ) ); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | } |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | * @return string The version of PHP. |
212 | 212 | */ |
213 | 213 | private function get_php_version() { |
214 | - return !empty( $GLOBALS['GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] ) ? |
|
215 | - $GLOBALS['GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] : phpversion(); |
|
214 | + return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE' ] ) ? |
|
215 | + $GLOBALS[ 'GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE' ] : phpversion(); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @return string The version of WordPress. |
224 | 224 | */ |
225 | 225 | private function get_wordpress_version() { |
226 | - return !empty( $GLOBALS['GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE'] ) ? |
|
227 | - $GLOBALS['GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE'] : $GLOBALS['wp_version']; |
|
226 | + return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE' ] ) ? |
|
227 | + $GLOBALS[ 'GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE' ] : $GLOBALS[ 'wp_version' ]; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -236,11 +236,11 @@ discard block |
||
236 | 236 | * @return string The version of Gravity Forms. |
237 | 237 | */ |
238 | 238 | private function get_gravityforms_version() { |
239 | - if ( !class_exists( '\GFCommon' ) || !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE'] ) ) |
|
239 | + if ( ! class_exists( '\GFCommon' ) || ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE' ] ) ) |
|
240 | 240 | throw new \ErrorException( 'Gravity Forms is inactive or not installed.' ); |
241 | 241 | |
242 | - return !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] ) ? |
|
243 | - $GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] : \GFCommon::$version; |
|
242 | + return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE' ] ) ? |
|
243 | + $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE' ] : \GFCommon::$version; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | private function __clone() { } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | * @return void |
25 | 25 | */ |
26 | 26 | public function append( $value ) { |
27 | - $this->storage []= $value; |
|
27 | + $this->storage [ ] = $value; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | public static function add() { |
57 | 57 | $shortcode = new static(); |
58 | 58 | if ( shortcode_exists( $shortcode->name ) ) { |
59 | - if ( empty( self::$shortcodes[$shortcode->name] ) ) { |
|
59 | + if ( empty( self::$shortcodes[ $shortcode->name ] ) ) { |
|
60 | 60 | throw new \ErrorException( sprintf( 'Shortcode [%s] has already been registered elsewhere.', $shortcode->name ) ); |
61 | 61 | } |
62 | 62 | } else { |
63 | 63 | add_shortcode( $shortcode->name, array( get_class( $shortcode ), 'callback' ) ); |
64 | - self::$shortcodes[$shortcode->name] = $shortcode; |
|
64 | + self::$shortcodes[ $shortcode->name ] = $shortcode; |
|
65 | 65 | } |
66 | 66 | |
67 | - return self::$shortcodes[$shortcode->name]; |
|
67 | + return self::$shortcodes[ $shortcode->name ]; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public static function remove() { |
78 | 78 | $shortcode = new static(); |
79 | - unset( self::$shortcodes[$shortcode->name] ); |
|
79 | + unset( self::$shortcodes[ $shortcode->name ] ); |
|
80 | 80 | remove_shortcode( $shortcode->name ); |
81 | 81 | } |
82 | 82 | |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER ); |
109 | 109 | |
110 | 110 | foreach ( $matches as $shortcode ) { |
111 | - $shortcode_name = $shortcode[2]; |
|
111 | + $shortcode_name = $shortcode[ 2 ]; |
|
112 | 112 | |
113 | - $shortcode_atts = shortcode_parse_atts( $shortcode[3] ); |
|
114 | - $shortcode_content = $shortcode[5]; |
|
113 | + $shortcode_atts = shortcode_parse_atts( $shortcode[ 3 ] ); |
|
114 | + $shortcode_content = $shortcode[ 5 ]; |
|
115 | 115 | |
116 | 116 | /** This is a registered GravityView shortcode. */ |
117 | - if ( !empty( self::$shortcodes[$shortcode_name] ) ) { |
|
118 | - $shortcode = clone( self::$shortcodes[$shortcode_name] ); |
|
117 | + if ( ! empty( self::$shortcodes[ $shortcode_name ] ) ) { |
|
118 | + $shortcode = clone( self::$shortcodes[ $shortcode_name ] ); |
|
119 | 119 | } else { |
120 | 120 | /** This is some generic shortcode. */ |
121 | 121 | $shortcode = new self; |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | */ |
18 | 18 | private function __construct( $passed_post = NULL ) { |
19 | 19 | |
20 | - if( !empty( $passed_post ) ) { |
|
20 | + if ( ! empty( $passed_post ) ) { |
|
21 | 21 | |
22 | 22 | $id_or_id_array = $this->maybe_get_view_id( $passed_post ); |
23 | 23 | |
24 | - if( !empty( $id_or_id_array ) ) { |
|
24 | + if ( ! empty( $id_or_id_array ) ) { |
|
25 | 25 | $this->add_view( $id_or_id_array ); |
26 | 26 | } |
27 | 27 | } |
@@ -58,40 +58,40 @@ discard block |
||
58 | 58 | public function maybe_get_view_id( $passed_post ) { |
59 | 59 | $ids = array(); |
60 | 60 | |
61 | - if( ! empty( $passed_post ) ) { |
|
61 | + if ( ! empty( $passed_post ) ) { |
|
62 | 62 | |
63 | - if( is_numeric( $passed_post ) ) { |
|
63 | + if ( is_numeric( $passed_post ) ) { |
|
64 | 64 | $passed_post = get_post( $passed_post ); |
65 | 65 | } |
66 | 66 | |
67 | 67 | // Convert WP_Posts into WP_Posts[] array |
68 | - if( $passed_post instanceof WP_Post ) { |
|
68 | + if ( $passed_post instanceof WP_Post ) { |
|
69 | 69 | $passed_post = array( $passed_post ); |
70 | 70 | } |
71 | 71 | |
72 | - if( is_array( $passed_post ) ) { |
|
72 | + if ( is_array( $passed_post ) ) { |
|
73 | 73 | |
74 | - foreach ( $passed_post as &$post) { |
|
74 | + foreach ( $passed_post as &$post ) { |
|
75 | 75 | if ( function_exists( 'gravityview' ) && $post instanceof WP_Post ) { |
76 | 76 | $views = \GV\View_Collection::from_post( $post ); |
77 | 77 | foreach ( $views->all() as $view ) { |
78 | - $ids []= $view->ID; |
|
78 | + $ids [ ] = $view->ID; |
|
79 | 79 | } |
80 | 80 | } else { |
81 | 81 | /** Deprecated, see \GV\View_Collection::from_post */ |
82 | - if( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
83 | - $ids[] = $post->ID; |
|
84 | - } else{ |
|
82 | + if ( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
83 | + $ids[ ] = $post->ID; |
|
84 | + } else { |
|
85 | 85 | // Parse the Post Content |
86 | 86 | $id = $this->parse_post_content( $post->post_content ); |
87 | - if( $id ) { |
|
88 | - $ids = array_merge( $ids, (array) $id ); |
|
87 | + if ( $id ) { |
|
88 | + $ids = array_merge( $ids, (array)$id ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Parse the Post Meta |
92 | 92 | $id = $this->parse_post_meta( $post->ID ); |
93 | - if( $id ) { |
|
94 | - $ids = array_merge( $ids, (array) $id ); |
|
93 | + if ( $id ) { |
|
94 | + $ids = array_merge( $ids, (array)$id ); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | } |
@@ -105,31 +105,31 @@ discard block |
||
105 | 105 | if ( function_exists( 'gravityview' ) ) { |
106 | 106 | $shortcodes = \GV\Shortcode::parse( $passed_post ); |
107 | 107 | foreach ( $shortcodes as $shortcode ) { |
108 | - if ( $shortcode->name == 'gravityview' && !empty( $shortcode->atts['id'] ) ) |
|
109 | - $ids []= $shortcode->atts['id']; |
|
108 | + if ( $shortcode->name == 'gravityview' && ! empty( $shortcode->atts[ 'id' ] ) ) |
|
109 | + $ids [ ] = $shortcode->atts[ 'id' ]; |
|
110 | 110 | } |
111 | 111 | } else { |
112 | 112 | /** Deprecated, use \GV\Shortcode::parse. */ |
113 | 113 | $id = $this->parse_post_content( $passed_post ); |
114 | - if( $id ) { |
|
115 | - $ids = array_merge( $ids, (array) $id ); |
|
114 | + if ( $id ) { |
|
115 | + $ids = array_merge( $ids, (array)$id ); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | 119 | } else { |
120 | 120 | $id = $this->get_id_from_atts( $passed_post ); |
121 | - $ids[] = intval( $id ); |
|
121 | + $ids[ ] = intval( $id ); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - if( empty($ids) ) { |
|
126 | + if ( empty( $ids ) ) { |
|
127 | 127 | return NULL; |
128 | 128 | } |
129 | 129 | |
130 | 130 | // If it's just one ID, return that. |
131 | 131 | // Otherwise, return array of IDs |
132 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
132 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public static function getInstance( $passed_post = NULL ) { |
139 | 139 | |
140 | - if( empty( self::$instance ) ) { |
|
140 | + if ( empty( self::$instance ) ) { |
|
141 | 141 | self::$instance = new GravityView_View_Data( $passed_post ); |
142 | 142 | } |
143 | 143 | |
@@ -150,19 +150,19 @@ discard block |
||
150 | 150 | |
151 | 151 | function get_view( $view_id, $atts = NULL ) { |
152 | 152 | |
153 | - if( ! is_numeric( $view_id) ) { |
|
154 | - do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) ); |
|
153 | + if ( ! is_numeric( $view_id ) ) { |
|
154 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id ) ); |
|
155 | 155 | return false; |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Backup: the view hasn't been fetched yet. Doing it now. |
159 | 159 | if ( ! isset( $this->views[ $view_id ] ) ) { |
160 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) ); |
|
160 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] View #%s not set yet.', $view_id ) ); |
|
161 | 161 | return $this->add_view( $view_id, $atts ); |
162 | 162 | } |
163 | 163 | |
164 | 164 | if ( empty( $this->views[ $view_id ] ) ) { |
165 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) ); |
|
165 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id ) ); |
|
166 | 166 | return false; |
167 | 167 | } |
168 | 168 | |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | function add_view( $view_id, $atts = NULL ) { |
194 | 194 | |
195 | 195 | // Handle array of IDs |
196 | - if( is_array( $view_id ) ) { |
|
197 | - foreach( $view_id as $id ) { |
|
196 | + if ( is_array( $view_id ) ) { |
|
197 | + foreach ( $view_id as $id ) { |
|
198 | 198 | |
199 | 199 | $this->add_view( $id, $atts ); |
200 | 200 | } |
@@ -203,21 +203,21 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | // The view has been set already; returning stored view. |
206 | - if ( !empty( $this->views[ $view_id ] ) ) { |
|
207 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) ); |
|
206 | + if ( ! empty( $this->views[ $view_id ] ) ) { |
|
207 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id ) ); |
|
208 | 208 | return $this->views[ $view_id ]; |
209 | 209 | } |
210 | 210 | |
211 | - if( ! $this->view_exists( $view_id ) ) { |
|
212 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) ); |
|
211 | + if ( ! $this->view_exists( $view_id ) ) { |
|
212 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id ) ); |
|
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | |
216 | 216 | $form_id = gravityview_get_form_id( $view_id ); |
217 | 217 | |
218 | - if( empty( $form_id ) ) { |
|
218 | + if ( empty( $form_id ) ) { |
|
219 | 219 | |
220 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) ); |
|
220 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id ) ); |
|
221 | 221 | |
222 | 222 | return false; |
223 | 223 | } |
@@ -225,21 +225,21 @@ discard block |
||
225 | 225 | // Get the settings for the View ID |
226 | 226 | $view_settings = gravityview_get_template_settings( $view_id ); |
227 | 227 | |
228 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings ); |
|
228 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id ), $view_settings ); |
|
229 | 229 | |
230 | 230 | // Merge the view settings with the defaults |
231 | 231 | $view_defaults = wp_parse_args( $view_settings, self::get_default_args() ); |
232 | 232 | |
233 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
233 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
234 | 234 | |
235 | - if( ! empty( $atts ) && is_array( $atts ) ) { |
|
235 | + if ( ! empty( $atts ) && is_array( $atts ) ) { |
|
236 | 236 | |
237 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
237 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
238 | 238 | |
239 | 239 | // Get the settings from the shortcode and merge them with defaults. |
240 | 240 | $atts = shortcode_atts( $view_defaults, $atts ); |
241 | 241 | |
242 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
242 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
243 | 243 | |
244 | 244 | } else { |
245 | 245 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | } |
250 | 250 | |
251 | - unset( $atts['id'], $view_defaults, $view_settings ); |
|
251 | + unset( $atts[ 'id' ], $view_defaults, $view_settings ); |
|
252 | 252 | |
253 | 253 | $data = array( |
254 | 254 | 'id' => $view_id, |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | 'form' => gravityview_get_form( $form_id ), |
262 | 262 | ); |
263 | 263 | |
264 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data ); |
|
264 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] View #%s being added.', $view_id ), $data ); |
|
265 | 265 | |
266 | 266 | $this->views[ $view_id ] = $data; |
267 | 267 | |
@@ -296,15 +296,15 @@ discard block |
||
296 | 296 | */ |
297 | 297 | private function filter_fields( $dir_fields ) { |
298 | 298 | |
299 | - if( empty( $dir_fields ) || !is_array( $dir_fields ) ) { |
|
299 | + if ( empty( $dir_fields ) || ! is_array( $dir_fields ) ) { |
|
300 | 300 | return $dir_fields; |
301 | 301 | } |
302 | 302 | |
303 | - foreach( $dir_fields as $area => $fields ) { |
|
303 | + foreach ( $dir_fields as $area => $fields ) { |
|
304 | 304 | |
305 | - foreach( (array)$fields as $uniqid => $properties ) { |
|
305 | + foreach ( (array)$fields as $uniqid => $properties ) { |
|
306 | 306 | |
307 | - if( $this->hide_field_check_conditions( $properties ) ) { |
|
307 | + if ( $this->hide_field_check_conditions( $properties ) ) { |
|
308 | 308 | unset( $dir_fields[ $area ][ $uniqid ] ); |
309 | 309 | } |
310 | 310 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | private function hide_field_check_conditions( $properties ) { |
327 | 327 | |
328 | 328 | // logged-in visibility |
329 | - if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) { |
|
329 | + if ( ! empty( $properties[ 'only_loggedin' ] ) && ! GVCommon::has_cap( $properties[ 'only_loggedin_cap' ] ) ) { |
|
330 | 330 | return true; |
331 | 331 | } |
332 | 332 | |
@@ -343,14 +343,14 @@ discard block |
||
343 | 343 | // Get the settings from the shortcode and merge them with defaults. |
344 | 344 | $atts = wp_parse_args( $atts, self::get_default_args() ); |
345 | 345 | |
346 | - $view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL; |
|
346 | + $view_id = ! empty( $atts[ 'view_id' ] ) ? (int)$atts[ 'view_id' ] : NULL; |
|
347 | 347 | |
348 | - if( empty( $view_id ) && !empty( $atts['id'] ) ) { |
|
349 | - $view_id = (int)$atts['id']; |
|
348 | + if ( empty( $view_id ) && ! empty( $atts[ 'id' ] ) ) { |
|
349 | + $view_id = (int)$atts[ 'id' ]; |
|
350 | 350 | } |
351 | 351 | |
352 | - if( empty( $view_id ) ) { |
|
353 | - do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
352 | + if ( empty( $view_id ) ) { |
|
353 | + do_action( 'gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
354 | 354 | return; |
355 | 355 | } |
356 | 356 | |
@@ -372,46 +372,46 @@ discard block |
||
372 | 372 | * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin |
373 | 373 | * @since 1.6 |
374 | 374 | */ |
375 | - if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) { |
|
375 | + if ( ! shortcode_exists( 'gravityview' ) && class_exists( 'GravityView_Shortcode' ) ) { |
|
376 | 376 | new GravityView_Shortcode; |
377 | 377 | } |
378 | 378 | |
379 | 379 | $shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' ); |
380 | 380 | |
381 | - if( empty( $shortcodes ) ) { |
|
381 | + if ( empty( $shortcodes ) ) { |
|
382 | 382 | return NULL; |
383 | 383 | } |
384 | 384 | |
385 | - do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
385 | + do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
386 | 386 | |
387 | 387 | $ids = array(); |
388 | 388 | |
389 | - foreach ($shortcodes as $key => $shortcode) { |
|
389 | + foreach ( $shortcodes as $key => $shortcode ) { |
|
390 | 390 | |
391 | - $shortcode[3] = htmlspecialchars_decode( $shortcode[3], ENT_QUOTES ); |
|
391 | + $shortcode[ 3 ] = htmlspecialchars_decode( $shortcode[ 3 ], ENT_QUOTES ); |
|
392 | 392 | |
393 | - $args = shortcode_parse_atts( $shortcode[3] ); |
|
393 | + $args = shortcode_parse_atts( $shortcode[ 3 ] ); |
|
394 | 394 | |
395 | - if( empty( $args['id'] ) ) { |
|
396 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); |
|
395 | + if ( empty( $args[ 'id' ] ) ) { |
|
396 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); |
|
397 | 397 | continue; |
398 | 398 | } |
399 | 399 | |
400 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args ); |
|
400 | + do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args[ 'id' ] ), $args ); |
|
401 | 401 | |
402 | 402 | // Store the View to the object for later fetching. |
403 | - $this->add_view( $args['id'], $args ); |
|
403 | + $this->add_view( $args[ 'id' ], $args ); |
|
404 | 404 | |
405 | - $ids[] = $args['id']; |
|
405 | + $ids[ ] = $args[ 'id' ]; |
|
406 | 406 | } |
407 | 407 | |
408 | - if( empty($ids) ) { |
|
408 | + if ( empty( $ids ) ) { |
|
409 | 409 | return NULL; |
410 | 410 | } |
411 | 411 | |
412 | 412 | // If it's just one ID, return that. |
413 | 413 | // Otherwise, return array of IDs |
414 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
414 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
415 | 415 | |
416 | 416 | } |
417 | 417 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | */ |
433 | 433 | $meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id ); |
434 | 434 | |
435 | - if( empty( $meta_keys ) ) { |
|
435 | + if ( empty( $meta_keys ) ) { |
|
436 | 436 | return NULL; |
437 | 437 | } |
438 | 438 | |
@@ -440,16 +440,16 @@ discard block |
||
440 | 440 | |
441 | 441 | $meta_content = ''; |
442 | 442 | |
443 | - foreach( $meta_keys as $key ) { |
|
444 | - $meta = get_post_meta( $post_id, $key , true ); |
|
445 | - if( ! is_string( $meta ) ) { |
|
443 | + foreach ( $meta_keys as $key ) { |
|
444 | + $meta = get_post_meta( $post_id, $key, true ); |
|
445 | + if ( ! is_string( $meta ) ) { |
|
446 | 446 | continue; |
447 | 447 | } |
448 | 448 | $meta_content .= $meta . ' '; |
449 | 449 | } |
450 | 450 | |
451 | - if( empty( $meta_content ) ) { |
|
452 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); |
|
451 | + if ( empty( $meta_content ) ) { |
|
452 | + do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); |
|
453 | 453 | return NULL; |
454 | 454 | } |
455 | 455 | |
@@ -476,16 +476,16 @@ discard block |
||
476 | 476 | $message = NULL; |
477 | 477 | |
478 | 478 | // Not invalid if not set! |
479 | - if( empty( $post_id ) || empty( $view_id ) ) { |
|
479 | + if ( empty( $post_id ) || empty( $view_id ) ) { |
|
480 | 480 | |
481 | - if( $empty_is_valid ) { |
|
481 | + if ( $empty_is_valid ) { |
|
482 | 482 | return true; |
483 | 483 | } |
484 | 484 | |
485 | 485 | $message = esc_html__( 'The ID is required.', 'gravityview' ); |
486 | 486 | } |
487 | 487 | |
488 | - if( ! $message ) { |
|
488 | + if ( ! $message ) { |
|
489 | 489 | $status = get_post_status( $post_id ); |
490 | 490 | |
491 | 491 | // Nothing exists with that post ID. |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
500 | - if( ! $message ) { |
|
500 | + if ( ! $message ) { |
|
501 | 501 | |
502 | 502 | // Nothing exists with that post ID. |
503 | 503 | if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) { |
@@ -506,8 +506,8 @@ discard block |
||
506 | 506 | |
507 | 507 | } |
508 | 508 | |
509 | - if( ! $message ) { |
|
510 | - if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) { |
|
509 | + if ( ! $message ) { |
|
510 | + if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) { |
|
511 | 511 | $views = GV\View_Collection::from_post( $post ); |
512 | 512 | $view_ids_in_post = array_map( function( $view ) { return $view->ID; }, $views->all() ); |
513 | 513 | } else { |
@@ -516,21 +516,21 @@ discard block |
||
516 | 516 | } |
517 | 517 | |
518 | 518 | // The post or page specified does not contain the shortcode. |
519 | - if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { |
|
519 | + if ( false === in_array( $view_id, (array)$view_ids_in_post ) ) { |
|
520 | 520 | $message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' ); |
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | - if( ! $message ) { |
|
524 | + if ( ! $message ) { |
|
525 | 525 | |
526 | 526 | // It's a View |
527 | - if( 'gravityview' === get_post_type( $post_id ) ) { |
|
528 | - $message = esc_html__( 'The ID is already a View.', 'gravityview' );; |
|
527 | + if ( 'gravityview' === get_post_type( $post_id ) ) { |
|
528 | + $message = esc_html__( 'The ID is already a View.', 'gravityview' ); ; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | } |
532 | 532 | |
533 | - if( $message ) { |
|
533 | + if ( $message ) { |
|
534 | 534 | return new WP_Error( 'invalid_embed_id', $message ); |
535 | 535 | } |
536 | 536 | |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | |
548 | 548 | $args = self::get_default_args( $with_details ); |
549 | 549 | |
550 | - if( !isset( $args[ $key ] ) ) { return NULL; } |
|
550 | + if ( ! isset( $args[ $key ] ) ) { return NULL; } |
|
551 | 551 | |
552 | 552 | return $args[ $key ]; |
553 | 553 | } |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | */ |
577 | 577 | $default_settings = apply_filters( 'gravityview_default_args', array( |
578 | 578 | 'id' => array( |
579 | - 'label' => __('View ID', 'gravityview'), |
|
579 | + 'label' => __( 'View ID', 'gravityview' ), |
|
580 | 580 | 'type' => 'number', |
581 | 581 | 'group' => 'default', |
582 | 582 | 'value' => NULL, |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | 'show_in_shortcode' => false, |
585 | 585 | ), |
586 | 586 | 'page_size' => array( |
587 | - 'label' => __('Number of entries per page', 'gravityview'), |
|
587 | + 'label' => __( 'Number of entries per page', 'gravityview' ), |
|
588 | 588 | 'type' => 'number', |
589 | 589 | 'class' => 'small-text', |
590 | 590 | 'group' => 'default', |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | ), |
609 | 609 | 'admin_show_all_statuses' => array( |
610 | 610 | 'label' => __( 'Show all entries to administrators', 'gravityview' ), |
611 | - 'desc' => __('Administrators will be able to see entries with any approval status.', 'gravityview'), |
|
612 | - 'tooltip' => __('Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview'), |
|
611 | + 'desc' => __( 'Administrators will be able to see entries with any approval status.', 'gravityview' ), |
|
612 | + 'tooltip' => __( 'Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview' ), |
|
613 | 613 | 'requires' => 'show_only_approved', |
614 | 614 | 'type' => 'checkbox', |
615 | 615 | 'group' => 'default', |
@@ -634,40 +634,40 @@ discard block |
||
634 | 634 | 'user_edit' => array( |
635 | 635 | 'label' => __( 'Allow User Edit', 'gravityview' ), |
636 | 636 | 'group' => 'default', |
637 | - 'desc' => __('Allow logged-in users to edit entries they created.', 'gravityview'), |
|
637 | + 'desc' => __( 'Allow logged-in users to edit entries they created.', 'gravityview' ), |
|
638 | 638 | 'value' => 0, |
639 | - 'tooltip' => __('Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview'), |
|
639 | + 'tooltip' => __( 'Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview' ), |
|
640 | 640 | 'type' => 'checkbox', |
641 | 641 | 'show_in_shortcode' => true, |
642 | 642 | ), |
643 | 643 | 'user_delete' => array( |
644 | 644 | 'label' => __( 'Allow User Delete', 'gravityview' ), |
645 | 645 | 'group' => 'default', |
646 | - 'desc' => __('Allow logged-in users to delete entries they created.', 'gravityview'), |
|
646 | + 'desc' => __( 'Allow logged-in users to delete entries they created.', 'gravityview' ), |
|
647 | 647 | 'value' => 0, |
648 | - 'tooltip' => __('Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview'), |
|
648 | + 'tooltip' => __( 'Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview' ), |
|
649 | 649 | 'type' => 'checkbox', |
650 | 650 | 'show_in_shortcode' => true, |
651 | 651 | ), |
652 | 652 | 'sort_field' => array( |
653 | - 'label' => __('Sort by field', 'gravityview'), |
|
653 | + 'label' => __( 'Sort by field', 'gravityview' ), |
|
654 | 654 | 'type' => 'select', |
655 | 655 | 'value' => '', |
656 | 656 | 'group' => 'sort', |
657 | 657 | 'options' => array( |
658 | - '' => __( 'Default', 'gravityview'), |
|
659 | - 'date_created' => __( 'Date Created', 'gravityview'), |
|
658 | + '' => __( 'Default', 'gravityview' ), |
|
659 | + 'date_created' => __( 'Date Created', 'gravityview' ), |
|
660 | 660 | ), |
661 | 661 | 'show_in_shortcode' => true, |
662 | 662 | ), |
663 | 663 | 'sort_direction' => array( |
664 | - 'label' => __('Sort direction', 'gravityview'), |
|
664 | + 'label' => __( 'Sort direction', 'gravityview' ), |
|
665 | 665 | 'type' => 'select', |
666 | 666 | 'value' => 'ASC', |
667 | 667 | 'group' => 'sort', |
668 | 668 | 'options' => array( |
669 | - 'ASC' => __('ASC', 'gravityview'), |
|
670 | - 'DESC' => __('DESC', 'gravityview'), |
|
669 | + 'ASC' => __( 'ASC', 'gravityview' ), |
|
670 | + 'DESC' => __( 'DESC', 'gravityview' ), |
|
671 | 671 | //'RAND' => __('Random', 'gravityview'), |
672 | 672 | ), |
673 | 673 | 'show_in_shortcode' => true, |
@@ -683,69 +683,69 @@ discard block |
||
683 | 683 | 'show_in_template' => array( 'default_table' ), |
684 | 684 | ), |
685 | 685 | 'start_date' => array( |
686 | - 'label' => __('Filter by Start Date', 'gravityview'), |
|
686 | + 'label' => __( 'Filter by Start Date', 'gravityview' ), |
|
687 | 687 | 'class' => 'gv-datepicker', |
688 | - 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
688 | + 'desc' => __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
689 | 689 | 'type' => 'text', |
690 | 690 | 'value' => '', |
691 | 691 | 'group' => 'filter', |
692 | 692 | 'show_in_shortcode' => true, |
693 | 693 | ), |
694 | 694 | 'end_date' => array( |
695 | - 'label' => __('Filter by End Date', 'gravityview'), |
|
695 | + 'label' => __( 'Filter by End Date', 'gravityview' ), |
|
696 | 696 | 'class' => 'gv-datepicker', |
697 | - 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
697 | + 'desc' => __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
698 | 698 | 'type' => 'text', |
699 | 699 | 'value' => '', |
700 | 700 | 'group' => 'filter', |
701 | 701 | 'show_in_shortcode' => true, |
702 | 702 | ), |
703 | 703 | 'class' => array( |
704 | - 'label' => __('CSS Class', 'gravityview'), |
|
705 | - 'desc' => __('CSS class to add to the wrapping HTML container.', 'gravityview'), |
|
704 | + 'label' => __( 'CSS Class', 'gravityview' ), |
|
705 | + 'desc' => __( 'CSS class to add to the wrapping HTML container.', 'gravityview' ), |
|
706 | 706 | 'group' => 'default', |
707 | 707 | 'type' => 'text', |
708 | 708 | 'value' => '', |
709 | 709 | 'show_in_shortcode' => false, |
710 | 710 | ), |
711 | 711 | 'search_value' => array( |
712 | - 'label' => __('Search Value', 'gravityview'), |
|
713 | - 'desc' => __('Define a default search value for the View', 'gravityview'), |
|
712 | + 'label' => __( 'Search Value', 'gravityview' ), |
|
713 | + 'desc' => __( 'Define a default search value for the View', 'gravityview' ), |
|
714 | 714 | 'type' => 'text', |
715 | 715 | 'value' => '', |
716 | 716 | 'group' => 'filter', |
717 | 717 | 'show_in_shortcode' => false, |
718 | 718 | ), |
719 | 719 | 'search_field' => array( |
720 | - 'label' => __('Search Field', 'gravityview'), |
|
721 | - 'desc' => __('If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview'), |
|
720 | + 'label' => __( 'Search Field', 'gravityview' ), |
|
721 | + 'desc' => __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview' ), |
|
722 | 722 | 'type' => 'number', |
723 | 723 | 'value' => '', |
724 | 724 | 'group' => 'filter', |
725 | 725 | 'show_in_shortcode' => false, |
726 | 726 | ), |
727 | 727 | 'single_title' => array( |
728 | - 'label' => __('Single Entry Title', 'gravityview'), |
|
728 | + 'label' => __( 'Single Entry Title', 'gravityview' ), |
|
729 | 729 | 'type' => 'text', |
730 | - 'desc' => __('When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview'), |
|
730 | + 'desc' => __( 'When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview' ), |
|
731 | 731 | 'group' => 'default', |
732 | 732 | 'value' => '', |
733 | 733 | 'show_in_shortcode' => false, |
734 | 734 | 'full_width' => true, |
735 | 735 | ), |
736 | 736 | 'back_link_label' => array( |
737 | - 'label' => __('Back Link Label', 'gravityview'), |
|
737 | + 'label' => __( 'Back Link Label', 'gravityview' ), |
|
738 | 738 | 'group' => 'default', |
739 | - 'desc' => __('The text of the link that returns to the multiple entries view.', 'gravityview'), |
|
739 | + 'desc' => __( 'The text of the link that returns to the multiple entries view.', 'gravityview' ), |
|
740 | 740 | 'type' => 'text', |
741 | 741 | 'value' => '', |
742 | 742 | 'show_in_shortcode' => false, |
743 | 743 | 'full_width' => true, |
744 | 744 | ), |
745 | 745 | 'embed_only' => array( |
746 | - 'label' => __('Prevent Direct Access', 'gravityview'), |
|
746 | + 'label' => __( 'Prevent Direct Access', 'gravityview' ), |
|
747 | 747 | 'group' => 'default', |
748 | - 'desc' => __('Only allow access to this View when embedded using the shortcode.', 'gravityview'), |
|
748 | + 'desc' => __( 'Only allow access to this View when embedded using the shortcode.', 'gravityview' ), |
|
749 | 749 | 'type' => 'checkbox', |
750 | 750 | 'value' => '', |
751 | 751 | 'show_in_shortcode' => false, |
@@ -756,15 +756,15 @@ discard block |
||
756 | 756 | 'value' => '', |
757 | 757 | 'show_in_shortcode' => false, |
758 | 758 | ), |
759 | - )); |
|
759 | + ) ); |
|
760 | 760 | |
761 | 761 | // By default, we only want the key => value pairing, not the whole array. |
762 | - if( empty( $with_details ) ) { |
|
762 | + if ( empty( $with_details ) ) { |
|
763 | 763 | |
764 | 764 | $defaults = array(); |
765 | 765 | |
766 | - foreach( $default_settings as $key => $value ) { |
|
767 | - $defaults[ $key ] = $value['value']; |
|
766 | + foreach ( $default_settings as $key => $value ) { |
|
767 | + $defaults[ $key ] = $value[ 'value' ]; |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | return $defaults; |
@@ -773,12 +773,12 @@ discard block |
||
773 | 773 | // But sometimes, we want all the details. |
774 | 774 | else { |
775 | 775 | |
776 | - foreach ($default_settings as $key => $value) { |
|
776 | + foreach ( $default_settings as $key => $value ) { |
|
777 | 777 | |
778 | 778 | // If the $group argument is set for the method, |
779 | 779 | // ignore any settings that aren't in that group. |
780 | - if( !empty( $group ) && is_string( $group ) ) { |
|
781 | - if( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
780 | + if ( ! empty( $group ) && is_string( $group ) ) { |
|
781 | + if ( empty( $value[ 'group' ] ) || $value[ 'group' ] !== $group ) { |
|
782 | 782 | unset( $default_settings[ $key ] ); |
783 | 783 | } |
784 | 784 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | static function getInstance() { |
44 | 44 | |
45 | - if( empty( self::$instance ) ) { |
|
45 | + if ( empty( self::$instance ) ) { |
|
46 | 46 | self::$instance = new self; |
47 | 47 | |
48 | 48 | self::$instance->initialize(); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // Catch either |
100 | 100 | $match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})"; |
101 | 101 | |
102 | - return '#'.$match_regex.'#i'; |
|
102 | + return '#' . $match_regex . '#i'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -118,18 +118,18 @@ discard block |
||
118 | 118 | |
119 | 119 | $post_id = url_to_postid( $url ); |
120 | 120 | |
121 | - if( empty( $post_id ) ) { |
|
121 | + if ( empty( $post_id ) ) { |
|
122 | 122 | |
123 | 123 | $args = array( |
124 | 124 | 'post_status' => 'publish', |
125 | 125 | 'name' => $slug, |
126 | - 'post_type' => array('any', 'gravityview'), |
|
126 | + 'post_type' => array( 'any', 'gravityview' ), |
|
127 | 127 | ); |
128 | 128 | |
129 | 129 | $posts = get_posts( $args ); |
130 | 130 | |
131 | - if( !empty( $posts ) ) { |
|
132 | - $post_id = $posts[0]->ID; |
|
131 | + if ( ! empty( $posts ) ) { |
|
132 | + $post_id = $posts[ 0 ]->ID; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -162,17 +162,17 @@ discard block |
||
162 | 162 | public function render_handler( $matches, $attr, $url, $rawattr ) { |
163 | 163 | |
164 | 164 | // If not using permalinks, re-assign values for matching groups |
165 | - if( !empty( $matches['entry_slug2'] ) ) { |
|
166 | - $matches['is_cpt'] = $matches['is_cpt2']; |
|
167 | - $matches['slug'] = $matches['slug2']; |
|
168 | - $matches['entry_slug'] = $matches['entry_slug2']; |
|
169 | - unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
165 | + if ( ! empty( $matches[ 'entry_slug2' ] ) ) { |
|
166 | + $matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ]; |
|
167 | + $matches[ 'slug' ] = $matches[ 'slug2' ]; |
|
168 | + $matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ]; |
|
169 | + unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // No Entry was found |
173 | - if( empty( $matches['entry_slug'] ) ) { |
|
173 | + if ( empty( $matches[ 'entry_slug' ] ) ) { |
|
174 | 174 | |
175 | - do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
175 | + do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
176 | 176 | |
177 | 177 | return ''; |
178 | 178 | } |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | // Setup the data used |
183 | 183 | $this->set_vars( $matches, $attr, $url, $rawattr ); |
184 | 184 | |
185 | - if( is_admin() && !$this->is_full_oembed_preview ) { |
|
185 | + if ( is_admin() && ! $this->is_full_oembed_preview ) { |
|
186 | 186 | $return = $this->render_admin( $matches, $attr, $url, $rawattr ); |
187 | 187 | } else { |
188 | 188 | |
189 | - if( $this->is_full_oembed_preview ) { |
|
189 | + if ( $this->is_full_oembed_preview ) { |
|
190 | 190 | $return .= $this->generate_preview_notice(); |
191 | 191 | } |
192 | 192 | |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | private function generate_preview_notice() { |
206 | 206 | $floaty = GravityView_Admin::get_floaty(); |
207 | 207 | $title = esc_html__( 'This will look better when it is embedded.', 'gravityview' ); |
208 | - $message = esc_html__('Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview'); |
|
209 | - return '<div class="updated notice">'. $floaty. '<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>'; |
|
208 | + $message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' ); |
|
209 | + return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>'; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -219,20 +219,20 @@ discard block |
||
219 | 219 | */ |
220 | 220 | private function set_vars( $matches, $attr, $url, $rawattr ) { |
221 | 221 | |
222 | - $this->entry_id = $matches['entry_slug']; |
|
222 | + $this->entry_id = $matches[ 'entry_slug' ]; |
|
223 | 223 | |
224 | - $post_id = $this->get_postid_from_url_and_slug( $url, $matches['slug'] ); |
|
224 | + $post_id = $this->get_postid_from_url_and_slug( $url, $matches[ 'slug' ] ); |
|
225 | 225 | |
226 | 226 | // The URL didn't have the View Custom Post Type structure. |
227 | - if( empty( $matches['is_cpt'] ) || $matches['is_cpt'] !== 'gravityview' ) { |
|
227 | + if ( empty( $matches[ 'is_cpt' ] ) || $matches[ 'is_cpt' ] !== 'gravityview' ) { |
|
228 | 228 | |
229 | - do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
229 | + do_action( 'gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
230 | 230 | |
231 | 231 | if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) { |
232 | 232 | $views = \GV\View_Collection::from_post( $post ); |
233 | 233 | $views = $views->all(); |
234 | 234 | if ( ! empty( $views ) ) |
235 | - $this->view_id = $views[0]->ID; |
|
235 | + $this->view_id = $views[ 0 ]->ID; |
|
236 | 236 | } else { |
237 | 237 | /** Deprecated. */ |
238 | 238 | $this->view_id = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | // The inline content has $_POST['type'] set to "embed", while the "Add Media" modal doesn't set that. |
248 | - $this->is_full_oembed_preview = ( isset( $_POST['action'] ) && $_POST['action'] === 'parse-embed' && !isset( $_POST['type'] ) ); |
|
248 | + $this->is_full_oembed_preview = ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] === 'parse-embed' && ! isset( $_POST[ 'type' ] ) ); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -263,15 +263,15 @@ discard block |
||
263 | 263 | // Floaty the astronaut |
264 | 264 | $image = GravityView_Admin::get_floaty(); |
265 | 265 | |
266 | - $embed_heading = sprintf( esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id ); |
|
266 | + $embed_heading = sprintf( esc_html__( 'Embed Entry %d', 'gravityview' ), $this->entry_id ); |
|
267 | 267 | |
268 | - $embed_text = sprintf( esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id ); |
|
268 | + $embed_text = sprintf( esc_html__( 'This entry will be displayed as it is configured in View %d', 'gravityview' ), $this->view_id ); |
|
269 | 269 | |
270 | 270 | return ' |
271 | 271 | <div class="loading-placeholder" style="background-color:#e6f0f5;"> |
272 | - <h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image.$embed_heading.'</h3> |
|
272 | + <h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image . $embed_heading . '</h3> |
|
273 | 273 | <p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;"> |
274 | - '.$embed_text.' |
|
274 | + '.$embed_text . ' |
|
275 | 275 | </p> |
276 | 276 | <br style="clear: both;"> |
277 | 277 | </div>'; |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | private function render_frontend( $matches, $attr, $url, $rawattr ) { |
327 | 327 | |
328 | 328 | // If it's already been parsed, don't re-output it. |
329 | - if( !empty( $this->output[ $this->entry_id ] ) ) { |
|
329 | + if ( ! empty( $this->output[ $this->entry_id ] ) ) { |
|
330 | 330 | return $this->output[ $this->entry_id ]; |
331 | 331 | } |
332 | 332 | |
333 | 333 | $entry_output = $this->generate_entry_output(); |
334 | 334 | |
335 | 335 | // Wrap a container div around the output to allow for custom styling |
336 | - $output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output ); |
|
336 | + $output = sprintf( '<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-' . $this->entry_id . '">%s</div>', $entry_output ); |
|
337 | 337 | |
338 | 338 | /** |
339 | 339 | * @filter `gravityview/oembed/entry` Filter the output of the oEmbed entry embed |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @var string $url The original URL that was matched by the regex. \n |
347 | 347 | * @var array $rawattr The original unmodified attributes. |
348 | 348 | */ |
349 | - $output = apply_filters('gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
349 | + $output = apply_filters( 'gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
350 | 350 | |
351 | 351 | unset( $entry_output ); |
352 | 352 |