Completed
Push — develop ( 151ba0...47ccc8 )
by Zack
45:18 queued 41:47
created
future/includes/class-gv-settings-addon.php 1 patch
Spacing   +53 added lines, -53 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
 					?>
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 	 * @return array The settings.
486 486
 	 */
487 487
 	public function all() {
488
-		$option_name  = 'gravityformsaddon_' . $this->_slug . '_app_settings';
488
+		$option_name = 'gravityformsaddon_' . $this->_slug . '_app_settings';
489 489
 
490
-		if( is_multisite() ) {
490
+		if ( is_multisite() ) {
491 491
 			$option_value = get_blog_option( get_main_site_id(), $option_name, array() );
492 492
         } else {
493 493
 		    $option_value = get_site_option( $option_name, array() );
@@ -542,15 +542,15 @@  discard block
 block discarded – undo
542 542
 	 * @return string The HTML
543 543
 	 */
544 544
 	public function as_html( $field, $echo = true ) {
545
-		$field['type']  = ( isset( $field['type'] ) && in_array( $field['type'], array( 'submit','reset','button' ) ) ) ? $field['type'] : 'submit';
545
+		$field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], array( 'submit', 'reset', 'button' ) ) ) ? $field[ 'type' ] : 'submit';
546 546
 
547 547
 		$attributes    = $this->get_field_attributes( $field );
548 548
 		$default_value = Utils::get( $field, 'value', Utils::get( $field, 'default_value' ) );
549
-		$value         = $this->get( $field['name'], $default_value );
549
+		$value         = $this->get( $field[ 'name' ], $default_value );
550 550
 
551 551
 
552
-		$attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton';
553
-		$name    = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_' . $field['name'];
552
+		$attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary gfbutton';
553
+		$name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ];
554 554
 
