Completed
Pull Request — develop (#843)
by Zack
05:39
created
includes/wordpress-widgets/class-gravityview-search-wp-widget.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 		$widget_ops = array(
13 13
 			'classname' => 'widget_gravityview_search',
14
-			'description' => __( 'A search form for a specific GravityView.', 'gravityview')
14
+			'description' => __( 'A search form for a specific GravityView.', 'gravityview' )
15 15
 		);
16 16
 
17 17
 		$widget_display = array(
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	}
35 35
 
36 36
 	private function load_required_files() {
37
-		if( !class_exists( 'GravityView_Widget_Search' ) ) {
37
+		if ( ! class_exists( 'GravityView_Widget_Search' ) ) {
38 38
 			gravityview_register_gravityview_widgets();
39 39
 		}
40 40
 	}
@@ -53,30 +53,30 @@  discard block
 block discarded – undo
53 53
 	public function widget( $args, $instance ) {
54 54
 
55 55
 		// Don't show unless a View ID has been set.
56
-		if( empty( $instance['view_id'] ) ) {
56
+		if ( empty( $instance[ 'view_id' ] ) ) {
57 57
 
58
-			do_action('gravityview_log_debug', sprintf( '%s[widget]: No View ID has been defined. Not showing the widget.', get_class($this)), $instance );
58
+			do_action( 'gravityview_log_debug', sprintf( '%s[widget]: No View ID has been defined. Not showing the widget.', get_class( $this ) ), $instance );
59 59
 
60 60
 			return;
61 61
 		}
62 62
 
63 63
 		/** This filter is documented in wp-includes/default-widgets.php */
64
-		$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
64
+		$title = apply_filters( 'widget_title', empty( $instance[ 'title' ] ) ? '' : $instance[ 'title' ], $instance, $this->id_base );
65 65
 
66
-		echo $args['before_widget'];
66
+		echo $args[ 'before_widget' ];
67 67
 
68 68
 		if ( $title ) {
69
-			echo $args['before_title'] . $title . $args['after_title'];
69
+			echo $args[ 'before_title' ] . $title . $args[ 'after_title' ];
70 70
 		}
71 71
 
72 72
 		// @todo Add to the widget configuration form
73
-		$instance['search_layout'] = apply_filters( 'gravityview/widget/search/layout', 'vertical', $instance );
73
+		$instance[ 'search_layout' ] = apply_filters( 'gravityview/widget/search/layout', 'vertical', $instance );
74 74
 
75
-		$instance['context'] = 'wp_widget';
75
+		$instance[ 'context' ] = 'wp_widget';
76 76
 
77 77
 		// form
78
-		$instance['form_id'] = GVCommon::get_meta_form_id( $instance['view_id'] );
79
-		$instance['form'] = GVCommon::get_form( $instance['form_id'] );
78
+		$instance[ 'form_id' ] = GVCommon::get_meta_form_id( $instance[ 'view_id' ] );
79
+		$instance[ 'form' ] = GVCommon::get_form( $instance[ 'form_id' ] );
80 80
 
81 81
 		// We don't want to overwrite existing context, etc.
82 82
 		$previous_view = GravityView_View::getInstance();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		 */
93 93
 		new GravityView_View( $previous_view );
94 94
 
95
-		echo $args['after_widget'];
95
+		echo $args[ 'after_widget' ];
96 96
 	}
97 97
 
98 98
 	/**
@@ -102,27 +102,27 @@  discard block
 block discarded – undo
102 102
 
103 103
 		$instance = $old_instance;
104 104
 
105
-		if( $this->is_preview() ) {
105
+		if ( $this->is_preview() ) {
106 106
 			//Oh! Sorry but still not fully compatible with customizer
107 107
 			return $instance;
108 108
 		}
109 109
 
110
-		$new_instance = wp_parse_args( (array) $new_instance, self::get_defaults() );
110
+		$new_instance = wp_parse_args( (array)$new_instance, self::get_defaults() );
111 111
 
112
-		$instance['title'] = strip_tags( $new_instance['title'] );
113
-		$instance['view_id'] = absint( $new_instance['view_id'] );
114
-		$instance['search_fields'] = $new_instance['search_fields'];
115
-		$instance['post_id'] = $new_instance['post_id'];
116
-		$instance['search_clear'] = $new_instance['search_clear'];
117
-		$instance['search_mode'] = $new_instance['search_mode'];
112
+		$instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
113
+		$instance[ 'view_id' ] = absint( $new_instance[ 'view_id' ] );
114
+		$instance[ 'search_fields' ] = $new_instance[ 'search_fields' ];
115
+		$instance[ 'post_id' ] = $new_instance[ 'post_id' ];
116
+		$instance[ 'search_clear' ] = $new_instance[ 'search_clear' ];
117
+		$instance[ 'search_mode' ] = $new_instance[ 'search_mode' ];
118 118
 
119
-		$is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $new_instance['post_id'], $instance['view_id'] );
119
+		$is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $new_instance[ 'post_id' ], $instance[ 'view_id' ] );
120 120
 
121 121
 		//check if post_id is a valid post with embedded View
122
-		$instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL;
122
+		$instance[ 'error_post_id' ] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL;
123 123
 
124 124
 		// Share that the widget isn't brand new
125
-		$instance['updated']  = 1;
125
+		$instance[ 'updated' ] = 1;
126 126
 
127 127
 		return $instance;
128 128
 	}
@@ -133,28 +133,28 @@  discard block
 block discarded – undo
133 133
 	public function form( $instance ) {
134 134
 
135 135
 		// @todo Make compatible with Customizer
136
-		if( $this->is_preview() ) {
136
+		if ( $this->is_preview() ) {
137 137
 
138
-			$warning = sprintf( esc_html__( 'This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview' ), '<a href="'.admin_url('widgets.php').'">', '</a>' );
138
+			$warning = sprintf( esc_html__( 'This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview' ), '<a href="' . admin_url( 'widgets.php' ) . '">', '</a>' );
139 139
 
140 140
 			echo wpautop( GravityView_Admin::get_floaty() . $warning );
141 141
 
142 142
 			return;
143 143
 		}
144 144
 
145
-		$instance = wp_parse_args( (array) $instance, self::get_defaults() );
145
+		$instance = wp_parse_args( (array)$instance, self::get_defaults() );
146 146
 
147
-		$title    = $instance['title'];
148
-		$view_id  = $instance['view_id'];
149
-		$post_id  = $instance['post_id'];
150
-		$search_fields = $instance['search_fields'];
151
-		$search_clear = $instance['search_clear'];
152
-		$search_mode = $instance['search_mode'];
147
+		$title    = $instance[ 'title' ];
148
+		$view_id  = $instance[ 'view_id' ];
149
+		$post_id  = $instance[ 'post_id' ];
150
+		$search_fields = $instance[ 'search_fields' ];
151
+		$search_clear = $instance[ 'search_clear' ];
152
+		$search_mode = $instance[ 'search_mode' ];
153 153
 
154 154
 		$views = GVCommon::get_all_views();
155 155
 
156 156
 		// If there are no views set up yet, we get outta here.
157
-		if( empty( $views ) ) { ?>
157
+		if ( empty( $views ) ) { ?>
158 158
 			<div id="select_gravityview_view">
159 159
 				<div class="wrap"><?php echo GravityView_Admin::no_views_text(); ?></div>
160 160
 			</div>
@@ -162,17 +162,17 @@  discard block
 block discarded – undo
162 162
 		}
163 163
 		?>
164 164
 
165
-		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'gravityview'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p>
165
+		<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'gravityview' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p>
166 166
 
167 167
 		<?php
168 168
 		/**
169 169
 		 * Display errors generated for invalid embed IDs
170 170
 		 * @see GravityView_View_Data::is_valid_embed_id
171 171
 		 */
172
-		if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) {
172
+		if ( isset( $instance[ 'updated' ] ) && empty( $instance[ 'view_id' ] ) ) {
173 173
 			?>
174 174
 			<div class="error inline hide-on-view-change">
175
-				<p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p>
175
+				<p><?php esc_html_e( 'Please select a View to search.', 'gravityview' ); ?></p>
176 176
 			</div>
177 177
 			<?php
178 178
 			unset ( $error );
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
 
182 182
 		<p>
183 183
 			<label for="gravityview_view_id"><?php _e( 'View:', 'gravityview' ); ?></label>
184
-			<select id="gravityview_view_id" name="<?php echo $this->get_field_name('view_id'); ?>" class="widefat">
184
+			<select id="gravityview_view_id" name="<?php echo $this->get_field_name( 'view_id' ); ?>" class="widefat">
185 185
 				<option value=""><?php esc_html_e( '&mdash; Select a View &mdash;', 'gravityview' ); ?></option>
186 186
 				<?php
187
-				foreach( $views as $view_option ) {
188
-					$title = empty( $view_option->post_title ) ? __('(no title)', 'gravityview') : $view_option->post_title;
189
-					echo '<option value="'. $view_option->ID .'" ' . selected( esc_attr( $view_id ), $view_option->ID, false ) . '>'. esc_html( sprintf('%s #%d', $title, $view_option->ID ) ) .'</option>';
187
+				foreach ( $views as $view_option ) {
188
+					$title = empty( $view_option->post_title ) ? __( '(no title)', 'gravityview' ) : $view_option->post_title;
189
+					echo '<option value="' . $view_option->ID . '" ' . selected( esc_attr( $view_id ), $view_option->ID, false ) . '>' . esc_html( sprintf( '%s #%d', $title, $view_option->ID ) ) . '</option>';
190 190
 				}
191 191
 				?>
192 192
 			</select>
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 		 * Display errors generated for invalid embed IDs
199 199
 		 * @see GravityView_View_Data::is_valid_embed_id
200 200
 		 */
201
-		if( !empty( $instance['error_post_id'] ) ) {
201
+		if ( ! empty( $instance[ 'error_post_id' ] ) ) {
202 202
 			?>
203 203
 			<div class="error inline">
204
-				<p><?php echo $instance['error_post_id']; ?></p>
204
+				<p><?php echo $instance[ 'error_post_id' ]; ?></p>
205 205
 			</div>
206 206
 			<?php
207 207
 			unset ( $error );
@@ -209,40 +209,40 @@  discard block
 block discarded – undo
209 209
 		?>
210 210
 
211 211
 		<p>
212
-			<label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label>
213
-			<input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr( $post_id ); ?>" />
212
+			<label for="<?php echo $this->get_field_id( 'post_id' ); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label>
213
+			<input class="code" size="3" id="<?php echo $this->get_field_id( 'post_id' ); ?>" name="<?php echo $this->get_field_name( 'post_id' ); ?>" type="text" value="<?php echo esc_attr( $post_id ); ?>" />
214 214
 			<span class="howto"><?php
215
-				esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' );
216
-				echo ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more&hellip;', 'gravityview' ), 'target=_blank' );
215
+				esc_html_e( 'To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' );
216
+				echo ' ' . gravityview_get_link( 'http://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more&hellip;', 'gravityview' ), 'target=_blank' );
217 217
 				?></span>
218 218
 		</p>
219 219
 
220 220
 		<p>
221
-			<label for="<?php echo $this->get_field_id('search_clear'); ?>"><?php esc_html_e( 'Show Clear button', 'gravityview' ); ?>:</label>
222
-			<input name="<?php echo $this->get_field_name('search_clear'); ?>" type="hidden" value="0">
223
-			<input id="<?php echo $this->get_field_id('search_clear'); ?>" name="<?php echo $this->get_field_name('search_clear'); ?>" type="checkbox" class="checkbox" value="1" <?php checked( $search_clear, 1, true ); ?>>
221
+			<label for="<?php echo $this->get_field_id( 'search_clear' ); ?>"><?php esc_html_e( 'Show Clear button', 'gravityview' ); ?>:</label>
222
+			<input name="<?php echo $this->get_field_name( 'search_clear' ); ?>" type="hidden" value="0">
223
+			<input id="<?php echo $this->get_field_id( 'search_clear' ); ?>" name="<?php echo $this->get_field_name( 'search_clear' ); ?>" type="checkbox" class="checkbox" value="1" <?php checked( $search_clear, 1, true ); ?>>
224 224
 		</p>
225 225
 
226 226
 		<p>
227 227
 			<label><?php esc_html_e( 'Search Mode', 'gravityview' ); ?>:</label>
228
-			<label for="<?php echo $this->get_field_id('search_mode'); ?>_any">
229
-				<input id="<?php echo $this->get_field_id('search_mode'); ?>_any" name="<?php echo $this->get_field_name('search_mode'); ?>" type="radio" class="radio" value="any" <?php checked( $search_mode, 'any', true ); ?>>
228
+			<label for="<?php echo $this->get_field_id( 'search_mode' ); ?>_any">
229
+				<input id="<?php echo $this->get_field_id( 'search_mode' ); ?>_any" name="<?php echo $this->get_field_name( 'search_mode' ); ?>" type="radio" class="radio" value="any" <?php checked( $search_mode, 'any', true ); ?>>
230 230
 				<?php esc_html_e( 'Match Any Fields', 'gravityview' ); ?>
231 231
 			</label>
232
-			<label for="<?php echo $this->get_field_id('search_mode'); ?>_all">
233
-				<input id="<?php echo $this->get_field_id('search_mode'); ?>_all" name="<?php echo $this->get_field_name('search_mode'); ?>" type="radio" class="radio" value="all" <?php checked( $search_mode, 'all', true ); ?>>
232
+			<label for="<?php echo $this->get_field_id( 'search_mode' ); ?>_all">
233
+				<input id="<?php echo $this->get_field_id( 'search_mode' ); ?>_all" name="<?php echo $this->get_field_name( 'search_mode' ); ?>" type="radio" class="radio" value="all" <?php checked( $search_mode, 'all', true ); ?>>
234 234
 				<?php esc_html_e( 'Match All Fields', 'gravityview' ); ?>
235 235
 			</label>
236
-			<span class="howto"><?php esc_html_e('Should search results match all search fields, or any?', 'gravityview' ); ?></span
236
+			<span class="howto"><?php esc_html_e( 'Should search results match all search fields, or any?', 'gravityview' ); ?></span
237 237
 		</p>
238 238
 
239 239
 		<hr />
240 240
 
241 241
 		<?php // @todo: move style to CSS ?>
242 242
 		<div style="margin-bottom: 1em;">
243
-			<label class="screen-reader-text" for="<?php echo $this->get_field_id('search_fields'); ?>"><?php _e( 'Searchable fields:', 'gravityview' ); ?></label>
244
-			<div class="gv-widget-search-fields" title="<?php esc_html_e('Search Fields', 'gravityview'); ?>">
245
-				<input id="<?php echo $this->get_field_id('search_fields'); ?>" name="<?php echo $this->get_field_name('search_fields'); ?>" type="hidden" value="<?php echo esc_attr( $search_fields ); ?>" class="gv-search-fields-value">
243
+			<label class="screen-reader-text" for="<?php echo $this->get_field_id( 'search_fields' ); ?>"><?php _e( 'Searchable fields:', 'gravityview' ); ?></label>
244
+			<div class="gv-widget-search-fields" title="<?php esc_html_e( 'Search Fields', 'gravityview' ); ?>">
245
+				<input id="<?php echo $this->get_field_id( 'search_fields' ); ?>" name="<?php echo $this->get_field_name( 'search_fields' ); ?>" type="hidden" value="<?php echo esc_attr( $search_fields ); ?>" class="gv-search-fields-value">
246 246
 			</div>
247 247
 
248 248
 		</div>
Please login to merge, or discard this patch.
future/includes/class-gv-collection-view.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 					continue;
72 72
 				}
73 73
 
74
-				if ( is_numeric( $shortcode->atts['id'] ) ) {
75
-					$views->append( View::by_id( $shortcode->atts['id'] ) );
74
+				if ( is_numeric( $shortcode->atts[ 'id' ] ) ) {
75
+					$views->append( View::by_id( $shortcode->atts[ 'id' ] ) );
76 76
 				}
77 77
 			}
78 78
 
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 						continue;
103 103
 					}
104 104
 
105
-					if ( is_numeric( $shortcode->atts['id'] ) ) {
106
-						$views->append( View::by_id( $shortcode->atts['id'] ) );
105
+					if ( is_numeric( $shortcode->atts[ 'id' ] ) ) {
106
+						$views->append( View::by_id( $shortcode->atts[ 'id' ] ) );
107 107
 					}
108 108
 				}
109 109
 			}
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,8 +2,9 @@  discard block
 block discarded – undo
2 2
 namespace GV;
3 3
 
4 4
 /** If this file is called directly, abort. */
5
-if ( ! defined( 'GRAVITYVIEW_DIR' ) )
5
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
6 6
 	die();
7
+}
7 8
 
8 9
 /**
9 10
  * A collection of \GV\View objects.
@@ -39,8 +40,9 @@  discard block
 block discarded – undo
39 40
 	 */
40 41
 	public function get( $view_id ) {
41 42
 		foreach ( $this->all() as $view ) {
42
-			if ( $view->ID == $view_id )
43
-				return $view;
43
+			if ( $view->ID == $view_id ) {
44
+							return $view;
45
+			}
44 46
 		}
45 47
 		return null;
46 48
 	}
Please login to merge, or discard this patch.
future/includes/class-gv-plugin.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 	 * @return string The version of PHP.
212 212
 	 */
213 213
 	private function get_php_version() {
214
-		return !empty( $GLOBALS['GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] ) ?
215
-			$GLOBALS['GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] : phpversion();
214
+		return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE' ] ) ?
215
+			$GLOBALS[ 'GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE' ] : phpversion();
216 216
 	}
217 217
 
218 218
 	/**
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 * @return string The version of WordPress.
224 224
 	 */
225 225
 	private function get_wordpress_version() {
226
-		return !empty( $GLOBALS['GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE'] ) ?
227
-			$GLOBALS['GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE'] : $GLOBALS['wp_version'];
226
+		return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE' ] ) ?
227
+			$GLOBALS[ 'GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE' ] : $GLOBALS[ 'wp_version' ];
228 228
 	}
229 229
 
230 230
 	/**
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
 	 * @return string The version of Gravity Forms.
237 237
 	 */
238 238
 	private function get_gravityforms_version() {
239
-		if ( !class_exists( '\GFCommon' ) || !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE'] ) )
239
+		if ( ! class_exists( '\GFCommon' ) || ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE' ] ) )
240 240
 			throw new \ErrorException( 'Gravity Forms is inactive or not installed.' );
241 241
 
242
-		return !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] ) ?
243
-			$GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] : \GFCommon::$version;
242
+		return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE' ] ) ?
243
+			$GLOBALS[ 'GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE' ] : \GFCommon::$version;
244 244
 	}
245 245
 
246 246
 	private function __clone() { }
Please login to merge, or discard this patch.
Braces   +11 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,8 +2,9 @@  discard block
 block discarded – undo
2 2
 namespace GV;
3 3
 
4 4
 /** If this file is called directly, abort. */
5
-if ( ! defined( 'GRAVITYVIEW_DIR' ) )
5
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
6 6
 	die();
7
+}
7 8
 
8 9
 /**
9 10
  * The GravityView WordPress plugin class.
@@ -68,8 +69,9 @@  discard block
 block discarded – undo
68 69
 	 * @return \GV\Plugin The global instance of GravityView Plugin.
69 70
 	 */
70 71
 	public static function get() {
71
-		if ( ! self::$__instance instanceof self )
72
-			self::$__instance = new self;
72
+		if ( ! self::$__instance instanceof self ) {
73
+					self::$__instance = new self;
74
+		}
73 75
 		return self::$__instance;
74 76
 	}
75 77
 
@@ -92,8 +94,9 @@  discard block
 block discarded – undo
92 94
 		 * Stop all further functionality from loading if the WordPress
93 95
 		 * plugin is incompatible with the current environment.
94 96
 		 */
95
-		if ( ! $this->is_compatible() )
96
-			return;
97
+		if ( ! $this->is_compatible() ) {
98
+					return;
99
+		}
97 100
 
98 101
 		/** Register hooks that are fired when the plugin is activated and deactivated. */
99 102
 		register_activation_hook( $this->dir( 'gravityview.php' ), array( $this, 'activate' ) );
@@ -236,8 +239,9 @@  discard block
 block discarded – undo
236 239
 	 * @return string The version of Gravity Forms.
237 240
 	 */
238 241
 	private function get_gravityforms_version() {
239
-		if ( !class_exists( '\GFCommon' ) || !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE'] ) )
240
-			throw new \ErrorException( 'Gravity Forms is inactive or not installed.' );
242
+		if ( !class_exists( '\GFCommon' ) || !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE'] ) ) {
243
+					throw new \ErrorException( 'Gravity Forms is inactive or not installed.' );
244
+		}
241 245
 
242 246
 		return !empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] ) ?
243 247
 			$GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] : \GFCommon::$version;
Please login to merge, or discard this patch.
future/includes/class-gv-collection.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	 * @return void
25 25
 	 */
26 26
 	public function append( $value ) {
27
-		$this->storage []= $value;
27
+		$this->storage [ ] = $value;
28 28
 	}
29 29
 
30 30
 	/**
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,8 +2,9 @@
 block discarded – undo
2 2
 namespace GV;
3 3
 
4 4
 /** If this file is called directly, abort. */
5
-if ( ! defined( 'GRAVITYVIEW_DIR' ) )
5
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
6 6
 	die();
7
+}
7 8
 
8 9
 /**
9 10
  * A generic Collection base class.
Please login to merge, or discard this patch.
future/includes/class-gv-request-frontend.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,8 +2,9 @@
 block discarded – undo
2 2
 namespace GV;
3 3
 
4 4
 /** If this file is called directly, abort. */
5
-if ( ! defined( 'GRAVITYVIEW_DIR' ) )
5
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
6 6
 	die();
7
+}
7 8
 
