@@ -215,39 +215,39 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | $wp_allowed_scripts = array( |
218 | - 'common', |
|
219 | - 'admin-bar', |
|
220 | - 'autosave', |
|
221 | - 'post', |
|
218 | + 'common', |
|
219 | + 'admin-bar', |
|
220 | + 'autosave', |
|
221 | + 'post', |
|
222 | 222 | 'inline-edit-post', |
223 | - 'utils', |
|
224 | - 'svg-painter', |
|
225 | - 'wp-auth-check', |
|
226 | - 'heartbeat', |
|
223 | + 'utils', |
|
224 | + 'svg-painter', |
|
225 | + 'wp-auth-check', |
|
226 | + 'heartbeat', |
|
227 | 227 | 'media-editor', |
228 | 228 | 'media-upload', |
229 | - 'thickbox', |
|
229 | + 'thickbox', |
|
230 | 230 | 'wp-color-picker', |
231 | 231 | |
232 | - // Settings |
|
232 | + // Settings |
|
233 | 233 | 'gv-admin-edd-license', |
234 | 234 | |
235 | - // Common |
|
236 | - 'select2-js', |
|
237 | - 'qtip-js', |
|
235 | + // Common |
|
236 | + 'select2-js', |
|
237 | + 'qtip-js', |
|
238 | 238 | |
239 | - // jQuery |
|
239 | + // jQuery |
|
240 | 240 | 'jquery', |
241 | - 'jquery-ui-core', |
|
242 | - 'jquery-ui-sortable', |
|
243 | - 'jquery-ui-datepicker', |
|
244 | - 'jquery-ui-dialog', |
|
245 | - 'jquery-ui-slider', |
|
241 | + 'jquery-ui-core', |
|
242 | + 'jquery-ui-sortable', |
|
243 | + 'jquery-ui-datepicker', |
|
244 | + 'jquery-ui-dialog', |
|
245 | + 'jquery-ui-slider', |
|
246 | 246 | 'jquery-ui-dialog', |
247 | 247 | 'jquery-ui-tabs', |
248 | 248 | 'jquery-ui-draggable', |
249 | 249 | 'jquery-ui-droppable', |
250 | - 'jquery-ui-accordion', |
|
250 | + 'jquery-ui-accordion', |
|
251 | 251 | ); |
252 | 252 | |
253 | 253 | $this->remove_conflicts( $wp_scripts, $wp_allowed_scripts, 'scripts' ); |
@@ -281,23 +281,23 @@ discard block |
||
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
284 | - $wp_allowed_styles = array( |
|
285 | - 'admin-bar', |
|
286 | - 'colors', |
|
287 | - 'ie', |
|
288 | - 'wp-auth-check', |
|
289 | - 'media-views', |
|
284 | + $wp_allowed_styles = array( |
|
285 | + 'admin-bar', |
|
286 | + 'colors', |
|
287 | + 'ie', |
|
288 | + 'wp-auth-check', |
|
289 | + 'media-views', |
|
290 | 290 | 'thickbox', |
291 | 291 | 'dashicons', |
292 | - 'wp-jquery-ui-dialog', |
|
293 | - 'jquery-ui-sortable', |
|
292 | + 'wp-jquery-ui-dialog', |
|
293 | + 'jquery-ui-sortable', |
|
294 | 294 | |
295 | - // Settings |
|
296 | - 'gravityview_settings', |
|
295 | + // Settings |
|
296 | + 'gravityview_settings', |
|
297 | 297 | |
298 | - // @todo qTip styles not loading for some reason! |
|
299 | - 'jquery-qtip.js', |
|
300 | - ); |
|
298 | + // @todo qTip styles not loading for some reason! |
|
299 | + 'jquery-qtip.js', |
|
300 | + ); |
|
301 | 301 | |
302 | 302 | $this->remove_conflicts( $wp_styles, $wp_allowed_styles, 'styles' ); |
303 | 303 | |
@@ -317,32 +317,32 @@ discard block |
||
317 | 317 | */ |
318 | 318 | private function remove_conflicts( &$wp_objects, $required_objects, $type = 'scripts' ) { |
319 | 319 | |
320 | - /** |
|
321 | - * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
|
322 | - * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
|
323 | - * @param array $required_objects |
|
324 | - */ |
|
325 | - $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
326 | - |
|
327 | - //reset queue |
|
328 | - $queue = array(); |
|
329 | - foreach( $wp_objects->queue as $object ) { |
|
330 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
331 | - $queue[] = $object; |
|
332 | - } |
|
333 | - } |
|
334 | - $wp_objects->queue = $queue; |
|
335 | - |
|
336 | - $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
337 | - |
|
338 | - //unregistering scripts |
|
339 | - $registered = array(); |
|
340 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
341 | - if( in_array( $handle, $required_objects ) ){ |
|
342 | - $registered[ $handle ] = $script_registration; |
|
343 | - } |
|
344 | - } |
|
345 | - $wp_objects->registered = $registered; |
|
320 | + /** |
|
321 | + * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
|
322 | + * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
|
323 | + * @param array $required_objects |
|
324 | + */ |
|
325 | + $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
326 | + |
|
327 | + //reset queue |
|
328 | + $queue = array(); |
|
329 | + foreach( $wp_objects->queue as $object ) { |
|
330 | + if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
331 | + $queue[] = $object; |
|
332 | + } |
|
333 | + } |
|
334 | + $wp_objects->queue = $queue; |
|
335 | + |
|
336 | + $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
337 | + |
|
338 | + //unregistering scripts |
|
339 | + $registered = array(); |
|
340 | + foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
341 | + if( in_array( $handle, $required_objects ) ){ |
|
342 | + $registered[ $handle ] = $script_registration; |
|
343 | + } |
|
344 | + } |
|
345 | + $wp_objects->registered = $registered; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -405,7 +405,6 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @deprecated since 1.12 |
407 | 407 | * @see GravityView_Compatibility::get_plugin_status() |
408 | - |
|
409 | 408 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
410 | 409 | */ |
411 | 410 | static function get_plugin_status( $location = '' ) { |
@@ -4,10 +4,10 @@ discard block |
||
4 | 4 | |
5 | 5 | function __construct() { |
6 | 6 | |
7 | - if( ! is_admin() ) { return; } |
|
7 | + if (!is_admin()) { return; } |
|
8 | 8 | |
9 | 9 | // If Gravity Forms isn't active or compatibile, stop loading |
10 | - if( false === GravityView_Compatibility::is_valid() ) { |
|
10 | + if (false === GravityView_Compatibility::is_valid()) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
@@ -22,22 +22,22 @@ discard block |
||
22 | 22 | private function include_required_files() { |
23 | 23 | |
24 | 24 | // Migrate Class |
25 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-migrate.php' ); |
|
25 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-migrate.php'); |
|
26 | 26 | |
27 | 27 | // Don't load tooltips if on Gravity Forms, otherwise it overrides translations |
28 | - if( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && !GFForms::is_gravity_page() ) { |
|
29 | - require_once( GFCommon::get_base_path() . '/tooltips.php' ); |
|
28 | + if (class_exists('GFCommon') && class_exists('GFForms') && !GFForms::is_gravity_page()) { |
|
29 | + require_once(GFCommon::get_base_path().'/tooltips.php'); |
|
30 | 30 | } |
31 | 31 | |
32 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php' ); |
|
33 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/entry-list.php' ); |
|
34 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
|
32 | + require_once(GRAVITYVIEW_DIR.'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php'); |
|
33 | + require_once(GRAVITYVIEW_DIR.'includes/admin/entry-list.php'); |
|
34 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-change-entry-creator.php'); |
|
35 | 35 | |
36 | 36 | /** @since 1.15 **/ |
37 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-support-port.php' ); |
|
37 | + require_once(GRAVITYVIEW_DIR.'includes/admin/class-gravityview-support-port.php'); |
|
38 | 38 | |
39 | 39 | /** @since 1.6 */ |
40 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-duplicate-view.php' ); |
|
40 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-admin-duplicate-view.php'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -47,21 +47,21 @@ discard block |
||
47 | 47 | private function add_hooks() { |
48 | 48 | |
49 | 49 | // Filter Admin messages |
50 | - add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); |
|
51 | - add_filter( 'bulk_post_updated_messages', array( $this, 'post_updated_messages' ) ); |
|
50 | + add_filter('post_updated_messages', array($this, 'post_updated_messages')); |
|
51 | + add_filter('bulk_post_updated_messages', array($this, 'post_updated_messages')); |
|
52 | 52 | |
53 | - add_filter( 'plugin_action_links_'. plugin_basename( GRAVITYVIEW_FILE ) , array( $this, 'plugin_action_links' ) ); |
|
53 | + add_filter('plugin_action_links_'.plugin_basename(GRAVITYVIEW_FILE), array($this, 'plugin_action_links')); |
|
54 | 54 | |
55 | - add_action( 'plugins_loaded', array( $this, 'backend_actions' ), 100 ); |
|
55 | + add_action('plugins_loaded', array($this, 'backend_actions'), 100); |
|
56 | 56 | |
57 | 57 | //Hooks for no-conflict functionality |
58 | - add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000); |
|
59 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9); |
|
58 | + add_action('wp_print_scripts', array($this, 'no_conflict_scripts'), 1000); |
|
59 | + add_action('admin_print_footer_scripts', array($this, 'no_conflict_scripts'), 9); |
|
60 | 60 | |
61 | - add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000); |
|
62 | - add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11); |
|
63 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1); |
|
64 | - add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1); |
|
61 | + add_action('wp_print_styles', array($this, 'no_conflict_styles'), 1000); |
|
62 | + add_action('admin_print_styles', array($this, 'no_conflict_styles'), 11); |
|
63 | + add_action('admin_print_footer_scripts', array($this, 'no_conflict_styles'), 1); |
|
64 | + add_action('admin_footer', array($this, 'no_conflict_styles'), 1); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | public function backend_actions() { |
75 | 75 | |
76 | 76 | /** @define "GRAVITYVIEW_DIR" "../" */ |
77 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.field.type.php' ); |
|
78 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.render.settings.php' ); |
|
79 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-label.php' ); |
|
80 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-views.php' ); |
|
81 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-welcome.php' ); |
|
82 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-add-shortcode.php' ); |
|
83 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
77 | + include_once(GRAVITYVIEW_DIR.'includes/admin/class.field.type.php'); |
|
78 | + include_once(GRAVITYVIEW_DIR.'includes/admin/class.render.settings.php'); |
|
79 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-label.php'); |
|
80 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-views.php'); |
|
81 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-welcome.php'); |
|
82 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-add-shortcode.php'); |
|
83 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-approve-entries.php'); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @action `gravityview_include_backend_actions` Triggered after all GravityView admin files are loaded |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | * @param array $links Array of action links under GravityView on the plugin page |
100 | 100 | * @return array Action links with Settings and Support included, if the user has the appropriate caps |
101 | 101 | */ |
102 | - public static function plugin_action_links( $links ) { |
|
102 | + public static function plugin_action_links($links) { |
|
103 | 103 | |
104 | 104 | $actions = array(); |
105 | 105 | |
106 | - if( GVCommon::has_cap( 'gravityview_view_settings' ) ) { |
|
107 | - $actions[] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) ); |
|
106 | + if (GVCommon::has_cap('gravityview_view_settings')) { |
|
107 | + $actions[] = sprintf('<a href="%s">%s</a>', admin_url('edit.php?post_type=gravityview&page=gravityview_settings'), esc_html__('Settings', 'gravityview')); |
|
108 | 108 | } |
109 | 109 | |
110 | - if( GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
111 | - $actions[] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>'; |
|
110 | + if (GVCommon::has_cap('gravityview_support_port')) { |
|
111 | + $actions[] = '<a href="http://docs.gravityview.co">'.esc_html__('Support', 'gravityview').'</a>'; |
|
112 | 112 | } |
113 | 113 | |
114 | - return array_merge( $actions, $links ); |
|
114 | + return array_merge($actions, $links); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -128,70 +128,70 @@ discard block |
||
128 | 128 | * @param array $messages Existing messages |
129 | 129 | * @return array Messages with GravityView views! |
130 | 130 | */ |
131 | - function post_updated_messages( $messages, $bulk_counts = NULL ) { |
|
131 | + function post_updated_messages($messages, $bulk_counts = NULL) { |
|
132 | 132 | global $post; |
133 | 133 | |
134 | - $post_id = isset($_GET['post']) ? intval($_GET['post']) : ( is_object( $post ) && isset( $post->ID ) ? $post->ID : NULL ); |
|
134 | + $post_id = isset($_GET['post']) ? intval($_GET['post']) : (is_object($post) && isset($post->ID) ? $post->ID : NULL); |
|
135 | 135 | |
136 | 136 | // By default, there will only be one item being modified. |
137 | 137 | // When in the `bulk_post_updated_messages` filter, there will be passed a number |
138 | 138 | // of modified items that will override this array. |
139 | - $bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1 , 'locked' => 1 , 'deleted' => 1 , 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts; |
|
139 | + $bulk_counts = is_null($bulk_counts) ? array('updated' => 1, 'locked' => 1, 'deleted' => 1, 'trashed' => 1, 'untrashed' => 1) : $bulk_counts; |
|
140 | 140 | |
141 | 141 | |
142 | 142 | // If we're starting fresh, a new form was created. |
143 | 143 | // We should let the user know this is the case. |
144 | - $start_fresh = get_post_meta( $post_id, '_gravityview_start_fresh', true ); |
|
144 | + $start_fresh = get_post_meta($post_id, '_gravityview_start_fresh', true); |
|
145 | 145 | |
146 | 146 | $new_form_text = ''; |
147 | 147 | |
148 | - if( !empty( $start_fresh ) ) { |
|
148 | + if (!empty($start_fresh)) { |
|
149 | 149 | |
150 | 150 | // Get the form that was created |
151 | - $connected_form = gravityview_get_form_id( $post_id ); |
|
151 | + $connected_form = gravityview_get_form_id($post_id); |
|
152 | 152 | |
153 | - if( !empty( $connected_form ) ) { |
|
154 | - $form = gravityview_get_form( $connected_form ); |
|
155 | - $form_name = esc_attr( $form['title'] ); |
|
153 | + if (!empty($connected_form)) { |
|
154 | + $form = gravityview_get_form($connected_form); |
|
155 | + $form_name = esc_attr($form['title']); |
|
156 | 156 | $image = self::get_floaty(); |
157 | - $new_form_text .= '<h3>'.$image.sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ).'</h3>'; |
|
158 | - $new_form_text .= sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
157 | + $new_form_text .= '<h3>'.$image.sprintf(__('A new form was created for this View: "%s"', 'gravityview'), $form_name).'</h3>'; |
|
158 | + $new_form_text .= sprintf(__('%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
159 | 159 | |
160 | 160 | You can %sedit the form%s in Gravity Forms and the updated fields will be available here. Don’t forget to %scustomize the form settings%s. |
161 | - ', 'gravityview' ), '<strong>', '</strong>', '<a href="'.site_url( '?gf_page=preview&id='.$connected_form ).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&id='.$connected_form ).'">', '</a>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&view=settings&id='.$connected_form ).'">', '</a>'); |
|
162 | - $new_form_text = wpautop( $new_form_text ); |
|
161 | + ', 'gravityview'), '<strong>', '</strong>', '<a href="'.site_url('?gf_page=preview&id='.$connected_form).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url('admin.php?page=gf_edit_forms&id='.$connected_form).'">', '</a>', '<a href="'.admin_url('admin.php?page=gf_edit_forms&view=settings&id='.$connected_form).'">', '</a>'); |
|
162 | + $new_form_text = wpautop($new_form_text); |
|
163 | 163 | |
164 | - delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
164 | + delete_post_meta($post_id, '_gravityview_start_fresh'); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | $messages['gravityview'] = array( |
169 | 169 | 0 => '', // Unused. Messages start at index 1. |
170 | - 1 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
171 | - 2 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
172 | - 3 => __( 'View deleted.', 'gravityview' ), |
|
173 | - 4 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
170 | + 1 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
171 | + 2 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
172 | + 3 => __('View deleted.', 'gravityview'), |
|
173 | + 4 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
174 | 174 | /* translators: %s: date and time of the revision */ |
175 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
176 | - 6 => sprintf(__( 'View published. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
177 | - 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
178 | - 8 => __( 'View submitted.', 'gravityview' ), |
|
175 | + 5 => isset($_GET['revision']) ? sprintf(__('View restored to revision from %s', 'gravityview'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
176 | + 6 => sprintf(__('View published. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>').$new_form_text, |
|
177 | + 7 => sprintf(__('View saved. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>').$new_form_text, |
|
178 | + 8 => __('View submitted.', 'gravityview'), |
|
179 | 179 | 9 => sprintf( |
180 | - __( 'View scheduled for: %1$s.', 'gravityview' ), |
|
180 | + __('View scheduled for: %1$s.', 'gravityview'), |
|
181 | 181 | // translators: Publish box date format, see http://php.net/date |
182 | - date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
|
183 | - ) . $new_form_text, |
|
184 | - 10 => sprintf(__( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
182 | + date_i18n(__('M j, Y @ G:i', 'gravityview'), strtotime((isset($post->post_date) ? $post->post_date : NULL))) |
|
183 | + ).$new_form_text, |
|
184 | + 10 => sprintf(__('View draft updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
185 | 185 | |
186 | 186 | /** |
187 | 187 | * These apply to `bulk_post_updated_messages` |
188 | 188 | * @file wp-admin/edit.php |
189 | 189 | */ |
190 | - 'updated' => _n( '%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview' ), |
|
191 | - 'locked' => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview' ), |
|
192 | - 'deleted' => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview' ), |
|
193 | - 'trashed' => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview' ), |
|
194 | - 'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview' ), |
|
190 | + 'updated' => _n('%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview'), |
|
191 | + 'locked' => _n('%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview'), |
|
192 | + 'deleted' => _n('%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview'), |
|
193 | + 'trashed' => _n('%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview'), |
|
194 | + 'untrashed' => _n('%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview'), |
|
195 | 195 | ); |
196 | 196 | |
197 | 197 | return $messages; |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | function no_conflict_scripts() { |
205 | 205 | global $wp_scripts; |
206 | 206 | |
207 | - if( ! gravityview_is_admin_page() ) { |
|
207 | + if (!gravityview_is_admin_page()) { |
|
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | 211 | $no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode'); |
212 | 212 | |
213 | - if( empty( $no_conflict_mode ) ) { |
|
213 | + if (empty($no_conflict_mode)) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | 'jquery-ui-accordion', |
251 | 251 | ); |
252 | 252 | |
253 | - $this->remove_conflicts( $wp_scripts, $wp_allowed_scripts, 'scripts' ); |
|
253 | + $this->remove_conflicts($wp_scripts, $wp_allowed_scripts, 'scripts'); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -260,16 +260,16 @@ discard block |
||
260 | 260 | function no_conflict_styles() { |
261 | 261 | global $wp_styles; |
262 | 262 | |
263 | - if( ! gravityview_is_admin_page() ) { |
|
263 | + if (!gravityview_is_admin_page()) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Dequeue other jQuery styles even if no-conflict is off. |
268 | 268 | // Terrible-looking tabs help no one. |
269 | - if( !empty( $wp_styles->registered ) ) { |
|
269 | + if (!empty($wp_styles->registered)) { |
|
270 | 270 | foreach ($wp_styles->registered as $key => $style) { |
271 | - if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
272 | - wp_dequeue_style( $key ); |
|
271 | + if (preg_match('/^(?:wp\-)?jquery/ism', $key)) { |
|
272 | + wp_dequeue_style($key); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode'); |
278 | 278 | |
279 | 279 | // If no conflict is off, jQuery will suffice. |
280 | - if( empty( $no_conflict_mode ) ) { |
|
280 | + if (empty($no_conflict_mode)) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | 'jquery-qtip.js', |
300 | 300 | ); |
301 | 301 | |
302 | - $this->remove_conflicts( $wp_styles, $wp_allowed_styles, 'styles' ); |
|
302 | + $this->remove_conflicts($wp_styles, $wp_allowed_styles, 'styles'); |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * @action `gravityview_remove_conflicts_after` Runs after no-conflict styles are removed. You can re-add styles here. |
@@ -315,31 +315,31 @@ discard block |
||
315 | 315 | * @param string $type Either 'styles' or 'scripts' |
316 | 316 | * @return void |
317 | 317 | */ |
318 | - private function remove_conflicts( &$wp_objects, $required_objects, $type = 'scripts' ) { |
|
318 | + private function remove_conflicts(&$wp_objects, $required_objects, $type = 'scripts') { |
|
319 | 319 | |
320 | 320 | /** |
321 | 321 | * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
322 | 322 | * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
323 | 323 | * @param array $required_objects |
324 | 324 | */ |
325 | - $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
325 | + $required_objects = apply_filters("gravityview_noconflict_{$type}", $required_objects); |
|
326 | 326 | |
327 | 327 | //reset queue |
328 | 328 | $queue = array(); |
329 | - foreach( $wp_objects->queue as $object ) { |
|
330 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
329 | + foreach ($wp_objects->queue as $object) { |
|
330 | + if (in_array($object, $required_objects) || preg_match('/gravityview|gf_|gravityforms/ism', $object)) { |
|
331 | 331 | $queue[] = $object; |
332 | 332 | } |
333 | 333 | } |
334 | 334 | $wp_objects->queue = $queue; |
335 | 335 | |
336 | - $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
336 | + $required_objects = $this->add_script_dependencies($wp_objects->registered, $required_objects); |
|
337 | 337 | |
338 | 338 | //unregistering scripts |
339 | 339 | $registered = array(); |
340 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
341 | - if( in_array( $handle, $required_objects ) ){ |
|
342 | - $registered[ $handle ] = $script_registration; |
|
340 | + foreach ($wp_objects->registered as $handle => $script_registration) { |
|
341 | + if (in_array($handle, $required_objects)) { |
|
342 | + $registered[$handle] = $script_registration; |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | $wp_objects->registered = $registered; |
@@ -356,16 +356,16 @@ discard block |
||
356 | 356 | //gets all dependent scripts linked to the $scripts array passed |
357 | 357 | do { |
358 | 358 | $dependents = array(); |
359 | - foreach ( $scripts as $script ) { |
|
360 | - $deps = isset( $registered[ $script ] ) && is_array( $registered[ $script ]->deps ) ? $registered[ $script ]->deps : array(); |
|
361 | - foreach ( $deps as $dep ) { |
|
362 | - if ( ! in_array( $dep, $scripts ) && ! in_array( $dep, $dependents ) ) { |
|
359 | + foreach ($scripts as $script) { |
|
360 | + $deps = isset($registered[$script]) && is_array($registered[$script]->deps) ? $registered[$script]->deps : array(); |
|
361 | + foreach ($deps as $dep) { |
|
362 | + if (!in_array($dep, $scripts) && !in_array($dep, $dependents)) { |
|
363 | 363 | $dependents[] = $dep; |
364 | 364 | } |
365 | 365 | } |
366 | 366 | } |
367 | - $scripts = array_merge( $scripts, $dependents ); |
|
368 | - } while ( ! empty( $dependents ) ); |
|
367 | + $scripts = array_merge($scripts, $dependents); |
|
368 | + } while (!empty($dependents)); |
|
369 | 369 | |
370 | 370 | return $scripts; |
371 | 371 | } |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | * @deprecated since 1.12 |
386 | 386 | * @param array $notice Array with `class` and `message` keys. The message is not escaped. |
387 | 387 | */ |
388 | - public static function add_notice( $notice = array() ) { |
|
389 | - GravityView_Admin_Notices::add_notice( $notice ); |
|
388 | + public static function add_notice($notice = array()) { |
|
389 | + GravityView_Admin_Notices::add_notice($notice); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | |
409 | 409 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
410 | 410 | */ |
411 | - static function get_plugin_status( $location = '' ) { |
|
412 | - return GravityView_Compatibility::get_plugin_status( $location ); |
|
411 | + static function get_plugin_status($location = '') { |
|
412 | + return GravityView_Compatibility::get_plugin_status($location); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -421,10 +421,10 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return bool|string|void If `false`, not a GravityView page. `true` if $page is passed and is the same as current page. Otherwise, the name of the page (`single`, `settings`, or `views`) |
423 | 423 | */ |
424 | - static function is_admin_page( $hook = '', $page = NULL ) { |
|
424 | + static function is_admin_page($hook = '', $page = NULL) { |
|
425 | 425 | global $current_screen, $plugin_page, $pagenow, $post; |
426 | 426 | |
427 | - if( ! is_admin() ) { return false; } |
|
427 | + if (!is_admin()) { return false; } |
|
428 | 428 | |
429 | 429 | $is_page = false; |
430 | 430 | |
@@ -432,21 +432,21 @@ discard block |
||
432 | 432 | |
433 | 433 | $is_gv_post_type_get = (isset($_GET['post_type']) && $_GET['post_type'] === 'gravityview'); |
434 | 434 | |
435 | - $is_gv_settings_get = isset( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings'; |
|
435 | + $is_gv_settings_get = isset($_GET['page']) && $_GET['page'] === 'gravityview_settings'; |
|
436 | 436 | |
437 | - if( empty( $post ) && $pagenow === 'post.php' && !empty( $_GET['post'] ) ) { |
|
438 | - $gv_post = get_post( intval( $_GET['post'] ) ); |
|
437 | + if (empty($post) && $pagenow === 'post.php' && !empty($_GET['post'])) { |
|
438 | + $gv_post = get_post(intval($_GET['post'])); |
|
439 | 439 | $is_gv_post_type = (!empty($gv_post) && !empty($gv_post->post_type) && $gv_post->post_type === 'gravityview'); |
440 | 440 | } else { |
441 | 441 | $is_gv_post_type = (!empty($post) && !empty($post->post_type) && $post->post_type === 'gravityview'); |
442 | 442 | } |
443 | 443 | |
444 | - if( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) { |
|
444 | + if ($is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get) { |
|
445 | 445 | |
446 | 446 | // $_GET `post_type` variable |
447 | - if(in_array($pagenow, array( 'post.php' , 'post-new.php' )) ) { |
|
447 | + if (in_array($pagenow, array('post.php', 'post-new.php'))) { |
|
448 | 448 | $is_page = 'single'; |
449 | - } else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( !empty( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings' ) ) { |
|
449 | + } else if (in_array($plugin_page, array('gravityview_settings', 'gravityview_page_gravityview_settings')) || (!empty($_GET['page']) && $_GET['page'] === 'gravityview_settings')) { |
|
450 | 450 | $is_page = 'settings'; |
451 | 451 | } else { |
452 | 452 | $is_page = 'views'; |
@@ -458,10 +458,10 @@ discard block |
||
458 | 458 | * @param[in,out] string|bool $is_page If false, no. If string, the name of the page (`single`, `settings`, or `views`) |
459 | 459 | * @param[in] string $hook The name of the page to check against. Is passed to the method. |
460 | 460 | */ |
461 | - $is_page = apply_filters( 'gravityview_is_admin_page', $is_page, $hook ); |
|
461 | + $is_page = apply_filters('gravityview_is_admin_page', $is_page, $hook); |
|
462 | 462 | |
463 | 463 | // If the current page is the same as the compared page |
464 | - if( !empty( $page ) ) { |
|
464 | + if (!empty($page)) { |
|
465 | 465 | return $is_page === $page; |
466 | 466 | } |
467 | 467 | |
@@ -473,5 +473,5 @@ discard block |
||
473 | 473 | new GravityView_Admin; |
474 | 474 | |
475 | 475 | function gravityview_is_admin_page($hook = '', $page = NULL) { |
476 | - return GravityView_Admin::is_admin_page( $hook, $page ); |
|
476 | + return GravityView_Admin::is_admin_page($hook, $page); |
|
477 | 477 | } |
@@ -311,7 +311,7 @@ |
||
311 | 311 | * Remove any style or script non-registered in the no conflict mode |
312 | 312 | * @todo Move this to GravityView_Admin_Views |
313 | 313 | * @param WP_Dependencies $wp_objects Object of WP_Styles or WP_Scripts |
314 | - * @param array $required_objects List of registered script/style handles |
|
314 | + * @param string[] $required_objects List of registered script/style handles |
|
315 | 315 | * @param string $type Either 'styles' or 'scripts' |
316 | 316 | * @return void |
317 | 317 | */ |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | * @since 1.13.1 |
33 | 33 | * @var array Columns in the database for leads |
34 | 34 | */ |
35 | - private $lead_db_columns = array( 'id', 'form_id', 'post_id', 'date_created', 'is_starred', 'is_read', 'ip', 'source_url', 'user_agent', 'currency', 'payment_status', 'payment_date', 'payment_amount', 'transaction_id', 'is_fulfilled', 'created_by', 'transaction_type', 'status' ); |
|
35 | + private $lead_db_columns = array('id', 'form_id', 'post_id', 'date_created', 'is_starred', 'is_read', 'ip', 'source_url', 'user_agent', 'currency', 'payment_status', 'payment_date', 'payment_amount', 'transaction_id', 'is_fulfilled', 'created_by', 'transaction_type', 'status'); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * |
39 | 39 | * @param array|int $form_ids Form ID or array of form IDs used in a request |
40 | 40 | * @param array $args Extra request parameters used to generate the query. This is used to generate the unique transient key. |
41 | 41 | */ |
42 | - function __construct( $form_ids = NULL, $args = array() ) { |
|
42 | + function __construct($form_ids = NULL, $args = array()) { |
|
43 | 43 | |
44 | 44 | $this->add_hooks(); |
45 | 45 | |
46 | - if ( ! is_null( $form_ids ) ) { |
|
46 | + if (!is_null($form_ids)) { |
|
47 | 47 | |
48 | 48 | $this->form_ids = $form_ids; |
49 | 49 | |
@@ -59,31 +59,31 @@ discard block |
||
59 | 59 | function add_hooks() { |
60 | 60 | |
61 | 61 | // Schedule cleanup of expired transients |
62 | - add_action( 'wp', array( $this, 'schedule_transient_cleanup' ) ); |
|
62 | + add_action('wp', array($this, 'schedule_transient_cleanup')); |
|
63 | 63 | |
64 | 64 | // Hook in to the scheduled cleanup, if scheduled |
65 | - add_action( 'gravityview-expired-transients', array( $this, 'delete_expired_transients' ) ); |
|
65 | + add_action('gravityview-expired-transients', array($this, 'delete_expired_transients')); |
|
66 | 66 | |
67 | 67 | // Trigger this when you need to prevent any results from being cached with forms that have been modified |
68 | - add_action( 'gravityview_clear_form_cache', array( $this, 'blacklist_add' ) ); |
|
68 | + add_action('gravityview_clear_form_cache', array($this, 'blacklist_add')); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @since 1.14 |
72 | 72 | */ |
73 | - add_action( 'gravityview_clear_entry_cache', array( $this, 'entry_status_changed' ) ); |
|
73 | + add_action('gravityview_clear_entry_cache', array($this, 'entry_status_changed')); |
|
74 | 74 | |
75 | - add_action( 'gform_after_update_entry', array( $this, 'entry_updated' ), 10, 2 ); |
|
75 | + add_action('gform_after_update_entry', array($this, 'entry_updated'), 10, 2); |
|
76 | 76 | |
77 | - add_action( 'gform_entry_created', array( $this, 'entry_created' ), 10, 2 ); |
|
77 | + add_action('gform_entry_created', array($this, 'entry_created'), 10, 2); |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @see RGFormsModel::update_lead_property() Trigger when any entry property changes |
81 | 81 | */ |
82 | - foreach( $this->lead_db_columns as $column ) { |
|
83 | - add_action( 'gform_update_' . $column, array( $this, 'entry_status_changed' ), 10, 3 ); |
|
82 | + foreach ($this->lead_db_columns as $column) { |
|
83 | + add_action('gform_update_'.$column, array($this, 'entry_status_changed'), 10, 3); |
|
84 | 84 | } |
85 | 85 | |
86 | - add_action( 'gform_delete_lead', array( $this, 'entry_status_changed' ), 10 ); |
|
86 | + add_action('gform_delete_lead', array($this, 'entry_status_changed'), 10); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -99,22 +99,22 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return void |
101 | 101 | */ |
102 | - public function entry_status_changed( $lead_id, $property_value = '', $previous_value = '' ) { |
|
102 | + public function entry_status_changed($lead_id, $property_value = '', $previous_value = '') { |
|
103 | 103 | |
104 | 104 | /** @var array $entry */ |
105 | - $entry = GFAPI::get_entry( $lead_id ); |
|
105 | + $entry = GFAPI::get_entry($lead_id); |
|
106 | 106 | |
107 | - if ( is_wp_error( $entry ) ) { |
|
107 | + if (is_wp_error($entry)) { |
|
108 | 108 | |
109 | 109 | /** @var WP_Error $entry */ |
110 | - do_action( 'gravityview_log_error', __METHOD__ . ' Could not retrieve entry ' . $lead_id . ' to delete it: ' . $entry->get_error_message() ); |
|
110 | + do_action('gravityview_log_error', __METHOD__.' Could not retrieve entry '.$lead_id.' to delete it: '.$entry->get_error_message()); |
|
111 | 111 | |
112 | 112 | return; |
113 | 113 | } |
114 | 114 | |
115 | - do_action( 'gravityview_log_debug', __METHOD__ . ' adding form ' . $entry['form_id'] . ' to blacklist because entry #' . $lead_id . ' was deleted', array( 'value' => $property_value, 'previous' => $previous_value ) ); |
|
115 | + do_action('gravityview_log_debug', __METHOD__.' adding form '.$entry['form_id'].' to blacklist because entry #'.$lead_id.' was deleted', array('value' => $property_value, 'previous' => $previous_value)); |
|
116 | 116 | |
117 | - $this->blacklist_add( $entry['form_id'] ); |
|
117 | + $this->blacklist_add($entry['form_id']); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | - public function entry_updated( $form, $lead_id ) { |
|
128 | + public function entry_updated($form, $lead_id) { |
|
129 | 129 | |
130 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form ' . $form['id'] . ' to blacklist because entry #' . $lead_id . ' was updated' ); |
|
130 | + do_action('gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form '.$form['id'].' to blacklist because entry #'.$lead_id.' was updated'); |
|
131 | 131 | |
132 | - $this->blacklist_add( $form['id'] ); |
|
132 | + $this->blacklist_add($form['id']); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return void |
144 | 144 | */ |
145 | - public function entry_created( $entry, $form ) { |
|
145 | + public function entry_created($entry, $form) { |
|
146 | 146 | |
147 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_created] adding form ' . $form['id'] . ' to blacklist because entry #' . $entry['id'] . ' was created' ); |
|
147 | + do_action('gravityview_log_debug', 'GravityView_Cache[entry_created] adding form '.$form['id'].' to blacklist because entry #'.$entry['id'].' was created'); |
|
148 | 148 | |
149 | - $this->blacklist_add( $form['id'] ); |
|
149 | + $this->blacklist_add($form['id']); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return string Prefix for the cache string used in set_key() |
158 | 158 | */ |
159 | - protected function get_cache_key_prefix( $form_ids = NULL ) { |
|
159 | + protected function get_cache_key_prefix($form_ids = NULL) { |
|
160 | 160 | |
161 | - if ( is_null( $form_ids ) ) { |
|
161 | + if (is_null($form_ids)) { |
|
162 | 162 | $form_ids = $this->form_ids; |
163 | 163 | } |
164 | 164 | |
165 | 165 | // Normally just one form, but supports multiple forms |
166 | 166 | // |
167 | 167 | // Array of IDs 12, 5, 14 would result in `f-12f-5f-14` |
168 | - $forms = 'f:' . implode( '&f:', (array) $form_ids ); |
|
168 | + $forms = 'f:'.implode('&f:', (array)$form_ids); |
|
169 | 169 | |
170 | 170 | // Prefix for transient keys |
171 | 171 | // Now the prefix would be: `gv-cache-f-12f-5f-14` |
172 | - return 'gv-cache-' . $forms . '-'; |
|
172 | + return 'gv-cache-'.$forms.'-'; |
|
173 | 173 | |
174 | 174 | } |
175 | 175 | |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | protected function set_key() { |
180 | 180 | |
181 | 181 | // Don't set key if no forms have been set. |
182 | - if ( empty( $this->form_ids ) ) { |
|
182 | + if (empty($this->form_ids)) { |
|
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
186 | - $key = $this->get_cache_key_prefix() . sha1( serialize( $this->args ) ); |
|
186 | + $key = $this->get_cache_key_prefix().sha1(serialize($this->args)); |
|
187 | 187 | |
188 | 188 | // The transient name column can handle up to 64 characters. |
189 | 189 | // The `_transient_timeout_` prefix that is prepended to the string is 11 characters. |
190 | 190 | // 64 - 19 = 45 |
191 | 191 | // We make sure the key isn't too long or else WP doesn't store data. |
192 | - $this->key = substr( $key, 0, 45 ); |
|
192 | + $this->key = substr($key, 0, 45); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -210,24 +210,24 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return boolean False if value was not updated and true if value was updated. |
212 | 212 | */ |
213 | - public function blacklist_add( $form_ids ) { |
|
213 | + public function blacklist_add($form_ids) { |
|
214 | 214 | |
215 | - $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
|
215 | + $blacklist = get_option(self::BLACKLIST_OPTION_NAME, array()); |
|
216 | 216 | |
217 | - $form_ids = is_array( $form_ids ) ? $form_ids : array( $form_ids ); |
|
217 | + $form_ids = is_array($form_ids) ? $form_ids : array($form_ids); |
|
218 | 218 | |
219 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_add] Adding form IDs to cache blacklist', array( |
|
219 | + do_action('gravityview_log_debug', 'GravityView_Cache[blacklist_add] Adding form IDs to cache blacklist', array( |
|
220 | 220 | '$form_ids' => $form_ids, |
221 | 221 | '$blacklist' => $blacklist |
222 | - ) ); |
|
222 | + )); |
|
223 | 223 | |
224 | 224 | // Add the passed form IDs |
225 | - $blacklist = array_merge( $blacklist, $form_ids ); |
|
225 | + $blacklist = array_merge($blacklist, $form_ids); |
|
226 | 226 | |
227 | 227 | // Don't duplicate |
228 | - $blacklist = array_unique( $blacklist ); |
|
228 | + $blacklist = array_unique($blacklist); |
|
229 | 229 | |
230 | - return update_option( self::BLACKLIST_OPTION_NAME, $blacklist ); |
|
230 | + return update_option(self::BLACKLIST_OPTION_NAME, $blacklist); |
|
231 | 231 | |
232 | 232 | } |
233 | 233 | |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return boolean Whether the removal was successful |
240 | 240 | */ |
241 | - public function blacklist_remove( $form_ids ) { |
|
241 | + public function blacklist_remove($form_ids) { |
|
242 | 242 | |
243 | - $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
|
243 | + $blacklist = get_option(self::BLACKLIST_OPTION_NAME, array()); |
|
244 | 244 | |
245 | - $updated_list = array_diff( $blacklist, (array) $form_ids ); |
|
245 | + $updated_list = array_diff($blacklist, (array)$form_ids); |
|
246 | 246 | |
247 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array( |
|
247 | + do_action('gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array( |
|
248 | 248 | '$form_ids' => $form_ids, |
249 | 249 | '$blacklist' => $blacklist, |
250 | 250 | '$updated_list' => $updated_list |
251 | - ) ); |
|
251 | + )); |
|
252 | 252 | |
253 | - return update_option( self::BLACKLIST_OPTION_NAME, $updated_list ); |
|
253 | + return update_option(self::BLACKLIST_OPTION_NAME, $updated_list); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -261,25 +261,25 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return [type] [description] |
263 | 263 | */ |
264 | - function in_blacklist( $form_ids = NULL ) { |
|
264 | + function in_blacklist($form_ids = NULL) { |
|
265 | 265 | |
266 | - $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
|
266 | + $blacklist = get_option(self::BLACKLIST_OPTION_NAME, array()); |
|
267 | 267 | |
268 | 268 | // Use object var if exists |
269 | - $form_ids = is_null( $form_ids ) ? $this->form_ids : $form_ids; |
|
269 | + $form_ids = is_null($form_ids) ? $this->form_ids : $form_ids; |
|
270 | 270 | |
271 | - if ( empty( $form_ids ) ) { |
|
271 | + if (empty($form_ids)) { |
|
272 | 272 | |
273 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[in_blacklist] Did not add form to blacklist; empty form ID', $form_ids ); |
|
273 | + do_action('gravityview_log_debug', 'GravityView_Cache[in_blacklist] Did not add form to blacklist; empty form ID', $form_ids); |
|
274 | 274 | |
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | |
278 | - foreach ( (array) $form_ids as $form_id ) { |
|
278 | + foreach ((array)$form_ids as $form_id) { |
|
279 | 279 | |
280 | - if ( in_array( $form_id, $blacklist ) ) { |
|
280 | + if (in_array($form_id, $blacklist)) { |
|
281 | 281 | |
282 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[in_blacklist] Form #' . esc_attr( $form_id ) . ' is in the cache blacklist' ); |
|
282 | + do_action('gravityview_log_debug', 'GravityView_Cache[in_blacklist] Form #'.esc_attr($form_id).' is in the cache blacklist'); |
|
283 | 283 | |
284 | 284 | return true; |
285 | 285 | } |
@@ -296,35 +296,35 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return mixed False: Not using cache or cache was a WP_Error object; NULL: no results found; Mixed: cache value |
298 | 298 | */ |
299 | - public function get( $key = NULL ) { |
|
299 | + public function get($key = NULL) { |
|
300 | 300 | |
301 | - $key = is_null( $key ) ? $this->key : $key; |
|
301 | + $key = is_null($key) ? $this->key : $key; |
|
302 | 302 | |
303 | - if ( ! $this->use_cache() ) { |
|
303 | + if (!$this->use_cache()) { |
|
304 | 304 | |
305 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Not using cached results because of GravityView_Cache->use_cache() results' ); |
|
305 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Not using cached results because of GravityView_Cache->use_cache() results'); |
|
306 | 306 | |
307 | 307 | return false; |
308 | 308 | } |
309 | 309 | |
310 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Fetching request with transient key ' . $key ); |
|
310 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Fetching request with transient key '.$key); |
|
311 | 311 | |
312 | - $result = get_transient( $key ); |
|
312 | + $result = get_transient($key); |
|
313 | 313 | |
314 | - if ( is_wp_error( $result ) ) { |
|
314 | + if (is_wp_error($result)) { |
|
315 | 315 | |
316 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Fetching request resulted in error:', $result ); |
|
316 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Fetching request resulted in error:', $result); |
|
317 | 317 | |
318 | 318 | return false; |
319 | 319 | |
320 | - } elseif ( $result ) { |
|
320 | + } elseif ($result) { |
|
321 | 321 | |
322 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Cached results found for transient key ' . $key ); |
|
322 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Cached results found for transient key '.$key); |
|
323 | 323 | |
324 | 324 | return $result; |
325 | 325 | } |
326 | 326 | |
327 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] No cached results found for transient key ' . $key ); |
|
327 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] No cached results found for transient key '.$key); |
|
328 | 328 | |
329 | 329 | return NULL; |
330 | 330 | |
@@ -338,24 +338,24 @@ discard block |
||
338 | 338 | * @param [type] $content [description] |
339 | 339 | * @param [type] $filter_name Name used to modify the cache time. Will be set to `gravityview_cache_time_{$filter_name}`. |
340 | 340 | */ |
341 | - public function set( $content, $filter_name = '' ) { |
|
341 | + public function set($content, $filter_name = '') { |
|
342 | 342 | |
343 | 343 | // Don't cache empty results |
344 | - if ( ! empty( $content ) ) { |
|
344 | + if (!empty($content)) { |
|
345 | 345 | |
346 | 346 | /** |
347 | 347 | * @filter `gravityview_cache_time_{$filter_name}` Modify the cache time for a type of cache |
348 | 348 | * @param int $time_in_seconds Default: `DAY_IN_SECONDS` |
349 | 349 | */ |
350 | - $cache_time = (int) apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS ); |
|
350 | + $cache_time = (int)apply_filters('gravityview_cache_time_'.$filter_name, DAY_IN_SECONDS); |
|
351 | 351 | |
352 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key ' . $this->key . ' for ' . $cache_time . ' seconds' ); |
|
352 | + do_action('gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key '.$this->key.' for '.$cache_time.' seconds'); |
|
353 | 353 | |
354 | - return set_transient( $this->key, $content, $cache_time ); |
|
354 | + return set_transient($this->key, $content, $cache_time); |
|
355 | 355 | |
356 | 356 | } |
357 | 357 | |
358 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Cache not set; content is empty' ); |
|
358 | + do_action('gravityview_log_debug', 'GravityView_Cache[set] Cache not set; content is empty'); |
|
359 | 359 | |
360 | 360 | return false; |
361 | 361 | |
@@ -371,39 +371,39 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return [type] [description] |
373 | 373 | */ |
374 | - public function delete( $form_ids = NULL ) { |
|
374 | + public function delete($form_ids = NULL) { |
|
375 | 375 | global $wpdb; |
376 | 376 | |
377 | 377 | // Use object var if exists |
378 | - $form_ids = is_null( $form_ids ) ? $this->form_ids : $form_ids; |
|
378 | + $form_ids = is_null($form_ids) ? $this->form_ids : $form_ids; |
|
379 | 379 | |
380 | - if ( empty( $form_ids ) ) { |
|
381 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[delete] Did not delete cache; empty form IDs' ); |
|
380 | + if (empty($form_ids)) { |
|
381 | + do_action('gravityview_log_debug', 'GravityView_Cache[delete] Did not delete cache; empty form IDs'); |
|
382 | 382 | |
383 | 383 | return; |
384 | 384 | } |
385 | 385 | |
386 | - foreach ( (array) $form_ids as $form_id ) { |
|
386 | + foreach ((array)$form_ids as $form_id) { |
|
387 | 387 | |
388 | - $key = $this->get_cache_key_prefix( $form_id ); |
|
388 | + $key = $this->get_cache_key_prefix($form_id); |
|
389 | 389 | |
390 | 390 | // WordPress 4.0+ |
391 | - if ( is_callable( array( $wpdb, 'esc_like' ) ) ) { |
|
392 | - $key = $wpdb->esc_like( $key ); |
|
391 | + if (is_callable(array($wpdb, 'esc_like'))) { |
|
392 | + $key = $wpdb->esc_like($key); |
|
393 | 393 | } else { |
394 | - $key = like_escape( $key ); |
|
394 | + $key = like_escape($key); |
|
395 | 395 | } |
396 | 396 | |
397 | - $key = "%" . $key . "%"; |
|
397 | + $key = "%".$key."%"; |
|
398 | 398 | |
399 | - $sql = $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE `option_name` LIKE %s", $key ); |
|
399 | + $sql = $wpdb->prepare("DELETE FROM {$wpdb->options} WHERE `option_name` LIKE %s", $key); |
|
400 | 400 | |
401 | - $result = $wpdb->query( $sql ); |
|
401 | + $result = $wpdb->query($sql); |
|
402 | 402 | |
403 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[delete] Deleting cache for form #' . $form_id, array( |
|
403 | + do_action('gravityview_log_debug', 'GravityView_Cache[delete] Deleting cache for form #'.$form_id, array( |
|
404 | 404 | $sql, |
405 | - sprintf( 'Deleted results: %d', $result ) |
|
406 | - ) ); |
|
405 | + sprintf('Deleted results: %d', $result) |
|
406 | + )); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | } |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | * @filter `gravityview_cleanup_transients` Override GravityView cleanup of transients by setting this to false |
422 | 422 | * @param boolean $cleanup Whether to run the GravityView auto-cleanup of transients. Default: `true` |
423 | 423 | */ |
424 | - $cleanup = apply_filters( 'gravityview_cleanup_transients', true ); |
|
424 | + $cleanup = apply_filters('gravityview_cleanup_transients', true); |
|
425 | 425 | |
426 | - if ( ! $cleanup ) { |
|
426 | + if (!$cleanup) { |
|
427 | 427 | return; |
428 | 428 | } |
429 | 429 | |
430 | - if ( ! wp_next_scheduled( 'gravityview-expired-transients' ) ) { |
|
431 | - wp_schedule_event( time(), 'daily', 'gravityview-expired-transients' ); |
|
430 | + if (!wp_next_scheduled('gravityview-expired-transients')) { |
|
431 | + wp_schedule_event(time(), 'daily', 'gravityview-expired-transients'); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | $threshold = time() - 60; |
454 | 454 | |
455 | 455 | // get table name for options on specified blog |
456 | - $table = $wpdb->get_blog_prefix( $blog_id ) . 'options'; |
|
456 | + $table = $wpdb->get_blog_prefix($blog_id).'options'; |
|
457 | 457 | |
458 | 458 | // delete expired transients, using the paired timeout record to find them |
459 | 459 | $sql = " |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | and t1.option_value < '$threshold' |
465 | 465 | "; |
466 | 466 | |
467 | - $num_results = $wpdb->query( $sql ); |
|
467 | + $num_results = $wpdb->query($sql); |
|
468 | 468 | |
469 | 469 | // delete orphaned transient expirations |
470 | 470 | // also delete NextGEN Gallery 2.x display cache timeout aliases |
@@ -479,9 +479,9 @@ discard block |
||
479 | 479 | and option_value < '$threshold' |
480 | 480 | "; |
481 | 481 | |
482 | - $num_results += $wpdb->query( $sql ); |
|
482 | + $num_results += $wpdb->query($sql); |
|
483 | 483 | |
484 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[delete_expired_transients] Deleted ' . $num_results . ' expired transient records from the database' ); |
|
484 | + do_action('gravityview_log_debug', 'GravityView_Cache[delete_expired_transients] Deleted '.$num_results.' expired transient records from the database'); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -495,11 +495,11 @@ discard block |
||
495 | 495 | |
496 | 496 | $use_cache = true; |
497 | 497 | |
498 | - if ( GVCommon::has_cap( 'edit_gravityviews' ) ) { |
|
498 | + if (GVCommon::has_cap('edit_gravityviews')) { |
|
499 | 499 | |
500 | - if ( isset( $_GET['cache'] ) || isset( $_GET['nocache'] ) ) { |
|
500 | + if (isset($_GET['cache']) || isset($_GET['nocache'])) { |
|
501 | 501 | |
502 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL' ); |
|
502 | + do_action('gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL'); |
|
503 | 503 | |
504 | 504 | $use_cache = false; |
505 | 505 | } |
@@ -507,13 +507,13 @@ discard block |
||
507 | 507 | } |
508 | 508 | |
509 | 509 | // Has the form been flagged as having changed items in it? |
510 | - if ( $this->in_blacklist() ) { |
|
510 | + if ($this->in_blacklist()) { |
|
511 | 511 | |
512 | 512 | // Delete caches for all items with form IDs XYZ |
513 | - $this->delete( $this->form_ids ); |
|
513 | + $this->delete($this->form_ids); |
|
514 | 514 | |
515 | 515 | // Remove the form from |
516 | - $this->blacklist_remove( $this->form_ids ); |
|
516 | + $this->blacklist_remove($this->form_ids); |
|
517 | 517 | |
518 | 518 | } |
519 | 519 | |
@@ -524,9 +524,9 @@ discard block |
||
524 | 524 | * @param[out,in] boolean $use_cache Previous setting |
525 | 525 | * @param[out] GravityView_Cache $this The GravityView_Cache object |
526 | 526 | */ |
527 | - $use_cache = apply_filters( 'gravityview_use_cache', $use_cache, $this ); |
|
527 | + $use_cache = apply_filters('gravityview_use_cache', $use_cache, $this); |
|
528 | 528 | |
529 | - return (boolean) $use_cache; |
|
529 | + return (boolean)$use_cache; |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | } |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | |
214 | 214 | if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
215 | 215 | foreach ( $field['inputs'] as $input ) { |
216 | - /** |
|
217 | - * @hack |
|
218 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
219 | - */ |
|
220 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
221 | - continue; |
|
222 | - } |
|
216 | + /** |
|
217 | + * @hack |
|
218 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
219 | + */ |
|
220 | + if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
221 | + continue; |
|
222 | + } |
|
223 | 223 | $fields[ (string)$input['id'] ] = array( |
224 | 224 | 'label' => rgar( $input, 'label' ), |
225 | 225 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
467 | 467 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
468 | 468 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
469 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
469 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
470 | 470 | $criteria['context_view_id'] = null; |
471 | 471 | } |
472 | 472 | |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | ), |
1083 | 1083 | ); |
1084 | 1084 | |
1085 | - $fields = $date_created + $fields; |
|
1085 | + $fields = $date_created + $fields; |
|
1086 | 1086 | |
1087 | 1087 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1088 | 1088 | |
@@ -1094,13 +1094,13 @@ discard block |
||
1094 | 1094 | } |
1095 | 1095 | } |
1096 | 1096 | |
1097 | - /** |
|
1098 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1099 | - * @since 1.12 |
|
1100 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1101 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1102 | - */ |
|
1103 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1097 | + /** |
|
1098 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1099 | + * @since 1.12 |
|
1100 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1101 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1102 | + */ |
|
1103 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1104 | 1104 | |
1105 | 1105 | return $fields; |
1106 | 1106 | } |
@@ -1365,17 +1365,17 @@ discard block |
||
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | |
1368 | - /** |
|
1369 | - * Display updated/error notice |
|
1370 | - * |
|
1371 | - * @param string $notice text/HTML of notice |
|
1372 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1373 | - * |
|
1374 | - * @return string |
|
1375 | - */ |
|
1376 | - public static function generate_notice( $notice, $class = '' ) { |
|
1377 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1378 | - } |
|
1368 | + /** |
|
1369 | + * Display updated/error notice |
|
1370 | + * |
|
1371 | + * @param string $notice text/HTML of notice |
|
1372 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1373 | + * |
|
1374 | + * @return string |
|
1375 | + */ |
|
1376 | + public static function generate_notice( $notice, $class = '' ) { |
|
1377 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1378 | + } |
|
1379 | 1379 | |
1380 | 1380 | |
1381 | 1381 |
@@ -167,7 +167,6 @@ discard block |
||
167 | 167 | * Returns the list of available forms |
168 | 168 | * |
169 | 169 | * @access public |
170 | - * @param mixed $form_id |
|
171 | 170 | * @return array Empty array if GFAPI isn't available or no forms. Otherwise, associative array with id, title keys |
172 | 171 | */ |
173 | 172 | public static function get_forms() { |
@@ -188,7 +187,7 @@ discard block |
||
188 | 187 | * Return array of fields' id and label, for a given Form ID |
189 | 188 | * |
190 | 189 | * @access public |
191 | - * @param string|array $form_id (default: '') or $form object |
|
190 | + * @param string|array $form (default: '') or $form object |
|
192 | 191 | * @return array |
193 | 192 | */ |
194 | 193 | public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | /** If this file is called directly, abort. */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | 18 | |
@@ -25,18 +25,18 @@ discard block |
||
25 | 25 | * @param mixed $form_id |
26 | 26 | * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms |
27 | 27 | */ |
28 | - public static function get_form( $form_id ) { |
|
29 | - if ( empty( $form_id ) ) { |
|
28 | + public static function get_form($form_id) { |
|
29 | + if (empty($form_id)) { |
|
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | 33 | // Only get_form_meta is cached. ::facepalm:: |
34 | - if ( class_exists( 'RGFormsModel' ) ) { |
|
35 | - return GFFormsModel::get_form_meta( $form_id ); |
|
34 | + if (class_exists('RGFormsModel')) { |
|
35 | + return GFFormsModel::get_form_meta($form_id); |
|
36 | 36 | } |
37 | 37 | |
38 | - if ( class_exists( 'GFAPI' ) ) { |
|
39 | - return GFAPI::get_form( $form_id ); |
|
38 | + if (class_exists('GFAPI')) { |
|
39 | + return GFAPI::get_form($form_id); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return false; |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities |
57 | 57 | */ |
58 | - public static function has_cap( $caps = '', $object_id = null, $user_id = null ) { |
|
59 | - return GravityView_Roles_Capabilities::has_cap( $caps, $object_id, $user_id ); |
|
58 | + public static function has_cap($caps = '', $object_id = null, $user_id = null) { |
|
59 | + return GravityView_Roles_Capabilities::has_cap($caps, $object_id, $user_id); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | * @param array|GF_Fields $field Gravity Forms field or array |
68 | 68 | * @return array Array version of $field |
69 | 69 | */ |
70 | - public static function get_field_array( $field ) { |
|
70 | + public static function get_field_array($field) { |
|
71 | 71 | |
72 | - if ( class_exists( 'GF_Fields' ) ) { |
|
72 | + if (class_exists('GF_Fields')) { |
|
73 | 73 | |
74 | - $field_object = GF_Fields::create( $field ); |
|
74 | + $field_object = GF_Fields::create($field); |
|
75 | 75 | |
76 | 76 | // Convert the field object in 1.9 to an array for backward compatibility |
77 | - $field_array = get_object_vars( $field_object ); |
|
77 | + $field_array = get_object_vars($field_object); |
|
78 | 78 | |
79 | 79 | } else { |
80 | 80 | $field_array = $field; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return array Array of Views as `WP_Post`. Empty array if none found. |
95 | 95 | */ |
96 | - public static function get_all_views( $args = array() ) { |
|
96 | + public static function get_all_views($args = array()) { |
|
97 | 97 | |
98 | 98 | $default_params = array( |
99 | 99 | 'post_type' => 'gravityview', |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | 'post_status' => 'publish', |
102 | 102 | ); |
103 | 103 | |
104 | - $params = wp_parse_args( $args, $default_params ); |
|
104 | + $params = wp_parse_args($args, $default_params); |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @filter `gravityview/get_all_views/params` Modify the parameters sent to get all views. |
108 | 108 | * @param[in,out] array $params Array of parameters to pass to `get_posts()` |
109 | 109 | */ |
110 | - $views_params = apply_filters( 'gravityview/get_all_views/params', $params ); |
|
110 | + $views_params = apply_filters('gravityview/get_all_views/params', $params); |
|
111 | 111 | |
112 | - $views = get_posts( $views_params ); |
|
112 | + $views = get_posts($views_params); |
|
113 | 113 | |
114 | 114 | return $views; |
115 | 115 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | * @param int|string $entry_slug Entry slug |
121 | 121 | * @return array Gravity Forms form array |
122 | 122 | */ |
123 | - public static function get_form_from_entry_id( $entry_slug ) { |
|
123 | + public static function get_form_from_entry_id($entry_slug) { |
|
124 | 124 | |
125 | - $entry = self::get_entry( $entry_slug, true ); |
|
125 | + $entry = self::get_entry($entry_slug, true); |
|
126 | 126 | |
127 | - $form = self::get_form( $entry['form_id'] ); |
|
127 | + $form = self::get_form($entry['form_id']); |
|
128 | 128 | |
129 | 129 | return $form; |
130 | 130 | } |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @return bool|GF_Field[] |
140 | 140 | */ |
141 | - public static function has_product_field( $form = array() ) { |
|
141 | + public static function has_product_field($form = array()) { |
|
142 | 142 | |
143 | - $product_fields = apply_filters( 'gform_product_field_types', array( 'option', 'quantity', 'product', 'total', 'shipping', 'calculation', 'price' ) ); |
|
143 | + $product_fields = apply_filters('gform_product_field_types', array('option', 'quantity', 'product', 'total', 'shipping', 'calculation', 'price')); |
|
144 | 144 | |
145 | - $fields = GFAPI::get_fields_by_type( $form, $product_fields ); |
|
145 | + $fields = GFAPI::get_fields_by_type($form, $product_fields); |
|
146 | 146 | |
147 | - return empty( $fields ) ? false : $fields; |
|
147 | + return empty($fields) ? false : $fields; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @param string $slug The entry slug, as returned by GravityView_API::get_entry_slug() |
155 | 155 | * @return int|null The entry ID, if exists; `NULL` if not |
156 | 156 | */ |
157 | - public static function get_entry_id_from_slug( $slug ) { |
|
157 | + public static function get_entry_id_from_slug($slug) { |
|
158 | 158 | global $wpdb; |
159 | 159 | |
160 | 160 | $search_criteria = array( |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | 'page_size' => 1, |
174 | 174 | ); |
175 | 175 | |
176 | - $results = GFAPI::get_entries( 0, $search_criteria, null, $paging ); |
|
176 | + $results = GFAPI::get_entries(0, $search_criteria, null, $paging); |
|
177 | 177 | |
178 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
178 | + $result = (!empty($results) && !empty($results[0]['id'])) ? $results[0]['id'] : null; |
|
179 | 179 | |
180 | 180 | return $result; |
181 | 181 | } |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public static function get_forms() { |
192 | 192 | $forms = array(); |
193 | - if ( class_exists( 'GFAPI' ) ) { |
|
193 | + if (class_exists('GFAPI')) { |
|
194 | 194 | $gf_forms = GFAPI::get_forms(); |
195 | - foreach ( $gf_forms as $form ) { |
|
195 | + foreach ($gf_forms as $form) { |
|
196 | 196 | $forms[] = array( |
197 | 197 | 'id' => $form['id'], |
198 | 198 | 'title' => $form['title'], |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | * @param string|array $form_id (default: '') or $form object |
210 | 210 | * @return array |
211 | 211 | */ |
212 | - public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
|
212 | + public static function get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true) { |
|
213 | 213 | |
214 | - if ( ! is_array( $form ) ) { |
|
215 | - $form = self::get_form( $form ); |
|
214 | + if (!is_array($form)) { |
|
215 | + $form = self::get_form($form); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | $fields = array(); |
@@ -222,56 +222,56 @@ discard block |
||
222 | 222 | $has_poll_fields = false; |
223 | 223 | |
224 | 224 | // If GF_Field exists, we're using GF 1.9+, where add_default_properties has been deprecated. |
225 | - if ( false === class_exists( 'GF_Field' ) && $add_default_properties ) { |
|
226 | - $form = RGFormsModel::add_default_properties( $form ); |
|
225 | + if (false === class_exists('GF_Field') && $add_default_properties) { |
|
226 | + $form = RGFormsModel::add_default_properties($form); |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( $form ) { |
|
230 | - foreach ( $form['fields'] as $field ) { |
|
231 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
232 | - $fields[ $field['id'] ] = array( |
|
233 | - 'label' => rgar( $field, 'label' ), |
|
229 | + if ($form) { |
|
230 | + foreach ($form['fields'] as $field) { |
|
231 | + if ($include_parent_field || empty($field['inputs'])) { |
|
232 | + $fields[$field['id']] = array( |
|
233 | + 'label' => rgar($field, 'label'), |
|
234 | 234 | 'parent' => null, |
235 | - 'type' => rgar( $field, 'type' ), |
|
236 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
237 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
235 | + 'type' => rgar($field, 'type'), |
|
236 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
237 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
238 | 238 | ); |
239 | 239 | } |
240 | 240 | |
241 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
242 | - foreach ( $field['inputs'] as $input ) { |
|
241 | + if ($add_default_properties && !empty($field['inputs'])) { |
|
242 | + foreach ($field['inputs'] as $input) { |
|
243 | 243 | /** |
244 | 244 | * @hack |
245 | 245 | * In case of email/email confirmation, the input for email has the same id as the parent field |
246 | 246 | */ |
247 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
247 | + if ('email' == rgar($field, 'type') && false === strpos($input['id'], '.')) { |
|
248 | 248 | continue; |
249 | 249 | } |
250 | - $fields[ (string)$input['id'] ] = array( |
|
251 | - 'label' => rgar( $input, 'label' ), |
|
252 | - 'customLabel' => rgar( $input, 'customLabel' ), |
|
250 | + $fields[(string)$input['id']] = array( |
|
251 | + 'label' => rgar($input, 'label'), |
|
252 | + 'customLabel' => rgar($input, 'customLabel'), |
|
253 | 253 | 'parent' => $field, |
254 | - 'type' => rgar( $field, 'type' ), |
|
255 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
256 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
254 | + 'type' => rgar($field, 'type'), |
|
255 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
256 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
257 | 257 | ); |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | 261 | /** @since 1.14 */ |
262 | - if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) { |
|
262 | + if ('list' === $field['type'] && !empty($field['enableColumns'])) { |
|
263 | 263 | |
264 | - foreach ( (array)$field['choices'] as $key => $input ) { |
|
264 | + foreach ((array)$field['choices'] as $key => $input) { |
|
265 | 265 | |
266 | - $input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key} |
|
266 | + $input_id = sprintf('%d.%d', $field['id'], $key); // {field_id}.{column_key} |
|
267 | 267 | |
268 | - $fields[ $input_id ] = array( |
|
269 | - 'label' => rgar( $input, 'text' ), |
|
268 | + $fields[$input_id] = array( |
|
269 | + 'label' => rgar($input, 'text'), |
|
270 | 270 | 'customLabel' => '', |
271 | 271 | 'parent' => $field, |
272 | - 'type' => rgar( $field, 'type' ), |
|
273 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
274 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
272 | + 'type' => rgar($field, 'type'), |
|
273 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
274 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
275 | 275 | ); |
276 | 276 | } |
277 | 277 | } |
@@ -279,27 +279,27 @@ discard block |
||
279 | 279 | /** |
280 | 280 | * @since 1.8 |
281 | 281 | */ |
282 | - if( 'quiz' === $field['type'] ) { |
|
282 | + if ('quiz' === $field['type']) { |
|
283 | 283 | $has_quiz_fields = true; |
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
287 | 287 | * @since 1.8 |
288 | 288 | */ |
289 | - if( 'poll' === $field['type'] ) { |
|
289 | + if ('poll' === $field['type']) { |
|
290 | 290 | $has_poll_fields = true; |
291 | 291 | } |
292 | 292 | |
293 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
293 | + if (GFCommon::is_product_field($field['type'])) { |
|
294 | 294 | $has_product_fields = true; |
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
298 | 298 | * @hack Version 1.9 |
299 | 299 | */ |
300 | - $field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field; |
|
300 | + $field_for_is_post_field = class_exists('GF_Fields') ? (object)$field : (array)$field; |
|
301 | 301 | |
302 | - if ( GFCommon::is_post_field( $field_for_is_post_field ) ) { |
|
302 | + if (GFCommon::is_post_field($field_for_is_post_field)) { |
|
303 | 303 | $has_post_fields = true; |
304 | 304 | } |
305 | 305 | } |
@@ -308,19 +308,19 @@ discard block |
||
308 | 308 | /** |
309 | 309 | * @since 1.7 |
310 | 310 | */ |
311 | - if ( $has_post_fields ) { |
|
311 | + if ($has_post_fields) { |
|
312 | 312 | $fields['post_id'] = array( |
313 | - 'label' => __( 'Post ID', 'gravityview' ), |
|
313 | + 'label' => __('Post ID', 'gravityview'), |
|
314 | 314 | 'type' => 'post_id', |
315 | 315 | ); |
316 | 316 | } |
317 | 317 | |
318 | - if ( $has_product_fields ) { |
|
318 | + if ($has_product_fields) { |
|
319 | 319 | |
320 | - $payment_fields = GravityView_Fields::get_all( 'pricing' ); |
|
320 | + $payment_fields = GravityView_Fields::get_all('pricing'); |
|
321 | 321 | |
322 | - foreach ( $payment_fields as $payment_field ) { |
|
323 | - if( isset( $fields["{$payment_field->name}"] ) ) { |
|
322 | + foreach ($payment_fields as $payment_field) { |
|
323 | + if (isset($fields["{$payment_field->name}"])) { |
|
324 | 324 | continue; |
325 | 325 | } |
326 | 326 | $fields["{$payment_field->name}"] = array( |
@@ -334,27 +334,27 @@ discard block |
||
334 | 334 | /** |
335 | 335 | * @since 1.8 |
336 | 336 | */ |
337 | - if( $has_quiz_fields ) { |
|
337 | + if ($has_quiz_fields) { |
|
338 | 338 | |
339 | - $fields['gquiz_score'] = array( |
|
340 | - 'label' => __( 'Quiz Score Total', 'gravityview' ), |
|
339 | + $fields['gquiz_score'] = array( |
|
340 | + 'label' => __('Quiz Score Total', 'gravityview'), |
|
341 | 341 | 'type' => 'quiz_score', |
342 | - 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
|
342 | + 'desc' => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'), |
|
343 | 343 | ); |
344 | 344 | $fields['gquiz_percent'] = array( |
345 | - 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
|
345 | + 'label' => __('Quiz Percentage Grade', 'gravityview'), |
|
346 | 346 | 'type' => 'quiz_percent', |
347 | - 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
|
347 | + 'desc' => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'), |
|
348 | 348 | ); |
349 | - $fields['gquiz_grade'] = array( |
|
350 | - 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
|
349 | + $fields['gquiz_grade'] = array( |
|
350 | + 'label' => __('Quiz Letter Grade', 'gravityview'), |
|
351 | 351 | 'type' => 'quiz_grade', |
352 | - 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
|
352 | + 'desc' => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'), |
|
353 | 353 | ); |
354 | 354 | $fields['gquiz_is_pass'] = array( |
355 | - 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
|
355 | + 'label' => __('Quiz Pass/Fail', 'gravityview'), |
|
356 | 356 | 'type' => 'quiz_is_pass', |
357 | - 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
|
357 | + 'desc' => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'), |
|
358 | 358 | ); |
359 | 359 | } |
360 | 360 | |
@@ -367,15 +367,15 @@ discard block |
||
367 | 367 | * @param string $form_id (default: '') |
368 | 368 | * @return array |
369 | 369 | */ |
370 | - public static function get_entry_meta( $form_id, $only_default_column = true ) { |
|
370 | + public static function get_entry_meta($form_id, $only_default_column = true) { |
|
371 | 371 | |
372 | - $extra_fields = GFFormsModel::get_entry_meta( $form_id ); |
|
372 | + $extra_fields = GFFormsModel::get_entry_meta($form_id); |
|
373 | 373 | |
374 | 374 | $fields = array(); |
375 | 375 | |
376 | - foreach ( $extra_fields as $key => $field ){ |
|
377 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
378 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
376 | + foreach ($extra_fields as $key => $field) { |
|
377 | + if (!empty($only_default_column) && !empty($field['is_default_column'])) { |
|
378 | + $fields[$key] = array('label' => $field['label'], 'type' => 'entry_meta'); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | * @since 1.1.6 |
392 | 392 | * @return array|void Array of entry IDs. Void if Gravity Forms isn't active. |
393 | 393 | */ |
394 | - public static function get_entry_ids( $form_id, $search_criteria = array() ) { |
|
394 | + public static function get_entry_ids($form_id, $search_criteria = array()) { |
|
395 | 395 | |
396 | - if ( ! class_exists( 'GFFormsModel' ) ) { |
|
396 | + if (!class_exists('GFFormsModel')) { |
|
397 | 397 | return; |
398 | 398 | } |
399 | 399 | |
400 | - return GFFormsModel::search_lead_ids( $form_id, $search_criteria ); |
|
400 | + return GFFormsModel::search_lead_ids($form_id, $search_criteria); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
@@ -409,33 +409,33 @@ discard block |
||
409 | 409 | * @param array $form_ids array Gravity Forms form IDs |
410 | 410 | * @return array |
411 | 411 | */ |
412 | - public static function calculate_get_entries_criteria( $passed_criteria = array(), $form_ids = array() ) { |
|
412 | + public static function calculate_get_entries_criteria($passed_criteria = array(), $form_ids = array()) { |
|
413 | 413 | |
414 | 414 | $search_criteria_defaults = array( |
415 | 415 | 'search_criteria' => null, |
416 | 416 | 'sorting' => null, |
417 | 417 | 'paging' => null, |
418 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
418 | + 'cache' => (isset($passed_criteria['cache']) ? $passed_criteria['cache'] : true), |
|
419 | 419 | ); |
420 | 420 | |
421 | - $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
|
421 | + $criteria = wp_parse_args($passed_criteria, $search_criteria_defaults); |
|
422 | 422 | |
423 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
424 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
423 | + if (!empty($criteria['search_criteria']['field_filters'])) { |
|
424 | + foreach ($criteria['search_criteria']['field_filters'] as &$filter) { |
|
425 | 425 | |
426 | - if ( ! is_array( $filter ) ) { |
|
426 | + if (!is_array($filter)) { |
|
427 | 427 | continue; |
428 | 428 | } |
429 | 429 | |
430 | 430 | // By default, we want searches to be wildcard for each field. |
431 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
431 | + $filter['operator'] = empty($filter['operator']) ? 'contains' : $filter['operator']; |
|
432 | 432 | |
433 | 433 | /** |
434 | 434 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
435 | 435 | * @param string $operator Existing search operator |
436 | 436 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
437 | 437 | */ |
438 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
438 | + $filter['operator'] = apply_filters('gravityview_search_operator', $filter['operator'], $filter); |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
@@ -443,32 +443,32 @@ discard block |
||
443 | 443 | * Prepare date formats to be in Gravity Forms DB format; |
444 | 444 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
445 | 445 | */ |
446 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
446 | + foreach (array('start_date', 'end_date') as $key) { |
|
447 | 447 | |
448 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
448 | + if (!empty($criteria['search_criteria'][$key])) { |
|
449 | 449 | |
450 | 450 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
451 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
451 | + $date = date_create($criteria['search_criteria'][$key]); |
|
452 | 452 | |
453 | - if ( $date ) { |
|
453 | + if ($date) { |
|
454 | 454 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
455 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
455 | + $criteria['search_criteria'][$key] = $date->format('Y-m-d H:i:s'); |
|
456 | 456 | } else { |
457 | 457 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
458 | - unset( $criteria['search_criteria'][ $key ] ); |
|
458 | + unset($criteria['search_criteria'][$key]); |
|
459 | 459 | |
460 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
460 | + do_action('gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][$key]); |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
465 | 465 | |
466 | 466 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
467 | - if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
467 | + if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry()) { |
|
468 | 468 | $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
469 | - } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
|
470 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
|
471 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
469 | + } elseif ('delete' === RGForms::get('action')) { |
|
470 | + $criteria['context_view_id'] = isset($_GET['view_id']) ? $_GET['view_id'] : null; |
|
471 | + } elseif (!isset($criteria['context_view_id'])) { |
|
472 | 472 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
473 | 473 | $criteria['context_view_id'] = null; |
474 | 474 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * @param array $form_ids Forms to search |
480 | 480 | * @param int $view_id ID of the view being used to search |
481 | 481 | */ |
482 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
482 | + $criteria = apply_filters('gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id']); |
|
483 | 483 | |
484 | 484 | return (array)$criteria; |
485 | 485 | |
@@ -497,35 +497,35 @@ discard block |
||
497 | 497 | * @param mixed &$total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate the total count. (default: null) |
498 | 498 | * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays |
499 | 499 | */ |
500 | - public static function get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { |
|
500 | + public static function get_entries($form_ids = null, $passed_criteria = null, &$total = null) { |
|
501 | 501 | |
502 | 502 | // Filter the criteria before query (includes Adv Filter) |
503 | - $criteria = self::calculate_get_entries_criteria( $passed_criteria, $form_ids ); |
|
503 | + $criteria = self::calculate_get_entries_criteria($passed_criteria, $form_ids); |
|
504 | 504 | |
505 | - do_action( 'gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria ); |
|
505 | + do_action('gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria); |
|
506 | 506 | |
507 | 507 | // Return value |
508 | 508 | $return = null; |
509 | 509 | |
510 | 510 | /** Reduce # of database calls */ |
511 | - add_filter( 'gform_is_encrypted_field', '__return_false' ); |
|
511 | + add_filter('gform_is_encrypted_field', '__return_false'); |
|
512 | 512 | |
513 | - if ( ! empty( $criteria['cache'] ) ) { |
|
513 | + if (!empty($criteria['cache'])) { |
|
514 | 514 | |
515 | - $Cache = new GravityView_Cache( $form_ids, $criteria ); |
|
515 | + $Cache = new GravityView_Cache($form_ids, $criteria); |
|
516 | 516 | |
517 | - if ( $entries = $Cache->get() ) { |
|
517 | + if ($entries = $Cache->get()) { |
|
518 | 518 | |
519 | 519 | // Still update the total count when using cached results |
520 | - if ( ! is_null( $total ) ) { |
|
521 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
520 | + if (!is_null($total)) { |
|
521 | + $total = GFAPI::count_entries($form_ids, $criteria['search_criteria']); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | $return = $entries; |
525 | 525 | } |
526 | 526 | } |
527 | 527 | |
528 | - if ( is_null( $return ) && class_exists( 'GFAPI' ) && ( is_numeric( $form_ids ) || is_array( $form_ids ) ) ) { |
|
528 | + if (is_null($return) && class_exists('GFAPI') && (is_numeric($form_ids) || is_array($form_ids))) { |
|
529 | 529 | |
530 | 530 | /** |
531 | 531 | * @filter `gravityview_pre_get_entries` Define entries to be used before GFAPI::get_entries() is called |
@@ -535,24 +535,24 @@ discard block |
||
535 | 535 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
536 | 536 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
537 | 537 | */ |
538 | - $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
|
538 | + $entries = apply_filters('gravityview_before_get_entries', null, $criteria, $passed_criteria, $total); |
|
539 | 539 | |
540 | 540 | // No entries returned from gravityview_before_get_entries |
541 | - if( is_null( $entries ) ) { |
|
541 | + if (is_null($entries)) { |
|
542 | 542 | |
543 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
543 | + $entries = GFAPI::get_entries($form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total); |
|
544 | 544 | |
545 | - if ( is_wp_error( $entries ) ) { |
|
546 | - do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
|
545 | + if (is_wp_error($entries)) { |
|
546 | + do_action('gravityview_log_error', $entries->get_error_message(), $entries); |
|
547 | 547 | |
548 | 548 | return false; |
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
552 | + if (!empty($criteria['cache']) && isset($Cache)) { |
|
553 | 553 | |
554 | 554 | // Cache results |
555 | - $Cache->set( $entries, 'entries' ); |
|
555 | + $Cache->set($entries, 'entries'); |
|
556 | 556 | |
557 | 557 | } |
558 | 558 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | /** Remove filter added above */ |
563 | - remove_filter( 'gform_is_encrypted_field', '__return_false' ); |
|
563 | + remove_filter('gform_is_encrypted_field', '__return_false'); |
|
564 | 564 | |
565 | 565 | /** |
566 | 566 | * @filter `gravityview_entries` Modify the array of entries returned to GravityView after it has been fetched from the cache or from `GFAPI::get_entries()`. |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
570 | 570 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
571 | 571 | */ |
572 | - $return = apply_filters( 'gravityview_entries', $return, $criteria, $passed_criteria, $total ); |
|
572 | + $return = apply_filters('gravityview_entries', $return, $criteria, $passed_criteria, $total); |
|
573 | 573 | |
574 | 574 | return $return; |
575 | 575 | } |
@@ -586,15 +586,15 @@ discard block |
||
586 | 586 | * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true. {@since 1.14} |
587 | 587 | * @return array|boolean |
588 | 588 | */ |
589 | - public static function get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) { |
|
589 | + public static function get_entry($entry_slug, $force_allow_ids = false, $check_entry_display = true) { |
|
590 | 590 | |
591 | - if ( class_exists( 'GFAPI' ) && ! empty( $entry_slug ) ) { |
|
591 | + if (class_exists('GFAPI') && !empty($entry_slug)) { |
|
592 | 592 | |
593 | 593 | /** |
594 | 594 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
595 | 595 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
596 | 596 | */ |
597 | - $custom_slug = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
597 | + $custom_slug = apply_filters('gravityview_custom_entry_slug', false); |
|
598 | 598 | |
599 | 599 | /** |
600 | 600 | * @filter `gravityview_custom_entry_slug_allow_id` When using a custom slug, allow access to the entry using the original slug (the Entry ID). |
@@ -602,38 +602,38 @@ discard block |
||
602 | 602 | * - If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`) |
603 | 603 | * @param boolean $custom_slug_id_access True: allow accessing the slug by ID; False: only use the slug passed to the method. |
604 | 604 | */ |
605 | - $custom_slug_id_access = $force_allow_ids || apply_filters( 'gravityview_custom_entry_slug_allow_id', false ); |
|
605 | + $custom_slug_id_access = $force_allow_ids || apply_filters('gravityview_custom_entry_slug_allow_id', false); |
|
606 | 606 | |
607 | 607 | /** |
608 | 608 | * If we're using custom entry slugs, we do a meta value search |
609 | 609 | * instead of doing a straightup ID search. |
610 | 610 | */ |
611 | - if ( $custom_slug ) { |
|
611 | + if ($custom_slug) { |
|
612 | 612 | |
613 | - $entry_id = self::get_entry_id_from_slug( $entry_slug ); |
|
613 | + $entry_id = self::get_entry_id_from_slug($entry_slug); |
|
614 | 614 | |
615 | 615 | } |
616 | 616 | |
617 | 617 | // If custom slug is off, search using the entry ID |
618 | 618 | // ID allow ID access is on, also use entry ID as a backup |
619 | - if ( empty( $custom_slug ) || ! empty( $custom_slug_id_access ) ) { |
|
619 | + if (empty($custom_slug) || !empty($custom_slug_id_access)) { |
|
620 | 620 | // Search for IDs matching $entry_slug |
621 | 621 | $entry_id = $entry_slug; |
622 | 622 | } |
623 | 623 | |
624 | - if ( empty( $entry_id ) ) { |
|
624 | + if (empty($entry_id)) { |
|
625 | 625 | return false; |
626 | 626 | } |
627 | 627 | |
628 | 628 | // fetch the entry |
629 | - $entry = GFAPI::get_entry( $entry_id ); |
|
629 | + $entry = GFAPI::get_entry($entry_id); |
|
630 | 630 | |
631 | - if( $check_entry_display ) { |
|
631 | + if ($check_entry_display) { |
|
632 | 632 | // Is the entry allowed |
633 | - $entry = self::check_entry_display( $entry ); |
|
633 | + $entry = self::check_entry_display($entry); |
|
634 | 634 | } |
635 | 635 | |
636 | - return is_wp_error( $entry ) ? false : $entry; |
|
636 | + return is_wp_error($entry) ? false : $entry; |
|
637 | 637 | |
638 | 638 | } |
639 | 639 | |
@@ -657,51 +657,51 @@ discard block |
||
657 | 657 | * |
658 | 658 | * @return bool True: matches, false: not matches |
659 | 659 | */ |
660 | - public static function matches_operation( $val1, $val2, $operation ) { |
|
660 | + public static function matches_operation($val1, $val2, $operation) { |
|
661 | 661 | |
662 | 662 | $value = false; |
663 | 663 | |
664 | - if( 'context' === $val1 ) { |
|
664 | + if ('context' === $val1) { |
|
665 | 665 | |
666 | - $matching_contexts = array( $val2 ); |
|
666 | + $matching_contexts = array($val2); |
|
667 | 667 | |
668 | 668 | // We allow for non-standard contexts. |
669 | - switch( $val2 ) { |
|
669 | + switch ($val2) { |
|
670 | 670 | // Check for either single or edit |
671 | 671 | case 'singular': |
672 | - $matching_contexts = array( 'single', 'edit' ); |
|
672 | + $matching_contexts = array('single', 'edit'); |
|
673 | 673 | break; |
674 | 674 | // Use multiple as alias for directory for consistency |
675 | 675 | case 'multiple': |
676 | - $matching_contexts = array( 'directory' ); |
|
676 | + $matching_contexts = array('directory'); |
|
677 | 677 | break; |
678 | 678 | } |
679 | 679 | |
680 | - $val1 = in_array( gravityview_get_context(), $matching_contexts ) ? $val2 : false; |
|
680 | + $val1 = in_array(gravityview_get_context(), $matching_contexts) ? $val2 : false; |
|
681 | 681 | } |
682 | 682 | |
683 | - switch ( $operation ) { |
|
683 | + switch ($operation) { |
|
684 | 684 | case 'equals': |
685 | - $value = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
685 | + $value = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
686 | 686 | break; |
687 | 687 | case 'greater_than_or_is': |
688 | 688 | case 'greater_than_or_equals': |
689 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
690 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'greater_than' ); |
|
691 | - $value = ( $is || $gt ); |
|
689 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
690 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'greater_than'); |
|
691 | + $value = ($is || $gt); |
|
692 | 692 | break; |
693 | 693 | case 'less_than_or_is': |
694 | 694 | case 'less_than_or_equals': |
695 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
696 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'less_than' ); |
|
697 | - $value = ( $is || $gt ); |
|
695 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
696 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'less_than'); |
|
697 | + $value = ($is || $gt); |
|
698 | 698 | break; |
699 | 699 | case 'not_contains': |
700 | - $contains = GFFormsModel::matches_operation( $val1, $val2, 'contains' ); |
|
701 | - $value = ! $contains; |
|
700 | + $contains = GFFormsModel::matches_operation($val1, $val2, 'contains'); |
|
701 | + $value = !$contains; |
|
702 | 702 | break; |
703 | 703 | default: |
704 | - $value = GFFormsModel::matches_operation( $val1, $val2, $operation ); |
|
704 | + $value = GFFormsModel::matches_operation($val1, $val2, $operation); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | return $value; |
@@ -719,41 +719,41 @@ discard block |
||
719 | 719 | * @param array $entry Gravity Forms Entry object |
720 | 720 | * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter) |
721 | 721 | */ |
722 | - public static function check_entry_display( $entry ) { |
|
722 | + public static function check_entry_display($entry) { |
|
723 | 723 | |
724 | - if ( ! $entry || is_wp_error( $entry ) ) { |
|
725 | - do_action( 'gravityview_log_debug', __METHOD__ . ' Entry was not found.', $entry ); |
|
724 | + if (!$entry || is_wp_error($entry)) { |
|
725 | + do_action('gravityview_log_debug', __METHOD__.' Entry was not found.', $entry); |
|
726 | 726 | return false; |
727 | 727 | } |
728 | 728 | |
729 | - if ( empty( $entry['form_id'] ) ) { |
|
730 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
|
729 | + if (empty($entry['form_id'])) { |
|
730 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry); |
|
731 | 731 | return false; |
732 | 732 | } |
733 | 733 | |
734 | 734 | $criteria = self::calculate_get_entries_criteria(); |
735 | 735 | |
736 | 736 | // Make sure the current View is connected to the same form as the Entry |
737 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
738 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
739 | - $context_form_id = gravityview_get_form_id( $context_view_id ); |
|
740 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
741 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
737 | + if (!empty($criteria['context_view_id'])) { |
|
738 | + $context_view_id = intval($criteria['context_view_id']); |
|
739 | + $context_form_id = gravityview_get_form_id($context_view_id); |
|
740 | + if (intval($context_form_id) !== intval($entry['form_id'])) { |
|
741 | + do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id']), $criteria['context_view_id']); |
|
742 | 742 | return false; |
743 | 743 | } |
744 | 744 | } |
745 | 745 | |
746 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
747 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
|
746 | + if (empty($criteria['search_criteria']) || !is_array($criteria['search_criteria'])) { |
|
747 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria); |
|
748 | 748 | return $entry; |
749 | 749 | } |
750 | 750 | |
751 | 751 | $search_criteria = $criteria['search_criteria']; |
752 | - unset( $criteria ); |
|
752 | + unset($criteria); |
|
753 | 753 | |
754 | 754 | // check entry status |
755 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
756 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
755 | + if (array_key_exists('status', $search_criteria) && $search_criteria['status'] != $entry['status']) { |
|
756 | + do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status']), $search_criteria); |
|
757 | 757 | return false; |
758 | 758 | } |
759 | 759 | |
@@ -761,53 +761,53 @@ discard block |
||
761 | 761 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
762 | 762 | |
763 | 763 | // field_filters |
764 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
765 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
|
764 | + if (empty($search_criteria['field_filters']) || !is_array($search_criteria['field_filters'])) { |
|
765 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria); |
|
766 | 766 | return $entry; |
767 | 767 | } |
768 | 768 | |
769 | 769 | $filters = $search_criteria['field_filters']; |
770 | - unset( $search_criteria ); |
|
770 | + unset($search_criteria); |
|
771 | 771 | |
772 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
773 | - unset( $filters['mode'] ); |
|
772 | + $mode = array_key_exists('mode', $filters) ? strtolower($filters['mode']) : 'all'; |
|
773 | + unset($filters['mode']); |
|
774 | 774 | |
775 | - $form = self::get_form( $entry['form_id'] ); |
|
775 | + $form = self::get_form($entry['form_id']); |
|
776 | 776 | |
777 | - foreach ( $filters as $filter ) { |
|
777 | + foreach ($filters as $filter) { |
|
778 | 778 | |
779 | - if ( ! isset( $filter['key'] ) ) { |
|
779 | + if (!isset($filter['key'])) { |
|
780 | 780 | continue; |
781 | 781 | } |
782 | 782 | |
783 | 783 | $k = $filter['key']; |
784 | 784 | |
785 | - if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
|
786 | - $field_value = $entry[ $k ]; |
|
785 | + if (in_array($k, array('created_by', 'payment_status'))) { |
|
786 | + $field_value = $entry[$k]; |
|
787 | 787 | $field = null; |
788 | 788 | } else { |
789 | - $field = self::get_field( $form, $k ); |
|
790 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
789 | + $field = self::get_field($form, $k); |
|
790 | + $field_value = GFFormsModel::get_lead_field_value($entry, $field); |
|
791 | 791 | } |
792 | 792 | |
793 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
794 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
793 | + $operator = isset($filter['operator']) ? strtolower($filter['operator']) : 'is'; |
|
794 | + $is_value_match = GFFormsModel::is_value_match($field_value, $filter['value'], $operator, $field); |
|
795 | 795 | |
796 | 796 | // verify if we are already free to go! |
797 | - if ( ! $is_value_match && 'all' === $mode ) { |
|
798 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter ); |
|
797 | + if (!$is_value_match && 'all' === $mode) { |
|
798 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter); |
|
799 | 799 | return false; |
800 | - } elseif ( $is_value_match && 'any' === $mode ) { |
|
800 | + } elseif ($is_value_match && 'any' === $mode) { |
|
801 | 801 | return $entry; |
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
805 | 805 | // at this point, if in ALL mode, then entry is approved - all conditions were met. |
806 | 806 | // Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved |
807 | - if ( 'all' === $mode ) { |
|
807 | + if ('all' === $mode) { |
|
808 | 808 | return $entry; |
809 | 809 | } else { |
810 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
810 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters); |
|
811 | 811 | return false; |
812 | 812 | } |
813 | 813 | |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | * |
833 | 833 | * @return int|null|string Formatted date based on the original date |
834 | 834 | */ |
835 | - public static function format_date( $date_string = '', $args = array() ) { |
|
835 | + public static function format_date($date_string = '', $args = array()) { |
|
836 | 836 | |
837 | 837 | $default_atts = array( |
838 | 838 | 'raw' => false, |
@@ -843,39 +843,39 @@ discard block |
||
843 | 843 | 'time' => false, |
844 | 844 | ); |
845 | 845 | |
846 | - $atts = wp_parse_args( $args, $default_atts ); |
|
846 | + $atts = wp_parse_args($args, $default_atts); |
|
847 | 847 | |
848 | 848 | /** |
849 | 849 | * Gravity Forms code to adjust date to locally-configured Time Zone |
850 | 850 | * @see GFCommon::format_date() for original code |
851 | 851 | */ |
852 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
853 | - $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
|
852 | + $date_gmt_time = mysql2date('G', $date_string); |
|
853 | + $date_local_timestamp = GFCommon::get_local_timestamp($date_gmt_time); |
|
854 | 854 | |
855 | - $format = rgar( $atts, 'format' ); |
|
856 | - $is_human = ! empty( $atts['human'] ); |
|
857 | - $is_diff = ! empty( $atts['diff'] ); |
|
858 | - $is_raw = ! empty( $atts['raw'] ); |
|
859 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
860 | - $include_time = ! empty( $atts['time'] ); |
|
855 | + $format = rgar($atts, 'format'); |
|
856 | + $is_human = !empty($atts['human']); |
|
857 | + $is_diff = !empty($atts['diff']); |
|
858 | + $is_raw = !empty($atts['raw']); |
|
859 | + $is_timestamp = !empty($atts['timestamp']); |
|
860 | + $include_time = !empty($atts['time']); |
|
861 | 861 | |
862 | 862 | // If we're using time diff, we want to have a different default format |
863 | - if( empty( $format ) ) { |
|
864 | - $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
|
863 | + if (empty($format)) { |
|
864 | + $format = $is_diff ? esc_html__('%s ago', 'gravityview') : get_option('date_format'); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | // If raw was specified, don't modify the stored value |
868 | - if ( $is_raw ) { |
|
868 | + if ($is_raw) { |
|
869 | 869 | $formatted_date = $date_string; |
870 | - } elseif( $is_timestamp ) { |
|
870 | + } elseif ($is_timestamp) { |
|
871 | 871 | $formatted_date = $date_local_timestamp; |
872 | - } elseif ( $is_diff ) { |
|
873 | - $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
|
872 | + } elseif ($is_diff) { |
|
873 | + $formatted_date = sprintf($format, human_time_diff($date_gmt_time)); |
|
874 | 874 | } else { |
875 | - $formatted_date = GFCommon::format_date( $date_string, $is_human, $format, $include_time ); |
|
875 | + $formatted_date = GFCommon::format_date($date_string, $is_human, $format, $include_time); |
|
876 | 876 | } |
877 | 877 | |
878 | - unset( $format, $is_diff, $is_human, $is_timestamp, $is_raw, $date_gmt_time, $date_local_timestamp, $default_atts ); |
|
878 | + unset($format, $is_diff, $is_human, $is_timestamp, $is_raw, $date_gmt_time, $date_local_timestamp, $default_atts); |
|
879 | 879 | |
880 | 880 | return $formatted_date; |
881 | 881 | } |
@@ -888,14 +888,14 @@ discard block |
||
888 | 888 | * @param string $field_id |
889 | 889 | * @return string |
890 | 890 | */ |
891 | - public static function get_field_label( $form = array(), $field_id = '' ) { |
|
891 | + public static function get_field_label($form = array(), $field_id = '') { |
|
892 | 892 | |
893 | - if ( empty( $form ) || empty( $field_id ) ) { |
|
893 | + if (empty($form) || empty($field_id)) { |
|
894 | 894 | return ''; |
895 | 895 | } |
896 | 896 | |
897 | - $field = self::get_field( $form, $field_id ); |
|
898 | - return isset( $field['label'] ) ? $field['label'] : ''; |
|
897 | + $field = self::get_field($form, $field_id); |
|
898 | + return isset($field['label']) ? $field['label'] : ''; |
|
899 | 899 | |
900 | 900 | } |
901 | 901 | |
@@ -912,9 +912,9 @@ discard block |
||
912 | 912 | * @param string|int $field_id |
913 | 913 | * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist |
914 | 914 | */ |
915 | - public static function get_field( $form, $field_id ) { |
|
916 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
917 | - return GFFormsModel::get_field( $form, $field_id ); |
|
915 | + public static function get_field($form, $field_id) { |
|
916 | + if (class_exists('GFFormsModel')) { |
|
917 | + return GFFormsModel::get_field($form, $field_id); |
|
918 | 918 | } else { |
919 | 919 | return null; |
920 | 920 | } |
@@ -930,16 +930,16 @@ discard block |
||
930 | 930 | * @param WP_Post $post WordPress post object |
931 | 931 | * @return boolean True: yep, GravityView; No: not! |
932 | 932 | */ |
933 | - public static function has_gravityview_shortcode( $post = null ) { |
|
934 | - if ( ! is_a( $post, 'WP_Post' ) ) { |
|
933 | + public static function has_gravityview_shortcode($post = null) { |
|
934 | + if (!is_a($post, 'WP_Post')) { |
|
935 | 935 | return false; |
936 | 936 | } |
937 | 937 | |
938 | - if ( 'gravityview' === get_post_type( $post ) ) { |
|
938 | + if ('gravityview' === get_post_type($post)) { |
|
939 | 939 | return true; |
940 | 940 | } |
941 | 941 | |
942 | - return self::has_shortcode_r( $post->post_content, 'gravityview' ) ? true : false; |
|
942 | + return self::has_shortcode_r($post->post_content, 'gravityview') ? true : false; |
|
943 | 943 | |
944 | 944 | } |
945 | 945 | |
@@ -950,27 +950,27 @@ discard block |
||
950 | 950 | * @param string $content Content to check whether there's a shortcode |
951 | 951 | * @param string $tag Current shortcode tag |
952 | 952 | */ |
953 | - public static function has_shortcode_r( $content, $tag = 'gravityview' ) { |
|
954 | - if ( false === strpos( $content, '[' ) ) { |
|
953 | + public static function has_shortcode_r($content, $tag = 'gravityview') { |
|
954 | + if (false === strpos($content, '[')) { |
|
955 | 955 | return false; |
956 | 956 | } |
957 | 957 | |
958 | - if ( shortcode_exists( $tag ) ) { |
|
958 | + if (shortcode_exists($tag)) { |
|
959 | 959 | |
960 | 960 | $shortcodes = array(); |
961 | 961 | |
962 | - preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
|
963 | - if ( empty( $matches ) ){ |
|
962 | + preg_match_all('/'.get_shortcode_regex().'/s', $content, $matches, PREG_SET_ORDER); |
|
963 | + if (empty($matches)) { |
|
964 | 964 | return false; |
965 | 965 | } |
966 | 966 | |
967 | - foreach ( $matches as $shortcode ) { |
|
968 | - if ( $tag === $shortcode[2] ) { |
|
967 | + foreach ($matches as $shortcode) { |
|
968 | + if ($tag === $shortcode[2]) { |
|
969 | 969 | |
970 | 970 | // Changed this to $shortcode instead of true so we get the parsed atts. |
971 | 971 | $shortcodes[] = $shortcode; |
972 | 972 | |
973 | - } else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
973 | + } else if (isset($shortcode[5]) && $result = self::has_shortcode_r($shortcode[5], $tag)) { |
|
974 | 974 | $shortcodes = $result; |
975 | 975 | } |
976 | 976 | } |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | * |
995 | 995 | * @return array Array with view details, as returned by get_posts() |
996 | 996 | */ |
997 | - public static function get_connected_views( $form_id, $args = array() ) { |
|
997 | + public static function get_connected_views($form_id, $args = array()) { |
|
998 | 998 | |
999 | 999 | $defaults = array( |
1000 | 1000 | 'post_type' => 'gravityview', |
@@ -1003,9 +1003,9 @@ discard block |
||
1003 | 1003 | 'meta_value' => (int)$form_id, |
1004 | 1004 | ); |
1005 | 1005 | |
1006 | - $args = wp_parse_args( $args, $defaults ); |
|
1006 | + $args = wp_parse_args($args, $defaults); |
|
1007 | 1007 | |
1008 | - $views = get_posts( $args ); |
|
1008 | + $views = get_posts($args); |
|
1009 | 1009 | |
1010 | 1010 | return $views; |
1011 | 1011 | } |
@@ -1017,8 +1017,8 @@ discard block |
||
1017 | 1017 | * |
1018 | 1018 | * @return string ID of the connected Form, if exists. Empty string if not. |
1019 | 1019 | */ |
1020 | - public static function get_meta_form_id( $view_id ) { |
|
1021 | - return get_post_meta( $view_id, '_gravityview_form_id', true ); |
|
1020 | + public static function get_meta_form_id($view_id) { |
|
1021 | + return get_post_meta($view_id, '_gravityview_form_id', true); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1030,8 +1030,8 @@ discard block |
||
1030 | 1030 | * |
1031 | 1031 | * @return string GravityView_Template::template_id value. Empty string if not. |
1032 | 1032 | */ |
1033 | - public static function get_meta_template_id( $view_id ) { |
|
1034 | - return get_post_meta( $view_id, '_gravityview_directory_template', true ); |
|
1033 | + public static function get_meta_template_id($view_id) { |
|
1034 | + return get_post_meta($view_id, '_gravityview_directory_template', true); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | |
@@ -1042,15 +1042,15 @@ discard block |
||
1042 | 1042 | * @param int $post_id View ID |
1043 | 1043 | * @return array Associative array of settings with plugin defaults used if not set by the View |
1044 | 1044 | */ |
1045 | - public static function get_template_settings( $post_id ) { |
|
1045 | + public static function get_template_settings($post_id) { |
|
1046 | 1046 | |
1047 | - $settings = get_post_meta( $post_id, '_gravityview_template_settings', true ); |
|
1047 | + $settings = get_post_meta($post_id, '_gravityview_template_settings', true); |
|
1048 | 1048 | |
1049 | - if ( class_exists( 'GravityView_View_Data' ) ) { |
|
1049 | + if (class_exists('GravityView_View_Data')) { |
|
1050 | 1050 | |
1051 | 1051 | $defaults = GravityView_View_Data::get_default_args(); |
1052 | 1052 | |
1053 | - return wp_parse_args( (array)$settings, $defaults ); |
|
1053 | + return wp_parse_args((array)$settings, $defaults); |
|
1054 | 1054 | |
1055 | 1055 | } |
1056 | 1056 | |
@@ -1067,12 +1067,12 @@ discard block |
||
1067 | 1067 | * @param string $key Key for the setting |
1068 | 1068 | * @return mixed|null Setting value, or NULL if not set. |
1069 | 1069 | */ |
1070 | - public static function get_template_setting( $post_id, $key ) { |
|
1070 | + public static function get_template_setting($post_id, $key) { |
|
1071 | 1071 | |
1072 | - $settings = self::get_template_settings( $post_id ); |
|
1072 | + $settings = self::get_template_settings($post_id); |
|
1073 | 1073 | |
1074 | - if ( isset( $settings[ $key ] ) ) { |
|
1075 | - return $settings[ $key ]; |
|
1074 | + if (isset($settings[$key])) { |
|
1075 | + return $settings[$key]; |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | return null; |
@@ -1108,8 +1108,8 @@ discard block |
||
1108 | 1108 | * @param int $post_id View ID |
1109 | 1109 | * @return array Multi-array of fields with first level being the field zones. See code comment. |
1110 | 1110 | */ |
1111 | - public static function get_directory_fields( $post_id ) { |
|
1112 | - return get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
|
1111 | + public static function get_directory_fields($post_id) { |
|
1112 | + return get_post_meta($post_id, '_gravityview_directory_fields', true); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | |
@@ -1120,25 +1120,25 @@ discard block |
||
1120 | 1120 | * @param int $formid Form ID |
1121 | 1121 | * @return string html |
1122 | 1122 | */ |
1123 | - public static function get_sortable_fields( $formid, $current = '' ) { |
|
1124 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1123 | + public static function get_sortable_fields($formid, $current = '') { |
|
1124 | + $output = '<option value="" '.selected('', $current, false).'>'.esc_html__('Default', 'gravityview').'</option>'; |
|
1125 | 1125 | |
1126 | - if ( empty( $formid ) ) { |
|
1126 | + if (empty($formid)) { |
|
1127 | 1127 | return $output; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | - $fields = self::get_sortable_fields_array( $formid ); |
|
1130 | + $fields = self::get_sortable_fields_array($formid); |
|
1131 | 1131 | |
1132 | - if ( ! empty( $fields ) ) { |
|
1132 | + if (!empty($fields)) { |
|
1133 | 1133 | |
1134 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
|
1134 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('list', 'textarea'), null); |
|
1135 | 1135 | |
1136 | - foreach ( $fields as $id => $field ) { |
|
1137 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1136 | + foreach ($fields as $id => $field) { |
|
1137 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
1138 | 1138 | continue; |
1139 | 1139 | } |
1140 | 1140 | |
1141 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1141 | + $output .= '<option value="'.$id.'" '.selected($id, $current, false).'>'.esc_attr($field['label']).'</option>'; |
|
1142 | 1142 | } |
1143 | 1143 | } |
1144 | 1144 | |
@@ -1156,27 +1156,27 @@ discard block |
||
1156 | 1156 | * |
1157 | 1157 | * @return array |
1158 | 1158 | */ |
1159 | - public static function get_sortable_fields_array( $formid, $blacklist = array( 'list', 'textarea' ) ) { |
|
1159 | + public static function get_sortable_fields_array($formid, $blacklist = array('list', 'textarea')) { |
|
1160 | 1160 | |
1161 | 1161 | // Get fields with sub-inputs and no parent |
1162 | - $fields = self::get_form_fields( $formid, true, false ); |
|
1162 | + $fields = self::get_form_fields($formid, true, false); |
|
1163 | 1163 | |
1164 | 1164 | $date_created = array( |
1165 | 1165 | 'date_created' => array( |
1166 | 1166 | 'type' => 'date_created', |
1167 | - 'label' => __( 'Date Created', 'gravityview' ), |
|
1167 | + 'label' => __('Date Created', 'gravityview'), |
|
1168 | 1168 | ), |
1169 | 1169 | ); |
1170 | 1170 | |
1171 | 1171 | $fields = $date_created + $fields; |
1172 | 1172 | |
1173 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
|
1173 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', $blacklist, NULL); |
|
1174 | 1174 | |
1175 | 1175 | // TODO: Convert to using array_filter |
1176 | - foreach( $fields as $id => $field ) { |
|
1176 | + foreach ($fields as $id => $field) { |
|
1177 | 1177 | |
1178 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1179 | - unset( $fields[ $id ] ); |
|
1178 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
1179 | + unset($fields[$id]); |
|
1180 | 1180 | } |
1181 | 1181 | } |
1182 | 1182 | |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | * @param array $fields Sub-set of GF form fields that are sortable |
1187 | 1187 | * @param int $formid The Gravity Forms form ID that the fields are from |
1188 | 1188 | */ |
1189 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1189 | + $fields = apply_filters('gravityview/common/sortable_fields', $fields, $formid); |
|
1190 | 1190 | |
1191 | 1191 | return $fields; |
1192 | 1192 | } |
@@ -1197,15 +1197,15 @@ discard block |
||
1197 | 1197 | * @param mixed $field_id Field ID or Field array |
1198 | 1198 | * @return string field type |
1199 | 1199 | */ |
1200 | - public static function get_field_type( $form = null, $field_id = '' ) { |
|
1200 | + public static function get_field_type($form = null, $field_id = '') { |
|
1201 | 1201 | |
1202 | - if ( ! empty( $field_id ) && ! is_array( $field_id ) ) { |
|
1203 | - $field = self::get_field( $form, $field_id ); |
|
1202 | + if (!empty($field_id) && !is_array($field_id)) { |
|
1203 | + $field = self::get_field($form, $field_id); |
|
1204 | 1204 | } else { |
1205 | 1205 | $field = $field_id; |
1206 | 1206 | } |
1207 | 1207 | |
1208 | - return class_exists( 'RGFormsModel' ) ? RGFormsModel::get_input_type( $field ) : ''; |
|
1208 | + return class_exists('RGFormsModel') ? RGFormsModel::get_input_type($field) : ''; |
|
1209 | 1209 | |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1216,17 +1216,17 @@ discard block |
||
1216 | 1216 | * @param int|array $field field key or field array |
1217 | 1217 | * @return boolean |
1218 | 1218 | */ |
1219 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1219 | + public static function is_field_numeric($form = null, $field = '') { |
|
1220 | 1220 | |
1221 | - if ( ! is_array( $form ) && ! is_array( $field ) ) { |
|
1222 | - $form = self::get_form( $form ); |
|
1221 | + if (!is_array($form) && !is_array($field)) { |
|
1222 | + $form = self::get_form($form); |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | // If entry meta, it's a string. Otherwise, numeric |
1226 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1226 | + if (!is_numeric($field) && is_string($field)) { |
|
1227 | 1227 | $type = $field; |
1228 | 1228 | } else { |
1229 | - $type = self::get_field_type( $form, $field ); |
|
1229 | + $type = self::get_field_type($form, $field); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | /** |
@@ -1234,16 +1234,16 @@ discard block |
||
1234 | 1234 | * @since 1.5.2 |
1235 | 1235 | * @param array $numeric_types Fields that are numeric. Default: `[ number, time ]` |
1236 | 1236 | */ |
1237 | - $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
|
1237 | + $numeric_types = apply_filters('gravityview/common/numeric_types', array('number', 'time')); |
|
1238 | 1238 | |
1239 | 1239 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1240 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1241 | - if( true === $gv_field->is_numeric ) { |
|
1240 | + if ($gv_field = GravityView_Fields::get($type)) { |
|
1241 | + if (true === $gv_field->is_numeric) { |
|
1242 | 1242 | $numeric_types[] = $gv_field->is_numeric; |
1243 | 1243 | } |
1244 | 1244 | } |
1245 | 1245 | |
1246 | - $return = in_array( $type, $numeric_types ); |
|
1246 | + $return = in_array($type, $numeric_types); |
|
1247 | 1247 | |
1248 | 1248 | return $return; |
1249 | 1249 | } |
@@ -1262,19 +1262,19 @@ discard block |
||
1262 | 1262 | * |
1263 | 1263 | * @return string Content, encrypted |
1264 | 1264 | */ |
1265 | - public static function js_encrypt( $content, $message = '' ) { |
|
1265 | + public static function js_encrypt($content, $message = '') { |
|
1266 | 1266 | |
1267 | 1267 | $output = $content; |
1268 | 1268 | |
1269 | - if ( ! class_exists( 'StandalonePHPEnkoder' ) ) { |
|
1270 | - include_once( GRAVITYVIEW_DIR . 'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php' ); |
|
1269 | + if (!class_exists('StandalonePHPEnkoder')) { |
|
1270 | + include_once(GRAVITYVIEW_DIR.'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php'); |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | - if ( class_exists( 'StandalonePHPEnkoder' ) ) { |
|
1273 | + if (class_exists('StandalonePHPEnkoder')) { |
|
1274 | 1274 | |
1275 | 1275 | $enkoder = new StandalonePHPEnkoder; |
1276 | 1276 | |
1277 | - $message = empty( $message ) ? __( 'Email hidden; Javascript is required.', 'gravityview' ) : $message; |
|
1277 | + $message = empty($message) ? __('Email hidden; Javascript is required.', 'gravityview') : $message; |
|
1278 | 1278 | |
1279 | 1279 | /** |
1280 | 1280 | * @filter `gravityview/phpenkoder/msg` Modify the message shown when Javascript is disabled and an encrypted email field is displayed |
@@ -1282,9 +1282,9 @@ discard block |
||
1282 | 1282 | * @param string $message Existing message |
1283 | 1283 | * @param string $content Content to encrypt |
1284 | 1284 | */ |
1285 | - $enkoder->enkode_msg = apply_filters( 'gravityview/phpenkoder/msg', $message, $content ); |
|
1285 | + $enkoder->enkode_msg = apply_filters('gravityview/phpenkoder/msg', $message, $content); |
|
1286 | 1286 | |
1287 | - $output = $enkoder->enkode( $content ); |
|
1287 | + $output = $enkoder->enkode($content); |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | return $output; |
@@ -1301,25 +1301,25 @@ discard block |
||
1301 | 1301 | * |
1302 | 1302 | * @author rubo77 at https://gist.github.com/rubo77/6821632 |
1303 | 1303 | **/ |
1304 | - public static function gv_parse_str( $string, &$result ) { |
|
1305 | - if ( empty( $string ) ) { |
|
1304 | + public static function gv_parse_str($string, &$result) { |
|
1305 | + if (empty($string)) { |
|
1306 | 1306 | return false; |
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | $result = array(); |
1310 | 1310 | |
1311 | 1311 | // find the pairs "name=value" |
1312 | - $pairs = explode( '&', $string ); |
|
1312 | + $pairs = explode('&', $string); |
|
1313 | 1313 | |
1314 | - foreach ( $pairs as $pair ) { |
|
1314 | + foreach ($pairs as $pair) { |
|
1315 | 1315 | // use the original parse_str() on each element |
1316 | - parse_str( $pair, $params ); |
|
1316 | + parse_str($pair, $params); |
|
1317 | 1317 | |
1318 | - $k = key( $params ); |
|
1319 | - if ( ! isset( $result[ $k ] ) ) { |
|
1318 | + $k = key($params); |
|
1319 | + if (!isset($result[$k])) { |
|
1320 | 1320 | $result += $params; |
1321 | - } elseif ( array_key_exists( $k, $params ) && is_array( $params[ $k ] ) ) { |
|
1322 | - $result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] ); |
|
1321 | + } elseif (array_key_exists($k, $params) && is_array($params[$k])) { |
|
1322 | + $result[$k] = self::array_merge_recursive_distinct($result[$k], $params[$k]); |
|
1323 | 1323 | } |
1324 | 1324 | } |
1325 | 1325 | return true; |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | * |
1342 | 1342 | * @return string HTML output of anchor link. If empty $href, returns NULL |
1343 | 1343 | */ |
1344 | - public static function get_link_html( $href = '', $anchor_text = '', $atts = array() ) { |
|
1344 | + public static function get_link_html($href = '', $anchor_text = '', $atts = array()) { |
|
1345 | 1345 | |
1346 | 1346 | // Supported attributes for anchor tags. HREF left out intentionally. |
1347 | 1347 | $allowed_atts = array( |
@@ -1377,31 +1377,31 @@ discard block |
||
1377 | 1377 | * @filter `gravityview/get_link/allowed_atts` Modify the attributes that are allowed to be used in generating links |
1378 | 1378 | * @param array $allowed_atts Array of attributes allowed |
1379 | 1379 | */ |
1380 | - $allowed_atts = apply_filters( 'gravityview/get_link/allowed_atts', $allowed_atts ); |
|
1380 | + $allowed_atts = apply_filters('gravityview/get_link/allowed_atts', $allowed_atts); |
|
1381 | 1381 | |
1382 | 1382 | // Make sure the attributes are formatted as array |
1383 | - $passed_atts = wp_parse_args( $atts ); |
|
1383 | + $passed_atts = wp_parse_args($atts); |
|
1384 | 1384 | |
1385 | 1385 | // Make sure the allowed attributes are only the ones in the $allowed_atts list |
1386 | - $final_atts = shortcode_atts( $allowed_atts, $passed_atts ); |
|
1386 | + $final_atts = shortcode_atts($allowed_atts, $passed_atts); |
|
1387 | 1387 | |
1388 | 1388 | // Remove attributes with empty values |
1389 | - $final_atts = array_filter( $final_atts ); |
|
1389 | + $final_atts = array_filter($final_atts); |
|
1390 | 1390 | |
1391 | 1391 | // If the href wasn't passed as an attribute, use the value passed to the function |
1392 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1392 | + if (empty($final_atts['href']) && !empty($href)) { |
|
1393 | 1393 | $final_atts['href'] = $href; |
1394 | 1394 | } |
1395 | 1395 | |
1396 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1396 | + $final_atts['href'] = esc_url_raw($href); |
|
1397 | 1397 | |
1398 | 1398 | // For each attribute, generate the code |
1399 | 1399 | $output = ''; |
1400 | - foreach ( $final_atts as $attr => $value ) { |
|
1401 | - $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
|
1400 | + foreach ($final_atts as $attr => $value) { |
|
1401 | + $output .= sprintf(' %s="%s"', $attr, esc_attr($value)); |
|
1402 | 1402 | } |
1403 | 1403 | |
1404 | - $output = '<a'. $output .'>'. $anchor_text .'</a>'; |
|
1404 | + $output = '<a'.$output.'>'.$anchor_text.'</a>'; |
|
1405 | 1405 | |
1406 | 1406 | return $output; |
1407 | 1407 | } |
@@ -1420,14 +1420,14 @@ discard block |
||
1420 | 1420 | * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk> |
1421 | 1421 | * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com> |
1422 | 1422 | */ |
1423 | - public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { |
|
1423 | + public static function array_merge_recursive_distinct(array &$array1, array &$array2) { |
|
1424 | 1424 | $merged = $array1; |
1425 | 1425 | |
1426 | - foreach ( $array2 as $key => &$value ) { |
|
1427 | - if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
|
1428 | - $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
|
1426 | + foreach ($array2 as $key => &$value) { |
|
1427 | + if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { |
|
1428 | + $merged[$key] = self::array_merge_recursive_distinct($merged[$key], $value); |
|
1429 | 1429 | } else { |
1430 | - $merged[ $key ] = $value; |
|
1430 | + $merged[$key] = $value; |
|
1431 | 1431 | } |
1432 | 1432 | } |
1433 | 1433 | |
@@ -1441,26 +1441,26 @@ discard block |
||
1441 | 1441 | * @param array $args Arguments to modify the user query. See get_users() {@since 1.14} |
1442 | 1442 | * @return array Array of WP_User objects. |
1443 | 1443 | */ |
1444 | - public static function get_users( $context = 'change_entry_creator', $args = array() ) { |
|
1444 | + public static function get_users($context = 'change_entry_creator', $args = array()) { |
|
1445 | 1445 | |
1446 | 1446 | $default_args = array( |
1447 | 1447 | 'number' => 2000, |
1448 | 1448 | 'orderby' => 'display_name', |
1449 | 1449 | 'order' => 'ASC', |
1450 | - 'fields' => array( 'ID', 'display_name', 'user_login', 'user_nicename' ) |
|
1450 | + 'fields' => array('ID', 'display_name', 'user_login', 'user_nicename') |
|
1451 | 1451 | ); |
1452 | 1452 | |
1453 | 1453 | // Merge in the passed arg |
1454 | - $get_users_settings = wp_parse_args( $args, $default_args ); |
|
1454 | + $get_users_settings = wp_parse_args($args, $default_args); |
|
1455 | 1455 | |
1456 | 1456 | /** |
1457 | 1457 | * @filter `gravityview/get_users/{$context}` There are issues with too many users using [get_users()](http://codex.wordpress.org/Function_Reference/get_users) where it breaks the select. We try to keep it at a reasonable number. \n |
1458 | 1458 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1459 | 1459 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1460 | 1460 | */ |
1461 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1461 | + $get_users_settings = apply_filters('gravityview/get_users/'.$context, apply_filters('gravityview_change_entry_creator_user_parameters', $get_users_settings)); |
|
1462 | 1462 | |
1463 | - return get_users( $get_users_settings ); |
|
1463 | + return get_users($get_users_settings); |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | |
@@ -1472,8 +1472,8 @@ discard block |
||
1472 | 1472 | * |
1473 | 1473 | * @return string |
1474 | 1474 | */ |
1475 | - public static function generate_notice( $notice, $class = '' ) { |
|
1476 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1475 | + public static function generate_notice($notice, $class = '') { |
|
1476 | + return '<div class="gv-notice '.gravityview_sanitize_html_class($class).'">'.$notice.'</div>'; |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | |
@@ -1495,6 +1495,6 @@ discard block |
||
1495 | 1495 | * |
1496 | 1496 | * @return string HTML output of anchor link. If empty $href, returns NULL |
1497 | 1497 | */ |
1498 | -function gravityview_get_link( $href = '', $anchor_text = '', $atts = array() ) { |
|
1499 | - return GVCommon::get_link_html( $href, $anchor_text, $atts ); |
|
1498 | +function gravityview_get_link($href = '', $anchor_text = '', $atts = array()) { |
|
1499 | + return GVCommon::get_link_html($href, $anchor_text, $atts); |
|
1500 | 1500 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** If this file is called directly, abort. */ |
4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | +if (!defined('ABSPATH')) { |
|
5 | 5 | die; |
6 | 6 | } |
7 | 7 | |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @param null $passed_post |
17 | 17 | */ |
18 | - private function __construct( $passed_post = NULL ) { |
|
18 | + private function __construct($passed_post = NULL) { |
|
19 | 19 | |
20 | - if( !empty( $passed_post ) ) { |
|
20 | + if (!empty($passed_post)) { |
|
21 | 21 | |
22 | - $id_or_id_array = $this->maybe_get_view_id( $passed_post ); |
|
22 | + $id_or_id_array = $this->maybe_get_view_id($passed_post); |
|
23 | 23 | |
24 | - if( !empty( $id_or_id_array ) ) { |
|
25 | - $this->add_view( $id_or_id_array ); |
|
24 | + if (!empty($id_or_id_array)) { |
|
25 | + $this->add_view($id_or_id_array); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public function has_multiple_views() { |
35 | 35 | |
36 | 36 | //multiple views |
37 | - return count( $this->get_views() ) > 1 ? true : false; |
|
37 | + return count($this->get_views()) > 1 ? true : false; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -52,37 +52,37 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return int|null|array ID of the View. If there are multiple views in the content, array of IDs parsed. |
54 | 54 | */ |
55 | - public function maybe_get_view_id( $passed_post ) { |
|
55 | + public function maybe_get_view_id($passed_post) { |
|
56 | 56 | |
57 | 57 | $ids = array(); |
58 | 58 | |
59 | - if( ! empty( $passed_post ) ) { |
|
59 | + if (!empty($passed_post)) { |
|
60 | 60 | |
61 | - if( is_numeric( $passed_post ) ) { |
|
62 | - $passed_post = get_post( $passed_post ); |
|
61 | + if (is_numeric($passed_post)) { |
|
62 | + $passed_post = get_post($passed_post); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Convert WP_Posts into WP_Posts[] array |
66 | - if( $passed_post instanceof WP_Post ) { |
|
67 | - $passed_post = array( $passed_post ); |
|
66 | + if ($passed_post instanceof WP_Post) { |
|
67 | + $passed_post = array($passed_post); |
|
68 | 68 | } |
69 | 69 | |
70 | - if( is_array( $passed_post ) ) { |
|
70 | + if (is_array($passed_post)) { |
|
71 | 71 | |
72 | - foreach ( $passed_post as &$post) { |
|
73 | - if( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
72 | + foreach ($passed_post as &$post) { |
|
73 | + if ((get_post_type($post) === 'gravityview')) { |
|
74 | 74 | $ids[] = $post->ID; |
75 | - } else{ |
|
75 | + } else { |
|
76 | 76 | // Parse the Post Content |
77 | - $id = $this->parse_post_content( $post->post_content ); |
|
78 | - if( $id ) { |
|
79 | - $ids = array_merge( $ids, (array) $id ); |
|
77 | + $id = $this->parse_post_content($post->post_content); |
|
78 | + if ($id) { |
|
79 | + $ids = array_merge($ids, (array)$id); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Parse the Post Meta |
83 | - $id = $this->parse_post_meta( $post->ID ); |
|
84 | - if( $id ) { |
|
85 | - $ids = array_merge( $ids, (array) $id ); |
|
83 | + $id = $this->parse_post_meta($post->ID); |
|
84 | + if ($id) { |
|
85 | + $ids = array_merge($ids, (array)$id); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -90,33 +90,33 @@ discard block |
||
90 | 90 | |
91 | 91 | } else { |
92 | 92 | |
93 | - if ( is_string( $passed_post ) ) { |
|
93 | + if (is_string($passed_post)) { |
|
94 | 94 | |
95 | - $id = $this->parse_post_content( $passed_post ); |
|
96 | - if( $id ) { |
|
97 | - $ids = array_merge( $ids, (array) $id ); |
|
95 | + $id = $this->parse_post_content($passed_post); |
|
96 | + if ($id) { |
|
97 | + $ids = array_merge($ids, (array)$id); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } else { |
101 | - $id = $this->get_id_from_atts( $passed_post ); |
|
102 | - $ids[] = intval( $id ); |
|
101 | + $id = $this->get_id_from_atts($passed_post); |
|
102 | + $ids[] = intval($id); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - if( empty($ids) ) { |
|
107 | + if (empty($ids)) { |
|
108 | 108 | return NULL; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // If it's just one ID, return that. |
112 | 112 | // Otherwise, return array of IDs |
113 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
113 | + return (sizeof($ids) === 1) ? $ids[0] : $ids; |
|
114 | 114 | } |
115 | 115 | |
116 | - public static function getInstance( $passed_post = NULL ) { |
|
116 | + public static function getInstance($passed_post = NULL) { |
|
117 | 117 | |
118 | - if( empty( self::$instance ) ) { |
|
119 | - self::$instance = new GravityView_View_Data( $passed_post ); |
|
118 | + if (empty(self::$instance)) { |
|
119 | + self::$instance = new GravityView_View_Data($passed_post); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return self::$instance; |
@@ -126,25 +126,25 @@ discard block |
||
126 | 126 | return $this->views; |
127 | 127 | } |
128 | 128 | |
129 | - function get_view( $view_id, $atts = NULL ) { |
|
129 | + function get_view($view_id, $atts = NULL) { |
|
130 | 130 | |
131 | - if( ! is_numeric( $view_id) ) { |
|
132 | - do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) ); |
|
131 | + if (!is_numeric($view_id)) { |
|
132 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id)); |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Backup: the view hasn't been fetched yet. Doing it now. |
137 | - if ( ! isset( $this->views[ $view_id ] ) ) { |
|
138 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) ); |
|
139 | - return $this->add_view( $view_id, $atts ); |
|
137 | + if (!isset($this->views[$view_id])) { |
|
138 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id)); |
|
139 | + return $this->add_view($view_id, $atts); |
|
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $this->views[ $view_id ] ) ) { |
|
143 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) ); |
|
142 | + if (empty($this->views[$view_id])) { |
|
143 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id)); |
|
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | |
147 | - return $this->views[ $view_id ]; |
|
147 | + return $this->views[$view_id]; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @return bool True if the post exists; otherwise, false. |
157 | 157 | * @since 1.0.0 |
158 | 158 | */ |
159 | - function view_exists( $view_id ) { |
|
160 | - return is_string( get_post_status( $view_id ) ); |
|
159 | + function view_exists($view_id) { |
|
160 | + return is_string(get_post_status($view_id)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -168,56 +168,56 @@ discard block |
||
168 | 168 | * @param array|string $atts Combine other attributes (eg. from shortcode) with the view settings (optional) |
169 | 169 | * @return type |
170 | 170 | */ |
171 | - function add_view( $view_id, $atts = NULL ) { |
|
171 | + function add_view($view_id, $atts = NULL) { |
|
172 | 172 | |
173 | 173 | // Handle array of IDs |
174 | - if( is_array( $view_id ) ) { |
|
175 | - foreach( $view_id as $id ) { |
|
174 | + if (is_array($view_id)) { |
|
175 | + foreach ($view_id as $id) { |
|
176 | 176 | |
177 | - $this->add_view( $id, $atts ); |
|
177 | + $this->add_view($id, $atts); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | return $this->views; |
181 | 181 | } |
182 | 182 | |
183 | 183 | // The view has been set already; returning stored view. |
184 | - if ( !empty( $this->views[ $view_id ] ) ) { |
|
185 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) ); |
|
186 | - return $this->views[ $view_id ]; |
|
184 | + if (!empty($this->views[$view_id])) { |
|
185 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id)); |
|
186 | + return $this->views[$view_id]; |
|
187 | 187 | } |
188 | 188 | |
189 | - if( ! $this->view_exists( $view_id ) ) { |
|
190 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) ); |
|
189 | + if (!$this->view_exists($view_id)) { |
|
190 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id)); |
|
191 | 191 | return false; |
192 | 192 | } |
193 | 193 | |
194 | - $form_id = gravityview_get_form_id( $view_id ); |
|
194 | + $form_id = gravityview_get_form_id($view_id); |
|
195 | 195 | |
196 | - if( empty( $form_id ) ) { |
|
196 | + if (empty($form_id)) { |
|
197 | 197 | |
198 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) ); |
|
198 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id)); |
|
199 | 199 | |
200 | 200 | return false; |
201 | 201 | } |
202 | 202 | |
203 | 203 | // Get the settings for the View ID |
204 | - $view_settings = gravityview_get_template_settings( $view_id ); |
|
204 | + $view_settings = gravityview_get_template_settings($view_id); |
|
205 | 205 | |
206 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings ); |
|
206 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings); |
|
207 | 207 | |
208 | 208 | // Merge the view settings with the defaults |
209 | - $view_defaults = wp_parse_args( $view_settings, self::get_default_args() ); |
|
209 | + $view_defaults = wp_parse_args($view_settings, self::get_default_args()); |
|
210 | 210 | |
211 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
211 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults); |
|
212 | 212 | |
213 | - if( ! empty( $atts ) && is_array( $atts ) ) { |
|
213 | + if (!empty($atts) && is_array($atts)) { |
|
214 | 214 | |
215 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
215 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts); |
|
216 | 216 | |
217 | 217 | // Get the settings from the shortcode and merge them with defaults. |
218 | - $atts = shortcode_atts( $view_defaults, $atts ); |
|
218 | + $atts = shortcode_atts($view_defaults, $atts); |
|
219 | 219 | |
220 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
220 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts); |
|
221 | 221 | |
222 | 222 | } else { |
223 | 223 | |
@@ -226,24 +226,24 @@ discard block |
||
226 | 226 | |
227 | 227 | } |
228 | 228 | |
229 | - unset( $atts['id'], $view_defaults, $view_settings ); |
|
229 | + unset($atts['id'], $view_defaults, $view_settings); |
|
230 | 230 | |
231 | 231 | $data = array( |
232 | 232 | 'id' => $view_id, |
233 | 233 | 'view_id' => $view_id, |
234 | 234 | 'form_id' => $form_id, |
235 | - 'template_id' => gravityview_get_template_id( $view_id ), |
|
235 | + 'template_id' => gravityview_get_template_id($view_id), |
|
236 | 236 | 'atts' => $atts, |
237 | - 'fields' => $this->get_fields( $view_id ), |
|
238 | - 'widgets' => get_post_meta( $view_id, '_gravityview_directory_widgets', true ), |
|
239 | - 'form' => gravityview_get_form( $form_id ), |
|
237 | + 'fields' => $this->get_fields($view_id), |
|
238 | + 'widgets' => get_post_meta($view_id, '_gravityview_directory_widgets', true), |
|
239 | + 'form' => gravityview_get_form($form_id), |
|
240 | 240 | ); |
241 | 241 | |
242 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data ); |
|
242 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data); |
|
243 | 243 | |
244 | - $this->views[ $view_id ] = $data; |
|
244 | + $this->views[$view_id] = $data; |
|
245 | 245 | |
246 | - return $this->views[ $view_id ]; |
|
246 | + return $this->views[$view_id]; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | * @param int $view_id View ID |
254 | 254 | * @return array Array of fields as passed by `gravityview_get_directory_fields()` |
255 | 255 | */ |
256 | - function get_fields( $view_id ) { |
|
256 | + function get_fields($view_id) { |
|
257 | 257 | |
258 | - $dir_fields = gravityview_get_directory_fields( $view_id ); |
|
259 | - do_action( 'gravityview_log_debug', '[render_view] Fields: ', $dir_fields ); |
|
258 | + $dir_fields = gravityview_get_directory_fields($view_id); |
|
259 | + do_action('gravityview_log_debug', '[render_view] Fields: ', $dir_fields); |
|
260 | 260 | |
261 | 261 | // remove fields according to visitor visibility permissions (if logged-in) |
262 | - $dir_fields = $this->filter_fields( $dir_fields ); |
|
263 | - do_action( 'gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields ); |
|
262 | + $dir_fields = $this->filter_fields($dir_fields); |
|
263 | + do_action('gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields); |
|
264 | 264 | |
265 | 265 | return $dir_fields; |
266 | 266 | } |
@@ -272,18 +272,18 @@ discard block |
||
272 | 272 | * @param array $dir_fields |
273 | 273 | * @return array |
274 | 274 | */ |
275 | - private function filter_fields( $dir_fields ) { |
|
275 | + private function filter_fields($dir_fields) { |
|
276 | 276 | |
277 | - if( empty( $dir_fields ) || !is_array( $dir_fields ) ) { |
|
277 | + if (empty($dir_fields) || !is_array($dir_fields)) { |
|
278 | 278 | return $dir_fields; |
279 | 279 | } |
280 | 280 | |
281 | - foreach( $dir_fields as $area => $fields ) { |
|
281 | + foreach ($dir_fields as $area => $fields) { |
|
282 | 282 | |
283 | - foreach( (array)$fields as $uniqid => $properties ) { |
|
283 | + foreach ((array)$fields as $uniqid => $properties) { |
|
284 | 284 | |
285 | - if( $this->hide_field_check_conditions( $properties ) ) { |
|
286 | - unset( $dir_fields[ $area ][ $uniqid ] ); |
|
285 | + if ($this->hide_field_check_conditions($properties)) { |
|
286 | + unset($dir_fields[$area][$uniqid]); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | } |
@@ -301,31 +301,31 @@ discard block |
||
301 | 301 | * @param array $properties |
302 | 302 | * @return void|boolean (field should be hidden) or false (field should be presented) |
303 | 303 | */ |
304 | - private function hide_field_check_conditions( $properties ) { |
|
304 | + private function hide_field_check_conditions($properties) { |
|
305 | 305 | |
306 | 306 | // logged-in visibility |
307 | - if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) { |
|
307 | + if (!empty($properties['only_loggedin']) && !GVCommon::has_cap($properties['only_loggedin_cap'])) { |
|
308 | 308 | return true; |
309 | 309 | } |
310 | 310 | |
311 | 311 | return false; |
312 | 312 | } |
313 | 313 | |
314 | - function get_id_from_atts( $atts ) { |
|
314 | + function get_id_from_atts($atts) { |
|
315 | 315 | |
316 | - $atts = is_array( $atts ) ? $atts : shortcode_parse_atts( $atts ); |
|
316 | + $atts = is_array($atts) ? $atts : shortcode_parse_atts($atts); |
|
317 | 317 | |
318 | 318 | // Get the settings from the shortcode and merge them with defaults. |
319 | - $atts = wp_parse_args( $atts, self::get_default_args() ); |
|
319 | + $atts = wp_parse_args($atts, self::get_default_args()); |
|
320 | 320 | |
321 | - $view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL; |
|
321 | + $view_id = !empty($atts['view_id']) ? (int)$atts['view_id'] : NULL; |
|
322 | 322 | |
323 | - if( empty( $view_id ) && !empty( $atts['id'] ) ) { |
|
323 | + if (empty($view_id) && !empty($atts['id'])) { |
|
324 | 324 | $view_id = (int)$atts['id']; |
325 | 325 | } |
326 | 326 | |
327 | - if( empty( $view_id ) ) { |
|
328 | - do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
327 | + if (empty($view_id)) { |
|
328 | + do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts); |
|
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
@@ -341,50 +341,50 @@ discard block |
||
341 | 341 | * @param string $content $post->post_content content |
342 | 342 | * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, NULL |
343 | 343 | */ |
344 | - function parse_post_content( $content ) { |
|
344 | + function parse_post_content($content) { |
|
345 | 345 | |
346 | 346 | /** |
347 | 347 | * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin |
348 | 348 | * @since 1.6 |
349 | 349 | */ |
350 | - if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) { |
|
350 | + if (!shortcode_exists('gravityview') && class_exists('GravityView_Shortcode')) { |
|
351 | 351 | new GravityView_Shortcode; |
352 | 352 | } |
353 | 353 | |
354 | - $shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' ); |
|
354 | + $shortcodes = gravityview_has_shortcode_r($content, 'gravityview'); |
|
355 | 355 | |
356 | - if( empty( $shortcodes ) ) { |
|
356 | + if (empty($shortcodes)) { |
|
357 | 357 | return NULL; |
358 | 358 | } |
359 | 359 | |
360 | - do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
360 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes); |
|
361 | 361 | |
362 | 362 | $ids = array(); |
363 | 363 | |
364 | 364 | foreach ($shortcodes as $key => $shortcode) { |
365 | 365 | |
366 | - $args = shortcode_parse_atts( $shortcode[3] ); |
|
366 | + $args = shortcode_parse_atts($shortcode[3]); |
|
367 | 367 | |
368 | - if( empty( $args['id'] ) ) { |
|
369 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); |
|
368 | + if (empty($args['id'])) { |
|
369 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID), $shortcode); |
|
370 | 370 | continue; |
371 | 371 | } |
372 | 372 | |
373 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args ); |
|
373 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args); |
|
374 | 374 | |
375 | 375 | // Store the View to the object for later fetching. |
376 | - $this->add_view( $args['id'], $args ); |
|
376 | + $this->add_view($args['id'], $args); |
|
377 | 377 | |
378 | 378 | $ids[] = $args['id']; |
379 | 379 | } |
380 | 380 | |
381 | - if( empty($ids) ) { |
|
381 | + if (empty($ids)) { |
|
382 | 382 | return NULL; |
383 | 383 | } |
384 | 384 | |
385 | 385 | // If it's just one ID, return that. |
386 | 386 | // Otherwise, return array of IDs |
387 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
387 | + return (sizeof($ids) === 1) ? $ids[0] : $ids; |
|
388 | 388 | |
389 | 389 | } |
390 | 390 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * @param int $post_id WP_Post ID |
396 | 396 | * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, or meta not parsed, NULL |
397 | 397 | */ |
398 | - private function parse_post_meta( $post_id ) { |
|
398 | + private function parse_post_meta($post_id) { |
|
399 | 399 | |
400 | 400 | /** |
401 | 401 | * @filter `gravityview/data/parse/meta_keys` Define meta keys to parse to check for GravityView shortcode content |
@@ -403,32 +403,32 @@ discard block |
||
403 | 403 | * @param[in,out] array $meta_keys Array of key values to check. If empty, do not check. Default: empty array |
404 | 404 | * @param[in] int $post_id ID of the post being checked |
405 | 405 | */ |
406 | - $meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id ); |
|
406 | + $meta_keys = (array)apply_filters('gravityview/data/parse/meta_keys', array(), $post_id); |
|
407 | 407 | |
408 | - if( empty( $meta_keys ) ) { |
|
408 | + if (empty($meta_keys)) { |
|
409 | 409 | return NULL; |
410 | 410 | } |
411 | 411 | |
412 | - do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys ); |
|
412 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys); |
|
413 | 413 | |
414 | 414 | $meta_content = ''; |
415 | 415 | |
416 | - foreach( $meta_keys as $key ) { |
|
417 | - $meta = get_post_meta( $post_id, $key , true ); |
|
418 | - if( ! is_string( $meta ) ) { |
|
416 | + foreach ($meta_keys as $key) { |
|
417 | + $meta = get_post_meta($post_id, $key, true); |
|
418 | + if (!is_string($meta)) { |
|
419 | 419 | continue; |
420 | 420 | } |
421 | - $meta_content .= $meta . ' '; |
|
421 | + $meta_content .= $meta.' '; |
|
422 | 422 | } |
423 | 423 | |
424 | - if( empty( $meta_content ) ) { |
|
425 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); |
|
424 | + if (empty($meta_content)) { |
|
425 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id), $meta_keys); |
|
426 | 426 | return NULL; |
427 | 427 | } |
428 | 428 | |
429 | - do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content ); |
|
429 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content); |
|
430 | 430 | |
431 | - return $this->parse_post_content( $meta_content ); |
|
431 | + return $this->parse_post_content($meta_content); |
|
432 | 432 | |
433 | 433 | } |
434 | 434 | |
@@ -444,61 +444,61 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return bool|WP_Error If valid, returns true. If invalid, returns WP_Error containing error message. |
446 | 446 | */ |
447 | - public static function is_valid_embed_id( $post_id = '', $view_id = '', $empty_is_valid = true ) { |
|
447 | + public static function is_valid_embed_id($post_id = '', $view_id = '', $empty_is_valid = true) { |
|
448 | 448 | |
449 | 449 | $message = NULL; |
450 | 450 | |
451 | 451 | // Not invalid if not set! |
452 | - if( empty( $post_id ) || empty( $view_id ) ) { |
|
452 | + if (empty($post_id) || empty($view_id)) { |
|
453 | 453 | |
454 | - if( $empty_is_valid ) { |
|
454 | + if ($empty_is_valid) { |
|
455 | 455 | return true; |
456 | 456 | } |
457 | 457 | |
458 | - $message = esc_html__( 'The ID is required.', 'gravityview' ); |
|
458 | + $message = esc_html__('The ID is required.', 'gravityview'); |
|
459 | 459 | } |
460 | 460 | |
461 | - if( ! $message ) { |
|
462 | - $status = get_post_status( $post_id ); |
|
461 | + if (!$message) { |
|
462 | + $status = get_post_status($post_id); |
|
463 | 463 | |
464 | 464 | // Nothing exists with that post ID. |
465 | - if ( ! is_numeric( $post_id ) ) { |
|
466 | - $message = esc_html__( 'You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview' ); |
|
465 | + if (!is_numeric($post_id)) { |
|
466 | + $message = esc_html__('You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview'); |
|
467 | 467 | |
468 | 468 | // @todo Convert to generic article about Embed IDs |
469 | - $message .= ' ' . gravityview_get_link( 'http://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
469 | + $message .= ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview'), 'target=_blank'); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
473 | - if( ! $message ) { |
|
473 | + if (!$message) { |
|
474 | 474 | |
475 | 475 | // Nothing exists with that post ID. |
476 | - if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) { |
|
477 | - $message = esc_html__( 'There is no post or page with that ID.', 'gravityview' ); |
|
476 | + if (empty($status) || in_array($status, array('revision', 'attachment'))) { |
|
477 | + $message = esc_html__('There is no post or page with that ID.', 'gravityview'); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | } |
481 | 481 | |
482 | - if( ! $message ) { |
|
483 | - $view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); |
|
482 | + if (!$message) { |
|
483 | + $view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id($post_id); |
|
484 | 484 | |
485 | 485 | // The post or page specified does not contain the shortcode. |
486 | - if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { |
|
487 | - $message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' ); |
|
486 | + if (false === in_array($view_id, (array)$view_ids_in_post)) { |
|
487 | + $message = sprintf(esc_html__('The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview'), '<br /><code>[gravityview id="'.intval($view_id).'"]</code>'); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | - if( ! $message ) { |
|
491 | + if (!$message) { |
|
492 | 492 | |
493 | 493 | // It's a View |
494 | - if( 'gravityview' === get_post_type( $post_id ) ) { |
|
495 | - $message = esc_html__( 'The ID is already a View.', 'gravityview' );; |
|
494 | + if ('gravityview' === get_post_type($post_id)) { |
|
495 | + $message = esc_html__('The ID is already a View.', 'gravityview'); ; |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | } |
499 | 499 | |
500 | - if( $message ) { |
|
501 | - return new WP_Error( 'invalid_embed_id', $message ); |
|
500 | + if ($message) { |
|
501 | + return new WP_Error('invalid_embed_id', $message); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | return true; |
@@ -510,13 +510,13 @@ discard block |
||
510 | 510 | * @param boolean $with_details Include details |
511 | 511 | * @return mixed|array If using $with_details, return array. Otherwise, mixed. |
512 | 512 | */ |
513 | - public static function get_default_arg( $key, $with_details = false ) { |
|
513 | + public static function get_default_arg($key, $with_details = false) { |
|
514 | 514 | |
515 | - $args = self::get_default_args( $with_details ); |
|
515 | + $args = self::get_default_args($with_details); |
|
516 | 516 | |
517 | - if( !isset( $args[ $key ] ) ) { return NULL; } |
|
517 | + if (!isset($args[$key])) { return NULL; } |
|
518 | 518 | |
519 | - return $args[ $key ]; |
|
519 | + return $args[$key]; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -535,13 +535,13 @@ discard block |
||
535 | 535 | * @param[out] array $options Array of values to use when generating select, multiselect, radio, or checkboxes fields |
536 | 536 | * @param[out] boolean $full_width True: Display the input and label together when rendering. False: Display label and input in separate columns when rendering. |
537 | 537 | */ |
538 | - public static function get_default_args( $with_details = false, $group = NULL ) { |
|
538 | + public static function get_default_args($with_details = false, $group = NULL) { |
|
539 | 539 | |
540 | 540 | /** |
541 | 541 | * @filter `gravityview_default_args` Modify the default settings for new Views |
542 | 542 | * @param[in,out] array $default_args Array of default args. |
543 | 543 | */ |
544 | - $default_settings = apply_filters( 'gravityview_default_args', array( |
|
544 | + $default_settings = apply_filters('gravityview_default_args', array( |
|
545 | 545 | 'id' => array( |
546 | 546 | 'label' => __('View ID', 'gravityview'), |
547 | 547 | 'type' => 'number', |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | 'show_in_shortcode' => true, |
560 | 560 | ), |
561 | 561 | 'lightbox' => array( |
562 | - 'label' => __( 'Enable lightbox for images', 'gravityview' ), |
|
562 | + 'label' => __('Enable lightbox for images', 'gravityview'), |
|
563 | 563 | 'type' => 'checkbox', |
564 | 564 | 'group' => 'default', |
565 | 565 | 'value' => 1, |
@@ -567,29 +567,29 @@ discard block |
||
567 | 567 | 'show_in_shortcode' => true, |
568 | 568 | ), |
569 | 569 | 'show_only_approved' => array( |
570 | - 'label' => __( 'Show only approved entries', 'gravityview' ), |
|
570 | + 'label' => __('Show only approved entries', 'gravityview'), |
|
571 | 571 | 'type' => 'checkbox', |
572 | 572 | 'group' => 'default', |
573 | 573 | 'value' => 0, |
574 | 574 | 'show_in_shortcode' => false, |
575 | 575 | ), |
576 | 576 | 'hide_until_searched' => array( |
577 | - 'label' => __( 'Hide View data until search is performed', 'gravityview' ), |
|
577 | + 'label' => __('Hide View data until search is performed', 'gravityview'), |
|
578 | 578 | 'type' => 'checkbox', |
579 | 579 | 'group' => 'default', |
580 | - 'tooltip' => __( 'When enabled it will only show any View entries after a search is performed.', 'gravityview' ), |
|
580 | + 'tooltip' => __('When enabled it will only show any View entries after a search is performed.', 'gravityview'), |
|
581 | 581 | 'value' => 0, |
582 | 582 | 'show_in_shortcode' => false, |
583 | 583 | ), |
584 | 584 | 'hide_empty' => array( |
585 | - 'label' => __( 'Hide empty fields', 'gravityview' ), |
|
585 | + 'label' => __('Hide empty fields', 'gravityview'), |
|
586 | 586 | 'group' => 'default', |
587 | 587 | 'type' => 'checkbox', |
588 | 588 | 'value' => 1, |
589 | 589 | 'show_in_shortcode' => false, |
590 | 590 | ), |
591 | 591 | 'user_edit' => array( |
592 | - 'label' => __( 'Allow User Edit', 'gravityview' ), |
|
592 | + 'label' => __('Allow User Edit', 'gravityview'), |
|
593 | 593 | 'group' => 'default', |
594 | 594 | 'desc' => __('Allow logged-in users to edit entries they created.', 'gravityview'), |
595 | 595 | 'value' => 0, |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | 'show_in_shortcode' => true, |
599 | 599 | ), |
600 | 600 | 'user_delete' => array( |
601 | - 'label' => __( 'Allow User Delete', 'gravityview' ), |
|
601 | + 'label' => __('Allow User Delete', 'gravityview'), |
|
602 | 602 | 'group' => 'default', |
603 | 603 | 'desc' => __('Allow logged-in users to delete entries they created.', 'gravityview'), |
604 | 604 | 'value' => 0, |
@@ -612,8 +612,8 @@ discard block |
||
612 | 612 | 'value' => '', |
613 | 613 | 'group' => 'sort', |
614 | 614 | 'options' => array( |
615 | - '' => __( 'Default', 'gravityview'), |
|
616 | - 'date_created' => __( 'Date Created', 'gravityview'), |
|
615 | + '' => __('Default', 'gravityview'), |
|
616 | + 'date_created' => __('Date Created', 'gravityview'), |
|
617 | 617 | ), |
618 | 618 | 'show_in_shortcode' => true, |
619 | 619 | ), |
@@ -630,19 +630,19 @@ discard block |
||
630 | 630 | 'show_in_shortcode' => true, |
631 | 631 | ), |
632 | 632 | 'sort_columns' => array( |
633 | - 'label' => __( 'Enable sorting by column', 'gravityview' ), |
|
634 | - 'left_label' => __( 'Column Sorting', 'gravityview' ), |
|
633 | + 'label' => __('Enable sorting by column', 'gravityview'), |
|
634 | + 'left_label' => __('Column Sorting', 'gravityview'), |
|
635 | 635 | 'type' => 'checkbox', |
636 | 636 | 'value' => false, |
637 | 637 | 'group' => 'sort', |
638 | 638 | 'tooltip' => NULL, |
639 | 639 | 'show_in_shortcode' => true, |
640 | - 'show_in_template' => array( 'default_table' ), |
|
640 | + 'show_in_template' => array('default_table'), |
|
641 | 641 | ), |
642 | 642 | 'start_date' => array( |
643 | 643 | 'label' => __('Filter by Start Date', 'gravityview'), |
644 | 644 | 'class' => 'gv-datepicker', |
645 | - 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
645 | + 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview'), |
|
646 | 646 | 'type' => 'text', |
647 | 647 | 'value' => '', |
648 | 648 | 'group' => 'filter', |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | 'end_date' => array( |
652 | 652 | 'label' => __('Filter by End Date', 'gravityview'), |
653 | 653 | 'class' => 'gv-datepicker', |
654 | - 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
654 | + 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview'), |
|
655 | 655 | 'type' => 'text', |
656 | 656 | 'value' => '', |
657 | 657 | 'group' => 'filter', |
@@ -711,12 +711,12 @@ discard block |
||
711 | 711 | )); |
712 | 712 | |
713 | 713 | // By default, we only want the key => value pairing, not the whole array. |
714 | - if( empty( $with_details ) ) { |
|
714 | + if (empty($with_details)) { |
|
715 | 715 | |
716 | 716 | $defaults = array(); |
717 | 717 | |
718 | - foreach( $default_settings as $key => $value ) { |
|
719 | - $defaults[ $key ] = $value['value']; |
|
718 | + foreach ($default_settings as $key => $value) { |
|
719 | + $defaults[$key] = $value['value']; |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | return $defaults; |
@@ -729,9 +729,9 @@ discard block |
||
729 | 729 | |
730 | 730 | // If the $group argument is set for the method, |
731 | 731 | // ignore any settings that aren't in that group. |
732 | - if( !empty( $group ) && is_string( $group ) ) { |
|
733 | - if( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
734 | - unset( $default_settings[ $key ] ); |
|
732 | + if (!empty($group) && is_string($group)) { |
|
733 | + if (empty($value['group']) || $value['group'] !== $group) { |
|
734 | + unset($default_settings[$key]); |
|
735 | 735 | } |
736 | 736 | } |
737 | 737 |
@@ -113,6 +113,9 @@ |
||
113 | 113 | return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
114 | 114 | } |
115 | 115 | |
116 | + /** |
|
117 | + * @return GravityView_View_Data |
|
118 | + */ |
|
116 | 119 | public static function getInstance( $passed_post = NULL ) { |
117 | 120 | |
118 | 121 | if( empty( self::$instance ) ) { |
@@ -173,8 +173,7 @@ |
||
173 | 173 | if( !is_null( $notice['data'] ) ) { |
174 | 174 | $output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview' ).'</em>'; |
175 | 175 | } |
176 | - } |
|
177 | - else { |
|
176 | + } else { |
|
178 | 177 | $output .= sprintf( '<pre>%s</pre>', print_r($this->esc_html_recursive( $notice['data'] ), true) ); |
179 | 178 | } |
180 | 179 |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | function init() { |
22 | 22 | |
23 | 23 | $icon = is_admin() ? '<i class="icon gv-icon-astronaut-head"></i> ' : NULL; |
24 | - $this->title( $icon . __('GravityView', 'gravityview') ); |
|
24 | + $this->title($icon.__('GravityView', 'gravityview')); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | function get_warnings() { |
28 | 28 | |
29 | - if( is_null( $this->warnings ) ) { |
|
29 | + if (is_null($this->warnings)) { |
|
30 | 30 | $this->warnings = GravityView_Logging::get_errors(); |
31 | 31 | } |
32 | 32 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | function get_notices() { |
37 | 37 | |
38 | - if( is_null( $this->notices ) ) { |
|
38 | + if (is_null($this->notices)) { |
|
39 | 39 | $this->notices = GravityView_Logging::get_notices(); |
40 | 40 | } |
41 | 41 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * @param boolean $visible {@internal Leave here for compatibility with the Debug_Bar_Panel parent class} |
52 | 52 | * @return void |
53 | 53 | */ |
54 | - function set_visible( $visible = false ) { |
|
55 | - $this->_visible = ( count( $this->get_notices() ) || count( $this->get_warnings() ) ); |
|
54 | + function set_visible($visible = false) { |
|
55 | + $this->_visible = (count($this->get_notices()) || count($this->get_warnings())); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -84,42 +84,42 @@ discard block |
||
84 | 84 | </style> |
85 | 85 | <div id='debug-bar-gravityview'>"; |
86 | 86 | |
87 | - $output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="alignright" alt="" width="100" height="132" />'; |
|
87 | + $output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE).'" class="alignright" alt="" width="100" height="132" />'; |
|
88 | 88 | |
89 | 89 | |
90 | 90 | $warnings = $this->get_warnings(); |
91 | 91 | $notices = $this->get_notices(); |
92 | 92 | |
93 | - if(count($warnings)) { |
|
93 | + if (count($warnings)) { |
|
94 | 94 | $output .= '<h3><span>'.__('Warnings', 'gravityview').'</span></h3>'; |
95 | 95 | $output .= '<ol>'; |
96 | - foreach ( $warnings as $key => $notice) { |
|
97 | - if(empty($notice['message'])) { continue; } |
|
98 | - $output .= '<li><a href="#'.sanitize_html_class( 'gv-warning-' . $key ).'">'.strip_tags($notice['message']).'</a></li>'; |
|
96 | + foreach ($warnings as $key => $notice) { |
|
97 | + if (empty($notice['message'])) { continue; } |
|
98 | + $output .= '<li><a href="#'.sanitize_html_class('gv-warning-'.$key).'">'.strip_tags($notice['message']).'</a></li>'; |
|
99 | 99 | } |
100 | 100 | $output .= '</ol><hr />'; |
101 | 101 | } |
102 | - if(count($notices)) { |
|
102 | + if (count($notices)) { |
|
103 | 103 | $output .= '<h3><span>'.__('Logs', 'gravityview').'</span></h3>'; |
104 | 104 | $output .= '<ol>'; |
105 | - foreach ( $notices as $key => $notice) { |
|
106 | - if(empty($notice['message'])) { continue; } |
|
107 | - $output .= '<li><a href="#'.sanitize_html_class( 'gv-notice-' . $key ).'">'.strip_tags($notice['message']).'</a></li>'; |
|
105 | + foreach ($notices as $key => $notice) { |
|
106 | + if (empty($notice['message'])) { continue; } |
|
107 | + $output .= '<li><a href="#'.sanitize_html_class('gv-notice-'.$key).'">'.strip_tags($notice['message']).'</a></li>'; |
|
108 | 108 | } |
109 | 109 | $output .= '</ol><hr />'; |
110 | 110 | } |
111 | 111 | |
112 | - if ( count( $warnings ) ) { |
|
112 | + if (count($warnings)) { |
|
113 | 113 | $output .= '<h3>Warnings</h3>'; |
114 | 114 | $output .= '<ol class="debug-bar-php-list">'; |
115 | - foreach ( $warnings as $key => $notice) { $output .= $this->render_item( $notice, 'gv-warning-' . $key ); } |
|
115 | + foreach ($warnings as $key => $notice) { $output .= $this->render_item($notice, 'gv-warning-'.$key); } |
|
116 | 116 | $output .= '</ol>'; |
117 | 117 | } |
118 | 118 | |
119 | - if ( count( $notices ) ) { |
|
119 | + if (count($notices)) { |
|
120 | 120 | $output .= '<h3>Notices</h3>'; |
121 | 121 | $output .= '<ol class="debug-bar-php-list">'; |
122 | - foreach ( $notices as $key => $notice) { $output .= $this->render_item( $notice, 'gv-notice-' . $key ); } |
|
122 | + foreach ($notices as $key => $notice) { $output .= $this->render_item($notice, 'gv-notice-'.$key); } |
|
123 | 123 | $output .= '</ol>'; |
124 | 124 | } |
125 | 125 | |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | * @return string Escaped HTML |
135 | 135 | */ |
136 | 136 | function esc_html_recursive($item) { |
137 | - if(is_object($item)) { |
|
138 | - foreach($item as $key => $value) { |
|
137 | + if (is_object($item)) { |
|
138 | + foreach ($item as $key => $value) { |
|
139 | 139 | $item->{$key} = $this->esc_html_recursive($value); |
140 | 140 | } |
141 | - } else if(is_array($item)) { |
|
142 | - foreach($item as $key => $value) { |
|
141 | + } else if (is_array($item)) { |
|
142 | + foreach ($item as $key => $value) { |
|
143 | 143 | $item[$key] = $this->esc_html_recursive($value); |
144 | 144 | } |
145 | 145 | } else { |
@@ -155,31 +155,31 @@ discard block |
||
155 | 155 | * @param string $anchor The anchor ID for the item |
156 | 156 | * @return string HTML output |
157 | 157 | */ |
158 | - function render_item( $notice, $anchor = '' ) { |
|
158 | + function render_item($notice, $anchor = '') { |
|
159 | 159 | |
160 | 160 | $output = ''; |
161 | 161 | |
162 | - if(!empty($notice['message'])) { |
|
163 | - $output .= '<a id="'.sanitize_html_class( $anchor ).'"></a>'; |
|
162 | + if (!empty($notice['message'])) { |
|
163 | + $output .= '<a id="'.sanitize_html_class($anchor).'"></a>'; |
|
164 | 164 | $output .= "<li class='debug-bar-php-notice'>"; |
165 | 165 | } |
166 | 166 | |
167 | 167 | $output .= '<div class="clear"></div>'; |
168 | 168 | |
169 | 169 | // Title |
170 | - $output .= '<div class="gravityview-debug-bar-title">'.esc_attr( $notice['message'] ).'</div>'; |
|
170 | + $output .= '<div class="gravityview-debug-bar-title">'.esc_attr($notice['message']).'</div>'; |
|
171 | 171 | |
172 | 172 | // Debugging Output |
173 | - if( empty( $notice['data'] ) ) { |
|
174 | - if( !is_null( $notice['data'] ) ) { |
|
175 | - $output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview' ).'</em>'; |
|
173 | + if (empty($notice['data'])) { |
|
174 | + if (!is_null($notice['data'])) { |
|
175 | + $output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview').'</em>'; |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | else { |
179 | - $output .= sprintf( '<pre>%s</pre>', print_r($this->esc_html_recursive( $notice['data'] ), true) ); |
|
179 | + $output .= sprintf('<pre>%s</pre>', print_r($this->esc_html_recursive($notice['data']), true)); |
|
180 | 180 | } |
181 | 181 | |
182 | - if(!empty($notice['message'])) { |
|
182 | + if (!empty($notice['message'])) { |
|
183 | 183 | $output .= '</li>'; |
184 | 184 | } |
185 | 185 |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * @since 1.13 |
24 | 24 | */ |
25 | 25 | private function add_hooks() { |
26 | - add_action( 'add_admin_bar_menus', array( $this, 'remove_links' ), 80 ); |
|
27 | - add_action( 'admin_bar_menu', array( $this, 'add_links' ), 85 ); |
|
26 | + add_action('add_admin_bar_menus', array($this, 'remove_links'), 80); |
|
27 | + add_action('admin_bar_menu', array($this, 'add_links'), 85); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | |
56 | 56 | $entry_id = $this->gravityview_view->getSingleEntry(); |
57 | 57 | |
58 | - if ( $entry_id && GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ), $entry_id ) ) { |
|
58 | + if ($entry_id && GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_entries'), $entry_id)) { |
|
59 | 59 | |
60 | 60 | $entry = $this->gravityview_view->getEntry(); |
61 | 61 | |
62 | - $wp_admin_bar->add_menu( array( |
|
62 | + $wp_admin_bar->add_menu(array( |
|
63 | 63 | 'id' => 'edit-entry', |
64 | - 'title' => __( 'Edit Entry', 'gravityview' ), |
|
65 | - 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry['form_id'], $entry['id'] ) ) ), |
|
66 | - ) ); |
|
64 | + 'title' => __('Edit Entry', 'gravityview'), |
|
65 | + 'href' => esc_url_raw(admin_url(sprintf('admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry['form_id'], $entry['id']))), |
|
66 | + )); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** @var WP_Admin_Bar $wp_admin_bar */ |
79 | 79 | global $wp_admin_bar; |
80 | 80 | |
81 | - if( GVCommon::has_cap('edit_gravityviews') ) { |
|
81 | + if (GVCommon::has_cap('edit_gravityviews')) { |
|
82 | 82 | |
83 | 83 | $view_data = GravityView_View_Data::getInstance(); |
84 | 84 | |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | |
87 | 87 | // If there is a View embed, shor Edit View link. |
88 | 88 | // todo: Support multiple View embeds with a drop-down menu |
89 | - if ( ! $this->gravityview_view->isGravityviewPostType() && ! empty( $views ) && ! $view_data->has_multiple_views() ) { |
|
90 | - $view = reset( $views ); |
|
89 | + if (!$this->gravityview_view->isGravityviewPostType() && !empty($views) && !$view_data->has_multiple_views()) { |
|
90 | + $view = reset($views); |
|
91 | 91 | |
92 | - if( GVCommon::has_cap( 'edit_gravityview', $view['id'] ) ) { |
|
93 | - $wp_admin_bar->add_menu( array( |
|
92 | + if (GVCommon::has_cap('edit_gravityview', $view['id'])) { |
|
93 | + $wp_admin_bar->add_menu(array( |
|
94 | 94 | 'id' => 'edit-view', |
95 | - 'title' => __( 'Edit View', 'gravityview' ), |
|
96 | - 'href' => esc_url_raw( admin_url( sprintf( 'post.php?post=%d&action=edit', $view['id'] ) ) ), |
|
97 | - ) ); |
|
95 | + 'title' => __('Edit View', 'gravityview'), |
|
96 | + 'href' => esc_url_raw(admin_url(sprintf('post.php?post=%d&action=edit', $view['id']))), |
|
97 | + )); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | } |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | function remove_links() { |
109 | 109 | |
110 | 110 | // If we're on the single entry page, we don't want to cause confusion. |
111 | - if ( is_admin() || ( $this->gravityview_view->getSingleEntry() && ! $this->gravityview_view->isGravityviewPostType() ) ) { |
|
112 | - remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 ); |
|
111 | + if (is_admin() || ($this->gravityview_view->getSingleEntry() && !$this->gravityview_view->isGravityviewPostType())) { |
|
112 | + remove_action('admin_bar_menu', 'wp_admin_bar_edit_menu', 80); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * When the plugin is activated, flush dismissed notices |
16 | 16 | * @since 1.15.1 |
17 | 17 | */ |
18 | -register_activation_hook( GRAVITYVIEW_FILE, array( 'GravityView_Admin_Notices', 'flush_dismissed_notices' ) ); |
|
18 | +register_activation_hook(GRAVITYVIEW_FILE, array('GravityView_Admin_Notices', 'flush_dismissed_notices')); |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Handle displaying and storing of admin notices for GravityView |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | function add_hooks() { |
36 | - add_action( 'network_admin_notices', array( $this, 'dismiss_notice' ), 50 ); |
|
37 | - add_action( 'admin_notices', array( $this, 'dismiss_notice' ), 50 ); |
|
38 | - add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 ); |
|
39 | - add_action( 'network_admin_notices', array( $this, 'admin_notice' ), 100 ); |
|
36 | + add_action('network_admin_notices', array($this, 'dismiss_notice'), 50); |
|
37 | + add_action('admin_notices', array($this, 'dismiss_notice'), 50); |
|
38 | + add_action('admin_notices', array($this, 'admin_notice'), 100); |
|
39 | + add_action('network_admin_notices', array($this, 'admin_notice'), 100); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return void |
47 | 47 | */ |
48 | 48 | static public function flush_dismissed_notices() { |
49 | - delete_transient( 'gravityview_dismissed_notices' ); |
|
49 | + delete_transient('gravityview_dismissed_notices'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -57,26 +57,26 @@ discard block |
||
57 | 57 | public function dismiss_notice() { |
58 | 58 | |
59 | 59 | // No dismiss sent |
60 | - if( empty( $_GET['gv-dismiss'] ) ) { |
|
60 | + if (empty($_GET['gv-dismiss'])) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Invalid nonce |
65 | - if( !wp_verify_nonce( $_GET['gv-dismiss'], 'dismiss' ) ) { |
|
65 | + if (!wp_verify_nonce($_GET['gv-dismiss'], 'dismiss')) { |
|
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | - $notice_id = esc_attr( $_GET['notice'] ); |
|
69 | + $notice_id = esc_attr($_GET['notice']); |
|
70 | 70 | |
71 | 71 | //don't display a message if use has dismissed the message for this version |
72 | - $dismissed_notices = (array)get_transient( 'gravityview_dismissed_notices' ); |
|
72 | + $dismissed_notices = (array)get_transient('gravityview_dismissed_notices'); |
|
73 | 73 | |
74 | 74 | $dismissed_notices[] = $notice_id; |
75 | 75 | |
76 | - $dismissed_notices = array_unique( $dismissed_notices ); |
|
76 | + $dismissed_notices = array_unique($dismissed_notices); |
|
77 | 77 | |
78 | 78 | // Remind users every 16 weeks |
79 | - set_transient( 'gravityview_dismissed_notices', $dismissed_notices, WEEK_IN_SECONDS * 16 ); |
|
79 | + set_transient('gravityview_dismissed_notices', $dismissed_notices, WEEK_IN_SECONDS * 16); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
@@ -91,15 +91,15 @@ discard block |
||
91 | 91 | * @param string $notice Notice array, set using `add_notice()`. |
92 | 92 | * @return boolean True: show notice; False: hide notice |
93 | 93 | */ |
94 | - private function is_notice_dismissed( $notice ) { |
|
94 | + private function is_notice_dismissed($notice) { |
|
95 | 95 | |
96 | 96 | // There are no dismissed notices. |
97 | - if( empty( self::$dismissed_notices ) ) { |
|
97 | + if (empty(self::$dismissed_notices)) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | |
101 | 101 | // Has the |
102 | - $is_dismissed = !empty( $notice['dismiss'] ) && in_array( $notice['dismiss'], self::$dismissed_notices ); |
|
102 | + $is_dismissed = !empty($notice['dismiss']) && in_array($notice['dismiss'], self::$dismissed_notices); |
|
103 | 103 | |
104 | 104 | return $is_dismissed ? true : false; |
105 | 105 | } |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | */ |
125 | 125 | private function check_show_multisite_notices() { |
126 | 126 | |
127 | - if( ! is_multisite() ) { |
|
127 | + if (!is_multisite()) { |
|
128 | 128 | return true; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // It's network activated but the user can't manage network plugins; they can't do anything about it. |
132 | - if( GravityView_Plugin::is_network_activated() && ! is_main_site() ) { |
|
132 | + if (GravityView_Plugin::is_network_activated() && !is_main_site()) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // or they don't have admin capabilities |
137 | - if( ! is_super_admin() ) { |
|
137 | + if (!is_super_admin()) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
@@ -155,53 +155,53 @@ discard block |
||
155 | 155 | * @filter `gravityview/admin/notices` Modify the notices displayed in the admin |
156 | 156 | * @since 1.12 |
157 | 157 | */ |
158 | - $notices = apply_filters( 'gravityview/admin/notices', self::$admin_notices ); |
|
158 | + $notices = apply_filters('gravityview/admin/notices', self::$admin_notices); |
|
159 | 159 | |
160 | - if( empty( $notices ) || ! $this->check_show_multisite_notices() ) { |
|
160 | + if (empty($notices) || !$this->check_show_multisite_notices()) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | |
164 | 164 | //don't display a message if use has dismissed the message for this version |
165 | 165 | // TODO: Use get_user_meta instead of get_transient |
166 | - self::$dismissed_notices = isset( $_GET['show-dismissed-notices'] ) ? array() : (array)get_transient( 'gravityview_dismissed_notices' ); |
|
166 | + self::$dismissed_notices = isset($_GET['show-dismissed-notices']) ? array() : (array)get_transient('gravityview_dismissed_notices'); |
|
167 | 167 | |
168 | 168 | $output = ''; |
169 | 169 | |
170 | - foreach( $notices as $notice ) { |
|
170 | + foreach ($notices as $notice) { |
|
171 | 171 | |
172 | 172 | // If the user doesn't have the capability to see the warning |
173 | - if( isset( $notice['cap'] ) && false === GVCommon::has_cap( $notice['cap'] ) ) { |
|
174 | - do_action( 'gravityview_log_debug', 'Notice not shown because user does not have the capability to view it.', $notice ); |
|
173 | + if (isset($notice['cap']) && false === GVCommon::has_cap($notice['cap'])) { |
|
174 | + do_action('gravityview_log_debug', 'Notice not shown because user does not have the capability to view it.', $notice); |
|
175 | 175 | continue; |
176 | 176 | } |
177 | 177 | |
178 | - if( true === $this->is_notice_dismissed( $notice ) ) { |
|
179 | - do_action( 'gravityview_log_debug', 'Notice not shown because the notice has already been dismissed.', $notice ); |
|
178 | + if (true === $this->is_notice_dismissed($notice)) { |
|
179 | + do_action('gravityview_log_debug', 'Notice not shown because the notice has already been dismissed.', $notice); |
|
180 | 180 | continue; |
181 | 181 | } |
182 | 182 | |
183 | - $output .= '<div id="message" style="position:relative" class="notice '. gravityview_sanitize_html_class( $notice['class'] ).'">'; |
|
183 | + $output .= '<div id="message" style="position:relative" class="notice '.gravityview_sanitize_html_class($notice['class']).'">'; |
|
184 | 184 | |
185 | 185 | // Too cute to leave out. |
186 | 186 | $output .= gravityview_get_floaty(); |
187 | 187 | |
188 | - if( !empty( $notice['title'] ) ) { |
|
189 | - $output .= '<h3>'.esc_html( $notice['title'] ) .'</h3>'; |
|
188 | + if (!empty($notice['title'])) { |
|
189 | + $output .= '<h3>'.esc_html($notice['title']).'</h3>'; |
|
190 | 190 | } |
191 | 191 | |
192 | - $message = isset( $notice['message'] ) ? $notice['message'] : ''; |
|
192 | + $message = isset($notice['message']) ? $notice['message'] : ''; |
|
193 | 193 | |
194 | - if( !empty( $notice['dismiss'] ) ) { |
|
194 | + if (!empty($notice['dismiss'])) { |
|
195 | 195 | |
196 | 196 | $dismiss = esc_attr($notice['dismiss']); |
197 | 197 | |
198 | - $url = esc_url( add_query_arg( array( 'gv-dismiss' => wp_create_nonce( 'dismiss' ), 'notice' => $dismiss ) ) ); |
|
198 | + $url = esc_url(add_query_arg(array('gv-dismiss' => wp_create_nonce('dismiss'), 'notice' => $dismiss))); |
|
199 | 199 | |
200 | 200 | $align = is_rtl() ? 'alignleft' : 'alignright'; |
201 | - $message .= '<a href="'.$url.'" data-notice="'.$dismiss.'" class="' . $align . ' button button-link">'.esc_html__('Dismiss', 'gravityview' ).'</a></p>'; |
|
201 | + $message .= '<a href="'.$url.'" data-notice="'.$dismiss.'" class="'.$align.' button button-link">'.esc_html__('Dismiss', 'gravityview').'</a></p>'; |
|
202 | 202 | } |
203 | 203 | |
204 | - $output .= wpautop( $message ); |
|
204 | + $output .= wpautop($message); |
|
205 | 205 | |
206 | 206 | $output .= '<div class="clear"></div>'; |
207 | 207 | $output .= '</div>'; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | echo $output; |
212 | 212 | |
213 | - unset( $output, $align, $message, $notices ); |
|
213 | + unset($output, $align, $message, $notices); |
|
214 | 214 | |
215 | 215 | //reset the notices handler |
216 | 216 | self::$admin_notices = array(); |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | * @param array $notice Array with `class`, `message`, `dismiss` and `cap` keys. The message is not escaped. |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - public static function add_notice( $notice = array() ) { |
|
226 | + public static function add_notice($notice = array()) { |
|
227 | 227 | |
228 | - if( !isset( $notice['message'] ) ) { |
|
229 | - do_action( 'gravityview_log_error', 'GravityView_Admin[add_notice] Notice not set', $notice ); |
|
228 | + if (!isset($notice['message'])) { |
|
229 | + do_action('gravityview_log_error', 'GravityView_Admin[add_notice] Notice not set', $notice); |
|
230 | 230 | return; |
231 | 231 | } |
232 | 232 | |
233 | - $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; |
|
233 | + $notice['class'] = empty($notice['class']) ? 'error' : $notice['class']; |
|
234 | 234 | |
235 | 235 | self::$admin_notices[] = $notice; |
236 | 236 | } |
@@ -5,220 +5,220 @@ |
||
5 | 5 | */ |
6 | 6 | class GravityView_Change_Entry_Creator { |
7 | 7 | |
8 | - function __construct() { |
|
9 | - |
|
10 | - /** |
|
11 | - * @since 1.5.1 |
|
12 | - */ |
|
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
14 | - |
|
15 | - // ONLY ADMIN FROM HERE ON. |
|
16 | - if( !is_admin() ) { return; } |
|
17 | - |
|
18 | - /** |
|
19 | - * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
20 | - * @since 1.7.4 |
|
21 | - * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
22 | - */ |
|
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
24 | - return; |
|
25 | - } |
|
26 | - |
|
27 | - /** |
|
28 | - * Use `init` to fix bbPress warning |
|
29 | - * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
30 | - */ |
|
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
32 | - |
|
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
8 | + function __construct() { |
|
9 | + |
|
10 | + /** |
|
11 | + * @since 1.5.1 |
|
12 | + */ |
|
13 | + add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
14 | + |
|
15 | + // ONLY ADMIN FROM HERE ON. |
|
16 | + if( !is_admin() ) { return; } |
|
17 | + |
|
18 | + /** |
|
19 | + * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
20 | + * @since 1.7.4 |
|
21 | + * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
22 | + */ |
|
23 | + if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
24 | + return; |
|
25 | + } |
|
26 | + |
|
27 | + /** |
|
28 | + * Use `init` to fix bbPress warning |
|
29 | + * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
30 | + */ |
|
31 | + add_action('init', array( $this, 'load'), 100 ); |
|
32 | + |
|
33 | + add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
34 | 34 | |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * When an user is created using the User Registration add-on, assign the entry to them |
|
39 | - * |
|
40 | - * @since 1.5.1 |
|
41 | - * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
42 | - * @param int $user_id WordPress User ID |
|
43 | - * @param array $config User registration feed configuration |
|
44 | - * @param array $entry GF Entry array |
|
45 | - * @param string $password User password |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
37 | + /** |
|
38 | + * When an user is created using the User Registration add-on, assign the entry to them |
|
39 | + * |
|
40 | + * @since 1.5.1 |
|
41 | + * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
42 | + * @param int $user_id WordPress User ID |
|
43 | + * @param array $config User registration feed configuration |
|
44 | + * @param array $entry GF Entry array |
|
45 | + * @param string $password User password |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
49 | 49 | |
50 | - /** |
|
51 | - * Disable assigning the new user to the entry by returning false. |
|
52 | - * @param int $user_id WordPress User ID |
|
53 | - * @param array $config User registration feed configuration |
|
54 | - * @param array $entry GF Entry array |
|
55 | - */ |
|
56 | - $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
57 | - |
|
58 | - // If filter returns false, do not process |
|
59 | - if( empty( $assign_to_lead ) ) { |
|
60 | - return; |
|
61 | - } |
|
50 | + /** |
|
51 | + * Disable assigning the new user to the entry by returning false. |
|
52 | + * @param int $user_id WordPress User ID |
|
53 | + * @param array $config User registration feed configuration |
|
54 | + * @param array $entry GF Entry array |
|
55 | + */ |
|
56 | + $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
57 | + |
|
58 | + // If filter returns false, do not process |
|
59 | + if( empty( $assign_to_lead ) ) { |
|
60 | + return; |
|
61 | + } |
|
62 | 62 | |
63 | - // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
64 | - $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
63 | + // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
64 | + $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
65 | 65 | |
66 | - if( empty( $result ) ) { |
|
67 | - $status = __('Error', 'gravityview'); |
|
68 | - } else { |
|
69 | - $status = __('Success', 'gravityview'); |
|
70 | - } |
|
71 | - |
|
72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
66 | + if( empty( $result ) ) { |
|
67 | + $status = __('Error', 'gravityview'); |
|
68 | + } else { |
|
69 | + $status = __('Success', 'gravityview'); |
|
70 | + } |
|
71 | + |
|
72 | + $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
73 | 73 | |
74 | - do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note ); |
|
74 | + do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note ); |
|
75 | 75 | |
76 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
76 | + GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
77 | 77 | |
78 | - } |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Disable previous functionality; use this one as the canonical. |
|
82 | - * @return void |
|
83 | - */ |
|
84 | - function prevent_conflicts() { |
|
80 | + /** |
|
81 | + * Disable previous functionality; use this one as the canonical. |
|
82 | + * @return void |
|
83 | + */ |
|
84 | + function prevent_conflicts() { |
|
85 | 85 | |
86 | - // Plugin that was provided here: |
|
87 | - // @link https://gravityview.co/support/documentation/201991205/ |
|
88 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10, 2); |
|
89 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10, 2); |
|
86 | + // Plugin that was provided here: |
|
87 | + // @link https://gravityview.co/support/documentation/201991205/ |
|
88 | + remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10, 2); |
|
89 | + remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10, 2); |
|
90 | 90 | |
91 | - // Disable for Gravity Forms Add-ons 3.6.2 and lower |
|
92 | - if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
91 | + // Disable for Gravity Forms Add-ons 3.6.2 and lower |
|
92 | + if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
93 | 93 | |
94 | - $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
|
94 | + $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
|
95 | 95 | |
96 | - // Now, no validation is required in the methods; let's hook in. |
|
97 | - remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
96 | + // Now, no validation is required in the methods; let's hook in. |
|
97 | + remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
98 | 98 | |
99 | - remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10, 2); |
|
99 | + remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10, 2); |
|
100 | 100 | |
101 | - remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10, 2); |
|
102 | - } |
|
101 | + remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10, 2); |
|
102 | + } |
|
103 | 103 | |
104 | - } |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @since 3.6.3 |
|
108 | - * @return void |
|
109 | - */ |
|
110 | - function load() { |
|
106 | + /** |
|
107 | + * @since 3.6.3 |
|
108 | + * @return void |
|
109 | + */ |
|
110 | + function load() { |
|
111 | 111 | |
112 | - // Does GF exist? |
|
113 | - if( !class_exists('GFCommon') ) { |
|
114 | - return; |
|
115 | - } |
|
112 | + // Does GF exist? |
|
113 | + if( !class_exists('GFCommon') ) { |
|
114 | + return; |
|
115 | + } |
|
116 | 116 | |
117 | - // Can the user edit entries? |
|
118 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
119 | - return; |
|
120 | - } |
|
117 | + // Can the user edit entries? |
|
118 | + if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
119 | + return; |
|
120 | + } |
|
121 | 121 | |
122 | - // If screen mode isn't set, then we're in the wrong place. |
|
123 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
124 | - return; |
|
125 | - } |
|
122 | + // If screen mode isn't set, then we're in the wrong place. |
|
123 | + if( empty( $_REQUEST['screen_mode'] ) ) { |
|
124 | + return; |
|
125 | + } |
|
126 | 126 | |
127 | - // Now, no validation is required in the methods; let's hook in. |
|
128 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
127 | + // Now, no validation is required in the methods; let's hook in. |
|
128 | + add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
129 | 129 | |
130 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
130 | + add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
131 | 131 | |
132 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
132 | + add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
133 | 133 | |
134 | - } |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
138 | - * @return void |
|
139 | - */ |
|
140 | - function set_screen_mode() { |
|
136 | + /** |
|
137 | + * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
138 | + * @return void |
|
139 | + */ |
|
140 | + function set_screen_mode() { |
|
141 | 141 | |
142 | - // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
143 | - if( rgget('screen_mode') === 'edit' ) { |
|
144 | - $_POST["screen_mode"] = 'edit'; |
|
145 | - } |
|
142 | + // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
143 | + if( rgget('screen_mode') === 'edit' ) { |
|
144 | + $_POST["screen_mode"] = 'edit'; |
|
145 | + } |
|
146 | 146 | |
147 | - } |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * When the entry creator is changed, add a note to the entry |
|
151 | - * @param array $form GF entry array |
|
152 | - * @param int $entry_id Entry ID |
|
153 | - * @return void |
|
154 | - */ |
|
155 | - function update_entry_creator($form, $entry_id) { |
|
156 | - global $current_user; |
|
149 | + /** |
|
150 | + * When the entry creator is changed, add a note to the entry |
|
151 | + * @param array $form GF entry array |
|
152 | + * @param int $entry_id Entry ID |
|
153 | + * @return void |
|
154 | + */ |
|
155 | + function update_entry_creator($form, $entry_id) { |
|
156 | + global $current_user; |
|
157 | 157 | |
158 | - // Update the entry |
|
159 | - $created_by = absint( rgpost('created_by') ); |
|
158 | + // Update the entry |
|
159 | + $created_by = absint( rgpost('created_by') ); |
|
160 | 160 | |
161 | - RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
161 | + RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
162 | 162 | |
163 | - // If the creator has changed, let's add a note about who it used to be. |
|
164 | - $originally_created_by = rgpost('originally_created_by'); |
|
163 | + // If the creator has changed, let's add a note about who it used to be. |
|
164 | + $originally_created_by = rgpost('originally_created_by'); |
|
165 | 165 | |
166 | - // If there's no owner and there didn't used to be, keep going |
|
167 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
168 | - return; |
|
169 | - } |
|
166 | + // If there's no owner and there didn't used to be, keep going |
|
167 | + if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
168 | + return; |
|
169 | + } |
|
170 | 170 | |
171 | - // If the values have changed |
|
172 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
171 | + // If the values have changed |
|
172 | + if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
173 | 173 | |
174 | - $user_data = get_userdata($current_user->ID); |
|
174 | + $user_data = get_userdata($current_user->ID); |
|
175 | 175 | |
176 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
176 | + $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
177 | 177 | |
178 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
178 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
179 | 179 | |
180 | - if( !empty( $originally_created_by ) ) { |
|
181 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
182 | - $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
183 | - } |
|
180 | + if( !empty( $originally_created_by ) ) { |
|
181 | + $originally_created_by_user_data = get_userdata($originally_created_by); |
|
182 | + $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
183 | + } |
|
184 | 184 | |
185 | - if( !empty( $created_by ) ) { |
|
186 | - $created_by_user_data = get_userdata($created_by); |
|
187 | - $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
188 | - } |
|
185 | + if( !empty( $created_by ) ) { |
|
186 | + $created_by_user_data = get_userdata($created_by); |
|
187 | + $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
188 | + } |
|
189 | 189 | |
190 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
191 | - } |
|
190 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
191 | + } |
|
192 | 192 | |
193 | - } |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * Output the select to change the entry creator |
|
197 | - * @param int $form_id GF Form ID |
|
198 | - * @param array $entry GF entry array |
|
199 | - * @return void |
|
200 | - */ |
|
201 | - function add_select($form_id, $entry ) { |
|
195 | + /** |
|
196 | + * Output the select to change the entry creator |
|
197 | + * @param int $form_id GF Form ID |
|
198 | + * @param array $entry GF entry array |
|
199 | + * @return void |
|
200 | + */ |
|
201 | + function add_select($form_id, $entry ) { |
|
202 | 202 | |
203 | - if( rgpost('screen_mode') !== 'edit' ) { |
|
204 | - return; |
|
205 | - } |
|
203 | + if( rgpost('screen_mode') !== 'edit' ) { |
|
204 | + return; |
|
205 | + } |
|
206 | 206 | |
207 | - $users = GVCommon::get_users( 'change_entry_creator' ); |
|
207 | + $users = GVCommon::get_users( 'change_entry_creator' ); |
|
208 | 208 | |
209 | - $output = '<label for="change_created_by">'; |
|
210 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
211 | - $output .= '</label> |
|
209 | + $output = '<label for="change_created_by">'; |
|
210 | + $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
211 | + $output .= '</label> |
|
212 | 212 | <select name="created_by" id="change_created_by" class="widefat">'; |
213 | - $output .= '<option value=""> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
214 | - foreach($users as $user) { |
|
215 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
216 | - } |
|
217 | - $output .= '</select>'; |
|
218 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
219 | - echo $output; |
|
220 | - |
|
221 | - } |
|
213 | + $output .= '<option value=""> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
214 | + foreach($users as $user) { |
|
215 | + $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
216 | + } |
|
217 | + $output .= '</select>'; |
|
218 | + $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
219 | + echo $output; |
|
220 | + |
|
221 | + } |
|
222 | 222 | |
223 | 223 | } |
224 | 224 |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @since 1.5.1 |
12 | 12 | */ |
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
13 | + add_action('gform_user_registered', array($this, 'assign_new_user_to_lead'), 10, 4); |
|
14 | 14 | |
15 | 15 | // ONLY ADMIN FROM HERE ON. |
16 | - if( !is_admin() ) { return; } |
|
16 | + if (!is_admin()) { return; } |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
20 | 20 | * @since 1.7.4 |
21 | 21 | * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
22 | 22 | */ |
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
23 | + if (apply_filters('gravityview_disable_change_entry_creator', false)) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * Use `init` to fix bbPress warning |
29 | 29 | * @see https://bbpress.trac.wordpress.org/ticket/2309 |
30 | 30 | */ |
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
31 | + add_action('init', array($this, 'load'), 100); |
|
32 | 32 | |
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
33 | + add_action('plugins_loaded', array($this, 'prevent_conflicts')); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string $password User password |
46 | 46 | * @return void |
47 | 47 | */ |
48 | - function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
48 | + function assign_new_user_to_lead($user_id, $config, $entry = array(), $password = '') { |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Disable assigning the new user to the entry by returning false. |
@@ -53,27 +53,27 @@ discard block |
||
53 | 53 | * @param array $config User registration feed configuration |
54 | 54 | * @param array $entry GF Entry array |
55 | 55 | */ |
56 | - $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
56 | + $assign_to_lead = apply_filters('gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry); |
|
57 | 57 | |
58 | 58 | // If filter returns false, do not process |
59 | - if( empty( $assign_to_lead ) ) { |
|
59 | + if (empty($assign_to_lead)) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
64 | - $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
64 | + $result = RGFormsModel::update_lead_property($entry['id'], 'created_by', $user_id, false, true); |
|
65 | 65 | |
66 | - if( empty( $result ) ) { |
|
66 | + if (empty($result)) { |
|
67 | 67 | $status = __('Error', 'gravityview'); |
68 | 68 | } else { |
69 | 69 | $status = __('Success', 'gravityview'); |
70 | 70 | } |
71 | 71 | |
72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
72 | + $note = sprintf(_x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id); |
|
73 | 73 | |
74 | - do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note ); |
|
74 | + do_action('gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note); |
|
75 | 75 | |
76 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
76 | + GravityView_Entry_Notes::add_note($entry['id'], -1, 'GravityView', $note, 'gravityview'); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10, 2); |
90 | 90 | |
91 | 91 | // Disable for Gravity Forms Add-ons 3.6.2 and lower |
92 | - if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
92 | + if (class_exists('KWS_GF_Change_Lead_Creator')) { |
|
93 | 93 | |
94 | 94 | $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
95 | 95 | |
96 | 96 | // Now, no validation is required in the methods; let's hook in. |
97 | - remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
97 | + remove_action('admin_init', array($Old_Lead_Creator, 'set_screen_mode')); |
|
98 | 98 | |
99 | - remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10, 2); |
|
99 | + remove_action("gform_entry_info", array($Old_Lead_Creator, 'add_select'), 10, 2); |
|
100 | 100 | |
101 | - remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10, 2); |
|
101 | + remove_action("gform_after_update_entry", array($Old_Lead_Creator, 'update_entry_creator'), 10, 2); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | } |
@@ -110,26 +110,26 @@ discard block |
||
110 | 110 | function load() { |
111 | 111 | |
112 | 112 | // Does GF exist? |
113 | - if( !class_exists('GFCommon') ) { |
|
113 | + if (!class_exists('GFCommon')) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Can the user edit entries? |
118 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
118 | + if (!GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_entries'))) { |
|
119 | 119 | return; |
120 | 120 | } |
121 | 121 | |
122 | 122 | // If screen mode isn't set, then we're in the wrong place. |
123 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
123 | + if (empty($_REQUEST['screen_mode'])) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Now, no validation is required in the methods; let's hook in. |
128 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
128 | + add_action('admin_init', array(&$this, 'set_screen_mode')); |
|
129 | 129 | |
130 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
130 | + add_action("gform_entry_info", array(&$this, 'add_select'), 10, 2); |
|
131 | 131 | |
132 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
132 | + add_action("gform_after_update_entry", array(&$this, 'update_entry_creator'), 10, 2); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | function set_screen_mode() { |
141 | 141 | |
142 | 142 | // If $_GET['screen_mode'] is set to edit, set $_POST value |
143 | - if( rgget('screen_mode') === 'edit' ) { |
|
143 | + if (rgget('screen_mode') === 'edit') { |
|
144 | 144 | $_POST["screen_mode"] = 'edit'; |
145 | 145 | } |
146 | 146 | |
@@ -156,38 +156,38 @@ discard block |
||
156 | 156 | global $current_user; |
157 | 157 | |
158 | 158 | // Update the entry |
159 | - $created_by = absint( rgpost('created_by') ); |
|
159 | + $created_by = absint(rgpost('created_by')); |
|
160 | 160 | |
161 | - RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
161 | + RGFormsModel::update_lead_property($entry_id, 'created_by', $created_by); |
|
162 | 162 | |
163 | 163 | // If the creator has changed, let's add a note about who it used to be. |
164 | 164 | $originally_created_by = rgpost('originally_created_by'); |
165 | 165 | |
166 | 166 | // If there's no owner and there didn't used to be, keep going |
167 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
167 | + if (empty($originally_created_by) && empty($created_by)) { |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | 171 | // If the values have changed |
172 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
172 | + if (absint($originally_created_by) !== absint($created_by)) { |
|
173 | 173 | |
174 | 174 | $user_data = get_userdata($current_user->ID); |
175 | 175 | |
176 | 176 | $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
177 | 177 | |
178 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
178 | + $original_name = $created_by_name = esc_attr_x('No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
179 | 179 | |
180 | - if( !empty( $originally_created_by ) ) { |
|
180 | + if (!empty($originally_created_by)) { |
|
181 | 181 | $originally_created_by_user_data = get_userdata($originally_created_by); |
182 | - $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
182 | + $original_name = sprintf($user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID); |
|
183 | 183 | } |
184 | 184 | |
185 | - if( !empty( $created_by ) ) { |
|
186 | - $created_by_user_data = get_userdata($created_by); |
|
187 | - $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
185 | + if (!empty($created_by)) { |
|
186 | + $created_by_user_data = get_userdata($created_by); |
|
187 | + $created_by_name = sprintf($user_format, $created_by_user_data->display_name, $created_by_user_data->ID); |
|
188 | 188 | } |
189 | 189 | |
190 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
190 | + GravityView_Entry_Notes::add_note($entry_id, $current_user->ID, $user_data->display_name, sprintf(__('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name), 'note'); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | } |
@@ -198,24 +198,24 @@ discard block |
||
198 | 198 | * @param array $entry GF entry array |
199 | 199 | * @return void |
200 | 200 | */ |
201 | - function add_select($form_id, $entry ) { |
|
201 | + function add_select($form_id, $entry) { |
|
202 | 202 | |
203 | - if( rgpost('screen_mode') !== 'edit' ) { |
|
203 | + if (rgpost('screen_mode') !== 'edit') { |
|
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
207 | - $users = GVCommon::get_users( 'change_entry_creator' ); |
|
207 | + $users = GVCommon::get_users('change_entry_creator'); |
|
208 | 208 | |
209 | 209 | $output = '<label for="change_created_by">'; |
210 | 210 | $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
211 | 211 | $output .= '</label> |
212 | 212 | <select name="created_by" id="change_created_by" class="widefat">'; |
213 | - $output .= '<option value=""> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
214 | - foreach($users as $user) { |
|
215 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
213 | + $output .= '<option value=""> — '.esc_attr_x('No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
214 | + foreach ($users as $user) { |
|
215 | + $output .= '<option value="'.$user->ID.'"'.selected($entry['created_by'], $user->ID, false).'>'.esc_attr($user->display_name.' ('.$user->user_nicename.')').'</option>'; |
|
216 | 216 | } |
217 | 217 | $output .= '</select>'; |
218 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
218 | + $output .= '<input name="originally_created_by" value="'.esc_attr($entry['created_by']).'" type="hidden" />'; |
|
219 | 219 | echo $output; |
220 | 220 | |
221 | 221 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** If this file is called directly, abort. */ |
4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | +if (!defined('ABSPATH')) { |
|
5 | 5 | die; |
6 | 6 | } |
7 | 7 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param string $link_format |
76 | 76 | * @param string $after_link |
77 | 77 | */ |
78 | - function __construct( $entries = array(), $post_id = 0, $form = array(), $link_format = '', $after_link = '', $context = '' ) { |
|
78 | + function __construct($entries = array(), $post_id = 0, $form = array(), $link_format = '', $after_link = '', $context = '') { |
|
79 | 79 | |
80 | 80 | $this->entries = $entries; |
81 | 81 | $this->post_id = $post_id; |
@@ -90,28 +90,28 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * @param int $post_id |
92 | 92 | */ |
93 | - public function set_post_id( $post_id ) { |
|
93 | + public function set_post_id($post_id) { |
|
94 | 94 | $this->post_id = $post_id; |
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
98 | 98 | * @param string $link_format |
99 | 99 | */ |
100 | - public function set_link_format( $link_format ) { |
|
100 | + public function set_link_format($link_format) { |
|
101 | 101 | $this->link_format = $link_format; |
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @param boolean $skip_current_entry |
106 | 106 | */ |
107 | - public function set_skip_current_entry( $skip_current_entry ) { |
|
107 | + public function set_skip_current_entry($skip_current_entry) { |
|
108 | 108 | $this->skip_current_entry = (bool)$skip_current_entry; |
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | 112 | * @param string $after_link |
113 | 113 | */ |
114 | - public function set_after_link( $after_link ) { |
|
114 | + public function set_after_link($after_link) { |
|
115 | 115 | $this->after_link = $after_link; |
116 | 116 | } |
117 | 117 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * Set the message when there are no entries to display |
120 | 120 | * @param string $empty_message |
121 | 121 | */ |
122 | - public function set_empty_message( $empty_message ) { |
|
122 | + public function set_empty_message($empty_message) { |
|
123 | 123 | $this->empty_message = $empty_message; |
124 | 124 | } |
125 | 125 | |
@@ -127,23 +127,23 @@ discard block |
||
127 | 127 | * Set the context in which this entry list is being displayed. |
128 | 128 | * @param string $context |
129 | 129 | */ |
130 | - public function set_context( $context ) { |
|
130 | + public function set_context($context) { |
|
131 | 131 | $this->context = $context; |
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | 135 | * @param string $wrapper_tag |
136 | 136 | */ |
137 | - public function set_wrapper_tag( $wrapper_tag ) { |
|
138 | - $this->wrapper_tag = esc_attr( $wrapper_tag ); |
|
137 | + public function set_wrapper_tag($wrapper_tag) { |
|
138 | + $this->wrapper_tag = esc_attr($wrapper_tag); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
142 | 142 | * |
143 | 143 | * @param string $item_tag |
144 | 144 | */ |
145 | - public function set_item_tag( $item_tag ) { |
|
146 | - $this->item_tag = esc_attr( $item_tag ); |
|
145 | + public function set_item_tag($item_tag) { |
|
146 | + $this->item_tag = esc_attr($item_tag); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -170,32 +170,32 @@ discard block |
||
170 | 170 | public function get_output() { |
171 | 171 | |
172 | 172 | // No Entries |
173 | - if( empty( $this->entries ) ) { |
|
173 | + if (empty($this->entries)) { |
|
174 | 174 | return '<div class="gv-no-results">'.$this->empty_message.'</div>'; |
175 | 175 | } |
176 | 176 | |
177 | 177 | $output = ''; |
178 | 178 | $current_entry = GravityView_View::getInstance()->getCurrentEntry(); |
179 | 179 | |
180 | - $output .= '<'. $this->wrapper_tag .'>'; |
|
180 | + $output .= '<'.$this->wrapper_tag.'>'; |
|
181 | 181 | |
182 | - foreach( $this->entries as $entry ) { |
|
182 | + foreach ($this->entries as $entry) { |
|
183 | 183 | |
184 | - if( $this->skip_entry( $entry, $current_entry ) ) { |
|
184 | + if ($this->skip_entry($entry, $current_entry)) { |
|
185 | 185 | continue; |
186 | 186 | } |
187 | 187 | |
188 | - $output .= $this->get_item_output( $entry ); |
|
188 | + $output .= $this->get_item_output($entry); |
|
189 | 189 | } |
190 | 190 | |
191 | - $output .= '</'. $this->wrapper_tag .'>'; |
|
191 | + $output .= '</'.$this->wrapper_tag.'>'; |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @filter `gravityview/widget/recent-entries/output` Modify the HTML of the Recent Entries widget output |
195 | 195 | * @param string $output HTML to be displayed |
196 | 196 | * @param GravityView_Entry_List $this The current class instance |
197 | 197 | */ |
198 | - $output = apply_filters( 'gravityview/widget/recent-entries/output', $output, $this ); |
|
198 | + $output = apply_filters('gravityview/widget/recent-entries/output', $output, $this); |
|
199 | 199 | |
200 | 200 | return $output; |
201 | 201 | } |
@@ -208,18 +208,18 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @return bool True: Skip entry; False: don't skip entry |
210 | 210 | */ |
211 | - private function skip_entry( $entry, $current_entry ) { |
|
211 | + private function skip_entry($entry, $current_entry) { |
|
212 | 212 | |
213 | 213 | // If skip entry is off, or there's no current entry, return false |
214 | - if( empty( $this->skip_current_entry ) || empty( $current_entry ) ) { |
|
214 | + if (empty($this->skip_current_entry) || empty($current_entry)) { |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
218 | 218 | // If in Single or Edit mode, $current_entry will be an array. |
219 | - $current_entry_id = is_array( $current_entry ) ? $current_entry['id'] : $current_entry; |
|
219 | + $current_entry_id = is_array($current_entry) ? $current_entry['id'] : $current_entry; |
|
220 | 220 | |
221 | 221 | // If the entry ID matches the current entry, yes: skip |
222 | - if( $entry['id'] === $current_entry_id ) { |
|
222 | + if ($entry['id'] === $current_entry_id) { |
|
223 | 223 | return true; |
224 | 224 | } |
225 | 225 | |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string HTML output for the entry |
242 | 242 | */ |
243 | - private function get_item_output( $entry ) { |
|
243 | + private function get_item_output($entry) { |
|
244 | 244 | |
245 | - $link = GravityView_API::entry_link( $entry, $this->post_id ); |
|
245 | + $link = GravityView_API::entry_link($entry, $this->post_id); |
|
246 | 246 | |
247 | - $item_output = gravityview_get_link( $link, $this->link_format ); |
|
247 | + $item_output = gravityview_get_link($link, $this->link_format); |
|
248 | 248 | |
249 | - if( !empty( $this->after_link ) ) { |
|
249 | + if (!empty($this->after_link)) { |
|
250 | 250 | |
251 | 251 | /** |
252 | 252 | * @filter `gravityview/entry-list/after-link` Modify the content displayed after the entry link in an entry list |
@@ -255,14 +255,14 @@ discard block |
||
255 | 255 | * @param array $entry Gravity Forms entry array |
256 | 256 | * @param GravityView_Entry_List $this The current class instance |
257 | 257 | */ |
258 | - $after_link = apply_filters( 'gravityview/entry-list/after-link', '<div>'.$this->after_link.'</div>', $entry, $this ); |
|
258 | + $after_link = apply_filters('gravityview/entry-list/after-link', '<div>'.$this->after_link.'</div>', $entry, $this); |
|
259 | 259 | |
260 | 260 | $item_output .= $after_link; |
261 | 261 | } |
262 | 262 | |
263 | - $item_output = GravityView_API::replace_variables( $item_output, $this->form, $entry ); |
|
263 | + $item_output = GravityView_API::replace_variables($item_output, $this->form, $entry); |
|
264 | 264 | |
265 | - $item_output = '<'. $this->item_tag .'>'. $item_output .'</'. $this->item_tag .'>'; |
|
265 | + $item_output = '<'.$this->item_tag.'>'.$item_output.'</'.$this->item_tag.'>'; |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * @filter `gravityview/entry-list/item` Modify each item's output in an entry list |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param array $entry Gravity Forms entry array |
272 | 272 | * @param GravityView_Entry_List $this The current class instance |
273 | 273 | */ |
274 | - $item_output = apply_filters( 'gravityview/entry-list/item', $item_output, $entry, $this ); |
|
274 | + $item_output = apply_filters('gravityview/entry-list/item', $item_output, $entry, $this); |
|
275 | 275 | |
276 | 276 | return $item_output; |
277 | 277 | } |