Completed
Push — develop ( 35a5b0...71f46a )
by Zack
16:25
created
includes/class-gravityview-compatibility.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -240,7 +240,7 @@
 block discarded – undo
240 240
 			self::$notices['wp_version'] = array(
241 241
 				'class' => 'error',
242 242
 				'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>' ),
243
-			    'cap' => 'update_core',
243
+				'cap' => 'update_core',
244 244
 				'dismiss' => 'wp_version',
245 245
 			);
246 246
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
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;
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 		// If Gravity Forms doesn't exist or is outdated, load the admin view class to
139 139
 		// show the notice, but not load any post types or process shortcodes.
140 140
 		// Without Gravity Forms, there is no GravityView. Beautiful, really.
141
-		if( ! self::is_valid() ) {
141
+		if ( ! self::is_valid() ) {
142 142
 
143 143
 			// If the plugin's not loaded, might as well hide the shortcode for people.
144
-			add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice') );
144
+			add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice' ) );
145 145
 
146 146
 		}
147 147
 	}
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public function _shortcode_gf_notice( $atts = array(), $content = null, $shortcode = 'gravityview' ) {
169 169
 
170
-		if( ! GVCommon::has_cap( 'activate_plugins' ) ) {
170
+		if ( ! GVCommon::has_cap( 'activate_plugins' ) ) {
171 171
 			return null;
172 172
 		}
173 173
 
174 174
 		$notices = self::get_notices();
175 175
 
176
-		$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>';
177
-		foreach( (array)$notices as $notice ) {
178
-			$message .= wpautop( $notice['message'] );
176
+		$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>';
177
+		foreach ( (array)$notices as $notice ) {
178
+			$message .= wpautop( $notice[ 'message' ] );
179 179
 		}
180 180
 		$message .= '</div>';
181 181
 
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 
196 196
 		if ( ! gravityview()->plugin->is_compatible_php() ) {
197 197
 
198
-			self::$notices['php_version'] = array(
198
+			self::$notices[ 'php_version' ] = array(
199 199
 				'class' => 'error',
200
-				'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>' ),
200
+				'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>' ),
201 201
 				'cap' => 'manage_options',
202 202
 				'dismiss' => 'php_version',
203 203
 			);
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 		if ( ! gravityview()->plugin->is_compatible_future_php() ) {
209 209
 
210 210
 			// Show the notice on every update. Yes, annoying, but not as annoying as a plugin breaking.
211
-			$key = sprintf('php_%s_%s', GV_FUTURE_MIN_PHP_VERSION, GravityView_Plugin::version );
211
+			$key = sprintf( 'php_%s_%s', GV_FUTURE_MIN_PHP_VERSION, GravityView_Plugin::version );
212 212
 
213 213
 			self::$notices[ $key ] = array(
214 214
 				'class' => 'error',
215
-				'message' => sprintf( __( "%sGravityView will soon require PHP Version %s.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_FUTURE_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ),
215
+				'message' => sprintf( __( "%sGravityView will soon require PHP Version %s.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_FUTURE_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . phpversion() . '</span>' ),
216 216
 				'cap' => 'manage_options',
217 217
 				'dismiss' => $key,
218 218
 			);
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 		if ( ! gravityview()->plugin->is_compatible_wordpress() ) {
239 239
 
240
-			self::$notices['wp_version'] = array(
240
+			self::$notices[ 'wp_version' ] = array(
241 241
 				'class' => 'error',
242 242
 				'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>' ),
243 243
 			    'cap' => 'update_core',
@@ -271,17 +271,17 @@  discard block
 block discarded – undo
271 271
 	public static function check_gravityforms() {
272 272
 
273 273
 		// Bypass other checks: if the class exists
274
-		if( class_exists( 'GFCommon' ) ) {
274
+		if ( class_exists( 'GFCommon' ) ) {
275 275
 
276 276
 			// Does the version meet future requirements?
277
-			if( true === gravityview()->plugin->is_compatible_future_gravityforms() ) {
277
+			if ( true === gravityview()->plugin->is_compatible_future_gravityforms() ) {
278 278
 				return true;
279 279
 			}
280 280
 
281 281
 			// Does it meet minimum requirements?
282 282
 			$meets_minimum = gravityview()->plugin->is_compatible_gravityforms();
283 283
 
284
-			if( $meets_minimum ) {
284
+			if ( $meets_minimum ) {
285 285
 				/* translators: first placeholder is the future required version of Gravity Forms. The second placeholder is the current version of Gravity Forms. */
286 286
 				$title = __( 'In the future, GravityView will require Gravity Forms Version %s or newer.', 'gravityview' );
287 287
 				$version = GV_FUTURE_MIN_GF_VERSION;
@@ -296,14 +296,14 @@  discard block
 block discarded – undo
296 296
 			$message = '<h3>' . esc_html( sprintf( $title, $version ) ) . '</h3>';
297 297
 
298 298
 			/* translators: the placeholder is the current version of Gravity Forms. */
299
-			$message .= '<p>' . sprintf( esc_html__( "You're using Version %s. Please update your Gravity Forms or purchase a license.", 'gravityview' ), '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>' ) . '</p>';
299
+			$message .= '<p>' . sprintf( esc_html__( "You're using Version %s. Please update your Gravity Forms or purchase a license.", 'gravityview' ), '<span style="font-family: Consolas, Courier, monospace;">' . GFCommon::$version . '</span>' ) . '</p>';
300 300
 
301 301
 			/* translators: In this context, "get" means purchase */
302 302
 			$message .= '<p><a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">' . esc_html__( 'Get the Latest Gravity Forms', 'gravityview' ) . '</a></p>';
303 303
 
304 304
 
305 305
 			// Show the notice even if the future version requirements aren't met
306
-			self::$notices['gf_version'] = array(
306
+			self::$notices[ 'gf_version' ] = array(
307 307
 				'class' => $class,
308 308
 				'message' => $message,
309 309
 				'cap' => 'update_plugins',
@@ -321,42 +321,42 @@  discard block
 block discarded – undo
321 321
 		 * OR
322 322
 		 * It's the Network Admin and we just don't know whether the sites have GF activated themselves.
323 323
 		 */
324
-		if( true === $gf_status || is_network_admin() ) {
324
+		if ( true === $gf_status || is_network_admin() ) {
325 325
 			return true;
326 326
 		}
327 327
 
328 328
 		// If GFCommon doesn't exist, assume GF not active
329 329
 		$return = false;
330 330
 
331
-		switch( $gf_status ) {
331
+		switch ( $gf_status ) {
332 332
 			case 'inactive':
333 333
 
334 334
 				// Required for multisite
335
-				if( ! function_exists('wp_create_nonce') ) {
335
+				if ( ! function_exists( 'wp_create_nonce' ) ) {
336 336
 					require_once ABSPATH . WPINC . '/pluggable.php';
337 337
 				}
338 338
 
339 339
 				// Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE"
340
-				if( is_multisite() ) {
340
+				if ( is_multisite() ) {
341 341
 					wp_cookie_constants();
342 342
 				}
343 343
 
344 344
 				$return = false;
345 345
 
346
-				$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">';
346
+				$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">';
347 347
 
348
-				self::$notices['gf_inactive'] = array(
348
+				self::$notices[ 'gf_inactive' ] = array(
349 349
 					'class' => 'error',
350
-					'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>' ),
350
+					'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>' ),
351 351
 					'cap' => 'activate_plugins',
352 352
 					'dismiss' => 'gf_inactive',
353 353
 				);
354 354
 
355 355
 				break;
356 356
 			default:
357
-				self::$notices['gf_installed'] = array(
357
+				self::$notices[ 'gf_installed' ] = array(
358 358
 					'class' => 'error',
359
-					'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $59%s%s', 'gravityview' ), '<h3>', "</h3>\n\n".'<a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'),
359
+					'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $59%s%s', 'gravityview' ), '<h3>', "</h3>\n\n" . '<a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>' ),
360 360
 					'cap' => 'install_plugins',
361 361
 					'dismiss' => 'gf_installed',
362 362
 				);
@@ -373,10 +373,10 @@  discard block
 block discarded – undo
373 373
 	 */
374 374
 	private static function check_gf_directory() {
375 375
 
376
-		if( class_exists( 'GFDirectory' ) ) {
377
-			self::$notices['gf_directory'] = array(
376
+		if ( class_exists( 'GFDirectory' ) ) {
377
+			self::$notices[ 'gf_directory' ] = array(
378 378
 				'class' => 'error is-dismissible',
379
-				'title' => __('Potential Conflict', 'gravityview' ),
379
+				'title' => __( 'Potential Conflict', 'gravityview' ),
380 380
 				'message' => __( 'GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview' ),
381 381
 				'dismiss' => 'gf_directory',
382 382
 				'cap' => 'activate_plugins',
@@ -394,21 +394,21 @@  discard block
 block discarded – undo
394 394
 	 */
395 395
 	public static function get_plugin_status( $location = '' ) {
396 396
 
397
-		if( ! function_exists('is_plugin_active') ) {
397
+		if ( ! function_exists( 'is_plugin_active' ) ) {
398 398
 			include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
399 399
 		}
400 400
 
401
-		if( is_network_admin() && is_plugin_active_for_network( $location ) ) {
401
+		if ( is_network_admin() && is_plugin_active_for_network( $location ) ) {
402 402
 			return true;
403 403
 		}
404 404
 
405
-		if( ! is_network_admin() && is_plugin_active( $location ) ) {
405
+		if ( ! is_network_admin() && is_plugin_active( $location ) ) {
406 406
 			return true;
407 407
 		}
408 408
 
409
-		if(
410
-			!file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
411
-			!file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
409
+		if (
410
+			! file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
411
+			! file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
412 412
 		) {
413 413
 			return false;
414 414
 		}
Please login to merge, or discard this patch.