8 9
 /**
9 10
  * The default Request class.
Please login to merge, or discard this patch.
includes/class-data.php 2 patches
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 */
18 18
 	private function __construct( $passed_post = NULL ) {
19 19
 
20
-		if( !empty( $passed_post ) ) {
20
+		if ( ! empty( $passed_post ) ) {
21 21
 
22 22
 			$id_or_id_array = $this->maybe_get_view_id( $passed_post );
23 23
 
24
-			if( !empty( $id_or_id_array ) ) {
24
+			if ( ! empty( $id_or_id_array ) ) {
25 25
 				$this->add_view( $id_or_id_array );
26 26
 			}
27 27
 		}
@@ -58,40 +58,40 @@  discard block
 block discarded – undo
58 58
 	public function maybe_get_view_id( $passed_post ) {
59 59
 		$ids = array();
60 60
 
61
-		if( ! empty( $passed_post ) ) {
61
+		if ( ! empty( $passed_post ) ) {
62 62
 
63
-			if( is_numeric( $passed_post ) ) {
63
+			if ( is_numeric( $passed_post ) ) {
64 64
 				$passed_post = get_post( $passed_post );
65 65
 			}
66 66
 
67 67
 			// Convert WP_Posts into WP_Posts[] array
68
-			if( $passed_post instanceof WP_Post ) {
68
+			if ( $passed_post instanceof WP_Post ) {
69 69
 				$passed_post = array( $passed_post );
70 70
 			}
71 71
 
72
-			if( is_array( $passed_post ) ) {
72
+			if ( is_array( $passed_post ) ) {
73 73
 
74
-				foreach ( $passed_post as &$post) {
74
+				foreach ( $passed_post as &$post ) {
75 75
 					if ( function_exists( 'gravityview' ) && $post instanceof WP_Post ) {
76 76
 						$views = \GV\View_Collection::from_post( $post );
77 77
 						foreach ( $views->all() as $view ) {
78
-							$ids []= $view->ID;
78
+							$ids [ ] = $view->ID;
79 79
 						}
80 80
 					} else {
81 81
 						/** Deprecated, see \GV\View_Collection::from_post */
82
-						if( ( get_post_type( $post ) === 'gravityview' ) ) {
83
-							$ids[] = $post->ID;
84
-						} else{
82
+						if ( ( get_post_type( $post ) === 'gravityview' ) ) {
83
+							$ids[ ] = $post->ID;
84
+						} else {
85 85
 							// Parse the Post Content
86 86
 							$id = $this->parse_post_content( $post->post_content );
87
-							if( $id ) {
88
-								$ids = array_merge( $ids, (array) $id );
87
+							if ( $id ) {
88
+								$ids = array_merge( $ids, (array)$id );
89 89
 							}
90 90
 
91 91
 							// Parse the Post Meta
92 92
 							$id = $this->parse_post_meta( $post->ID );
93
-							if( $id ) {
94
-								$ids = array_merge( $ids, (array) $id );
93
+							if ( $id ) {
94
+								$ids = array_merge( $ids, (array)$id );
95 95
 							}
96 96
 						}
97 97
 					}
@@ -105,31 +105,31 @@  discard block
 block discarded – undo
105 105
 					if ( function_exists( 'gravityview' ) ) {
106 106
 						$shortcodes = \GV\Shortcode::parse( $passed_post );
107 107
 						foreach ( $shortcodes as $shortcode ) {
108
-							if ( $shortcode->name == 'gravityview' && !empty( $shortcode->atts['id'] ) )
109
-								$ids []= $shortcode->atts['id'];
108
+							if ( $shortcode->name == 'gravityview' && ! empty( $shortcode->atts[ 'id' ] ) )
109
+								$ids [ ] = $shortcode->atts[ 'id' ];
110 110
 						}
111 111
 					} else {
112 112
 						/** Deprecated, use \GV\Shortcode::parse. */
113 113
 						$id = $this->parse_post_content( $passed_post );
114
-						if( $id ) {
115
-							$ids = array_merge( $ids, (array) $id );
114
+						if ( $id ) {
115
+							$ids = array_merge( $ids, (array)$id );
116 116
 						}
117 117
 					}
118 118
 
119 119
 				} else {
120 120
 					$id = $this->get_id_from_atts( $passed_post );
121
-					$ids[] = intval( $id );
121
+					$ids[ ] = intval( $id );
122 122
 				}
123 123
 			}
124 124
 		}
125 125
 
126
-		if( empty($ids) ) {
126
+		if ( empty( $ids ) ) {
127 127
 			return NULL;
128 128
 		}
129 129
 
130 130
 		// If it's just one ID, return that.
131 131
 		// Otherwise, return array of IDs
132
-		return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids;
132
+		return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids;
133 133
 	}
134 134
 
135 135
 	/**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 */
138 138
 	public static function getInstance( $passed_post = NULL ) {
139 139
 
140
-		if( empty( self::$instance ) ) {
140
+		if ( empty( self::$instance ) ) {
141 141
 			self::$instance = new GravityView_View_Data( $passed_post );
142 142
 		}
143 143
 
@@ -150,19 +150,19 @@  discard block
 block discarded – undo
150 150
 
151 151
 	function get_view( $view_id, $atts = NULL ) {
152 152
 
153
-		if( ! is_numeric( $view_id) ) {
154
-			do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) );
153
+		if ( ! is_numeric( $view_id ) ) {
154
+			do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id ) );
155 155
 			return false;
156 156
 		}
157 157
 
158 158
 		// Backup: the view hasn't been fetched yet. Doing it now.
159 159
 		if ( ! isset( $this->views[ $view_id ] ) ) {
160
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) );
160
+			do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] View #%s not set yet.', $view_id ) );
161 161
 			return $this->add_view( $view_id, $atts );
162 162
 		}
163 163
 
164 164
 		if ( empty( $this->views[ $view_id ] ) ) {
165
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) );
165
+			do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id ) );
166 166
 			return false;
167 167
 		}
168 168
 
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 	function add_view( $view_id, $atts = NULL ) {
194 194
 
195 195
 		// Handle array of IDs
196
-		if( is_array( $view_id ) ) {
197
-			foreach( $view_id as $id ) {
196
+		if ( is_array( $view_id ) ) {
197
+			foreach ( $view_id as $id ) {
198 198
 
199 199
 				$this->add_view( $id, $atts );
200 200
 			}
@@ -203,21 +203,21 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 
205 205
 		// The view has been set already; returning stored view.
206
-		if ( !empty( $this->views[ $view_id ] ) ) {
207
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) );
206
+		if ( ! empty( $this->views[ $view_id ] ) ) {
207
+			do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id ) );
208 208
 			return $this->views[ $view_id ];
209 209
 		}
210 210
 
211
-		if( ! $this->view_exists( $view_id ) ) {
212
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) );
211
+		if ( ! $this->view_exists( $view_id ) ) {
212
+			do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id ) );
213 213
 			return false;
214 214
 		}
215 215
 
216 216
 		$form_id = gravityview_get_form_id( $view_id );
217 217
 
218
-		if( empty( $form_id ) ) {
218
+		if ( empty( $form_id ) ) {
219 219
 
220
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) );
220
+			do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id ) );
221 221
 
222 222
 			return false;
223 223
 		}
@@ -225,21 +225,21 @@  discard block
 block discarded – undo
225 225
 		// Get the settings for the View ID
226 226
 		$view_settings = gravityview_get_template_settings( $view_id );
227 227
 
228
-		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings );
228
+		do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id ), $view_settings );
229 229
 
