Completed
Push — develop ( da0095...8c385e )
by Zack
07:21
created
future/includes/class-gv-settings-addon.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @return array
103 103
 	 */
104 104
 	public function modify_app_settings_menu_title( $setting_tabs ) {
105
-		$setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview' );
105
+		$setting_tabs[ 0 ][ 'label' ] = __( 'GravityView Settings', 'gravityview' );
106 106
 		return $setting_tabs;
107 107
 	}
108 108
 
@@ -308,15 +308,15 @@  discard block
 block discarded – undo
308 308
             </ul>
309 309
             <div class="gv-followup widefat">
310 310
                 <p><strong><label for="gv-reason-details"><?php esc_html_e( 'Comments', 'gravityview' ); ?></label></strong></p>
311
-                <textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e('Please share your thoughts about GravityView', 'gravityview') ?>" placeholder="<?php esc_attr_e('Please share your thoughts about GravityView', 'gravityview'); ?>" class="large-text"></textarea>
311
+                <textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ) ?>" placeholder="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ); ?>" class="large-text"></textarea>
312 312
             </div>
313 313
             <div class="scale-description">
314 314
                 <p><strong><?php esc_html_e( 'How likely are you to recommend GravityView?', 'gravityview' ); ?></strong></p>
315 315
                 <ul class="inline">
316 316
 					<?php
317 317
 					$i = 0;
318
-					while( $i < 11 ) {
319
-						echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_'.$i.'" value="'.$i.'" type="radio"> '.$i.'</label></li>';
318
+					while ( $i < 11 ) {
319
+						echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_' . $i . '" value="' . $i . '" type="radio"> ' . $i . '</label></li>';
320 320
 						$i++;
321 321
 					}
322 322
 					?>
@@ -549,15 +549,15 @@  discard block
 block discarded – undo
549 549
 	 * @return string The HTML
550 550
 	 */
551 551
 	public function as_html( $field, $echo = true ) {
552
-		$field['type']  = ( isset( $field['type'] ) && in_array( $field['type'], array( 'submit','reset','button' ) ) ) ? $field['type'] : 'submit';
552
+		$field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], array( 'submit', 'reset', 'button' ) ) ) ? $field[ 'type' ] : 'submit';
553 553
 
554 554
 		$attributes    = $this->get_field_attributes( $field );
555 555
 		$default_value = Utils::get( $field, 'value', Utils::get( $field, 'default_value' ) );
556
-		$value         = $this->get( $field['name'], $default_value );
556
+		$value         = $this->get( $field[ 'name' ], $default_value );
557 557
 
558 558
 
559
-		$attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton';
560
-		$name    = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_' . $field['name'];
559
+		$attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary gfbutton';
560
+		$name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ];
561 561
 
