Completed
Push — develop ( ca604f...ac8bbb )
by Zack
19:09
created
future/includes/class-gv-settings-addon.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @return array
102 102
 	 */
103 103
 	public function modify_app_settings_menu_title( $setting_tabs ) {
104
-		$setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview' );
104
+		$setting_tabs[ 0 ][ 'label' ] = __( 'GravityView Settings', 'gravityview' );
105 105
 		return $setting_tabs;
106 106
 	}
107 107
 
@@ -304,15 +304,15 @@  discard block
 block discarded – undo
304 304
             </ul>
305 305
             <div class="gv-followup widefat">
306 306
                 <p><strong><label for="gv-reason-details"><?php esc_html_e( 'Comments', 'gravityview' ); ?></label></strong></p>
307
-                <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>
307
+                <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>
308 308
             </div>
309 309
             <div class="scale-description">
310 310
                 <p><strong><?php esc_html_e( 'How likely are you to recommend GravityView?', 'gravityview' ); ?></strong></p>
311 311
                 <ul class="inline">
312 312
 					<?php
313 313
 					$i = 0;
314
-					while( $i < 11 ) {
315
-						echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_'.$i.'" value="'.$i.'" type="radio"> '.$i.'</label></li>';
314
+					while ( $i < 11 ) {
315
+						echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_' . $i . '" value="' . $i . '" type="radio"> ' . $i . '</label></li>';
316 316
 						$i++;
317 317
 					}
318 318
 					?>
@@ -529,15 +529,15 @@  discard block
 block discarded – undo
529 529
 	 * @return string The HTML
530 530
 	 */
531 531
 	public function as_html( $field, $echo = true ) {
532
-		$field['type']  = ( isset( $field['type'] ) && in_array( $field['type'], array( 'submit','reset','button' ) ) ) ? $field['type'] : 'submit';
532
+		$field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], array( 'submit', 'reset', 'button' ) ) ) ? $field[ 'type' ] : 'submit';
533 533
 
534 534
 		$attributes    = $this->get_field_attributes( $field );
535 535
 		$default_value = Utils::get( $field, 'value', Utils::get( $field, 'default_value' ) );
536
-		$value         = $this->get( $field['name'], $default_value );
536
+		$value         = $this->get( $field[ 'name' ], $default_value );
537 537
 
538 538
 
539
-		$attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton';
540
-		$name    = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_' . $field['name'];
539
+		$attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary gfbutton';
540
+		$name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ];
541 541
 