230 230
 		// Merge the view settings with the defaults
231 231
 		$view_defaults = wp_parse_args( $view_settings, self::get_default_args() );
232 232
 
233
-		do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults );
233
+		do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults );
234 234
 
235
-		if( ! empty( $atts ) && is_array( $atts ) ) {
235
+		if ( ! empty( $atts ) && is_array( $atts ) ) {
236 236
 
237
-			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging  with the $view_defaults', $atts );
237
+			do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging  with the $view_defaults', $atts );
238 238
 
239 239
 			// Get the settings from the shortcode and merge them with defaults.
240 240
 			$atts = shortcode_atts( $view_defaults, $atts );
241 241
 
242
-			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging  with the $view_defaults', $atts );
242
+			do_action( 'gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging  with the $view_defaults', $atts );
243 243
 
244 244
 		} else {
245 245
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
 		}
250 250
 
251
-		unset( $atts['id'], $view_defaults, $view_settings );
251
+		unset( $atts[ 'id' ], $view_defaults, $view_settings );
252 252
 
253 253
 		$data = array(
254 254
 			'id' => $view_id,
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			'form' => gravityview_get_form( $form_id ),
262 262
 		);
263 263
 
264
-		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data );
264
+		do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[add_view] View #%s being added.', $view_id ), $data );
265 265
 
