@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -defined( 'ABSPATH' ) || exit; |
|
14 | +defined('ABSPATH') || exit; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * GravityView Roles Class |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public static function get_instance() { |
35 | 35 | |
36 | - if( ! self::$instance ) { |
|
36 | + if (!self::$instance) { |
|
37 | 37 | self::$instance = new self; |
38 | 38 | } |
39 | 39 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @since 1.15 |
54 | 54 | */ |
55 | 55 | private function add_hooks() { |
56 | - add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) ); |
|
57 | - add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 ); |
|
58 | - add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 ); |
|
59 | - add_action( 'admin_init', array( $this, 'add_caps') ); |
|
56 | + add_filter('members_get_capabilities', array('GravityView_Roles_Capabilities', 'merge_with_all_caps')); |
|
57 | + add_action('members_register_cap_groups', array($this, 'members_register_cap_group'), 20); |
|
58 | + add_filter('user_has_cap', array($this, 'filter_user_has_cap'), 10, 4); |
|
59 | + add_action('admin_init', array($this, 'add_caps')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -74,28 +74,28 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return mixed |
76 | 76 | */ |
77 | - public function filter_user_has_cap( $usercaps = array(), $caps = array(), $args = array(), $user = NULL ) { |
|
77 | + public function filter_user_has_cap($usercaps = array(), $caps = array(), $args = array(), $user = NULL) { |
|
78 | 78 | |
79 | 79 | // Empty caps_to_check array |
80 | - if( ! $usercaps || ! $caps ) { |
|
80 | + if (!$usercaps || !$caps) { |
|
81 | 81 | return $usercaps; |
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Enable all GravityView caps_to_check if `gravityview_full_access` is enabled |
86 | 86 | */ |
87 | - if( ! empty( $usercaps['gravityview_full_access'] ) ) { |
|
87 | + if (!empty($usercaps['gravityview_full_access'])) { |
|
88 | 88 | |
89 | 89 | $all_gravityview_caps = self::all_caps(); |
90 | 90 | |
91 | - foreach( $all_gravityview_caps as $gv_cap ) { |
|
92 | - $usercaps[ $gv_cap ] = true; |
|
91 | + foreach ($all_gravityview_caps as $gv_cap) { |
|
92 | + $usercaps[$gv_cap] = true; |
|
93 | 93 | } |
94 | 94 | |
95 | - unset( $all_gravityview_caps ); |
|
95 | + unset($all_gravityview_caps); |
|
96 | 96 | } |
97 | 97 | |
98 | - $usercaps = $this->add_gravity_forms_usercaps_to_gravityview_caps( $usercaps ); |
|
98 | + $usercaps = $this->add_gravity_forms_usercaps_to_gravityview_caps($usercaps); |
|
99 | 99 | |
100 | 100 | return $usercaps; |
101 | 101 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - private function add_gravity_forms_usercaps_to_gravityview_caps( $usercaps ) { |
|
117 | + private function add_gravity_forms_usercaps_to_gravityview_caps($usercaps) { |
|
118 | 118 | |
119 | 119 | $gf_to_gv_caps = array( |
120 | 120 | 'gravityforms_edit_entries' => 'gravityview_edit_others_entries', |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | 'gravityforms_edit_entry_notes' => 'gravityview_edit_others_entry_notes', |
123 | 123 | ); |
124 | 124 | |
125 | - foreach ( $gf_to_gv_caps as $gf_cap => $gv_cap ) { |
|
126 | - if ( isset( $usercaps[ $gf_cap ] ) && ! isset( $usercaps[ $gv_cap ] ) ) { |
|
127 | - $usercaps[ $gv_cap ] = $usercaps[ $gf_cap ]; |
|
125 | + foreach ($gf_to_gv_caps as $gf_cap => $gv_cap) { |
|
126 | + if (isset($usercaps[$gf_cap]) && !isset($usercaps[$gv_cap])) { |
|
127 | + $usercaps[$gv_cap] = $usercaps[$gf_cap]; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | * @return void |
139 | 139 | */ |
140 | 140 | function members_register_cap_group() { |
141 | - if ( function_exists( 'members_register_cap_group' ) ) { |
|
141 | + if (function_exists('members_register_cap_group')) { |
|
142 | 142 | |
143 | 143 | $args = array( |
144 | - 'label' => __( 'GravityView', 'gravityview' ), |
|
144 | + 'label' => __('GravityView', 'gravityview'), |
|
145 | 145 | 'icon' => 'gv-icon-astronaut-head', |
146 | 146 | 'caps' => self::all_caps(), |
147 | 147 | 'merge_added' => true, |
148 | 148 | 'diff_added' => false, |
149 | 149 | ); |
150 | 150 | |
151 | - members_register_cap_group( 'gravityview', $args ); |
|
151 | + members_register_cap_group('gravityview', $args); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | * @param array $caps Existing capabilities |
160 | 160 | * @return array Modified capabilities array |
161 | 161 | */ |
162 | - public static function merge_with_all_caps( $caps ) { |
|
162 | + public static function merge_with_all_caps($caps) { |
|
163 | 163 | |
164 | - $return_caps = array_merge( $caps, self::all_caps() ); |
|
164 | + $return_caps = array_merge($caps, self::all_caps()); |
|
165 | 165 | |
166 | - return array_unique( $return_caps ); |
|
166 | + return array_unique($return_caps); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | private function wp_roles() { |
179 | 179 | global $wp_roles; |
180 | 180 | |
181 | - if ( ! isset( $wp_roles ) ) { |
|
181 | + if (!isset($wp_roles)) { |
|
182 | 182 | $wp_roles = new WP_Roles(); |
183 | 183 | } |
184 | 184 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $wp_roles = $this->wp_roles(); |
198 | 198 | |
199 | - if ( is_object( $wp_roles ) ) { |
|
199 | + if (is_object($wp_roles)) { |
|
200 | 200 | |
201 | 201 | $_use_db_backup = $wp_roles->use_db; |
202 | 202 | |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | */ |
207 | 207 | $wp_roles->use_db = false; |
208 | 208 | |
209 | - $capabilities = self::all_caps( false, false ); |
|
209 | + $capabilities = self::all_caps(false, false); |
|
210 | 210 | |
211 | - foreach ( $capabilities as $role_slug => $role_caps ) { |
|
212 | - foreach ( $role_caps as $cap ) { |
|
213 | - $wp_roles->add_cap( $role_slug, $cap ); |
|
211 | + foreach ($capabilities as $role_slug => $role_caps) { |
|
212 | + foreach ($role_caps as $cap) { |
|
213 | + $wp_roles->add_cap($role_slug, $cap); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @see WP_Roles::add_cap() Original code |
221 | 221 | */ |
222 | - update_option( $wp_roles->role_key, $wp_roles->roles ); |
|
222 | + update_option($wp_roles->role_key, $wp_roles->roles); |
|
223 | 223 | |
224 | 224 | /** |
225 | 225 | * Restore previous $use_db setting |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return array If $role is set, flat array of caps_to_check. Otherwise, a multi-dimensional array of roles and their caps_to_check with the following keys: 'administrator', 'editor', 'author', 'contributor', 'subscriber' |
242 | 242 | */ |
243 | - public static function all_caps( $single_role = false, $flat_array = true ) { |
|
243 | + public static function all_caps($single_role = false, $flat_array = true) { |
|
244 | 244 | |
245 | 245 | // Change settings |
246 | 246 | $administrator_caps = array( |
@@ -297,20 +297,20 @@ discard block |
||
297 | 297 | ); |
298 | 298 | |
299 | 299 | $subscriber = $subscriber_caps; |
300 | - $contributor = array_merge( $contributor_caps, $subscriber_caps ); |
|
301 | - $author = array_merge( $author_caps, $contributor_caps, $subscriber_caps ); |
|
302 | - $editor = array_merge( $editor_caps, $author_caps, $contributor_caps, $subscriber_caps ); |
|
303 | - $administrator = array_merge( $administrator_caps, $editor_caps, $author_caps, $contributor_caps, $subscriber_caps ); |
|
300 | + $contributor = array_merge($contributor_caps, $subscriber_caps); |
|
301 | + $author = array_merge($author_caps, $contributor_caps, $subscriber_caps); |
|
302 | + $editor = array_merge($editor_caps, $author_caps, $contributor_caps, $subscriber_caps); |
|
303 | + $administrator = array_merge($administrator_caps, $editor_caps, $author_caps, $contributor_caps, $subscriber_caps); |
|
304 | 304 | $all = $administrator; |
305 | 305 | |
306 | 306 | // If role is set, return caps_to_check for just that role. |
307 | - if( $single_role ) { |
|
308 | - $caps = isset( ${$single_role} ) ? ${$single_role} : false; |
|
309 | - return $flat_array ? $caps : array( $single_role => $caps ); |
|
307 | + if ($single_role) { |
|
308 | + $caps = isset(${$single_role} ) ? ${$single_role} : false; |
|
309 | + return $flat_array ? $caps : array($single_role => $caps); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | // Otherwise, return multi-dimensional array of all caps_to_check |
313 | - return $flat_array ? $all : compact( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
313 | + return $flat_array ? $all : compact('administrator', 'editor', 'author', 'contributor', 'subscriber'); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -330,25 +330,25 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities |
332 | 332 | */ |
333 | - public static function has_cap( $caps_to_check = '', $object_id = null, $user_id = null ) { |
|
333 | + public static function has_cap($caps_to_check = '', $object_id = null, $user_id = null) { |
|
334 | 334 | |
335 | 335 | $has_cap = false; |
336 | 336 | |
337 | - if( empty( $caps_to_check ) ) { |
|
337 | + if (empty($caps_to_check)) { |
|
338 | 338 | return $has_cap; |
339 | 339 | } |
340 | 340 | |
341 | 341 | // Add full access caps for GV & GF |
342 | - $caps_to_check = self::maybe_add_full_access_caps( $caps_to_check ); |
|
342 | + $caps_to_check = self::maybe_add_full_access_caps($caps_to_check); |
|
343 | 343 | |
344 | - foreach ( $caps_to_check as $cap ) { |
|
345 | - if( ! is_null( $object_id ) ) { |
|
346 | - $has_cap = $user_id ? user_can( $user_id, $cap, $object_id ) : current_user_can( $cap, $object_id ); |
|
344 | + foreach ($caps_to_check as $cap) { |
|
345 | + if (!is_null($object_id)) { |
|
346 | + $has_cap = $user_id ? user_can($user_id, $cap, $object_id) : current_user_can($cap, $object_id); |
|
347 | 347 | } else { |
348 | - $has_cap = $user_id ? user_can( $user_id, $cap ) : current_user_can( $cap ); |
|
348 | + $has_cap = $user_id ? user_can($user_id, $cap) : current_user_can($cap); |
|
349 | 349 | } |
350 | 350 | // At the first successful response, stop checking |
351 | - if( $has_cap ) { |
|
351 | + if ($has_cap) { |
|
352 | 352 | break; |
353 | 353 | } |
354 | 354 | } |
@@ -365,25 +365,25 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return array |
367 | 367 | */ |
368 | - public static function maybe_add_full_access_caps( $caps_to_check = array() ) { |
|
368 | + public static function maybe_add_full_access_caps($caps_to_check = array()) { |
|
369 | 369 | |
370 | 370 | $caps_to_check = (array)$caps_to_check; |
371 | 371 | |
372 | 372 | $all_gravityview_caps = self::all_caps(); |
373 | 373 | |
374 | 374 | // Are there any $caps_to_check that are from GravityView? |
375 | - if( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) { |
|
375 | + if ($has_gravityview_caps = array_intersect($caps_to_check, $all_gravityview_caps)) { |
|
376 | 376 | $caps_to_check[] = 'gravityview_full_access'; |
377 | 377 | } |
378 | 378 | |
379 | - $all_gravity_forms_caps = class_exists( 'GFCommon' ) ? GFCommon::all_caps() : array(); |
|
379 | + $all_gravity_forms_caps = class_exists('GFCommon') ? GFCommon::all_caps() : array(); |
|
380 | 380 | |
381 | 381 | // Are there any $caps_to_check that are from Gravity Forms? |
382 | - if( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) { |
|
382 | + if ($all_gravity_forms_caps = array_intersect($caps_to_check, $all_gravity_forms_caps)) { |
|
383 | 383 | $caps_to_check[] = 'gform_full_access'; |
384 | 384 | } |
385 | 385 | |
386 | - return array_unique( $caps_to_check ); |
|
386 | + return array_unique($caps_to_check); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -396,19 +396,19 @@ discard block |
||
396 | 396 | |
397 | 397 | $wp_roles = $this->wp_roles(); |
398 | 398 | |
399 | - if ( is_object( $wp_roles ) ) { |
|
399 | + if (is_object($wp_roles)) { |
|
400 | 400 | |
401 | 401 | /** Remove all GravityView caps_to_check from all roles */ |
402 | 402 | $capabilities = self::all_caps(); |
403 | 403 | |
404 | 404 | // Loop through each role and remove GV caps_to_check |
405 | - foreach( $wp_roles->get_names() as $role_slug => $role_name ) { |
|
406 | - foreach ( $capabilities as $cap ) { |
|
407 | - $wp_roles->remove_cap( $role_slug, $cap ); |
|
405 | + foreach ($wp_roles->get_names() as $role_slug => $role_name) { |
|
406 | + foreach ($capabilities as $cap) { |
|
407 | + $wp_roles->remove_cap($role_slug, $cap); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } |
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
414 | -add_action( 'init', array( 'GravityView_Roles_Capabilities', 'get_instance' ), 1 ); |
|
415 | 414 | \ No newline at end of file |
415 | +add_action('init', array('GravityView_Roles_Capabilities', 'get_instance'), 1); |
|
416 | 416 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | private function add_hooks() { |
26 | 26 | |
27 | 27 | // Shortcode to render view (directory) |
28 | - add_shortcode( 'gravityview', array( $this, 'shortcode' ) ); |
|
28 | + add_shortcode('gravityview', array($this, 'shortcode')); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | * @param string|null $content Content passed inside the shortcode |
40 | 40 | * @return null|string If admin, null. Otherwise, output of $this->render_view() |
41 | 41 | */ |
42 | - function shortcode( $passed_atts, $content = null ) { |
|
42 | + function shortcode($passed_atts, $content = null) { |
|
43 | 43 | |
44 | 44 | // Don't process when saving post. |
45 | - if ( is_admin() ) { |
|
45 | + if (is_admin()) { |
|
46 | 46 | return null; |
47 | 47 | } |
48 | 48 | |
49 | - do_action( 'gravityview_log_debug', __FUNCTION__ . ' $passed_atts: ', $passed_atts ); |
|
49 | + do_action('gravityview_log_debug', __FUNCTION__.' $passed_atts: ', $passed_atts); |
|
50 | 50 | |
51 | 51 | // Get details about the current View |
52 | - if( !empty( $passed_atts['detail'] ) ) { |
|
53 | - return $this->get_view_detail( $passed_atts['detail'] ); |
|
52 | + if (!empty($passed_atts['detail'])) { |
|
53 | + return $this->get_view_detail($passed_atts['detail']); |
|
54 | 54 | } |
55 | 55 | |
56 | - $atts = $this->parse_and_sanitize_atts( $passed_atts ); |
|
56 | + $atts = $this->parse_and_sanitize_atts($passed_atts); |
|
57 | 57 | |
58 | - return GravityView_frontend::getInstance()->render_view( $atts ); |
|
58 | + return GravityView_frontend::getInstance()->render_view($atts); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -76,26 +76,26 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return array Valid and sanitized attribute pairs |
78 | 78 | */ |
79 | - private function parse_and_sanitize_atts( $passed_atts ) { |
|
79 | + private function parse_and_sanitize_atts($passed_atts) { |
|
80 | 80 | |
81 | - $defaults = GravityView_View_Data::get_default_args( true ); |
|
81 | + $defaults = GravityView_View_Data::get_default_args(true); |
|
82 | 82 | |
83 | - $supported_atts = array_fill_keys( array_keys( $defaults ), '' ); |
|
83 | + $supported_atts = array_fill_keys(array_keys($defaults), ''); |
|
84 | 84 | |
85 | 85 | // Whittle down the attributes to only valid pairs |
86 | - $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
|
86 | + $filtered_atts = shortcode_atts($supported_atts, $passed_atts, 'gravityview'); |
|
87 | 87 | |
88 | 88 | // Only keep the passed attributes after making sure that they're valid pairs |
89 | - $filtered_atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $passed_atts, $filtered_atts ) : $filtered_atts; |
|
89 | + $filtered_atts = function_exists('array_intersect_key') ? array_intersect_key($passed_atts, $filtered_atts) : $filtered_atts; |
|
90 | 90 | |
91 | 91 | $atts = array(); |
92 | 92 | |
93 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
93 | + foreach ($filtered_atts as $key => $passed_value) { |
|
94 | 94 | |
95 | 95 | // Allow using {get} merge tags in shortcode attributes |
96 | - $passed_value = GravityView_Merge_Tags::replace_get_variables( $passed_value ); |
|
96 | + $passed_value = GravityView_Merge_Tags::replace_get_variables($passed_value); |
|
97 | 97 | |
98 | - switch( $defaults[ $key ]['type'] ) { |
|
98 | + switch ($defaults[$key]['type']) { |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Make sure number fields are numeric. |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
104 | 104 | */ |
105 | 105 | case 'number': |
106 | - if( is_numeric( $passed_value ) ) { |
|
107 | - $atts[ $key ] = ( $passed_value + 0 ); |
|
106 | + if (is_numeric($passed_value)) { |
|
107 | + $atts[$key] = ($passed_value + 0); |
|
108 | 108 | } |
109 | 109 | break; |
110 | 110 | |
111 | 111 | // Checkboxes should be 1 or 0 |
112 | 112 | case 'checkbox': |
113 | - $atts[ $key ] = gv_empty( $passed_value ) ? 0 : 1; |
|
113 | + $atts[$key] = gv_empty($passed_value) ? 0 : 1; |
|
114 | 114 | break; |
115 | 115 | |
116 | 116 | /** |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | */ |
119 | 119 | case 'select': |
120 | 120 | case 'radio': |
121 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
122 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
123 | - $atts[ $key ] = $passed_value; |
|
121 | + $options = isset($defaults[$key]['choices']) ? $defaults[$key]['choices'] : $defaults[$key]['options']; |
|
122 | + if (in_array($passed_value, array_keys($options))) { |
|
123 | + $atts[$key] = $passed_value; |
|
124 | 124 | } |
125 | 125 | break; |
126 | 126 | |
127 | 127 | case 'text': |
128 | 128 | default: |
129 | - $atts[ $key ] = $passed_value; |
|
129 | + $atts[$key] = $passed_value; |
|
130 | 130 | break; |
131 | 131 | } |
132 | 132 | } |
@@ -143,26 +143,26 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string Detail information |
145 | 145 | */ |
146 | - private function get_view_detail( $detail = '' ) { |
|
146 | + private function get_view_detail($detail = '') { |
|
147 | 147 | |
148 | 148 | $gravityview_view = GravityView_View::getInstance(); |
149 | 149 | $return = ''; |
150 | 150 | |
151 | - switch( $detail ) { |
|
151 | + switch ($detail) { |
|
152 | 152 | case 'total_entries': |
153 | - $return = number_format_i18n( $gravityview_view->getTotalEntries() ); |
|
153 | + $return = number_format_i18n($gravityview_view->getTotalEntries()); |
|
154 | 154 | break; |
155 | 155 | case 'first_entry': |
156 | 156 | $paging = $gravityview_view->getPaginationCounts(); |
157 | - $return = empty( $paging ) ? '' : number_format_i18n( $paging['first'] ); |
|
157 | + $return = empty($paging) ? '' : number_format_i18n($paging['first']); |
|
158 | 158 | break; |
159 | 159 | case 'last_entry': |
160 | 160 | $paging = $gravityview_view->getPaginationCounts(); |
161 | - $return = empty( $paging ) ? '' : number_format_i18n( $paging['last'] ); |
|
161 | + $return = empty($paging) ? '' : number_format_i18n($paging['last']); |
|
162 | 162 | break; |
163 | 163 | case 'page_size': |
164 | 164 | $paging = $gravityview_view->getPaging(); |
165 | - $return = number_format_i18n( $paging['page_size'] ); |
|
165 | + $return = number_format_i18n($paging['page_size']); |
|
166 | 166 | break; |
167 | 167 | } |
168 | 168 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @since 1.13 |
172 | 172 | * @param string $return Existing output |
173 | 173 | */ |
174 | - $return = apply_filters( 'gravityview/shortcode/detail/' . $detail, $return ); |
|
174 | + $return = apply_filters('gravityview/shortcode/detail/'.$detail, $return); |
|
175 | 175 | |
176 | 176 | return $return; |
177 | 177 | } |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | public $active_areas; |
38 | 38 | |
39 | 39 | |
40 | - function __construct( $id, $settings = array(), $field_options = array(), $areas = array() ) { |
|
40 | + function __construct($id, $settings = array(), $field_options = array(), $areas = array()) { |
|
41 | 41 | |
42 | - if ( empty( $id ) ) { |
|
42 | + if (empty($id)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $this->template_id = $id; |
47 | 47 | |
48 | - $this->merge_defaults( $settings ); |
|
48 | + $this->merge_defaults($settings); |
|
49 | 49 | |
50 | 50 | $this->field_options = $field_options; |
51 | 51 | $this->active_areas = $areas; |
@@ -60,25 +60,25 @@ discard block |
||
60 | 60 | */ |
61 | 61 | private function add_hooks() { |
62 | 62 | |
63 | - add_filter( 'gravityview_register_directory_template', array( $this, 'register_template' ) ); |
|
63 | + add_filter('gravityview_register_directory_template', array($this, 'register_template')); |
|
64 | 64 | |
65 | 65 | // presets hooks: |
66 | 66 | // form xml |
67 | - add_filter( 'gravityview_template_formxml', array( $this, 'assign_form_xml' ), 10, 2 ); |
|
67 | + add_filter('gravityview_template_formxml', array($this, 'assign_form_xml'), 10, 2); |
|
68 | 68 | // fields config xml |
69 | - add_filter( 'gravityview_template_fieldsxml', array( $this, 'assign_fields_xml' ), 10, 2 ); |
|
69 | + add_filter('gravityview_template_fieldsxml', array($this, 'assign_fields_xml'), 10, 2); |
|
70 | 70 | |
71 | 71 | // assign active areas |
72 | - add_filter( 'gravityview_template_active_areas', array( $this, 'assign_active_areas' ), 10, 3 ); |
|
72 | + add_filter('gravityview_template_active_areas', array($this, 'assign_active_areas'), 10, 3); |
|
73 | 73 | |
74 | 74 | // field options |
75 | - add_filter( 'gravityview_template_field_options', array( $this, 'assign_field_options' ), 10, 4 ); |
|
75 | + add_filter('gravityview_template_field_options', array($this, 'assign_field_options'), 10, 4); |
|
76 | 76 | |
77 | 77 | // template slug |
78 | - add_filter( "gravityview_template_slug_{$this->template_id}", array( $this, 'assign_view_slug' ), 10, 2 ); |
|
78 | + add_filter("gravityview_template_slug_{$this->template_id}", array($this, 'assign_view_slug'), 10, 2); |
|
79 | 79 | |
80 | 80 | // register template CSS |
81 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) ); |
|
81 | + add_action('wp_enqueue_scripts', array($this, 'register_styles')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return array Merged template settings. |
92 | 92 | */ |
93 | - private function merge_defaults( $settings = array() ) { |
|
93 | + private function merge_defaults($settings = array()) { |
|
94 | 94 | |
95 | 95 | $defaults = array( |
96 | 96 | 'slug' => '', |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'preset_fields' => '' |
106 | 106 | ); |
107 | 107 | |
108 | - $this->settings = wp_parse_args( $settings, $defaults ); |
|
108 | + $this->settings = wp_parse_args($settings, $defaults); |
|
109 | 109 | |
110 | 110 | return $this->settings; |
111 | 111 | } |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return array Array of templates available for GV |
121 | 121 | */ |
122 | - public function register_template( $templates ) { |
|
123 | - $templates[ $this->template_id ] = $this->settings; |
|
122 | + public function register_template($templates) { |
|
123 | + $templates[$this->template_id] = $this->settings; |
|
124 | 124 | |
125 | 125 | return $templates; |
126 | 126 | } |
@@ -136,17 +136,17 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return array Array of active areas |
138 | 138 | */ |
139 | - public function assign_active_areas( $areas, $template = '', $context = 'directory' ) { |
|
140 | - if ( $this->template_id === $template ) { |
|
141 | - $areas = $this->get_active_areas( $context ); |
|
139 | + public function assign_active_areas($areas, $template = '', $context = 'directory') { |
|
140 | + if ($this->template_id === $template) { |
|
141 | + $areas = $this->get_active_areas($context); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | return $areas; |
145 | 145 | } |
146 | 146 | |
147 | - public function get_active_areas( $context ) { |
|
148 | - if ( isset( $this->active_areas[ $context ] ) ) { |
|
149 | - return $this->active_areas[ $context ]; |
|
147 | + public function get_active_areas($context) { |
|
148 | + if (isset($this->active_areas[$context])) { |
|
149 | + return $this->active_areas[$context]; |
|
150 | 150 | } else { |
151 | 151 | return $this->active_areas; |
152 | 152 | } |
@@ -163,21 +163,21 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array Array of field options |
165 | 165 | */ |
166 | - public function assign_field_options( $field_options, $template_id, $field_id = NULL, $context = 'directory' ) { |
|
166 | + public function assign_field_options($field_options, $template_id, $field_id = NULL, $context = 'directory') { |
|
167 | 167 | |
168 | - if ( $this->template_id === $template_id ) { |
|
168 | + if ($this->template_id === $template_id) { |
|
169 | 169 | |
170 | - foreach ( $this->field_options as $key => $field_option ) { |
|
170 | + foreach ($this->field_options as $key => $field_option) { |
|
171 | 171 | |
172 | - $field_context = rgar( $field_option, 'context' ); |
|
172 | + $field_context = rgar($field_option, 'context'); |
|
173 | 173 | |
174 | 174 | // Does the field option only apply to a certain context? |
175 | 175 | // You can define multiple contexts as an array: `context => array("directory", "single")` |
176 | - $context_matches = is_array( $field_context ) ? in_array( $context, $field_context ) : $context === $field_context; |
|
176 | + $context_matches = is_array($field_context) ? in_array($context, $field_context) : $context === $field_context; |
|
177 | 177 | |
178 | 178 | // If the context matches (or isn't defined), add the field options. |
179 | - if ( $context_matches ) { |
|
180 | - $field_options[ $key ] = $field_option; |
|
179 | + if ($context_matches) { |
|
180 | + $field_options[$key] = $field_option; |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | } |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @see GravityView_Admin_Views::create_preset_form() |
193 | 193 | * @return string Path to XML file |
194 | 194 | */ |
195 | - public function assign_form_xml( $xml = '', $template = '' ) { |
|
196 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_form'] ) && $this->template_id === $template ) { |
|
195 | + public function assign_form_xml($xml = '', $template = '') { |
|
196 | + if ($this->settings['type'] === 'preset' && !empty($this->settings['preset_form']) && $this->template_id === $template) { |
|
197 | 197 | return $this->settings['preset_form']; |
198 | 198 | } |
199 | 199 | |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | * @see GravityView_Admin_Views::pre_get_form_fields() |
207 | 207 | * @return string Path to XML file |
208 | 208 | */ |
209 | - public function assign_fields_xml( $xml = '', $template = '' ) { |
|
210 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_fields'] ) && $this->template_id === $template ) { |
|
209 | + public function assign_fields_xml($xml = '', $template = '') { |
|
210 | + if ($this->settings['type'] === 'preset' && !empty($this->settings['preset_fields']) && $this->template_id === $template) { |
|
211 | 211 | return $this->settings['preset_fields']; |
212 | 212 | } |
213 | 213 | |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - public function assign_view_slug( $default, $context ) { |
|
227 | + public function assign_view_slug($default, $context) { |
|
228 | 228 | |
229 | - if ( ! empty( $this->settings['slug'] ) ) { |
|
229 | + if (!empty($this->settings['slug'])) { |
|
230 | 230 | return $this->settings['slug']; |
231 | 231 | } |
232 | - if ( ! empty( $default ) ) { |
|
232 | + if (!empty($default)) { |
|
233 | 233 | return $default; |
234 | 234 | } |
235 | 235 | |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @return void |
245 | 245 | */ |
246 | 246 | public function register_styles() { |
247 | - if ( ! empty( $this->settings['css_source'] ) ) { |
|
248 | - wp_register_style( 'gravityview_style_' . $this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all' ); |
|
247 | + if (!empty($this->settings['css_source'])) { |
|
248 | + wp_register_style('gravityview_style_'.$this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all'); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return GV_License_Handler |
35 | 35 | */ |
36 | - public static function get_instance( GravityView_Settings $GFAddOn ) { |
|
37 | - if( empty( self::$instance ) ) { |
|
38 | - self::$instance = new self( $GFAddOn ); |
|
36 | + public static function get_instance(GravityView_Settings $GFAddOn) { |
|
37 | + if (empty(self::$instance)) { |
|
38 | + self::$instance = new self($GFAddOn); |
|
39 | 39 | } |
40 | 40 | return self::$instance; |
41 | 41 | } |
42 | 42 | |
43 | - private function __construct( GravityView_Settings $GFAddOn ) { |
|
43 | + private function __construct(GravityView_Settings $GFAddOn) { |
|
44 | 44 | |
45 | 45 | $this->Addon = $GFAddOn; |
46 | 46 | |
@@ -50,25 +50,25 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | private function add_hooks() { |
53 | - add_action( 'wp_ajax_gravityview_license', array( $this, 'license_call' ) ); |
|
53 | + add_action('wp_ajax_gravityview_license', array($this, 'license_call')); |
|
54 | 54 | } |
55 | 55 | |
56 | - function settings_edd_license_activation( $field, $echo ) { |
|
56 | + function settings_edd_license_activation($field, $echo) { |
|
57 | 57 | |
58 | - wp_enqueue_script( 'gv-admin-edd-license', GRAVITYVIEW_URL . 'assets/js/admin-edd-license.js', array( 'jquery' ) ); |
|
58 | + wp_enqueue_script('gv-admin-edd-license', GRAVITYVIEW_URL.'assets/js/admin-edd-license.js', array('jquery')); |
|
59 | 59 | |
60 | - $status = trim( $this->Addon->get_app_setting( 'license_key_status' ) ); |
|
61 | - $key = trim( $this->Addon->get_app_setting( 'license_key' ) ); |
|
60 | + $status = trim($this->Addon->get_app_setting('license_key_status')); |
|
61 | + $key = trim($this->Addon->get_app_setting('license_key')); |
|
62 | 62 | |
63 | - if( !empty( $key ) ) { |
|
64 | - $response = $this->Addon->get_app_setting( 'license_key_response' ); |
|
65 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
63 | + if (!empty($key)) { |
|
64 | + $response = $this->Addon->get_app_setting('license_key_response'); |
|
65 | + $response = is_array($response) ? (object)$response : json_decode($response); |
|
66 | 66 | } else { |
67 | 67 | $response = array(); |
68 | 68 | } |
69 | 69 | |
70 | - wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array( |
|
71 | - 'license_box' => $this->get_license_message( $response ) |
|
70 | + wp_localize_script('gv-admin-edd-license', 'GVGlobals', array( |
|
71 | + 'license_box' => $this->get_license_message($response) |
|
72 | 72 | )); |
73 | 73 | |
74 | 74 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | 'value' => __('Deactivate License', 'gravityview'), |
86 | 86 | 'data-pending_text' => __('Deactivating license…', 'gravityview'), |
87 | 87 | 'data-edd_action' => 'deactivate_license', |
88 | - 'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ), |
|
88 | + 'class' => (empty($status) ? 'button-primary hide' : 'button-primary'), |
|
89 | 89 | ), |
90 | 90 | array( |
91 | 91 | 'name' => 'edd-check', |
@@ -100,19 +100,19 @@ discard block |
||
100 | 100 | |
101 | 101 | $class = 'button gv-edd-action'; |
102 | 102 | |
103 | - $class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
103 | + $class .= (!empty($key) && $status !== 'valid') ? '' : ' hide'; |
|
104 | 104 | |
105 | - $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
|
105 | + $disabled_attribute = GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled'; |
|
106 | 106 | |
107 | 107 | $submit = '<div class="gv-edd-button-wrapper">'; |
108 | - foreach ( $fields as $field ) { |
|
108 | + foreach ($fields as $field) { |
|
109 | 109 | $field['type'] = 'button'; |
110 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
110 | + $field['class'] = isset($field['class']) ? $field['class'].' '.$class : $class; |
|
111 | 111 | $field['style'] = 'margin-left: 10px;'; |
112 | - if( $disabled_attribute ) { |
|
112 | + if ($disabled_attribute) { |
|
113 | 113 | $field['disabled'] = $disabled_attribute; |
114 | 114 | } |
115 | - $submit .= $this->Addon->settings_submit( $field, $echo ); |
|
115 | + $submit .= $this->Addon->settings_submit($field, $echo); |
|
116 | 116 | } |
117 | 117 | $submit .= '</div>'; |
118 | 118 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | private function setup_edd() { |
128 | 128 | |
129 | - if( !class_exists('EDD_SL_Plugin_Updater') ) { |
|
130 | - require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
129 | + if (!class_exists('EDD_SL_Plugin_Updater')) { |
|
130 | + require_once(GRAVITYVIEW_DIR.'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // setup the updater |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return array |
151 | 151 | */ |
152 | - function _get_edd_settings( $action = '', $license = '' ) { |
|
152 | + function _get_edd_settings($action = '', $license = '') { |
|
153 | 153 | |
154 | 154 | // retrieve our license key from the DB |
155 | - $license_key = empty( $license ) ? trim( $this->Addon->get_app_setting( 'license_key' ) ) : $license; |
|
155 | + $license_key = empty($license) ? trim($this->Addon->get_app_setting('license_key')) : $license; |
|
156 | 156 | |
157 | 157 | $settings = array( |
158 | 158 | 'version' => self::version, |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | 'url' => home_url(), |
164 | 164 | ); |
165 | 165 | |
166 | - if( !empty( $action ) ) { |
|
167 | - $settings['edd_action'] = esc_attr( $action ); |
|
166 | + if (!empty($action)) { |
|
167 | + $settings['edd_action'] = esc_attr($action); |
|
168 | 168 | } |
169 | 169 | |
170 | - $settings = array_map( 'urlencode', $settings ); |
|
170 | + $settings = array_map('urlencode', $settings); |
|
171 | 171 | |
172 | 172 | return $settings; |
173 | 173 | } |
@@ -176,27 +176,27 @@ discard block |
||
176 | 176 | * Perform the call |
177 | 177 | * @return array|WP_Error |
178 | 178 | */ |
179 | - private function _license_get_remote_response( $data, $license = '' ) { |
|
179 | + private function _license_get_remote_response($data, $license = '') { |
|
180 | 180 | |
181 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
181 | + $api_params = $this->_get_edd_settings($data['edd_action'], $license); |
|
182 | 182 | |
183 | - $url = add_query_arg( $api_params, self::url ); |
|
183 | + $url = add_query_arg($api_params, self::url); |
|
184 | 184 | |
185 | - $response = wp_remote_get( $url, array( |
|
185 | + $response = wp_remote_get($url, array( |
|
186 | 186 | 'timeout' => 15, |
187 | 187 | 'sslverify' => false, |
188 | 188 | )); |
189 | 189 | |
190 | - if ( is_wp_error( $response ) ) { |
|
190 | + if (is_wp_error($response)) { |
|
191 | 191 | return array(); |
192 | 192 | } |
193 | 193 | |
194 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
194 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
195 | 195 | |
196 | 196 | // Not JSON |
197 | - if ( empty( $license_data ) ) { |
|
197 | + if (empty($license_data)) { |
|
198 | 198 | |
199 | - delete_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid' ); |
|
199 | + delete_transient('gravityview_'.esc_attr($data['field_id']).'_valid'); |
|
200 | 200 | |
201 | 201 | // Change status |
202 | 202 | return array(); |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return string |
218 | 218 | */ |
219 | - function get_license_message( $license_data ) { |
|
219 | + function get_license_message($license_data) { |
|
220 | 220 | |
221 | - if( empty( $license_data ) ) { |
|
221 | + if (empty($license_data)) { |
|
222 | 222 | $class = 'hide'; |
223 | 223 | $message = ''; |
224 | 224 | } else { |
225 | 225 | |
226 | - if( ! empty( $license_data->error ) ) { |
|
226 | + if (!empty($license_data->error)) { |
|
227 | 227 | $class = 'error'; |
228 | 228 | $string_key = $license_data->error; |
229 | 229 | } else { |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | $string_key = $license_data->license; |
232 | 232 | } |
233 | 233 | |
234 | - $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) ); |
|
234 | + $message = sprintf('<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings($string_key, $license_data)); |
|
235 | 235 | } |
236 | 236 | |
237 | - return $this->generate_license_box( $message, $class ); |
|
237 | + return $this->generate_license_box($message, $class); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return string |
248 | 248 | */ |
249 | - private function generate_license_box( $message, $class = '' ) { |
|
249 | + private function generate_license_box($message, $class = '') { |
|
250 | 250 | |
251 | 251 | $template = '<div id="gv-edd-status" class="gv-edd-message inline %s">%s</div>'; |
252 | 252 | |
253 | - $output = sprintf( $template, esc_attr( $class ), $message ); |
|
253 | + $output = sprintf($template, esc_attr($class), $message); |
|
254 | 254 | |
255 | 255 | return $output; |
256 | 256 | } |
@@ -270,63 +270,63 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return mixed|string|void |
272 | 272 | */ |
273 | - public function license_call( $array = array() ) { |
|
273 | + public function license_call($array = array()) { |
|
274 | 274 | |
275 | - $is_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
276 | - $data = empty( $array ) ? $_POST['data'] : $array; |
|
277 | - $has_cap = GVCommon::has_cap( 'gravityview_edit_settings' ); |
|
275 | + $is_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
276 | + $data = empty($array) ? $_POST['data'] : $array; |
|
277 | + $has_cap = GVCommon::has_cap('gravityview_edit_settings'); |
|
278 | 278 | |
279 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
280 | - die( - 1 ); |
|
279 | + if ($is_ajax && empty($data['license'])) { |
|
280 | + die( -1 ); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | // If the user isn't allowed to edit settings, show an error message |
284 | - if( ! $has_cap ) { |
|
284 | + if (!$has_cap) { |
|
285 | 285 | $license_data = new stdClass(); |
286 | 286 | $license_data->error = 'capability'; |
287 | - $license_data->message = $this->get_license_message( $license_data ); |
|
288 | - $json = json_encode( $license_data ); |
|
287 | + $license_data->message = $this->get_license_message($license_data); |
|
288 | + $json = json_encode($license_data); |
|
289 | 289 | } else { |
290 | 290 | |
291 | - $license = esc_attr( rgget( 'license', $data ) ); |
|
292 | - $license_data = $this->_license_get_remote_response( $data, $license ); |
|
291 | + $license = esc_attr(rgget('license', $data)); |
|
292 | + $license_data = $this->_license_get_remote_response($data, $license); |
|
293 | 293 | |
294 | 294 | // Empty is returned when there's an error. |
295 | - if ( empty( $license_data ) ) { |
|
296 | - if ( $is_ajax ) { |
|
297 | - exit( json_encode( array() ) ); |
|
295 | + if (empty($license_data)) { |
|
296 | + if ($is_ajax) { |
|
297 | + exit(json_encode(array())); |
|
298 | 298 | } else { // Non-ajax call |
299 | - return json_encode( array() ); |
|
299 | + return json_encode(array()); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
303 | - $license_data->message = $this->get_license_message( $license_data ); |
|
303 | + $license_data->message = $this->get_license_message($license_data); |
|
304 | 304 | |
305 | - $json = json_encode( $license_data ); |
|
305 | + $json = json_encode($license_data); |
|
306 | 306 | |
307 | - $update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) ); |
|
307 | + $update_license = (!isset($data['update']) || !empty($data['update'])); |
|
308 | 308 | |
309 | - $is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
309 | + $is_check_action_button = ('check_license' === $data['edd_action'] && defined('DOING_AJAX') && DOING_AJAX); |
|
310 | 310 | |
311 | 311 | // Failed is the response from trying to de-activate a license and it didn't work. |
312 | 312 | // This likely happened because people entered in a different key and clicked "Deactivate", |
313 | 313 | // meaning to deactivate the original key. We don't want to save this response, since it is |
314 | 314 | // most likely a mistake. |
315 | - if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) { |
|
315 | + if ($license_data->license !== 'failed' && !$is_check_action_button && $update_license) { |
|
316 | 316 | |
317 | - if ( ! empty( $data['field_id'] ) ) { |
|
318 | - set_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid', $license_data, DAY_IN_SECONDS ); |
|
317 | + if (!empty($data['field_id'])) { |
|
318 | + set_transient('gravityview_'.esc_attr($data['field_id']).'_valid', $license_data, DAY_IN_SECONDS); |
|
319 | 319 | } |
320 | 320 | |
321 | - $this->license_call_update_settings( $license_data, $data ); |
|
321 | + $this->license_call_update_settings($license_data, $data); |
|
322 | 322 | |
323 | 323 | } |
324 | 324 | } // End $has_cap |
325 | 325 | |
326 | - if ( $is_ajax ) { |
|
327 | - exit( $json ); |
|
326 | + if ($is_ajax) { |
|
327 | + exit($json); |
|
328 | 328 | } else { // Non-ajax call |
329 | - return ( rgget('format', $data ) === 'object' ) ? $license_data : $json; |
|
329 | + return (rgget('format', $data) === 'object') ? $license_data : $json; |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
@@ -335,16 +335,16 @@ discard block |
||
335 | 335 | * @param object $license_data |
336 | 336 | * @return void |
337 | 337 | */ |
338 | - private function license_call_update_settings( $license_data, $data ) { |
|
338 | + private function license_call_update_settings($license_data, $data) { |
|
339 | 339 | |
340 | 340 | // Update option with passed data license |
341 | 341 | $settings = $this->Addon->get_app_settings(); |
342 | 342 | |
343 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
343 | + $settings['license_key'] = $license_data->license_key = trim($data['license']); |
|
344 | 344 | $settings['license_key_status'] = $license_data->license; |
345 | 345 | $settings['license_key_response'] = (array)$license_data; |
346 | 346 | |
347 | - $this->Addon->update_app_settings( $settings ); |
|
347 | + $this->Addon->update_app_settings($settings); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -353,8 +353,8 @@ discard block |
||
353 | 353 | * @param object|null $license_data Object with license data |
354 | 354 | * @return string Renewal or account URL |
355 | 355 | */ |
356 | - private function get_license_renewal_url( $license_data ) { |
|
357 | - $renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
356 | + private function get_license_renewal_url($license_data) { |
|
357 | + $renew_license_url = (!empty($license_data) && !empty($license_data->license_key)) ? sprintf('https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key) : 'https://gravityview.co/account/'; |
|
358 | 358 | return $renew_license_url; |
359 | 359 | } |
360 | 360 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @param object|null $license_data Object with license data |
365 | 365 | * @return array Modified array of content |
366 | 366 | */ |
367 | - public function strings( $status = NULL, $license_data = null ) { |
|
367 | + public function strings($status = NULL, $license_data = null) { |
|
368 | 368 | |
369 | 369 | |
370 | 370 | $strings = array( |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | 'error' => esc_html__('There was an error processing the request.', 'gravityview'), |
373 | 373 | 'failed' => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'), |
374 | 374 | 'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
375 | - 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
375 | + 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview').' '.sprintf(esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>'), |
|
376 | 376 | 'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'), |
377 | 377 | 'valid' => esc_html__('The license key is valid and active.', 'gravityview'), |
378 | 378 | 'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'), |
379 | 379 | 'missing' => esc_html__('The license key was not defined.', 'gravityview'), |
380 | 380 | 'revoked' => esc_html__('This license key has been revoked.', 'gravityview'), |
381 | - 'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
382 | - 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
|
381 | + 'expired' => sprintf(esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'.esc_url($this->get_license_renewal_url($license_data)).'">', '</a>'), |
|
382 | + 'capability' => esc_html__('You don\'t have the ability to edit plugin settings.', 'gravityview'), |
|
383 | 383 | |
384 | 384 | 'verifying_license' => esc_html__('Verifying license…', 'gravityview'), |
385 | 385 | 'activate_license' => esc_html__('Activate License', 'gravityview'), |
@@ -387,33 +387,33 @@ discard block |
||
387 | 387 | 'check_license' => esc_html__('Verify License', 'gravityview'), |
388 | 388 | ); |
389 | 389 | |
390 | - if( empty( $status ) ) { |
|
390 | + if (empty($status)) { |
|
391 | 391 | return $strings; |
392 | 392 | } |
393 | 393 | |
394 | - if( isset( $strings[ $status ] ) ) { |
|
395 | - return $strings[ $status ]; |
|
394 | + if (isset($strings[$status])) { |
|
395 | + return $strings[$status]; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | return NULL; |
399 | 399 | } |
400 | 400 | |
401 | - public function validate_license_key( $value, $field ) { |
|
401 | + public function validate_license_key($value, $field) { |
|
402 | 402 | |
403 | 403 | // No license? No status. |
404 | - if( empty( $value ) ) { |
|
404 | + if (empty($value)) { |
|
405 | 405 | return NULL; |
406 | 406 | } |
407 | 407 | |
408 | 408 | $response = $this->license_call(array( |
409 | - 'license' => $this->Addon->get_app_setting( 'license_key' ), |
|
409 | + 'license' => $this->Addon->get_app_setting('license_key'), |
|
410 | 410 | 'edd_action' => 'check_license', |
411 | 411 | 'field_id' => $field['name'], |
412 | 412 | )); |
413 | 413 | |
414 | - $response = is_string( $response ) ? json_decode( $response, true ) : $response; |
|
414 | + $response = is_string($response) ? json_decode($response, true) : $response; |
|
415 | 415 | |
416 | - switch( $response['license'] ) { |
|
416 | + switch ($response['license']) { |
|
417 | 417 | case 'valid': |
418 | 418 | $return = true; |
419 | 419 | break; |
@@ -5,13 +5,13 @@ discard block |
||
5 | 5 | */ |
6 | 6 | class GVLogic_Shortcode { |
7 | 7 | |
8 | - private static $SUPPORTED_SCALAR_OPERATORS = array( 'is', 'isnot', 'contains', 'starts_with', 'ends_with' ); |
|
8 | + private static $SUPPORTED_SCALAR_OPERATORS = array('is', 'isnot', 'contains', 'starts_with', 'ends_with'); |
|
9 | 9 | |
10 | - private static $SUPPORTED_NUMERIC_OPERATORS = array( 'greater_than', 'less_than' ); |
|
10 | + private static $SUPPORTED_NUMERIC_OPERATORS = array('greater_than', 'less_than'); |
|
11 | 11 | |
12 | - private static $SUPPORTED_ARRAY_OPERATORS = array( 'in', 'not_in', 'isnot', 'contains' ); |
|
12 | + private static $SUPPORTED_ARRAY_OPERATORS = array('in', 'not_in', 'isnot', 'contains'); |
|
13 | 13 | |
14 | - private static $SUPPORTED_CUSTOM_OPERATORS = array( 'equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains' ); |
|
14 | + private static $SUPPORTED_CUSTOM_OPERATORS = array('equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains'); |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Attributes passed to the shortcode |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function get_instance() { |
87 | 87 | |
88 | - if( empty( self::$instance ) ) { |
|
88 | + if (empty(self::$instance)) { |
|
89 | 89 | self::$instance = new self; |
90 | 90 | } |
91 | 91 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return void |
106 | 106 | */ |
107 | 107 | function add_hooks() { |
108 | - add_shortcode( 'gvlogic', array( $this, 'shortcode' ) ); |
|
108 | + add_shortcode('gvlogic', array($this, 'shortcode')); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - function get_operators( $with_values = false ) { |
|
117 | + function get_operators($with_values = false) { |
|
118 | 118 | |
119 | - $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
|
119 | + $operators = array_merge(self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS); |
|
120 | 120 | |
121 | - if( $with_values ) { |
|
121 | + if ($with_values) { |
|
122 | 122 | $operators_with_values = array(); |
123 | - foreach( $operators as $key ) { |
|
124 | - $operators_with_values[ $key ] = ''; |
|
123 | + foreach ($operators as $key) { |
|
124 | + $operators_with_values[$key] = ''; |
|
125 | 125 | } |
126 | 126 | return $operators_with_values; |
127 | 127 | } else { |
@@ -135,16 +135,16 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return bool True: it's an allowed operation type and was added. False: invalid operation type |
137 | 137 | */ |
138 | - function set_operation( $operation = '' ) { |
|
138 | + function set_operation($operation = '') { |
|
139 | 139 | |
140 | - if( empty( $operation ) ) { |
|
140 | + if (empty($operation)) { |
|
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | - $operators = $this->get_operators( false ); |
|
144 | + $operators = $this->get_operators(false); |
|
145 | 145 | |
146 | - if( !in_array( $operation, $operators ) ) { |
|
147 | - do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation ); |
|
146 | + if (!in_array($operation, $operators)) { |
|
147 | + do_action('gravityview_log_debug', __METHOD__.' Attempted to add invalid operation type.', $operation); |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | */ |
165 | 165 | function setup_operation_and_comparison() { |
166 | 166 | |
167 | - foreach( $this->atts as $key => $value ) { |
|
167 | + foreach ($this->atts as $key => $value) { |
|
168 | 168 | |
169 | - $valid = $this->set_operation( $key ); |
|
169 | + $valid = $this->set_operation($key); |
|
170 | 170 | |
171 | - if( $valid ) { |
|
171 | + if ($valid) { |
|
172 | 172 | $this->comparison = $value; |
173 | 173 | return true; |
174 | 174 | } |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @return string|null |
186 | 186 | */ |
187 | - public function shortcode( $atts = array(), $content = NULL, $shortcode_tag = '' ) { |
|
187 | + public function shortcode($atts = array(), $content = NULL, $shortcode_tag = '') { |
|
188 | 188 | |
189 | 189 | // Don't process except on frontend |
190 | - if ( GravityView_Plugin::is_admin() ) { |
|
190 | + if (GravityView_Plugin::is_admin()) { |
|
191 | 191 | return null; |
192 | 192 | } |
193 | 193 | |
@@ -198,16 +198,16 @@ discard block |
||
198 | 198 | $this->parse_atts(); |
199 | 199 | |
200 | 200 | // We need an "if" |
201 | - if( false === $this->if ) { |
|
202 | - do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->atts ); |
|
201 | + if (false === $this->if) { |
|
202 | + do_action('gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->atts); |
|
203 | 203 | return null; |
204 | 204 | } |
205 | 205 | |
206 | 206 | $setup = $this->setup_operation_and_comparison(); |
207 | 207 | |
208 | 208 | // We need an operation and comparison value |
209 | - if( ! $setup ) { |
|
210 | - do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts ); |
|
209 | + if (!$setup) { |
|
210 | + do_action('gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts); |
|
211 | 211 | return null; |
212 | 212 | } |
213 | 213 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @return boolean True: yep; false: nope |
229 | 229 | */ |
230 | 230 | function set_is_match() { |
231 | - $this->is_match = GVCommon::matches_operation( $this->if, $this->comparison, $this->operation ); |
|
231 | + $this->is_match = GVCommon::matches_operation($this->if, $this->comparison, $this->operation); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -238,23 +238,23 @@ discard block |
||
238 | 238 | */ |
239 | 239 | function get_output() { |
240 | 240 | |
241 | - if( $this->is_match ) { |
|
241 | + if ($this->is_match) { |
|
242 | 242 | $output = $this->content; |
243 | 243 | } else { |
244 | 244 | $output = $this->else_content; |
245 | 245 | } |
246 | 246 | |
247 | 247 | // Get recursive! |
248 | - $output = do_shortcode( $output ); |
|
248 | + $output = do_shortcode($output); |
|
249 | 249 | |
250 | 250 | /** |
251 | 251 | * @filter `gravityview/gvlogic/output` Modify the [gvlogic] output |
252 | 252 | * @param string $output HTML/text output |
253 | 253 | * @param GVLogic_Shortcode $this This class |
254 | 254 | */ |
255 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
255 | + $output = apply_filters('gravityview/gvlogic/output', $output, $this); |
|
256 | 256 | |
257 | - do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output ); |
|
257 | + do_action('gravityview_log_debug', __METHOD__.' Output: ', $output); |
|
258 | 258 | |
259 | 259 | return $output; |
260 | 260 | } |
@@ -268,13 +268,13 @@ discard block |
||
268 | 268 | */ |
269 | 269 | function set_content_and_else_content() { |
270 | 270 | |
271 | - $content = explode( '[else]', $this->passed_content ); |
|
271 | + $content = explode('[else]', $this->passed_content); |
|
272 | 272 | |
273 | 273 | $this->content = $content[0]; |
274 | 274 | |
275 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
275 | + $else_attr = isset($this->atts['else']) ? $this->atts['else'] : NULL; |
|
276 | 276 | |
277 | - $this->else_content = isset( $content[1] ) ? $content[1] : $else_attr; |
|
277 | + $this->else_content = isset($content[1]) ? $content[1] : $else_attr; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | 'else' => false, |
289 | 289 | ); |
290 | 290 | |
291 | - $supported_args = $supported + $this->get_operators( true ); |
|
291 | + $supported_args = $supported + $this->get_operators(true); |
|
292 | 292 | |
293 | 293 | // Whittle down the attributes to only valid pairs |
294 | - $this->atts = shortcode_atts( $supported_args, $this->passed_atts, $this->shortcode ); |
|
294 | + $this->atts = shortcode_atts($supported_args, $this->passed_atts, $this->shortcode); |
|
295 | 295 | |
296 | 296 | // Only keep the passed attributes after making sure that they're valid pairs |
297 | - $this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts; |
|
297 | + $this->atts = function_exists('array_intersect_key') ? array_intersect_key($this->passed_atts, $this->atts) : $this->atts; |
|
298 | 298 | |
299 | 299 | // Strip whitespace if it's not default false |
300 | - $this->if = is_string( $this->atts['if'] ) ? trim( $this->atts['if'] ) : false; |
|
300 | + $this->if = is_string($this->atts['if']) ? trim($this->atts['if']) : false; |
|
301 | 301 | |
302 | 302 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
303 | - unset( $this->atts['if'] ); |
|
303 | + unset($this->atts['if']); |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @since 1.6 |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if (!defined('ABSPATH')) { |
|
14 | 14 | die; |
15 | 15 | } |
16 | 16 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | private function initialize() { |
34 | 34 | |
35 | - add_action( 'init', array( $this, 'register_handler' ) ); |
|
35 | + add_action('init', array($this, 'register_handler')); |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | |
@@ -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(); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function register_handler() { |
61 | 61 | |
62 | - wp_embed_register_handler( 'gravityview_entry', $this->get_handler_regex(), array( $this, 'render_handler' ), 20000 ); |
|
62 | + wp_embed_register_handler('gravityview_entry', $this->get_handler_regex(), array($this, 'render_handler'), 20000); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | * @filter `gravityview_slug` Modify the url part for a View. [Read the doc](http://docs.gravityview.co/article/62-changing-the-view-slug) |
81 | 81 | * @param string $rewrite_slug The slug shown in the URL |
82 | 82 | */ |
83 | - $rewrite_slug = apply_filters( 'gravityview_slug', 'view' ); |
|
83 | + $rewrite_slug = apply_filters('gravityview_slug', 'view'); |
|
84 | 84 | |
85 | 85 | // Only support embeds for current site |
86 | - $prefix = trailingslashit( home_url() ); |
|
86 | + $prefix = trailingslashit(home_url()); |
|
87 | 87 | |
88 | 88 | // Using permalinks |
89 | - $using_permalinks = $prefix . "(?P<is_cpt>{$rewrite_slug})?/?(?P<slug>.+?)/{$entry_var_name}/(?P<entry_slug>.+?)/?\$"; |
|
89 | + $using_permalinks = $prefix."(?P<is_cpt>{$rewrite_slug})?/?(?P<slug>.+?)/{$entry_var_name}/(?P<entry_slug>.+?)/?\$"; |
|
90 | 90 | |
91 | 91 | // Not using permalinks |
92 | - $not_using_permalinks = $prefix . "(?:index.php)?\?(?P<is_cpt2>[^=]+)=(?P<slug2>[^&]+)&entry=(?P<entry_slug2>[^&]+)\$"; |
|
92 | + $not_using_permalinks = $prefix."(?:index.php)?\?(?P<is_cpt2>[^=]+)=(?P<slug2>[^&]+)&entry=(?P<entry_slug2>[^&]+)\$"; |
|
93 | 93 | |
94 | 94 | // Catch either |
95 | 95 | $match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})"; |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | * @param string $slug The name of a post, used as backup way of checking for post ID |
110 | 110 | * @return int 0 if not found; int of URL post ID otherwise |
111 | 111 | */ |
112 | - private function get_postid_from_url_and_slug( $url = '', $slug = '' ) { |
|
112 | + private function get_postid_from_url_and_slug($url = '', $slug = '') { |
|
113 | 113 | |
114 | - $post_id = url_to_postid( $url ); |
|
114 | + $post_id = url_to_postid($url); |
|
115 | 115 | |
116 | - if( empty( $post_id ) ) { |
|
116 | + if (empty($post_id)) { |
|
117 | 117 | |
118 | 118 | $args = array( |
119 | 119 | 'post_status' => 'publish', |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | 'post_type' => array('any', 'gravityview'), |
122 | 122 | ); |
123 | 123 | |
124 | - $posts = get_posts( $args ); |
|
124 | + $posts = get_posts($args); |
|
125 | 125 | |
126 | - if( !empty( $posts ) ) { |
|
126 | + if (!empty($posts)) { |
|
127 | 127 | $post_id = $posts[0]->ID; |
128 | 128 | } |
129 | 129 | } |
@@ -154,20 +154,20 @@ discard block |
||
154 | 154 | * @param array $rawattr The original unmodified attributes. |
155 | 155 | * @return string The embed HTML. |
156 | 156 | */ |
157 | - public function render_handler( $matches, $attr, $url, $rawattr ) { |
|
157 | + public function render_handler($matches, $attr, $url, $rawattr) { |
|
158 | 158 | |
159 | 159 | // If not using permalinks, re-assign values for matching groups |
160 | - if( !empty( $matches['entry_slug2'] ) ) { |
|
160 | + if (!empty($matches['entry_slug2'])) { |
|
161 | 161 | $matches['is_cpt'] = $matches['is_cpt2']; |
162 | 162 | $matches['slug'] = $matches['slug2']; |
163 | 163 | $matches['entry_slug'] = $matches['entry_slug2']; |
164 | - unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
164 | + unset($matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2']); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // No Entry was found |
168 | - if( empty( $matches['entry_slug'] ) ) { |
|
168 | + if (empty($matches['entry_slug'])) { |
|
169 | 169 | |
170 | - do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
170 | + do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches); |
|
171 | 171 | |
172 | 172 | return ''; |
173 | 173 | } |
@@ -175,17 +175,17 @@ discard block |
||
175 | 175 | $return = ''; |
176 | 176 | |
177 | 177 | // Setup the data used |
178 | - $this->set_vars( $matches, $attr, $url, $rawattr ); |
|
178 | + $this->set_vars($matches, $attr, $url, $rawattr); |
|
179 | 179 | |
180 | - if( is_admin() && !$this->is_full_oembed_preview ) { |
|
181 | - $return = $this->render_admin( $matches, $attr, $url, $rawattr ); |
|
180 | + if (is_admin() && !$this->is_full_oembed_preview) { |
|
181 | + $return = $this->render_admin($matches, $attr, $url, $rawattr); |
|
182 | 182 | } else { |
183 | 183 | |
184 | - if( $this->is_full_oembed_preview ) { |
|
184 | + if ($this->is_full_oembed_preview) { |
|
185 | 185 | $return .= $this->generate_preview_notice(); |
186 | 186 | } |
187 | 187 | |
188 | - $return .= $this->render_frontend( $matches, $attr, $url, $rawattr ); |
|
188 | + $return .= $this->render_frontend($matches, $attr, $url, $rawattr); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | return $return; |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | */ |
200 | 200 | private function generate_preview_notice() { |
201 | 201 | $floaty = GravityView_Admin::get_floaty(); |
202 | - $title = esc_html__( 'This will look better when it is embedded.', 'gravityview' ); |
|
202 | + $title = esc_html__('This will look better when it is embedded.', 'gravityview'); |
|
203 | 203 | $message = esc_html__('Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview'); |
204 | - return '<div class="updated notice">'. $floaty. '<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>'; |
|
204 | + return '<div class="updated notice">'.$floaty.'<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>'; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -212,18 +212,18 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @see render_handler |
214 | 214 | */ |
215 | - private function set_vars( $matches, $attr, $url, $rawattr ) { |
|
215 | + private function set_vars($matches, $attr, $url, $rawattr) { |
|
216 | 216 | |
217 | 217 | $this->entry_id = $matches['entry_slug']; |
218 | 218 | |
219 | - $post_id = $this->get_postid_from_url_and_slug( $url, $matches['slug'] ); |
|
219 | + $post_id = $this->get_postid_from_url_and_slug($url, $matches['slug']); |
|
220 | 220 | |
221 | 221 | // The URL didn't have the View Custom Post Type structure. |
222 | - if( empty( $matches['is_cpt'] ) || $matches['is_cpt'] !== 'gravityview' ) { |
|
222 | + if (empty($matches['is_cpt']) || $matches['is_cpt'] !== 'gravityview') { |
|
223 | 223 | |
224 | - do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
224 | + do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches); |
|
225 | 225 | |
226 | - $this->view_id = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); |
|
226 | + $this->view_id = GravityView_View_Data::getInstance()->maybe_get_view_id($post_id); |
|
227 | 227 | |
228 | 228 | } else { |
229 | 229 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | |
234 | 234 | // The inline content has $_POST['type'] set to "embed", while the "Add Media" modal doesn't set that. |
235 | - $this->is_full_oembed_preview = ( isset( $_POST['action'] ) && $_POST['action'] === 'parse-embed' && !isset( $_POST['type'] ) ); |
|
235 | + $this->is_full_oembed_preview = (isset($_POST['action']) && $_POST['action'] === 'parse-embed' && !isset($_POST['type'])); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | * @param array $rawattr The original unmodified attributes. |
245 | 245 | * @return string The embed HTML. |
246 | 246 | */ |
247 | - private function render_admin( $matches, $attr, $url, $rawattr ) { |
|
247 | + private function render_admin($matches, $attr, $url, $rawattr) { |
|
248 | 248 | global $wp_version; |
249 | 249 | |
250 | 250 | // Floaty the astronaut |
251 | 251 | $image = GravityView_Admin::get_floaty(); |
252 | 252 | |
253 | - $embed_heading = sprintf( esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id ); |
|
253 | + $embed_heading = sprintf(esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id); |
|
254 | 254 | |
255 | - $embed_text = sprintf( esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id ); |
|
255 | + $embed_text = sprintf(esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id); |
|
256 | 256 | |
257 | 257 | return ' |
258 | 258 | <div class="loading-placeholder" style="background-color:#e6f0f5;"> |
@@ -268,21 +268,21 @@ discard block |
||
268 | 268 | private function generate_entry_output() { |
269 | 269 | |
270 | 270 | // Tell get_gravityview() to display a single entry |
271 | - add_filter( 'gravityview/is_single_entry', array( $this, 'set_single_entry_id' ) ); |
|
271 | + add_filter('gravityview/is_single_entry', array($this, 'set_single_entry_id')); |
|
272 | 272 | |
273 | 273 | ob_start(); |
274 | 274 | |
275 | 275 | // Print the entry as configured in View |
276 | - the_gravityview( $this->view_id ); |
|
276 | + the_gravityview($this->view_id); |
|
277 | 277 | |
278 | 278 | $view_html = ob_get_clean(); |
279 | 279 | |
280 | 280 | // Clean up the filter |
281 | - remove_filter( 'gravityview/is_single_entry', array( $this, 'set_single_entry_id' ) ); |
|
281 | + remove_filter('gravityview/is_single_entry', array($this, 'set_single_entry_id')); |
|
282 | 282 | |
283 | 283 | // Strip the new lines that are generated--when editing an entry in particular, scripts are printed that |
284 | 284 | // then are passed through wpautop() and everything looks terrible. |
285 | - $view_html = str_replace( "\n", ' ', $view_html ); |
|
285 | + $view_html = str_replace("\n", ' ', $view_html); |
|
286 | 286 | |
287 | 287 | return $view_html; |
288 | 288 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return int The current entry ID |
298 | 298 | */ |
299 | - public function set_single_entry_id( $is_single_entry = false ) { |
|
299 | + public function set_single_entry_id($is_single_entry = false) { |
|
300 | 300 | |
301 | 301 | return $this->entry_id; |
302 | 302 | } |
@@ -310,17 +310,17 @@ discard block |
||
310 | 310 | * @param array $rawattr The original unmodified attributes. |
311 | 311 | * @return string The embed HTML. |
312 | 312 | */ |
313 | - private function render_frontend( $matches, $attr, $url, $rawattr ) { |
|
313 | + private function render_frontend($matches, $attr, $url, $rawattr) { |
|
314 | 314 | |
315 | 315 | // If it's already been parsed, don't re-output it. |
316 | - if( !empty( $this->output[ $this->entry_id ] ) ) { |
|
317 | - return $this->output[ $this->entry_id ]; |
|
316 | + if (!empty($this->output[$this->entry_id])) { |
|
317 | + return $this->output[$this->entry_id]; |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | $entry_output = $this->generate_entry_output(); |
321 | 321 | |
322 | 322 | // Wrap a container div around the output to allow for custom styling |
323 | - $output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output ); |
|
323 | + $output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output); |
|
324 | 324 | |
325 | 325 | /** |
326 | 326 | * @filter `gravityview/oembed/entry` Filter the output of the oEmbed entry embed |
@@ -333,13 +333,13 @@ discard block |
||
333 | 333 | * @var string $url The original URL that was matched by the regex. \n |
334 | 334 | * @var array $rawattr The original unmodified attributes. |
335 | 335 | */ |
336 | - $output = apply_filters('gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
336 | + $output = apply_filters('gravityview/oembed/entry', $output, $this, compact($entry_output, $matches, $attr, $url, $rawattr)); |
|
337 | 337 | |
338 | - unset( $entry_output ); |
|
338 | + unset($entry_output); |
|
339 | 339 | |
340 | - $this->output[ $this->entry_id ] = $output; |
|
340 | + $this->output[$this->entry_id] = $output; |
|
341 | 341 | |
342 | - return $this->output[ $this->entry_id ]; |
|
342 | + return $this->output[$this->entry_id]; |
|
343 | 343 | |
344 | 344 | } |
345 | 345 |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | |
18 | 18 | // Load custom post types. It's a static method. |
19 | 19 | // Load even when invalid to allow for export |
20 | - add_action( 'init', array( 'GravityView_Post_Types', 'init_post_types' ) ); |
|
20 | + add_action('init', array('GravityView_Post_Types', 'init_post_types')); |
|
21 | 21 | |
22 | - if( GravityView_Compatibility::is_valid() ) { |
|
23 | - add_action( 'init', array( 'GravityView_Post_Types', 'init_rewrite' ) ); |
|
22 | + if (GravityView_Compatibility::is_valid()) { |
|
23 | + add_action('init', array('GravityView_Post_Types', 'init_rewrite')); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | * @since 1.13 |
40 | 40 | * @param boolean $is_hierarchical Default: false |
41 | 41 | */ |
42 | - $is_hierarchical = (bool)apply_filters( 'gravityview_is_hierarchical', false ); |
|
42 | + $is_hierarchical = (bool)apply_filters('gravityview_is_hierarchical', false); |
|
43 | 43 | |
44 | - $supports = array( 'title', 'revisions' ); |
|
44 | + $supports = array('title', 'revisions'); |
|
45 | 45 | |
46 | - if( $is_hierarchical ) { |
|
46 | + if ($is_hierarchical) { |
|
47 | 47 | $supports[] = 'page-attributes'; |
48 | 48 | } |
49 | 49 | |
@@ -54,30 +54,30 @@ discard block |
||
54 | 54 | * @param array $supports Array of features associated with a functional area of the edit screen. Default: 'title', 'revisions'. If $is_hierarchical, also 'page-attributes' |
55 | 55 | * @param[in] boolean $is_hierarchical Do Views support parent/child relationships? See `gravityview_is_hierarchical` filter. |
56 | 56 | */ |
57 | - $supports = apply_filters( 'gravityview_post_type_support', $supports, $is_hierarchical ); |
|
57 | + $supports = apply_filters('gravityview_post_type_support', $supports, $is_hierarchical); |
|
58 | 58 | |
59 | 59 | //Register Custom Post Type - gravityview |
60 | 60 | $labels = array( |
61 | - 'name' => _x( 'Views', 'Post Type General Name', 'gravityview' ), |
|
62 | - 'singular_name' => _x( 'View', 'Post Type Singular Name', 'gravityview' ), |
|
63 | - 'menu_name' => _x( 'Views', 'Menu name', 'gravityview' ), |
|
64 | - 'parent_item_colon' => __( 'Parent View:', 'gravityview' ), |
|
65 | - 'all_items' => __( 'All Views', 'gravityview' ), |
|
66 | - 'view_item' => _x( 'View', 'View Item', 'gravityview' ), |
|
67 | - 'add_new_item' => __( 'Add New View', 'gravityview' ), |
|
68 | - 'add_new' => __( 'New View', 'gravityview' ), |
|
69 | - 'edit_item' => __( 'Edit View', 'gravityview' ), |
|
70 | - 'update_item' => __( 'Update View', 'gravityview' ), |
|
71 | - 'search_items' => __( 'Search Views', 'gravityview' ), |
|
61 | + 'name' => _x('Views', 'Post Type General Name', 'gravityview'), |
|
62 | + 'singular_name' => _x('View', 'Post Type Singular Name', 'gravityview'), |
|
63 | + 'menu_name' => _x('Views', 'Menu name', 'gravityview'), |
|
64 | + 'parent_item_colon' => __('Parent View:', 'gravityview'), |
|
65 | + 'all_items' => __('All Views', 'gravityview'), |
|
66 | + 'view_item' => _x('View', 'View Item', 'gravityview'), |
|
67 | + 'add_new_item' => __('Add New View', 'gravityview'), |
|
68 | + 'add_new' => __('New View', 'gravityview'), |
|
69 | + 'edit_item' => __('Edit View', 'gravityview'), |
|
70 | + 'update_item' => __('Update View', 'gravityview'), |
|
71 | + 'search_items' => __('Search Views', 'gravityview'), |
|
72 | 72 | 'not_found' => self::no_views_text(), |
73 | - 'not_found_in_trash' => __( 'No Views found in Trash', 'gravityview' ), |
|
74 | - 'filter_items_list' => __( 'Filter Views list', 'gravityview' ), |
|
75 | - 'items_list_navigation' => __( 'Views list navigation', 'gravityview' ), |
|
76 | - 'items_list' => __( 'Views list', 'gravityview' ), |
|
73 | + 'not_found_in_trash' => __('No Views found in Trash', 'gravityview'), |
|
74 | + 'filter_items_list' => __('Filter Views list', 'gravityview'), |
|
75 | + 'items_list_navigation' => __('Views list navigation', 'gravityview'), |
|
76 | + 'items_list' => __('Views list', 'gravityview'), |
|
77 | 77 | ); |
78 | 78 | $args = array( |
79 | - 'label' => __( 'view', 'gravityview' ), |
|
80 | - 'description' => __( 'Create views based on a Gravity Forms form', 'gravityview' ), |
|
79 | + 'label' => __('view', 'gravityview'), |
|
80 | + 'description' => __('Create views based on a Gravity Forms form', 'gravityview'), |
|
81 | 81 | 'labels' => $labels, |
82 | 82 | 'supports' => $supports, |
83 | 83 | 'hierarchical' => $is_hierarchical, |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param[in,out] boolean `true`: allow Views to be accessible directly. `false`: Only allow Views to be embedded via shortcode. Default: `true` |
89 | 89 | * @param int $view_id The ID of the View currently being requested. `0` for general setting |
90 | 90 | */ |
91 | - 'public' => apply_filters( 'gravityview_direct_access', GravityView_Compatibility::is_valid(), 0 ), |
|
91 | + 'public' => apply_filters('gravityview_direct_access', GravityView_Compatibility::is_valid(), 0), |
|
92 | 92 | 'show_ui' => GravityView_Compatibility::is_valid(), |
93 | 93 | 'show_in_menu' => GravityView_Compatibility::is_valid(), |
94 | 94 | 'show_in_nav_menus' => true, |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @since 1.7.3 |
102 | 102 | * @param boolean False: don't have frontend archive; True: yes, have archive. Default: false |
103 | 103 | */ |
104 | - 'has_archive' => apply_filters( 'gravityview_has_archive', false ), |
|
104 | + 'has_archive' => apply_filters('gravityview_has_archive', false), |
|
105 | 105 | 'exclude_from_search' => true, |
106 | 106 | 'rewrite' => array( |
107 | 107 | /** |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | * @see http://docs.gravityview.co/article/62-changing-the-view-slug |
110 | 110 | * @param string $slug The slug shown in the URL |
111 | 111 | */ |
112 | - 'slug' => apply_filters( 'gravityview_slug', 'view' ) |
|
112 | + 'slug' => apply_filters('gravityview_slug', 'view') |
|
113 | 113 | ), |
114 | 114 | 'capability_type' => 'gravityview', |
115 | 115 | 'map_meta_cap' => true, |
116 | 116 | ); |
117 | 117 | |
118 | - register_post_type( 'gravityview', $args ); |
|
118 | + register_post_type('gravityview', $args); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $endpoint = self::get_entry_var_name(); |
132 | 132 | |
133 | 133 | //add_permastruct( "{$endpoint}", $endpoint.'/%'.$endpoint.'%/?', true); |
134 | - add_rewrite_endpoint( "{$endpoint}", EP_ALL ); |
|
134 | + add_rewrite_endpoint("{$endpoint}", EP_ALL); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * @filter `gravityview_directory_endpoint` Change the slug used for single entries |
148 | 148 | * @param[in,out] string $endpoint Slug to use when accessing single entry. Default: `entry` |
149 | 149 | */ |
150 | - $endpoint = apply_filters( 'gravityview_directory_endpoint', 'entry' ); |
|
150 | + $endpoint = apply_filters('gravityview_directory_endpoint', 'entry'); |
|
151 | 151 | |
152 | - return sanitize_title( $endpoint ); |
|
152 | + return sanitize_title($endpoint); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -159,20 +159,20 @@ discard block |
||
159 | 159 | */ |
160 | 160 | static function no_views_text() { |
161 | 161 | |
162 | - if( !class_exists( 'GravityView_Admin' ) ) { |
|
163 | - require_once( GRAVITYVIEW_DIR .'includes/class-admin.php' ); |
|
162 | + if (!class_exists('GravityView_Admin')) { |
|
163 | + require_once(GRAVITYVIEW_DIR.'includes/class-admin.php'); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | // Floaty the astronaut |
167 | 167 | $image = GravityView_Admin::get_floaty(); |
168 | 168 | |
169 | - if( GVCommon::has_cap( 'edit_gravityviews' ) ) { |
|
170 | - $output = sprintf( esc_attr__( "%sYou don't have any active views. Let’s go %screate one%s!%s\n\nIf you feel like you're lost in space and need help getting started, check out the %sGetting Started%s page.", 'gravityview' ), '<h3>', '<a href="' . admin_url( 'post-new.php?post_type=gravityview' ) . '">', '</a>', '</h3>', '<a href="' . admin_url( 'edit.php?post_type=gravityview&page=gv-getting-started' ) . '">', '</a>' ); |
|
169 | + if (GVCommon::has_cap('edit_gravityviews')) { |
|
170 | + $output = sprintf(esc_attr__("%sYou don't have any active views. Let’s go %screate one%s!%s\n\nIf you feel like you're lost in space and need help getting started, check out the %sGetting Started%s page.", 'gravityview'), '<h3>', '<a href="'.admin_url('post-new.php?post_type=gravityview').'">', '</a>', '</h3>', '<a href="'.admin_url('edit.php?post_type=gravityview&page=gv-getting-started').'">', '</a>'); |
|
171 | 171 | } else { |
172 | - $output = esc_attr__( 'There are no active Views', 'gravityview' ); |
|
172 | + $output = esc_attr__('There are no active Views', 'gravityview'); |
|
173 | 173 | } |
174 | 174 | |
175 | - return $image . wpautop( $output ); |
|
175 | + return $image.wpautop($output); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * @param mixed $form_id |
22 | 22 | * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms |
23 | 23 | */ |
24 | -function gravityview_get_form( $form_id ) { |
|
25 | - return GVCommon::get_form( $form_id ); |
|
24 | +function gravityview_get_form($form_id) { |
|
25 | + return GVCommon::get_form($form_id); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * @param int|string $entry_slug Entry slug |
33 | 33 | * @return array Gravity Forms form array |
34 | 34 | */ |
35 | -function gravityview_get_form_from_entry_id( $entry_slug ) { |
|
36 | - return GVCommon::get_form_from_entry_id( $entry_slug ); |
|
35 | +function gravityview_get_form_from_entry_id($entry_slug) { |
|
36 | + return GVCommon::get_form_from_entry_id($entry_slug); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string|array $form_id (default: '') or $form object |
57 | 57 | * @return array |
58 | 58 | */ |
59 | -function gravityview_get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
|
60 | - return GVCommon::get_form_fields( $form, $add_default_properties, $include_parent_field ); |
|
59 | +function gravityview_get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true) { |
|
60 | + return GVCommon::get_form_fields($form, $add_default_properties, $include_parent_field); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @param string $form_id (default: '') |
66 | 66 | * @return array |
67 | 67 | */ |
68 | -function gravityview_get_entry_meta( $form_id, $only_default_column = true ) { |
|
69 | - return GVCommon::get_entry_meta( $form_id, $only_default_column ); |
|
68 | +function gravityview_get_entry_meta($form_id, $only_default_column = true) { |
|
69 | + return GVCommon::get_entry_meta($form_id, $only_default_column); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @since 1.1.6 |
78 | 78 | * @return array Array of entry IDs |
79 | 79 | */ |
80 | -function gravityview_get_entry_ids( $form_id, $search_criteria = array() ) { |
|
81 | - return GVCommon::get_entry_ids( $form_id, $search_criteria ); |
|
80 | +function gravityview_get_entry_ids($form_id, $search_criteria = array()) { |
|
81 | + return GVCommon::get_entry_ids($form_id, $search_criteria); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @param mixed &$total (default: null) |
94 | 94 | * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays |
95 | 95 | */ |
96 | -function gravityview_get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { |
|
97 | - return GVCommon::get_entries( $form_ids, $passed_criteria, $total ); |
|
96 | +function gravityview_get_entries($form_ids = null, $passed_criteria = null, &$total = null) { |
|
97 | + return GVCommon::get_entries($form_ids, $passed_criteria, $total); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true {@since 1.14} |
109 | 109 | * @return array|boolean |
110 | 110 | */ |
111 | -function gravityview_get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) { |
|
112 | - return GVCommon::get_entry( $entry_slug, $force_allow_ids, $check_entry_display ); |
|
111 | +function gravityview_get_entry($entry_slug, $force_allow_ids = false, $check_entry_display = true) { |
|
112 | + return GVCommon::get_entry($entry_slug, $force_allow_ids, $check_entry_display); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @param mixed $field_id |
121 | 121 | * @return string |
122 | 122 | */ |
123 | -function gravityview_get_field_label( $form, $field_id ) { |
|
124 | - return GVCommon::get_field_label( $form, $field_id ); |
|
123 | +function gravityview_get_field_label($form, $field_id) { |
|
124 | + return GVCommon::get_field_label($form, $field_id); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | * @param string|int $field_id |
138 | 138 | * @return array |
139 | 139 | */ |
140 | -function gravityview_get_field( $form, $field_id ) { |
|
141 | - return GVCommon::get_field( $form, $field_id ); |
|
140 | +function gravityview_get_field($form, $field_id) { |
|
141 | + return GVCommon::get_field($form, $field_id); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -151,16 +151,16 @@ discard block |
||
151 | 151 | * @param WP_Post $post WordPress post object |
152 | 152 | * @return boolean True: yep, GravityView; No: not! |
153 | 153 | */ |
154 | -function has_gravityview_shortcode( $post = NULL ) { |
|
155 | - return GVCommon::has_gravityview_shortcode( $post ); |
|
154 | +function has_gravityview_shortcode($post = NULL) { |
|
155 | + return GVCommon::has_gravityview_shortcode($post); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Placeholder until the recursive has_shortcode() patch is merged |
160 | 160 | * @see https://core.trac.wordpress.org/ticket/26343#comment:10 |
161 | 161 | */ |
162 | -function gravityview_has_shortcode_r( $content, $tag = 'gravityview' ) { |
|
163 | - return GVCommon::has_shortcode_r( $content, $tag ); |
|
162 | +function gravityview_has_shortcode_r($content, $tag = 'gravityview') { |
|
163 | + return GVCommon::has_shortcode_r($content, $tag); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param int $form_id Gravity Forms form ID |
169 | 169 | * @return array Array with view details |
170 | 170 | */ |
171 | -function gravityview_get_connected_views( $form_id ) { |
|
172 | - return GVCommon::get_connected_views( $form_id ); |
|
171 | +function gravityview_get_connected_views($form_id) { |
|
172 | + return GVCommon::get_connected_views($form_id); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return int |
181 | 181 | */ |
182 | -function gravityview_get_form_id( $view_id ) { |
|
183 | - return GVCommon::get_meta_form_id( $view_id ); |
|
182 | +function gravityview_get_form_id($view_id) { |
|
183 | + return GVCommon::get_meta_form_id($view_id); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return string GravityView_Template::template_id value. Empty string if not. |
194 | 194 | */ |
195 | -function gravityview_get_template_id( $post_id ) { |
|
196 | - return GVCommon::get_meta_template_id( $post_id ); |
|
195 | +function gravityview_get_template_id($post_id) { |
|
196 | + return GVCommon::get_meta_template_id($post_id); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | * @param int $post_id View ID |
204 | 204 | * @return array Associative array of settings with plugin defaults used if not set by the View |
205 | 205 | */ |
206 | -function gravityview_get_template_settings( $post_id ) { |
|
207 | - return GVCommon::get_template_settings( $post_id ); |
|
206 | +function gravityview_get_template_settings($post_id) { |
|
207 | + return GVCommon::get_template_settings($post_id); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | * @param string $key Key for the setting |
217 | 217 | * @return mixed|null Setting value, or NULL if not set. |
218 | 218 | */ |
219 | -function gravityview_get_template_setting( $post_id, $key ) { |
|
220 | - return GVCommon::get_template_setting( $post_id, $key ); |
|
219 | +function gravityview_get_template_setting($post_id, $key) { |
|
220 | + return GVCommon::get_template_setting($post_id, $key); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @filter `gravityview_register_directory_template` Fetch available View templates |
232 | 232 | * @param array $templates Templates to show |
233 | 233 | */ |
234 | - $templates = apply_filters( 'gravityview_register_directory_template', array() ); |
|
234 | + $templates = apply_filters('gravityview_register_directory_template', array()); |
|
235 | 235 | |
236 | 236 | return $templates; |
237 | 237 | } |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @param int $post_id View ID |
267 | 267 | * @return array Multi-array of fields with first level being the field zones. See code comment. |
268 | 268 | */ |
269 | -function gravityview_get_directory_fields( $post_id ) { |
|
270 | - return GVCommon::get_directory_fields( $post_id ); |
|
269 | +function gravityview_get_directory_fields($post_id) { |
|
270 | + return GVCommon::get_directory_fields($post_id); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @param string $current Field ID of field used to sort |
279 | 279 | * @return string html |
280 | 280 | */ |
281 | -function gravityview_get_sortable_fields( $formid, $current = '' ) { |
|
282 | - return GVCommon::get_sortable_fields( $formid, $current ); |
|
281 | +function gravityview_get_sortable_fields($formid, $current = '') { |
|
282 | + return GVCommon::get_sortable_fields($formid, $current); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param mixed $field_id Field ID or Field array |
290 | 290 | * @return string field type |
291 | 291 | */ |
292 | -function gravityview_get_field_type( $form = null , $field_id = '' ) { |
|
293 | - return GVCommon::get_field_type( $form, $field_id ); |
|
292 | +function gravityview_get_field_type($form = null, $field_id = '') { |
|
293 | + return GVCommon::get_field_type($form, $field_id); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -302,15 +302,15 @@ discard block |
||
302 | 302 | * @param array $atts (default: array()) |
303 | 303 | * @return string HTML of the output. Empty string if $view_id is empty. |
304 | 304 | */ |
305 | -function get_gravityview( $view_id = '', $atts = array() ) { |
|
306 | - if( !empty( $view_id ) ) { |
|
305 | +function get_gravityview($view_id = '', $atts = array()) { |
|
306 | + if (!empty($view_id)) { |
|
307 | 307 | $atts['id'] = $view_id; |
308 | - $args = wp_parse_args( $atts, GravityView_View_Data::get_default_args() ); |
|
308 | + $args = wp_parse_args($atts, GravityView_View_Data::get_default_args()); |
|
309 | 309 | $GravityView_frontend = GravityView_frontend::getInstance(); |
310 | - $GravityView_frontend->setGvOutputData( GravityView_View_Data::getInstance( $view_id ) ); |
|
311 | - $GravityView_frontend->set_context_view_id( $view_id ); |
|
310 | + $GravityView_frontend->setGvOutputData(GravityView_View_Data::getInstance($view_id)); |
|
311 | + $GravityView_frontend->set_context_view_id($view_id); |
|
312 | 312 | $GravityView_frontend->set_entry_data(); |
313 | - return $GravityView_frontend->render_view( $args ); |
|
313 | + return $GravityView_frontend->render_view($args); |
|
314 | 314 | } |
315 | 315 | return ''; |
316 | 316 | } |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param array $atts (default: array()) |
324 | 324 | * @return void |
325 | 325 | */ |
326 | -function the_gravityview( $view_id = '', $atts = array() ) { |
|
327 | - echo get_gravityview( $view_id, $atts ); |
|
326 | +function the_gravityview($view_id = '', $atts = array()) { |
|
327 | + echo get_gravityview($view_id, $atts); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -345,17 +345,17 @@ discard block |
||
345 | 345 | * @param array $form Gravity Forms form |
346 | 346 | * @param array $view_fields GravityView fields array |
347 | 347 | */ |
348 | -function gravityview_view_has_single_checkbox_or_radio( $form, $view_fields ) { |
|
348 | +function gravityview_view_has_single_checkbox_or_radio($form, $view_fields) { |
|
349 | 349 | |
350 | - if( $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
350 | + if ($form_fields = GFFormsModel::get_fields_by_type($form, array('checkbox', 'radio'))) { |
|
351 | 351 | |
352 | 352 | /** @var GF_Field_Radio|GF_Field_Checkbox $form_field */ |
353 | - foreach( $form_fields as $form_field ) { |
|
353 | + foreach ($form_fields as $form_field) { |
|
354 | 354 | $field_id = $form_field->id; |
355 | - foreach( $view_fields as $zone ) { |
|
356 | - foreach( $zone as $field ) { |
|
355 | + foreach ($view_fields as $zone) { |
|
356 | + foreach ($zone as $field) { |
|
357 | 357 | // If it's an input, not the parent and the parent ID matches a checkbox or radio |
358 | - if( ( strpos( $field['id'], '.' ) > 0 ) && floor( $field['id'] ) === floor( $field_id ) ) { |
|
358 | + if ((strpos($field['id'], '.') > 0) && floor($field['id']) === floor($field_id)) { |
|
359 | 359 | return true; |
360 | 360 | } |
361 | 361 | } |
@@ -5,4 +5,4 @@ |
||
5 | 5 | * @deprecated 1.7.5 |
6 | 6 | */ |
7 | 7 | |
8 | -include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' ); |
|
8 | +include_once(GRAVITYVIEW_DIR.'includes/widgets/class-gravityview-widget.php'); |