@@ -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 |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @param string $prevent_multiple_instances |
71 | 71 | */ |
72 | - public function __construct( $prevent_multiple_instances = '' ) { |
|
72 | + public function __construct($prevent_multiple_instances = '') { |
|
73 | 73 | |
74 | - if( $prevent_multiple_instances === 'get_instance' ) { |
|
74 | + if ($prevent_multiple_instances === 'get_instance') { |
|
75 | 75 | return parent::__construct(); |
76 | 76 | } |
77 | 77 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public static function get_instance() { |
85 | 85 | |
86 | - if( empty( self::$instance ) ) { |
|
87 | - self::$instance = new self( 'get_instance' ); |
|
86 | + if (empty(self::$instance)) { |
|
87 | + self::$instance = new self('get_instance'); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | return self::$instance; |
@@ -100,21 +100,21 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return bool |
102 | 102 | */ |
103 | - public function current_user_can_any( $caps ) { |
|
103 | + public function current_user_can_any($caps) { |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Prevent Gravity Forms from showing the uninstall tab on the settings page |
107 | 107 | * @hack |
108 | 108 | */ |
109 | - if( $caps === $this->_capabilities_uninstall ) { |
|
109 | + if ($caps === $this->_capabilities_uninstall) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - if( empty( $caps ) ) { |
|
114 | - $caps = array( 'gravityview_full_access' ); |
|
113 | + if (empty($caps)) { |
|
114 | + $caps = array('gravityview_full_access'); |
|
115 | 115 | } |
116 | 116 | |
117 | - return GVCommon::has_cap( $caps ); |
|
117 | + return GVCommon::has_cap($caps); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | |
131 | 131 | $this->license_key_notice(); |
132 | 132 | |
133 | - add_filter( 'gform_addon_app_settings_menu_gravityview', array( $this, 'modify_app_settings_menu_title' ) ); |
|
133 | + add_filter('gform_addon_app_settings_menu_gravityview', array($this, 'modify_app_settings_menu_title')); |
|
134 | 134 | |
135 | 135 | /** @since 1.7.6 */ |
136 | - add_action('network_admin_menu', array( $this, 'add_network_menu' ) ); |
|
136 | + add_action('network_admin_menu', array($this, 'add_network_menu')); |
|
137 | 137 | |
138 | 138 | parent::init_admin(); |
139 | 139 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return array |
147 | 147 | */ |
148 | - public function modify_app_settings_menu_title( $setting_tabs ) { |
|
148 | + public function modify_app_settings_menu_title($setting_tabs) { |
|
149 | 149 | |
150 | - $setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview'); |
|
150 | + $setting_tabs[0]['label'] = __('GravityView Settings', 'gravityview'); |
|
151 | 151 | |
152 | 152 | return $setting_tabs; |
153 | 153 | } |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | */ |
165 | 165 | private function _load_license_handler() { |
166 | 166 | |
167 | - if( !empty( $this->License_Handler ) ) { |
|
167 | + if (!empty($this->License_Handler)) { |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gv-license-handler.php'); |
|
171 | + require_once(GRAVITYVIEW_DIR.'includes/class-gv-license-handler.php'); |
|
172 | 172 | |
173 | - $this->License_Handler = GV_License_Handler::get_instance( $this ); |
|
173 | + $this->License_Handler = GV_License_Handler::get_instance($this); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | function license_key_notice() { |
181 | 181 | |
182 | 182 | // Show license notice on all GV pages, except for settings page |
183 | - if( gravityview_is_admin_page( '', 'settings' ) ) { |
|
183 | + if (gravityview_is_admin_page('', 'settings')) { |
|
184 | 184 | return; |
185 | 185 | } |
186 | 186 | |
187 | 187 | $license_status = self::getSetting('license_key_status'); |
188 | 188 | $license_id = self::getSetting('license_key'); |
189 | - $license_id = empty( $license_id ) ? 'license' : $license_id; |
|
189 | + $license_id = empty($license_id) ? 'license' : $license_id; |
|
190 | 190 | |
191 | 191 | $message = esc_html__('Your GravityView license %s. This means you’re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview'); |
192 | 192 | $title = __('Inactive License', 'gravityview'); |
193 | 193 | $status = ''; |
194 | - switch ( $license_status ) { |
|
194 | + switch ($license_status) { |
|
195 | 195 | case 'invalid': |
196 | 196 | $title = __('Invalid License', 'gravityview'); |
197 | 197 | $status = __('is invalid', 'gravityview'); |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | break; |
209 | 209 | } |
210 | 210 | $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice'; |
211 | - $message = sprintf( $message, $status, "\n\n".'<a href="'.admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ).'" class="button button-primary">', '</a>', '<a href="'.esc_url( $url ).'" class="button button-secondary">', '</a>' ); |
|
212 | - if( !empty( $status ) ) { |
|
213 | - GravityView_Admin_Notices::add_notice( array( |
|
211 | + $message = sprintf($message, $status, "\n\n".'<a href="'.admin_url('edit.php?post_type=gravityview&page=gravityview_settings').'" class="button button-primary">', '</a>', '<a href="'.esc_url($url).'" class="button button-secondary">', '</a>'); |
|
212 | + if (!empty($status)) { |
|
213 | + GravityView_Admin_Notices::add_notice(array( |
|
214 | 214 | 'message' => $message, |
215 | 215 | 'class' => 'updated', |
216 | 216 | 'title' => $title, |
217 | - 'dismiss' => sha1( $license_status.'_'.$license_id ), |
|
217 | + 'dismiss' => sha1($license_status.'_'.$license_id), |
|
218 | 218 | )); |
219 | 219 | } |
220 | 220 | } |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | |
230 | 230 | $styles[] = array( |
231 | 231 | 'handle' => 'gravityview_settings', |
232 | - 'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ), |
|
232 | + 'src' => plugins_url('assets/css/admin-settings.css', GRAVITYVIEW_FILE), |
|
233 | 233 | 'version' => GravityView_Plugin::version, |
234 | 234 | "deps" => array( |
235 | 235 | 'gaddon_form_settings_css' |
236 | 236 | ), |
237 | 237 | 'enqueue' => array( |
238 | - array( 'admin_page' => array( |
|
238 | + array('admin_page' => array( |
|
239 | 239 | 'app_settings' |
240 | - ) ), |
|
240 | + )), |
|
241 | 241 | ) |
242 | 242 | ); |
243 | 243 | |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | * @return void |
251 | 251 | */ |
252 | 252 | public function add_network_menu() { |
253 | - if( GravityView_Plugin::is_network_activated() ) { |
|
254 | - add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' ); |
|
253 | + if (GravityView_Plugin::is_network_activated()) { |
|
254 | + add_menu_page(__('Settings', 'gravityview'), __('GravityView', 'gravityview'), $this->_capabilities_app_settings, "{$this->_slug}_settings", array($this, 'app_tab_page'), 'none'); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
@@ -267,17 +267,17 @@ discard block |
||
267 | 267 | * If multisite and not network admin, we don't want the settings to show. |
268 | 268 | * @since 1.7.6 |
269 | 269 | */ |
270 | - $show_submenu = !is_multisite() || is_main_site() || !GravityView_Plugin::is_network_activated() || ( is_network_admin() && GravityView_Plugin::is_network_activated() ); |
|
270 | + $show_submenu = !is_multisite() || is_main_site() || !GravityView_Plugin::is_network_activated() || (is_network_admin() && GravityView_Plugin::is_network_activated()); |
|
271 | 271 | |
272 | 272 | /** |
273 | 273 | * Override whether to show the Settings menu on a per-blog basis. |
274 | 274 | * @since 1.7.6 |
275 | 275 | * @param bool $hide_if_network_activated Default: true |
276 | 276 | */ |
277 | - $show_submenu = apply_filters( 'gravityview/show-settings-menu', $show_submenu ); |
|
277 | + $show_submenu = apply_filters('gravityview/show-settings-menu', $show_submenu); |
|
278 | 278 | |
279 | - if( $show_submenu ) { |
|
280 | - add_submenu_page( 'edit.php?post_type=gravityview', __( 'Settings', 'gravityview' ), __( 'Settings', 'gravityview' ), $this->_capabilities_app_settings, $this->_slug . '_settings', array( $this, 'app_tab_page' ) ); |
|
279 | + if ($show_submenu) { |
|
280 | + add_submenu_page('edit.php?post_type=gravityview', __('Settings', 'gravityview'), __('Settings', 'gravityview'), $this->_capabilities_app_settings, $this->_slug.'_settings', array($this, 'app_tab_page')); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
@@ -302,20 +302,20 @@ discard block |
||
302 | 302 | * @inheritDoc |
303 | 303 | * @access public |
304 | 304 | */ |
305 | - public function get_app_setting( $setting_name ) { |
|
305 | + public function get_app_setting($setting_name) { |
|
306 | 306 | |
307 | 307 | /** |
308 | 308 | * Backward compatibility with Redux |
309 | 309 | */ |
310 | - if( $setting_name === 'license' ) { |
|
310 | + if ($setting_name === 'license') { |
|
311 | 311 | return array( |
312 | - 'license' => parent::get_app_setting( 'license_key' ), |
|
313 | - 'status' => parent::get_app_setting( 'license_key_status' ), |
|
314 | - 'response' => parent::get_app_setting( 'license_key_response' ), |
|
312 | + 'license' => parent::get_app_setting('license_key'), |
|
313 | + 'status' => parent::get_app_setting('license_key_status'), |
|
314 | + 'response' => parent::get_app_setting('license_key_response'), |
|
315 | 315 | ); |
316 | 316 | } |
317 | 317 | |
318 | - return parent::get_app_setting( $setting_name ); |
|
318 | + return parent::get_app_setting($setting_name); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @return array |
331 | 331 | */ |
332 | 332 | public function get_app_settings() { |
333 | - return get_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $this->get_default_settings() ); |
|
333 | + return get_option('gravityformsaddon_'.$this->_slug.'_app_settings', $this->get_default_settings()); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @return boolean False if value was not updated and true if value was updated. |
345 | 345 | */ |
346 | - public function update_app_settings( $settings ) { |
|
347 | - return update_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $settings ); |
|
346 | + public function update_app_settings($settings) { |
|
347 | + return update_option('gravityformsaddon_'.$this->_slug.'_app_settings', $settings); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -352,8 +352,8 @@ discard block |
||
352 | 352 | * @inheritDoc |
353 | 353 | * @access public |
354 | 354 | */ |
355 | - public function set_field_error( $field, $error_message = '' ) { |
|
356 | - parent::set_field_error( $field, $error_message ); |
|
355 | + public function set_field_error($field, $error_message = '') { |
|
356 | + parent::set_field_error($field, $error_message); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -363,15 +363,15 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return string |
365 | 365 | */ |
366 | - protected function settings_edd_license( $field, $echo = true ) { |
|
366 | + protected function settings_edd_license($field, $echo = true) { |
|
367 | 367 | |
368 | - $text = self::settings_text( $field, false ); |
|
368 | + $text = self::settings_text($field, false); |
|
369 | 369 | |
370 | - $activation = $this->License_Handler->settings_edd_license_activation( $field, false ); |
|
370 | + $activation = $this->License_Handler->settings_edd_license_activation($field, false); |
|
371 | 371 | |
372 | - $return = $text . $activation; |
|
372 | + $return = $text.$activation; |
|
373 | 373 | |
374 | - if( $echo ) { |
|
374 | + if ($echo) { |
|
375 | 375 | echo $return; |
376 | 376 | } |
377 | 377 | |
@@ -396,32 +396,32 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return string The HTML |
398 | 398 | */ |
399 | - public function settings_submit( $field, $echo = true ) { |
|
399 | + public function settings_submit($field, $echo = true) { |
|
400 | 400 | |
401 | - $field['type'] = ( isset($field['type']) && in_array( $field['type'], array('submit','reset','button') ) ) ? $field['type'] : 'submit'; |
|
401 | + $field['type'] = (isset($field['type']) && in_array($field['type'], array('submit', 'reset', 'button'))) ? $field['type'] : 'submit'; |
|
402 | 402 | |
403 | - $attributes = $this->get_field_attributes( $field ); |
|
404 | - $default_value = rgar( $field, 'value' ) ? rgar( $field, 'value' ) : rgar( $field, 'default_value' ); |
|
405 | - $value = $this->get_setting( $field['name'], $default_value ); |
|
403 | + $attributes = $this->get_field_attributes($field); |
|
404 | + $default_value = rgar($field, 'value') ? rgar($field, 'value') : rgar($field, 'default_value'); |
|
405 | + $value = $this->get_setting($field['name'], $default_value); |
|
406 | 406 | |
407 | 407 | |
408 | - $attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton'; |
|
409 | - $name = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_'.$field['name']; |
|
408 | + $attributes['class'] = isset($attributes['class']) ? esc_attr($attributes['class']) : 'button-primary gfbutton'; |
|
409 | + $name = ($field['name'] === 'gform-settings-save') ? $field['name'] : '_gaddon_setting_'.$field['name']; |
|
410 | 410 | |
411 | - if ( empty( $value ) ) { |
|
412 | - $value = __( 'Update Settings', 'gravityview' ); |
|
411 | + if (empty($value)) { |
|
412 | + $value = __('Update Settings', 'gravityview'); |
|
413 | 413 | } |
414 | 414 | |
415 | - $attributes = $this->get_field_attributes( $field ); |
|
415 | + $attributes = $this->get_field_attributes($field); |
|
416 | 416 | |
417 | 417 | $html = '<input |
418 | - type="' . $field['type'] . '" |
|
419 | - name="' . esc_attr( $name ) . '" |
|
420 | - value="' . $value . '" ' . |
|
421 | - implode( ' ', $attributes ) . |
|
418 | + type="' . $field['type'].'" |
|
419 | + name="' . esc_attr($name).'" |
|
420 | + value="' . $value.'" '. |
|
421 | + implode(' ', $attributes). |
|
422 | 422 | ' />'; |
423 | 423 | |
424 | - if ( $echo ) { |
|
424 | + if ($echo) { |
|
425 | 425 | echo $html; |
426 | 426 | } |
427 | 427 | |
@@ -436,17 +436,17 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @return string |
438 | 438 | */ |
439 | - public function settings_save( $field, $echo = true ) { |
|
439 | + public function settings_save($field, $echo = true) { |
|
440 | 440 | $field['type'] = 'submit'; |
441 | 441 | $field['name'] = 'gform-settings-save'; |
442 | - $field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton'; |
|
442 | + $field['class'] = isset($field['class']) ? $field['class'] : 'button-primary gfbutton'; |
|
443 | 443 | |
444 | - if ( ! rgar( $field, 'value' ) ) |
|
445 | - $field['value'] = __( 'Update Settings', 'gravityview' ); |
|
444 | + if (!rgar($field, 'value')) |
|
445 | + $field['value'] = __('Update Settings', 'gravityview'); |
|
446 | 446 | |
447 | - $output = $this->settings_submit( $field, false ); |
|
447 | + $output = $this->settings_submit($field, false); |
|
448 | 448 | |
449 | - if( $echo ) { |
|
449 | + if ($echo) { |
|
450 | 450 | echo $output; |
451 | 451 | } |
452 | 452 | |
@@ -458,22 +458,22 @@ discard block |
||
458 | 458 | * @inheritDoc |
459 | 459 | * @param $field array |
460 | 460 | */ |
461 | - public function single_setting_label( $field ) { |
|
461 | + public function single_setting_label($field) { |
|
462 | 462 | |
463 | 463 | echo $field['label']; |
464 | 464 | |
465 | 465 | |
466 | - if ( isset( $field['tooltip'] ) ) { |
|
467 | - echo ' ' . gform_tooltip( $field['tooltip'], rgar( $field, 'tooltip_class' ), true ); |
|
466 | + if (isset($field['tooltip'])) { |
|
467 | + echo ' '.gform_tooltip($field['tooltip'], rgar($field, 'tooltip_class'), true); |
|
468 | 468 | } |
469 | 469 | |
470 | - if ( rgar( $field, 'required' ) ) { |
|
471 | - echo ' ' . $this->get_required_indicator( $field ); |
|
470 | + if (rgar($field, 'required')) { |
|
471 | + echo ' '.$this->get_required_indicator($field); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | // Added by GravityView |
475 | - if ( isset( $field['description'] ) ) { |
|
476 | - echo '<span class="description">'. $field['description'] .'</span>'; |
|
475 | + if (isset($field['description'])) { |
|
476 | + echo '<span class="description">'.$field['description'].'</span>'; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | } |
@@ -489,10 +489,10 @@ discard block |
||
489 | 489 | |
490 | 490 | $defaults = array( |
491 | 491 | // Set the default license in wp-config.php |
492 | - 'license_key' => defined( 'GRAVITYVIEW_LICENSE_KEY' ) ? GRAVITYVIEW_LICENSE_KEY : '', |
|
492 | + 'license_key' => defined('GRAVITYVIEW_LICENSE_KEY') ? GRAVITYVIEW_LICENSE_KEY : '', |
|
493 | 493 | 'license_key_response' => '', |
494 | 494 | 'license_key_status' => '', |
495 | - 'support-email' => get_bloginfo( 'admin_email' ), |
|
495 | + 'support-email' => get_bloginfo('admin_email'), |
|
496 | 496 | 'no-conflict-mode' => '0', |
497 | 497 | 'support_port' => '1', |
498 | 498 | 'delete-on-uninstall' => '0', |
@@ -510,10 +510,10 @@ discard block |
||
510 | 510 | */ |
511 | 511 | public function maybe_save_app_settings() { |
512 | 512 | |
513 | - if ( $this->is_save_postback() ) { |
|
514 | - if ( ! GVCommon::has_cap( 'gravityview_edit_settings' ) ) { |
|
513 | + if ($this->is_save_postback()) { |
|
514 | + if (!GVCommon::has_cap('gravityview_edit_settings')) { |
|
515 | 515 | $_POST = array(); // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't |
516 | - GFCommon::add_error_message( __( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ) ); |
|
516 | + GFCommon::add_error_message(__('You don\'t have the ability to edit plugin settings.', 'gravityview')); |
|
517 | 517 | return; |
518 | 518 | } |
519 | 519 | } |
@@ -532,10 +532,10 @@ discard block |
||
532 | 532 | |
533 | 533 | // If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response), |
534 | 534 | // then we assume it's changed. If it's changed, unset the status and the previous response. |
535 | - if( isset( $posted_settings['license_key'] ) && isset( $posted_settings['license_key_response']['license_key'] ) && $posted_settings['license_key'] !== $posted_settings['license_key_response']['license_key'] ) { |
|
536 | - unset( $posted_settings['license_key_response'] ); |
|
537 | - unset( $posted_settings['license_key_status'] ); |
|
538 | - GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) ); |
|
535 | + if (isset($posted_settings['license_key']) && isset($posted_settings['license_key_response']['license_key']) && $posted_settings['license_key'] !== $posted_settings['license_key_response']['license_key']) { |
|
536 | + unset($posted_settings['license_key_response']); |
|
537 | + unset($posted_settings['license_key_status']); |
|
538 | + GFCommon::add_error_message(__('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview')); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | return $posted_settings; |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @return string - Returns markup of the required indicator symbol |
551 | 551 | */ |
552 | - public function get_required_indicator( $field ) { |
|
553 | - return '<span class="required" title="' . esc_attr__( 'Required', 'gravityview' ) . '">*</span>'; |
|
552 | + public function get_required_indicator($field) { |
|
553 | + return '<span class="required" title="'.esc_attr__('Required', 'gravityview').'">*</span>'; |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -561,18 +561,18 @@ discard block |
||
561 | 561 | |
562 | 562 | $default_settings = $this->get_default_settings(); |
563 | 563 | |
564 | - $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
|
564 | + $disabled_attribute = GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled'; |
|
565 | 565 | |
566 | - $fields = apply_filters( 'gravityview_settings_fields', array( |
|
566 | + $fields = apply_filters('gravityview_settings_fields', array( |
|
567 | 567 | array( |
568 | 568 | 'name' => 'license_key', |
569 | 569 | 'required' => true, |
570 | - 'label' => __( 'License Key', 'gravityview' ), |
|
571 | - 'description' => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates & support.', 'gravityview' ), |
|
570 | + 'label' => __('License Key', 'gravityview'), |
|
571 | + 'description' => __('Enter the license key that was sent to you on purchase. This enables plugin updates & support.', 'gravityview'), |
|
572 | 572 | 'type' => 'edd_license', |
573 | 573 | 'data-pending-text' => __('Verifying license…', 'gravityview'), |
574 | 574 | 'default_value' => $default_settings['license_key'], |
575 | - 'class' => ( '' == $this->get_app_setting( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key', |
|
575 | + 'class' => ('' == $this->get_app_setting('license_key')) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key', |
|
576 | 576 | ), |
577 | 577 | array( |
578 | 578 | 'name' => 'license_key_response', |
@@ -589,8 +589,8 @@ discard block |
||
589 | 589 | 'type' => 'text', |
590 | 590 | 'validate' => 'email', |
591 | 591 | 'default_value' => $default_settings['support-email'], |
592 | - 'label' => __( 'Support Email', 'gravityview' ), |
|
593 | - 'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ), |
|
592 | + 'label' => __('Support Email', 'gravityview'), |
|
593 | + 'description' => __('In order to provide responses to your support requests, please provide your email address.', 'gravityview'), |
|
594 | 594 | 'class' => 'code regular-text', |
595 | 595 | ), |
596 | 596 | /** |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | array( |
600 | 600 | 'name' => 'support_port', |
601 | 601 | 'type' => 'radio', |
602 | - 'label' => __( 'Show Support Port?', 'gravityview' ), |
|
602 | + 'label' => __('Show Support Port?', 'gravityview'), |
|
603 | 603 | 'default_value' => $default_settings['support_port'], |
604 | 604 | 'horizontal' => 1, |
605 | 605 | 'choices' => array( |
@@ -612,13 +612,13 @@ discard block |
||
612 | 612 | 'value' => '0', |
613 | 613 | ), |
614 | 614 | ), |
615 | - 'tooltip' => '<p><img src="' . esc_url_raw( plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview') . '</p>', |
|
616 | - 'description' => __( 'Show the Support Port on GravityView pages?', 'gravityview' ), |
|
615 | + 'tooltip' => '<p><img src="'.esc_url_raw(plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE)).'" alt="'.esc_attr__('The Support Port looks like this.', 'gravityview').'" class="alignright" style="max-width:40px; margin:.5em;" />'.esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview').'</p>', |
|
616 | + 'description' => __('Show the Support Port on GravityView pages?', 'gravityview'), |
|
617 | 617 | ), |
618 | 618 | array( |
619 | 619 | 'name' => 'no-conflict-mode', |
620 | 620 | 'type' => 'radio', |
621 | - 'label' => __( 'No-Conflict Mode', 'gravityview' ), |
|
621 | + 'label' => __('No-Conflict Mode', 'gravityview'), |
|
622 | 622 | 'default_value' => $default_settings['no-conflict-mode'], |
623 | 623 | 'horizontal' => 1, |
624 | 624 | 'choices' => array( |
@@ -631,30 +631,30 @@ discard block |
||
631 | 631 | 'value' => '0', |
632 | 632 | ), |
633 | 633 | ), |
634 | - 'description' => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __('If your Edit View tabs are ugly, enable this setting.', 'gravityview'), |
|
634 | + 'description' => __('Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview').' '.__('If your Edit View tabs are ugly, enable this setting.', 'gravityview'), |
|
635 | 635 | ), |
636 | 636 | array( |
637 | 637 | 'name' => 'delete-on-uninstall', |
638 | 638 | 'type' => 'radio', |
639 | - 'label' => __( 'Remove Data on Delete?', 'gravityview' ), |
|
639 | + 'label' => __('Remove Data on Delete?', 'gravityview'), |
|
640 | 640 | 'default_value' => $default_settings['delete-on-uninstall'], |
641 | 641 | 'horizontal' => 1, |
642 | 642 | 'choices' => array( |
643 | 643 | array( |
644 | - 'label' => _x( 'Keep GravityView Data', 'Setting: what to do when uninstalling plugin', 'gravityview' ), |
|
644 | + 'label' => _x('Keep GravityView Data', 'Setting: what to do when uninstalling plugin', 'gravityview'), |
|
645 | 645 | 'value' => '0', |
646 | - 'tooltip' => sprintf( '<h6>%s</h6><p>%s</p>', __( 'Keep GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install the plugin, all GravityView data will be kept. Views, settings, etc. will be untouched.', 'gravityview' ) ), |
|
646 | + 'tooltip' => sprintf('<h6>%s</h6><p>%s</p>', __('Keep GravityView content and settings', 'gravityview'), __('If you delete then re-install the plugin, all GravityView data will be kept. Views, settings, etc. will be untouched.', 'gravityview')), |
|
647 | 647 | ), |
648 | 648 | array( |
649 | - 'label' => _x( 'Permanently Delete', 'Setting: what to do when uninstalling plugin', 'gravityview' ), |
|
649 | + 'label' => _x('Permanently Delete', 'Setting: what to do when uninstalling plugin', 'gravityview'), |
|
650 | 650 | 'value' => 'delete', |
651 | - 'tooltip' => sprintf( '<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __( 'Delete all GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' ), __( 'When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview' ) ), |
|
651 | + 'tooltip' => sprintf('<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __('Delete all GravityView content and settings', 'gravityview'), __('If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview'), __('When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview')), |
|
652 | 652 | ), |
653 | 653 | ), |
654 | - 'description' => sprintf( __( 'Should GravityView content and entry approval status be removed from the site when the GravityView plugin is deleted?', 'gravityview' ), __( 'Permanently Delete', 'gravityview' ) ), |
|
654 | + 'description' => sprintf(__('Should GravityView content and entry approval status be removed from the site when the GravityView plugin is deleted?', 'gravityview'), __('Permanently Delete', 'gravityview')), |
|
655 | 655 | ), |
656 | 656 | |
657 | - ) ); |
|
657 | + )); |
|
658 | 658 | |
659 | 659 | |
660 | 660 | |
@@ -662,21 +662,21 @@ discard block |
||
662 | 662 | * Redux backward compatibility |
663 | 663 | * @since 1.7.4 |
664 | 664 | */ |
665 | - foreach ( $fields as &$field ) { |
|
666 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : rgget('id', $field ); |
|
667 | - $field['label'] = isset( $field['label'] ) ? $field['label'] : rgget('title', $field ); |
|
668 | - $field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : rgget('default', $field ); |
|
669 | - $field['description'] = isset( $field['description'] ) ? $field['description'] : rgget('subtitle', $field ); |
|
670 | - |
|
671 | - if( $disabled_attribute ) { |
|
672 | - $field['disabled'] = $disabled_attribute; |
|
665 | + foreach ($fields as &$field) { |
|
666 | + $field['name'] = isset($field['name']) ? $field['name'] : rgget('id', $field); |
|
667 | + $field['label'] = isset($field['label']) ? $field['label'] : rgget('title', $field); |
|
668 | + $field['default_value'] = isset($field['default_value']) ? $field['default_value'] : rgget('default', $field); |
|
669 | + $field['description'] = isset($field['description']) ? $field['description'] : rgget('subtitle', $field); |
|
670 | + |
|
671 | + if ($disabled_attribute) { |
|
672 | + $field['disabled'] = $disabled_attribute; |
|
673 | 673 | } |
674 | 674 | } |
675 | 675 | |
676 | 676 | |
677 | 677 | $sections = array( |
678 | 678 | array( |
679 | - 'description' => sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ), |
|
679 | + 'description' => sprintf('<span class="version-info description">%s</span>', sprintf(__('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version)), |
|
680 | 680 | 'fields' => $fields, |
681 | 681 | ) |
682 | 682 | ); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | 'type' => 'save', |
688 | 688 | ); |
689 | 689 | |
690 | - if( $disabled_attribute ) { |
|
690 | + if ($disabled_attribute) { |
|
691 | 691 | $button['disabled'] = $disabled_attribute; |
692 | 692 | } |
693 | 693 | |
@@ -703,22 +703,22 @@ discard block |
||
703 | 703 | * </code> |
704 | 704 | * @param array $extension_settings Empty array, ready for extension settings! |
705 | 705 | */ |
706 | - $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() ); |
|
706 | + $extension_sections = apply_filters('gravityview/settings/extension/sections', array()); |
|
707 | 707 | |
708 | 708 | // If there are extensions, add a section for them |
709 | - if ( ! empty( $extension_sections ) ) { |
|
709 | + if (!empty($extension_sections)) { |
|
710 | 710 | |
711 | - if( $disabled_attribute ) { |
|
712 | - foreach ( $extension_sections as &$section ) { |
|
713 | - foreach ( $section['fields'] as &$field ) { |
|
711 | + if ($disabled_attribute) { |
|
712 | + foreach ($extension_sections as &$section) { |
|
713 | + foreach ($section['fields'] as &$field) { |
|
714 | 714 | $field['disabled'] = $disabled_attribute; |
715 | 715 | } |
716 | 716 | } |
717 | 717 | } |
718 | 718 | |
719 | - $k = count( $extension_sections ) - 1 ; |
|
720 | - $extension_sections[ $k ]['fields'][] = $button; |
|
721 | - $sections = array_merge( $sections, $extension_sections ); |
|
719 | + $k = count($extension_sections) - 1; |
|
720 | + $extension_sections[$k]['fields'][] = $button; |
|
721 | + $sections = array_merge($sections, $extension_sections); |
|
722 | 722 | } else { |
723 | 723 | // add the 'update settings' button to the general section |
724 | 724 | $sections[0]['fields'][] = $button; |
@@ -734,8 +734,8 @@ discard block |
||
734 | 734 | * |
735 | 735 | * @return mixed |
736 | 736 | */ |
737 | - static public function getSetting( $key ) { |
|
738 | - return self::get_instance()->get_app_setting( $key ); |
|
737 | + static public function getSetting($key) { |
|
738 | + return self::get_instance()->get_app_setting($key); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | } |
@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | /** If this file is called directly, abort. */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | 18 | |
19 | -if( ! class_exists( 'Gamajo_Template_Loader' ) ) { |
|
20 | - require( GRAVITYVIEW_DIR . 'includes/lib/class-gamajo-template-loader.php' ); |
|
19 | +if (!class_exists('Gamajo_Template_Loader')) { |
|
20 | + require(GRAVITYVIEW_DIR.'includes/lib/class-gamajo-template-loader.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | class GravityView_View extends Gamajo_Template_Loader { |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * Construct the view object |
146 | 146 | * @param array $atts Associative array to set the data of |
147 | 147 | */ |
148 | - function __construct( $atts = array() ) { |
|
148 | + function __construct($atts = array()) { |
|
149 | 149 | |
150 | - $atts = wp_parse_args( $atts, array( |
|
150 | + $atts = wp_parse_args($atts, array( |
|
151 | 151 | 'form_id' => NULL, |
152 | 152 | 'view_id' => NULL, |
153 | 153 | 'fields' => NULL, |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | 'post_id' => NULL, |
156 | 156 | 'form' => NULL, |
157 | 157 | 'atts' => NULL, |
158 | - ) ); |
|
158 | + )); |
|
159 | 159 | |
160 | 160 | foreach ($atts as $key => $value) { |
161 | - if( is_null( $value ) ) { |
|
161 | + if (is_null($value)) { |
|
162 | 162 | continue; |
163 | 163 | } |
164 | 164 | $this->{$key} = $value; |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | |
167 | 167 | |
168 | 168 | // Add granular overrides |
169 | - add_filter( $this->filter_prefix . '_get_template_part', array( $this, 'add_id_specific_templates' ), 10, 3 ); |
|
169 | + add_filter($this->filter_prefix.'_get_template_part', array($this, 'add_id_specific_templates'), 10, 3); |
|
170 | 170 | |
171 | 171 | |
172 | 172 | // widget logic |
173 | - add_action( 'gravityview_before', array( $this, 'render_widget_hooks' ) ); |
|
174 | - add_action( 'gravityview_after', array( $this, 'render_widget_hooks' ) ); |
|
173 | + add_action('gravityview_before', array($this, 'render_widget_hooks')); |
|
174 | + add_action('gravityview_after', array($this, 'render_widget_hooks')); |
|
175 | 175 | |
176 | 176 | /** |
177 | 177 | * Clear the current entry after the loop is done |
178 | 178 | * @since 1.7.3 |
179 | 179 | */ |
180 | - add_action( 'gravityview_footer', array( $this, 'clearCurrentEntry' ), 500 ); |
|
180 | + add_action('gravityview_footer', array($this, 'clearCurrentEntry'), 500); |
|
181 | 181 | |
182 | 182 | self::$instance = &$this; |
183 | 183 | } |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return GravityView_View |
189 | 189 | */ |
190 | - static function getInstance( $passed_post = NULL ) { |
|
190 | + static function getInstance($passed_post = NULL) { |
|
191 | 191 | |
192 | - if( empty( self::$instance ) ) { |
|
193 | - self::$instance = new self( $passed_post ); |
|
192 | + if (empty(self::$instance)) { |
|
193 | + self::$instance = new self($passed_post); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | return self::$instance; |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | * @param string|null $key The key to a specific attribute of the current field |
201 | 201 | * @return array|mixed|null If $key is set and attribute exists at $key, return that. If not set, return NULL. Otherwise, return current field array |
202 | 202 | */ |
203 | - public function getCurrentField( $key = NULL ) { |
|
203 | + public function getCurrentField($key = NULL) { |
|
204 | 204 | |
205 | - if( !empty( $key ) ) { |
|
206 | - if( isset( $this->_current_field[ $key ] ) ) { |
|
207 | - return $this->_current_field[ $key ]; |
|
205 | + if (!empty($key)) { |
|
206 | + if (isset($this->_current_field[$key])) { |
|
207 | + return $this->_current_field[$key]; |
|
208 | 208 | } |
209 | 209 | return NULL; |
210 | 210 | } |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | return $this->_current_field; |
213 | 213 | } |
214 | 214 | |
215 | - public function setCurrentFieldSetting( $key, $value ) { |
|
215 | + public function setCurrentFieldSetting($key, $value) { |
|
216 | 216 | |
217 | - if( !empty( $this->_current_field ) ) { |
|
218 | - $this->_current_field['field_settings'][ $key ] = $value; |
|
217 | + if (!empty($this->_current_field)) { |
|
218 | + $this->_current_field['field_settings'][$key] = $value; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | } |
222 | 222 | |
223 | - public function getCurrentFieldSetting( $key ) { |
|
223 | + public function getCurrentFieldSetting($key) { |
|
224 | 224 | $settings = $this->getCurrentField('field_settings'); |
225 | 225 | |
226 | - if( $settings && !empty( $settings[ $key ] ) ) { |
|
227 | - return $settings[ $key ]; |
|
226 | + if ($settings && !empty($settings[$key])) { |
|
227 | + return $settings[$key]; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | return NULL; |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @param array $passed_field |
235 | 235 | */ |
236 | - public function setCurrentField( $passed_field ) { |
|
236 | + public function setCurrentField($passed_field) { |
|
237 | 237 | |
238 | 238 | $existing_field = $this->getCurrentField(); |
239 | 239 | |
240 | - $set_field = wp_parse_args( $passed_field, $existing_field ); |
|
240 | + $set_field = wp_parse_args($passed_field, $existing_field); |
|
241 | 241 | |
242 | 242 | $this->_current_field = $set_field; |
243 | 243 | |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | * @param string|null $key The key to a specific field in the fields array |
253 | 253 | * @return array|mixed|null If $key is set and field exists at $key, return that. If not set, return NULL. Otherwise, return array of fields. |
254 | 254 | */ |
255 | - public function getAtts( $key = NULL ) { |
|
255 | + public function getAtts($key = NULL) { |
|
256 | 256 | |
257 | - if( !empty( $key ) ) { |
|
258 | - if( isset( $this->atts[ $key ] ) ) { |
|
259 | - return $this->atts[ $key ]; |
|
257 | + if (!empty($key)) { |
|
258 | + if (isset($this->atts[$key])) { |
|
259 | + return $this->atts[$key]; |
|
260 | 260 | } |
261 | 261 | return NULL; |
262 | 262 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | /** |
268 | 268 | * @param array $atts |
269 | 269 | */ |
270 | - public function setAtts( $atts ) { |
|
270 | + public function setAtts($atts) { |
|
271 | 271 | $this->atts = $atts; |
272 | 272 | } |
273 | 273 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | /** |
282 | 282 | * @param array $form |
283 | 283 | */ |
284 | - public function setForm( $form ) { |
|
284 | + public function setForm($form) { |
|
285 | 285 | $this->form = $form; |
286 | 286 | } |
287 | 287 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | /** |
296 | 296 | * @param int|null $post_id |
297 | 297 | */ |
298 | - public function setPostId( $post_id ) { |
|
298 | + public function setPostId($post_id) { |
|
299 | 299 | $this->post_id = $post_id; |
300 | 300 | } |
301 | 301 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | /** |
310 | 310 | * @param string $context |
311 | 311 | */ |
312 | - public function setContext( $context ) { |
|
312 | + public function setContext($context) { |
|
313 | 313 | $this->context = $context; |
314 | 314 | } |
315 | 315 | |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | * @param string|null $key The key to a specific field in the fields array |
318 | 318 | * @return array|mixed|null If $key is set and field exists at $key, return that. If not set, return NULL. Otherwise, return array of fields. |
319 | 319 | */ |
320 | - public function getFields( $key = null ) { |
|
320 | + public function getFields($key = null) { |
|
321 | 321 | |
322 | - $fields = empty( $this->fields ) ? NULL : $this->fields; |
|
322 | + $fields = empty($this->fields) ? NULL : $this->fields; |
|
323 | 323 | |
324 | - if( $fields && !empty( $key ) ) { |
|
325 | - $fields = isset( $fields[ $key ] ) ? $fields[ $key ] : NULL; |
|
324 | + if ($fields && !empty($key)) { |
|
325 | + $fields = isset($fields[$key]) ? $fields[$key] : NULL; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | return $fields; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | /** |
332 | 332 | * @param array $fields |
333 | 333 | */ |
334 | - public function setFields( $fields ) { |
|
334 | + public function setFields($fields) { |
|
335 | 335 | $this->fields = $fields; |
336 | 336 | } |
337 | 337 | |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | * @param string $key The key to a specific field in the fields array |
340 | 340 | * @return array|mixed|null If $key is set and field exists at $key, return that. If not set, return NULL. Otherwise, return array of fields. |
341 | 341 | */ |
342 | - public function getField( $key ) { |
|
342 | + public function getField($key) { |
|
343 | 343 | |
344 | - if( !empty( $key ) ) { |
|
345 | - if( isset( $this->fields[ $key ] ) ) { |
|
346 | - return $this->fields[ $key ]; |
|
344 | + if (!empty($key)) { |
|
345 | + if (isset($this->fields[$key])) { |
|
346 | + return $this->fields[$key]; |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
@@ -354,22 +354,22 @@ discard block |
||
354 | 354 | * @param string $key The key to a specific field in the fields array |
355 | 355 | * @param mixed $value The value to set for the field |
356 | 356 | */ |
357 | - public function setField( $key, $value ) { |
|
358 | - $this->fields[ $key ] = $value; |
|
357 | + public function setField($key, $value) { |
|
358 | + $this->fields[$key] = $value; |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | 362 | * @return int |
363 | 363 | */ |
364 | 364 | public function getViewId() { |
365 | - return absint( $this->view_id ); |
|
365 | + return absint($this->view_id); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
369 | 369 | * @param int $view_id |
370 | 370 | */ |
371 | - public function setViewId( $view_id ) { |
|
372 | - $this->view_id = intval( $view_id ); |
|
371 | + public function setViewId($view_id) { |
|
372 | + $this->view_id = intval($view_id); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | /** |
383 | 383 | * @param int $form_id |
384 | 384 | */ |
385 | - public function setFormId( $form_id ) { |
|
385 | + public function setFormId($form_id) { |
|
386 | 386 | $this->form_id = $form_id; |
387 | 387 | } |
388 | 388 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | /** |
397 | 397 | * @param array $entries |
398 | 398 | */ |
399 | - public function setEntries( $entries ) { |
|
399 | + public function setEntries($entries) { |
|
400 | 400 | $this->entries = $entries; |
401 | 401 | } |
402 | 402 | |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | /** |
411 | 411 | * @param int $total_entries |
412 | 412 | */ |
413 | - public function setTotalEntries( $total_entries ) { |
|
414 | - $this->total_entries = intval( $total_entries ); |
|
413 | + public function setTotalEntries($total_entries) { |
|
414 | + $this->total_entries = intval($total_entries); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | /** |
425 | 425 | * @param array $paging |
426 | 426 | */ |
427 | - public function setPaging( $paging ) { |
|
427 | + public function setPaging($paging) { |
|
428 | 428 | $this->paging = $paging; |
429 | 429 | } |
430 | 430 | |
@@ -446,25 +446,25 @@ discard block |
||
446 | 446 | $page_size = $paging['page_size']; |
447 | 447 | $total = $this->getTotalEntries(); |
448 | 448 | |
449 | - if ( empty( $total ) ) { |
|
450 | - do_action( 'gravityview_log_debug', __METHOD__ . ': No entries. Returning empty array.' ); |
|
449 | + if (empty($total)) { |
|
450 | + do_action('gravityview_log_debug', __METHOD__.': No entries. Returning empty array.'); |
|
451 | 451 | |
452 | 452 | return array(); |
453 | 453 | } |
454 | 454 | |
455 | - $first = empty( $offset ) ? 1 : $offset + 1; |
|
455 | + $first = empty($offset) ? 1 : $offset + 1; |
|
456 | 456 | |
457 | 457 | // If the page size + starting entry is larger than total, the total is the max. |
458 | - $last = ( $offset + $page_size > $total ) ? $total : $offset + $page_size; |
|
458 | + $last = ($offset + $page_size > $total) ? $total : $offset + $page_size; |
|
459 | 459 | |
460 | 460 | /** |
461 | 461 | * @filter `gravityview_pagination_counts` Modify the displayed pagination numbers |
462 | 462 | * @since 1.13 |
463 | 463 | * @param array $counts Array with $first, $last, $total numbers in that order |
464 | 464 | */ |
465 | - list( $first, $last, $total ) = apply_filters( 'gravityview_pagination_counts', array( $first, $last, $total ) ); |
|
465 | + list($first, $last, $total) = apply_filters('gravityview_pagination_counts', array($first, $last, $total)); |
|
466 | 466 | |
467 | - return array( 'first' => (int) $first, 'last' => (int) $last, 'total' => (int) $total ); |
|
467 | + return array('first' => (int)$first, 'last' => (int)$last, 'total' => (int)$total); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | /** |
478 | 478 | * @param array $sorting |
479 | 479 | */ |
480 | - public function setSorting( $sorting ) { |
|
480 | + public function setSorting($sorting) { |
|
481 | 481 | $this->sorting = $sorting; |
482 | 482 | } |
483 | 483 | |
@@ -486,9 +486,9 @@ discard block |
||
486 | 486 | */ |
487 | 487 | public function getBackLinkLabel() { |
488 | 488 | |
489 | - $back_link_label = GravityView_API::replace_variables( $this->back_link_label, $this->getForm(), $this->getCurrentEntry() ); |
|
489 | + $back_link_label = GravityView_API::replace_variables($this->back_link_label, $this->getForm(), $this->getCurrentEntry()); |
|
490 | 490 | |
491 | - $back_link_label = do_shortcode( $back_link_label ); |
|
491 | + $back_link_label = do_shortcode($back_link_label); |
|
492 | 492 | |
493 | 493 | return $back_link_label; |
494 | 494 | } |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | /** |
497 | 497 | * @param string $back_link_label |
498 | 498 | */ |
499 | - public function setBackLinkLabel( $back_link_label ) { |
|
499 | + public function setBackLinkLabel($back_link_label) { |
|
500 | 500 | $this->back_link_label = $back_link_label; |
501 | 501 | } |
502 | 502 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | /** |
511 | 511 | * @param boolean $hide_until_searched |
512 | 512 | */ |
513 | - public function setHideUntilSearched( $hide_until_searched ) { |
|
513 | + public function setHideUntilSearched($hide_until_searched) { |
|
514 | 514 | $this->hide_until_searched = $hide_until_searched; |
515 | 515 | } |
516 | 516 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | /** |
525 | 525 | * @param string $template_part_slug |
526 | 526 | */ |
527 | - public function setTemplatePartSlug( $template_part_slug ) { |
|
527 | + public function setTemplatePartSlug($template_part_slug) { |
|
528 | 528 | $this->template_part_slug = $template_part_slug; |
529 | 529 | } |
530 | 530 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | /** |
539 | 539 | * @param string $template_part_name |
540 | 540 | */ |
541 | - public function setTemplatePartName( $template_part_name ) { |
|
541 | + public function setTemplatePartName($template_part_name) { |
|
542 | 542 | $this->template_part_name = $template_part_name; |
543 | 543 | } |
544 | 544 | |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | */ |
549 | 549 | public function getCurrentEntry() { |
550 | 550 | |
551 | - if( in_array( $this->getContext(), array( 'edit', 'single') ) ) { |
|
551 | + if (in_array($this->getContext(), array('edit', 'single'))) { |
|
552 | 552 | $entries = $this->getEntries(); |
553 | 553 | return $entries[0]; |
554 | 554 | } |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @param array $current_entry |
561 | 561 | * @return void |
562 | 562 | */ |
563 | - public function setCurrentEntry( $current_entry ) { |
|
563 | + public function setCurrentEntry($current_entry) { |
|
564 | 564 | $this->_current_entry = $current_entry; |
565 | 565 | } |
566 | 566 | |
@@ -582,9 +582,9 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @return string|null |
584 | 584 | */ |
585 | - public function renderZone( $zone = '', $atts = array() ) { |
|
585 | + public function renderZone($zone = '', $atts = array()) { |
|
586 | 586 | |
587 | - if( empty( $zone ) ) { |
|
587 | + if (empty($zone)) { |
|
588 | 588 | do_action('gravityview_log_error', 'GravityView_View[renderZone] No zone defined.'); |
589 | 589 | return NULL; |
590 | 590 | } |
@@ -597,32 +597,32 @@ discard block |
||
597 | 597 | 'hide_empty' => $this->getAtts('hide_empty'), |
598 | 598 | ); |
599 | 599 | |
600 | - $final_atts = wp_parse_args( $atts, $defaults ); |
|
600 | + $final_atts = wp_parse_args($atts, $defaults); |
|
601 | 601 | |
602 | 602 | $output = ''; |
603 | 603 | |
604 | 604 | $final_atts['zone_id'] = "{$final_atts['context']}_{$final_atts['slug']}-{$zone}"; |
605 | 605 | |
606 | - $fields = $this->getField( $final_atts['zone_id'] ); |
|
606 | + $fields = $this->getField($final_atts['zone_id']); |
|
607 | 607 | |
608 | 608 | // Backward compatibility |
609 | - if( 'table' === $this->getTemplatePartSlug() ) { |
|
609 | + if ('table' === $this->getTemplatePartSlug()) { |
|
610 | 610 | /** |
611 | 611 | * Modify the fields displayed in the table |
612 | 612 | * @var array |
613 | 613 | */ |
614 | - $fields = apply_filters("gravityview_table_cells", $fields, $this ); |
|
614 | + $fields = apply_filters("gravityview_table_cells", $fields, $this); |
|
615 | 615 | } |
616 | 616 | |
617 | - if( empty( $fields ) ) { |
|
617 | + if (empty($fields)) { |
|
618 | 618 | return NULL; |
619 | 619 | } |
620 | 620 | |
621 | 621 | $field_output = ''; |
622 | - foreach ( $fields as $field ) { |
|
622 | + foreach ($fields as $field) { |
|
623 | 623 | $final_atts['field'] = $field; |
624 | 624 | |
625 | - $field_output .= gravityview_field_output( $final_atts ); |
|
625 | + $field_output .= gravityview_field_output($final_atts); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -631,17 +631,17 @@ discard block |
||
631 | 631 | * @since 1.7.6 |
632 | 632 | * @param boolean $hide_empty_zone Default: false |
633 | 633 | */ |
634 | - if( empty( $field_output ) && apply_filters( 'gravityview/render/hide-empty-zone', false ) ) { |
|
634 | + if (empty($field_output) && apply_filters('gravityview/render/hide-empty-zone', false)) { |
|
635 | 635 | return NULL; |
636 | 636 | } |
637 | 637 | |
638 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
639 | - $output .= '<div class="'.gravityview_sanitize_html_class( $final_atts['wrapper_class'] ).'">'; |
|
638 | + if (!empty($final_atts['wrapper_class'])) { |
|
639 | + $output .= '<div class="'.gravityview_sanitize_html_class($final_atts['wrapper_class']).'">'; |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | $output .= $field_output; |
643 | 643 | |
644 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
644 | + if (!empty($final_atts['wrapper_class'])) { |
|
645 | 645 | $output .= '</div>'; |
646 | 646 | } |
647 | 647 | |
@@ -659,24 +659,24 @@ discard block |
||
659 | 659 | * @see Gamajo_Template_Loader::locate_template() |
660 | 660 | * @return null|string NULL: Template not found; String: path to template |
661 | 661 | */ |
662 | - function locate_template( $template_names, $load = false, $require_once = true ) { |
|
662 | + function locate_template($template_names, $load = false, $require_once = true) { |
|
663 | 663 | |
664 | - if( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
664 | + if (is_string($template_names) && isset($this->located_templates[$template_names])) { |
|
665 | 665 | |
666 | - $located = $this->located_templates[ $template_names ]; |
|
666 | + $located = $this->located_templates[$template_names]; |
|
667 | 667 | |
668 | 668 | } else { |
669 | 669 | |
670 | 670 | // Set $load to always falso so we handle it here. |
671 | - $located = parent::locate_template( $template_names, false, $require_once ); |
|
671 | + $located = parent::locate_template($template_names, false, $require_once); |
|
672 | 672 | |
673 | - if( is_string( $template_names ) ) { |
|
674 | - $this->located_templates[ $template_names ] = $located; |
|
673 | + if (is_string($template_names)) { |
|
674 | + $this->located_templates[$template_names] = $located; |
|
675 | 675 | } |
676 | 676 | } |
677 | 677 | |
678 | - if ( $load && $located ) { |
|
679 | - load_template( $located, $require_once ); |
|
678 | + if ($load && $located) { |
|
679 | + load_template($located, $require_once); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | return $located; |
@@ -687,8 +687,8 @@ discard block |
||
687 | 687 | * @param string $name Key for the data retrieval. |
688 | 688 | * @return mixed|null The stored data. |
689 | 689 | */ |
690 | - public function __get( $name ) { |
|
691 | - if( isset( $this->{$name} ) ) { |
|
690 | + public function __get($name) { |
|
691 | + if (isset($this->{$name} )) { |
|
692 | 692 | return $this->{$name}; |
693 | 693 | } else { |
694 | 694 | return NULL; |
@@ -712,47 +712,47 @@ discard block |
||
712 | 712 | * |
713 | 713 | * @return array $templates Modified template array, merged with existing $templates values |
714 | 714 | */ |
715 | - function add_id_specific_templates( $templates, $slug, $name ) { |
|
715 | + function add_id_specific_templates($templates, $slug, $name) { |
|
716 | 716 | |
717 | 717 | $additional = array(); |
718 | 718 | |
719 | 719 | // form-19-table-body.php |
720 | - $additional[] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
720 | + $additional[] = sprintf('form-%d-%s-%s.php', $this->getFormId(), $slug, $name); |
|
721 | 721 | |
722 | 722 | // view-3-table-body.php |
723 | - $additional[] = sprintf( 'view-%d-%s-%s.php', $this->getViewId(), $slug, $name ); |
|
723 | + $additional[] = sprintf('view-%d-%s-%s.php', $this->getViewId(), $slug, $name); |
|
724 | 724 | |
725 | - if( $this->getPostId() ) { |
|
725 | + if ($this->getPostId()) { |
|
726 | 726 | |
727 | 727 | // page-19-table-body.php |
728 | - $additional[] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
728 | + $additional[] = sprintf('page-%d-%s-%s.php', $this->getPostId(), $slug, $name); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | // Combine with existing table-body.php and table.php |
732 | - $templates = array_merge( $additional, $templates ); |
|
732 | + $templates = array_merge($additional, $templates); |
|
733 | 733 | |
734 | - do_action( 'gravityview_log_debug', '[add_id_specific_templates] List of Template Files', $templates ); |
|
734 | + do_action('gravityview_log_debug', '[add_id_specific_templates] List of Template Files', $templates); |
|
735 | 735 | |
736 | 736 | return $templates; |
737 | 737 | } |
738 | 738 | |
739 | 739 | // Load the template |
740 | - public function render( $slug, $name, $require_once = true ) { |
|
740 | + public function render($slug, $name, $require_once = true) { |
|
741 | 741 | |
742 | - $this->setTemplatePartSlug( $slug ); |
|
742 | + $this->setTemplatePartSlug($slug); |
|
743 | 743 | |
744 | - $this->setTemplatePartName( $name ); |
|
744 | + $this->setTemplatePartName($name); |
|
745 | 745 | |
746 | - $template_file = $this->get_template_part( $slug, $name, false ); |
|
746 | + $template_file = $this->get_template_part($slug, $name, false); |
|
747 | 747 | |
748 | - do_action( 'gravityview_log_debug', '[render] Rendering Template File', $template_file ); |
|
748 | + do_action('gravityview_log_debug', '[render] Rendering Template File', $template_file); |
|
749 | 749 | |
750 | - if( !empty( $template_file) ) { |
|
750 | + if (!empty($template_file)) { |
|
751 | 751 | |
752 | - if ( $require_once ) { |
|
753 | - require_once( $template_file ); |
|
752 | + if ($require_once) { |
|
753 | + require_once($template_file); |
|
754 | 754 | } else { |
755 | - require( $template_file ); |
|
755 | + require($template_file); |
|
756 | 756 | } |
757 | 757 | |
758 | 758 | } |
@@ -762,24 +762,24 @@ discard block |
||
762 | 762 | * |
763 | 763 | * @param $view_id |
764 | 764 | */ |
765 | - public function render_widget_hooks( $view_id ) { |
|
765 | + public function render_widget_hooks($view_id) { |
|
766 | 766 | |
767 | - if( empty( $view_id ) || 'single' == gravityview_get_context() ) { |
|
768 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Not rendering widgets; single entry' ); |
|
767 | + if (empty($view_id) || 'single' == gravityview_get_context()) { |
|
768 | + do_action('gravityview_log_debug', __METHOD__.' - Not rendering widgets; single entry'); |
|
769 | 769 | return; |
770 | 770 | } |
771 | 771 | |
772 | - $view_data = gravityview_get_current_view_data( $view_id ); |
|
772 | + $view_data = gravityview_get_current_view_data($view_id); |
|
773 | 773 | |
774 | 774 | // TODO: Move to sep. method, use an action instead |
775 | - wp_enqueue_style( 'gravityview_default_style'); |
|
775 | + wp_enqueue_style('gravityview_default_style'); |
|
776 | 776 | |
777 | 777 | // get View widget configuration |
778 | 778 | $widgets = $view_data['widgets']; |
779 | 779 | |
780 | 780 | $rows = GravityView_Plugin::get_default_widget_areas(); |
781 | 781 | |
782 | - switch( current_filter() ) { |
|
782 | + switch (current_filter()) { |
|
783 | 783 | case 'gravityview_before': |
784 | 784 | $zone = 'header'; |
785 | 785 | break; |
@@ -789,8 +789,8 @@ discard block |
||
789 | 789 | } |
790 | 790 | |
791 | 791 | // Prevent being called twice |
792 | - if( did_action( $zone.'_'.$view_id.'_widgets' ) ) { |
|
793 | - do_action( 'gravityview_log_debug', sprintf( '%s - Not rendering %s; already rendered', __METHOD__ , $zone.'_'.$view_id.'_widgets' ) ); |
|
792 | + if (did_action($zone.'_'.$view_id.'_widgets')) { |
|
793 | + do_action('gravityview_log_debug', sprintf('%s - Not rendering %s; already rendered', __METHOD__, $zone.'_'.$view_id.'_widgets')); |
|
794 | 794 | return; |
795 | 795 | } |
796 | 796 | |
@@ -798,17 +798,17 @@ discard block |
||
798 | 798 | ?> |
799 | 799 | <div class="gv-grid"> |
800 | 800 | <?php |
801 | - foreach( $rows as $row ) { |
|
802 | - foreach( $row as $col => $areas ) { |
|
801 | + foreach ($rows as $row) { |
|
802 | + foreach ($row as $col => $areas) { |
|
803 | 803 | $column = ($col == '2-2') ? '1-2 gv-right' : $col.' gv-left'; |
804 | 804 | ?> |
805 | - <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
|
805 | + <div class="gv-grid-col-<?php echo esc_attr($column); ?>"> |
|
806 | 806 | <?php |
807 | - if( !empty( $areas ) ) { |
|
808 | - foreach( $areas as $area ) { |
|
809 | - if( !empty( $widgets[ $zone .'_'. $area['areaid'] ] ) ) { |
|
810 | - foreach( $widgets[ $zone .'_'. $area['areaid'] ] as $widget ) { |
|
811 | - do_action( "gravityview_render_widget_{$widget['id']}", $widget ); |
|
807 | + if (!empty($areas)) { |
|
808 | + foreach ($areas as $area) { |
|
809 | + if (!empty($widgets[$zone.'_'.$area['areaid']])) { |
|
810 | + foreach ($widgets[$zone.'_'.$area['areaid']] as $widget) { |
|
811 | + do_action("gravityview_render_widget_{$widget['id']}", $widget); |
|
812 | 812 | } |
813 | 813 | } |
814 | 814 | } |
@@ -824,8 +824,8 @@ discard block |
||
824 | 824 | * Prevent widgets from being called twice. |
825 | 825 | * Checking for loop_start prevents themes and plugins that pre-process shortcodes from triggering the action before displaying. Like, ahem, the Divi theme and WordPress SEO plugin |
826 | 826 | */ |
827 | - if( did_action( 'loop_start' ) ) { |
|
828 | - do_action( $zone.'_'.$view_id.'_widgets' ); |
|
827 | + if (did_action('loop_start')) { |
|
828 | + do_action($zone.'_'.$view_id.'_widgets'); |
|
829 | 829 | } |
830 | 830 | } |
831 | 831 |