Completed
Pull Request — master (#605)
by Zack
05:45
created
includes/admin/metaboxes/class-gravityview-metabox-tab.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
 	 * @param string $icon_class_name Icon class used in vertical tabs. Supports non-dashicon. If dashicons, no need for `dashicons ` prefix
96 96
 	 * @param string $callback Function to render the metabox, if $file is not defined.
97 97
 	 * @param null $callback_args Arguments passed to the callback
98
-	 * @return void
98
+	 * @return GravityView_Metabox_Tab
99 99
 	 */
100 100
 	function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = null  ) {
101 101
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 	 * @param array $callback_args Arguments passed to the callback
98 98
 	 * @return void
99 99
 	 */
100
-	function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array()  ) {
100
+	function __construct($id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array()) {
101 101
 
102 102
 		$this->id = $this->prefix.$id;
103 103
 		$this->title = $title;
104 104
 		$this->render_template_file = $file;
105 105
 		$this->callback = $callback;
106 106
 		$this->callback_args = $callback_args;
107
-		$this->icon_class_name = $this->parse_icon_class_name( $icon_class_name );
107
+		$this->icon_class_name = $this->parse_icon_class_name($icon_class_name);
108 108
 	}
109 109
 
110 110
 	/**
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return string sanitized CSS class
118 118
 	 */
119
-	function parse_icon_class_name( $icon_class_name = '' ) {
119
+	function parse_icon_class_name($icon_class_name = '') {
120 120
 
121
-		if( preg_match( '/dashicon/i', $icon_class_name ) ) {
122
-			$icon_class_name = 'dashicons ' . $icon_class_name;
121
+		if (preg_match('/dashicon/i', $icon_class_name)) {
122
+			$icon_class_name = 'dashicons '.$icon_class_name;
123 123
 		}
124 124
 
125
-		return esc_attr( $icon_class_name );
125
+		return esc_attr($icon_class_name);
126 126
 	}
127 127
 
128 128
 	/**
@@ -140,38 +140,38 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @param WP_Post $post Currently edited post object
142 142
 	 */
143
-	function render( $post ) {
143
+	function render($post) {
144 144
 
145
-		if( !empty( $this->render_template_file ) ) {
145
+		if (!empty($this->render_template_file)) {
146 146
 
147 147
 			$file = $this->render_template_file;
148 148
 
149 149
 			// If the full path exists, use it
150
-			if( file_exists( $file ) ) {
150
+			if (file_exists($file)) {
151 151
 				$path = $file;
152 152
 			} else {
153
-				$path = GRAVITYVIEW_DIR .'includes/admin/metaboxes/views/'.$file;
153
+				$path = GRAVITYVIEW_DIR.'includes/admin/metaboxes/views/'.$file;
154 154
 			}
155 155
 
156
-			if( file_exists( $path ) ) {
156
+			if (file_exists($path)) {
157 157
 				include $path;
158 158
 			} else {
159
-				do_action( 'gravityview_log_error', 'Metabox template file not found', $this );
159
+				do_action('gravityview_log_error', 'Metabox template file not found', $this);
160 160
 			}
161 161
 
162
-		} else if( !empty( $this->callback ) ) {
162
+		} else if (!empty($this->callback)) {
163 163
 
164
-			if( is_callable( $this->callback ) ) {
164
+			if (is_callable($this->callback)) {
165 165
 
166 166
 				/** @see do_accordion_sections() */
167
-				call_user_func( $this->callback, $post, (array) $this );
167
+				call_user_func($this->callback, $post, (array)$this);
168 168
 
169 169
 			} else {
170
-				do_action( 'gravityview_log_error', 'Metabox callback was not callable', $this );
170
+				do_action('gravityview_log_error', 'Metabox callback was not callable', $this);
171 171
 			}
172 172
 
173 173
 		} else {
174
-			do_action( 'gravityview_log_error', 'Metabox file and callback were not found', $this );
174
+			do_action('gravityview_log_error', 'Metabox file and callback were not found', $this);
175 175
 		}
176 176
 	}
177 177
 
Please login to merge, or discard this patch.
includes/class-admin-add-shortcode.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -144,7 +144,6 @@
 block discarded – undo
144 144
 	 * Enqueue scripts and styles
145 145
 	 *
146 146
 	 * @access public
147
-	 * @param mixed $hook
148 147
 	 * @return void
149 148
 	 */
150 149
 	function add_scripts_and_styles() {
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Adds a button to add the View shortcode into the post content
4
- *
5
- * @package   GravityView
6
- * @license   GPL2+
7
- * @author    Katz Web Services, Inc.
8
- * @link      http://gravityview.co
9
- * @copyright Copyright 2014, Katz Web Services, Inc.
10
- *
11
- * @since 1.0.0
12
- */
3
+	 * Adds a button to add the View shortcode into the post content
4
+	 *
5
+	 * @package   GravityView
6
+	 * @license   GPL2+
7
+	 * @author    Katz Web Services, Inc.
8
+	 * @link      http://gravityview.co
9
+	 * @copyright Copyright 2014, Katz Web Services, Inc.
10
+	 *
11
+	 * @since 1.0.0
12
+	 */
13 13
 
14 14
 /** If this file is called directly, abort. */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
 
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
 
21 21
 	function __construct() {
22 22
 
23
-			add_action( 'media_buttons', array( $this, 'add_shortcode_button'), 30);
23
+			add_action('media_buttons', array($this, 'add_shortcode_button'), 30);
24 24
 
25
-			add_action( 'admin_footer',	array( $this, 'add_shortcode_popup') );
25
+			add_action('admin_footer', array($this, 'add_shortcode_popup'));
26 26
 
27 27
 			// adding styles and scripts
28
-			add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') );
28
+			add_action('admin_enqueue_scripts', array($this, 'add_scripts_and_styles'));
29 29
 
30 30
 			// ajax - populate sort fields based on the selected view
31
-			add_action( 'wp_ajax_gv_sortable_fields', array( $this, 'get_sortable_fields' ) );
31
+			add_action('wp_ajax_gv_sortable_fields', array($this, 'get_sortable_fields'));
32 32
 	}
33 33
 
34 34
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	function is_post_editor_screen() {
42 42
 		global $current_screen, $pagenow;
43
-		return !empty( $current_screen->post_type ) && 'gravityview' != $current_screen->post_type && in_array( $pagenow , array( 'post.php' , 'post-new.php' ) );
43
+		return !empty($current_screen->post_type) && 'gravityview' != $current_screen->post_type && in_array($pagenow, array('post.php', 'post-new.php'));
44 44
 	}
45 45
 
46 46
 
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 		/**
56 56
 		 * @since 1.15.3
57 57
 		 */
58
-		if( ! GVCommon::has_cap( array( 'publish_gravityviews' ) ) ) {
58
+		if (!GVCommon::has_cap(array('publish_gravityviews'))) {
59 59
 			return;
60 60
 		}
61 61
 
62
-		if( !$this->is_post_editor_screen() ) {
62
+		if (!$this->is_post_editor_screen()) {
63 63
 			return;
64 64
 		}
65 65
 		?>
66
-		<a href="#TB_inline?width=480&amp;inlineId=select_gravityview_view&amp;width=600&amp;height=800" class="thickbox button gform_media_link" id="add_gravityview" title="<?php esc_attr_e("Insert View", 'gravityview'); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e( 'Add View', 'gravityview' ); ?></a>
66
+		<a href="#TB_inline?width=480&amp;inlineId=select_gravityview_view&amp;width=600&amp;height=800" class="thickbox button gform_media_link" id="add_gravityview" title="<?php esc_attr_e("Insert View", 'gravityview'); ?>"><span class="icon gv-icon-astronaut-head"></span><?php esc_html_e('Add View', 'gravityview'); ?></a>
67 67
 		<?php
68 68
 
69 69
 	}
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
 	function add_shortcode_popup() {
80 80
 		global $post;
81 81
 
82
-		if( !$this->is_post_editor_screen() ) {
82
+		if (!$this->is_post_editor_screen()) {
83 83
 			return;
84 84
 		}
85 85
 
86 86
 		$post_type = get_post_type_object($post->post_type);
87 87
 
88
-		$views = get_posts( array('post_type' => 'gravityview', 'posts_per_page' => -1 ) );
88
+		$views = get_posts(array('post_type' => 'gravityview', 'posts_per_page' => -1));
89 89
 
90 90
 		// If there are no views set up yet, we get outta here.
91
-		if( empty( $views ) ) {
92
-			echo '<div id="select_gravityview_view"><div class="wrap">'. GravityView_Post_Types::no_views_text() .'</div></div>';
91
+		if (empty($views)) {
92
+			echo '<div id="select_gravityview_view"><div class="wrap">'.GravityView_Post_Types::no_views_text().'</div></div>';
93 93
 			return;
94 94
 		}
95 95
 
@@ -98,18 +98,18 @@  discard block
 block discarded – undo
98 98
 			<form action="#" method="get" id="select_gravityview_view_form">
99 99
 				<div class="wrap">
100 100
 
101
-					<h2 class=""><?php esc_html_e( 'Embed a View', 'gravityview' ); ?></h2>
102
-					<p class="subtitle"><?php printf( esc_attr ( __( 'Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview') ), $post_type->labels->singular_name, '<a href="http://gravityview.co/support/documentation/202934188/" target="_blank">', '</a>' ); ?></p>
101
+					<h2 class=""><?php esc_html_e('Embed a View', 'gravityview'); ?></h2>
102
+					<p class="subtitle"><?php printf(esc_attr(__('Use this form to embed a View into this %s. %sLearn more about using shortcodes.%s', 'gravityview')), $post_type->labels->singular_name, '<a href="http://gravityview.co/support/documentation/202934188/" target="_blank">', '</a>'); ?></p>
103 103
 
104 104
 					<div>
105
-						<h3><label for="gravityview_id"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label></h3>
105
+						<h3><label for="gravityview_id"><?php esc_html_e('Select a View', 'gravityview'); ?></label></h3>
106 106
 
107 107
 						<select name="gravityview_id" id="gravityview_id">
108
-							<option value=""><?php esc_html_e( '&mdash; Select a View to Insert &mdash;', 'gravityview' ); ?></option>
108
+							<option value=""><?php esc_html_e('&mdash; Select a View to Insert &mdash;', 'gravityview'); ?></option>
109 109
 							<?php
110
-							foreach( $views as $view ) {
111
-								$title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title;
112
-								echo '<option value="'. $view->ID .'">'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>';
110
+							foreach ($views as $view) {
111
+								$title = empty($view->post_title) ? __('(no title)', 'gravityview') : $view->post_title;
112
+								echo '<option value="'.$view->ID.'">'.esc_html(sprintf('%s #%d', $title, $view->ID)).'</option>';
113 113
 							}
114 114
 							?>
115 115
 						</select>
@@ -117,24 +117,24 @@  discard block
 block discarded – undo
117 117
 
118 118
 					<table class="form-table hide-if-js">
119 119
 
120
-						<caption><?php esc_html_e( 'View Settings', 'gravityview' ); ?></caption>
120
+						<caption><?php esc_html_e('View Settings', 'gravityview'); ?></caption>
121 121
 
122 122
 						<?php
123 123
 
124
-						$settings = GravityView_View_Data::get_default_args( true );
124
+						$settings = GravityView_View_Data::get_default_args(true);
125 125
 
126
-						foreach ( $settings as $key => $setting ) {
126
+						foreach ($settings as $key => $setting) {
127 127
 
128
-							if( empty( $setting['show_in_shortcode'] ) ) { continue; }
128
+							if (empty($setting['show_in_shortcode'])) { continue; }
129 129
 
130
-							GravityView_Render_Settings::render_setting_row( $key, array(), NULL, 'gravityview_%s', 'gravityview_%s' );
130
+							GravityView_Render_Settings::render_setting_row($key, array(), NULL, 'gravityview_%s', 'gravityview_%s');
131 131
 						}
132 132
 						?>
133 133
 
134 134
 					</table>
135 135
 
136 136
 					<div class="submit">
137
-						<input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview' ); ?>" id="insert_gravityview_view" />
137
+						<input type="submit" class="button button-primary button-large alignleft hide-if-js" value="<?php esc_attr_e('Insert View', 'gravityview'); ?>" id="insert_gravityview_view" />
138 138
 						<input class="button button-secondary alignright" type="submit" onclick="tb_remove(); return false;" value="<?php esc_attr_e("Cancel", 'gravityview'); ?>" />
139 139
 					</div>
140 140
 
@@ -157,32 +157,32 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	function add_scripts_and_styles() {
159 159
 
160
-		if( ! $this->is_post_editor_screen() ) {
160
+		if (!$this->is_post_editor_screen()) {
161 161
 			return;
162 162
 		}
163 163
 
164
-		wp_enqueue_style( 'dashicons' );
164
+		wp_enqueue_style('dashicons');
165 165
 
166 166
 		// date picker
167
-		wp_enqueue_script( 'jquery-ui-datepicker' );
167
+		wp_enqueue_script('jquery-ui-datepicker');
168 168
 
169 169
 		$protocol = is_ssl() ? 'https://' : 'http://';
170 170
 
171
-		wp_enqueue_style( 'jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version );
171
+		wp_enqueue_style('jquery-ui-datepicker', $protocol.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css', array(), GravityView_Plugin::version);
172 172
 
173 173
 		//enqueue styles
174
-		wp_register_style( 'gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version );
175
-		wp_enqueue_style( 'gravityview_postedit_styles' );
174
+		wp_register_style('gravityview_postedit_styles', plugins_url('assets/css/admin-post-edit.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version);
175
+		wp_enqueue_style('gravityview_postedit_styles');
176 176
 
177 177
 		$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
178 178
 
179 179
 		// custom js
180
-		wp_register_script( 'gravityview_postedit_scripts',  plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'jquery-ui-datepicker' ), GravityView_Plugin::version );
181
-		wp_enqueue_script( 'gravityview_postedit_scripts' );
180
+		wp_register_script('gravityview_postedit_scripts', plugins_url('assets/js/admin-post-edit'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery', 'jquery-ui-datepicker'), GravityView_Plugin::version);
181
+		wp_enqueue_script('gravityview_postedit_scripts');
182 182
 		wp_localize_script('gravityview_postedit_scripts', 'gvGlobals', array(
183
-			'nonce' => wp_create_nonce( 'gravityview_ajaxaddshortcode'),
184
-			'loading_text' => esc_html__( 'Loading&hellip;', 'gravityview' ),
185
-			'alert_1' => esc_html__( 'Please select a View', 'gravityview'),
183
+			'nonce' => wp_create_nonce('gravityview_ajaxaddshortcode'),
184
+			'loading_text' => esc_html__('Loading&hellip;', 'gravityview'),
185
+			'alert_1' => esc_html__('Please select a View', 'gravityview'),
186 186
 		));
187 187
 
188 188
 	}
@@ -199,27 +199,27 @@  discard block
 block discarded – undo
199 199
 	function get_sortable_fields() {
200 200
 
201 201
 		// Not properly formatted request
202
-		if ( empty( $_POST['viewid'] ) || !is_numeric( $_POST['viewid'] ) ) {
203
-			exit( false );
202
+		if (empty($_POST['viewid']) || !is_numeric($_POST['viewid'])) {
203
+			exit(false);
204 204
 		}
205 205
 
206 206
 		// Not valid request
207
-		if( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxaddshortcode' ) ) {
208
-			exit( false );
207
+		if (empty($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxaddshortcode')) {
208
+			exit(false);
209 209
 		}
210 210
 
211 211
 		$viewid = (int)$_POST['viewid'];
212 212
 
213 213
 		// fetch form id assigned to the view
214
-		$formid = gravityview_get_form_id( $viewid );
214
+		$formid = gravityview_get_form_id($viewid);
215 215
 
216 216
 		// Get the default sort field for the view
217
-		$sort_field = gravityview_get_template_setting( $viewid, 'sort_field' );
217
+		$sort_field = gravityview_get_template_setting($viewid, 'sort_field');
218 218
 
219 219
 		// Generate the output `<option>`s
220
-		$response = gravityview_get_sortable_fields( $formid, $sort_field );
220
+		$response = gravityview_get_sortable_fields($formid, $sort_field);
221 221
 
222
-		exit( $response );
222
+		exit($response);
223 223
 	}
224 224
 
225 225
 }
Please login to merge, or discard this patch.
includes/class-ajax.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @since 1.15
29 29
 	 * @param bool|false $mixed
30 30
 	 *
31
-	 * @return bool
31
+	 * @return boolean|null
32 32
 	 */
33 33
 	private function _exit( $mixed = NULL ) {
34 34
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * Import Gravity Form XML or JSON
201 201
 	 *
202 202
 	 * @param  string $xml_or_json_path Path to form XML or JSON file
203
-	 * @return int|bool       Imported form ID or false
203
+	 * @return false|string       Imported form ID or false
204 204
 	 */
205 205
 	function import_form( $xml_or_json_path = '' ) {
206 206
 
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
 		// template areas
138 138
 		$template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' );
139
-        $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' );
139
+		$template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' );
140 140
 
141 141
 		// widget areas
142 142
 		$default_widget_areas = GravityView_Plugin::get_default_widget_areas();
@@ -328,40 +328,40 @@  discard block
 block discarded – undo
328 328
 		// load file
329 329
 		$xmlstr = file_get_contents( $form_file );
330 330
 
331
-        $options = array(
332
-            "page" => array("unserialize_as_array" => true),
333
-            "form"=> array("unserialize_as_array" => true),
334
-            "field"=> array("unserialize_as_array" => true),
335
-            "rule"=> array("unserialize_as_array" => true),
336
-            "choice"=> array("unserialize_as_array" => true),
337
-            "input"=> array("unserialize_as_array" => true),
338
-            "routing_item"=> array("unserialize_as_array" => true),
339
-            "creditCard"=> array("unserialize_as_array" => true),
340
-            "routin"=> array("unserialize_as_array" => true),
341
-            "confirmation" => array("unserialize_as_array" => true),
342
-            "notification" => array("unserialize_as_array" => true)
343
-        );
331
+		$options = array(
332
+			"page" => array("unserialize_as_array" => true),
333
+			"form"=> array("unserialize_as_array" => true),
334
+			"field"=> array("unserialize_as_array" => true),
335
+			"rule"=> array("unserialize_as_array" => true),
336
+			"choice"=> array("unserialize_as_array" => true),
337
+			"input"=> array("unserialize_as_array" => true),
338
+			"routing_item"=> array("unserialize_as_array" => true),
339
+			"creditCard"=> array("unserialize_as_array" => true),
340
+			"routin"=> array("unserialize_as_array" => true),
341
+			"confirmation" => array("unserialize_as_array" => true),
342
+			"notification" => array("unserialize_as_array" => true)
343
+		);
344 344
 
345 345
 		$xml = new RGXML($options);
346
-        $forms = $xml->unserialize($xmlstr);
346
+		$forms = $xml->unserialize($xmlstr);
347 347
 
348
-        if( !$forms ) {
349
-        	do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file );
350
-        	return false;
351
-        }
348
+		if( !$forms ) {
349
+			do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file );
350
+			return false;
351
+		}
352 352
 
353
-        if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
354
-        	$form = $forms[0];
355
-        }
353
+		if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
354
+			$form = $forms[0];
355
+		}
356 356
 
357
-        if( empty( $form ) ) {
358
-        	do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms );
359
-        	return false;
360
-        }
357
+		if( empty( $form ) ) {
358
+			do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms );
359
+			return false;
360
+		}
361 361
 
362
-        do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form );
362
+		do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form );
363 363
 
364
-        return $form;
364
+		return $form;
365 365
 
366 366
 	}
367 367
 
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -5,21 +5,21 @@  discard block
 block discarded – undo
5 5
 	function __construct() {
6 6
 
7 7
 		//get field options
8
-		add_action( 'wp_ajax_gv_field_options', array( $this, 'get_field_options' ) );
8
+		add_action('wp_ajax_gv_field_options', array($this, 'get_field_options'));
9 9
 
10 10
 		// get available fields
11
-		add_action( 'wp_ajax_gv_available_fields', array( $this, 'get_available_fields_html' ) );
11
+		add_action('wp_ajax_gv_available_fields', array($this, 'get_available_fields_html'));
12 12
 
13 13
 		// get active areas
14
-		add_action( 'wp_ajax_gv_get_active_areas', array( $this, 'get_active_areas' ) );
14
+		add_action('wp_ajax_gv_get_active_areas', array($this, 'get_active_areas'));
15 15
 
16 16
 		// get preset fields
17
-		add_action( 'wp_ajax_gv_get_preset_fields', array( $this, 'get_preset_fields_config' ) );
17
+		add_action('wp_ajax_gv_get_preset_fields', array($this, 'get_preset_fields_config'));
18 18
 
19 19
 		// get preset fields
20
-		add_action( 'wp_ajax_gv_set_preset_form', array( $this, 'create_preset_form' ) );
20
+		add_action('wp_ajax_gv_set_preset_form', array($this, 'create_preset_form'));
21 21
 
22
-		add_action( 'wp_ajax_gv_sortable_fields_form', array( $this, 'get_sortable_fields' ) );
22
+		add_action('wp_ajax_gv_sortable_fields_form', array($this, 'get_sortable_fields'));
23 23
 	}
24 24
 
25 25
 	/**
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return bool
32 32
 	 */
33
-	private function _exit( $mixed = NULL ) {
33
+	private function _exit($mixed = NULL) {
34 34
 
35 35
 		/**
36 36
 		 * Don't exit if we're running test suite.
37 37
 		 * @since 1.15
38 38
 		 */
39
-		if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) {
39
+		if (defined('DOING_GRAVITYVIEW_TESTS') && DOING_GRAVITYVIEW_TESTS) {
40 40
 			return $mixed;
41 41
 		}
42 42
 
43
-		exit( $mixed );
43
+		exit($mixed);
44 44
 	}
45 45
 
46 46
 	/** -------- AJAX ---------- */
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * @return void
51 51
 	 */
52 52
 	function check_ajax_nonce() {
53
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) {
54
-			$this->_exit( false );
53
+		if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxviews')) {
54
+			$this->_exit(false);
55 55
 		}
56 56
 	}
57 57
 
@@ -67,20 +67,20 @@  discard block
 block discarded – undo
67 67
 		//check nonce
68 68
 		$this->check_ajax_nonce();
69 69
 
70
-		$context = isset($_POST['context']) ? esc_attr( $_POST['context'] ) : 'directory';
70
+		$context = isset($_POST['context']) ? esc_attr($_POST['context']) : 'directory';
71 71
 
72 72
 		// If Form was changed, JS sends form ID, if start fresh, JS sends template_id
73
-		if( !empty( $_POST['form_id'] ) ) {
74
-			do_action( 'gravityview_render_available_fields', (int) $_POST['form_id'], $context );
73
+		if (!empty($_POST['form_id'])) {
74
+			do_action('gravityview_render_available_fields', (int)$_POST['form_id'], $context);
75 75
 			$this->_exit();
76
-		} elseif( !empty( $_POST['template_id'] ) ) {
77
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
78
-			do_action( 'gravityview_render_available_fields', $form, $context );
76
+		} elseif (!empty($_POST['template_id'])) {
77
+			$form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']);
78
+			do_action('gravityview_render_available_fields', $form, $context);
79 79
 			$this->_exit();
80 80
 		}
81 81
 
82 82
 		//if everything fails..
83
-		$this->_exit( false );
83
+		$this->_exit(false);
84 84
 	}
85 85
 
86 86
 
@@ -94,21 +94,21 @@  discard block
 block discarded – undo
94 94
 	function get_active_areas() {
95 95
 		$this->check_ajax_nonce();
96 96
 
97
-		if( empty( $_POST['template_id'] ) ) {
98
-			$this->_exit( false );
97
+		if (empty($_POST['template_id'])) {
98
+			$this->_exit(false);
99 99
 		}
100 100
 
101 101
 		ob_start();
102
-		do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true );
102
+		do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true);
103 103
 		$response['directory'] = ob_get_clean();
104 104
 
105 105
 		ob_start();
106
-		do_action( 'gravityview_render_directory_active_areas',  $_POST['template_id'], 'single', '', true );
106
+		do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true);
107 107
 		$response['single'] = ob_get_clean();
108 108
 
109
-		$response = array_map( 'gravityview_strip_whitespace', $response );
109
+		$response = array_map('gravityview_strip_whitespace', $response);
110 110
 
111
-		$this->_exit( json_encode( $response ) );
111
+		$this->_exit(json_encode($response));
112 112
 	}
113 113
 
114 114
 	/**
@@ -119,49 +119,49 @@  discard block
 block discarded – undo
119 119
 
120 120
 		$this->check_ajax_nonce();
121 121
 
122
-		if( empty( $_POST['template_id'] ) ) {
123
-			$this->_exit( false );
122
+		if (empty($_POST['template_id'])) {
123
+			$this->_exit(false);
124 124
 		}
125 125
 
126 126
 		// get the fields xml config file for this specific preset
127
-		$preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] );
127
+		$preset_fields_path = apply_filters('gravityview_template_fieldsxml', array(), $_POST['template_id']);
128 128
 		// import fields
129
-		if( !empty( $preset_fields_path ) ) {
130
-			$presets = $this->import_fields( $preset_fields_path );
129
+		if (!empty($preset_fields_path)) {
130
+			$presets = $this->import_fields($preset_fields_path);
131 131
 		} else {
132
-			$presets = array( 'widgets' => array(), 'fields' => array() );
132
+			$presets = array('widgets' => array(), 'fields' => array());
133 133
 		}
134 134
 
135
-		$template_id = esc_attr( $_POST['template_id'] );
135
+		$template_id = esc_attr($_POST['template_id']);
136 136
 
137 137
 		// template areas
138
-		$template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' );
139
-        $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' );
138
+		$template_areas_directory = apply_filters('gravityview_template_active_areas', array(), $template_id, 'directory');
139
+        $template_areas_single = apply_filters('gravityview_template_active_areas', array(), $template_id, 'single');
140 140
 
141 141
 		// widget areas
142 142
 		$default_widget_areas = GravityView_Plugin::get_default_widget_areas();
143 143
 
144 144
 		ob_start();
145
-		do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] );
145
+		do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets']);
146 146
 		$response['header'] = ob_get_clean();
147 147
 
148 148
 		ob_start();
149
-		do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] );
149
+		do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets']);
150 150
 		$response['footer'] = ob_get_clean();
151 151
 
152 152
 		ob_start();
153
-		do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] );
153
+		do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields']);
154 154
 		$response['directory'] = ob_get_clean();
155 155
 
156 156
 		ob_start();
157
-		do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] );
157
+		do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields']);
158 158
 		$response['single'] = ob_get_clean();
159 159
 
160
-		$response = array_map( 'gravityview_strip_whitespace', $response );
160
+		$response = array_map('gravityview_strip_whitespace', $response);
161 161
 
162
-		do_action( 'gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response );
162
+		do_action('gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response);
163 163
 
164
-		$this->_exit( json_encode( $response ) );
164
+		$this->_exit(json_encode($response));
165 165
 	}
166 166
 
167 167
 	/**
@@ -173,26 +173,26 @@  discard block
 block discarded – undo
173 173
 
174 174
 		$this->check_ajax_nonce();
175 175
 
176
-		if( empty( $_POST['template_id'] ) ) {
177
-			do_action( 'gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.' );
178
-			$this->_exit( false );
176
+		if (empty($_POST['template_id'])) {
177
+			do_action('gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.');
178
+			$this->_exit(false);
179 179
 		}
180 180
 
181 181
 		// get the xml for this specific template_id
182
-		$preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] );
182
+		$preset_form_xml_path = apply_filters('gravityview_template_formxml', '', $_POST['template_id']);
183 183
 
184 184
 		// import form
185
-		$form = $this->import_form( $preset_form_xml_path );
185
+		$form = $this->import_form($preset_form_xml_path);
186 186
 
187 187
 		// get the form ID
188
-		if( false === $form ) {
188
+		if (false === $form) {
189 189
 			// send error to user
190
-			do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int) $_POST['template_id'] );
190
+			do_action('gravityview_log_error', '[create_preset_form] Error importing form for template id: '.(int)$_POST['template_id']);
191 191
 
192
-			$this->_exit( false );
192
+			$this->_exit(false);
193 193
 		}
194 194
 
195
-		$this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' );
195
+		$this->_exit('<option value="'.esc_attr($form['id']).'" selected="selected">'.esc_html($form['title']).'</option>');
196 196
 
197 197
 	}
198 198
 
@@ -202,24 +202,24 @@  discard block
 block discarded – undo
202 202
 	 * @param  string $xml_or_json_path Path to form XML or JSON file
203 203
 	 * @return int|bool       Imported form ID or false
204 204
 	 */
205
-	function import_form( $xml_or_json_path = '' ) {
205
+	function import_form($xml_or_json_path = '') {
206 206
 
207
-		do_action( 'gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path );
207
+		do_action('gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path);
208 208
 
209
-		if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) {
210
-			do_action( 'gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path );
209
+		if (empty($xml_or_json_path) || !class_exists('GFExport') || !file_exists($xml_or_json_path)) {
210
+			do_action('gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path);
211 211
 			return false;
212 212
 		}
213 213
 
214 214
 		// import form
215 215
 		$forms = '';
216
-		$count = GFExport::import_file( $xml_or_json_path, $forms );
216
+		$count = GFExport::import_file($xml_or_json_path, $forms);
217 217
 
218
-		do_action( 'gravityview_log_debug', '[import_form] Importing form (Result)', $count );
219
-		do_action( 'gravityview_log_debug', '[import_form] Importing form (Form) ', $forms );
218
+		do_action('gravityview_log_debug', '[import_form] Importing form (Result)', $count);
219
+		do_action('gravityview_log_debug', '[import_form] Importing form (Form) ', $forms);
220 220
 
221
-		if( $count != 1 || empty( $forms[0]['id'] ) ) {
222
-			do_action( 'gravityview_log_error', '[import_form] Form Import Failed!' );
221
+		if ($count != 1 || empty($forms[0]['id'])) {
222
+			do_action('gravityview_log_error', '[import_form] Form Import Failed!');
223 223
 			return false;
224 224
 		}
225 225
 
@@ -238,26 +238,26 @@  discard block
 block discarded – undo
238 238
 	function get_field_options() {
239 239
 		$this->check_ajax_nonce();
240 240
 
241
-		if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) {
242
-			do_action( 'gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ' );
243
-			$this->_exit( false );
241
+		if (empty($_POST['template']) || empty($_POST['area']) || empty($_POST['field_id']) || empty($_POST['field_type'])) {
242
+			do_action('gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ');
243
+			$this->_exit(false);
244 244
 		}
245 245
 
246 246
 		// Fix apostrophes added by JSON response
247
-		$_post = array_map( 'stripslashes_deep', $_POST );
247
+		$_post = array_map('stripslashes_deep', $_POST);
248 248
 
249 249
 		// Sanitize
250
-		$_post = array_map( 'esc_attr', $_post );
250
+		$_post = array_map('esc_attr', $_post);
251 251
 
252 252
 		// The GF type of field: `product`, `name`, `creditcard`, `id`, `text`
253
-		$input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL;
254
-		$context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL;
253
+		$input_type = isset($_post['input_type']) ? esc_attr($_post['input_type']) : NULL;
254
+		$context = isset($_post['context']) ? esc_attr($_post['context']) : NULL;
255 255
 
256
-		$response = GravityView_Render_Settings::render_field_options( $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context  );
256
+		$response = GravityView_Render_Settings::render_field_options($_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context);
257 257
 
258
-		$response = gravityview_strip_whitespace( $response );
258
+		$response = gravityview_strip_whitespace($response);
259 259
 
260
-		$this->_exit( $response );
260
+		$this->_exit($response);
261 261
 	}
262 262
 
263 263
 	/**
@@ -274,23 +274,23 @@  discard block
 block discarded – undo
274 274
 		$form = '';
275 275
 
276 276
 		// if form id is set, use it, else, get form from preset
277
-		if( !empty( $_POST['form_id'] ) ) {
277
+		if (!empty($_POST['form_id'])) {
278 278
 
279
-			$form = (int) $_POST['form_id'];
279
+			$form = (int)$_POST['form_id'];
280 280
 
281 281
 		}
282 282
 		// get form from preset
283
-		elseif( !empty( $_POST['template_id'] ) ) {
283
+		elseif (!empty($_POST['template_id'])) {
284 284
 
285
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
285
+			$form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']);
286 286
 
287 287
 		}
288 288
 
289
-		$response = gravityview_get_sortable_fields( $form );
289
+		$response = gravityview_get_sortable_fields($form);
290 290
 
291
-		$response = gravityview_strip_whitespace( $response );
291
+		$response = gravityview_strip_whitespace($response);
292 292
 
293
-		$this->_exit( $response );
293
+		$this->_exit($response);
294 294
 	}
295 295
 
296 296
 	/**
@@ -298,35 +298,35 @@  discard block
 block discarded – undo
298 298
 	 * @param  string $template_id Preset template
299 299
 	 *
300 300
 	 */
301
-	static function pre_get_form_fields( $template_id = '') {
301
+	static function pre_get_form_fields($template_id = '') {
302 302
 
303
-		if( empty( $template_id ) ) {
304
-			do_action( 'gravityview_log_error', __METHOD__ . ' - Template ID not set.' );
303
+		if (empty($template_id)) {
304
+			do_action('gravityview_log_error', __METHOD__.' - Template ID not set.');
305 305
 			return false;
306 306
 		} else {
307
-			$form_file = apply_filters( 'gravityview_template_formxml', '', $template_id );
308
-			if( !file_exists( $form_file )  ) {
309
-				do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset ['. $template_id .']. File not found. file: ' . $form_file );
307
+			$form_file = apply_filters('gravityview_template_formxml', '', $template_id);
308
+			if (!file_exists($form_file)) {
309
+				do_action('gravityview_log_error', __METHOD__.' - Importing Form Fields for preset ['.$template_id.']. File not found. file: '.$form_file);
310 310
 				return false;
311 311
 			}
312 312
 		}
313 313
 
314 314
 		// Load xml parser (from GravityForms)
315
-		if( class_exists( 'GFCommon' ) ) {
316
-			$xml_parser = GFCommon::get_base_path() . '/xml.php';
315
+		if (class_exists('GFCommon')) {
316
+			$xml_parser = GFCommon::get_base_path().'/xml.php';
317 317
 		} else {
318
-			$xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php';
318
+			$xml_parser = trailingslashit(WP_PLUGIN_DIR).'gravityforms/xml.php';
319 319
 		}
320 320
 
321
-		if( file_exists( $xml_parser ) ) {
322
-			require_once( $xml_parser );
321
+		if (file_exists($xml_parser)) {
322
+			require_once($xml_parser);
323 323
 		} else {
324
-			do_action( 'gravityview_log_debug', __METHOD__ . ' - Gravity Forms XML Parser not found.', $xml_parser );
324
+			do_action('gravityview_log_debug', __METHOD__.' - Gravity Forms XML Parser not found.', $xml_parser);
325 325
 			return false;
326 326
 		}
327 327
 
328 328
 		// load file
329
-		$xmlstr = file_get_contents( $form_file );
329
+		$xmlstr = file_get_contents($form_file);
330 330
 
331 331
         $options = array(
332 332
             "page" => array("unserialize_as_array" => true),
@@ -345,21 +345,21 @@  discard block
 block discarded – undo
345 345
 		$xml = new RGXML($options);
346 346
         $forms = $xml->unserialize($xmlstr);
347 347
 
348
-        if( !$forms ) {
349
-        	do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file );
348
+        if (!$forms) {
349
+        	do_action('gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. Error importing file. (File)', $form_file);
350 350
         	return false;
351 351
         }
352 352
 
353
-        if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
353
+        if (!empty($forms[0]) && is_array($forms[0])) {
354 354
         	$form = $forms[0];
355 355
         }
356 356
 
357
-        if( empty( $form ) ) {
358
-        	do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms );
357
+        if (empty($form)) {
358
+        	do_action('gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms);
359 359
         	return false;
360 360
         }
361 361
 
362
-        do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form );
362
+        do_action('gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. (Form)', $form);
363 363
 
364 364
         return $form;
365 365
 
@@ -371,46 +371,46 @@  discard block
 block discarded – undo
371 371
 	 * @param  string $file path to file
372 372
 	 * @return array       Fields config array (unserialized)
373 373
 	 */
374
-	function import_fields( $file ) {
374
+	function import_fields($file) {
375 375
 
376
-		if( empty( $file ) || !file_exists(  $file ) ) {
377
-			do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file );
376
+		if (empty($file) || !file_exists($file)) {
377
+			do_action('gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file);
378 378
 			return false;
379 379
 		}
380 380
 
381
-		if( !class_exists('WXR_Parser') ) {
382
-			include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php';
381
+		if (!class_exists('WXR_Parser')) {
382
+			include_once GRAVITYVIEW_DIR.'includes/lib/xml-parsers/parsers.php';
383 383
 		}
384 384
 
385 385
 		$parser = new WXR_Parser();
386
-		$presets = $parser->parse( $file );
386
+		$presets = $parser->parse($file);
387 387
 
388
-		if(is_wp_error( $presets )) {
389
-			do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets );
388
+		if (is_wp_error($presets)) {
389
+			do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets);
390 390
 			return false;
391 391
 		}
392 392
 
393
-		if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) {
394
-			do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file );
393
+		if (empty($presets['posts'][0]['postmeta']) && !is_array($presets['posts'][0]['postmeta'])) {
394
+			do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file);
395 395
 			return false;
396 396
 		}
397 397
 
398
-		do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta'] );
398
+		do_action('gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta']);
399 399
 
400 400
 		$fields = $widgets = array();
401
-		foreach( $presets['posts'][0]['postmeta'] as $meta ) {
401
+		foreach ($presets['posts'][0]['postmeta'] as $meta) {
402 402
 			switch ($meta['key']) {
403 403
 				case '_gravityview_directory_fields':
404
-					$fields = maybe_unserialize( $meta['value'] );
404
+					$fields = maybe_unserialize($meta['value']);
405 405
 					break;
406 406
 				case '_gravityview_directory_widgets':
407
-					$widgets = maybe_unserialize( $meta['value'] );
407
+					$widgets = maybe_unserialize($meta['value']);
408 408
 					break;
409 409
 			}
410 410
 		}
411 411
 
412
-		do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields );
413
-		do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets );
412
+		do_action('gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields);
413
+		do_action('gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets);
414 414
 
415 415
 		return array(
416 416
 			'fields' => $fields,
Please login to merge, or discard this patch.
includes/class-frontend-views.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
 	/**
152 152
 	 * Sets the single entry ID and also the entry
153
-	 * @param bool|int $single_entry
153
+	 * @param boolean|string $single_entry
154 154
 	 */
155 155
 	public function setSingleEntry( $single_entry ) {
156 156
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 	/**
169 169
 	 * Set the current entry
170
-	 * @param array|int $entry Entry array or entry ID
170
+	 * @param boolean|string $entry Entry array or entry ID
171 171
 	 */
172 172
 	public function setEntry( $entry ) {
173 173
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 *
226 226
 	 *
227 227
 	 *
228
-	 * @param null $view_id
228
+	 * @param string $view_id
229 229
 	 */
230 230
 	public function set_context_view_id( $view_id = null ) {
231 231
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 	 *
935 935
 	 * @uses  gravityview_get_entries()
936 936
 	 * @access public
937
-	 * @param array $args\n
937
+	 * @param array $args
938 938
 	 *   - $id - View id
939 939
 	 *   - $page_size - Page
940 940
 	 *   - $sort_field - form field id to sort
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
 	/**
1365 1365
 	 * Checks if field (column) is sortable
1366 1366
 	 *
1367
-	 * @param string $field Field settings
1367
+	 * @param string $field_id Field settings
1368 1368
 	 * @param array $form Gravity Forms form array
1369 1369
 	 *
1370 1370
 	 * @since 1.7
Please login to merge, or discard this patch.
Spacing   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @since 1.7.4.1
21 21
 	 * @var array
22 22
 	 */
23
-	private static $search_parameters = array( 'gv_search', 'gv_start', 'gv_end', 'gv_id', 'gv_by', 'filter_*' );
23
+	private static $search_parameters = array('gv_search', 'gv_start', 'gv_end', 'gv_id', 'gv_by', 'filter_*');
24 24
 
25 25
 	/**
26 26
 	 * Is the currently viewed post a `gravityview` post type?
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
 	private function __construct() {}
86 86
 
87 87
 	private function initialize() {
88
-		add_action( 'wp', array( $this, 'parse_content'), 11 );
89
-		add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 );
88
+		add_action('wp', array($this, 'parse_content'), 11);
89
+		add_action('template_redirect', array($this, 'set_entry_data'), 1);
90 90
 
91 91
 		// Enqueue scripts and styles after GravityView_Template::register_styles()
92
-		add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 );
92
+		add_action('wp_enqueue_scripts', array($this, 'add_scripts_and_styles'), 20);
93 93
 
94 94
 		// Enqueue and print styles in the footer. Added 1 priorty so stuff gets printed at 10 priority.
95
-		add_action( 'wp_print_footer_scripts', array( $this, 'add_scripts_and_styles' ), 1 );
95
+		add_action('wp_print_footer_scripts', array($this, 'add_scripts_and_styles'), 1);
96 96
 
97
-		add_filter( 'the_title', array( $this, 'single_entry_title' ), 1, 2 );
98
-		add_filter( 'the_content', array( $this, 'insert_view_in_content' ) );
99
-		add_filter( 'comments_open', array( $this, 'comments_open' ), 10, 2 );
97
+		add_filter('the_title', array($this, 'single_entry_title'), 1, 2);
98
+		add_filter('the_content', array($this, 'insert_view_in_content'));
99
+		add_filter('comments_open', array($this, 'comments_open'), 10, 2);
100 100
 	}
101 101
 
102 102
 	/**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public static function getInstance() {
107 107
 
108
-		if ( empty( self::$instance ) ) {
108
+		if (empty(self::$instance)) {
109 109
 			self::$instance = new self;
110 110
 			self::$instance->initialize();
111 111
 		}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	/**
124 124
 	 * @param GravityView_View_Data $gv_output_data
125 125
 	 */
126
-	public function setGvOutputData( $gv_output_data ) {
126
+	public function setGvOutputData($gv_output_data) {
127 127
 		$this->gv_output_data = $gv_output_data;
128 128
 	}
129 129
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	/**
138 138
 	 * @param boolean $is_search
139 139
 	 */
140
-	public function setIsSearch( $is_search ) {
140
+	public function setIsSearch($is_search) {
141 141
 		$this->is_search = $is_search;
142 142
 	}
143 143
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * Sets the single entry ID and also the entry
153 153
 	 * @param bool|int $single_entry
154 154
 	 */
155
-	public function setSingleEntry( $single_entry ) {
155
+	public function setSingleEntry($single_entry) {
156 156
 
157 157
 		$this->single_entry = $single_entry;
158 158
 
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	 * Set the current entry
170 170
 	 * @param array|int $entry Entry array or entry ID
171 171
 	 */
172
-	public function setEntry( $entry ) {
172
+	public function setEntry($entry) {
173 173
 
174
-		if ( ! is_array( $entry ) ) {
175
-			$entry = GVCommon::get_entry( $entry );
174
+		if (!is_array($entry)) {
175
+			$entry = GVCommon::get_entry($entry);
176 176
 		}
177 177
 
178 178
 		$this->entry = $entry;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	/**
189 189
 	 * @param int $post_id
190 190
 	 */
191
-	public function setPostId( $post_id ) {
191
+	public function setPostId($post_id) {
192 192
 		$this->post_id = $post_id;
193 193
 	}
194 194
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	/**
203 203
 	 * @param boolean $post_has_shortcode
204 204
 	 */
205
-	public function setPostHasShortcode( $post_has_shortcode ) {
205
+	public function setPostHasShortcode($post_has_shortcode) {
206 206
 		$this->post_has_shortcode = $post_has_shortcode;
207 207
 	}
208 208
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	/**
217 217
 	 * @param boolean $is_gravityview_post_type
218 218
 	 */
219
-	public function setIsGravityviewPostType( $is_gravityview_post_type ) {
219
+	public function setIsGravityviewPostType($is_gravityview_post_type) {
220 220
 		$this->is_gravityview_post_type = $is_gravityview_post_type;
221 221
 	}
222 222
 
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @param null $view_id
229 229
 	 */
230
-	public function set_context_view_id( $view_id = null ) {
230
+	public function set_context_view_id($view_id = null) {
231 231
 
232
-		if ( ! empty( $view_id ) ) {
232
+		if (!empty($view_id)) {
233 233
 
234 234
 			$this->context_view_id = $view_id;
235 235
 
236
-		} elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) {
236
+		} elseif (isset($_GET['gvid']) && $this->getGvOutputData()->has_multiple_views()) {
237 237
 			/**
238 238
 			 * used on a has_multiple_views context
239 239
 			 * @see GravityView_API::entry_link
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
 			 */
242 242
 			$this->context_view_id = $_GET['gvid'];
243 243
 
244
-		} elseif ( ! $this->getGvOutputData()->has_multiple_views() )  {
245
-			$array_keys = array_keys( $this->getGvOutputData()->get_views() );
246
-			$this->context_view_id = array_pop( $array_keys );
247
-			unset( $array_keys );
244
+		} elseif (!$this->getGvOutputData()->has_multiple_views()) {
245
+			$array_keys = array_keys($this->getGvOutputData()->get_views());
246
+			$this->context_view_id = array_pop($array_keys);
247
+			unset($array_keys);
248 248
 		}
249 249
 
250 250
 	}
@@ -265,31 +265,31 @@  discard block
 block discarded – undo
265 265
 	 * @param  array  $wp Passed in the `wp` hook. Not used.
266 266
 	 * @return void
267 267
 	 */
268
-	function parse_content( $wp = array() ) {
268
+	function parse_content($wp = array()) {
269 269
 		global $post;
270 270
 
271 271
 		// If in admin and NOT AJAX request, get outta here.
272
-		if ( GravityView_Plugin::is_admin() )  {
272
+		if (GravityView_Plugin::is_admin()) {
273 273
 			return;
274 274
 		}
275 275
 
276 276
 		// Calculate requested Views
277
-		$this->setGvOutputData( GravityView_View_Data::getInstance( $post ) );
277
+		$this->setGvOutputData(GravityView_View_Data::getInstance($post));
278 278
 
279 279
 		// !important: we need to run this before getting single entry (to kick the advanced filter)
280 280
 		$this->set_context_view_id();
281 281
 
282
-		$this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' );
282
+		$this->setIsGravityviewPostType(get_post_type($post) === 'gravityview');
283 283
 
284
-		$post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null );
285
-		$this->setPostId( $post_id );
286
-		$post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false;
287
-		$this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) );
284
+		$post_id = $this->getPostId() ? $this->getPostId() : (isset($post) ? $post->ID : null);
285
+		$this->setPostId($post_id);
286
+		$post_has_shortcode = !empty($post->post_content) ? gravityview_has_shortcode_r($post->post_content, 'gravityview') : false;
287
+		$this->setPostHasShortcode($this->isGravityviewPostType() ? null : !empty($post_has_shortcode));
288 288
 
289 289
 		// check if the View is showing search results (only for multiple entries View)
290
-		$this->setIsSearch( $this->is_searching() );
290
+		$this->setIsSearch($this->is_searching());
291 291
 
292
-		unset( $entry, $post_id, $post_has_shortcode );
292
+		unset($entry, $post_id, $post_has_shortcode);
293 293
 	}
294 294
 
295 295
 	/**
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	function set_entry_data() {
299 299
 		$entry_id = self::is_single_entry();
300
-		$this->setSingleEntry( $entry_id );
301
-		$this->setEntry( $entry_id );
300
+		$this->setSingleEntry($entry_id);
301
+		$this->setEntry($entry_id);
302 302
 	}
303 303
 
304 304
 	/**
@@ -311,31 +311,31 @@  discard block
 block discarded – undo
311 311
 	function is_searching() {
312 312
 
313 313
 		// It's a single entry, not search
314
-		if ( $this->getSingleEntry() ) {
314
+		if ($this->getSingleEntry()) {
315 315
 			return false;
316 316
 		}
317 317
 
318 318
 		// No $_GET parameters
319
-		if ( empty( $_GET ) || ! is_array( $_GET ) ) {
319
+		if (empty($_GET) || !is_array($_GET)) {
320 320
 			return false;
321 321
 		}
322 322
 
323 323
 		// Remove empty values
324
-		$get = array_filter( $_GET );
324
+		$get = array_filter($_GET);
325 325
 
326 326
 		// If the $_GET parameters are empty, it's no search.
327
-		if ( empty( $get ) ) {
327
+		if (empty($get)) {
328 328
 			return false;
329 329
 		}
330 330
 
331
-		$search_keys = array_keys( $get );
331
+		$search_keys = array_keys($get);
332 332
 
333
-		$search_match = implode( '|', self::$search_parameters );
333
+		$search_match = implode('|', self::$search_parameters);
334 334
 
335
-		foreach ( $search_keys as $search_key ) {
335
+		foreach ($search_keys as $search_key) {
336 336
 
337 337
 			// Analyze the search key $_GET parameter and see if it matches known GV args
338
-			if ( preg_match( '/(' . $search_match . ')/i', $search_key ) ) {
338
+			if (preg_match('/('.$search_match.')/i', $search_key)) {
339 339
 				return true;
340 340
 			}
341 341
 		}
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
 	 * @param  int $passed_post_id Post ID
351 351
 	 * @return string          (modified) title
352 352
 	 */
353
-	public function single_entry_title( $title, $passed_post_id = null ) {
353
+	public function single_entry_title($title, $passed_post_id = null) {
354 354
 		global $post;
355 355
 
356 356
 		// If this is the directory view, return.
357
-		if ( ! $this->getSingleEntry() ) {
357
+		if (!$this->getSingleEntry()) {
358 358
 			return $title;
359 359
 		}
360 360
 
@@ -365,44 +365,44 @@  discard block
 block discarded – undo
365 365
 		 * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop
366 366
 		 * @param array $entry Current entry
367 367
 		 */
368
-		$apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry );
368
+		$apply_outside_loop = apply_filters('gravityview/single/title/out_loop', in_the_loop(), $entry);
369 369
 
370
-		if ( ! $apply_outside_loop ) {
370
+		if (!$apply_outside_loop) {
371 371
 			return $title;
372 372
 		}
373 373
 
374 374
 		// User reported WooCommerce doesn't pass two args.
375
-		if ( empty( $passed_post_id ) )  {
375
+		if (empty($passed_post_id)) {
376 376
 			return $title;
377 377
 		}
378 378
 
379 379
 		// Don't modify the title for anything other than the current view/post.
380 380
 		// This is true for embedded shortcodes and Views.
381
-		if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) {
381
+		if (is_object($post) && (int)$post->ID !== (int)$passed_post_id) {
382 382
 			return $title;
383 383
 		}
384 384
 
385 385
 		$context_view_id = $this->get_context_view_id();
386 386
 
387
-		if ( $this->getGvOutputData()->has_multiple_views() && ! empty( $context_view_id ) ) {
388
-			$view_meta = $this->getGvOutputData()->get_view( $context_view_id );
387
+		if ($this->getGvOutputData()->has_multiple_views() && !empty($context_view_id)) {
388
+			$view_meta = $this->getGvOutputData()->get_view($context_view_id);
389 389
 		} else {
390
-			foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) {
391
-				if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) {
390
+			foreach ($this->getGvOutputData()->get_views() as $view_id => $view_data) {
391
+				if (intval($view_data['form_id']) === intval($entry['form_id'])) {
392 392
 					$view_meta = $view_data;
393 393
 					break;
394 394
 				}
395 395
 			}
396 396
 		}
397 397
 
398
-		if ( ! empty( $view_meta['atts']['single_title'] ) ) {
398
+		if (!empty($view_meta['atts']['single_title'])) {
399 399
 
400 400
 			$title = $view_meta['atts']['single_title'];
401 401
 
402 402
 			// We are allowing HTML in the fields, so no escaping the output
403
-			$title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry );
403
+			$title = GravityView_API::replace_variables($title, $view_meta['form'], $entry);
404 404
 
405
-			$title = do_shortcode( $title );
405
+			$title = do_shortcode($title);
406 406
 		}
407 407
 
408 408
 		return $title;
@@ -417,38 +417,38 @@  discard block
 block discarded – undo
417 417
 	 * @param mixed $content
418 418
 	 * @return string Add the View output into View CPT content
419 419
 	 */
420
-	public function insert_view_in_content( $content ) {
420
+	public function insert_view_in_content($content) {
421 421
 
422 422
 		// Plugins may run through the content in the header. WP SEO does this for its OpenGraph functionality.
423
-		if ( ! did_action( 'loop_start' ) ) {
423
+		if (!did_action('loop_start')) {
424 424
 
425
-			do_action( 'gravityview_log_debug', '[insert_view_in_content] Not processing yet: loop_start hasn\'t run yet. Current action:', current_filter() );
425
+			do_action('gravityview_log_debug', '[insert_view_in_content] Not processing yet: loop_start hasn\'t run yet. Current action:', current_filter());
426 426
 
427 427
 			return $content;
428 428
 		}
429 429
 
430 430
 		//	We don't want this filter to run infinite loop on any post content fields
431
-		remove_filter( 'the_content', array( $this, 'insert_view_in_content' ) );
431
+		remove_filter('the_content', array($this, 'insert_view_in_content'));
432 432
 
433 433
 		// Otherwise, this is called on the Views page when in Excerpt mode.
434
-		if ( is_admin() ) {
434
+		if (is_admin()) {
435 435
 			return $content;
436 436
 		}
437 437
 
438
-		if ( $this->isGravityviewPostType() ) {
438
+		if ($this->isGravityviewPostType()) {
439 439
 
440 440
 			/** @since 1.7.4 */
441
-			if ( is_preview() && ! gravityview_get_form_id( $this->post_id ) ) {
442
-				$content .= __( 'When using a Start Fresh template, you must save the View before a Preview is available.', 'gravityview' );
441
+			if (is_preview() && !gravityview_get_form_id($this->post_id)) {
442
+				$content .= __('When using a Start Fresh template, you must save the View before a Preview is available.', 'gravityview');
443 443
 			} else {
444
-				foreach ( $this->getGvOutputData()->get_views() as $view_id => $data ) {
445
-					$content .= $this->render_view( array( 'id' => $view_id ) );
444
+				foreach ($this->getGvOutputData()->get_views() as $view_id => $data) {
445
+					$content .= $this->render_view(array('id' => $view_id));
446 446
 				}
447 447
 			}
448 448
 		}
449 449
 
450 450
 		//	Add the filter back in
451
-		add_filter( 'the_content', array( $this, 'insert_view_in_content' ) );
451
+		add_filter('the_content', array($this, 'insert_view_in_content'));
452 452
 
453 453
 		return $content;
454 454
 	}
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
 	 * @param  int $post_id Post ID
460 460
 	 * @return boolean
461 461
 	 */
462
-	public function comments_open( $open, $post_id ) {
462
+	public function comments_open($open, $post_id) {
463 463
 
464
-		if ( $this->isGravityviewPostType() ) {
464
+		if ($this->isGravityviewPostType()) {
465 465
 			$open = false;
466 466
 		}
467 467
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 		 * @param  boolean $open Open or closed status
472 472
 		 * @param  int $post_id Post ID to set comment status for
473 473
 		 */
474
-		$open = apply_filters( 'gravityview/comments_open', $open, $post_id );
474
+		$open = apply_filters('gravityview/comments_open', $open, $post_id);
475 475
 
476 476
 		return $open;
477 477
 	}
@@ -498,55 +498,55 @@  discard block
 block discarded – undo
498 498
 	 *
499 499
 	 * @return string|null HTML output of a View, NULL if View isn't found
500 500
 	 */
501
-	public function render_view( $passed_args ) {
501
+	public function render_view($passed_args) {
502 502
 
503 503
 		// validate attributes
504
-		if ( empty( $passed_args['id'] ) ) {
505
-			do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args );
504
+		if (empty($passed_args['id'])) {
505
+			do_action('gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args);
506 506
 			return null;
507 507
 		}
508 508
 
509 509
 		// Solve problem when loading content via admin-ajax.php
510 510
 		// @hack
511
-		if ( ! $this->getGvOutputData() ) {
511
+		if (!$this->getGvOutputData()) {
512 512
 
513
-			do_action( 'gravityview_log_error', '[render_view] gv_output_data not defined; parsing content.', $passed_args );
513
+			do_action('gravityview_log_error', '[render_view] gv_output_data not defined; parsing content.', $passed_args);
514 514
 
515 515
 			$this->parse_content();
516 516
 		}
517 517
 
518 518
 		// Make 100% sure that we're dealing with a properly called situation
519
-		if ( ! is_object( $this->getGvOutputData() ) || ! is_callable( array( $this->getGvOutputData(), 'get_view' ) ) ) {
519
+		if (!is_object($this->getGvOutputData()) || !is_callable(array($this->getGvOutputData(), 'get_view'))) {
520 520
 
521
-			do_action( 'gravityview_log_error', '[render_view] gv_output_data not an object or get_view not callable.', $this->getGvOutputData() );
521
+			do_action('gravityview_log_error', '[render_view] gv_output_data not an object or get_view not callable.', $this->getGvOutputData());
522 522
 
523 523
 			return null;
524 524
 		}
525 525
 
526 526
 		$view_id = $passed_args['id'];
527 527
 
528
-		$view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args );
528
+		$view_data = $this->getGvOutputData()->get_view($view_id, $passed_args);
529 529
 
530
-		do_action( 'gravityview_log_debug', '[render_view] View Data: ', $view_data );
530
+		do_action('gravityview_log_debug', '[render_view] View Data: ', $view_data);
531 531
 
532
-		do_action( 'gravityview_log_debug', '[render_view] Init View. Arguments: ', $passed_args );
532
+		do_action('gravityview_log_debug', '[render_view] Init View. Arguments: ', $passed_args);
533 533
 
534 534
 		// The passed args were always winning, even if they were NULL.
535 535
 		// This prevents that. Filters NULL, FALSE, and empty strings.
536
-		$passed_args = array_filter( $passed_args, 'strlen' );
536
+		$passed_args = array_filter($passed_args, 'strlen');
537 537
 
538 538
 		//Override shortcode args over View template settings
539
-		$atts = wp_parse_args( $passed_args, $view_data['atts'] );
539
+		$atts = wp_parse_args($passed_args, $view_data['atts']);
540 540
 
541
-		do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts );
541
+		do_action('gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts);
542 542
 
543 543
 		// It's password protected and you need to log in.
544
-		if ( post_password_required( $view_id ) ) {
544
+		if (post_password_required($view_id)) {
545 545
 
546
-			do_action( 'gravityview_log_error', sprintf( '[render_view] Returning: View %d is password protected.', $view_id ) );
546
+			do_action('gravityview_log_error', sprintf('[render_view] Returning: View %d is password protected.', $view_id));
547 547
 
548 548
 			// If we're in an embed or on an archive page, show the password form
549
-			if ( get_the_ID() !== $view_id ) {
549
+			if (get_the_ID() !== $view_id) {
550 550
 				return get_the_password_form();
551 551
 			}
552 552
 
@@ -558,11 +558,11 @@  discard block
 block discarded – undo
558 558
 		 * Don't render View if user isn't allowed to see it
559 559
 		 * @since 1.15
560 560
 		 */
561
-		if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
561
+		if (is_user_logged_in() && false === GVCommon::has_cap('read_gravityview', $view_id)) {
562 562
 			return null;
563 563
 		}
564 564
 
565
-		if( $this->isGravityviewPostType() ) {
565
+		if ($this->isGravityviewPostType()) {
566 566
 
567 567
 			/**
568 568
 			 * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode?
@@ -572,12 +572,12 @@  discard block
 block discarded – undo
572 572
 			 * @param[in,out] boolean `true`: allow Views to be accessible directly. `false`: Only allow Views to be embedded via shortcode. Default: `true`
573 573
 			 * @param int $view_id The ID of the View currently being requested. `0` for general setting
574 574
 			 */
575
-			$direct_access = apply_filters( 'gravityview_direct_access', true, $view_id );
575
+			$direct_access = apply_filters('gravityview_direct_access', true, $view_id);
576 576
 
577
-			$embed_only = ! empty( $atts['embed_only'] );
577
+			$embed_only = !empty($atts['embed_only']);
578 578
 
579
-			if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) {
580
-				return __( 'You are not allowed to view this content.', 'gravityview' );
579
+			if (!$direct_access || ($embed_only && !GVCommon::has_cap('read_private_gravityviews'))) {
580
+				return __('You are not allowed to view this content.', 'gravityview');
581 581
 			}
582 582
 		}
583 583
 
@@ -589,137 +589,137 @@  discard block
 block discarded – undo
589 589
 		 */
590 590
 		global $gravityview_view;
591 591
 
592
-		$gravityview_view = new GravityView_View( $view_data );
592
+		$gravityview_view = new GravityView_View($view_data);
593 593
 
594
-		$post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId();
594
+		$post_id = !empty($atts['post_id']) ? intval($atts['post_id']) : $this->getPostId();
595 595
 
596
-		$gravityview_view->setPostId( $post_id );
596
+		$gravityview_view->setPostId($post_id);
597 597
 
598
-		if ( ! $this->getSingleEntry() ) {
598
+		if (!$this->getSingleEntry()) {
599 599
 
600 600
 			// user requested Directory View
601
-			do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' );
601
+			do_action('gravityview_log_debug', '[render_view] Executing Directory View');
602 602
 
603 603
 			//fetch template and slug
604
-			$view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' );
604
+			$view_slug = apply_filters('gravityview_template_slug_'.$view_data['template_id'], 'table', 'directory');
605 605
 
606
-			do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug );
606
+			do_action('gravityview_log_debug', '[render_view] View template slug: ', $view_slug);
607 607
 
608 608
 			/**
609 609
 			 * Disable fetching initial entries for views that don't need it (DataTables)
610 610
 			 */
611
-			$get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true );
611
+			$get_entries = apply_filters('gravityview_get_view_entries_'.$view_slug, true);
612 612
 
613 613
 			/**
614 614
 			 * Hide View data until search is performed
615 615
 			 * @since 1.5.4
616 616
 			 */
617
-			if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) {
618
-				$gravityview_view->setHideUntilSearched( true );
617
+			if (!empty($atts['hide_until_searched']) && !$this->isSearch()) {
618
+				$gravityview_view->setHideUntilSearched(true);
619 619
 				$get_entries = false;
620 620
 			}
621 621
 
622 622
 
623
-			if ( $get_entries ) {
623
+			if ($get_entries) {
624 624
 
625
-				if ( ! empty( $atts['sort_columns'] ) ) {
625
+				if (!empty($atts['sort_columns'])) {
626 626
 					// add filter to enable column sorting
627
-					add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 );
627
+					add_filter('gravityview/template/field_label', array($this, 'add_columns_sort_links'), 100, 3);
628 628
 				}
629 629
 
630
-				$view_entries = self::get_view_entries( $atts, $view_data['form_id'] );
630
+				$view_entries = self::get_view_entries($atts, $view_data['form_id']);
631 631
 
632
-				do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) );
632
+				do_action('gravityview_log_debug', sprintf('[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof($view_entries['entries'])));
633 633
 
634 634
 			} else {
635 635
 
636
-				$view_entries = array( 'count' => null, 'entries' => null, 'paging' => null );
636
+				$view_entries = array('count' => null, 'entries' => null, 'paging' => null);
637 637
 
638
-				do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' );
638
+				do_action('gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false');
639 639
 			}
640 640
 
641
-			$gravityview_view->setPaging( $view_entries['paging'] );
642
-			$gravityview_view->setContext( 'directory' );
643
-			$sections = array( 'header', 'body', 'footer' );
641
+			$gravityview_view->setPaging($view_entries['paging']);
642
+			$gravityview_view->setContext('directory');
643
+			$sections = array('header', 'body', 'footer');
644 644
 
645 645
 		} else {
646 646
 
647 647
 			// user requested Single Entry View
648
-			do_action( 'gravityview_log_debug', '[render_view] Executing Single View' );
648
+			do_action('gravityview_log_debug', '[render_view] Executing Single View');
649 649
 
650
-			do_action( 'gravityview_render_entry_'.$view_data['id'] );
650
+			do_action('gravityview_render_entry_'.$view_data['id']);
651 651
 
652 652
 			$entry = $this->getEntry();
653 653
 
654 654
 			// You are not permitted to view this entry.
655
-			if ( empty( $entry ) || ! self::is_entry_approved( $entry, $atts ) ) {
655
+			if (empty($entry) || !self::is_entry_approved($entry, $atts)) {
656 656
 
657
-				do_action( 'gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.' );
657
+				do_action('gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.');
658 658
 
659 659
 				/**
660 660
 				 * @since 1.6
661 661
 				 */
662
-				echo esc_attr( apply_filters( 'gravityview/render/entry/not_visible', __( 'You have attempted to view an entry that is not visible or may not exist.', 'gravityview' ) ) );
662
+				echo esc_attr(apply_filters('gravityview/render/entry/not_visible', __('You have attempted to view an entry that is not visible or may not exist.', 'gravityview')));
663 663
 
664 664
 				return null;
665 665
 			}
666 666
 
667 667
 			// We're in single view, but the view being processed is not the same view the single entry belongs to.
668 668
 			// important: do not remove this as it prevents fake attempts of displaying entries from other views/forms
669
-			if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) {
670
-				do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id );
669
+			if ($this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id()) {
670
+				do_action('gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '.$view_id);
671 671
 				return null;
672 672
 			}
673 673
 
674 674
 			//fetch template and slug
675
-			$view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' );
676
-			do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug );
675
+			$view_slug = apply_filters('gravityview_template_slug_'.$view_data['template_id'], 'table', 'single');
676
+			do_action('gravityview_log_debug', '[render_view] View single template slug: ', $view_slug);
677 677
 
678 678
 			//fetch entry detail
679 679
 			$view_entries['count'] = 1;
680 680
 			$view_entries['entries'][] = $entry;
681
-			do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] );
681
+			do_action('gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries']);
682 682
 
683
-			$back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null;
683
+			$back_link_label = isset($atts['back_link_label']) ? $atts['back_link_label'] : null;
684 684
 
685 685
 			// set back link label
686
-			$gravityview_view->setBackLinkLabel( $back_link_label );
687
-			$gravityview_view->setContext( 'single' );
688
-			$sections = array( 'single' );
686
+			$gravityview_view->setBackLinkLabel($back_link_label);
687
+			$gravityview_view->setContext('single');
688
+			$sections = array('single');
689 689
 
690 690
 		}
691 691
 
692 692
 		// add template style
693
-		self::add_style( $view_data['template_id'] );
693
+		self::add_style($view_data['template_id']);
694 694
 
695 695
 		// Prepare to render view and set vars
696
-		$gravityview_view->setEntries( $view_entries['entries'] );
697
-		$gravityview_view->setTotalEntries( $view_entries['count'] );
696
+		$gravityview_view->setEntries($view_entries['entries']);
697
+		$gravityview_view->setTotalEntries($view_entries['count']);
698 698
 
699 699
 		// If Edit
700
-		if ( 'edit' === gravityview_get_context() ) {
700
+		if ('edit' === gravityview_get_context()) {
701 701
 
702
-			do_action( 'gravityview_log_debug', '[render_view] Edit Entry ' );
702
+			do_action('gravityview_log_debug', '[render_view] Edit Entry ');
703 703
 
704
-			do_action( 'gravityview_edit_entry', $this->getGvOutputData() );
704
+			do_action('gravityview_edit_entry', $this->getGvOutputData());
705 705
 
706 706
 			return ob_get_clean();
707 707
 
708 708
 		} else {
709 709
 			// finaly we'll render some html
710
-			$sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] );
710
+			$sections = apply_filters('gravityview_render_view_sections', $sections, $view_data['template_id']);
711 711
 
712
-			do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections );
713
-			foreach ( $sections as $section ) {
714
-				do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' );
715
-				$gravityview_view->render( $view_slug, $section, false );
712
+			do_action('gravityview_log_debug', '[render_view] Sections to render: ', $sections);
713
+			foreach ($sections as $section) {
714
+				do_action('gravityview_log_debug', '[render_view] Rendering '.$section.' section.');
715
+				$gravityview_view->render($view_slug, $section, false);
716 716
 			}
717 717
 		}
718 718
 
719 719
 		//@todo: check why we need the IF statement vs. print the view id always.
720
-		if ( $this->isGravityviewPostType() || $this->isPostHasShortcode() ) {
720
+		if ($this->isGravityviewPostType() || $this->isPostHasShortcode()) {
721 721
 			// Print the View ID to enable proper cookie pagination
722
-			echo '<input type="hidden" class="gravityview-view-id" value="' . esc_attr( $view_id ) . '">';
722
+			echo '<input type="hidden" class="gravityview-view-id" value="'.esc_attr($view_id).'">';
723 723
 		}
724 724
 		$output = ob_get_clean();
725 725
 
@@ -741,23 +741,23 @@  discard block
 block discarded – undo
741 741
 	 * @param  array      $search_criteria Search being performed, if any
742 742
 	 * @return array                       Modified `$search_criteria` array
743 743
 	 */
744
-	public static function process_search_dates( $args, $search_criteria = array() ) {
744
+	public static function process_search_dates($args, $search_criteria = array()) {
745 745
 
746 746
 		$return_search_criteria = $search_criteria;
747 747
 
748
-		foreach ( array( 'start_date', 'end_date' ) as $key ) {
748
+		foreach (array('start_date', 'end_date') as $key) {
749 749
 
750 750
 
751 751
 			// Is the start date or end date set in the view or shortcode?
752 752
 			// If so, we want to make sure that the search doesn't go outside the bounds defined.
753
-			if ( ! empty( $args[ $key ] ) ) {
753
+			if (!empty($args[$key])) {
754 754
 
755 755
 				// Get a timestamp and see if it's a valid date format
756
-				$date = strtotime( $args[ $key ] );
756
+				$date = strtotime($args[$key]);
757 757
 
758 758
 				// The date was invalid
759
-				if ( empty( $date ) ) {
760
-					do_action( 'gravityview_log_error', __METHOD__ . ' Invalid ' . $key . ' date format: ' . $args[ $key ] );
759
+				if (empty($date)) {
760
+					do_action('gravityview_log_error', __METHOD__.' Invalid '.$key.' date format: '.$args[$key]);
761 761
 					continue;
762 762
 				}
763 763
 
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
 				$datetime_format = 'Y-m-d H:i:s';
766 766
 				$search_is_outside_view_bounds = false;
767 767
 
768
-				if( ! empty( $search_criteria[ $key ] ) ) {
768
+				if (!empty($search_criteria[$key])) {
769 769
 
770
-					$search_date = strtotime( $search_criteria[ $key ] );
770
+					$search_date = strtotime($search_criteria[$key]);
771 771
 
772 772
 					// The search is for entries before the start date defined by the settings
773
-					switch ( $key ) {
773
+					switch ($key) {
774 774
 						case 'end_date':
775 775
 							/**
776 776
 							 * If the end date is formatted as 'Y-m-d', it should be formatted without hours and seconds
@@ -780,28 +780,28 @@  discard block
 block discarded – undo
780 780
 							 *
781 781
 							 * @see GFFormsModel::get_date_range_where
782 782
 							 */
783
-							$datetime_format               = gravityview_is_valid_datetime( $args[ $key ] ) ? 'Y-m-d' : 'Y-m-d H:i:s';
784
-							$search_is_outside_view_bounds = ( $search_date > $date );
783
+							$datetime_format               = gravityview_is_valid_datetime($args[$key]) ? 'Y-m-d' : 'Y-m-d H:i:s';
784
+							$search_is_outside_view_bounds = ($search_date > $date);
785 785
 							break;
786 786
 						case 'start_date':
787
-							$search_is_outside_view_bounds = ( $search_date < $date );
787
+							$search_is_outside_view_bounds = ($search_date < $date);
788 788
 							break;
789 789
 					}
790 790
 				}
791 791
 
792 792
 				// If there is no search being performed, or if there is a search being performed that's outside the bounds
793
-				if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) {
793
+				if (empty($search_criteria[$key]) || $search_is_outside_view_bounds) {
794 794
 
795 795
 					// Then we override the search and re-set the start date
796
-					$return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true );
796
+					$return_search_criteria[$key] = date_i18n($datetime_format, $date, true);
797 797
 				}
798 798
 			}
799 799
 		}
800 800
 
801
-		if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) {
801
+		if (isset($return_search_criteria['start_date']) && isset($return_search_criteria['end_date'])) {
802 802
 			// The start date is AFTER the end date. This will result in no results, but let's not force the issue.
803
-			if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) {
804
-				do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria );
803
+			if (strtotime($return_search_criteria['start_date']) > strtotime($return_search_criteria['end_date'])) {
804
+				do_action('gravityview_log_error', __METHOD__.' Invalid search: the start date is after the end date.', $return_search_criteria);
805 805
 			}
806 806
 		}
807 807
 
@@ -816,13 +816,13 @@  discard block
 block discarded – undo
816 816
 	 * @param  array      $search_criteria Search being performed, if any
817 817
 	 * @return array                       Modified `$search_criteria` array
818 818
 	 */
819
-	public static function process_search_only_approved( $args, $search_criteria ) {
819
+	public static function process_search_only_approved($args, $search_criteria) {
820 820
 
821
-		if ( ! empty( $args['show_only_approved'] ) ) {
822
-			$search_criteria['field_filters'][] = array( 'key' => 'is_approved', 'value' => 'Approved' );
821
+		if (!empty($args['show_only_approved'])) {
822
+			$search_criteria['field_filters'][] = array('key' => 'is_approved', 'value' => 'Approved');
823 823
 			$search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met
824 824
 
825
-			do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria );
825
+			do_action('gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria);
826 826
 		}
827 827
 
828 828
 		return $search_criteria;
@@ -842,16 +842,16 @@  discard block
 block discarded – undo
842 842
 	 *
843 843
 	 * @return bool
844 844
 	 */
845
-	public static function is_entry_approved( $entry, $args = array() ) {
845
+	public static function is_entry_approved($entry, $args = array()) {
846 846
 
847
-		if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) {
847
+		if (empty($entry['id']) || (array_key_exists('show_only_approved', $args) && !$args['show_only_approved'])) {
848 848
 			// is implicitly approved if entry is null or View settings doesn't require to check for approval
849 849
 			return true;
850 850
 		}
851 851
 
852
-		$is_approved = gform_get_meta( $entry['id'], 'is_approved' );
852
+		$is_approved = gform_get_meta($entry['id'], 'is_approved');
853 853
 
854
-		if ( $is_approved ) {
854
+		if ($is_approved) {
855 855
 			return true;
856 856
 		}
857 857
 
@@ -872,47 +872,47 @@  discard block
 block discarded – undo
872 872
 	 * @param  int $form_id Gravity Forms form ID
873 873
 	 * @return array          Array of search parameters, formatted in Gravity Forms mode, using `status` key set to "active" by default, `field_filters` array with `key`, `value` and `operator` keys.
874 874
 	 */
875
-	public static function get_search_criteria( $args, $form_id ) {
875
+	public static function get_search_criteria($args, $form_id) {
876 876
 
877 877
 		// Search Criteria
878
-		$search_criteria = apply_filters( 'gravityview_fe_search_criteria', array( 'field_filters' => array() ), $form_id );
878
+		$search_criteria = apply_filters('gravityview_fe_search_criteria', array('field_filters' => array()), $form_id);
879 879
 
880 880
 		$original_search_criteria = $search_criteria;
881 881
 
882
-		do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria );
882
+		do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria);
883 883
 
884 884
 		// implicity search
885
-		if ( ! empty( $args['search_value'] ) ) {
885
+		if (!empty($args['search_value'])) {
886 886
 
887 887
 			// Search operator options. Options: `is` or `contains`
888
-			$operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains';
888
+			$operator = !empty($args['search_operator']) && in_array($args['search_operator'], array('is', 'isnot', '>', '<', 'contains')) ? $args['search_operator'] : 'contains';
889 889
 
890 890
 			$search_criteria['field_filters'][] = array(
891
-				'key' => rgget( 'search_field', $args ), // The field ID to search
892
-				'value' => esc_attr( $args['search_value'] ), // The value to search
891
+				'key' => rgget('search_field', $args), // The field ID to search
892
+				'value' => esc_attr($args['search_value']), // The value to search
893 893
 				'operator' => $operator,
894 894
 			);
895 895
 		}
896 896
 
897
-		if( $search_criteria !== $original_search_criteria ) {
898
-			do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria );
897
+		if ($search_criteria !== $original_search_criteria) {
898
+			do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria);
899 899
 		}
900 900
 
901 901
 		// Handle setting date range
902
-		$search_criteria = self::process_search_dates( $args, $search_criteria );
902
+		$search_criteria = self::process_search_dates($args, $search_criteria);
903 903
 
904
-		if( $search_criteria !== $original_search_criteria ) {
905
-			do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria );
904
+		if ($search_criteria !== $original_search_criteria) {
905
+			do_action('gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria);
906 906
 		}
907 907
 
908 908
 		// remove not approved entries
909
-		$search_criteria = self::process_search_only_approved( $args, $search_criteria );
909
+		$search_criteria = self::process_search_only_approved($args, $search_criteria);
910 910
 
911 911
 		/**
912 912
 		 * @filter `gravityview_status` Modify entry status requirements to be included in search results.
913 913
 		 * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash`
914 914
 		 */
915
-		$search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args );
915
+		$search_criteria['status'] = apply_filters('gravityview_status', 'active', $args);
916 916
 
917 917
 		return $search_criteria;
918 918
 	}
@@ -946,29 +946,29 @@  discard block
 block discarded – undo
946 946
 	 * @param int $form_id Gravity Forms Form ID
947 947
 	 * @return array Associative array with `count`, `entries`, and `paging` keys. `count` has the total entries count, `entries` is an array with Gravity Forms full entry data, `paging` is an array with `offset` and `page_size` keys
948 948
 	 */
949
-	public static function get_view_entries( $args, $form_id ) {
949
+	public static function get_view_entries($args, $form_id) {
950 950
 
951
-		do_action( 'gravityview_log_debug', '[get_view_entries] init' );
951
+		do_action('gravityview_log_debug', '[get_view_entries] init');
952 952
 		// start filters and sorting
953 953
 
954 954
 		/**
955 955
 		 * Process search parameters
956 956
 		 * @var array
957 957
 		 */
958
-		$search_criteria = self::get_search_criteria( $args, $form_id );
958
+		$search_criteria = self::get_search_criteria($args, $form_id);
959 959
 
960 960
 		// Paging & offset
961
-		$page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : apply_filters( 'gravityview_default_page_size', 25 );
961
+		$page_size = !empty($args['page_size']) ? intval($args['page_size']) : apply_filters('gravityview_default_page_size', 25);
962 962
 
963 963
 		if ( -1 === $page_size ) {
964 964
 			$page_size = PHP_INT_MAX;
965 965
 		}
966 966
 
967
-		if ( isset( $args['offset'] ) ) {
968
-			$offset = intval( $args['offset'] );
967
+		if (isset($args['offset'])) {
968
+			$offset = intval($args['offset']);
969 969
 		} else {
970
-			$curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] );
971
-			$offset = ( $curr_page - 1 ) * $page_size;
970
+			$curr_page = empty($_GET['pagenum']) ? 1 : intval($_GET['pagenum']);
971
+			$offset = ($curr_page - 1) * $page_size;
972 972
 		}
973 973
 
974 974
 		$paging = array(
@@ -976,16 +976,16 @@  discard block
 block discarded – undo
976 976
 			'page_size' => $page_size,
977 977
 		);
978 978
 
979
-		do_action( 'gravityview_log_debug', '[get_view_entries] Paging: ', $paging );
979
+		do_action('gravityview_log_debug', '[get_view_entries] Paging: ', $paging);
980 980
 
981 981
 		// Sorting
982
-		$sorting = self::updateViewSorting( $args, $form_id );
982
+		$sorting = self::updateViewSorting($args, $form_id);
983 983
 
984 984
 		$parameters = array(
985 985
 			'search_criteria' => $search_criteria,
986 986
 			'sorting' => $sorting,
987 987
 			'paging' => $paging,
988
-			'cache' => isset( $args['cache'] ) ? $args['cache'] : true,
988
+			'cache' => isset($args['cache']) ? $args['cache'] : true,
989 989
 		);
990 990
 
991 991
 		/**
@@ -1003,22 +1003,22 @@  discard block
 block discarded – undo
1003 1003
 		 * }
1004 1004
 		 * @param int $form_id ID of Gravity Forms form
1005 1005
 		 */
1006
-		$parameters = apply_filters( 'gravityview_get_entries', $parameters, $args, $form_id );
1006
+		$parameters = apply_filters('gravityview_get_entries', $parameters, $args, $form_id);
1007 1007
 
1008 1008
 		/**
1009 1009
 		 * @filter `gravityview_get_entries_{View ID}` Filter get entries criteria
1010 1010
 		 * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys.
1011 1011
 		 * @param array $args View configuration args.
1012 1012
 		 */
1013
-		$parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id );
1013
+		$parameters = apply_filters('gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id);
1014 1014
 
1015
-		do_action( 'gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters );
1015
+		do_action('gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters);
1016 1016
 
1017 1017
 		//fetch entries
1018 1018
 		$count = 0;
1019
-		$entries = gravityview_get_entries( $form_id, $parameters, $count );
1019
+		$entries = gravityview_get_entries($form_id, $parameters, $count);
1020 1020
 
1021
-		do_action( 'gravityview_log_debug', sprintf( '[get_view_entries] Get Entries. Found: %s entries', $count ), $entries );
1021
+		do_action('gravityview_log_debug', sprintf('[get_view_entries] Get Entries. Found: %s entries', $count), $entries);
1022 1022
 
1023 1023
 		/**
1024 1024
 		 * @filter `gravityview_view_entries` Filter the entries output to the View
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 		 * @param array $args View settings associative array
1027 1027
 		 * @var array
1028 1028
 		 */
1029
-		$entries = apply_filters( 'gravityview_view_entries', $entries, $args );
1029
+		$entries = apply_filters('gravityview_view_entries', $entries, $args);
1030 1030
 
1031 1031
 		/**
1032 1032
 		 * @filter `gravityview/view/entries` Filter the entries output to the View
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 		 * @param array $args View settings associative array
1035 1035
 		 * @since 1.5.2
1036 1036
 		 */
1037
-		return apply_filters( 'gravityview/view/entries', compact( 'count', 'entries', 'paging' ), $args );
1037
+		return apply_filters('gravityview/view/entries', compact('count', 'entries', 'paging'), $args);
1038 1038
 
1039 1039
 	}
1040 1040
 
@@ -1048,24 +1048,24 @@  discard block
 block discarded – undo
1048 1048
 	 * @param int $form_id The ID of the form used to sort
1049 1049
 	 * @return array $sorting Array with `key`, `direction` and `is_numeric` keys
1050 1050
 	 */
1051
-	public static function updateViewSorting( $args, $form_id ) {
1051
+	public static function updateViewSorting($args, $form_id) {
1052 1052
 		$sorting = array();
1053
-		$sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' );
1054
-		$sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' );
1053
+		$sort_field_id = isset($_GET['sort']) ? $_GET['sort'] : rgar($args, 'sort_field');
1054
+		$sort_direction = isset($_GET['dir']) ? $_GET['dir'] : rgar($args, 'sort_direction');
1055 1055
 
1056
-		$sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id );
1056
+		$sort_field_id = self::_override_sorting_id_by_field_type($sort_field_id, $form_id);
1057 1057
 
1058
-		if ( ! empty( $sort_field_id ) ) {
1058
+		if (!empty($sort_field_id)) {
1059 1059
 			$sorting = array(
1060 1060
 				'key' => $sort_field_id,
1061
-				'direction' => strtolower( $sort_direction ),
1062
-				'is_numeric' => GVCommon::is_field_numeric( $form_id, $sort_field_id )
1061
+				'direction' => strtolower($sort_direction),
1062
+				'is_numeric' => GVCommon::is_field_numeric($form_id, $sort_field_id)
1063 1063
 			);
1064 1064
 		}
1065 1065
 
1066
-		GravityView_View::getInstance()->setSorting( $sorting );
1066
+		GravityView_View::getInstance()->setSorting($sorting);
1067 1067
 
1068
-		do_action( 'gravityview_log_debug', '[updateViewSorting] Sort Criteria : ', $sorting );
1068
+		do_action('gravityview_log_debug', '[updateViewSorting] Sort Criteria : ', $sorting);
1069 1069
 
1070 1070
 		return $sorting;
1071 1071
 
@@ -1085,17 +1085,17 @@  discard block
 block discarded – undo
1085 1085
 	 *
1086 1086
 	 * @return string Possibly modified sorting ID
1087 1087
 	 */
1088
-	private static function _override_sorting_id_by_field_type( $sort_field_id, $form_id ) {
1088
+	private static function _override_sorting_id_by_field_type($sort_field_id, $form_id) {
1089 1089
 
1090
-		$form = gravityview_get_form( $form_id );
1090
+		$form = gravityview_get_form($form_id);
1091 1091
 
1092
-		$sort_field = GFFormsModel::get_field( $form, $sort_field_id );
1092
+		$sort_field = GFFormsModel::get_field($form, $sort_field_id);
1093 1093
 
1094
-		switch ( $sort_field['type'] ) {
1094
+		switch ($sort_field['type']) {
1095 1095
 
1096 1096
 			case 'address':
1097 1097
 				// Sorting by full address
1098
-				if ( floatval( $sort_field_id ) === floor( $sort_field_id ) ) {
1098
+				if (floatval($sort_field_id) === floor($sort_field_id)) {
1099 1099
 
1100 1100
 					/**
1101 1101
 					 * Override how to sort when sorting address
@@ -1106,9 +1106,9 @@  discard block
 block discarded – undo
1106 1106
 					 * @param string $sort_field_id Field used for sorting
1107 1107
 					 * @param int $form_id GF Form ID
1108 1108
 					 */
1109
-					$address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id );
1109
+					$address_part = apply_filters('gravityview/sorting/address', 'city', $sort_field_id, $form_id);
1110 1110
 
1111
-					switch( strtolower( $address_part ) ){
1111
+					switch (strtolower($address_part)) {
1112 1112
 						case 'street':
1113 1113
 							$sort_field_id .= '.1';
1114 1114
 							break;
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 				break;
1135 1135
 			case 'name':
1136 1136
 				// Sorting by full name, not first, last, etc.
1137
-				if ( floatval( $sort_field_id ) === floor( $sort_field_id ) ) {
1137
+				if (floatval($sort_field_id) === floor($sort_field_id)) {
1138 1138
 					/**
1139 1139
 					 * @filter `gravityview/sorting/full-name` Override how to sort when sorting full name.
1140 1140
 					 * @since 1.7.4
@@ -1142,9 +1142,9 @@  discard block
 block discarded – undo
1142 1142
 					 * @param[in] string $sort_field_id Field used for sorting
1143 1143
 					 * @param[in] int $form_id GF Form ID
1144 1144
 					 */
1145
-					$name_part = apply_filters( 'gravityview/sorting/full-name', 'first', $sort_field_id, $form_id );
1145
+					$name_part = apply_filters('gravityview/sorting/full-name', 'first', $sort_field_id, $form_id);
1146 1146
 
1147
-					if ( 'last' === strtolower( $name_part ) ) {
1147
+					if ('last' === strtolower($name_part)) {
1148 1148
 						$sort_field_id .= '.6';
1149 1149
 					} else {
1150 1150
 						$sort_field_id .= '.3';
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 				 * @param[in,out] string $name_part Field used for sorting
1164 1164
 				 * @param[in] int $form_id GF Form ID
1165 1165
 				 */
1166
-				$sort_field_id = apply_filters( 'gravityview/sorting/time', $sort_field_id, $form_id );
1166
+				$sort_field_id = apply_filters('gravityview/sorting/time', $sort_field_id, $form_id);
1167 1167
 				break;
1168 1168
 		}
1169 1169
 
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 
1179 1179
 		$var_name = GravityView_Post_Types::get_entry_var_name();
1180 1180
 
1181
-		$single_entry = get_query_var( $var_name );
1181
+		$single_entry = get_query_var($var_name);
1182 1182
 
1183 1183
 		/**
1184 1184
 		 * Modify the entry that is being displayed.
@@ -1186,9 +1186,9 @@  discard block
 block discarded – undo
1186 1186
 		 * @internal Should only be used by things like the oEmbed functionality.
1187 1187
 		 * @since 1.6
1188 1188
 		 */
1189
-		$single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry );
1189
+		$single_entry = apply_filters('gravityview/is_single_entry', $single_entry);
1190 1190
 
1191
-		if ( empty( $single_entry ) ){
1191
+		if (empty($single_entry)) {
1192 1192
 			return false;
1193 1193
 		} else {
1194 1194
 			return $single_entry;
@@ -1205,38 +1205,38 @@  discard block
 block discarded – undo
1205 1205
 	public function add_scripts_and_styles() {
1206 1206
 		global $post, $posts;
1207 1207
 		// enqueue template specific styles
1208
-		if ( $this->getGvOutputData() ) {
1208
+		if ($this->getGvOutputData()) {
1209 1209
 
1210 1210
 			$views = $this->getGvOutputData()->get_views();
1211 1211
 
1212
-			foreach ( $views as $view_id => $data ) {
1212
+			foreach ($views as $view_id => $data) {
1213 1213
 
1214 1214
 				/**
1215 1215
 				 * Don't enqueue the scripts or styles if it's not going to be displayed.
1216 1216
 				 * @since 1.15
1217 1217
 				 */
1218
-				if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
1218
+				if (is_user_logged_in() && false === GVCommon::has_cap('read_gravityview', $view_id)) {
1219 1219
 					continue;
1220 1220
 				}
1221 1221
 
1222 1222
 				// By default, no thickbox
1223
-				$js_dependencies = array( 'jquery', 'gravityview-jquery-cookie' );
1223
+				$js_dependencies = array('jquery', 'gravityview-jquery-cookie');
1224 1224
 				$css_dependencies = array();
1225 1225
 
1226 1226
 				// If the thickbox is enqueued, add dependencies
1227
-				if ( ! empty( $data['atts']['lightbox'] ) ) {
1227
+				if (!empty($data['atts']['lightbox'])) {
1228 1228
 
1229 1229
 					/**
1230 1230
 					 * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox`
1231 1231
 					 * @param string $script_slug If you want to use a different lightbox script, return the name of it here.
1232 1232
 					 */
1233
-					$js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' );
1233
+					$js_dependencies[] = apply_filters('gravity_view_lightbox_script', 'thickbox');
1234 1234
 
1235 1235
 					/**
1236 1236
 					 * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox`
1237 1237
 					 * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here.
1238 1238
 					 */
1239
-					$css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' );
1239
+					$css_dependencies[] = apply_filters('gravity_view_lightbox_style', 'thickbox');
1240 1240
 				}
1241 1241
 
1242 1242
 				/**
@@ -1244,34 +1244,34 @@  discard block
 block discarded – undo
1244 1244
 				 * @see https://github.com/katzwebservices/GravityView/issues/536
1245 1245
 				 * @since 1.15
1246 1246
 				 */
1247
-				if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) {
1247
+				if (gravityview_view_has_single_checkbox_or_radio($data['form'], $data['fields'])) {
1248 1248
 					$css_dependencies[] = 'dashicons';
1249 1249
 				}
1250 1250
 
1251
-				wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true );
1251
+				wp_register_script('gravityview-jquery-cookie', plugins_url('includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE), array('jquery'), GravityView_Plugin::version, true);
1252 1252
 
1253
-				$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1253
+				$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
1254 1254
 
1255
-				wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true );
1255
+				wp_register_script('gravityview-fe-view', plugins_url('assets/js/fe-views'.$script_debug.'.js', GRAVITYVIEW_FILE), apply_filters('gravityview_js_dependencies', $js_dependencies), GravityView_Plugin::version, true);
1256 1256
 
1257
-				wp_enqueue_script( 'gravityview-fe-view' );
1257
+				wp_enqueue_script('gravityview-fe-view');
1258 1258
 
1259
-				if ( ! empty( $data['atts']['sort_columns'] ) ) {
1260
-					wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1259
+				if (!empty($data['atts']['sort_columns'])) {
1260
+					wp_enqueue_style('gravityview_font', plugins_url('assets/css/font.css', GRAVITYVIEW_FILE), $css_dependencies, GravityView_Plugin::version, 'all');
1261 1261
 				}
1262 1262
 
1263
-				wp_enqueue_style( 'gravityview_default_style', plugins_url( 'templates/css/gv-default-styles.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1263
+				wp_enqueue_style('gravityview_default_style', plugins_url('templates/css/gv-default-styles.css', GRAVITYVIEW_FILE), $css_dependencies, GravityView_Plugin::version, 'all');
1264 1264
 
1265
-				self::add_style( $data['template_id'] );
1265
+				self::add_style($data['template_id']);
1266 1266
 
1267 1267
 			}
1268 1268
 
1269
-			if ( 'wp_print_footer_scripts' === current_filter() ) {
1269
+			if ('wp_print_footer_scripts' === current_filter()) {
1270 1270
 
1271 1271
 				$js_localization = array(
1272 1272
 					'cookiepath' => COOKIEPATH,
1273
-					'clear' => _x( 'Clear', 'Clear all data from the form', 'gravityview' ),
1274
-					'reset' => _x( 'Reset', 'Reset the search form to the state that existed on page load', 'gravityview' ),
1273
+					'clear' => _x('Clear', 'Clear all data from the form', 'gravityview'),
1274
+					'reset' => _x('Reset', 'Reset the search form to the state that existed on page load', 'gravityview'),
1275 1275
 				);
1276 1276
 
1277 1277
 				/**
@@ -1279,9 +1279,9 @@  discard block
 block discarded – undo
1279 1279
 				 * @param array $js_localization The data padded to the Javascript file
1280 1280
 				 * @param array $views Array of View data arrays with View settings
1281 1281
 				 */
1282
-				$js_localization = apply_filters( 'gravityview_js_localization', $js_localization, $views );
1282
+				$js_localization = apply_filters('gravityview_js_localization', $js_localization, $views);
1283 1283
 
1284
-				wp_localize_script( 'gravityview-fe-view', 'gvGlobals', $js_localization );
1284
+				wp_localize_script('gravityview-fe-view', 'gvGlobals', $js_localization);
1285 1285
 			}
1286 1286
 		}
1287 1287
 	}
@@ -1290,15 +1290,15 @@  discard block
 block discarded – undo
1290 1290
 	 * Add template extra style if exists
1291 1291
 	 * @param string $template_id
1292 1292
 	 */
1293
-	public static function add_style( $template_id ) {
1293
+	public static function add_style($template_id) {
1294 1294
 
1295
-		if ( ! empty( $template_id ) && wp_style_is( 'gravityview_style_' . $template_id, 'registered' ) ) {
1296
-			do_action( 'gravityview_log_debug', sprintf( '[add_style] Adding extra template style for %s', $template_id ) );
1297
-			wp_enqueue_style( 'gravityview_style_' . $template_id );
1298
-		} elseif ( empty( $template_id ) ) {
1299
-			do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' );
1295
+		if (!empty($template_id) && wp_style_is('gravityview_style_'.$template_id, 'registered')) {
1296
+			do_action('gravityview_log_debug', sprintf('[add_style] Adding extra template style for %s', $template_id));
1297
+			wp_enqueue_style('gravityview_style_'.$template_id);
1298
+		} elseif (empty($template_id)) {
1299
+			do_action('gravityview_log_error', '[add_style] Cannot add template style; template_id is empty');
1300 1300
 		} else {
1301
-			do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) );
1301
+			do_action('gravityview_log_error', sprintf('[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id));
1302 1302
 		}
1303 1303
 
1304 1304
 	}
@@ -1317,17 +1317,17 @@  discard block
 block discarded – undo
1317 1317
 	 *
1318 1318
 	 * @return string Field Label
1319 1319
 	 */
1320
-	public function add_columns_sort_links( $label = '', $field, $form ) {
1320
+	public function add_columns_sort_links($label = '', $field, $form) {
1321 1321
 
1322 1322
 		/**
1323 1323
 		 * Not a table-based template; don't add sort icons
1324 1324
 		 * @since 1.12
1325 1325
 		 */
1326
-		if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) {
1326
+		if (!preg_match('/table/ism', GravityView_View::getInstance()->getTemplatePartSlug())) {
1327 1327
 			return $label;
1328 1328
 		}
1329 1329
 
1330
-		if ( ! $this->is_field_sortable( $field['id'], $form ) ) {
1330
+		if (!$this->is_field_sortable($field['id'], $form)) {
1331 1331
 			return $label;
1332 1332
 		}
1333 1333
 
@@ -1335,16 +1335,16 @@  discard block
 block discarded – undo
1335 1335
 
1336 1336
 		$class = 'gv-sort icon';
1337 1337
 
1338
-		$sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] );
1338
+		$sort_field_id = self::_override_sorting_id_by_field_type($field['id'], $form['id']);
1339 1339
 
1340 1340
 		$sort_args = array(
1341 1341
 			'sort' => $field['id'],
1342 1342
 			'dir' => 'asc',
1343 1343
 		);
1344 1344
 
1345
-		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
1345
+		if (!empty($sorting['key']) && (string)$sort_field_id === (string)$sorting['key']) {
1346 1346
 			//toggle sorting direction.
1347
-			if ( 'asc' === $sorting['direction'] ) {
1347
+			if ('asc' === $sorting['direction']) {
1348 1348
 				$sort_args['dir'] = 'desc';
1349 1349
 				$class .= ' gv-icon-sort-desc';
1350 1350
 			} else {
@@ -1355,9 +1355,9 @@  discard block
 block discarded – undo
1355 1355
 			$class .= ' gv-icon-caret-up-down';
1356 1356
 		}
1357 1357
 
1358
-		$url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) );
1358
+		$url = add_query_arg($sort_args, remove_query_arg(array('pagenum')));
1359 1359
 
1360
-		return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a>&nbsp;'. $label;
1360
+		return '<a href="'.esc_url_raw($url).'" class="'.$class.'" ></a>&nbsp;'.$label;
1361 1361
 
1362 1362
 	}
1363 1363
 
@@ -1371,12 +1371,12 @@  discard block
 block discarded – undo
1371 1371
 	 *
1372 1372
 	 * @return bool True: Yes, field is sortable; False: not sortable
1373 1373
 	 */
1374
-	public function is_field_sortable( $field_id = '', $form = array() ) {
1374
+	public function is_field_sortable($field_id = '', $form = array()) {
1375 1375
 
1376 1376
 		$field_type = $field_id;
1377 1377
 
1378
-		if( is_numeric( $field_id ) ) {
1379
-			$field = GFFormsModel::get_field( $form, $field_id );
1378
+		if (is_numeric($field_id)) {
1379
+			$field = GFFormsModel::get_field($form, $field_id);
1380 1380
 			$field_type = $field->type;
1381 1381
 		}
1382 1382
 
@@ -1392,13 +1392,13 @@  discard block
 block discarded – undo
1392 1392
 		 * @param string $field_type Field type to check whether the field is sortable
1393 1393
 		 * @param array $form Gravity Forms form
1394 1394
 		 */
1395
-		$not_sortable = apply_filters( 'gravityview/sortable/field_blacklist', $not_sortable, $field_type, $form );
1395
+		$not_sortable = apply_filters('gravityview/sortable/field_blacklist', $not_sortable, $field_type, $form);
1396 1396
 
1397
-		if ( in_array( $field_type, $not_sortable ) ) {
1397
+		if (in_array($field_type, $not_sortable)) {
1398 1398
 			return false;
1399 1399
 		}
1400 1400
 
1401
-		return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) );
1401
+		return apply_filters("gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters("gravityview/sortable/field_{$field_id}", true, $form));
1402 1402
 
1403 1403
 	}
1404 1404
 
Please login to merge, or discard this patch.
includes/class-gravityview-admin-duplicate-view.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@
 block discarded – undo
195 195
 	 *
196 196
 	 * @since 1.6
197 197
 	 *
198
-	 * @param int $new_view_id The ID of the newly created View
198
+	 * @param int $new_id The ID of the newly created View
199 199
 	 * @param WP_Post $post The View that was just cloned
200 200
 	 *
201 201
 	 * @return void
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 	function __construct() {
16 16
 
17 17
 		// Only run on Admin
18
-		if ( !is_admin() ) {
18
+		if (!is_admin()) {
19 19
 			return;
20 20
 		}
21 21
 
22 22
 		// If the Duplicate Post plugin is active, don't run.
23
-		if( defined('DUPLICATE_POST_CURRENT_VERSION') ) {
23
+		if (defined('DUPLICATE_POST_CURRENT_VERSION')) {
24 24
 			return;
25 25
 		}
26 26
 
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
 	 * @return void
34 34
 	 */
35 35
 	private function add_hooks() {
36
-		add_filter( 'post_row_actions', array( $this, 'make_duplicate_link_row' ), 10, 2 );
36
+		add_filter('post_row_actions', array($this, 'make_duplicate_link_row'), 10, 2);
37 37
 
38 38
 		/**
39 39
 		 * Connect actions to functions
40 40
 		 */
41
-		add_action( 'admin_action_duplicate_view', array( $this, 'save_as_new_view' ) );
42
-		add_action( 'admin_action_duplicate_view_as_draft', array( $this, 'save_as_new_view_draft' ) );
41
+		add_action('admin_action_duplicate_view', array($this, 'save_as_new_view'));
42
+		add_action('admin_action_duplicate_view_as_draft', array($this, 'save_as_new_view_draft'));
43 43
 
44 44
 		// Using our action hooks to copy meta fields
45
-		add_action( 'gv_duplicate_view', array( $this, 'copy_view_meta_info' ), 10, 2 );
45
+		add_action('gv_duplicate_view', array($this, 'copy_view_meta_info'), 10, 2);
46 46
 
47
-		add_filter( 'gravityview_connected_form_links', array( $this, 'connected_form_links' ), 10, 2 );
47
+		add_filter('gravityview_connected_form_links', array($this, 'connected_form_links'), 10, 2);
48 48
 	}
49 49
 
50 50
 	/**
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return array If it's the All Views page, return unedited. Otherwise, add a link to create cloned draft of View
57 57
 	 */
58
-	function connected_form_links( $links = array(), $form = array() ) {
58
+	function connected_form_links($links = array(), $form = array()) {
59 59
 		/** @global WP_Post $post */
60 60
 		global $post;
61 61
 
62 62
 		// We only want to add Clone links to the Edit View metabox
63
-		if( !$this->is_all_views_page() ) {
63
+		if (!$this->is_all_views_page()) {
64 64
 
65
-			if( $duplicate_links = $this->make_duplicate_link_row( array(), $post ) ) {
66
-				$links[] = '<span>' . $duplicate_links['edit_as_new_draft'] . '</span>';
65
+			if ($duplicate_links = $this->make_duplicate_link_row(array(), $post)) {
66
+				$links[] = '<span>'.$duplicate_links['edit_as_new_draft'].'</span>';
67 67
 			}
68 68
 
69 69
 		}
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @since 1.6
90 90
 	 */
91
-	private function current_user_can_copy( $post ) {
91
+	private function current_user_can_copy($post) {
92 92
 
93
-		$id = is_object( $post ) ? $post->ID : $post;
93
+		$id = is_object($post) ? $post->ID : $post;
94 94
 
95 95
 		// Can't edit this current View
96
-		return GVCommon::has_cap( 'copy_gravityviews', $id );
96
+		return GVCommon::has_cap('copy_gravityviews', $id);
97 97
 
98 98
 	}
99 99
 
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 	 * @param string $status The post status
105 105
 	 * @since 1.6
106 106
 	 */
107
-	private function create_duplicate( $post, $status = '' ) {
107
+	private function create_duplicate($post, $status = '') {
108 108
 
109 109
 		// We only want to clone Views
110
-		if ( $post->post_type !== 'gravityview' ) {
110
+		if ($post->post_type !== 'gravityview') {
111 111
 			return;
112 112
 		}
113 113
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		 * @param string|null If string, the status to set for the new View. If empty, use existing View status.
120 120
 		 * @param WP_Post $post View being cloned
121 121
 		 */
122
-		$new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post );
122
+		$new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post);
123 123
 
124 124
 		$new_view = array(
125 125
 			'menu_order'     => $post->menu_order,
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 			'post_mime_type' => $post->post_mime_type,
132 132
 			'post_parent'    => $post->post_parent,
133 133
 			'post_password'  => $post->post_password,
134
-			'post_status'    => ( empty( $new_view_status ) ) ? $post->post_status : $new_view_status,
134
+			'post_status'    => (empty($new_view_status)) ? $post->post_status : $new_view_status,
135 135
 			'post_title'     => $post->post_title,
136 136
 			'post_type'      => $post->post_type,
137 137
 		);
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 		 * @param boolean $copy_date Whether the copy the date from the existing View. Default: `false`
143 143
 		 * @param WP_Post $post View being cloned
144 144
 		 */
145
-		$copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post );
145
+		$copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post);
146 146
 
147
-		if ( $copy_date ) {
147
+		if ($copy_date) {
148 148
 			$new_view['post_date']     = $new_post_date = $post->post_date;
149
-			$new_view['post_date_gmt'] = get_gmt_from_date( $new_post_date );
149
+			$new_view['post_date_gmt'] = get_gmt_from_date($new_post_date);
150 150
 		}
151 151
 
152 152
 		/**
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 		 * @param array $new_view Array of settings to be passed to wp_insert_post()
156 156
 		 * @param WP_Post $post View being cloned
157 157
 		 */
158
-		$new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post );
158
+		$new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post);
159 159
 
160 160
 		// Magic happens here.
161
-		$new_view_id = wp_insert_post( $new_view );
161
+		$new_view_id = wp_insert_post($new_view);
162 162
 
163 163
 		// If the copy is published or scheduled, we have to set a proper slug.
164
-		if ( $new_view_status == 'publish' || $new_view_status == 'future' ) {
164
+		if ($new_view_status == 'publish' || $new_view_status == 'future') {
165 165
 
166
-			$view_name = wp_unique_post_slug( $post->post_name, $new_view_id, $new_view_status, $post->post_type, $post->post_parent );
166
+			$view_name = wp_unique_post_slug($post->post_name, $new_view_id, $new_view_status, $post->post_type, $post->post_parent);
167 167
 
168 168
 			$new_view_name_array = array(
169 169
 				'ID' => $new_view_id,
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 			);
172 172
 
173 173
 			// Update the post into the database
174
-			wp_update_post( $new_view_name_array );
174
+			wp_update_post($new_view_name_array);
175 175
 		}
176 176
 
177 177
 		/**
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 		 * @param int $new_view_id The ID of the newly created View
182 182
 		 * @param WP_Post The View that was just cloned
183 183
 		 */
184
-		do_action( 'gv_duplicate_view', $new_view_id, $post );
184
+		do_action('gv_duplicate_view', $new_view_id, $post);
185 185
 
186
-		delete_post_meta( $new_view_id, '_dp_original' );
186
+		delete_post_meta($new_view_id, '_dp_original');
187 187
 
188
-		add_post_meta( $new_view_id, '_dp_original', $post->ID, false );
188
+		add_post_meta($new_view_id, '_dp_original', $post->ID, false);
189 189
 
190 190
 		return $new_view_id;
191 191
 	}
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @return void
202 202
 	 */
203
-	public function copy_view_meta_info( $new_id, $post ) {
203
+	public function copy_view_meta_info($new_id, $post) {
204 204
 
205
-		$post_meta_keys = get_post_custom_keys( $post->ID );
205
+		$post_meta_keys = get_post_custom_keys($post->ID);
206 206
 
207
-		if ( empty( $post_meta_keys ) ) {
207
+		if (empty($post_meta_keys)) {
208 208
 			return;
209 209
 		}
210 210
 
211
-		foreach ( $post_meta_keys as $meta_key ) {
211
+		foreach ($post_meta_keys as $meta_key) {
212 212
 
213
-			$meta_values = get_post_custom_values( $meta_key, $post->ID );
213
+			$meta_values = get_post_custom_values($meta_key, $post->ID);
214 214
 
215
-			foreach ( $meta_values as $meta_value ) {
215
+			foreach ($meta_values as $meta_value) {
216 216
 
217
-				$meta_value = maybe_unserialize( $meta_value );
217
+				$meta_value = maybe_unserialize($meta_value);
218 218
 
219
-				add_post_meta( $new_id, $meta_key, $meta_value );
219
+				add_post_meta($new_id, $meta_key, $meta_value);
220 220
 			}
221 221
 		}
222 222
 	}
@@ -228,22 +228,22 @@  discard block
 block discarded – undo
228 228
 	 * @param array $actions Row action links. Defaults are 'Edit', 'Quick Edit', 'Restore, 'Trash', 'Delete Permanently', 'Preview', and 'View'
229 229
 	 * @param WP_Post $post
230 230
 	 */
231
-	public function make_duplicate_link_row( $actions, $post ) {
231
+	public function make_duplicate_link_row($actions, $post) {
232 232
 
233 233
 		// Only process on GravityView Views
234
-		if ( get_post_type( $post ) === 'gravityview' && $this->current_user_can_copy( $post ) ) {
234
+		if (get_post_type($post) === 'gravityview' && $this->current_user_can_copy($post)) {
235 235
 
236
-			$clone_link = $this->get_clone_view_link( $post->ID, 'display', false );
237
-			$clone_text = __( 'Clone', 'gravityview' );
238
-			$clone_title = __( 'Clone this View', 'gravityview' );
236
+			$clone_link = $this->get_clone_view_link($post->ID, 'display', false);
237
+			$clone_text = __('Clone', 'gravityview');
238
+			$clone_title = __('Clone this View', 'gravityview');
239 239
 
240
-			$actions['clone'] = gravityview_get_link( $clone_link, $clone_text, 'title='.$clone_title );
240
+			$actions['clone'] = gravityview_get_link($clone_link, $clone_text, 'title='.$clone_title);
241 241
 
242
-			$clone_draft_link = $this->get_clone_view_link( $post->ID );
243
-			$clone_draft_text = $this->is_all_views_page() ? __( 'New Draft', 'gravityview' ) : __( 'Clone View', 'gravityview' );
244
-			$clone_draft_title = __( 'Copy as a new draft View', 'gravityview' );
242
+			$clone_draft_link = $this->get_clone_view_link($post->ID);
243
+			$clone_draft_text = $this->is_all_views_page() ? __('New Draft', 'gravityview') : __('Clone View', 'gravityview');
244
+			$clone_draft_title = __('Copy as a new draft View', 'gravityview');
245 245
 
246
-			$actions['edit_as_new_draft'] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title='.$clone_draft_title );
246
+			$actions['edit_as_new_draft'] = gravityview_get_link($clone_draft_link, esc_html($clone_draft_text), 'title='.$clone_draft_title);
247 247
 		}
248 248
 
249 249
 		return $actions;
@@ -259,31 +259,31 @@  discard block
 block discarded – undo
259 259
 	 * @param string $draft Optional, default to true
260 260
 	 * @return string
261 261
 	 */
262
-	private function get_clone_view_link( $id = 0, $context = 'display', $draft = true ) {
262
+	private function get_clone_view_link($id = 0, $context = 'display', $draft = true) {
263 263
 
264 264
 		// Make sure they have permission
265
-		if ( false === $this->current_user_can_copy( $id ) ) {
265
+		if (false === $this->current_user_can_copy($id)) {
266 266
 			return '';
267 267
 		}
268 268
 
269 269
 		// Verify the View exists
270
-		if ( !$view = get_post( $id ) ) {
270
+		if (!$view = get_post($id)) {
271 271
 			return '';
272 272
 		}
273 273
 
274 274
 		$action_name = $draft ? "duplicate_view_as_draft" : "duplicate_view";
275 275
 
276
-		$action = '?action=' . $action_name . '&post=' . $view->ID;
276
+		$action = '?action='.$action_name.'&post='.$view->ID;
277 277
 
278
-		if ( 'display' == $context ) {
279
-			$action = esc_html( $action );
278
+		if ('display' == $context) {
279
+			$action = esc_html($action);
280 280
 		}
281 281
 
282
-		$post_type_object = get_post_type_object( $view->post_type );
282
+		$post_type_object = get_post_type_object($view->post_type);
283 283
 
284 284
 		/** If there's no gravityview post type for some reason, abort! */
285
-		if ( !$post_type_object ) {
286
-			do_action( 'gravityview_log_error', __METHOD__ . ' No gravityview post type exists when trying to clone the View.', $view );
285
+		if (!$post_type_object) {
286
+			do_action('gravityview_log_error', __METHOD__.' No gravityview post type exists when trying to clone the View.', $view);
287 287
 			return '';
288 288
 		}
289 289
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		 * @param int $view_id View ID
295 295
 		 * @param string $context How to display the link. If "display", the URL is run through esc_html(). Default: `display`
296 296
 		 */
297
-		$clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php". $action ), $view->ID, $context );
297
+		$clone_view_link = apply_filters('gravityview/duplicate-view/get_clone_view_link', admin_url("admin.php".$action), $view->ID, $context);
298 298
 
299 299
 		return $clone_view_link;
300 300
 	}
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @return void
309 309
 	 */
310 310
 	public function save_as_new_view_draft() {
311
-		$this->save_as_new_view( 'draft' );
311
+		$this->save_as_new_view('draft');
312 312
 	}
313 313
 
314 314
 	/**
@@ -319,38 +319,38 @@  discard block
 block discarded – undo
319 319
 	 * @param string $status The status to set for the new View
320 320
 	 * @return void
321 321
 	 */
322
-	public function save_as_new_view( $status = '' ) {
322
+	public function save_as_new_view($status = '') {
323 323
 
324
-		if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) ) ) {
325
-			wp_die( __( 'No post to duplicate has been supplied!', 'gravityview' ) );
324
+		if (!(isset($_GET['post']) || isset($_POST['post']))) {
325
+			wp_die(__('No post to duplicate has been supplied!', 'gravityview'));
326 326
 		}
327 327
 
328 328
 		// Get the original post
329
-		$id   = ( isset( $_GET['post'] ) ? $_GET['post'] : $_POST['post'] );
329
+		$id = (isset($_GET['post']) ? $_GET['post'] : $_POST['post']);
330 330
 
331
-		if( ! $this->current_user_can_copy( $id ) ) {
332
-			wp_die( __( 'You don\'t have permission to copy this View.', 'gravityview' ) );
331
+		if (!$this->current_user_can_copy($id)) {
332
+			wp_die(__('You don\'t have permission to copy this View.', 'gravityview'));
333 333
 		}
334 334
 
335
-		$post = get_post( $id );
335
+		$post = get_post($id);
336 336
 
337 337
 		// Copy the post and insert it
338
-		if ( isset( $post ) && $post != NULL ) {
338
+		if (isset($post) && $post != NULL) {
339 339
 
340
-			$new_id = $this->create_duplicate( $post, $status );
340
+			$new_id = $this->create_duplicate($post, $status);
341 341
 
342
-			if ( $status == '' ) {
342
+			if ($status == '') {
343 343
 				// Redirect to the post list screen
344
-				wp_redirect( admin_url( 'edit.php?post_type=' . $post->post_type ) );
344
+				wp_redirect(admin_url('edit.php?post_type='.$post->post_type));
345 345
 			} else {
346 346
 				// Redirect to the edit screen for the new draft post
347
-				wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_id ) );
347
+				wp_redirect(admin_url('post.php?action=edit&post='.$new_id));
348 348
 			}
349 349
 			exit;
350 350
 
351 351
 		} else {
352 352
 
353
-			wp_die( sprintf( esc_attr__( 'Copy creation failed, could not find original View with ID #%d', 'gravityview' ), $id ) );
353
+			wp_die(sprintf(esc_attr__('Copy creation failed, could not find original View with ID #%d', 'gravityview'), $id));
354 354
 
355 355
 		}
356 356
 	}
Please login to merge, or discard this patch.
includes/class-gravityview-compatibility.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
 
117 117
 	/**
118 118
 	 * @since 1.12
119
-	 * @return bool
119
+	 * @return boolean|null
120 120
 	 */
121 121
 	private function add_fallback_shortcode() {
122 122
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@
 block discarded – undo
204 204
 			self::$notices['wp_version'] = array(
205 205
 				'class' => 'error',
206 206
 				'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ),
207
-			    'cap' => 'update_core',
207
+				'cap' => 'update_core',
208 208
 				'dismiss' => 'wp_version',
209 209
 			);
210 210
 
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 	function add_hooks() {
59 59
 
60
-		add_filter( 'gravityview/admin/notices', array( $this, 'insert_admin_notices' ) );
60
+		add_filter('gravityview/admin/notices', array($this, 'insert_admin_notices'));
61 61
 
62 62
 		$this->add_fallback_shortcode();
63 63
 	}
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @return array
70 70
 	 */
71
-	function insert_admin_notices( $notices = array() ) {
72
-		return array_merge( $notices, self::$notices );
71
+	function insert_admin_notices($notices = array()) {
72
+		return array_merge($notices, self::$notices);
73 73
 	}
74 74
 
75 75
 	/**
76 76
 	 * @return GravityView_Compatibility
77 77
 	 */
78 78
 	public static function getInstance() {
79
-		if( self::$instance ) {
79
+		if (self::$instance) {
80 80
 			return self::$instance;
81 81
 		}
82 82
 		return new self;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @return bool
88 88
 	 */
89 89
 	public static function is_valid() {
90
-		return ( self::is_valid_gravity_forms() && self::is_valid_wordpress() && self::is_valid_php() );
90
+		return (self::is_valid_gravity_forms() && self::is_valid_wordpress() && self::is_valid_php());
91 91
 	}
92 92
 
93 93
 	/**
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 		// If Gravity Forms doesn't exist or is outdated, load the admin view class to
124 124
 		// show the notice, but not load any post types or process shortcodes.
125 125
 		// Without Gravity Forms, there is no GravityView. Beautiful, really.
126
-		if( ! self::is_valid() ) {
126
+		if (!self::is_valid()) {
127 127
 
128 128
 			// If the plugin's not loaded, might as well hide the shortcode for people.
129
-			add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice') );
129
+			add_shortcode('gravityview', array($this, '_shortcode_gf_notice'));
130 130
 
131 131
 		}
132 132
 	}
@@ -150,17 +150,17 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return null|string NULL returned if user can't activate plugins. Notice shown with a warning that GF isn't supported.
152 152
 	 */
153
-	public function _shortcode_gf_notice( $atts = array(), $content = null, $shortcode = 'gravityview' ) {
153
+	public function _shortcode_gf_notice($atts = array(), $content = null, $shortcode = 'gravityview') {
154 154
 
155
-		if( ! GVCommon::has_cap( 'activate_plugins' ) ) {
155
+		if (!GVCommon::has_cap('activate_plugins')) {
156 156
 			return null;
157 157
 		}
158 158
 
159 159
 		$notices = self::get_notices();
160 160
 
161
-		$message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview') . '</em></p>';
162
-		foreach( (array)$notices as $notice ) {
163
-			$message .= wpautop( $notice['message'] );
161
+		$message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>'.esc_html__('You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview').'</em></p>';
162
+		foreach ((array)$notices as $notice) {
163
+			$message .= wpautop($notice['message']);
164 164
 		}
165 165
 		$message .= '</div>';
166 166
 
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
 	 * @return boolean
176 176
 	 */
177 177
 	public static function check_php() {
178
-		if( false === version_compare( phpversion(), GV_MIN_PHP_VERSION , '>=' ) ) {
178
+		if (false === version_compare(phpversion(), GV_MIN_PHP_VERSION, '>=')) {
179 179
 
180 180
 			self::$notices['php_version'] = array(
181 181
 				'class' => 'error',
182
-				'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ),
182
+				'message' => sprintf(__("%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview'), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>'),
183 183
 				'cap' => 'manage_options',
184 184
 				'dismiss' => 'php_version',
185 185
 			);
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	public static function check_wordpress() {
200 200
 		global $wp_version;
201 201
 
202
-		if( version_compare( $wp_version, GV_MIN_WP_VERSION ) <= 0 ) {
202
+		if (version_compare($wp_version, GV_MIN_WP_VERSION) <= 0) {
203 203
 
204 204
 			self::$notices['wp_version'] = array(
205 205
 				'class' => 'error',
206
-				'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ),
206
+				'message' => sprintf(__("%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview'), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>'),
207 207
 			    'cap' => 'update_core',
208 208
 				'dismiss' => 'wp_version',
209 209
 			);
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
 	public static function check_gravityforms() {
227 227
 
228 228
 		// Bypass other checks: if the class exists
229
-		if( class_exists( 'GFCommon' ) ) {
229
+		if (class_exists('GFCommon')) {
230 230
 
231 231
 			// and the version's right, we're good.
232
-			if( true === version_compare( GFCommon::$version, GV_MIN_GF_VERSION, ">=" ) ) {
232
+			if (true === version_compare(GFCommon::$version, GV_MIN_GF_VERSION, ">=")) {
233 233
 				return true;
234 234
 			}
235 235
 
236 236
 			// Or the version's wrong
237 237
 			self::$notices['gf_version'] = array(
238 238
 				'class' => 'error',
239
-				'message' => sprintf( __( "%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at $39%s%s", 'gravityview' ), '<h3>', GV_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>', "\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'),
239
+				'message' => sprintf(__("%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at $39%s%s", 'gravityview'), '<h3>', GV_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>', "\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>'),
240 240
 				'cap' => 'update_plugins',
241 241
 				'dismiss' => 'gf_version',
242 242
 			);
@@ -244,40 +244,40 @@  discard block
 block discarded – undo
244 244
 			return false;
245 245
 		}
246 246
 
247
-		$gf_status = self::get_plugin_status( 'gravityforms/gravityforms.php' );
247
+		$gf_status = self::get_plugin_status('gravityforms/gravityforms.php');
248 248
 
249 249
 		/**
250 250
 		 * The plugin is activated and yet somehow GFCommon didn't get picked up...
251 251
 		 * OR
252 252
 		 * It's the Network Admin and we just don't know whether the sites have GF activated themselves.
253 253
 		 */
254
-		if( true === $gf_status || is_network_admin() ) {
254
+		if (true === $gf_status || is_network_admin()) {
255 255
 			return true;
256 256
 		}
257 257
 
258 258
 		// If GFCommon doesn't exist, assume GF not active
259 259
 		$return = false;
260 260
 
261
-		switch( $gf_status ) {
261
+		switch ($gf_status) {
262 262
 			case 'inactive':
263 263
 
264 264
 				// Required for multisite
265
-				if( ! function_exists('wp_create_nonce') ) {
266
-					require_once ABSPATH . WPINC . '/pluggable.php';
265
+				if (!function_exists('wp_create_nonce')) {
266
+					require_once ABSPATH.WPINC.'/pluggable.php';
267 267
 				}
268 268
 
269 269
 				// Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE"
270
-				if( is_multisite() ) {
270
+				if (is_multisite()) {
271 271
 					wp_cookie_constants();
272 272
 				}
273 273
 
274 274
 				$return = false;
275 275
 
276
-				$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php') . '" class="button button-large">';
276
+				$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="'.wp_nonce_url(admin_url('plugins.php?action=activate&plugin=gravityforms/gravityforms.php'), 'activate-plugin_gravityforms/gravityforms.php').'" class="button button-large">';
277 277
 
278 278
 				self::$notices['gf_inactive'] = array(
279 279
 					'class' => 'error',
280
-					'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n". $button, '</a></strong>' ),
280
+					'message' => sprintf(__('%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview'), '<h3>', "</h3>\n\n".$button, '</a></strong>'),
281 281
 					'cap' => 'activate_plugins',
282 282
 					'dismiss' => 'gf_inactive',
283 283
 				);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			default:
287 287
 				self::$notices['gf_installed'] = array(
288 288
 					'class' => 'error',
289
-					'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview' ), '<h3>', "</h3>\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'),
289
+					'message' => sprintf(__('%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview'), '<h3>', "</h3>\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>'),
290 290
 					'cap' => 'install_plugins',
291 291
 					'dismiss' => 'gf_installed',
292 292
 				);
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 	 */
304 304
 	private static function check_gf_directory() {
305 305
 
306
-		if( class_exists( 'GFDirectory' ) ) {
306
+		if (class_exists('GFDirectory')) {
307 307
 			self::$notices['gf_directory'] = array(
308 308
 				'class' => 'error is-dismissible',
309
-				'title' => __('Potential Conflict', 'gravityview' ),
310
-				'message' => __( 'GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview' ),
309
+				'title' => __('Potential Conflict', 'gravityview'),
310
+				'message' => __('GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview'),
311 311
 				'dismiss' => 'gf_directory',
312 312
 				'cap' => 'activate_plugins',
313 313
 			);
@@ -323,23 +323,23 @@  discard block
 block discarded – undo
323 323
 	 * @param string $location (default: '')
324 324
 	 * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive
325 325
 	 */
326
-	public static function get_plugin_status( $location = '' ) {
326
+	public static function get_plugin_status($location = '') {
327 327
 
328
-		if( ! function_exists('is_plugin_active') ) {
329
-			include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
328
+		if (!function_exists('is_plugin_active')) {
329
+			include_once(ABSPATH.'/wp-admin/includes/plugin.php');
330 330
 		}
331 331
 
332
-		if( is_network_admin() && is_plugin_active_for_network( $location ) ) {
332
+		if (is_network_admin() && is_plugin_active_for_network($location)) {
333 333
 			return true;
334 334
 		}
335 335
 
336
-		if( !is_network_admin() && is_plugin_active( $location ) ) {
336
+		if (!is_network_admin() && is_plugin_active($location)) {
337 337
 			return true;
338 338
 		}
339 339
 
340
-		if(
341
-			!file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
342
-			!file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
340
+		if (
341
+			!file_exists(trailingslashit(WP_PLUGIN_DIR).$location) &&
342
+			!file_exists(trailingslashit(WPMU_PLUGIN_DIR).$location)
343 343
 		) {
344 344
 			return false;
345 345
 		}
Please login to merge, or discard this patch.
includes/class-gravityview-entry-link-shortcode.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -221,7 +221,6 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @since 1.15
223 223
 	 *
224
-	 * @param string|null $content Content inside shortcode, if defined
225 224
 	 *
226 225
 	 * @return string|boolean If URL is fetched, the URL to the entry link. If not found, returns false.
227 226
 	 */
@@ -316,7 +315,7 @@  discard block
 block discarded – undo
316 315
 	 *
317 316
 	 * @since 1.15
318 317
 	 *
319
-	 * @param string $href URL
318
+	 * @param string|null $url
320 319
 	 */
321 320
 	private function maybe_add_field_values_query_args( $url ) {
322 321
 
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -51,17 +51,17 @@  discard block
 block discarded – undo
51 51
 	 * @since 1.15
52 52
 	 */
53 53
 	private function add_hooks() {
54
-		add_shortcode( 'gv_entry_link', array( $this, 'read_shortcode' ) );
55
-		add_shortcode( 'gv_edit_entry_link', array( $this, 'edit_shortcode' ) );
56
-		add_shortcode( 'gv_delete_entry_link', array( $this, 'delete_shortcode' ) );
54
+		add_shortcode('gv_entry_link', array($this, 'read_shortcode'));
55
+		add_shortcode('gv_edit_entry_link', array($this, 'edit_shortcode'));
56
+		add_shortcode('gv_delete_entry_link', array($this, 'delete_shortcode'));
57 57
 	}
58 58
 
59 59
 	/**
60 60
 	 * @since 1.15
61 61
 	 * @copydoc GravityView_Entry_Link_Shortcode::shortcode
62 62
 	 */
63
-	public function read_shortcode( $atts, $content = null, $context = 'gv_entry_link' ) {
64
-		return $this->shortcode( $atts, $content, $context );
63
+	public function read_shortcode($atts, $content = null, $context = 'gv_entry_link') {
64
+		return $this->shortcode($atts, $content, $context);
65 65
 	}
66 66
 
67 67
 	/**
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 	 * @since 1.15
72 72
 	 * @copydoc GravityView_Entry_Link_Shortcode::shortcode
73 73
 	 */
74
-	public function edit_shortcode( $atts, $content = null, $context = 'gv_edit_entry_link' ) {
74
+	public function edit_shortcode($atts, $content = null, $context = 'gv_edit_entry_link') {
75 75
 		$atts['action'] = 'edit';
76 76
 
77
-		return $this->shortcode( $atts, $content, $context );
77
+		return $this->shortcode($atts, $content, $context);
78 78
 	}
79 79
 
80 80
 	/**
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 	 * @since 1.15
85 85
 	 * @copydoc GravityView_Entry_Link_Shortcode::shortcode
86 86
 	 */
87
-	public function delete_shortcode( $atts, $content = null, $context = 'gv_delete_entry_link' ) {
87
+	public function delete_shortcode($atts, $content = null, $context = 'gv_delete_entry_link') {
88 88
 		$atts['action'] = 'delete';
89 89
 
90
-		return $this->shortcode( $atts, $content, $context );
90
+		return $this->shortcode($atts, $content, $context);
91 91
 	}
92 92
 
93 93
 	/**
@@ -110,58 +110,58 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return null|string If admin or an error occurred, returns null. Otherwise, returns entry link output. If `$atts['return']` is 'url', the entry link URL. Otherwise, entry link `<a>` HTML tag.
112 112
 	 */
113
-	private function shortcode( $atts, $content = null, $context = 'gv_entry_link' ) {
113
+	private function shortcode($atts, $content = null, $context = 'gv_entry_link') {
114 114
 
115 115
 		// Don't process when saving post. Keep processing if it's admin-ajax.php
116
-		if ( ! class_exists( 'GravityView_Plugin' ) || GravityView_Plugin::is_admin() ) {
116
+		if (!class_exists('GravityView_Plugin') || GravityView_Plugin::is_admin()) {
117 117
 			return null;
118 118
 		}
119 119
 
120 120
 		// Make sure GV is loaded
121
-		if ( ! class_exists( 'GravityView_frontend' ) || ! class_exists( 'GravityView_View' ) ) {
122
-			do_action( 'gravityview_log_error', __METHOD__ . ' GravityView_frontend or GravityView_View do not exist.' );
121
+		if (!class_exists('GravityView_frontend') || !class_exists('GravityView_View')) {
122
+			do_action('gravityview_log_error', __METHOD__.' GravityView_frontend or GravityView_View do not exist.');
123 123
 
124 124
 			return null;
125 125
 		}
126 126
 
127
-		$this->settings = shortcode_atts( self::$defaults, $atts, $context );
127
+		$this->settings = shortcode_atts(self::$defaults, $atts, $context);
128 128
 
129
-		$this->view_id = empty( $this->settings['view_id'] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings['view_id'] );
129
+		$this->view_id = empty($this->settings['view_id']) ? GravityView_View::getInstance()->getViewId() : absint($this->settings['view_id']);
130 130
 
131
-		if ( empty( $this->view_id ) ) {
132
-			do_action( 'gravityview_log_error', __METHOD__ . ' A View ID was not defined and we are not inside a View' );
131
+		if (empty($this->view_id)) {
132
+			do_action('gravityview_log_error', __METHOD__.' A View ID was not defined and we are not inside a View');
133 133
 
134 134
 			return null;
135 135
 		}
136 136
 
137
-		$this->entry = $this->get_entry( $this->settings['entry_id'] );
137
+		$this->entry = $this->get_entry($this->settings['entry_id']);
138 138
 
139
-		do_action( 'gravityview_log_debug', __METHOD__ . ' ' . $context . ' $atts: ', $atts );
139
+		do_action('gravityview_log_debug', __METHOD__.' '.$context.' $atts: ', $atts);
140 140
 
141
-		if ( ! $this->has_cap() ) {
142
-			do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the capability to ' . esc_attr( $this->settings['action'] ) . ' this entry: ' . $this->entry['id'] );
141
+		if (!$this->has_cap()) {
142
+			do_action('gravityview_log_error', __METHOD__.' User does not have the capability to '.esc_attr($this->settings['action']).' this entry: '.$this->entry['id']);
143 143
 
144 144
 			return null;
145 145
 		}
146 146
 
147 147
 		$url = $this->get_url();
148 148
 
149
-		if ( ! $url ) {
150
-			do_action( 'gravityview_log_error', __METHOD__ . ' Link returned false; View or Post may not exist.' );
149
+		if (!$url) {
150
+			do_action('gravityview_log_error', __METHOD__.' Link returned false; View or Post may not exist.');
151 151
 
152 152
 			return false;
153 153
 		}
154 154
 
155 155
 		// Get just the URL, not the tag
156
-		if ( 'url' === $this->settings['return'] ) {
156
+		if ('url' === $this->settings['return']) {
157 157
 			return $url;
158 158
 		}
159 159
 
160 160
 		$link_atts = $this->get_link_atts();
161 161
 
162
-		$link_text = $this->get_anchor_text( $content );
162
+		$link_text = $this->get_anchor_text($content);
163 163
 
164
-		return gravityview_get_link( $url, $link_text, $link_atts );
164
+		return gravityview_get_link($url, $link_text, $link_atts);
165 165
 	}
166 166
 
167 167
 	/**
@@ -174,13 +174,13 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	private function get_link_atts() {
176 176
 
177
-		wp_parse_str( $this->settings['link_atts'], $link_atts );
177
+		wp_parse_str($this->settings['link_atts'], $link_atts);
178 178
 
179
-		if ( 'delete' === $this->settings['action'] ) {
180
-			$link_atts['onclick'] = isset( $link_atts['onclick'] ) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog();
179
+		if ('delete' === $this->settings['action']) {
180
+			$link_atts['onclick'] = isset($link_atts['onclick']) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog();
181 181
 		}
182 182
 
183
-		return (array) $link_atts;
183
+		return (array)$link_atts;
184 184
 	}
185 185
 
186 186
 	/**
@@ -194,21 +194,21 @@  discard block
 block discarded – undo
194 194
 	 *
195 195
 	 * @return string Text to use for HTML anchor
196 196
 	 */
197
-	private function get_anchor_text( $content = null ) {
197
+	private function get_anchor_text($content = null) {
198 198
 
199
-		if ( $content ) {
199
+		if ($content) {
200 200
 			return $content;
201 201
 		}
202 202
 
203
-		switch ( $this->settings['action'] ) {
203
+		switch ($this->settings['action']) {
204 204
 			case 'edit':
205
-				$anchor_text = __( 'Edit Entry', 'gravityview' );
205
+				$anchor_text = __('Edit Entry', 'gravityview');
206 206
 				break;
207 207
 			case 'delete':
208
-				$anchor_text = __( 'Delete Entry', 'gravityview' );
208
+				$anchor_text = __('Delete Entry', 'gravityview');
209 209
 				break;
210 210
 			default:
211
-				$anchor_text = __( 'View Details', 'gravityview' );
211
+				$anchor_text = __('View Details', 'gravityview');
212 212
 		}
213 213
 
214 214
 		return $anchor_text;
@@ -228,21 +228,21 @@  discard block
 block discarded – undo
228 228
 	private function get_url() {
229 229
 
230 230
 		// if post_id is not defined, default to view_id
231
-		$post_id = empty( $this->settings['post_id'] ) ? $this->view_id : absint( $this->settings['post_id'] );
231
+		$post_id = empty($this->settings['post_id']) ? $this->view_id : absint($this->settings['post_id']);
232 232
 
233
-		switch ( $this->settings['action'] ) {
233
+		switch ($this->settings['action']) {
234 234
 			case 'edit':
235
-				$url = GravityView_Edit_Entry::get_edit_link( $this->entry, $this->view_id, $post_id );
235
+				$url = GravityView_Edit_Entry::get_edit_link($this->entry, $this->view_id, $post_id);
236 236
 				break;
237 237
 			case 'delete':
238
-				$url = GravityView_Delete_Entry::get_delete_link( $this->entry, $this->view_id, $post_id );
238
+				$url = GravityView_Delete_Entry::get_delete_link($this->entry, $this->view_id, $post_id);
239 239
 				break;
240 240
 			case 'read':
241 241
 			default:
242
-				$url = GravityView_API::entry_link( $this->entry, $post_id );
242
+				$url = GravityView_API::entry_link($this->entry, $post_id);
243 243
 		}
244 244
 
245
-		$url = $this->maybe_add_field_values_query_args( $url );
245
+		$url = $this->maybe_add_field_values_query_args($url);
246 246
 
247 247
 		return $url;
248 248
 	}
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
 	 */
256 256
 	private function has_cap() {
257 257
 
258
-		switch ( $this->settings['action'] ) {
258
+		switch ($this->settings['action']) {
259 259
 			case 'edit':
260
-				$has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry, $this->view_id );
260
+				$has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry($this->entry, $this->view_id);
261 261
 				break;
262 262
 			case 'delete':
263
-				$has_cap = GravityView_Delete_Entry::check_user_cap_delete_entry( $this->entry, array(), $this->view_id );
263
+				$has_cap = GravityView_Delete_Entry::check_user_cap_delete_entry($this->entry, array(), $this->view_id);
264 264
 				break;
265 265
 			case 'read':
266 266
 			default:
@@ -281,28 +281,28 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return array|bool Gravity Forms array, if found. Otherwise, false.
283 283
 	 */
284
-	private function get_entry( $entry_id = 0 ) {
284
+	private function get_entry($entry_id = 0) {
285 285
 
286 286
 		$backup_entry = GravityView_frontend::getInstance()->getSingleEntry() ? GravityView_frontend::getInstance()->getEntry() : GravityView_View::getInstance()->getCurrentEntry();
287 287
 
288
-		if ( empty( $entry_id ) ) {
289
-			if ( ! $backup_entry ) {
290
-				do_action( 'gravityview_log_error', __METHOD__ . ' No entry defined (or entry id not valid number)', $this->settings );
288
+		if (empty($entry_id)) {
289
+			if (!$backup_entry) {
290
+				do_action('gravityview_log_error', __METHOD__.' No entry defined (or entry id not valid number)', $this->settings);
291 291
 
292 292
 				return false;
293 293
 			}
294 294
 			$entry = $backup_entry;
295 295
 		} else {
296
-			$entry = wp_cache_get( 'gv_entry_link_entry_' . $entry_id, 'gravityview_entry_link_shortcode' );
297
-			if ( false === $entry ) {
298
-				$entry = GVCommon::get_entry( $entry_id, true, false );
299
-				wp_cache_add( 'gv_entry_link_entry_' . $entry_id, $entry, 'gravityview_entry_link_shortcode' );
296
+			$entry = wp_cache_get('gv_entry_link_entry_'.$entry_id, 'gravityview_entry_link_shortcode');
297
+			if (false === $entry) {
298
+				$entry = GVCommon::get_entry($entry_id, true, false);
299
+				wp_cache_add('gv_entry_link_entry_'.$entry_id, $entry, 'gravityview_entry_link_shortcode');
300 300
 			}
301 301
 		}
302 302
 
303 303
 		// No search results
304
-		if ( false === $entry ) {
305
-			do_action( 'gravityview_log_error', __METHOD__ . ' No entries match the entry ID defined', $entry_id );
304
+		if (false === $entry) {
305
+			do_action('gravityview_log_error', __METHOD__.' No entries match the entry ID defined', $entry_id);
306 306
 
307 307
 			return false;
308 308
 		}
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
 	 *
319 319
 	 * @param string $href URL
320 320
 	 */
321
-	private function maybe_add_field_values_query_args( $url ) {
321
+	private function maybe_add_field_values_query_args($url) {
322 322
 
323
-		if ( $url && ! empty( $this->settings['field_values'] ) ) {
323
+		if ($url && !empty($this->settings['field_values'])) {
324 324
 
325
-			wp_parse_str( $this->settings['field_values'], $field_values );
325
+			wp_parse_str($this->settings['field_values'], $field_values);
326 326
 
327
-			$url = add_query_arg( $field_values, $url );
327
+			$url = add_query_arg($field_values, $url);
328 328
 		}
329 329
 
330 330
 		return $url;
Please login to merge, or discard this patch.
includes/class-gravityview-extension.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@
 block discarded – undo
278 278
 
279 279
 	/**
280 280
 	 * Add a notice to be displayed in the admin.
281
-	 * @param array $notice Array with `class` and `message` keys. The message is not escaped.
281
+	 * @param string $notice Array with `class` and `message` keys. The message is not escaped.
282 282
 	 */
283 283
 	public static function add_notice( $notice = array() ) {
284 284
 
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -69,22 +69,22 @@  discard block
 block discarded – undo
69 69
 
70 70
 	function __construct() {
71 71
 
72
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
72
+		add_action('init', array($this, 'load_plugin_textdomain'));
73 73
 
74
-		add_action( 'admin_init', array( $this, 'settings') );
74
+		add_action('admin_init', array($this, 'settings'));
75 75
 
76
-		add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 );
76
+		add_action('admin_notices', array($this, 'admin_notice'), 100);
77 77
 
78
-		add_action( 'gravityview/metaboxes/before_render', array( $this, 'add_metabox_tab' ) );
78
+		add_action('gravityview/metaboxes/before_render', array($this, 'add_metabox_tab'));
79 79
 
80
-		if( false === $this->is_extension_supported() ) {
80
+		if (false === $this->is_extension_supported()) {
81 81
 			return;
82 82
 		}
83 83
 
84
-		add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) );
84
+		add_filter('gravityview_tooltips', array($this, 'tooltips'));
85 85
 
86 86
 		// Save the form configuration. Run at 14 so that View metadata is already saved (at 10)
87
-		add_action( 'save_post', array( $this, 'save_post' ), 14 );
87
+		add_action('save_post', array($this, 'save_post'), 14);
88 88
 
89 89
 		$this->add_hooks();
90 90
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		$tab_settings = $this->tab_settings();
117 117
 
118 118
 		// Don't add a tab if it's empty.
119
-		if( empty( $tab_settings ) ) {
119
+		if (empty($tab_settings)) {
120 120
 			return;
121 121
 		}
122 122
 
@@ -131,20 +131,20 @@  discard block
 block discarded – undo
131 131
 			'priority' => 'default',
132 132
 		);
133 133
 
134
-		$tab = wp_parse_args( $tab_settings, $tab_defaults );
134
+		$tab = wp_parse_args($tab_settings, $tab_defaults);
135 135
 
136 136
 		// Force the screen to be GravityView
137 137
 		$tab['screen'] = 'gravityview';
138 138
 
139
-		if( class_exists('GravityView_Metabox_Tab') ) {
139
+		if (class_exists('GravityView_Metabox_Tab')) {
140 140
 
141
-			$metabox = new GravityView_Metabox_Tab( $tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args'] );
141
+			$metabox = new GravityView_Metabox_Tab($tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args']);
142 142
 
143
-			GravityView_Metabox_Tabs::add( $metabox );
143
+			GravityView_Metabox_Tabs::add($metabox);
144 144
 
145 145
 		} else {
146 146
 
147
-			add_meta_box( 'gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority'] );
147
+			add_meta_box('gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority']);
148 148
 
149 149
 		}
150 150
 	}
@@ -160,37 +160,37 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function load_plugin_textdomain() {
162 162
 
163
-		if( empty( $this->_text_domain ) ) {
164
-			do_action( 'gravityview_log_debug', __METHOD__ . ': Extension translation cannot be loaded; the `_text_domain` variable is not defined', $this );
163
+		if (empty($this->_text_domain)) {
164
+			do_action('gravityview_log_debug', __METHOD__.': Extension translation cannot be loaded; the `_text_domain` variable is not defined', $this);
165 165
 			return;
166 166
 		}
167 167
 
168 168
 		// Backward compat for Ratings & Reviews / Maps
169
-		$path = isset( $this->_path ) ? $this->_path : ( isset( $this->plugin_file ) ? $this->plugin_file : '' );
169
+		$path = isset($this->_path) ? $this->_path : (isset($this->plugin_file) ? $this->plugin_file : '');
170 170
 
171 171
 		// Set filter for plugin's languages directory
172
-		$lang_dir = dirname( plugin_basename( $path ) ) . '/languages/';
172
+		$lang_dir = dirname(plugin_basename($path)).'/languages/';
173 173
 
174 174
 		// Traditional WordPress plugin locale filter
175
-		$locale = apply_filters( 'plugin_locale',  get_locale(), $this->_text_domain );
175
+		$locale = apply_filters('plugin_locale', get_locale(), $this->_text_domain);
176 176
 
177
-		$mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale );
177
+		$mofile = sprintf('%1$s-%2$s.mo', $this->_text_domain, $locale);
178 178
 
179 179
 		// Setup paths to current locale file
180
-		$mofile_local  = $lang_dir . $mofile;
181
-		$mofile_global = WP_LANG_DIR . '/' . $this->_text_domain . '/' . $mofile;
180
+		$mofile_local  = $lang_dir.$mofile;
181
+		$mofile_global = WP_LANG_DIR.'/'.$this->_text_domain.'/'.$mofile;
182 182
 
183
-		if ( file_exists( $mofile_global ) ) {
183
+		if (file_exists($mofile_global)) {
184 184
 			// Look in global /wp-content/languages/[plugin-dir]/ folder
185
-			load_textdomain( $this->_text_domain, $mofile_global );
185
+			load_textdomain($this->_text_domain, $mofile_global);
186 186
 		}
187
-		elseif ( file_exists( $mofile_local ) ) {
187
+		elseif (file_exists($mofile_local)) {
188 188
 			// Look in local /wp-content/plugins/[plugin-dir]/languages/ folder
189
-			load_textdomain( $this->_text_domain, $mofile_local );
189
+			load_textdomain($this->_text_domain, $mofile_local);
190 190
 		}
191 191
 		else {
192 192
 			// Load the default language files
193
-			load_plugin_textdomain( $this->_text_domain, false, $lang_dir );
193
+			load_plugin_textdomain($this->_text_domain, false, $lang_dir);
194 194
 		}
195 195
 	}
196 196
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	protected function get_license() {
204 204
 
205
-		if( !class_exists( 'GravityView_Settings' ) ) {
205
+		if (!class_exists('GravityView_Settings')) {
206 206
 			return false;
207 207
 		}
208 208
 
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
 	public function settings() {
220 220
 
221 221
 		// If doing ajax, get outta here
222
-		if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )  {
222
+		if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
223 223
 			return;
224 224
 		}
225 225
 
226
-		if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) {
226
+		if (!class_exists('EDD_SL_Plugin_Updater')) {
227 227
 
228
-			$file_path = plugin_dir_path( __FILE__ ) . 'lib/EDD_SL_Plugin_Updater.php';
228
+			$file_path = plugin_dir_path(__FILE__).'lib/EDD_SL_Plugin_Updater.php';
229 229
 
230 230
 			// This file may be in the lib/ directory already
231
-			if( ! file_exists( $file_path ) ) {
232
-				$file_path = plugin_dir_path( __FILE__ ) . '/EDD_SL_Plugin_Updater.php';
231
+			if (!file_exists($file_path)) {
232
+				$file_path = plugin_dir_path(__FILE__).'/EDD_SL_Plugin_Updater.php';
233 233
 			}
234 234
 
235 235
 			include_once $file_path;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		$license = $this->get_license();
239 239
 
240 240
 		// Don't update if invalid license.
241
-		if( false === $license || empty( $license['status'] ) || strtolower( $license['status'] ) !== 'valid' ) { return; }
241
+		if (false === $license || empty($license['status']) || strtolower($license['status']) !== 'valid') { return; }
242 242
 
243 243
 		new EDD_SL_Plugin_Updater(
244 244
 			$this->_remote_update_url,
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
             	'version'	=> $this->_version, // current version number
248 248
             	'license'	=> $license['license'],
249 249
 	            'item_id'   => $this->_item_id, // The ID of the download on _remote_update_url
250
-            	'item_name' => $this->_title,  // name of this plugin
251
-            	'author' 	=> strip_tags( $this->_author )  // author of this plugin
250
+            	'item_name' => $this->_title, // name of this plugin
251
+            	'author' 	=> strip_tags($this->_author)  // author of this plugin
252 252
           	)
253 253
         );
254 254
 	}
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	public function admin_notice() {
262 262
 
263
-		if( empty( self::$admin_notices ) ) {
263
+		if (empty(self::$admin_notices)) {
264 264
 			return;
265 265
 		}
266 266
 
267
-		foreach( self::$admin_notices as $key => $notice ) {
267
+		foreach (self::$admin_notices as $key => $notice) {
268 268
 
269
-			echo '<div id="message" class="'. esc_attr( $notice['class'] ).'">';
270
-			echo wpautop( $notice['message'] );
269
+			echo '<div id="message" class="'.esc_attr($notice['class']).'">';
270
+			echo wpautop($notice['message']);
271 271
 			echo '<div class="clear"></div>';
272 272
 			echo '</div>';
273 273
 		}
@@ -280,16 +280,16 @@  discard block
 block discarded – undo
280 280
 	 * Add a notice to be displayed in the admin.
281 281
 	 * @param array $notice Array with `class` and `message` keys. The message is not escaped.
282 282
 	 */
283
-	public static function add_notice( $notice = array() ) {
283
+	public static function add_notice($notice = array()) {
284 284
 
285
-		if( is_array( $notice ) && !isset( $notice['message'] ) ) {
286
-			do_action( 'gravityview_log_error', __CLASS__.'[add_notice] Notice not set', $notice );
285
+		if (is_array($notice) && !isset($notice['message'])) {
286
+			do_action('gravityview_log_error', __CLASS__.'[add_notice] Notice not set', $notice);
287 287
 			return;
288
-		} else if( is_string( $notice ) ) {
289
-			$notice = array( 'message' => $notice );
288
+		} else if (is_string($notice)) {
289
+			$notice = array('message' => $notice);
290 290
 		}
291 291
 
292
-		$notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class'];
292
+		$notice['class'] = empty($notice['class']) ? 'error' : $notice['class'];
293 293
 
294 294
 		self::$admin_notices[] = $notice;
295 295
 	}
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 * @param  int $post_id Post ID
305 305
 	 * @return void
306 306
 	 */
307
-	public function save_post( $post_id ) {}
307
+	public function save_post($post_id) {}
308 308
 
309 309
 	/**
310 310
 	 * Add tooltips for the extension.
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	 * @param  array  $tooltips Existing GV tooltips, with `title` and `value` keys
324 324
 	 * @return array           Modified tooltips
325 325
 	 */
326
-	public function tooltips( $tooltips = array() ) {
326
+	public function tooltips($tooltips = array()) {
327 327
 
328 328
 		return $tooltips;
329 329
 
@@ -346,17 +346,17 @@  discard block
 block discarded – undo
346 346
 
347 347
 		$message = '';
348 348
 
349
-		if( !class_exists( 'GravityView_Plugin' ) ) {
349
+		if (!class_exists('GravityView_Plugin')) {
350 350
 
351
-			$message = sprintf( __('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), $this->_title );
351
+			$message = sprintf(__('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), $this->_title);
352 352
 
353
-		} else if( false === version_compare(GravityView_Plugin::version, $this->_min_gravityview_version , ">=") ) {
353
+		} else if (false === version_compare(GravityView_Plugin::version, $this->_min_gravityview_version, ">=")) {
354 354
 
355
-			$message = sprintf( __('The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_gravityview_version.'</tt>' );
355
+			$message = sprintf(__('The %s Extension requires GravityView Version %s or newer.', 'gravityview'), $this->_title, '<tt>'.$this->_min_gravityview_version.'</tt>');
356 356
 
357
-		} else if( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version , ">=") ) {
357
+		} else if (isset($this->_min_php_version) && false === version_compare(phpversion(), $this->_min_php_version, ">=")) {
358 358
 
359
-			$message = sprintf( __('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_php_version.'</tt>' );
359
+			$message = sprintf(__('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview'), $this->_title, '<tt>'.$this->_min_php_version.'</tt>');
360 360
 
361 361
 		} else {
362 362
 
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
 
365 365
 		}
366 366
 
367
-		if ( ! empty( $message ) ) {
367
+		if (!empty($message)) {
368 368
 
369
-			self::add_notice( $message );
369
+			self::add_notice($message);
370 370
 
371
-			do_action( 'gravityview_log_error', __METHOD__. ' ' . $message );
371
+			do_action('gravityview_log_error', __METHOD__.' '.$message);
372 372
 
373 373
 			self::$is_compatible = false;
374 374
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -183,12 +183,10 @@
 block discarded – undo
183 183
 		if ( file_exists( $mofile_global ) ) {
184 184
 			// Look in global /wp-content/languages/[plugin-dir]/ folder
185 185
 			load_textdomain( $this->_text_domain, $mofile_global );
186
-		}
187
-		elseif ( file_exists( $mofile_local ) ) {
186
+		} elseif ( file_exists( $mofile_local ) ) {
188 187
 			// Look in local /wp-content/plugins/[plugin-dir]/languages/ folder
189 188
 			load_textdomain( $this->_text_domain, $mofile_local );
190
-		}
191
-		else {
189
+		} else {
192 190
 			// Load the default language files
193 191
 			load_plugin_textdomain( $this->_text_domain, false, $lang_dir );
194 192
 		}
Please login to merge, or discard this patch.
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @package GravityView
4
- * @license   GPL2+
5
- * @author    Katz Web Services, Inc.
6
- * @link      https://gravityview.co
7
- * @copyright Copyright 2015, Katz Web Services, Inc.
8
- */
3
+	 * @package GravityView
4
+	 * @license   GPL2+
5
+	 * @author    Katz Web Services, Inc.
6
+	 * @link      https://gravityview.co
7
+	 * @copyright Copyright 2015, Katz Web Services, Inc.
8
+	 */
9 9
 
10 10
 /**
11 11
  * Extend this class to create a GravityView extension that gets updates from GravityView.co
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 			$this->_remote_update_url,
245 245
 			$this->_path,
246 246
 			array(
247
-            	'version'	=> $this->_version, // current version number
248
-            	'license'	=> $license['license'],
249
-	            'item_id'   => $this->_item_id, // The ID of the download on _remote_update_url
250
-            	'item_name' => $this->_title,  // name of this plugin
251
-            	'author' 	=> strip_tags( $this->_author )  // author of this plugin
252
-          	)
253
-        );
247
+				'version'	=> $this->_version, // current version number
248
+				'license'	=> $license['license'],
249
+				'item_id'   => $this->_item_id, // The ID of the download on _remote_update_url
250
+				'item_name' => $this->_title,  // name of this plugin
251
+				'author' 	=> strip_tags( $this->_author )  // author of this plugin
252
+		  	)
253
+		);
254 254
 	}
255 255
 
256 256
 	/**
Please login to merge, or discard this patch.
includes/class-gravityview-merge-tags.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
 	 * @param bool $url_encode Whether to URL-encode output
136 136
 	 * @param bool $esc_html Whether to apply `esc_html()` to output
137 137
 	 *
138
-	 * @return mixed
138
+	 * @return string
139 139
 	 */
140 140
 	public static function replace_gv_merge_tags(  $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) {
141 141
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@
 block discarded – undo
122 122
 
123 123
 		$atts = array(
124 124
 			'format' => self::get_format_from_modifiers( $exploded, false ),
125
-		    'human' => in_array( 'human', $exploded ), // {date_created:human}
125
+			'human' => in_array( 'human', $exploded ), // {date_created:human}
126 126
 			'diff' => in_array( 'diff', $exploded ), // {date_created:diff}
127 127
 			'raw' => in_array( 'raw', $exploded ), // {date_created:raw}
128 128
 			'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp}
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	private function add_hooks() {
21 21
 
22 22
 		/** @see GFCommon::replace_variables_prepopulate **/
23
-		add_filter( 'gform_replace_merge_tags', array( 'GravityView_Merge_Tags', 'replace_gv_merge_tags' ), 10, 7 );
23
+		add_filter('gform_replace_merge_tags', array('GravityView_Merge_Tags', 'replace_gv_merge_tags'), 10, 7);
24 24
 
25 25
 	}
26 26
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @param  bool       $esc_html     Pass return value through `esc_html()`
42 42
 	 * @return string                  Text with variables maybe replaced
43 43
 	 */
44
-	public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) {
44
+	public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true) {
45 45
 
46 46
 		/**
47 47
 		 * @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 		 * @param[in]  array      $form        GF Form array
54 54
 		 * @param[in]  array      $entry        GF Entry array
55 55
 		 */
56
-		$do_replace_variables = apply_filters( 'gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry );
56
+		$do_replace_variables = apply_filters('gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry);
57 57
 
58
-		if ( strpos( $text, '{' ) === false || ! $do_replace_variables ) {
58
+		if (strpos($text, '{') === false || !$do_replace_variables) {
59 59
 			return $text;
60 60
 		}
61 61
 
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		 *
65 65
 		 * @internal Reported to GF Support on 12/3
66 66
 		 */
67
-		$form['title']  = isset( $form['title'] ) ? $form['title'] : '';
68
-		$form['id']     = isset( $form['id'] ) ? $form['id'] : '';
69
-		$form['fields'] = isset( $form['fields'] ) ? $form['fields'] : array();
67
+		$form['title']  = isset($form['title']) ? $form['title'] : '';
68
+		$form['id']     = isset($form['id']) ? $form['id'] : '';
69
+		$form['fields'] = isset($form['fields']) ? $form['fields'] : array();
70 70
 
71
-		return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html );
71
+		return GFCommon::replace_variables($text, $form, $entry, $url_encode, $esc_html);
72 72
 	}
73 73
 
74 74
 	/**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return mixed
88 88
 	 */
89
-	public static function replace_gv_merge_tags(  $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) {
89
+	public static function replace_gv_merge_tags($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false) {
90 90
 
91 91
 		/**
92 92
 		 * This prevents the gform_replace_merge_tags filter from being called twice, as defined in:
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 		 * @see GFCommon::replace_variables_prepopulate()
95 95
 		 * @todo Remove eventually: Gravity Forms fixed this issue in 1.9.14
96 96
 		 */
97
-		if( false === $form ) {
97
+		if (false === $form) {
98 98
 			return $text;
99 99
 		}
100 100
 
101
-		$text = self::replace_get_variables( $text, $form, $entry, $url_encode );
101
+		$text = self::replace_get_variables($text, $form, $entry, $url_encode);
102 102
 
103 103
 		return $text;
104 104
 	}
@@ -115,21 +115,21 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return int|string If timestamp requested, timestamp int. Otherwise, string output.
117 117
 	 */
118
-	public static function format_date( $date_created = '', $property = '' ) {
118
+	public static function format_date($date_created = '', $property = '') {
119 119
 
120 120
 		// Expand all modifiers, skipping escaped colons. str_replace worked better than preg_split( "/(?<!\\):/" )
121
-		$exploded = explode( ':', str_replace( '\:', '|COLON|', $property ) );
121
+		$exploded = explode(':', str_replace('\:', '|COLON|', $property));
122 122
 
123 123
 		$atts = array(
124
-			'format' => self::get_format_from_modifiers( $exploded, false ),
125
-		    'human' => in_array( 'human', $exploded ), // {date_created:human}
126
-			'diff' => in_array( 'diff', $exploded ), // {date_created:diff}
127
-			'raw' => in_array( 'raw', $exploded ), // {date_created:raw}
128
-			'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp}
129
-			'time' => in_array( 'time', $exploded ),  // {date_created:time}
124
+			'format' => self::get_format_from_modifiers($exploded, false),
125
+		    'human' => in_array('human', $exploded), // {date_created:human}
126
+			'diff' => in_array('diff', $exploded), // {date_created:diff}
127
+			'raw' => in_array('raw', $exploded), // {date_created:raw}
128
+			'timestamp' => in_array('timestamp', $exploded), // {date_created:timestamp}
129
+			'time' => in_array('time', $exploded), // {date_created:time}
130 130
 		);
131 131
 
132
-		$formatted_date = GVCommon::format_date( $date_created, $atts );
132
+		$formatted_date = GVCommon::format_date($date_created, $atts);
133 133
 
134 134
 		return $formatted_date;
135 135
 	}
@@ -147,16 +147,16 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return string If format is found, the passed format. Otherwise, the backup.
149 149
 	 */
150
-	private static function get_format_from_modifiers( $exploded, $backup = '' ) {
150
+	private static function get_format_from_modifiers($exploded, $backup = '') {
151 151
 
152 152
 		$return = $backup;
153 153
 
154
-		$format_key_index = array_search( 'format', $exploded );
154
+		$format_key_index = array_search('format', $exploded);
155 155
 
156 156
 		// If there's a "format:[php date format string]" date format, grab it
157
-		if ( false !== $format_key_index && isset( $exploded[ $format_key_index + 1 ] ) ) {
157
+		if (false !== $format_key_index && isset($exploded[$format_key_index + 1])) {
158 158
 			// Return escaped colons placeholder
159
-			$return = str_replace( '|COLON|', ':', $exploded[ $format_key_index + 1 ] );
159
+			$return = str_replace('|COLON|', ':', $exploded[$format_key_index + 1]);
160 160
 		}
161 161
 
162 162
 		return $return;
@@ -183,22 +183,22 @@  discard block
 block discarded – undo
183 183
 	 * @param array $entry Entry array
184 184
 	 * @param bool $url_encode Whether to URL-encode output
185 185
 	 */
186
-	public static function replace_get_variables( $text, $form = array(), $entry = array(), $url_encode = false ) {
186
+	public static function replace_get_variables($text, $form = array(), $entry = array(), $url_encode = false) {
187 187
 
188 188
 		// Is there is {get:[xyz]} merge tag?
189
-		preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER );
189
+		preg_match_all("/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER);
190 190
 
191 191
 		// If there are no matches OR the Entry `created_by` isn't set or is 0 (no user)
192
-		if( empty( $matches ) ) {
192
+		if (empty($matches)) {
193 193
 			return $text;
194 194
 		}
195 195
 
196
-		foreach ( $matches as $match ) {
196
+		foreach ($matches as $match) {
197 197
 
198 198
 			$full_tag = $match[0];
199 199
 			$property = $match[1];
200 200
 
201
-			$value = stripslashes_deep( rgget( $property ) );
201
+			$value = stripslashes_deep(rgget($property));
202 202
 
203 203
 			/**
204 204
 			 * @filter `gravityview/merge_tags/get/glue/` Modify the glue used to convert an array of `{get}` values from an array to string
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
 			 * @param[in,out] string $glue String used to `implode()` $_GET values Default: ', '
207 207
 			 * @param[in] string $property The current name of the $_GET parameter being combined
208 208
 			 */
209
-			$glue = apply_filters( 'gravityview/merge_tags/get/glue/', ', ', $property );
209
+			$glue = apply_filters('gravityview/merge_tags/get/glue/', ', ', $property);
210 210
 
211
-			$value = is_array( $value ) ? implode( $glue, $value ) : $value;
211
+			$value = is_array($value) ? implode($glue, $value) : $value;
212 212
 
213
-			$value = $url_encode ? urlencode( $value ) : $value;
213
+			$value = $url_encode ? urlencode($value) : $value;
214 214
 
215 215
 			/**
216 216
 			 * @filter `gravityview/merge_tags/get/esc_html/{url parameter name}` Disable esc_html() from running on `{get}` merge tag
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 			 * @since 1.15
221 221
 			 * @param bool $esc_html Whether to esc_html() the value. Default: `true`
222 222
 			 */
223
-			$esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true );
223
+			$esc_html = apply_filters('gravityview/merge_tags/get/esc_html/'.$property, true);
224 224
 
225
-			$value = $esc_html ? esc_html( $value ) : $value;
225
+			$value = $esc_html ? esc_html($value) : $value;
226 226
 
227 227
 			/**
228 228
 			 * @filter `gravityview/merge_tags/get/esc_html/{url parameter name}` Modify the value of the `{get}` replacement before being used
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 			 * @param[in] array $form Gravity Forms form array
232 232
 			 * @param[in] array $entry Entry array
233 233
 			 */
234
-			$value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry );
234
+			$value = apply_filters('gravityview/merge_tags/get/value/'.$property, $value, $text, $form, $entry);
235 235
 
236
-			$text = str_replace( $full_tag, $value, $text );
236
+			$text = str_replace($full_tag, $value, $text);
237 237
 		}
238 238
 
239
-		unset( $value, $glue, $matches );
239
+		unset($value, $glue, $matches);
240 240
 
241 241
 		return $text;
242 242
 	}
Please login to merge, or discard this patch.