542 542
 		if ( empty( $value ) ) {
543 543
 			$value = __( 'Update Settings', 'gravityview' );
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 		$attributes = $this->get_field_attributes( $field );
547 547
 
548 548
 		$html = '<input
549
-                    type="' . $field['type'] . '"
549
+                    type="' . $field[ 'type' ] . '"
550 550
                     name="' . esc_attr( $name ) . '"
551 551
                     value="' . $value . '" ' .
552 552
 		        implode( ' ', $attributes ) .
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	 */
575 575
 	public function license_key_notice() {
576 576
 
577
-	    if( $this->is_save_postback() ) {
577
+	    if ( $this->is_save_postback() ) {
578 578
 		    $settings = $this->get_posted_settings();
579 579
 		    $license_key = \GV\Utils::get( $settings, 'license_key' );
580 580
 		    $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' );
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 		 * but didn't want to mess up the translation strings for the translators.
593 593
 		 */
594 594
 		$message = mb_substr( $message, 0, mb_strlen( $message ) - 1 );
595
-		$title = __ ( 'Inactive License', 'gravityview');
595
+		$title = __( 'Inactive License', 'gravityview' );
596 596
 		$status = '';
597 597
 		$update_below = false;
598 598
 		$primary_button_link = admin_url( 'edit.php?post_type=gravityview&amp;page=gravityview_settings' );
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 				$update_below = __( 'Activate your license key below.', 'gravityview' );
623 623
 				break;
624 624
 		}
625
-		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice';
625
+		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice';
626 626
 
627 627
 		// Show a different notice on settings page for inactive licenses (hide the buttons)
628 628
 		if ( $update_below && gravityview_is_admin_page( '', 'settings' ) ) {
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 	public function scripts() {
665 665
 		$scripts = parent::scripts();
666 666
 
667
-		$scripts[] = array(
667
+		$scripts[ ] = array(
668 668
 			'handle'  => 'gform_tooltip_init',
669 669
 			'enqueue' => array(
670 670
                 array(
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 	public function styles() {
684 684
 		$styles = parent::styles();
685 685
 
686
-		$styles[] = array(
686
+		$styles[ ] = array(
687 687
 			'handle'  => 'gravityview_settings',
688 688
 			'src'     => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ),
689 689
 			'version' => Plugin::$version,
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 		 * If multisite and not network admin, we don't want the settings to show.
715 715
 		 * @since 1.7.6
716 716
 		 */
717
-		$show_submenu = ( ! is_multisite() ) ||  is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() );
717
+		$show_submenu = ( ! is_multisite() ) || is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() );
718 718
 
719 719
 		/**
720 720
 		 * Override whether to show the Settings menu on a per-blog basis.
@@ -762,26 +762,26 @@  discard block
 block discarded – undo
762 762
 				'label' => __( 'License Key', 'gravityview' ),
763 763
 				'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' ) ),
764 764
 				'type' => 'edd_license',
765
-				'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' )  && GRAVITYVIEW_LICENSE_KEY ),
765
+				'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ),
766 766
 				'data-pending-text' => __( 'Verifying license&hellip;', 'gravityview' ),
767
-				'default_value' => $default_settings['license_key'],
767
+				'default_value' => $default_settings[ 'license_key' ],
768 768
 				'class' => ( '' == $this->get( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
769 769
 			),
770 770
 			array(
771 771
 				'name' => 'license_key_response',
772
-				'default_value' => $default_settings['license_key_response'],
772
+				'default_value' => $default_settings[ 'license_key_response' ],
773 773
 				'type' => 'hidden',
774 774
 			),
775 775
 			array(
776 776
 				'name' => 'license_key_status',
777
-				'default_value' => $default_settings['license_key_status'],
777
+				'default_value' => $default_settings[ 'license_key_status' ],
778 778
 				'type' => 'hidden',
779 779
 			),
780 780
 			array(
781 781
 				'name' => 'support-email',
782 782
 				'type' => 'text',
783 783
 				'validate' => 'email',
784
-				'default_value' => $default_settings['support-email'],
784
+				'default_value' => $default_settings[ 'support-email' ],
785 785
 				'label' => __( 'Support Email', 'gravityview' ),
786 786
 				'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ),
787 787
 				'class' => 'code regular-text',
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 				'name' => 'support_port',
794 794
 				'type' => 'radio',
795 795
 				'label' => __( 'Show Support Port?', 'gravityview' ),
796
-				'default_value' => $default_settings['support_port'],
796
+				'default_value' => $default_settings[ 'support_port' ],
797 797
 				'horizontal' => 1,
798 798
 				'choices' => array(
799 799
 					array(
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 				'name' => 'no-conflict-mode',
813 813
 				'type' => 'radio',
814 814
 				'label' => __( 'No-Conflict Mode', 'gravityview' ),
815
-				'default_value' => $default_settings['no-conflict-mode'],
815
+				'default_value' => $default_settings[ 'no-conflict-mode' ],
816 816
 				'horizontal' => 1,
817 817
 				'choices' => array(
818 818
 					array(
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 					'name' => 'rest_api',
835 835
 					'type' => 'radio',
836 836
 					'label' => __( 'REST API', 'gravityview' ),
837
-					'default_value' => $default_settings['rest_api'],
837
+					'default_value' => $default_settings[ 'rest_api' ],
838 838
 					'horizontal' => 1,
839 839
 					'choices' => array(
840 840
 						array(
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 				'name' => 'beta',
854 854
 				'type' => 'checkbox',
855 855
 				'label' => __( 'Become a Beta Tester', 'gravityview' ),
856
-				'default_value' => $default_settings['beta'],
856
+				'default_value' => $default_settings[ 'beta' ],
857 857
 				'horizontal' => 1,
858 858
 				'choices' => array(
859 859
 					array(
@@ -886,17 +886,17 @@  discard block
 block discarded – undo
886 886
 		 * @since 1.7.4
887 887
 		 */
888 888
 		foreach ( $fields as &$field ) {
889
-			$field['name']          = isset( $field['name'] ) ? $field['name'] : Utils::get( $field, 'id' );
890
-			$field['label']         = isset( $field['label'] ) ? $field['label'] : Utils::get( $field, 'title' );
891
-			$field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : Utils::get( $field, 'default' );
892
-			$field['description']   = isset( $field['description'] ) ? $field['description'] : Utils::get( $field, 'subtitle' );
889
+			$field[ 'name' ]          = isset( $field[ 'name' ] ) ? $field[ 'name' ] : Utils::get( $field, 'id' );
890
+			$field[ 'label' ]         = isset( $field[ 'label' ] ) ? $field[ 'label' ] : Utils::get( $field, 'title' );
891
+			$field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : Utils::get( $field, 'default' );
892
+			$field[ 'description' ]   = isset( $field[ 'description' ] ) ? $field[ 'description' ] : Utils::get( $field, 'subtitle' );
893 893
 
894 894
 			if ( $disabled_attribute ) {
895
-				$field['disabled']  = $disabled_attribute;
895
+				$field[ 'disabled' ] = $disabled_attribute;
896 896
 			}
897 897
 
898
-			if ( empty( $field['disabled'] ) ) {
899
-				unset( $field['disabled'] );
898
+			if ( empty( $field[ 'disabled' ] ) ) {
899
+				unset( $field[ 'disabled' ] );
900 900
             }
901 901
 		}
902 902
 
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
         );
915 915
 
916 916
 		if ( $disabled_attribute ) {
917
-			$button['disabled'] = $disabled_attribute;
917
+			$button[ 'disabled' ] = $disabled_attribute;
918 918
 		}
919 919
 
920 920
         /**
@@ -933,20 +933,20 @@  discard block
 block discarded – undo
933 933
 		// If there are extensions, add a section for them
934 934
 		if ( ! empty( $extension_sections ) ) {
935 935
 
936
-			if( $disabled_attribute ) {
936
+			if ( $disabled_attribute ) {
937 937
 				foreach ( $extension_sections as &$section ) {
938
-					foreach ( $section['fields'] as &$field ) {
939
-						$field['disabled'] = $disabled_attribute;
938
+					foreach ( $section[ 'fields' ] as &$field ) {
939
+						$field[ 'disabled' ] = $disabled_attribute;
940 940
 					}
941 941
 				}
942 942
 			}
943 943
 
944
-            $k = count( $extension_sections ) - 1 ;
945
-            $extension_sections[ $k ]['fields'][] = $button;
944
+            $k = count( $extension_sections ) - 1;
945
+            $extension_sections[ $k ][ 'fields' ][ ] = $button;
946 946
 			$sections = array_merge( $sections, $extension_sections );
947 947
 		} else {
948 948
             // add the 'update settings' button to the general section
949
-            $sections[0]['fields'][] = $button;
949
+            $sections[ 0 ][ 'fields' ][ ] = $button;
950 950
         }
951 951
 
952 952
 		return $sections;
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 	protected function settings_edd_license( $field, $echo = true ) {
1003 1003
 
1004 1004
 	    if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) {
1005
-		    $field['input_type'] = 'password';
1005
+		    $field[ 'input_type' ] = 'password';
1006 1006
         }
1007 1007
 
1008 1008
 		$text = $this->settings_text( $field, false );
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 	public function single_setting_row_html( $field ) {
1052 1052
 		?>
1053 1053
 
1054
-        <tr id="gaddon-setting-row-<?php echo esc_attr( $field['name'] ); ?>">
1054
+        <tr id="gaddon-setting-row-<?php echo esc_attr( $field[ 'name' ] ); ?>">
1055 1055
             <td colspan="2">
1056 1056
 				<?php $this->single_setting( $field ); ?>
1057 1057
             </td>
@@ -1069,10 +1069,10 @@  discard block
 block discarded – undo
1069 1069
 	 * @return string
1070 1070
 	 */
1071 1071
 	public function settings_save( $field, $echo = true ) {
1072
-		$field['type']  = 'submit';
1073
-		$field['name']  = 'gform-settings-save';
1074
-		$field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton';
1075
-		$field['value'] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) );
1072
+		$field[ 'type' ]  = 'submit';
1073
+		$field[ 'name' ]  = 'gform-settings-save';
1074
+		$field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] : 'button-primary gfbutton';
1075
+		$field[ 'value' ] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) );
1076 1076
 
1077 1077
 		$output = $this->settings_submit( $field, false );
1078 1078
 
@@ -1103,8 +1103,8 @@  discard block
 block discarded – undo
1103 1103
      * @return void
1104 1104
 	 */
1105 1105
 	public function single_setting_row( $field ) {
1106
-		$field['gv_description'] = Utils::get( $field, 'description' );
1107
-		$field['description']    = Utils::get( $field, 'subtitle' );
1106
+		$field[ 'gv_description' ] = Utils::get( $field, 'description' );
1107
+		$field[ 'description' ]    = Utils::get( $field, 'subtitle' );
1108 1108
 		parent::single_setting_row( $field );
1109 1109
 	}
1110 1110
 
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 	public function single_setting_label( $field ) {
1117 1117
 		parent::single_setting_label( $field );
1118 1118
 		if ( $description = Utils::get( $field, 'gv_description' ) ) {
1119
-			echo '<span class="description">'. $description .'</span>';
1119
+			echo '<span class="description">' . $description . '</span>';
1120 1120
 		}
1121 1121
 	}
1122 1122
 
@@ -1153,9 +1153,9 @@  discard block
 block discarded – undo
1153 1153
 		// If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response),
1154 1154
 		// then we assume it's changed. If it's changed, unset the status and the previous response.
1155 1155
 		if ( $local_key !== $response_key ) {
1156
-			unset( $posted_settings['license_key_response'] );
1157
-			unset( $posted_settings['license_key_status'] );
1158
-			\GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
1156
+			unset( $posted_settings[ 'license_key_response' ] );
1157
+			unset( $posted_settings[ 'license_key_status' ] );
1158
+			\GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
1159 1159
 		}
1160 1160
 		return $posted_settings;
1161 1161
 	}
Please login to merge, or discard this patch.