Completed
Push — develop ( 2f7cb5...6c998d )
by Zack
06:19
created
includes/class-gravityview-settings.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function __construct( $prevent_multiple_instances = '' ) {
73 73
 
74
-		if( $prevent_multiple_instances === 'get_instance' ) {
74
+		if ( $prevent_multiple_instances === 'get_instance' ) {
75 75
 			return parent::__construct();
76 76
 		}
77 77
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public static function get_instance() {
85 85
 
86
-		if( empty( self::$instance ) ) {
86
+		if ( empty( self::$instance ) ) {
87 87
 			self::$instance = new self( 'get_instance' );
88 88
 		}
89 89
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 		 * Prevent Gravity Forms from showing the uninstall tab on the settings page
107 107
 		 * @hack
108 108
 		 */
109
-		if( $caps === $this->_capabilities_uninstall ) {
109
+		if ( $caps === $this->_capabilities_uninstall ) {
110 110
 			return false;
111 111
 		}
112 112
 
113
-		if( empty( $caps ) ) {
113
+		if ( empty( $caps ) ) {
114 114
 			$caps = array( 'gravityview_full_access' );
115 115
 		}
116 116
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		add_filter( 'gform_addon_app_settings_menu_gravityview', array( $this, 'modify_app_settings_menu_title' ) );
134 134
 
135 135
 		/** @since 1.7.6 */
136
-		add_action('network_admin_menu', array( $this, 'add_network_menu' ) );
136
+		add_action( 'network_admin_menu', array( $this, 'add_network_menu' ) );
137 137
 
138 138
 		parent::init_admin();
139 139
 	}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function modify_app_settings_menu_title( $setting_tabs ) {
149 149
 
150
-		$setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview');
150
+		$setting_tabs[ 0 ][ 'label' ] = __( 'GravityView Settings', 'gravityview' );
151 151
 
152 152
 		return $setting_tabs;
153 153
 	}
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	private function _load_license_handler() {
166 166
 
167
-		if( !empty( $this->License_Handler ) ) {
167
+		if ( ! empty( $this->License_Handler ) ) {
168 168
 			return;
169 169
 		}
170 170
 
171
-		require_once( GRAVITYVIEW_DIR . 'includes/class-gv-license-handler.php');
171
+		require_once( GRAVITYVIEW_DIR . 'includes/class-gv-license-handler.php' );
172 172
 
173 173
 		$this->License_Handler = GV_License_Handler::get_instance( $this );
174 174
 	}
@@ -180,60 +180,60 @@  discard block
 block discarded – undo
180 180
 	function license_key_notice() {
181 181
 
182 182
 		// Only show on GravityView pages
183
-		if( ! gravityview_is_admin_page() ) {
183
+		if ( ! gravityview_is_admin_page() ) {
184 184
 			return;
185 185
 		}
186 186
 
187
-		$license_status = self::getSetting('license_key_status');
188
-		$license_id = self::getSetting('license_key');
187
+		$license_status = self::getSetting( 'license_key_status' );
188
+		$license_id = self::getSetting( 'license_key' );
189 189
 		$license_id = empty( $license_id ) ? 'license' : $license_id;
190 190
 
191
-		$message = esc_html__('Your GravityView license %s. This means you’re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview');
191
+		$message = esc_html__( 'Your GravityView license %s. This means you’re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview' );
192 192
 
193 193
 		/**
194 194
 		 * I wanted to remove the period from after the buttons in the string,
195 195
 		 * but didn't want to mess up the translation strings for the translators.
196 196
 		 */
197 197
 		$message = mb_substr( $message, 0, mb_strlen( $message ) - 1 );
198
-		$title = __('Inactive License', 'gravityview');
198
+		$title = __( 'Inactive License', 'gravityview' );
199 199
 		$status = '';
200 200
 		$update_below = false;
201 201
 		$primary_button_link = admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' );
202 202
 		switch ( $license_status ) {
203 203
 			case 'invalid':
204
-				$title = __('Invalid License', 'gravityview');
205
-				$status = __('is invalid', 'gravityview');
204
+				$title = __( 'Invalid License', 'gravityview' );
205
+				$status = __( 'is invalid', 'gravityview' );
206 206
 				break;
207 207
 			case 'deactivated':
208
-				$status = __('is inactive', 'gravityview');
209
-				$update_below = __('Activate your license key below.', 'gravityview');
208
+				$status = __( 'is inactive', 'gravityview' );
209
+				$update_below = __( 'Activate your license key below.', 'gravityview' );
210 210
 				break;
211 211
 			/** @noinspection PhpMissingBreakStatementInspection */
212 212
 			case '':
213 213
 				$license_status = 'site_inactive';
214 214
 				// break intentionally left blank
215 215
 			case 'site_inactive':
216
-				$status = __('has not been activated', 'gravityview');
217
-				$update_below = __('Activate your license key below.', 'gravityview');
216
+				$status = __( 'has not been activated', 'gravityview' );
217
+				$update_below = __( 'Activate your license key below.', 'gravityview' );
218 218
 				break;
219 219
 		}
220
-		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice';
220
+		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice';
221 221
 
222 222
 		// Show a different notice on settings page for inactive licenses (hide the buttons)
223
-		if( $update_below && gravityview_is_admin_page( '', 'settings' ) ) {
223
+		if ( $update_below && gravityview_is_admin_page( '', 'settings' ) ) {
224 224
 			$message = sprintf( $message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">' . $update_below . '</a>' );
225 225
 		} else {
226 226
 			$message = sprintf( $message, $status, "\n\n" . '<a href="' . $primary_button_link . '" class="button button-primary">', '</a>', '<a href="' . esc_url( $url ) . '" class="button button-secondary">', '</a>' );
227 227
 		}
228 228
 
229
-		if( !empty( $status ) ) {
229
+		if ( ! empty( $status ) ) {
230 230
 			GravityView_Admin_Notices::add_notice( array(
231 231
 				'message' => $message,
232 232
 				'class'	=> 'updated',
233 233
 				'title' => $title,
234 234
 				'cap' => 'gravityview_edit_settings',
235
-				'dismiss' => sha1( $license_status.'_'.$license_id ),
236
-			));
235
+				'dismiss' => sha1( $license_status . '_' . $license_id ),
236
+			) );
237 237
 		}
238 238
 	}
239 239
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 
246 246
 		$styles = parent::styles();
247 247
 
248
-		$styles[] = array(
248
+		$styles[ ] = array(
249 249
 			'handle'  => 'gravityview_settings',
250 250
 			'src'     => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ),
251 251
 			'version' => GravityView_Plugin::version,
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 * @return void
269 269
 	 */
270 270
 	public function add_network_menu() {
271
-		if( GravityView_Plugin::is_network_activated() ) {
271
+		if ( GravityView_Plugin::is_network_activated() ) {
272 272
 			add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' );
273 273
 		}
274 274
 	}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		 * If multisite and not network admin, we don't want the settings to show.
286 286
 		 * @since 1.7.6
287 287
 		 */
288
-		$show_submenu = !is_multisite() ||  is_main_site() || !GravityView_Plugin::is_network_activated() || ( is_network_admin() && GravityView_Plugin::is_network_activated() );
288
+		$show_submenu = ! is_multisite() || is_main_site() || ! GravityView_Plugin::is_network_activated() || ( is_network_admin() && GravityView_Plugin::is_network_activated() );
289 289
 
290 290
 		/**
291 291
 		 * Override whether to show the Settings menu on a per-blog basis.
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		 */
295 295
 		$show_submenu = apply_filters( 'gravityview/show-settings-menu', $show_submenu );
296 296
 
297
-		if( $show_submenu ) {
297
+		if ( $show_submenu ) {
298 298
 			add_submenu_page( 'edit.php?post_type=gravityview', __( 'Settings', 'gravityview' ), __( 'Settings', 'gravityview' ), $this->_capabilities_app_settings, $this->_slug . '_settings', array( $this, 'app_tab_page' ) );
299 299
 		}
300 300
 	}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		/**
326 326
 		 * Backward compatibility with Redux
327 327
 		 */
328
-		if( $setting_name === 'license' ) {
328
+		if ( $setting_name === 'license' ) {
329 329
 			return array(
330 330
 				'license' => parent::get_app_setting( 'license_key' ),
331 331
 				'status' => parent::get_app_setting( 'license_key_status' ),
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 
390 390
 		$return = $text . $activation;
391 391
 
392
-		if( $echo ) {
392
+		if ( $echo ) {
393 393
 			echo $return;
394 394
 		}
395 395
 
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
 	 */
417 417
 	public function settings_submit( $field, $echo = true ) {
418 418
 
419
-		$field['type']  = ( isset($field['type']) && in_array( $field['type'], array('submit','reset','button') ) ) ? $field['type'] : 'submit';
419
+		$field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], array( 'submit', 'reset', 'button' ) ) ) ? $field[ 'type' ] : 'submit';
420 420
 
421 421
 		$attributes    = $this->get_field_attributes( $field );
422 422
 		$default_value = rgar( $field, 'value' ) ? rgar( $field, 'value' ) : rgar( $field, 'default_value' );
423
-		$value         = $this->get_setting( $field['name'], $default_value );
423
+		$value         = $this->get_setting( $field[ 'name' ], $default_value );
424 424
 
425 425
 
426
-		$attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton';
427
-		$name    = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_'.$field['name'];
426
+		$attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary gfbutton';
427
+		$name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ];
428 428
 
429 429
 		if ( empty( $value ) ) {
430 430
 			$value = __( 'Update Settings', 'gravityview' );
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 		$attributes = $this->get_field_attributes( $field );
434 434
 
435 435
 		$html = '<input
436
-                    type="' . $field['type'] . '"
436
+                    type="' . $field[ 'type' ] . '"
437 437
                     name="' . esc_attr( $name ) . '"
438 438
                     value="' . $value . '" ' .
439 439
 		        implode( ' ', $attributes ) .
@@ -455,16 +455,16 @@  discard block
 block discarded – undo
455 455
 	 * @return string
456 456
 	 */
457 457
 	public function settings_save( $field, $echo = true ) {
458
-		$field['type']  = 'submit';
459
-		$field['name']  = 'gform-settings-save';
460
-		$field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton';
458
+		$field[ 'type' ]  = 'submit';
459
+		$field[ 'name' ]  = 'gform-settings-save';
460
+		$field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] : 'button-primary gfbutton';
461 461
 
462 462
 		if ( ! rgar( $field, 'value' ) )
463
-			$field['value'] = __( 'Update Settings', 'gravityview' );
463
+			$field[ 'value' ] = __( 'Update Settings', 'gravityview' );
464 464
 
465 465
 		$output = $this->settings_submit( $field, false );
466 466
 
467
-		if( $echo ) {
467
+		if ( $echo ) {
468 468
 			echo $output;
469 469
 		}
470 470
 
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
 		parent::single_setting_label( $field );
482 482
 
483 483
 		// Added by GravityView
484
-		if ( isset( $field['description'] ) ) {
485
-			echo '<span class="description">'. $field['description'] .'</span>';
484
+		if ( isset( $field[ 'description' ] ) ) {
485
+			echo '<span class="description">' . $field[ 'description' ] . '</span>';
486 486
 		}
487 487
 
488 488
 	}
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
 
545 545
 		// If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response),
546 546
 		// then we assume it's changed. If it's changed, unset the status and the previous response.
547
-		if( $local_key !== $response_key ) {
547
+		if ( $local_key !== $response_key ) {
548 548
 
549
-			unset( $posted_settings['license_key_response'] );
550
-			unset( $posted_settings['license_key_status'] );
551
-			GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
549
+			unset( $posted_settings[ 'license_key_response' ] );
550
+			unset( $posted_settings[ 'license_key_status' ] );
551
+			GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
552 552
 		}
553 553
 
554 554
 		return $posted_settings;
@@ -583,25 +583,25 @@  discard block
 block discarded – undo
583 583
 				'label'             => __( 'License Key', 'gravityview' ),
584 584
 				'description'          => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates &amp; support.', 'gravityview' ),
585 585
 				'type'              => 'edd_license',
586
-				'data-pending-text' => __('Verifying license&hellip;', 'gravityview'),
587
-				'default_value'           => $default_settings['license_key'],
586
+				'data-pending-text' => __( 'Verifying license&hellip;', 'gravityview' ),
587
+				'default_value'           => $default_settings[ 'license_key' ],
588 588
 				'class'             => ( '' == $this->get_app_setting( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
589 589
 			),
590 590
 			array(
591 591
 				'name'       => 'license_key_response',
592
-				'default_value'  => $default_settings['license_key_response'],
592
+				'default_value'  => $default_settings[ 'license_key_response' ],
593 593
 				'type'     => 'hidden',
594 594
 			),
595 595
 			array(
596 596
 				'name'       => 'license_key_status',
597
-				'default_value'  => $default_settings['license_key_status'],
597
+				'default_value'  => $default_settings[ 'license_key_status' ],
598 598
 				'type'     => 'hidden',
599 599
 			),
600 600
 			array(
601 601
 				'name'       => 'support-email',
602 602
 				'type'     => 'text',
603 603
 				'validate' => 'email',
604
-				'default_value'  => $default_settings['support-email'],
604
+				'default_value'  => $default_settings[ 'support-email' ],
605 605
 				'label'    => __( 'Support Email', 'gravityview' ),
606 606
 				'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ),
607 607
 				'class'    => 'code regular-text',
@@ -613,44 +613,44 @@  discard block
 block discarded – undo
613 613
 				'name'         => 'support_port',
614 614
 				'type'       => 'radio',
615 615
 				'label'      => __( 'Show Support Port?', 'gravityview' ),
616
-				'default_value'    => $default_settings['support_port'],
616
+				'default_value'    => $default_settings[ 'support_port' ],
617 617
 				'horizontal' => 1,
618 618
 				'choices'    => array(
619 619
 					array(
620
-						'label' => _x('Show', 'Setting: Show or Hide', 'gravityview'),
620
+						'label' => _x( 'Show', 'Setting: Show or Hide', 'gravityview' ),
621 621
 						'value' => '1',
622 622
 					),
623 623
 					array(
624
-						'label' => _x('Hide', 'Setting: Show or Hide', 'gravityview'),
624
+						'label' => _x( 'Hide', 'Setting: Show or Hide', 'gravityview' ),
625 625
 						'value' => '0',
626 626
 					),
627 627
 				),
628
-				'tooltip' => '<p><img src="' . esc_url_raw( plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview') . '</p>',
628
+				'tooltip' => '<p><img src="' . esc_url_raw( plugins_url( 'assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__( 'The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview' ) . '</p>',
629 629
 				'description'   => __( 'Show the Support Port on GravityView pages?', 'gravityview' ),
630 630
 			),
631 631
 			array(
632 632
 				'name'         => 'no-conflict-mode',
633 633
 				'type'       => 'radio',
634 634
 				'label'      => __( 'No-Conflict Mode', 'gravityview' ),
635
-				'default_value'    => $default_settings['no-conflict-mode'],
635
+				'default_value'    => $default_settings[ 'no-conflict-mode' ],
636 636
 				'horizontal' => 1,
637 637
 				'choices'    => array(
638 638
 					array(
639
-						'label' => _x('On', 'Setting: On or off', 'gravityview'),
639
+						'label' => _x( 'On', 'Setting: On or off', 'gravityview' ),
640 640
 						'value' => '1',
641 641
 					),
642 642
 					array(
643
-						'label' => _x('Off', 'Setting: On or off', 'gravityview'),
643
+						'label' => _x( 'Off', 'Setting: On or off', 'gravityview' ),
644 644
 						'value' => '0',
645 645
 					),
646 646
 				),
647
-				'description'   => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __('If your Edit View tabs are ugly, enable this setting.', 'gravityview'),
647
+				'description'   => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __( 'If your Edit View tabs are ugly, enable this setting.', 'gravityview' ),
648 648
 			),
649 649
 			array(
650 650
 				'name'       => 'delete-on-uninstall',
651 651
 				'type'       => 'radio',
652 652
 				'label'      => __( 'Remove Data on Delete?', 'gravityview' ),
653
-				'default_value'    => $default_settings['delete-on-uninstall'],
653
+				'default_value'    => $default_settings[ 'delete-on-uninstall' ],
654 654
 				'horizontal' => 1,
655 655
 				'choices'    => array(
656 656
 					array(
@@ -676,20 +676,20 @@  discard block
 block discarded – undo
676 676
 		 * @since 1.7.4
677 677
 		 */
678 678
 		foreach ( $fields as &$field ) {
679
-			$field['name']          = isset( $field['name'] ) ? $field['name'] : rgget('id', $field );
680
-			$field['label']         = isset( $field['label'] ) ? $field['label'] : rgget('title', $field );
681
-			$field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : rgget('default', $field );
682
-			$field['description']   = isset( $field['description'] ) ? $field['description'] : rgget('subtitle', $field );
679
+			$field[ 'name' ]          = isset( $field[ 'name' ] ) ? $field[ 'name' ] : rgget( 'id', $field );
680
+			$field[ 'label' ]         = isset( $field[ 'label' ] ) ? $field[ 'label' ] : rgget( 'title', $field );
681
+			$field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : rgget( 'default', $field );
682
+			$field[ 'description' ]   = isset( $field[ 'description' ] ) ? $field[ 'description' ] : rgget( 'subtitle', $field );
683 683
 
684
-			if( $disabled_attribute ) {
685
-				$field['disabled']  = $disabled_attribute;
684
+			if ( $disabled_attribute ) {
685
+				$field[ 'disabled' ] = $disabled_attribute;
686 686
 			}
687 687
 		}
688 688
 
689 689
 
690 690
         $sections = array(
691 691
             array(
692
-                'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ),
692
+                'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __( 'You are running GravityView version %s', 'gravityview' ), GravityView_Plugin::version ) ),
693 693
                 'fields'      => $fields,
694 694
             )
695 695
         );
@@ -700,8 +700,8 @@  discard block
 block discarded – undo
700 700
             'type'     => 'save',
701 701
         );
702 702
 
703
-		if( $disabled_attribute ) {
704
-			$button['disabled'] = $disabled_attribute;
703
+		if ( $disabled_attribute ) {
704
+			$button[ 'disabled' ] = $disabled_attribute;
705 705
 		}
706 706
 
707 707
 
@@ -721,20 +721,20 @@  discard block
 block discarded – undo
721 721
 		// If there are extensions, add a section for them
722 722
 		if ( ! empty( $extension_sections ) ) {
723 723
 
724
-			if( $disabled_attribute ) {
724
+			if ( $disabled_attribute ) {
725 725
 				foreach ( $extension_sections as &$section ) {
726
-					foreach ( $section['fields'] as &$field ) {
727
-						$field['disabled'] = $disabled_attribute;
726
+					foreach ( $section[ 'fields' ] as &$field ) {
727
+						$field[ 'disabled' ] = $disabled_attribute;
728 728
 					}
729 729
 				}
730 730
 			}
731 731
 
732
-            $k = count( $extension_sections ) - 1 ;
733
-            $extension_sections[ $k ]['fields'][] = $button;
732
+            $k = count( $extension_sections ) - 1;
733
+            $extension_sections[ $k ][ 'fields' ][ ] = $button;
734 734
 			$sections = array_merge( $sections, $extension_sections );
735 735
 		} else {
736 736
             // add the 'update settings' button to the general section
737
-            $sections[0]['fields'][] = $button;
737
+            $sections[ 0 ][ 'fields' ][ ] = $button;
738 738
         }
739 739
 
740 740
 		return $sections;
Please login to merge, or discard this patch.