@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | public $active_areas; |
38 | 38 | |
39 | 39 | |
40 | - function __construct( $id, $settings = array(), $field_options = array(), $areas = array() ) { |
|
40 | + function __construct($id, $settings = array(), $field_options = array(), $areas = array()) { |
|
41 | 41 | |
42 | - if ( empty( $id ) ) { |
|
42 | + if (empty($id)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $this->template_id = $id; |
47 | 47 | |
48 | - $this->merge_defaults( $settings ); |
|
48 | + $this->merge_defaults($settings); |
|
49 | 49 | |
50 | 50 | $this->field_options = $field_options; |
51 | 51 | $this->active_areas = $areas; |
@@ -60,25 +60,25 @@ discard block |
||
60 | 60 | */ |
61 | 61 | private function add_hooks() { |
62 | 62 | |
63 | - add_filter( 'gravityview_register_directory_template', array( $this, 'register_template' ) ); |
|
63 | + add_filter('gravityview_register_directory_template', array($this, 'register_template')); |
|
64 | 64 | |
65 | 65 | // presets hooks: |
66 | 66 | // form xml |
67 | - add_filter( 'gravityview_template_formxml', array( $this, 'assign_form_xml' ), 10, 2 ); |
|
67 | + add_filter('gravityview_template_formxml', array($this, 'assign_form_xml'), 10, 2); |
|
68 | 68 | // fields config xml |
69 | - add_filter( 'gravityview_template_fieldsxml', array( $this, 'assign_fields_xml' ), 10, 2 ); |
|
69 | + add_filter('gravityview_template_fieldsxml', array($this, 'assign_fields_xml'), 10, 2); |
|
70 | 70 | |
71 | 71 | // assign active areas |
72 | - add_filter( 'gravityview_template_active_areas', array( $this, 'assign_active_areas' ), 10, 3 ); |
|
72 | + add_filter('gravityview_template_active_areas', array($this, 'assign_active_areas'), 10, 3); |
|
73 | 73 | |
74 | 74 | // field options |
75 | - add_filter( 'gravityview_template_field_options', array( $this, 'assign_field_options' ), 10, 4 ); |
|
75 | + add_filter('gravityview_template_field_options', array($this, 'assign_field_options'), 10, 4); |
|
76 | 76 | |
77 | 77 | // template slug |
78 | - add_filter( "gravityview_template_slug_{$this->template_id}", array( $this, 'assign_view_slug' ), 10, 2 ); |
|
78 | + add_filter("gravityview_template_slug_{$this->template_id}", array($this, 'assign_view_slug'), 10, 2); |
|
79 | 79 | |
80 | 80 | // register template CSS |
81 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) ); |
|
81 | + add_action('wp_enqueue_scripts', array($this, 'register_styles')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return array Merged template settings. |
92 | 92 | */ |
93 | - private function merge_defaults( $settings = array() ) { |
|
93 | + private function merge_defaults($settings = array()) { |
|
94 | 94 | |
95 | 95 | $defaults = array( |
96 | 96 | 'slug' => '', |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'preset_fields' => '' |
106 | 106 | ); |
107 | 107 | |
108 | - $this->settings = wp_parse_args( $settings, $defaults ); |
|
108 | + $this->settings = wp_parse_args($settings, $defaults); |
|
109 | 109 | |
110 | 110 | return $this->settings; |
111 | 111 | } |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return array Array of templates available for GV |
121 | 121 | */ |
122 | - public function register_template( $templates ) { |
|
123 | - $templates[ $this->template_id ] = $this->settings; |
|
122 | + public function register_template($templates) { |
|
123 | + $templates[$this->template_id] = $this->settings; |
|
124 | 124 | |
125 | 125 | return $templates; |
126 | 126 | } |
@@ -136,17 +136,17 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return array Array of active areas |
138 | 138 | */ |
139 | - public function assign_active_areas( $areas, $template = '', $context = 'directory' ) { |
|
140 | - if ( $this->template_id === $template ) { |
|
141 | - $areas = $this->get_active_areas( $context ); |
|
139 | + public function assign_active_areas($areas, $template = '', $context = 'directory') { |
|
140 | + if ($this->template_id === $template) { |
|
141 | + $areas = $this->get_active_areas($context); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | return $areas; |
145 | 145 | } |
146 | 146 | |
147 | - public function get_active_areas( $context ) { |
|
148 | - if ( isset( $this->active_areas[ $context ] ) ) { |
|
149 | - return $this->active_areas[ $context ]; |
|
147 | + public function get_active_areas($context) { |
|
148 | + if (isset($this->active_areas[$context])) { |
|
149 | + return $this->active_areas[$context]; |
|
150 | 150 | } else { |
151 | 151 | return $this->active_areas; |
152 | 152 | } |
@@ -163,21 +163,21 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array Array of field options |
165 | 165 | */ |
166 | - public function assign_field_options( $field_options, $template_id, $field_id = NULL, $context = 'directory' ) { |
|
166 | + public function assign_field_options($field_options, $template_id, $field_id = NULL, $context = 'directory') { |
|
167 | 167 | |
168 | - if ( $this->template_id === $template_id ) { |
|
168 | + if ($this->template_id === $template_id) { |
|
169 | 169 | |
170 | - foreach ( $this->field_options as $key => $field_option ) { |
|
170 | + foreach ($this->field_options as $key => $field_option) { |
|
171 | 171 | |
172 | - $field_context = rgar( $field_option, 'context' ); |
|
172 | + $field_context = rgar($field_option, 'context'); |
|
173 | 173 | |
174 | 174 | // Does the field option only apply to a certain context? |
175 | 175 | // You can define multiple contexts as an array: `context => array("directory", "single")` |
176 | - $context_matches = is_array( $field_context ) ? in_array( $context, $field_context ) : $context === $field_context; |
|
176 | + $context_matches = is_array($field_context) ? in_array($context, $field_context) : $context === $field_context; |
|
177 | 177 | |
178 | 178 | // If the context matches (or isn't defined), add the field options. |
179 | - if ( $context_matches ) { |
|
180 | - $field_options[ $key ] = $field_option; |
|
179 | + if ($context_matches) { |
|
180 | + $field_options[$key] = $field_option; |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | } |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @see GravityView_Admin_Views::create_preset_form() |
193 | 193 | * @return string Path to XML file |
194 | 194 | */ |
195 | - public function assign_form_xml( $xml = '', $template = '' ) { |
|
196 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_form'] ) && $this->template_id === $template ) { |
|
195 | + public function assign_form_xml($xml = '', $template = '') { |
|
196 | + if ($this->settings['type'] === 'preset' && !empty($this->settings['preset_form']) && $this->template_id === $template) { |
|
197 | 197 | return $this->settings['preset_form']; |
198 | 198 | } |
199 | 199 | |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | * @see GravityView_Admin_Views::pre_get_form_fields() |
207 | 207 | * @return string Path to XML file |
208 | 208 | */ |
209 | - public function assign_fields_xml( $xml = '', $template = '' ) { |
|
210 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_fields'] ) && $this->template_id === $template ) { |
|
209 | + public function assign_fields_xml($xml = '', $template = '') { |
|
210 | + if ($this->settings['type'] === 'preset' && !empty($this->settings['preset_fields']) && $this->template_id === $template) { |
|
211 | 211 | return $this->settings['preset_fields']; |
212 | 212 | } |
213 | 213 | |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - public function assign_view_slug( $default, $context ) { |
|
227 | + public function assign_view_slug($default, $context) { |
|
228 | 228 | |
229 | - if ( ! empty( $this->settings['slug'] ) ) { |
|
229 | + if (!empty($this->settings['slug'])) { |
|
230 | 230 | return $this->settings['slug']; |
231 | 231 | } |
232 | - if ( ! empty( $default ) ) { |
|
232 | + if (!empty($default)) { |
|
233 | 233 | return $default; |
234 | 234 | } |
235 | 235 | |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @return void |
245 | 245 | */ |
246 | 246 | public function register_styles() { |
247 | - if ( ! empty( $this->settings['css_source'] ) ) { |
|
248 | - wp_register_style( 'gravityview_style_' . $this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all' ); |
|
247 | + if (!empty($this->settings['css_source'])) { |
|
248 | + wp_register_style('gravityview_style_'.$this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all'); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return GV_License_Handler |
35 | 35 | */ |
36 | - public static function get_instance( GravityView_Settings $GFAddOn ) { |
|
37 | - if( empty( self::$instance ) ) { |
|
38 | - self::$instance = new self( $GFAddOn ); |
|
36 | + public static function get_instance(GravityView_Settings $GFAddOn) { |
|
37 | + if (empty(self::$instance)) { |
|
38 | + self::$instance = new self($GFAddOn); |
|
39 | 39 | } |
40 | 40 | return self::$instance; |
41 | 41 | } |
42 | 42 | |
43 | - private function __construct( GravityView_Settings $GFAddOn ) { |
|
43 | + private function __construct(GravityView_Settings $GFAddOn) { |
|
44 | 44 | |
45 | 45 | $this->Addon = $GFAddOn; |
46 | 46 | |
@@ -50,25 +50,25 @@ discard block |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | private function add_hooks() { |
53 | - add_action( 'wp_ajax_gravityview_license', array( $this, 'license_call' ) ); |
|
53 | + add_action('wp_ajax_gravityview_license', array($this, 'license_call')); |
|
54 | 54 | } |
55 | 55 | |
56 | - function settings_edd_license_activation( $field, $echo ) { |
|
56 | + function settings_edd_license_activation($field, $echo) { |
|
57 | 57 | |
58 | - wp_enqueue_script( 'gv-admin-edd-license', GRAVITYVIEW_URL . 'assets/js/admin-edd-license.js', array( 'jquery' ) ); |
|
58 | + wp_enqueue_script('gv-admin-edd-license', GRAVITYVIEW_URL.'assets/js/admin-edd-license.js', array('jquery')); |
|
59 | 59 | |
60 | - $status = trim( $this->Addon->get_app_setting( 'license_key_status' ) ); |
|
61 | - $key = trim( $this->Addon->get_app_setting( 'license_key' ) ); |
|
60 | + $status = trim($this->Addon->get_app_setting('license_key_status')); |
|
61 | + $key = trim($this->Addon->get_app_setting('license_key')); |
|
62 | 62 | |
63 | - if( !empty( $key ) ) { |
|
64 | - $response = $this->Addon->get_app_setting( 'license_key_response' ); |
|
65 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
63 | + if (!empty($key)) { |
|
64 | + $response = $this->Addon->get_app_setting('license_key_response'); |
|
65 | + $response = is_array($response) ? (object)$response : json_decode($response); |
|
66 | 66 | } else { |
67 | 67 | $response = array(); |
68 | 68 | } |
69 | 69 | |
70 | - wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array( |
|
71 | - 'license_box' => $this->get_license_message( $response ) |
|
70 | + wp_localize_script('gv-admin-edd-license', 'GVGlobals', array( |
|
71 | + 'license_box' => $this->get_license_message($response) |
|
72 | 72 | )); |
73 | 73 | |
74 | 74 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | 'value' => __('Deactivate License', 'gravityview'), |
86 | 86 | 'data-pending_text' => __('Deactivating license…', 'gravityview'), |
87 | 87 | 'data-edd_action' => 'deactivate_license', |
88 | - 'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ), |
|
88 | + 'class' => (empty($status) ? 'button-primary hide' : 'button-primary'), |
|
89 | 89 | ), |
90 | 90 | array( |
91 | 91 | 'name' => 'edd-check', |
@@ -100,19 +100,19 @@ discard block |
||
100 | 100 | |
101 | 101 | $class = 'button gv-edd-action'; |
102 | 102 | |
103 | - $class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
103 | + $class .= (!empty($key) && $status !== 'valid') ? '' : ' hide'; |
|
104 | 104 | |
105 | - $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
|
105 | + $disabled_attribute = GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled'; |
|
106 | 106 | |
107 | 107 | $submit = '<div class="gv-edd-button-wrapper">'; |
108 | - foreach ( $fields as $field ) { |
|
108 | + foreach ($fields as $field) { |
|
109 | 109 | $field['type'] = 'button'; |
110 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
110 | + $field['class'] = isset($field['class']) ? $field['class'].' '.$class : $class; |
|
111 | 111 | $field['style'] = 'margin-left: 10px;'; |
112 | - if( $disabled_attribute ) { |
|
112 | + if ($disabled_attribute) { |
|
113 | 113 | $field['disabled'] = $disabled_attribute; |
114 | 114 | } |
115 | - $submit .= $this->Addon->settings_submit( $field, $echo ); |
|
115 | + $submit .= $this->Addon->settings_submit($field, $echo); |
|
116 | 116 | } |
117 | 117 | $submit .= '</div>'; |
118 | 118 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | private function setup_edd() { |
128 | 128 | |
129 | - if( !class_exists('EDD_SL_Plugin_Updater') ) { |
|
130 | - require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
129 | + if (!class_exists('EDD_SL_Plugin_Updater')) { |
|
130 | + require_once(GRAVITYVIEW_DIR.'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // setup the updater |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return array |
151 | 151 | */ |
152 | - function _get_edd_settings( $action = '', $license = '' ) { |
|
152 | + function _get_edd_settings($action = '', $license = '') { |
|
153 | 153 | |
154 | 154 | // retrieve our license key from the DB |
155 | - $license_key = empty( $license ) ? trim( $this->Addon->get_app_setting( 'license_key' ) ) : $license; |
|
155 | + $license_key = empty($license) ? trim($this->Addon->get_app_setting('license_key')) : $license; |
|
156 | 156 | |
157 | 157 | $settings = array( |
158 | 158 | 'version' => self::version, |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | 'url' => home_url(), |
164 | 164 | ); |
165 | 165 | |
166 | - if( !empty( $action ) ) { |
|
167 | - $settings['edd_action'] = esc_attr( $action ); |
|
166 | + if (!empty($action)) { |
|
167 | + $settings['edd_action'] = esc_attr($action); |
|
168 | 168 | } |
169 | 169 | |
170 | - $settings = array_map( 'urlencode', $settings ); |
|
170 | + $settings = array_map('urlencode', $settings); |
|
171 | 171 | |
172 | 172 | return $settings; |
173 | 173 | } |
@@ -176,27 +176,27 @@ discard block |
||
176 | 176 | * Perform the call |
177 | 177 | * @return array|WP_Error |
178 | 178 | */ |
179 | - private function _license_get_remote_response( $data, $license = '' ) { |
|
179 | + private function _license_get_remote_response($data, $license = '') { |
|
180 | 180 | |
181 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
181 | + $api_params = $this->_get_edd_settings($data['edd_action'], $license); |
|
182 | 182 | |
183 | - $url = add_query_arg( $api_params, self::url ); |
|
183 | + $url = add_query_arg($api_params, self::url); |
|
184 | 184 | |
185 | - $response = wp_remote_get( $url, array( |
|
185 | + $response = wp_remote_get($url, array( |
|
186 | 186 | 'timeout' => 15, |
187 | 187 | 'sslverify' => false, |
188 | 188 | )); |
189 | 189 | |
190 | - if ( is_wp_error( $response ) ) { |
|
190 | + if (is_wp_error($response)) { |
|
191 | 191 | return array(); |
192 | 192 | } |
193 | 193 | |
194 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
194 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
195 | 195 | |
196 | 196 | // Not JSON |
197 | - if ( empty( $license_data ) ) { |
|
197 | + if (empty($license_data)) { |
|
198 | 198 | |
199 | - delete_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid' ); |
|
199 | + delete_transient('gravityview_'.esc_attr($data['field_id']).'_valid'); |
|
200 | 200 | |
201 | 201 | // Change status |
202 | 202 | return array(); |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @return string |
218 | 218 | */ |
219 | - function get_license_message( $license_data ) { |
|
219 | + function get_license_message($license_data) { |
|
220 | 220 | |
221 | - if( empty( $license_data ) ) { |
|
221 | + if (empty($license_data)) { |
|
222 | 222 | $class = 'hide'; |
223 | 223 | $message = ''; |
224 | 224 | } else { |
225 | 225 | |
226 | - if( ! empty( $license_data->error ) ) { |
|
226 | + if (!empty($license_data->error)) { |
|
227 | 227 | $class = 'error'; |
228 | 228 | $string_key = $license_data->error; |
229 | 229 | } else { |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | $string_key = $license_data->license; |
232 | 232 | } |
233 | 233 | |
234 | - $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) ); |
|
234 | + $message = sprintf('<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings($string_key, $license_data)); |
|
235 | 235 | } |
236 | 236 | |
237 | - return $this->generate_license_box( $message, $class ); |
|
237 | + return $this->generate_license_box($message, $class); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @return string |
248 | 248 | */ |
249 | - private function generate_license_box( $message, $class = '' ) { |
|
249 | + private function generate_license_box($message, $class = '') { |
|
250 | 250 | |
251 | 251 | $template = '<div id="gv-edd-status" class="gv-edd-message inline %s">%s</div>'; |
252 | 252 | |
253 | - $output = sprintf( $template, esc_attr( $class ), $message ); |
|
253 | + $output = sprintf($template, esc_attr($class), $message); |
|
254 | 254 | |
255 | 255 | return $output; |
256 | 256 | } |
@@ -270,63 +270,63 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return mixed|string|void |
272 | 272 | */ |
273 | - public function license_call( $array = array() ) { |
|
273 | + public function license_call($array = array()) { |
|
274 | 274 | |
275 | - $is_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
276 | - $data = empty( $array ) ? $_POST['data'] : $array; |
|
277 | - $has_cap = GVCommon::has_cap( 'gravityview_edit_settings' ); |
|
275 | + $is_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
276 | + $data = empty($array) ? $_POST['data'] : $array; |
|
277 | + $has_cap = GVCommon::has_cap('gravityview_edit_settings'); |
|
278 | 278 | |
279 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
280 | - die( - 1 ); |
|
279 | + if ($is_ajax && empty($data['license'])) { |
|
280 | + die( -1 ); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | // If the user isn't allowed to edit settings, show an error message |
284 | - if( ! $has_cap ) { |
|
284 | + if (!$has_cap) { |
|
285 | 285 | $license_data = new stdClass(); |
286 | 286 | $license_data->error = 'capability'; |
287 | - $license_data->message = $this->get_license_message( $license_data ); |
|
288 | - $json = json_encode( $license_data ); |
|
287 | + $license_data->message = $this->get_license_message($license_data); |
|
288 | + $json = json_encode($license_data); |
|
289 | 289 | } else { |
290 | 290 | |
291 | - $license = esc_attr( rgget( 'license', $data ) ); |
|
292 | - $license_data = $this->_license_get_remote_response( $data, $license ); |
|
291 | + $license = esc_attr(rgget('license', $data)); |
|
292 | + $license_data = $this->_license_get_remote_response($data, $license); |
|
293 | 293 | |
294 | 294 | // Empty is returned when there's an error. |
295 | - if ( empty( $license_data ) ) { |
|
296 | - if ( $is_ajax ) { |
|
297 | - exit( json_encode( array() ) ); |
|
295 | + if (empty($license_data)) { |
|
296 | + if ($is_ajax) { |
|
297 | + exit(json_encode(array())); |
|
298 | 298 | } else { // Non-ajax call |
299 | - return json_encode( array() ); |
|
299 | + return json_encode(array()); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
303 | - $license_data->message = $this->get_license_message( $license_data ); |
|
303 | + $license_data->message = $this->get_license_message($license_data); |
|
304 | 304 | |
305 | - $json = json_encode( $license_data ); |
|
305 | + $json = json_encode($license_data); |
|
306 | 306 | |
307 | - $update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) ); |
|
307 | + $update_license = (!isset($data['update']) || !empty($data['update'])); |
|
308 | 308 | |
309 | - $is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
309 | + $is_check_action_button = ('check_license' === $data['edd_action'] && defined('DOING_AJAX') && DOING_AJAX); |
|
310 | 310 | |
311 | 311 | // Failed is the response from trying to de-activate a license and it didn't work. |
312 | 312 | // This likely happened because people entered in a different key and clicked "Deactivate", |
313 | 313 | // meaning to deactivate the original key. We don't want to save this response, since it is |
314 | 314 | // most likely a mistake. |
315 | - if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) { |
|
315 | + if ($license_data->license !== 'failed' && !$is_check_action_button && $update_license) { |
|
316 | 316 | |
317 | - if ( ! empty( $data['field_id'] ) ) { |
|
318 | - set_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid', $license_data, DAY_IN_SECONDS ); |
|
317 | + if (!empty($data['field_id'])) { |
|
318 | + set_transient('gravityview_'.esc_attr($data['field_id']).'_valid', $license_data, DAY_IN_SECONDS); |
|
319 | 319 | } |
320 | 320 | |
321 | - $this->license_call_update_settings( $license_data, $data ); |
|
321 | + $this->license_call_update_settings($license_data, $data); |
|
322 | 322 | |
323 | 323 | } |
324 | 324 | } // End $has_cap |
325 | 325 | |
326 | - if ( $is_ajax ) { |
|
327 | - exit( $json ); |
|
326 | + if ($is_ajax) { |
|
327 | + exit($json); |
|
328 | 328 | } else { // Non-ajax call |
329 | - return ( rgget('format', $data ) === 'object' ) ? $license_data : $json; |
|
329 | + return (rgget('format', $data) === 'object') ? $license_data : $json; |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
@@ -335,16 +335,16 @@ discard block |
||
335 | 335 | * @param object $license_data |
336 | 336 | * @return void |
337 | 337 | */ |
338 | - private function license_call_update_settings( $license_data, $data ) { |
|
338 | + private function license_call_update_settings($license_data, $data) { |
|
339 | 339 | |
340 | 340 | // Update option with passed data license |
341 | 341 | $settings = $this->Addon->get_app_settings(); |
342 | 342 | |
343 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
343 | + $settings['license_key'] = $license_data->license_key = trim($data['license']); |
|
344 | 344 | $settings['license_key_status'] = $license_data->license; |
345 | 345 | $settings['license_key_response'] = (array)$license_data; |
346 | 346 | |
347 | - $this->Addon->update_app_settings( $settings ); |
|
347 | + $this->Addon->update_app_settings($settings); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -353,8 +353,8 @@ discard block |
||
353 | 353 | * @param object|null $license_data Object with license data |
354 | 354 | * @return string Renewal or account URL |
355 | 355 | */ |
356 | - private function get_license_renewal_url( $license_data ) { |
|
357 | - $renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
356 | + private function get_license_renewal_url($license_data) { |
|
357 | + $renew_license_url = (!empty($license_data) && !empty($license_data->license_key)) ? sprintf('https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key) : 'https://gravityview.co/account/'; |
|
358 | 358 | return $renew_license_url; |
359 | 359 | } |
360 | 360 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @param object|null $license_data Object with license data |
365 | 365 | * @return array Modified array of content |
366 | 366 | */ |
367 | - public function strings( $status = NULL, $license_data = null ) { |
|
367 | + public function strings($status = NULL, $license_data = null) { |
|
368 | 368 | |
369 | 369 | |
370 | 370 | $strings = array( |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | 'error' => esc_html__('There was an error processing the request.', 'gravityview'), |
373 | 373 | 'failed' => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'), |
374 | 374 | 'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
375 | - 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
375 | + 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview').' '.sprintf(esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>'), |
|
376 | 376 | 'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'), |
377 | 377 | 'valid' => esc_html__('The license key is valid and active.', 'gravityview'), |
378 | 378 | 'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'), |
379 | 379 | 'missing' => esc_html__('The license key was not defined.', 'gravityview'), |
380 | 380 | 'revoked' => esc_html__('This license key has been revoked.', 'gravityview'), |
381 | - 'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
382 | - 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
|
381 | + 'expired' => sprintf(esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'.esc_url($this->get_license_renewal_url($license_data)).'">', '</a>'), |
|
382 | + 'capability' => esc_html__('You don\'t have the ability to edit plugin settings.', 'gravityview'), |
|
383 | 383 | |
384 | 384 | 'verifying_license' => esc_html__('Verifying license…', 'gravityview'), |
385 | 385 | 'activate_license' => esc_html__('Activate License', 'gravityview'), |
@@ -387,33 +387,33 @@ discard block |
||
387 | 387 | 'check_license' => esc_html__('Verify License', 'gravityview'), |
388 | 388 | ); |
389 | 389 | |
390 | - if( empty( $status ) ) { |
|
390 | + if (empty($status)) { |
|
391 | 391 | return $strings; |
392 | 392 | } |
393 | 393 | |
394 | - if( isset( $strings[ $status ] ) ) { |
|
395 | - return $strings[ $status ]; |
|
394 | + if (isset($strings[$status])) { |
|
395 | + return $strings[$status]; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | return NULL; |
399 | 399 | } |
400 | 400 | |
401 | - public function validate_license_key( $value, $field ) { |
|
401 | + public function validate_license_key($value, $field) { |
|
402 | 402 | |
403 | 403 | // No license? No status. |
404 | - if( empty( $value ) ) { |
|
404 | + if (empty($value)) { |
|
405 | 405 | return NULL; |
406 | 406 | } |
407 | 407 | |
408 | 408 | $response = $this->license_call(array( |
409 | - 'license' => $this->Addon->get_app_setting( 'license_key' ), |
|
409 | + 'license' => $this->Addon->get_app_setting('license_key'), |
|
410 | 410 | 'edd_action' => 'check_license', |
411 | 411 | 'field_id' => $field['name'], |
412 | 412 | )); |
413 | 413 | |
414 | - $response = is_string( $response ) ? json_decode( $response, true ) : $response; |
|
414 | + $response = is_string($response) ? json_decode($response, true) : $response; |
|
415 | 415 | |
416 | - switch( $response['license'] ) { |
|
416 | + switch ($response['license']) { |
|
417 | 417 | case 'valid': |
418 | 418 | $return = true; |
419 | 419 | break; |
@@ -5,13 +5,13 @@ discard block |
||
5 | 5 | */ |
6 | 6 | class GVLogic_Shortcode { |
7 | 7 | |
8 | - private static $SUPPORTED_SCALAR_OPERATORS = array( 'is', 'isnot', 'contains', 'starts_with', 'ends_with' ); |
|
8 | + private static $SUPPORTED_SCALAR_OPERATORS = array('is', 'isnot', 'contains', 'starts_with', 'ends_with'); |
|
9 | 9 | |
10 | - private static $SUPPORTED_NUMERIC_OPERATORS = array( 'greater_than', 'less_than' ); |
|
10 | + private static $SUPPORTED_NUMERIC_OPERATORS = array('greater_than', 'less_than'); |
|
11 | 11 | |
12 | - private static $SUPPORTED_ARRAY_OPERATORS = array( 'in', 'not_in', 'isnot', 'contains' ); |
|
12 | + private static $SUPPORTED_ARRAY_OPERATORS = array('in', 'not_in', 'isnot', 'contains'); |
|
13 | 13 | |
14 | - private static $SUPPORTED_CUSTOM_OPERATORS = array( 'equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains' ); |
|
14 | + private static $SUPPORTED_CUSTOM_OPERATORS = array('equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains'); |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Attributes passed to the shortcode |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function get_instance() { |
87 | 87 | |
88 | - if( empty( self::$instance ) ) { |
|
88 | + if (empty(self::$instance)) { |
|
89 | 89 | self::$instance = new self; |
90 | 90 | } |
91 | 91 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return void |
106 | 106 | */ |
107 | 107 | function add_hooks() { |
108 | - add_shortcode( 'gvlogic', array( $this, 'shortcode' ) ); |
|
108 | + add_shortcode('gvlogic', array($this, 'shortcode')); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - function get_operators( $with_values = false ) { |
|
117 | + function get_operators($with_values = false) { |
|
118 | 118 | |
119 | - $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
|
119 | + $operators = array_merge(self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS); |
|
120 | 120 | |
121 | - if( $with_values ) { |
|
121 | + if ($with_values) { |
|
122 | 122 | $operators_with_values = array(); |
123 | - foreach( $operators as $key ) { |
|
124 | - $operators_with_values[ $key ] = ''; |
|
123 | + foreach ($operators as $key) { |
|
124 | + $operators_with_values[$key] = ''; |
|
125 | 125 | } |
126 | 126 | return $operators_with_values; |
127 | 127 | } else { |
@@ -135,16 +135,16 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return bool True: it's an allowed operation type and was added. False: invalid operation type |
137 | 137 | */ |
138 | - function set_operation( $operation = '' ) { |
|
138 | + function set_operation($operation = '') { |
|
139 | 139 | |
140 | - if( empty( $operation ) ) { |
|
140 | + if (empty($operation)) { |
|
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | - $operators = $this->get_operators( false ); |
|
144 | + $operators = $this->get_operators(false); |
|
145 | 145 | |
146 | - if( !in_array( $operation, $operators ) ) { |
|
147 | - do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation ); |
|
146 | + if (!in_array($operation, $operators)) { |
|
147 | + do_action('gravityview_log_debug', __METHOD__.' Attempted to add invalid operation type.', $operation); |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | */ |
165 | 165 | function setup_operation_and_comparison() { |
166 | 166 | |
167 | - foreach( $this->atts as $key => $value ) { |
|
167 | + foreach ($this->atts as $key => $value) { |
|
168 | 168 | |
169 | - $valid = $this->set_operation( $key ); |
|
169 | + $valid = $this->set_operation($key); |
|
170 | 170 | |
171 | - if( $valid ) { |
|
171 | + if ($valid) { |
|
172 | 172 | $this->comparison = $value; |
173 | 173 | return true; |
174 | 174 | } |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @return string|null |
186 | 186 | */ |
187 | - public function shortcode( $atts = array(), $content = NULL, $shortcode_tag = '' ) { |
|
187 | + public function shortcode($atts = array(), $content = NULL, $shortcode_tag = '') { |
|
188 | 188 | |
189 | 189 | // Don't process except on frontend |
190 | - if ( GravityView_Plugin::is_admin() ) { |
|
190 | + if (GravityView_Plugin::is_admin()) { |
|
191 | 191 | return null; |
192 | 192 | } |
193 | 193 | |
@@ -198,16 +198,16 @@ discard block |
||
198 | 198 | $this->parse_atts(); |
199 | 199 | |
200 | 200 | // We need an "if" |
201 | - if( false === $this->if ) { |
|
202 | - do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->atts ); |
|
201 | + if (false === $this->if) { |
|
202 | + do_action('gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->atts); |
|
203 | 203 | return null; |
204 | 204 | } |
205 | 205 | |
206 | 206 | $setup = $this->setup_operation_and_comparison(); |
207 | 207 | |
208 | 208 | // We need an operation and comparison value |
209 | - if( ! $setup ) { |
|
210 | - do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts ); |
|
209 | + if (!$setup) { |
|
210 | + do_action('gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts); |
|
211 | 211 | return null; |
212 | 212 | } |
213 | 213 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @return boolean True: yep; false: nope |
229 | 229 | */ |
230 | 230 | function set_is_match() { |
231 | - $this->is_match = GVCommon::matches_operation( $this->if, $this->comparison, $this->operation ); |
|
231 | + $this->is_match = GVCommon::matches_operation($this->if, $this->comparison, $this->operation); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -238,23 +238,23 @@ discard block |
||
238 | 238 | */ |
239 | 239 | function get_output() { |
240 | 240 | |
241 | - if( $this->is_match ) { |
|
241 | + if ($this->is_match) { |
|
242 | 242 | $output = $this->content; |
243 | 243 | } else { |
244 | 244 | $output = $this->else_content; |
245 | 245 | } |
246 | 246 | |
247 | 247 | // Get recursive! |
248 | - $output = do_shortcode( $output ); |
|
248 | + $output = do_shortcode($output); |
|
249 | 249 | |
250 | 250 | /** |
251 | 251 | * @filter `gravityview/gvlogic/output` Modify the [gvlogic] output |
252 | 252 | * @param string $output HTML/text output |
253 | 253 | * @param GVLogic_Shortcode $this This class |
254 | 254 | */ |
255 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
255 | + $output = apply_filters('gravityview/gvlogic/output', $output, $this); |
|
256 | 256 | |
257 | - do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output ); |
|
257 | + do_action('gravityview_log_debug', __METHOD__.' Output: ', $output); |
|
258 | 258 | |
259 | 259 | return $output; |
260 | 260 | } |
@@ -268,13 +268,13 @@ discard block |
||
268 | 268 | */ |
269 | 269 | function set_content_and_else_content() { |
270 | 270 | |
271 | - $content = explode( '[else]', $this->passed_content ); |
|
271 | + $content = explode('[else]', $this->passed_content); |
|
272 | 272 | |
273 | 273 | $this->content = $content[0]; |
274 | 274 | |
275 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
275 | + $else_attr = isset($this->atts['else']) ? $this->atts['else'] : NULL; |
|
276 | 276 | |
277 | - $this->else_content = isset( $content[1] ) ? $content[1] : $else_attr; |
|
277 | + $this->else_content = isset($content[1]) ? $content[1] : $else_attr; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | 'else' => false, |
289 | 289 | ); |
290 | 290 | |
291 | - $supported_args = $supported + $this->get_operators( true ); |
|
291 | + $supported_args = $supported + $this->get_operators(true); |
|
292 | 292 | |
293 | 293 | // Whittle down the attributes to only valid pairs |
294 | - $this->atts = shortcode_atts( $supported_args, $this->passed_atts, $this->shortcode ); |
|
294 | + $this->atts = shortcode_atts($supported_args, $this->passed_atts, $this->shortcode); |
|
295 | 295 | |
296 | 296 | // Only keep the passed attributes after making sure that they're valid pairs |
297 | - $this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts; |
|
297 | + $this->atts = function_exists('array_intersect_key') ? array_intersect_key($this->passed_atts, $this->atts) : $this->atts; |
|
298 | 298 | |
299 | 299 | // Strip whitespace if it's not default false |
300 | - $this->if = is_string( $this->atts['if'] ) ? trim( $this->atts['if'] ) : false; |
|
300 | + $this->if = is_string($this->atts['if']) ? trim($this->atts['if']) : false; |
|
301 | 301 | |
302 | 302 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
303 | - unset( $this->atts['if'] ); |
|
303 | + unset($this->atts['if']); |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @since 1.6 |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if (!defined('ABSPATH')) { |
|
14 | 14 | die; |
15 | 15 | } |
16 | 16 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | private function initialize() { |
34 | 34 | |
35 | - add_action( 'init', array( $this, 'register_handler' ) ); |
|
35 | + add_action('init', array($this, 'register_handler')); |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | static function getInstance() { |
44 | 44 | |
45 | - if( empty( self::$instance ) ) { |
|
45 | + if (empty(self::$instance)) { |
|
46 | 46 | self::$instance = new self; |
47 | 47 | |
48 | 48 | self::$instance->initialize(); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function register_handler() { |
61 | 61 | |
62 | - wp_embed_register_handler( 'gravityview_entry', $this->get_handler_regex(), array( $this, 'render_handler' ), 20000 ); |
|
62 | + wp_embed_register_handler('gravityview_entry', $this->get_handler_regex(), array($this, 'render_handler'), 20000); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | * @filter `gravityview_slug` Modify the url part for a View. [Read the doc](http://docs.gravityview.co/article/62-changing-the-view-slug) |
81 | 81 | * @param string $rewrite_slug The slug shown in the URL |
82 | 82 | */ |
83 | - $rewrite_slug = apply_filters( 'gravityview_slug', 'view' ); |
|
83 | + $rewrite_slug = apply_filters('gravityview_slug', 'view'); |
|
84 | 84 | |
85 | 85 | // Only support embeds for current site |
86 | - $prefix = trailingslashit( home_url() ); |
|
86 | + $prefix = trailingslashit(home_url()); |
|
87 | 87 | |
88 | 88 | // Using permalinks |
89 | - $using_permalinks = $prefix . "(?P<is_cpt>{$rewrite_slug})?/?(?P<slug>.+?)/{$entry_var_name}/(?P<entry_slug>.+?)/?\$"; |
|
89 | + $using_permalinks = $prefix."(?P<is_cpt>{$rewrite_slug})?/?(?P<slug>.+?)/{$entry_var_name}/(?P<entry_slug>.+?)/?\$"; |
|
90 | 90 | |
91 | 91 | // Not using permalinks |
92 | - $not_using_permalinks = $prefix . "(?:index.php)?\?(?P<is_cpt2>[^=]+)=(?P<slug2>[^&]+)&entry=(?P<entry_slug2>[^&]+)\$"; |
|
92 | + $not_using_permalinks = $prefix."(?:index.php)?\?(?P<is_cpt2>[^=]+)=(?P<slug2>[^&]+)&entry=(?P<entry_slug2>[^&]+)\$"; |
|
93 | 93 | |
94 | 94 | // Catch either |
95 | 95 | $match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})"; |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | * @param string $slug The name of a post, used as backup way of checking for post ID |
110 | 110 | * @return int 0 if not found; int of URL post ID otherwise |
111 | 111 | */ |
112 | - private function get_postid_from_url_and_slug( $url = '', $slug = '' ) { |
|
112 | + private function get_postid_from_url_and_slug($url = '', $slug = '') { |
|
113 | 113 | |
114 | - $post_id = url_to_postid( $url ); |
|
114 | + $post_id = url_to_postid($url); |
|
115 | 115 | |
116 | - if( empty( $post_id ) ) { |
|
116 | + if (empty($post_id)) { |
|
117 | 117 | |
118 | 118 | $args = array( |
119 | 119 | 'post_status' => 'publish', |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | 'post_type' => array('any', 'gravityview'), |
122 | 122 | ); |
123 | 123 | |
124 | - $posts = get_posts( $args ); |
|
124 | + $posts = get_posts($args); |
|
125 | 125 | |
126 | - if( !empty( $posts ) ) { |
|
126 | + if (!empty($posts)) { |
|
127 | 127 | $post_id = $posts[0]->ID; |
128 | 128 | } |
129 | 129 | } |
@@ -154,20 +154,20 @@ discard block |
||
154 | 154 | * @param array $rawattr The original unmodified attributes. |
155 | 155 | * @return string The embed HTML. |
156 | 156 | */ |
157 | - public function render_handler( $matches, $attr, $url, $rawattr ) { |
|
157 | + public function render_handler($matches, $attr, $url, $rawattr) { |
|
158 | 158 | |
159 | 159 | // If not using permalinks, re-assign values for matching groups |
160 | - if( !empty( $matches['entry_slug2'] ) ) { |
|
160 | + if (!empty($matches['entry_slug2'])) { |
|
161 | 161 | $matches['is_cpt'] = $matches['is_cpt2']; |
162 | 162 | $matches['slug'] = $matches['slug2']; |
163 | 163 | $matches['entry_slug'] = $matches['entry_slug2']; |
164 | - unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
164 | + unset($matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2']); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // No Entry was found |
168 | - if( empty( $matches['entry_slug'] ) ) { |
|
168 | + if (empty($matches['entry_slug'])) { |
|
169 | 169 | |
170 | - do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
170 | + do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches); |
|
171 | 171 | |
172 | 172 | return ''; |
173 | 173 | } |
@@ -175,17 +175,17 @@ discard block |
||
175 | 175 | $return = ''; |
176 | 176 | |
177 | 177 | // Setup the data used |
178 | - $this->set_vars( $matches, $attr, $url, $rawattr ); |
|
178 | + $this->set_vars($matches, $attr, $url, $rawattr); |
|
179 | 179 | |
180 | - if( is_admin() && !$this->is_full_oembed_preview ) { |
|
181 | - $return = $this->render_admin( $matches, $attr, $url, $rawattr ); |
|
180 | + if (is_admin() && !$this->is_full_oembed_preview) { |
|
181 | + $return = $this->render_admin($matches, $attr, $url, $rawattr); |
|
182 | 182 | } else { |
183 | 183 | |
184 | - if( $this->is_full_oembed_preview ) { |
|
184 | + if ($this->is_full_oembed_preview) { |
|
185 | 185 | $return .= $this->generate_preview_notice(); |
186 | 186 | } |
187 | 187 | |
188 | - $return .= $this->render_frontend( $matches, $attr, $url, $rawattr ); |
|
188 | + $return .= $this->render_frontend($matches, $attr, $url, $rawattr); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | return $return; |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | */ |
200 | 200 | private function generate_preview_notice() { |
201 | 201 | $floaty = GravityView_Admin::get_floaty(); |
202 | - $title = esc_html__( 'This will look better when it is embedded.', 'gravityview' ); |
|
202 | + $title = esc_html__('This will look better when it is embedded.', 'gravityview'); |
|
203 | 203 | $message = esc_html__('Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview'); |
204 | - return '<div class="updated notice">'. $floaty. '<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>'; |
|
204 | + return '<div class="updated notice">'.$floaty.'<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>'; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -212,18 +212,18 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @see render_handler |
214 | 214 | */ |
215 | - private function set_vars( $matches, $attr, $url, $rawattr ) { |
|
215 | + private function set_vars($matches, $attr, $url, $rawattr) { |
|
216 | 216 | |
217 | 217 | $this->entry_id = $matches['entry_slug']; |
218 | 218 | |
219 | - $post_id = $this->get_postid_from_url_and_slug( $url, $matches['slug'] ); |
|
219 | + $post_id = $this->get_postid_from_url_and_slug($url, $matches['slug']); |
|
220 | 220 | |
221 | 221 | // The URL didn't have the View Custom Post Type structure. |
222 | - if( empty( $matches['is_cpt'] ) || $matches['is_cpt'] !== 'gravityview' ) { |
|
222 | + if (empty($matches['is_cpt']) || $matches['is_cpt'] !== 'gravityview') { |
|
223 | 223 | |
224 | - do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
224 | + do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches); |
|
225 | 225 | |
226 | - $this->view_id = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); |
|
226 | + $this->view_id = GravityView_View_Data::getInstance()->maybe_get_view_id($post_id); |
|
227 | 227 | |
228 | 228 | } else { |
229 | 229 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | |
234 | 234 | // The inline content has $_POST['type'] set to "embed", while the "Add Media" modal doesn't set that. |
235 | - $this->is_full_oembed_preview = ( isset( $_POST['action'] ) && $_POST['action'] === 'parse-embed' && !isset( $_POST['type'] ) ); |
|
235 | + $this->is_full_oembed_preview = (isset($_POST['action']) && $_POST['action'] === 'parse-embed' && !isset($_POST['type'])); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | * @param array $rawattr The original unmodified attributes. |
245 | 245 | * @return string The embed HTML. |
246 | 246 | */ |
247 | - private function render_admin( $matches, $attr, $url, $rawattr ) { |
|
247 | + private function render_admin($matches, $attr, $url, $rawattr) { |
|
248 | 248 | global $wp_version; |
249 | 249 | |
250 | 250 | // Floaty the astronaut |
251 | 251 | $image = GravityView_Admin::get_floaty(); |
252 | 252 | |
253 | - $embed_heading = sprintf( esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id ); |
|
253 | + $embed_heading = sprintf(esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id); |
|
254 | 254 | |
255 | - $embed_text = sprintf( esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id ); |
|
255 | + $embed_text = sprintf(esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id); |
|
256 | 256 | |
257 | 257 | return ' |
258 | 258 | <div class="loading-placeholder" style="background-color:#e6f0f5;"> |
@@ -268,21 +268,21 @@ discard block |
||
268 | 268 | private function generate_entry_output() { |
269 | 269 | |
270 | 270 | // Tell get_gravityview() to display a single entry |
271 | - add_filter( 'gravityview/is_single_entry', array( $this, 'set_single_entry_id' ) ); |
|
271 | + add_filter('gravityview/is_single_entry', array($this, 'set_single_entry_id')); |
|
272 | 272 | |
273 | 273 | ob_start(); |
274 | 274 | |
275 | 275 | // Print the entry as configured in View |
276 | - the_gravityview( $this->view_id ); |
|
276 | + the_gravityview($this->view_id); |
|
277 | 277 | |
278 | 278 | $view_html = ob_get_clean(); |
279 | 279 | |
280 | 280 | // Clean up the filter |
281 | - remove_filter( 'gravityview/is_single_entry', array( $this, 'set_single_entry_id' ) ); |
|
281 | + remove_filter('gravityview/is_single_entry', array($this, 'set_single_entry_id')); |
|
282 | 282 | |
283 | 283 | // Strip the new lines that are generated--when editing an entry in particular, scripts are printed that |
284 | 284 | // then are passed through wpautop() and everything looks terrible. |
285 | - $view_html = str_replace( "\n", ' ', $view_html ); |
|
285 | + $view_html = str_replace("\n", ' ', $view_html); |
|
286 | 286 | |
287 | 287 | return $view_html; |
288 | 288 | } |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return int The current entry ID |
298 | 298 | */ |
299 | - public function set_single_entry_id( $is_single_entry = false ) { |
|
299 | + public function set_single_entry_id($is_single_entry = false) { |
|
300 | 300 | |
301 | 301 | return $this->entry_id; |
302 | 302 | } |
@@ -310,17 +310,17 @@ discard block |
||
310 | 310 | * @param array $rawattr The original unmodified attributes. |
311 | 311 | * @return string The embed HTML. |
312 | 312 | */ |
313 | - private function render_frontend( $matches, $attr, $url, $rawattr ) { |
|
313 | + private function render_frontend($matches, $attr, $url, $rawattr) { |
|
314 | 314 | |
315 | 315 | // If it's already been parsed, don't re-output it. |
316 | - if( !empty( $this->output[ $this->entry_id ] ) ) { |
|
317 | - return $this->output[ $this->entry_id ]; |
|
316 | + if (!empty($this->output[$this->entry_id])) { |
|
317 | + return $this->output[$this->entry_id]; |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | $entry_output = $this->generate_entry_output(); |
321 | 321 | |
322 | 322 | // Wrap a container div around the output to allow for custom styling |
323 | - $output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output ); |
|
323 | + $output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output); |
|
324 | 324 | |
325 | 325 | /** |
326 | 326 | * @filter `gravityview/oembed/entry` Filter the output of the oEmbed entry embed |
@@ -333,13 +333,13 @@ discard block |
||
333 | 333 | * @var string $url The original URL that was matched by the regex. \n |
334 | 334 | * @var array $rawattr The original unmodified attributes. |
335 | 335 | */ |
336 | - $output = apply_filters('gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
336 | + $output = apply_filters('gravityview/oembed/entry', $output, $this, compact($entry_output, $matches, $attr, $url, $rawattr)); |
|
337 | 337 | |
338 | - unset( $entry_output ); |
|
338 | + unset($entry_output); |
|
339 | 339 | |
340 | - $this->output[ $this->entry_id ] = $output; |
|
340 | + $this->output[$this->entry_id] = $output; |
|
341 | 341 | |
342 | - return $this->output[ $this->entry_id ]; |
|
342 | + return $this->output[$this->entry_id]; |
|
343 | 343 | |
344 | 344 | } |
345 | 345 |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | |
18 | 18 | // Load custom post types. It's a static method. |
19 | 19 | // Load even when invalid to allow for export |
20 | - add_action( 'init', array( 'GravityView_Post_Types', 'init_post_types' ) ); |
|
20 | + add_action('init', array('GravityView_Post_Types', 'init_post_types')); |
|
21 | 21 | |
22 | - if( GravityView_Compatibility::is_valid() ) { |
|
23 | - add_action( 'init', array( 'GravityView_Post_Types', 'init_rewrite' ) ); |
|
22 | + if (GravityView_Compatibility::is_valid()) { |
|
23 | + add_action('init', array('GravityView_Post_Types', 'init_rewrite')); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | * @since 1.13 |
40 | 40 | * @param boolean $is_hierarchical Default: false |
41 | 41 | */ |
42 | - $is_hierarchical = (bool)apply_filters( 'gravityview_is_hierarchical', false ); |
|
42 | + $is_hierarchical = (bool)apply_filters('gravityview_is_hierarchical', false); |
|
43 | 43 | |
44 | - $supports = array( 'title', 'revisions' ); |
|
44 | + $supports = array('title', 'revisions'); |
|
45 | 45 | |
46 | - if( $is_hierarchical ) { |
|
46 | + if ($is_hierarchical) { |
|
47 | 47 | $supports[] = 'page-attributes'; |
48 | 48 | } |
49 | 49 | |
@@ -54,30 +54,30 @@ discard block |
||
54 | 54 | * @param array $supports Array of features associated with a functional area of the edit screen. Default: 'title', 'revisions'. If $is_hierarchical, also 'page-attributes' |
55 | 55 | * @param[in] boolean $is_hierarchical Do Views support parent/child relationships? See `gravityview_is_hierarchical` filter. |
56 | 56 | */ |
57 | - $supports = apply_filters( 'gravityview_post_type_support', $supports, $is_hierarchical ); |
|
57 | + $supports = apply_filters('gravityview_post_type_support', $supports, $is_hierarchical); |
|
58 | 58 | |
59 | 59 | //Register Custom Post Type - gravityview |
60 | 60 | $labels = array( |
61 | - 'name' => _x( 'Views', 'Post Type General Name', 'gravityview' ), |
|
62 | - 'singular_name' => _x( 'View', 'Post Type Singular Name', 'gravityview' ), |
|
63 | - 'menu_name' => _x( 'Views', 'Menu name', 'gravityview' ), |
|
64 | - 'parent_item_colon' => __( 'Parent View:', 'gravityview' ), |
|
65 | - 'all_items' => __( 'All Views', 'gravityview' ), |
|
66 | - 'view_item' => _x( 'View', 'View Item', 'gravityview' ), |
|
67 | - 'add_new_item' => __( 'Add New View', 'gravityview' ), |
|
68 | - 'add_new' => __( 'New View', 'gravityview' ), |
|
69 | - 'edit_item' => __( 'Edit View', 'gravityview' ), |
|
70 | - 'update_item' => __( 'Update View', 'gravityview' ), |
|
71 | - 'search_items' => __( 'Search Views', 'gravityview' ), |
|
61 | + 'name' => _x('Views', 'Post Type General Name', 'gravityview'), |
|
62 | + 'singular_name' => _x('View', 'Post Type Singular Name', 'gravityview'), |
|
63 | + 'menu_name' => _x('Views', 'Menu name', 'gravityview'), |
|
64 | + 'parent_item_colon' => __('Parent View:', 'gravityview'), |
|
65 | + 'all_items' => __('All Views', 'gravityview'), |
|
66 | + 'view_item' => _x('View', 'View Item', 'gravityview'), |
|
67 | + 'add_new_item' => __('Add New View', 'gravityview'), |
|
68 | + 'add_new' => __('New View', 'gravityview'), |
|
69 | + 'edit_item' => __('Edit View', 'gravityview'), |
|
70 | + 'update_item' => __('Update View', 'gravityview'), |
|
71 | + 'search_items' => __('Search Views', 'gravityview'), |
|
72 | 72 | 'not_found' => self::no_views_text(), |
73 | - 'not_found_in_trash' => __( 'No Views found in Trash', 'gravityview' ), |
|
74 | - 'filter_items_list' => __( 'Filter Views list', 'gravityview' ), |
|
75 | - 'items_list_navigation' => __( 'Views list navigation', 'gravityview' ), |
|
76 | - 'items_list' => __( 'Views list', 'gravityview' ), |
|
73 | + 'not_found_in_trash' => __('No Views found in Trash', 'gravityview'), |
|
74 | + 'filter_items_list' => __('Filter Views list', 'gravityview'), |
|
75 | + 'items_list_navigation' => __('Views list navigation', 'gravityview'), |
|
76 | + 'items_list' => __('Views list', 'gravityview'), |
|
77 | 77 | ); |
78 | 78 | $args = array( |
79 | - 'label' => __( 'view', 'gravityview' ), |
|
80 | - 'description' => __( 'Create views based on a Gravity Forms form', 'gravityview' ), |
|
79 | + 'label' => __('view', 'gravityview'), |
|
80 | + 'description' => __('Create views based on a Gravity Forms form', 'gravityview'), |
|
81 | 81 | 'labels' => $labels, |
82 | 82 | 'supports' => $supports, |
83 | 83 | 'hierarchical' => $is_hierarchical, |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param[in,out] boolean `true`: allow Views to be accessible directly. `false`: Only allow Views to be embedded via shortcode. Default: `true` |
89 | 89 | * @param int $view_id The ID of the View currently being requested. `0` for general setting |
90 | 90 | */ |
91 | - 'public' => apply_filters( 'gravityview_direct_access', GravityView_Compatibility::is_valid(), 0 ), |
|
91 | + 'public' => apply_filters('gravityview_direct_access', GravityView_Compatibility::is_valid(), 0), |
|
92 | 92 | 'show_ui' => GravityView_Compatibility::is_valid(), |
93 | 93 | 'show_in_menu' => GravityView_Compatibility::is_valid(), |
94 | 94 | 'show_in_nav_menus' => true, |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @since 1.7.3 |
102 | 102 | * @param boolean False: don't have frontend archive; True: yes, have archive. Default: false |
103 | 103 | */ |
104 | - 'has_archive' => apply_filters( 'gravityview_has_archive', false ), |
|
104 | + 'has_archive' => apply_filters('gravityview_has_archive', false), |
|
105 | 105 | 'exclude_from_search' => true, |
106 | 106 | 'rewrite' => array( |
107 | 107 | /** |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | * @see http://docs.gravityview.co/article/62-changing-the-view-slug |
110 | 110 | * @param string $slug The slug shown in the URL |
111 | 111 | */ |
112 | - 'slug' => apply_filters( 'gravityview_slug', 'view' ) |
|
112 | + 'slug' => apply_filters('gravityview_slug', 'view') |
|
113 | 113 | ), |
114 | 114 | 'capability_type' => 'gravityview', |
115 | 115 | 'map_meta_cap' => true, |
116 | 116 | ); |
117 | 117 | |
118 | - register_post_type( 'gravityview', $args ); |
|
118 | + register_post_type('gravityview', $args); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $endpoint = self::get_entry_var_name(); |
132 | 132 | |
133 | 133 | //add_permastruct( "{$endpoint}", $endpoint.'/%'.$endpoint.'%/?', true); |
134 | - add_rewrite_endpoint( "{$endpoint}", EP_ALL ); |
|
134 | + add_rewrite_endpoint("{$endpoint}", EP_ALL); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * @filter `gravityview_directory_endpoint` Change the slug used for single entries |
148 | 148 | * @param[in,out] string $endpoint Slug to use when accessing single entry. Default: `entry` |
149 | 149 | */ |
150 | - $endpoint = apply_filters( 'gravityview_directory_endpoint', 'entry' ); |
|
150 | + $endpoint = apply_filters('gravityview_directory_endpoint', 'entry'); |
|
151 | 151 | |
152 | - return sanitize_title( $endpoint ); |
|
152 | + return sanitize_title($endpoint); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -159,20 +159,20 @@ discard block |
||
159 | 159 | */ |
160 | 160 | static function no_views_text() { |
161 | 161 | |
162 | - if( !class_exists( 'GravityView_Admin' ) ) { |
|
163 | - require_once( GRAVITYVIEW_DIR .'includes/class-admin.php' ); |
|
162 | + if (!class_exists('GravityView_Admin')) { |
|
163 | + require_once(GRAVITYVIEW_DIR.'includes/class-admin.php'); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | // Floaty the astronaut |
167 | 167 | $image = GravityView_Admin::get_floaty(); |
168 | 168 | |
169 | - if( GVCommon::has_cap( 'edit_gravityviews' ) ) { |
|
170 | - $output = sprintf( esc_attr__( "%sYou don't have any active views. Let’s go %screate one%s!%s\n\nIf you feel like you're lost in space and need help getting started, check out the %sGetting Started%s page.", 'gravityview' ), '<h3>', '<a href="' . admin_url( 'post-new.php?post_type=gravityview' ) . '">', '</a>', '</h3>', '<a href="' . admin_url( 'edit.php?post_type=gravityview&page=gv-getting-started' ) . '">', '</a>' ); |
|
169 | + if (GVCommon::has_cap('edit_gravityviews')) { |
|
170 | + $output = sprintf(esc_attr__("%sYou don't have any active views. Let’s go %screate one%s!%s\n\nIf you feel like you're lost in space and need help getting started, check out the %sGetting Started%s page.", 'gravityview'), '<h3>', '<a href="'.admin_url('post-new.php?post_type=gravityview').'">', '</a>', '</h3>', '<a href="'.admin_url('edit.php?post_type=gravityview&page=gv-getting-started').'">', '</a>'); |
|
171 | 171 | } else { |
172 | - $output = esc_attr__( 'There are no active Views', 'gravityview' ); |
|
172 | + $output = esc_attr__('There are no active Views', 'gravityview'); |
|
173 | 173 | } |
174 | 174 | |
175 | - return $image . wpautop( $output ); |
|
175 | + return $image.wpautop($output); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * @param mixed $form_id |
22 | 22 | * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms |
23 | 23 | */ |
24 | -function gravityview_get_form( $form_id ) { |
|
25 | - return GVCommon::get_form( $form_id ); |
|
24 | +function gravityview_get_form($form_id) { |
|
25 | + return GVCommon::get_form($form_id); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * @param int|string $entry_slug Entry slug |
33 | 33 | * @return array Gravity Forms form array |
34 | 34 | */ |
35 | -function gravityview_get_form_from_entry_id( $entry_slug ) { |
|
36 | - return GVCommon::get_form_from_entry_id( $entry_slug ); |
|
35 | +function gravityview_get_form_from_entry_id($entry_slug) { |
|
36 | + return GVCommon::get_form_from_entry_id($entry_slug); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string|array $form_id (default: '') or $form object |
57 | 57 | * @return array |
58 | 58 | */ |
59 | -function gravityview_get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
|
60 | - return GVCommon::get_form_fields( $form, $add_default_properties, $include_parent_field ); |
|
59 | +function gravityview_get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true) { |
|
60 | + return GVCommon::get_form_fields($form, $add_default_properties, $include_parent_field); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @param string $form_id (default: '') |
66 | 66 | * @return array |
67 | 67 | */ |
68 | -function gravityview_get_entry_meta( $form_id, $only_default_column = true ) { |
|
69 | - return GVCommon::get_entry_meta( $form_id, $only_default_column ); |
|
68 | +function gravityview_get_entry_meta($form_id, $only_default_column = true) { |
|
69 | + return GVCommon::get_entry_meta($form_id, $only_default_column); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @since 1.1.6 |
78 | 78 | * @return array Array of entry IDs |
79 | 79 | */ |
80 | -function gravityview_get_entry_ids( $form_id, $search_criteria = array() ) { |
|
81 | - return GVCommon::get_entry_ids( $form_id, $search_criteria ); |
|
80 | +function gravityview_get_entry_ids($form_id, $search_criteria = array()) { |
|
81 | + return GVCommon::get_entry_ids($form_id, $search_criteria); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @param mixed &$total (default: null) |
94 | 94 | * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays |
95 | 95 | */ |
96 | -function gravityview_get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { |
|
97 | - return GVCommon::get_entries( $form_ids, $passed_criteria, $total ); |
|
96 | +function gravityview_get_entries($form_ids = null, $passed_criteria = null, &$total = null) { |
|
97 | + return GVCommon::get_entries($form_ids, $passed_criteria, $total); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true {@since 1.14} |
109 | 109 | * @return array|boolean |
110 | 110 | */ |
111 | -function gravityview_get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) { |
|
112 | - return GVCommon::get_entry( $entry_slug, $force_allow_ids, $check_entry_display ); |
|
111 | +function gravityview_get_entry($entry_slug, $force_allow_ids = false, $check_entry_display = true) { |
|
112 | + return GVCommon::get_entry($entry_slug, $force_allow_ids, $check_entry_display); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @param mixed $field_id |
121 | 121 | * @return string |
122 | 122 | */ |
123 | -function gravityview_get_field_label( $form, $field_id ) { |
|
124 | - return GVCommon::get_field_label( $form, $field_id ); |
|
123 | +function gravityview_get_field_label($form, $field_id) { |
|
124 | + return GVCommon::get_field_label($form, $field_id); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | * @param string|int $field_id |
138 | 138 | * @return array |
139 | 139 | */ |
140 | -function gravityview_get_field( $form, $field_id ) { |
|
141 | - return GVCommon::get_field( $form, $field_id ); |
|
140 | +function gravityview_get_field($form, $field_id) { |
|
141 | + return GVCommon::get_field($form, $field_id); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -151,16 +151,16 @@ discard block |
||
151 | 151 | * @param WP_Post $post WordPress post object |
152 | 152 | * @return boolean True: yep, GravityView; No: not! |
153 | 153 | */ |
154 | -function has_gravityview_shortcode( $post = NULL ) { |
|
155 | - return GVCommon::has_gravityview_shortcode( $post ); |
|
154 | +function has_gravityview_shortcode($post = NULL) { |
|
155 | + return GVCommon::has_gravityview_shortcode($post); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Placeholder until the recursive has_shortcode() patch is merged |
160 | 160 | * @see https://core.trac.wordpress.org/ticket/26343#comment:10 |
161 | 161 | */ |
162 | -function gravityview_has_shortcode_r( $content, $tag = 'gravityview' ) { |
|
163 | - return GVCommon::has_shortcode_r( $content, $tag ); |
|
162 | +function gravityview_has_shortcode_r($content, $tag = 'gravityview') { |
|
163 | + return GVCommon::has_shortcode_r($content, $tag); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param int $form_id Gravity Forms form ID |
169 | 169 | * @return array Array with view details |
170 | 170 | */ |
171 | -function gravityview_get_connected_views( $form_id ) { |
|
172 | - return GVCommon::get_connected_views( $form_id ); |
|
171 | +function gravityview_get_connected_views($form_id) { |
|
172 | + return GVCommon::get_connected_views($form_id); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return int |
181 | 181 | */ |
182 | -function gravityview_get_form_id( $view_id ) { |
|
183 | - return GVCommon::get_meta_form_id( $view_id ); |
|
182 | +function gravityview_get_form_id($view_id) { |
|
183 | + return GVCommon::get_meta_form_id($view_id); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return string GravityView_Template::template_id value. Empty string if not. |
194 | 194 | */ |
195 | -function gravityview_get_template_id( $post_id ) { |
|
196 | - return GVCommon::get_meta_template_id( $post_id ); |
|
195 | +function gravityview_get_template_id($post_id) { |
|
196 | + return GVCommon::get_meta_template_id($post_id); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | * @param int $post_id View ID |
204 | 204 | * @return array Associative array of settings with plugin defaults used if not set by the View |
205 | 205 | */ |
206 | -function gravityview_get_template_settings( $post_id ) { |
|
207 | - return GVCommon::get_template_settings( $post_id ); |
|
206 | +function gravityview_get_template_settings($post_id) { |
|
207 | + return GVCommon::get_template_settings($post_id); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | * @param string $key Key for the setting |
217 | 217 | * @return mixed|null Setting value, or NULL if not set. |
218 | 218 | */ |
219 | -function gravityview_get_template_setting( $post_id, $key ) { |
|
220 | - return GVCommon::get_template_setting( $post_id, $key ); |
|
219 | +function gravityview_get_template_setting($post_id, $key) { |
|
220 | + return GVCommon::get_template_setting($post_id, $key); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @filter `gravityview_register_directory_template` Fetch available View templates |
232 | 232 | * @param array $templates Templates to show |
233 | 233 | */ |
234 | - $templates = apply_filters( 'gravityview_register_directory_template', array() ); |
|
234 | + $templates = apply_filters('gravityview_register_directory_template', array()); |
|
235 | 235 | |
236 | 236 | return $templates; |
237 | 237 | } |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @param int $post_id View ID |
267 | 267 | * @return array Multi-array of fields with first level being the field zones. See code comment. |
268 | 268 | */ |
269 | -function gravityview_get_directory_fields( $post_id ) { |
|
270 | - return GVCommon::get_directory_fields( $post_id ); |
|
269 | +function gravityview_get_directory_fields($post_id) { |
|
270 | + return GVCommon::get_directory_fields($post_id); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @param string $current Field ID of field used to sort |
279 | 279 | * @return string html |
280 | 280 | */ |
281 | -function gravityview_get_sortable_fields( $formid, $current = '' ) { |
|
282 | - return GVCommon::get_sortable_fields( $formid, $current ); |
|
281 | +function gravityview_get_sortable_fields($formid, $current = '') { |
|
282 | + return GVCommon::get_sortable_fields($formid, $current); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param mixed $field_id Field ID or Field array |
290 | 290 | * @return string field type |
291 | 291 | */ |
292 | -function gravityview_get_field_type( $form = null , $field_id = '' ) { |
|
293 | - return GVCommon::get_field_type( $form, $field_id ); |
|
292 | +function gravityview_get_field_type($form = null, $field_id = '') { |
|
293 | + return GVCommon::get_field_type($form, $field_id); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -302,15 +302,15 @@ discard block |
||
302 | 302 | * @param array $atts (default: array()) |
303 | 303 | * @return string HTML of the output. Empty string if $view_id is empty. |
304 | 304 | */ |
305 | -function get_gravityview( $view_id = '', $atts = array() ) { |
|
306 | - if( !empty( $view_id ) ) { |
|
305 | +function get_gravityview($view_id = '', $atts = array()) { |
|
306 | + if (!empty($view_id)) { |
|
307 | 307 | $atts['id'] = $view_id; |
308 | - $args = wp_parse_args( $atts, GravityView_View_Data::get_default_args() ); |
|
308 | + $args = wp_parse_args($atts, GravityView_View_Data::get_default_args()); |
|
309 | 309 | $GravityView_frontend = GravityView_frontend::getInstance(); |
310 | - $GravityView_frontend->setGvOutputData( GravityView_View_Data::getInstance( $view_id ) ); |
|
311 | - $GravityView_frontend->set_context_view_id( $view_id ); |
|
310 | + $GravityView_frontend->setGvOutputData(GravityView_View_Data::getInstance($view_id)); |
|
311 | + $GravityView_frontend->set_context_view_id($view_id); |
|
312 | 312 | $GravityView_frontend->set_entry_data(); |
313 | - return $GravityView_frontend->render_view( $args ); |
|
313 | + return $GravityView_frontend->render_view($args); |
|
314 | 314 | } |
315 | 315 | return ''; |
316 | 316 | } |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param array $atts (default: array()) |
324 | 324 | * @return void |
325 | 325 | */ |
326 | -function the_gravityview( $view_id = '', $atts = array() ) { |
|
327 | - echo get_gravityview( $view_id, $atts ); |
|
326 | +function the_gravityview($view_id = '', $atts = array()) { |
|
327 | + echo get_gravityview($view_id, $atts); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -345,17 +345,17 @@ discard block |
||
345 | 345 | * @param array $form Gravity Forms form |
346 | 346 | * @param array $view_fields GravityView fields array |
347 | 347 | */ |
348 | -function gravityview_view_has_single_checkbox_or_radio( $form, $view_fields ) { |
|
348 | +function gravityview_view_has_single_checkbox_or_radio($form, $view_fields) { |
|
349 | 349 | |
350 | - if( $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
350 | + if ($form_fields = GFFormsModel::get_fields_by_type($form, array('checkbox', 'radio'))) { |
|
351 | 351 | |
352 | 352 | /** @var GF_Field_Radio|GF_Field_Checkbox $form_field */ |
353 | - foreach( $form_fields as $form_field ) { |
|
353 | + foreach ($form_fields as $form_field) { |
|
354 | 354 | $field_id = $form_field->id; |
355 | - foreach( $view_fields as $zone ) { |
|
356 | - foreach( $zone as $field ) { |
|
355 | + foreach ($view_fields as $zone) { |
|
356 | + foreach ($zone as $field) { |
|
357 | 357 | // If it's an input, not the parent and the parent ID matches a checkbox or radio |
358 | - if( ( strpos( $field['id'], '.' ) > 0 ) && floor( $field['id'] ) === floor( $field_id ) ) { |
|
358 | + if ((strpos($field['id'], '.') > 0) && floor($field['id']) === floor($field_id)) { |
|
359 | 359 | return true; |
360 | 360 | } |
361 | 361 | } |
@@ -5,4 +5,4 @@ |
||
5 | 5 | * @deprecated 1.7.5 |
6 | 6 | */ |
7 | 7 | |
8 | -include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' ); |
|
8 | +include_once(GRAVITYVIEW_DIR.'includes/widgets/class-gravityview-widget.php'); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @copyright Copyright 2014, Katz Web Services, Inc. |
13 | 13 | */ |
14 | 14 | |
15 | -if ( ! defined( 'WPINC' ) ) { |
|
15 | +if (!defined('WPINC')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | 18 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | function __construct() { |
32 | 32 | |
33 | - self::$file = plugin_dir_path( __FILE__ ); |
|
33 | + self::$file = plugin_dir_path(__FILE__); |
|
34 | 34 | |
35 | 35 | $this->add_hooks(); |
36 | 36 | } |
@@ -39,22 +39,22 @@ discard block |
||
39 | 39 | * @since 1.9.2 |
40 | 40 | */ |
41 | 41 | private function add_hooks() { |
42 | - add_action( 'wp', array( $this, 'process_delete' ), 10000 ); |
|
42 | + add_action('wp', array($this, 'process_delete'), 10000); |
|
43 | 43 | |
44 | - add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field'), 10, 3 ); |
|
44 | + add_filter('gravityview_entry_default_fields', array($this, 'add_default_field'), 10, 3); |
|
45 | 45 | |
46 | - add_action( 'gravityview_before', array( $this, 'display_message' ) ); |
|
46 | + add_action('gravityview_before', array($this, 'display_message')); |
|
47 | 47 | |
48 | 48 | // For the Delete Entry Link, you don't want visible to all users. |
49 | - add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps'), 10, 5 ); |
|
49 | + add_filter('gravityview_field_visibility_caps', array($this, 'modify_visibility_caps'), 10, 5); |
|
50 | 50 | |
51 | 51 | // Modify the field options based on the name of the field type |
52 | - add_filter( 'gravityview_template_delete_link_options', array( $this, 'delete_link_field_options' ), 10, 5 ); |
|
52 | + add_filter('gravityview_template_delete_link_options', array($this, 'delete_link_field_options'), 10, 5); |
|
53 | 53 | |
54 | 54 | // add template path to check for field |
55 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
55 | + add_filter('gravityview_template_paths', array($this, 'add_template_path')); |
|
56 | 56 | |
57 | - add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button'), 10, 3 ); |
|
57 | + add_action('gravityview/edit-entry/publishing-action/after', array($this, 'add_delete_button'), 10, 3); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | static function getInstance() { |
67 | 67 | |
68 | - if( empty( self::$instance ) ) { |
|
68 | + if (empty(self::$instance)) { |
|
69 | 69 | self::$instance = new self; |
70 | 70 | } |
71 | 71 | |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | * @since 1.5.1 |
79 | 79 | * @param array $file_paths List of template paths ordered |
80 | 80 | */ |
81 | - function add_template_path( $file_paths ) { |
|
81 | + function add_template_path($file_paths) { |
|
82 | 82 | |
83 | 83 | // Index 100 is the default GravityView template path. |
84 | 84 | // Index 110 is Edit Entry link |
85 | - $file_paths[ 115 ] = self::$file; |
|
85 | + $file_paths[115] = self::$file; |
|
86 | 86 | |
87 | 87 | return $file_paths; |
88 | 88 | } |
@@ -98,17 +98,17 @@ discard block |
||
98 | 98 | * @param [type] $input_type [description] |
99 | 99 | * @return [type] [description] |
100 | 100 | */ |
101 | - function delete_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
|
101 | + function delete_link_field_options($field_options, $template_id, $field_id, $context, $input_type) { |
|
102 | 102 | |
103 | 103 | // Always a link, never a filter |
104 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
104 | + unset($field_options['show_as_link'], $field_options['search_filter']); |
|
105 | 105 | |
106 | 106 | // Delete Entry link should only appear to visitors capable of editing entries |
107 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
107 | + unset($field_options['only_loggedin'], $field_options['only_loggedin_cap']); |
|
108 | 108 | |
109 | 109 | $add_option['delete_link'] = array( |
110 | 110 | 'type' => 'text', |
111 | - 'label' => __( 'Delete Link Text', 'gravityview' ), |
|
111 | + 'label' => __('Delete Link Text', 'gravityview'), |
|
112 | 112 | 'desc' => NULL, |
113 | 113 | 'value' => __('Delete Entry', 'gravityview'), |
114 | 114 | 'merge_tags' => true, |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | |
117 | 117 | $field_options['allow_edit_cap'] = array( |
118 | 118 | 'type' => 'select', |
119 | - 'label' => __( 'Allow the following users to delete the entry:', 'gravityview' ), |
|
120 | - 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
|
119 | + 'label' => __('Allow the following users to delete the entry:', 'gravityview'), |
|
120 | + 'choices' => GravityView_Render_Settings::get_cap_choices($template_id, $field_id, $context, $input_type), |
|
121 | 121 | 'tooltip' => 'allow_edit_cap', |
122 | 122 | 'class' => 'widefat', |
123 | 123 | 'value' => 'read', // Default: entry creator |
124 | 124 | ); |
125 | 125 | |
126 | 126 | |
127 | - return array_merge( $add_option, $field_options ); |
|
127 | + return array_merge($add_option, $field_options); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param string|array $form form_ID or form object |
137 | 137 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
138 | 138 | */ |
139 | - function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
|
139 | + function add_default_field($entry_default_fields, $form = array(), $zone = '') { |
|
140 | 140 | |
141 | 141 | $entry_default_fields['delete_link'] = array( |
142 | 142 | 'label' => __('Delete Entry', 'gravityview'), |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | * @since 1.5.1 |
153 | 153 | * @param array $available_fields |
154 | 154 | */ |
155 | - function add_available_field( $available_fields = array() ) { |
|
155 | + function add_available_field($available_fields = array()) { |
|
156 | 156 | |
157 | 157 | $available_fields['delete_link'] = array( |
158 | - 'label_text' => __( 'Delete Entry', 'gravityview' ), |
|
158 | + 'label_text' => __('Delete Entry', 'gravityview'), |
|
159 | 159 | 'field_id' => 'delete_link', |
160 | 160 | 'label_type' => 'field', |
161 | 161 | 'input_type' => 'delete_link', |
@@ -177,15 +177,15 @@ discard block |
||
177 | 177 | * @param string $input_type (textarea, list, select, etc.) |
178 | 178 | * @return array Array of field options with `label`, `value`, `type`, `default` keys |
179 | 179 | */ |
180 | - public function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) { |
|
180 | + public function modify_visibility_caps($visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '') { |
|
181 | 181 | |
182 | 182 | $caps = $visibility_caps; |
183 | 183 | |
184 | 184 | // If we're configuring fields in the edit context, we want a limited selection |
185 | - if( $field_id === 'delete_link' ) { |
|
185 | + if ($field_id === 'delete_link') { |
|
186 | 186 | |
187 | 187 | // Remove other built-in caps. |
188 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
188 | + unset($caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts']); |
|
189 | 189 | |
190 | 190 | $caps['read'] = _x('Entry Creator', 'User capability', 'gravityview'); |
191 | 191 | } |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @since 1.5.1 |
200 | 200 | * @param [type] $entry [description] |
201 | 201 | */ |
202 | - function set_entry( $entry = null ) { |
|
203 | - $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry; |
|
202 | + function set_entry($entry = null) { |
|
203 | + $this->entry = empty($entry) ? GravityView_View::getInstance()->entries[0] : $entry; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * @param int $entry_id Entry ID |
211 | 211 | * @return string Key used to validate request |
212 | 212 | */ |
213 | - public static function get_nonce_key( $entry_id ) { |
|
214 | - return sprintf( 'delete_%s', $entry_id ); |
|
213 | + public static function get_nonce_key($entry_id) { |
|
214 | + return sprintf('delete_%s', $entry_id); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
@@ -224,30 +224,30 @@ discard block |
||
224 | 224 | * @param array $entry Gravity Forms entry array |
225 | 225 | * @return string|null If directory link is valid, the URL to process the delete request. Otherwise, `NULL`. |
226 | 226 | */ |
227 | - public static function get_delete_link( $entry, $view_id = 0, $post_id = null ) { |
|
227 | + public static function get_delete_link($entry, $view_id = 0, $post_id = null) { |
|
228 | 228 | |
229 | - self::getInstance()->set_entry( $entry ); |
|
229 | + self::getInstance()->set_entry($entry); |
|
230 | 230 | |
231 | - $base = GravityView_API::directory_link( $post_id, true ); |
|
231 | + $base = GravityView_API::directory_link($post_id, true); |
|
232 | 232 | |
233 | - if( empty( $base ) ) { |
|
234 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id ); |
|
233 | + if (empty($base)) { |
|
234 | + do_action('gravityview_log_error', __METHOD__.' - Post ID does not exist: '.$post_id); |
|
235 | 235 | return NULL; |
236 | 236 | } |
237 | 237 | |
238 | 238 | // Use the slug instead of the ID for consistent security |
239 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
239 | + $entry_slug = GravityView_API::get_entry_slug($entry['id'], $entry); |
|
240 | 240 | |
241 | - $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id; |
|
241 | + $view_id = empty($view_id) ? gravityview_get_view_id() : $view_id; |
|
242 | 242 | |
243 | - $actionurl = add_query_arg( array( |
|
243 | + $actionurl = add_query_arg(array( |
|
244 | 244 | 'action' => 'delete', |
245 | 245 | 'entry_id' => $entry_slug, |
246 | 246 | 'gvid' => $view_id, |
247 | 247 | 'view_id' => $view_id, |
248 | - ), $base ); |
|
248 | + ), $base); |
|
249 | 249 | |
250 | - $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' ); |
|
250 | + $url = wp_nonce_url($actionurl, 'delete_'.$entry_slug, 'delete'); |
|
251 | 251 | |
252 | 252 | return $url; |
253 | 253 | } |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | * @param array $entry Gravity Forms entry array |
262 | 262 | * @param int $view_id GravityView View ID |
263 | 263 | */ |
264 | - function add_delete_button( $form = array(), $entry = array(), $view_id = NULL ) { |
|
264 | + function add_delete_button($form = array(), $entry = array(), $view_id = NULL) { |
|
265 | 265 | |
266 | 266 | // Only show the link to those who are allowed to see it. |
267 | - if( !self::check_user_cap_delete_entry( $entry ) ) { |
|
267 | + if (!self::check_user_cap_delete_entry($entry)) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | * @filter `gravityview/delete-entry/show-delete-button` Should the Delete button be shown in the Edit Entry screen? |
273 | 273 | * @param boolean $show_entry Default: true |
274 | 274 | */ |
275 | - $show_delete_button = apply_filters( 'gravityview/delete-entry/show-delete-button', true ); |
|
275 | + $show_delete_button = apply_filters('gravityview/delete-entry/show-delete-button', true); |
|
276 | 276 | |
277 | 277 | // If the button is hidden by the filter, don't show. |
278 | - if( !$show_delete_button ) { |
|
278 | + if (!$show_delete_button) { |
|
279 | 279 | return; |
280 | 280 | } |
281 | 281 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | 'onclick' => self::get_confirm_dialog(), |
286 | 286 | ); |
287 | 287 | |
288 | - echo gravityview_get_link( self::get_delete_link( $entry, $view_id ), esc_attr__( 'Delete', 'gravityview' ), $attributes ); |
|
288 | + echo gravityview_get_link(self::get_delete_link($entry, $view_id), esc_attr__('Delete', 'gravityview'), $attributes); |
|
289 | 289 | |
290 | 290 | } |
291 | 291 | |
@@ -305,39 +305,39 @@ discard block |
||
305 | 305 | function process_delete() { |
306 | 306 | |
307 | 307 | // If the form is submitted |
308 | - if( RGForms::get("action") === "delete") { |
|
308 | + if (RGForms::get("action") === "delete") { |
|
309 | 309 | |
310 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
310 | + $nonce_key = self::get_nonce_key($_GET['entry_id']); |
|
311 | 311 | |
312 | 312 | // Make sure it's a valid request |
313 | - check_admin_referer( $nonce_key, 'delete' ); |
|
313 | + check_admin_referer($nonce_key, 'delete'); |
|
314 | 314 | |
315 | 315 | // Get the entry slug |
316 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
316 | + $entry_slug = esc_attr($_GET['entry_id']); |
|
317 | 317 | |
318 | 318 | // See if there's an entry there |
319 | - $entry = gravityview_get_entry( $entry_slug ); |
|
319 | + $entry = gravityview_get_entry($entry_slug); |
|
320 | 320 | |
321 | - if( $entry ) { |
|
321 | + if ($entry) { |
|
322 | 322 | |
323 | - $has_permission = $this->user_can_delete_entry( $entry ); |
|
323 | + $has_permission = $this->user_can_delete_entry($entry); |
|
324 | 324 | |
325 | - if( is_wp_error( $has_permission ) ) { |
|
325 | + if (is_wp_error($has_permission)) { |
|
326 | 326 | |
327 | 327 | $messages = array( |
328 | - 'message' => urlencode( $has_permission->get_error_message() ), |
|
328 | + 'message' => urlencode($has_permission->get_error_message()), |
|
329 | 329 | 'status' => 'error', |
330 | 330 | ); |
331 | 331 | |
332 | 332 | } else { |
333 | 333 | |
334 | 334 | // Delete the entry |
335 | - $delete_response = $this->delete_or_trash_entry( $entry['id'] ); |
|
335 | + $delete_response = $this->delete_or_trash_entry($entry['id']); |
|
336 | 336 | |
337 | - if( is_wp_error( $delete_response ) ) { |
|
337 | + if (is_wp_error($delete_response)) { |
|
338 | 338 | |
339 | 339 | $messages = array( |
340 | - 'message' => urlencode( $delete_response->get_error_message() ), |
|
340 | + 'message' => urlencode($delete_response->get_error_message()), |
|
341 | 341 | 'status' => 'error', |
342 | 342 | ); |
343 | 343 | |
@@ -353,18 +353,18 @@ discard block |
||
353 | 353 | |
354 | 354 | } else { |
355 | 355 | |
356 | - do_action('gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug '. $entry_slug ); |
|
356 | + do_action('gravityview_log_debug', __METHOD__.' Delete entry failed: there was no entry with the entry slug '.$entry_slug); |
|
357 | 357 | |
358 | 358 | $messages = array( |
359 | - 'message' => urlencode( __('The entry does not exist.', 'gravityview') ), |
|
359 | + 'message' => urlencode(__('The entry does not exist.', 'gravityview')), |
|
360 | 360 | 'status' => 'error', |
361 | 361 | ); |
362 | 362 | } |
363 | 363 | |
364 | - $redirect_to_base = esc_url_raw( remove_query_arg( array( 'action' ) ) ); |
|
365 | - $redirect_to = add_query_arg( $messages, $redirect_to_base ); |
|
364 | + $redirect_to_base = esc_url_raw(remove_query_arg(array('action'))); |
|
365 | + $redirect_to = add_query_arg($messages, $redirect_to_base); |
|
366 | 366 | |
367 | - wp_safe_redirect( $redirect_to ); |
|
367 | + wp_safe_redirect($redirect_to); |
|
368 | 368 | |
369 | 369 | exit(); |
370 | 370 | |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | * @since 1.13.1 |
385 | 385 | * @param string $delete_mode Delete mode: `trash` or `delete`. Default: `delete` |
386 | 386 | */ |
387 | - $delete_mode = apply_filters( 'gravityview/delete-entry/mode', 'delete' ); |
|
387 | + $delete_mode = apply_filters('gravityview/delete-entry/mode', 'delete'); |
|
388 | 388 | |
389 | - return ( 'trash' === $delete_mode ) ? 'trash' : 'delete'; |
|
389 | + return ('trash' === $delete_mode) ? 'trash' : 'delete'; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -394,37 +394,37 @@ discard block |
||
394 | 394 | * @see GFAPI::delete_entry() |
395 | 395 | * @return WP_Error|boolean GFAPI::delete_entry() returns a WP_Error on error |
396 | 396 | */ |
397 | - private function delete_or_trash_entry( $entry_id ) { |
|
397 | + private function delete_or_trash_entry($entry_id) { |
|
398 | 398 | |
399 | 399 | $mode = $this->get_delete_mode(); |
400 | 400 | |
401 | - if( 'delete' === $mode ) { |
|
401 | + if ('delete' === $mode) { |
|
402 | 402 | |
403 | - do_action( 'gravityview_log_debug', __METHOD__ . ' Starting delete entry: ', $entry_id ); |
|
403 | + do_action('gravityview_log_debug', __METHOD__.' Starting delete entry: ', $entry_id); |
|
404 | 404 | |
405 | 405 | // Delete the entry |
406 | - $delete_response = GFAPI::delete_entry( $entry_id ); |
|
406 | + $delete_response = GFAPI::delete_entry($entry_id); |
|
407 | 407 | |
408 | - if( ! is_wp_error( $delete_response ) ) { |
|
408 | + if (!is_wp_error($delete_response)) { |
|
409 | 409 | $delete_response = 'deleted'; |
410 | 410 | } |
411 | 411 | |
412 | - do_action( 'gravityview_log_debug', __METHOD__ . ' Delete response: ', $delete_response ); |
|
412 | + do_action('gravityview_log_debug', __METHOD__.' Delete response: ', $delete_response); |
|
413 | 413 | |
414 | 414 | } else { |
415 | 415 | |
416 | - do_action( 'gravityview_log_debug', __METHOD__ . ' Starting trash entry: ', $entry_id ); |
|
416 | + do_action('gravityview_log_debug', __METHOD__.' Starting trash entry: ', $entry_id); |
|
417 | 417 | |
418 | - $trashed = GFAPI::update_entry_property( $entry_id, 'status', 'trash' ); |
|
418 | + $trashed = GFAPI::update_entry_property($entry_id, 'status', 'trash'); |
|
419 | 419 | new GravityView_Cache; |
420 | 420 | |
421 | - if( ! $trashed ) { |
|
422 | - $delete_response = new WP_Error( 'trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview' ) ); |
|
421 | + if (!$trashed) { |
|
422 | + $delete_response = new WP_Error('trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview')); |
|
423 | 423 | } else { |
424 | 424 | $delete_response = 'trashed'; |
425 | 425 | } |
426 | 426 | |
427 | - do_action( 'gravityview_log_debug', __METHOD__ . ' Trashed? ', $delete_response ); |
|
427 | + do_action('gravityview_log_debug', __METHOD__.' Trashed? ', $delete_response); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | return $delete_response; |
@@ -439,13 +439,13 @@ discard block |
||
439 | 439 | public function verify_nonce() { |
440 | 440 | |
441 | 441 | // No delete entry request was made |
442 | - if( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) { |
|
442 | + if (empty($_GET['entry_id']) || empty($_GET['delete'])) { |
|
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | |
446 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
446 | + $nonce_key = self::get_nonce_key($_GET['entry_id']); |
|
447 | 447 | |
448 | - $valid = wp_verify_nonce( $_GET['delete'], $nonce_key ); |
|
448 | + $valid = wp_verify_nonce($_GET['delete'], $nonce_key); |
|
449 | 449 | |
450 | 450 | /** |
451 | 451 | * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid. |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * @param int|boolean $valid False if invalid; 1 or 2 when nonce was generated |
455 | 455 | * @param string $nonce_key Name of nonce action used in wp_verify_nonce. $_GET['delete'] holds the nonce value itself. Default: `delete_{entry_id}` |
456 | 456 | */ |
457 | - $valid = apply_filters( 'gravityview/delete-entry/verify_nonce', $valid, $nonce_key ); |
|
457 | + $valid = apply_filters('gravityview/delete-entry/verify_nonce', $valid, $nonce_key); |
|
458 | 458 | |
459 | 459 | return $valid; |
460 | 460 | } |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | * @filter `gravityview/delete-entry/confirm-text` Modify the Delete Entry Javascript confirmation text |
474 | 474 | * @param string $confirm Default: "Are you sure you want to delete this entry? This cannot be undone." |
475 | 475 | */ |
476 | - $confirm = apply_filters( 'gravityview/delete-entry/confirm-text', $confirm ); |
|
476 | + $confirm = apply_filters('gravityview/delete-entry/confirm-text', $confirm); |
|
477 | 477 | |
478 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
478 | + return 'return window.confirm(\''.esc_js($confirm).'\');'; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
@@ -489,34 +489,34 @@ discard block |
||
489 | 489 | * @param array $entry Gravity Forms entry array |
490 | 490 | * @return boolean|WP_Error True: can edit form. WP_Error: nope. |
491 | 491 | */ |
492 | - function user_can_delete_entry( $entry = array() ) { |
|
492 | + function user_can_delete_entry($entry = array()) { |
|
493 | 493 | |
494 | 494 | $error = NULL; |
495 | 495 | |
496 | - if( ! $this->verify_nonce() ) { |
|
497 | - $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview'); |
|
496 | + if (!$this->verify_nonce()) { |
|
497 | + $error = __('The link to delete this entry is not valid; it may have expired.', 'gravityview'); |
|
498 | 498 | } |
499 | 499 | |
500 | - if( ! self::check_user_cap_delete_entry( $entry ) ) { |
|
501 | - $error = __( 'You do not have permission to delete this entry.', 'gravityview'); |
|
500 | + if (!self::check_user_cap_delete_entry($entry)) { |
|
501 | + $error = __('You do not have permission to delete this entry.', 'gravityview'); |
|
502 | 502 | } |
503 | 503 | |
504 | - if( $entry['status'] === 'trash' ) { |
|
505 | - if( 'trash' === $this->get_delete_mode() ) { |
|
506 | - $error = __( 'The entry is already in the trash.', 'gravityview' ); |
|
504 | + if ($entry['status'] === 'trash') { |
|
505 | + if ('trash' === $this->get_delete_mode()) { |
|
506 | + $error = __('The entry is already in the trash.', 'gravityview'); |
|
507 | 507 | } else { |
508 | - $error = __( 'You cannot delete the entry; it is already in the trash.', 'gravityview' ); |
|
508 | + $error = __('You cannot delete the entry; it is already in the trash.', 'gravityview'); |
|
509 | 509 | } |
510 | 510 | } |
511 | 511 | |
512 | 512 | // No errors; everything's fine here! |
513 | - if( empty( $error ) ) { |
|
513 | + if (empty($error)) { |
|
514 | 514 | return true; |
515 | 515 | } |
516 | 516 | |
517 | - do_action('gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error ); |
|
517 | + do_action('gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]'.$error); |
|
518 | 518 | |
519 | - return new WP_Error( 'gravityview-delete-entry-permissions', $error ); |
|
519 | + return new WP_Error('gravityview-delete-entry-permissions', $error); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -531,77 +531,77 @@ discard block |
||
531 | 531 | * @param int $view_id Pass a View ID to check caps against. If not set, check against current View (optional) |
532 | 532 | * @return bool |
533 | 533 | */ |
534 | - public static function check_user_cap_delete_entry( $entry, $field = array(), $view_id = 0 ) { |
|
534 | + public static function check_user_cap_delete_entry($entry, $field = array(), $view_id = 0) { |
|
535 | 535 | $gravityview_view = GravityView_View::getInstance(); |
536 | 536 | |
537 | 537 | $current_user = wp_get_current_user(); |
538 | 538 | |
539 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL; |
|
539 | + $entry_id = isset($entry['id']) ? $entry['id'] : NULL; |
|
540 | 540 | |
541 | 541 | // Or if they can delete any entries (as defined in Gravity Forms), we're good. |
542 | - if( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { |
|
542 | + if (GVCommon::has_cap(array('gravityforms_delete_entries', 'gravityview_delete_others_entries'), $entry_id)) { |
|
543 | 543 | |
544 | - do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' ); |
|
544 | + do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.'); |
|
545 | 545 | |
546 | 546 | return true; |
547 | 547 | } |
548 | 548 | |
549 | 549 | |
550 | 550 | // If field options are passed, check if current user can view the link |
551 | - if( !empty( $field ) ) { |
|
551 | + if (!empty($field)) { |
|
552 | 552 | |
553 | 553 | // If capability is not defined, something is not right! |
554 | - if( empty( $field['allow_edit_cap'] ) ) { |
|
554 | + if (empty($field['allow_edit_cap'])) { |
|
555 | 555 | |
556 | - do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Cannot read delete entry field caps', $field ); |
|
556 | + do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Cannot read delete entry field caps', $field); |
|
557 | 557 | |
558 | 558 | return false; |
559 | 559 | } |
560 | 560 | |
561 | - if( GVCommon::has_cap( $field['allow_edit_cap'] ) ) { |
|
561 | + if (GVCommon::has_cap($field['allow_edit_cap'])) { |
|
562 | 562 | |
563 | 563 | // Do not return true if cap is read, as we need to check if the current user created the entry |
564 | - if( $field['allow_edit_cap'] !== 'read' ) { |
|
564 | + if ($field['allow_edit_cap'] !== 'read') { |
|
565 | 565 | return true; |
566 | 566 | } |
567 | 567 | |
568 | 568 | } else { |
569 | 569 | |
570 | - do_action( 'gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s is not authorized to view delete entry link ', $current_user->ID ) ); |
|
570 | + do_action('gravityview_log_debug', sprintf('GravityView_Delete_Entry[check_user_cap_delete_entry] User %s is not authorized to view delete entry link ', $current_user->ID)); |
|
571 | 571 | |
572 | 572 | return false; |
573 | 573 | } |
574 | 574 | |
575 | 575 | } |
576 | 576 | |
577 | - if( !isset( $entry['created_by'] ) ) { |
|
577 | + if (!isset($entry['created_by'])) { |
|
578 | 578 | |
579 | 579 | do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.'); |
580 | 580 | |
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | |
584 | - $view_id = empty( $view_id ) ? $gravityview_view->getViewId() : $view_id; |
|
584 | + $view_id = empty($view_id) ? $gravityview_view->getViewId() : $view_id; |
|
585 | 585 | |
586 | 586 | // Only checks user_delete view option if view is already set |
587 | - if( $view_id ) { |
|
587 | + if ($view_id) { |
|
588 | 588 | |
589 | - $current_view = gravityview_get_current_view_data( $view_id ); |
|
589 | + $current_view = gravityview_get_current_view_data($view_id); |
|
590 | 590 | |
591 | - $user_delete = isset( $current_view['atts']['user_delete'] ) ? $current_view['atts']['user_delete'] : false; |
|
591 | + $user_delete = isset($current_view['atts']['user_delete']) ? $current_view['atts']['user_delete'] : false; |
|
592 | 592 | |
593 | - if( empty( $user_delete ) ) { |
|
593 | + if (empty($user_delete)) { |
|
594 | 594 | |
595 | - do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' ); |
|
595 | + do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.'); |
|
596 | 596 | |
597 | 597 | return false; |
598 | 598 | } |
599 | 599 | } |
600 | 600 | |
601 | 601 | // If the logged-in user is the same as the user who created the entry, we're good. |
602 | - if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
602 | + if (is_user_logged_in() && intval($current_user->ID) === intval($entry['created_by'])) { |
|
603 | 603 | |
604 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) ); |
|
604 | + do_action('gravityview_log_debug', sprintf('GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID)); |
|
605 | 605 | |
606 | 606 | return true; |
607 | 607 | } |
@@ -622,27 +622,27 @@ discard block |
||
622 | 622 | * @param int $current_view_id The ID of the View being rendered |
623 | 623 | * @return void |
624 | 624 | */ |
625 | - public function display_message( $current_view_id = 0 ) { |
|
625 | + public function display_message($current_view_id = 0) { |
|
626 | 626 | |
627 | - if( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
627 | + if (empty($_GET['status']) || !self::verify_nonce()) { |
|
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | 631 | // Entry wasn't deleted from current View |
632 | - if( intval( $_GET['gvid'] ) !== intval( $current_view_id ) ) { |
|
632 | + if (intval($_GET['gvid']) !== intval($current_view_id)) { |
|
633 | 633 | return; |
634 | 634 | } |
635 | 635 | |
636 | - $status = esc_attr( $_GET['status'] ); |
|
636 | + $status = esc_attr($_GET['status']); |
|
637 | 637 | $message_from_url = rgget('message'); |
638 | - $message_from_url = urldecode( stripslashes_deep( $message_from_url ) ); |
|
638 | + $message_from_url = urldecode(stripslashes_deep($message_from_url)); |
|
639 | 639 | $class = ''; |
640 | 640 | |
641 | - switch ( $status ) { |
|
641 | + switch ($status) { |
|
642 | 642 | case 'error': |
643 | 643 | $class = ' gv-error error'; |
644 | 644 | $error_message = __('There was an error deleting the entry: %s', 'gravityview'); |
645 | - $message = sprintf( $error_message, $message_from_url ); |
|
645 | + $message = sprintf($error_message, $message_from_url); |
|
646 | 646 | break; |
647 | 647 | case 'trashed': |
648 | 648 | $message = __('The entry was successfully moved to the trash.', 'gravityview'); |
@@ -659,10 +659,10 @@ discard block |
||
659 | 659 | * @param string $status Message status (`error` or `success`) |
660 | 660 | * @param string $message_from_url The original error message, if any, without the "There was an error deleting the entry:" prefix |
661 | 661 | */ |
662 | - $message = apply_filters( 'gravityview/delete-entry/message', esc_attr( $message ), $status, $message_from_url ); |
|
662 | + $message = apply_filters('gravityview/delete-entry/message', esc_attr($message), $status, $message_from_url); |
|
663 | 663 | |
664 | 664 | // DISPLAY ERROR/SUCCESS MESSAGE |
665 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
665 | + echo '<div class="gv-notice'.esc_attr($class).'">'.$message.'</div>'; |
|
666 | 666 | } |
667 | 667 | |
668 | 668 |
@@ -4,21 +4,21 @@ |
||
4 | 4 | |
5 | 5 | $view_id = $gravityview_view->getViewId(); |
6 | 6 | |
7 | -extract( $gravityview_view->getCurrentField() ); |
|
7 | +extract($gravityview_view->getCurrentField()); |
|
8 | 8 | |
9 | 9 | // Only show the link to logged-in users with the rigth caps. |
10 | -if( !GravityView_Delete_Entry::check_user_cap_delete_entry( $entry, $field_settings ) ) { |
|
10 | +if (!GravityView_Delete_Entry::check_user_cap_delete_entry($entry, $field_settings)) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
14 | -$link_text = empty( $field_settings['delete_link'] ) ? __('Delete Entry', 'gravityview') : $field_settings['delete_link']; |
|
14 | +$link_text = empty($field_settings['delete_link']) ? __('Delete Entry', 'gravityview') : $field_settings['delete_link']; |
|
15 | 15 | |
16 | -$link_text = apply_filters( 'gravityview_entry_link', GravityView_API::replace_variables( $link_text, $form, $entry ) ); |
|
16 | +$link_text = apply_filters('gravityview_entry_link', GravityView_API::replace_variables($link_text, $form, $entry)); |
|
17 | 17 | |
18 | -$href = GravityView_Delete_Entry::get_delete_link( $entry, $view_id ); |
|
18 | +$href = GravityView_Delete_Entry::get_delete_link($entry, $view_id); |
|
19 | 19 | |
20 | 20 | $attributes = array( |
21 | 21 | 'onclick' => GravityView_Delete_Entry::get_confirm_dialog() |
22 | 22 | ); |
23 | 23 | |
24 | -echo gravityview_get_link( $href, $link_text, $attributes ); |
|
24 | +echo gravityview_get_link($href, $link_text, $attributes); |