266 266
 		$this->views[ $view_id ] = $data;
267 267
 
@@ -296,15 +296,15 @@  discard block
 block discarded – undo
296 296
 	 */
297 297
 	private function filter_fields( $dir_fields ) {
298 298
 
299
-		if( empty( $dir_fields ) || !is_array( $dir_fields ) ) {
299
+		if ( empty( $dir_fields ) || ! is_array( $dir_fields ) ) {
300 300
 			return $dir_fields;
301 301
 		}
302 302
 
303
-		foreach( $dir_fields as $area => $fields ) {
303
+		foreach ( $dir_fields as $area => $fields ) {
304 304
 
305
-			foreach( (array)$fields as $uniqid => $properties ) {
305
+			foreach ( (array)$fields as $uniqid => $properties ) {
306 306
 
307
-				if( $this->hide_field_check_conditions( $properties ) ) {
307
+				if ( $this->hide_field_check_conditions( $properties ) ) {
308 308
 					unset( $dir_fields[ $area ][ $uniqid ] );
309 309
 				}
310 310
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	private function hide_field_check_conditions( $properties ) {
327 327
 
328 328
 		// logged-in visibility
329
-		if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) {
329
+		if ( ! empty( $properties[ 'only_loggedin' ] ) && ! GVCommon::has_cap( $properties[ 'only_loggedin_cap' ] ) ) {
330 330
 			return true;
331 331
 		}
332 332
 
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
 		// Get the settings from the shortcode and merge them with defaults.
344 344
 		$atts = wp_parse_args( $atts, self::get_default_args() );
345 345
 
346
-		$view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL;
346
+		$view_id = ! empty( $atts[ 'view_id' ] ) ? (int)$atts[ 'view_id' ] : NULL;
347 347
 
348
-		if( empty( $view_id ) && !empty( $atts['id'] ) ) {
349
-			$view_id = (int)$atts['id'];
348
+		if ( empty( $view_id ) && ! empty( $atts[ 'id' ] ) ) {
349
+			$view_id = (int)$atts[ 'id' ];
350 350
 		}
351 351
 
352
-		if( empty( $view_id ) ) {
353
-			do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts );
352
+		if ( empty( $view_id ) ) {
353
+			do_action( 'gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts );
354 354
 			return;
355 355
 		}
356 356
 
@@ -372,46 +372,46 @@  discard block
 block discarded – undo
372 372
 		 * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin
373 373
 		 * @since 1.6
374 374
 		 */
375
-		if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) {
375
+		if ( ! shortcode_exists( 'gravityview' ) && class_exists( 'GravityView_Shortcode' ) ) {
376 376
 			new GravityView_Shortcode;
377 377
 		}
378 378
 
379 379
 		$shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' );
380 380
 
381
-		if( empty( $shortcodes ) ) {
381
+		if ( empty( $shortcodes ) ) {
382 382
 			return NULL;
383 383
 		}
384 384
 
385
-		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes );
385
+		do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes );
386 386
 
387 387
 		$ids = array();
388 388
 
389
-		foreach ($shortcodes as $key => $shortcode) {
389
+		foreach ( $shortcodes as $key => $shortcode ) {
390 390
 
391
-			$shortcode[3] = htmlspecialchars_decode( $shortcode[3], ENT_QUOTES );
391
+			$shortcode[ 3 ] = htmlspecialchars_decode( $shortcode[ 3 ], ENT_QUOTES );
392 392
 
393
-			$args = shortcode_parse_atts( $shortcode[3] );
393
+			$args = shortcode_parse_atts( $shortcode[ 3 ] );
394 394
 
395
-			if( empty( $args['id'] ) ) {
396
-				do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode );
395
+			if ( empty( $args[ 'id' ] ) ) {
396
+				do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode );
397 397
 				continue;
398 398
 			}
399 399
 
400
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args );
400
+			do_action( 'gravityview_log_debug', sprintf( 'GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args[ 'id' ] ), $args );
401 401
 
402 402
 			// Store the View to the object for later fetching.
403
-			$this->add_view( $args['id'], $args );
403
+			$this->add_view( $args[ 'id' ], $args );
404 404
 
405
-			$ids[] = $args['id'];
405
+			$ids[ ] = $args[ 'id' ];
406 406
 		}
407 407
 
408
-		if( empty($ids) ) {
408
+		if ( empty( $ids ) ) {
409 409
 			return NULL;
410 410
 		}
411 411
 
412 412
 		// If it's just one ID, return that.
413 413
 		// Otherwise, return array of IDs
414
-		return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids;
414
+		return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids;
415 415
 
416 416
 	}
417 417
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		 */
433 433
 		$meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id );
434 434
 
435
-		if( empty( $meta_keys ) ) {
435
+		if ( empty( $meta_keys ) ) {
436 436
 			return NULL;
437 437
 		}
438 438
 
@@ -440,16 +440,16 @@  discard block
 block discarded – undo
440 440
 
441 441
 		$meta_content = '';
442 442
 
443
-		foreach( $meta_keys as $key ) {
444
-			$meta = get_post_meta( $post_id, $key , true );
445
-			if( ! is_string( $meta ) ) {
443
+		foreach ( $meta_keys as $key ) {
444
+			$meta = get_post_meta( $post_id, $key, true );
445
+			if ( ! is_string( $meta ) ) {
446 446
 				continue;
447 447
 			}
448 448
 			$meta_content .= $meta . ' ';
449 449
 		}
450 450
 
451
-		if( empty( $meta_content ) ) {
452
-			do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys );
451
+		if ( empty( $meta_content ) ) {
452
+			do_action( 'gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys );
453 453
 			return NULL;
454 454
 		}
455 455
 
@@ -476,16 +476,16 @@  discard block
 block discarded – undo
476 476
 		$message = NULL;
477 477
 
478 478
 		// Not invalid if not set!
479
-		if( empty( $post_id ) || empty( $view_id ) ) {
479
+		if ( empty( $post_id ) || empty( $view_id ) ) {
480 480
 
481
-			if( $empty_is_valid ) {
481
+			if ( $empty_is_valid ) {
482 482
 				return true;
483 483
 			}
484 484
 
485 485
 			$message = esc_html__( 'The ID is required.', 'gravityview' );
486 486
 		}
487 487
 
488
-		if( ! $message ) {
488
+		if ( ! $message ) {
489 489
 			$status = get_post_status( $post_id );
490 490
 
491 491
 			// Nothing exists with that post ID.
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 			}
498 498
 		}
499 499
 
500
-		if( ! $message ) {
500
+		if ( ! $message ) {
501 501
 
502 502
 			// Nothing exists with that post ID.
503 503
 			if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) {
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 
507 507
 		}
508 508
 
509
-		if( ! $message ) {
510
-			if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) )  {
509
+		if ( ! $message ) {
510
+			if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) {
511 511
 				$views = GV\View_Collection::from_post( $post );
512 512
 				$view_ids_in_post = array_map( function( $view ) { return $view->ID; }, $views->all() );
513 513
 			} else {
@@ -516,21 +516,21 @@  discard block
 block discarded – undo
516 516
 			}
517 517
 
518 518
 			// The post or page specified does not contain the shortcode.
519
-			if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) {
519
+			if ( false === in_array( $view_id, (array)$view_ids_in_post ) ) {
520 520
 				$message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' );
521 521
 			}
522 522
 		}
523 523
 
524
-		if( ! $message ) {
524
+		if ( ! $message ) {
525 525
 
526 526
 			// It's a View
527
-			if( 'gravityview' === get_post_type( $post_id ) ) {
528
-				$message = esc_html__( 'The ID is already a View.', 'gravityview' );;
527
+			if ( 'gravityview' === get_post_type( $post_id ) ) {
528
+				$message = esc_html__( 'The ID is already a View.', 'gravityview' ); ;
529 529
 			}
530 530
 
531 531
 		}
532 532
 
533
-		if( $message ) {
533
+		if ( $message ) {
534 534
 			return new WP_Error( 'invalid_embed_id', $message );
535 535
 		}
536 536
 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 
548 548
 		$args = self::get_default_args( $with_details );
549 549
 
550
-		if( !isset( $args[ $key ] ) ) { return NULL; }
550
+		if ( ! isset( $args[ $key ] ) ) { return NULL; }
551 551
 
552 552
 		return $args[ $key ];
553 553
 	}
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 		 */
577 577
 		$default_settings = apply_filters( 'gravityview_default_args', array(
578 578
 			'id' => array(
579
-				'label' => __('View ID', 'gravityview'),
579
+				'label' => __( 'View ID', 'gravityview' ),
580 580
 				'type' => 'number',
581 581
 				'group'	=> 'default',
582 582
 				'value' => NULL,
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 				'show_in_shortcode' => false,
585 585
 			),
586 586
 			'page_size' => array(
587
-				'label' 	=> __('Number of entries per page', 'gravityview'),
587
+				'label' 	=> __( 'Number of entries per page', 'gravityview' ),
588 588
 				'type' => 'number',
589 589
 				'class'	=> 'small-text',
590 590
 				'group'	=> 'default',
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 			),
609 609
 			'admin_show_all_statuses' => array(
610 610
 				'label' => __( 'Show all entries to administrators', 'gravityview' ),
611
-				'desc'	=> __('Administrators will be able to see entries with any approval status.', 'gravityview'),
612
-				'tooltip' => __('Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview'),
611
+				'desc'	=> __( 'Administrators will be able to see entries with any approval status.', 'gravityview' ),
612
+				'tooltip' => __( 'Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview' ),
613 613
 				'requires' => 'show_only_approved',
614 614
 				'type' => 'checkbox',
615 615
 				'group'	=> 'default',
@@ -634,40 +634,40 @@  discard block
 block discarded – undo
634 634
 			'user_edit' => array(
635 635
 				'label'	=> __( 'Allow User Edit', 'gravityview' ),
636 636
 				'group'	=> 'default',
637
-				'desc'	=> __('Allow logged-in users to edit entries they created.', 'gravityview'),
637
+				'desc'	=> __( 'Allow logged-in users to edit entries they created.', 'gravityview' ),
638 638
 				'value'	=> 0,
639
-				'tooltip' => __('Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview'),
639
+				'tooltip' => __( 'Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview' ),
640 640
 				'type'	=> 'checkbox',
641 641
 				'show_in_shortcode' => true,
642 642
 			),
643 643
 			'user_delete' => array(
644 644
 				'label'	=> __( 'Allow User Delete', 'gravityview' ),
645 645
 				'group'	=> 'default',
646
-				'desc'	=> __('Allow logged-in users to delete entries they created.', 'gravityview'),
646
+				'desc'	=> __( 'Allow logged-in users to delete entries they created.', 'gravityview' ),
647 647
 				'value'	=> 0,
648
-				'tooltip' => __('Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview'),
648
+				'tooltip' => __( 'Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview' ),
649 649
 				'type'	=> 'checkbox',
650 650
 				'show_in_shortcode' => true,
651 651
 			),
652 652
 			'sort_field' => array(
653
-				'label'	=> __('Sort by field', 'gravityview'),
653
+				'label'	=> __( 'Sort by field', 'gravityview' ),
654 654
 				'type' => 'select',
655 655
 				'value' => '',
656 656
 				'group'	=> 'sort',
657 657
 				'options' => array(
658
-					'' => __( 'Default', 'gravityview'),
659
-					'date_created' => __( 'Date Created', 'gravityview'),
658
+					'' => __( 'Default', 'gravityview' ),
659
+					'date_created' => __( 'Date Created', 'gravityview' ),
660 660
 				),
661 661
 				'show_in_shortcode' => true,
662 662
 			),
663 663
 			'sort_direction' => array(
664
-				'label' 	=> __('Sort direction', 'gravityview'),
664
+				'label' 	=> __( 'Sort direction', 'gravityview' ),
665 665
 				'type' => 'select',
666 666
 				'value' => 'ASC',
667 667
 				'group'	=> 'sort',
668 668
 				'options' => array(
669
-					'ASC' => __('ASC', 'gravityview'),
670
-					'DESC' => __('DESC', 'gravityview'),
669
+					'ASC' => __( 'ASC', 'gravityview' ),
670
+					'DESC' => __( 'DESC', 'gravityview' ),
671 671
 					//'RAND' => __('Random', 'gravityview'),
672 672
 				),
673 673
 				'show_in_shortcode' => true,
@@ -683,69 +683,69 @@  discard block
 block discarded – undo
683 683
 				'show_in_template' => array( 'default_table' ),
684 684
 			),
685 685
 			'start_date' => array(
686
-				'label' 	=> __('Filter by Start Date', 'gravityview'),
686
+				'label' 	=> __( 'Filter by Start Date', 'gravityview' ),
687 687
 				'class'	=> 'gv-datepicker',
688
-				'desc'	=> __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ),
688
+				'desc'	=> __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ),
689 689
 				'type' => 'text',
690 690
 				'value' => '',
691 691
 				'group'	=> 'filter',
692 692
 				'show_in_shortcode' => true,
693 693
 			),
694 694
 			'end_date' => array(
695
-				'label' 	=> __('Filter by End Date', 'gravityview'),
695
+				'label' 	=> __( 'Filter by End Date', 'gravityview' ),
696 696
 				'class'	=> 'gv-datepicker',
697
-				'desc'	=> __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ),
697
+				'desc'	=> __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ),
698 698
 				'type' => 'text',
699 699
 				'value' => '',
700 700
 				'group'	=> 'filter',
701 701
 				'show_in_shortcode' => true,
702 702
 			),
703 703
 			'class' => array(
704
-				'label' 	=> __('CSS Class', 'gravityview'),
705
-				'desc'	=> __('CSS class to add to the wrapping HTML container.', 'gravityview'),
704
+				'label' 	=> __( 'CSS Class', 'gravityview' ),
705
+				'desc'	=> __( 'CSS class to add to the wrapping HTML container.', 'gravityview' ),
706 706
 				'group'	=> 'default',
707 707
 				'type' => 'text',
708 708
 				'value' => '',
709 709
 				'show_in_shortcode' => false,
710 710
 			),
711 711
 			'search_value' => array(
712
-				'label' 	=> __('Search Value', 'gravityview'),
713
-				'desc'	=> __('Define a default search value for the View', 'gravityview'),
712
+				'label' 	=> __( 'Search Value', 'gravityview' ),
713
+				'desc'	=> __( 'Define a default search value for the View', 'gravityview' ),
714 714
 				'type' => 'text',
715 715
 				'value' => '',
716 716
 				'group'	=> 'filter',
717 717
 				'show_in_shortcode' => false,
718 718
 			),
719 719
 			'search_field' => array(
720
-				'label' 	=> __('Search Field', 'gravityview'),
721
-				'desc'	=> __('If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview'),
720
+				'label' 	=> __( 'Search Field', 'gravityview' ),
721
+				'desc'	=> __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview' ),
722 722
 				'type' => 'number',
723 723
 				'value' => '',
724 724
 				'group'	=> 'filter',
725 725
 				'show_in_shortcode' => false,
726 726
 			),
727 727
 			'single_title' => array(
728
-				'label'	=> __('Single Entry Title', 'gravityview'),
728
+				'label'	=> __( 'Single Entry Title', 'gravityview' ),
729 729
 				'type'	=> 'text',
730
-				'desc'	=> __('When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview'),
730
+				'desc'	=> __( 'When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview' ),
731 731
 				'group'	=> 'default',
732 732
 				'value'	=> '',
733 733
 				'show_in_shortcode' => false,
734 734
 				'full_width' => true,
735 735
 			),
736 736
 			'back_link_label' => array(
737
-				'label'	=> __('Back Link Label', 'gravityview'),
737
+				'label'	=> __( 'Back Link Label', 'gravityview' ),
738 738
 				'group'	=> 'default',
739
-				'desc'	=> __('The text of the link that returns to the multiple entries view.', 'gravityview'),
739
+				'desc'	=> __( 'The text of the link that returns to the multiple entries view.', 'gravityview' ),
740 740
 				'type'	=> 'text',
741 741
 				'value'	=> '',
742 742
 				'show_in_shortcode' => false,
743 743
 				'full_width' => true,
744 744
 			),
745 745
 			'embed_only' => array(
746
-				'label'	=> __('Prevent Direct Access', 'gravityview'),
746
+				'label'	=> __( 'Prevent Direct Access', 'gravityview' ),
747 747
 				'group'	=> 'default',
748
-				'desc'	=> __('Only allow access to this View when embedded using the shortcode.', 'gravityview'),
748
+				'desc'	=> __( 'Only allow access to this View when embedded using the shortcode.', 'gravityview' ),
749 749
 				'type'	=> 'checkbox',
750 750
 				'value'	=> '',
751 751
 				'show_in_shortcode' => false,
@@ -756,15 +756,15 @@  discard block
 block discarded – undo
756 756
 				'value' => '',
757 757
 				'show_in_shortcode' => false,
758 758
 			),
759
-		));
759
+		) );
760 760
 
761 761
 		// By default, we only want the key => value pairing, not the whole array.
762
-		if( empty( $with_details ) ) {
762
+		if ( empty( $with_details ) ) {
763 763
 
764 764
 			$defaults = array();
765 765
 
766
-			foreach( $default_settings as $key => $value ) {
767
-				$defaults[ $key ] = $value['value'];
766
+			foreach ( $default_settings as $key => $value ) {
767
+				$defaults[ $key ] = $value[ 'value' ];
768 768
 			}
769 769
 
770 770
 			return $defaults;
@@ -773,12 +773,12 @@  discard block
 block discarded – undo
773 773
 		// But sometimes, we want all the details.
774 774
 		else {
775 775
 
776
-			foreach ($default_settings as $key => $value) {
776
+			foreach ( $default_settings as $key => $value ) {
777 777
 
778 778
 				// If the $group argument is set for the method,
779 779
 				// ignore any settings that aren't in that group.
780
-				if( !empty( $group ) && is_string( $group ) ) {
781
-					if( empty( $value['group'] ) || $value['group'] !== $group ) {
780
+				if ( ! empty( $group ) && is_string( $group ) ) {
781
+					if ( empty( $value[ 'group' ] ) || $value[ 'group' ] !== $group ) {
782 782
 						unset( $default_settings[ $key ] );
783 783
 					}
784 784
 				}
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 						/** Deprecated, see \GV\View_Collection::from_post */
82 82
 						if( ( get_post_type( $post ) === 'gravityview' ) ) {
83 83
 							$ids[] = $post->ID;
84
-						} else{
84
+						} else {
85 85
 							// Parse the Post Content
86 86
 							$id = $this->parse_post_content( $post->post_content );
87 87
 							if( $id ) {
@@ -105,8 +105,9 @@  discard block
 block discarded – undo
105 105
 					if ( function_exists( 'gravityview' ) ) {
106 106
 						$shortcodes = \GV\Shortcode::parse( $passed_post );
107 107
 						foreach ( $shortcodes as $shortcode ) {
108
-							if ( $shortcode->name == 'gravityview' && !empty( $shortcode->atts['id'] ) )
109
-								$ids []= $shortcode->atts['id'];
108
+							if ( $shortcode->name == 'gravityview' && !empty( $shortcode->atts['id'] ) ) {
109
+															$ids []= $shortcode->atts['id'];
110
+							}
110 111
 						}
111 112
 					} else {
112 113
 						/** Deprecated, use \GV\Shortcode::parse. */
@@ -507,7 +508,7 @@  discard block
 block discarded – undo
507 508
 		}
508 509
 
509 510
 		if( ! $message ) {
510
-			if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) )  {
511
+			if ( function_exists( 'gravityview' ) && $post = get_post( $post_id ) ) {
511 512
 				$views = GV\View_Collection::from_post( $post );
512 513
 				$view_ids_in_post = array_map( function( $view ) { return $view->ID; }, $views->all() );
513 514
 			} else {
Please login to merge, or discard this patch.