562 562
 		if ( empty( $value ) ) {
563 563
 			$value = __( 'Update Settings', 'gravityview' );
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 		$attributes = $this->get_field_attributes( $field );
567 567
 
568 568
 		$html = '<input
569
-                    type="' . $field['type'] . '"
569
+                    type="' . $field[ 'type' ] . '"
570 570
                     name="' . esc_attr( $name ) . '"
571 571
                     value="' . $value . '" ' .
572 572
 		        implode( ' ', $attributes ) .
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	 * @return bool
598 598
 	 */
599 599
 	public function is_save_postback() {
600
-		return isset( $_POST['gform-settings-save'] ) && isset( $_POST['_gravityview_save_settings_nonce'] );
600
+		return isset( $_POST[ 'gform-settings-save' ] ) && isset( $_POST[ '_gravityview_save_settings_nonce' ] );
601 601
 	}
602 602
 
603 603
 	/**
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	 */
608 608
 	public function license_key_notice() {
609 609
 
610
-	    if( $this->is_save_postback() ) {
610
+	    if ( $this->is_save_postback() ) {
611 611
 		    $settings = $this->get_posted_settings();
612 612
 		    $license_key = defined( 'GRAVITYVIEW_LICENSE_KEY' ) ? GRAVITYVIEW_LICENSE_KEY : \GV\Utils::get( $settings, 'license_key' );
613 613
 		    $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' );
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 		 * but didn't want to mess up the translation strings for the translators.
629 629
 		 */
630 630
 		$message = mb_substr( $message, 0, mb_strlen( $message ) - 1 );
631
-		$title = __( 'Inactive License', 'gravityview');
631
+		$title = __( 'Inactive License', 'gravityview' );
632 632
 		$status = '';
633 633
 		$update_below = false;
634 634
 		$primary_button_link = admin_url( 'edit.php?post_type=gravityview&amp;page=gravityview_settings' );
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 				$update_below = __( 'Activate your license key below.', 'gravityview' );
659 659
 				break;
660 660
 		}
661
-		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice';
661
+		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice';
662 662
 
663 663
 		// Show a different notice on settings page for inactive licenses (hide the buttons)
664 664
 		if ( $update_below && gravityview()->request->is_admin( '', 'settings' ) ) {
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	public function scripts() {
703 703
 		$scripts = parent::scripts();
704 704
 
705
-		$scripts[] = array(
705
+		$scripts[ ] = array(
706 706
 			'handle'  => 'gform_tooltip_init',
707 707
 			'enqueue' => array(
708 708
                 array(
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	public function styles() {
722 722
 		$styles = parent::styles();
723 723
 
724
-		$styles[] = array(
724
+		$styles[ ] = array(
725 725
 			'handle'  => 'gravityview_settings',
726 726
 			'src'     => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ),
727 727
 			'version' => Plugin::$version,
@@ -810,26 +810,26 @@  discard block
 block discarded – undo
810 810
 				'label' => __( 'License Key', 'gravityview' ),
811 811
 				'description' => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates &amp; support.', 'gravityview' ) . $this->get_license_handler()->license_details( $this->get_app_setting( 'license_key_response' ) ),
812 812
 				'type' => 'edd_license',
813
-				'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' )  && GRAVITYVIEW_LICENSE_KEY ),
813
+				'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ),
814 814
 				'data-pending-text' => __( 'Verifying license&hellip;', 'gravityview' ),
815
-				'default_value' => $default_settings['license_key'],
815
+				'default_value' => $default_settings[ 'license_key' ],
816 816
 				'class' => ( '' == $this->get( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
817 817
 			),
818 818
 			array(
819 819
 				'name' => 'license_key_response',
820
-				'default_value' => $default_settings['license_key_response'],
820
+				'default_value' => $default_settings[ 'license_key_response' ],
821 821
 				'type' => 'hidden',
822 822
 			),
823 823
 			array(
824 824
 				'name' => 'license_key_status',
825
-				'default_value' => $default_settings['license_key_status'],
825
+				'default_value' => $default_settings[ 'license_key_status' ],
826 826
 				'type' => 'hidden',
827 827
 			),
828 828
 			array(
829 829
 				'name' => 'support-email',
830 830
 				'type' => 'text',
831 831
 				'validate' => 'email',
832
-				'default_value' => $default_settings['support-email'],
832
+				'default_value' => $default_settings[ 'support-email' ],
833 833
 				'label' => __( 'Support Email', 'gravityview' ),
834 834
 				'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ),
835 835
 				'class' => 'code regular-text',
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 				'name' => 'support_port',
842 842
 				'type' => 'radio',
843 843
 				'label' => __( 'Show Support Port?', 'gravityview' ),
844
-				'default_value' => $default_settings['support_port'],
844
+				'default_value' => $default_settings[ 'support_port' ],
845 845
 				'horizontal' => 1,
846 846
 				'choices' => array(
847 847
 					array(
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 				'name' => 'no-conflict-mode',
861 861
 				'type' => 'radio',
862 862
 				'label' => __( 'No-Conflict Mode', 'gravityview' ),
863
-				'default_value' => $default_settings['no-conflict-mode'],
863
+				'default_value' => $default_settings[ 'no-conflict-mode' ],
864 864
 				'horizontal' => 1,
865 865
 				'choices' => array(
866 866
 					array(
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 					'name' => 'rest_api',
883 883
 					'type' => 'radio',
884 884
 					'label' => __( 'REST API', 'gravityview' ),
885
-					'default_value' => $default_settings['rest_api'],
885
+					'default_value' => $default_settings[ 'rest_api' ],
886 886
 					'horizontal' => 1,
887 887
 					'choices' => array(
888 888
 						array(
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 				'name' => 'beta',
902 902
 				'type' => 'checkbox',
903 903
 				'label' => __( 'Become a Beta Tester', 'gravityview' ),
904
-				'default_value' => $default_settings['beta'],
904
+				'default_value' => $default_settings[ 'beta' ],
905 905
 				'horizontal' => 1,
906 906
 				'choices' => array(
907 907
 					array(
@@ -934,17 +934,17 @@  discard block
 block discarded – undo
934 934
 		 * @since 1.7.4
935 935
 		 */
936 936
 		foreach ( $fields as &$field ) {
937
-			$field['name']          = isset( $field['name'] ) ? $field['name'] : Utils::get( $field, 'id' );
938
-			$field['label']         = isset( $field['label'] ) ? $field['label'] : Utils::get( $field, 'title' );
939
-			$field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : Utils::get( $field, 'default' );
940
-			$field['description']   = isset( $field['description'] ) ? $field['description'] : Utils::get( $field, 'subtitle' );
937
+			$field[ 'name' ]          = isset( $field[ 'name' ] ) ? $field[ 'name' ] : Utils::get( $field, 'id' );
938
+			$field[ 'label' ]         = isset( $field[ 'label' ] ) ? $field[ 'label' ] : Utils::get( $field, 'title' );
939
+			$field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : Utils::get( $field, 'default' );
940
+			$field[ 'description' ]   = isset( $field[ 'description' ] ) ? $field[ 'description' ] : Utils::get( $field, 'subtitle' );
941 941
 
942 942
 			if ( $disabled_attribute ) {
943
-				$field['disabled']  = $disabled_attribute;
943
+				$field[ 'disabled' ] = $disabled_attribute;
944 944
 			}
945 945
 
946
-			if ( empty( $field['disabled'] ) ) {
947
-				unset( $field['disabled'] );
946
+			if ( empty( $field[ 'disabled' ] ) ) {
947
+				unset( $field[ 'disabled' ] );
948 948
             }
949 949
 		}
950 950
 
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
         );
963 963
 
964 964
 		if ( $disabled_attribute ) {
965
-			$button['disabled'] = $disabled_attribute;
965
+			$button[ 'disabled' ] = $disabled_attribute;
966 966
 		}
967 967
 
968 968
         /**
@@ -981,20 +981,20 @@  discard block
 block discarded – undo
981 981
 		// If there are extensions, add a section for them
982 982
 		if ( ! empty( $extension_sections ) ) {
983 983
 
984
-			if( $disabled_attribute ) {
984
+			if ( $disabled_attribute ) {
985 985
 				foreach ( $extension_sections as &$section ) {
986
-					foreach ( $section['fields'] as &$field ) {
987
-						$field['disabled'] = $disabled_attribute;
986
+					foreach ( $section[ 'fields' ] as &$field ) {
987
+						$field[ 'disabled' ] = $disabled_attribute;
988 988
 					}
989 989
 				}
990 990
 			}
991 991
 
992
-            $k = count( $extension_sections ) - 1 ;
993
-            $extension_sections[ $k ]['fields'][] = $button;
992
+            $k = count( $extension_sections ) - 1;
993
+            $extension_sections[ $k ][ 'fields' ][ ] = $button;
994 994
 			$sections = array_merge( $sections, $extension_sections );
995 995
 		} else {
996 996
             // add the 'update settings' button to the general section
997
-            $sections[0]['fields'][] = $button;
997
+            $sections[ 0 ][ 'fields' ][ ] = $button;
998 998
         }
999 999
 
1000 1000
 		return $sections;
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 	protected function settings_edd_license( $field, $echo = true ) {
1051 1051
 
1052 1052
 	    if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) {
1053
-		    $field['input_type'] = 'password';
1053
+		    $field[ 'input_type' ] = 'password';
1054 1054
         }
1055 1055
 
1056 1056
 		$text = $this->settings_text( $field, false );
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 	public function single_setting_row_html( $field ) {
1100 1100
 		?>
1101 1101
 
1102
-        <tr id="gaddon-setting-row-<?php echo esc_attr( $field['name'] ); ?>">
1102
+        <tr id="gaddon-setting-row-<?php echo esc_attr( $field[ 'name' ] ); ?>">
1103 1103
             <td colspan="2">
1104 1104
 				<?php $this->single_setting( $field ); ?>
1105 1105
             </td>
@@ -1117,10 +1117,10 @@  discard block
 block discarded – undo
1117 1117
 	 * @return string
1118 1118
 	 */
1119 1119
 	public function settings_save( $field, $echo = true ) {
1120
-		$field['type']  = 'submit';
1121
-		$field['name']  = 'gform-settings-save';
1122
-		$field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton';
1123
-		$field['value'] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) );
1120
+		$field[ 'type' ]  = 'submit';
1121
+		$field[ 'name' ]  = 'gform-settings-save';
1122
+		$field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] : 'button-primary gfbutton';
1123
+		$field[ 'value' ] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) );
1124 1124
 
1125 1125
 		$output = $this->settings_submit( $field, false );
1126 1126
 
@@ -1151,8 +1151,8 @@  discard block
 block discarded – undo
1151 1151
      * @return void
1152 1152
 	 */
1153 1153
 	public function single_setting_row( $field ) {
1154
-		$field['gv_description'] = Utils::get( $field, 'description' );
1155
-		$field['description']    = Utils::get( $field, 'subtitle' );
1154
+		$field[ 'gv_description' ] = Utils::get( $field, 'description' );
1155
+		$field[ 'description' ]    = Utils::get( $field, 'subtitle' );
1156 1156
 		parent::single_setting_row( $field );
1157 1157
 	}
1158 1158
 
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 	public function single_setting_label( $field ) {
1165 1165
 		parent::single_setting_label( $field );
1166 1166
 		if ( $description = Utils::get( $field, 'gv_description' ) ) {
1167
-			echo '<span class="description">'. $description .'</span>';
1167
+			echo '<span class="description">' . $description . '</span>';
1168 1168
 		}
1169 1169
 	}
1170 1170
 
@@ -1209,10 +1209,10 @@  discard block
 block discarded – undo
1209 1209
 		// then we assume it's changed. If it's changed, unset the status and the previous response.
1210 1210
 		if ( ! $added_message && ( $local_key !== $response_key ) ) {
1211 1211
 
1212
-			unset( $posted_settings['license_key_response'] );
1213
-			unset( $posted_settings['license_key_status'] );
1212
+			unset( $posted_settings[ 'license_key_response' ] );
1213
+			unset( $posted_settings[ 'license_key_status' ] );
1214 1214
 
1215
-			\GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
1215
+			\GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
1216 1216
 
1217 1217
 			$added_message = true;
1218 1218
 		}
Please login to merge, or discard this patch.