555 555
 		if ( empty( $value ) ) {
556 556
 			$value = __( 'Update Settings', 'gravityview' );
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 		$attributes = $this->get_field_attributes( $field );
560 560
 
561 561
 		$html = '<input
562
-                    type="' . $field['type'] . '"
562
+                    type="' . $field[ 'type' ] . '"
563 563
                     name="' . esc_attr( $name ) . '"
564 564
                     value="' . $value . '" ' .
565 565
 		        implode( ' ', $attributes ) .
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	 * @return bool
591 591
 	 */
592 592
 	public function is_save_postback() {
593
-		return isset( $_POST['gform-settings-save'] ) && isset( $_POST['_gravityview_save_settings_nonce'] );
593
+		return isset( $_POST[ 'gform-settings-save' ] ) && isset( $_POST[ '_gravityview_save_settings_nonce' ] );
594 594
 	}
595 595
 
596 596
 	/**
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 */
601 601
 	public function license_key_notice() {
602 602
 
603
-	    if( $this->is_save_postback() ) {
603
+	    if ( $this->is_save_postback() ) {
604 604
 		    $settings = $this->get_posted_settings();
605 605
 		    $license_key = \GV\Utils::get( $settings, 'license_key' );
606 606
 		    $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' );
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 		 * but didn't want to mess up the translation strings for the translators.
622 622
 		 */
623 623
 		$message = mb_substr( $message, 0, mb_strlen( $message ) - 1 );
624
-		$title = __( 'Inactive License', 'gravityview');
624
+		$title = __( 'Inactive License', 'gravityview' );
625 625
 		$status = '';
626 626
 		$update_below = false;
627 627
 		$primary_button_link = admin_url( 'edit.php?post_type=gravityview&amp;page=gravityview_settings' );
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 				$update_below = __( 'Activate your license key below.', 'gravityview' );
652 652
 				break;
653 653
 		}
654
-		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice';
654
+		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice';
655 655
 
656 656
 		// Show a different notice on settings page for inactive licenses (hide the buttons)
657 657
 		if ( $update_below && gravityview()->request->is_admin( '', 'settings' ) ) {
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 	public function scripts() {
696 696
 		$scripts = parent::scripts();
697 697
 
698
-		$scripts[] = array(
698
+		$scripts[ ] = array(
699 699
 			'handle'  => 'gform_tooltip_init',
700 700
 			'enqueue' => array(
701 701
                 array(
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 	public function styles() {
715 715
 		$styles = parent::styles();
716 716
 
717
-		$styles[] = array(
717
+		$styles[ ] = array(
718 718
 			'handle'  => 'gravityview_settings',
719 719
 			'src'     => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ),
720 720
 			'version' => Plugin::$version,
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 		 * If multisite and not network admin, we don't want the settings to show.
746 746
 		 * @since 1.7.6
747 747
 		 */
748
-		$show_submenu = ( ! is_multisite() ) ||  is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() );
748
+		$show_submenu = ( ! is_multisite() ) || is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() );
749 749
 
750 750
 		/**
751 751
 		 * Override whether to show the Settings menu on a per-blog basis.
@@ -793,26 +793,26 @@  discard block
 block discarded – undo
793 793
 				'label' => __( 'License Key', 'gravityview' ),
794 794
 				'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' ) ),
795 795
 				'type' => 'edd_license',
796
-				'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' )  && GRAVITYVIEW_LICENSE_KEY ),
796
+				'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ),
797 797
 				'data-pending-text' => __( 'Verifying license&hellip;', 'gravityview' ),
798
-				'default_value' => $default_settings['license_key'],
798
+				'default_value' => $default_settings[ 'license_key' ],
799 799
 				'class' => ( '' == $this->get( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
800 800
 			),
801 801
 			array(
802 802
 				'name' => 'license_key_response',
803
-				'default_value' => $default_settings['license_key_response'],
803
+				'default_value' => $default_settings[ 'license_key_response' ],
804 804
 				'type' => 'hidden',
805 805
 			),
806 806
 			array(
807 807
 				'name' => 'license_key_status',
808
-				'default_value' => $default_settings['license_key_status'],
808
+				'default_value' => $default_settings[ 'license_key_status' ],
809 809
 				'type' => 'hidden',
810 810
 			),
811 811
 			array(
812 812
 				'name' => 'support-email',
813 813
 				'type' => 'text',
814 814
 				'validate' => 'email',
815
-				'default_value' => $default_settings['support-email'],
815
+				'default_value' => $default_settings[ 'support-email' ],
816 816
 				'label' => __( 'Support Email', 'gravityview' ),
817 817
 				'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ),
818 818
 				'class' => 'code regular-text',
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 				'name' => 'support_port',
825 825
 				'type' => 'radio',
826 826
 				'label' => __( 'Show Support Port?', 'gravityview' ),
827
-				'default_value' => $default_settings['support_port'],
827
+				'default_value' => $default_settings[ 'support_port' ],
828 828
 				'horizontal' => 1,
829 829
 				'choices' => array(
830 830
 					array(
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 				'name' => 'no-conflict-mode',
844 844
 				'type' => 'radio',
845 845
 				'label' => __( 'No-Conflict Mode', 'gravityview' ),
846
-				'default_value' => $default_settings['no-conflict-mode'],
846
+				'default_value' => $default_settings[ 'no-conflict-mode' ],
847 847
 				'horizontal' => 1,
848 848
 				'choices' => array(
849 849
 					array(
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 					'name' => 'rest_api',
866 866
 					'type' => 'radio',
867 867
 					'label' => __( 'REST API', 'gravityview' ),
868
-					'default_value' => $default_settings['rest_api'],
868
+					'default_value' => $default_settings[ 'rest_api' ],
869 869
 					'horizontal' => 1,
870 870
 					'choices' => array(
871 871
 						array(
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 				'name' => 'beta',
885 885
 				'type' => 'checkbox',
886 886
 				'label' => __( 'Become a Beta Tester', 'gravityview' ),
887
-				'default_value' => $default_settings['beta'],
887
+				'default_value' => $default_settings[ 'beta' ],
888 888
 				'horizontal' => 1,
889 889
 				'choices' => array(
890 890
 					array(
@@ -917,17 +917,17 @@  discard block
 block discarded – undo
917 917
 		 * @since 1.7.4
918 918
 		 */
919 919
 		foreach ( $fields as &$field ) {
920
-			$field['name']          = isset( $field['name'] ) ? $field['name'] : Utils::get( $field, 'id' );
921
-			$field['label']         = isset( $field['label'] ) ? $field['label'] : Utils::get( $field, 'title' );
922
-			$field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : Utils::get( $field, 'default' );
923
-			$field['description']   = isset( $field['description'] ) ? $field['description'] : Utils::get( $field, 'subtitle' );
920
+			$field[ 'name' ]          = isset( $field[ 'name' ] ) ? $field[ 'name' ] : Utils::get( $field, 'id' );
921
+			$field[ 'label' ]         = isset( $field[ 'label' ] ) ? $field[ 'label' ] : Utils::get( $field, 'title' );
922
+			$field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : Utils::get( $field, 'default' );
923
+			$field[ 'description' ]   = isset( $field[ 'description' ] ) ? $field[ 'description' ] : Utils::get( $field, 'subtitle' );
924 924
 
925 925
 			if ( $disabled_attribute ) {
926
-				$field['disabled']  = $disabled_attribute;
926
+				$field[ 'disabled' ] = $disabled_attribute;
927 927
 			}
928 928
 
929
-			if ( empty( $field['disabled'] ) ) {
930
-				unset( $field['disabled'] );
929
+			if ( empty( $field[ 'disabled' ] ) ) {
930
+				unset( $field[ 'disabled' ] );
931 931
             }
932 932
 		}
933 933
 
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
         );
946 946
 
947 947
 		if ( $disabled_attribute ) {
948
-			$button['disabled'] = $disabled_attribute;
948
+			$button[ 'disabled' ] = $disabled_attribute;
949 949
 		}
950 950
 
951 951
         /**
@@ -964,20 +964,20 @@  discard block
 block discarded – undo
964 964
 		// If there are extensions, add a section for them
965 965
 		if ( ! empty( $extension_sections ) ) {
966 966
 
967
-			if( $disabled_attribute ) {
967
+			if ( $disabled_attribute ) {
968 968
 				foreach ( $extension_sections as &$section ) {
969
-					foreach ( $section['fields'] as &$field ) {
970
-						$field['disabled'] = $disabled_attribute;
969
+					foreach ( $section[ 'fields' ] as &$field ) {
970
+						$field[ 'disabled' ] = $disabled_attribute;
971 971
 					}
972 972
 				}
973 973
 			}
974 974
 
975
-            $k = count( $extension_sections ) - 1 ;
976
-            $extension_sections[ $k ]['fields'][] = $button;
975
+            $k = count( $extension_sections ) - 1;
976
+            $extension_sections[ $k ][ 'fields' ][ ] = $button;
977 977
 			$sections = array_merge( $sections, $extension_sections );
978 978
 		} else {
979 979
             // add the 'update settings' button to the general section
980
-            $sections[0]['fields'][] = $button;
980
+            $sections[ 0 ][ 'fields' ][ ] = $button;
981 981
         }
982 982
 
983 983
 		return $sections;
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 	protected function settings_edd_license( $field, $echo = true ) {
1034 1034
 
1035 1035
 	    if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) {
1036
-		    $field['input_type'] = 'password';
1036
+		    $field[ 'input_type' ] = 'password';
1037 1037
         }
1038 1038
 
1039 1039
 		$text = $this->settings_text( $field, false );
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 	public function single_setting_row_html( $field ) {
1083 1083
 		?>
1084 1084
 
1085
-        <tr id="gaddon-setting-row-<?php echo esc_attr( $field['name'] ); ?>">
1085
+        <tr id="gaddon-setting-row-<?php echo esc_attr( $field[ 'name' ] ); ?>">
1086 1086
             <td colspan="2">
1087 1087
 				<?php $this->single_setting( $field ); ?>
1088 1088
             </td>
@@ -1100,10 +1100,10 @@  discard block
 block discarded – undo
1100 1100
 	 * @return string
1101 1101
 	 */
1102 1102
 	public function settings_save( $field, $echo = true ) {
1103
-		$field['type']  = 'submit';
1104
-		$field['name']  = 'gform-settings-save';
1105
-		$field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton';
1106
-		$field['value'] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) );
1103
+		$field[ 'type' ]  = 'submit';
1104
+		$field[ 'name' ]  = 'gform-settings-save';
1105
+		$field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] : 'button-primary gfbutton';
1106
+		$field[ 'value' ] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) );
1107 1107
 
1108 1108
 		$output = $this->settings_submit( $field, false );
1109 1109
 
@@ -1134,8 +1134,8 @@  discard block
 block discarded – undo
1134 1134
      * @return void
1135 1135
 	 */
1136 1136
 	public function single_setting_row( $field ) {
1137
-		$field['gv_description'] = Utils::get( $field, 'description' );
1138
-		$field['description']    = Utils::get( $field, 'subtitle' );
1137
+		$field[ 'gv_description' ] = Utils::get( $field, 'description' );
1138
+		$field[ 'description' ]    = Utils::get( $field, 'subtitle' );
1139 1139
 		parent::single_setting_row( $field );
1140 1140
 	}
1141 1141
 
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 	public function single_setting_label( $field ) {
1148 1148
 		parent::single_setting_label( $field );
1149 1149
 		if ( $description = Utils::get( $field, 'gv_description' ) ) {
1150
-			echo '<span class="description">'. $description .'</span>';
1150
+			echo '<span class="description">' . $description . '</span>';
1151 1151
 		}
1152 1152
 	}
1153 1153
 
@@ -1184,9 +1184,9 @@  discard block
 block discarded – undo
1184 1184
 		// If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response),
1185 1185
 		// then we assume it's changed. If it's changed, unset the status and the previous response.
1186 1186
 		if ( $local_key !== $response_key ) {
1187
-			unset( $posted_settings['license_key_response'] );
1188
-			unset( $posted_settings['license_key_status'] );
1189
-			\GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
1187
+			unset( $posted_settings[ 'license_key_response' ] );
1188
+			unset( $posted_settings[ 'license_key_status' ] );
1189
+			\GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
1190 1190
 		}
1191 1191
 		return $posted_settings;
1192 1192
 	}
Please login to merge, or discard this patch.