Passed
Push — add/42 ( 1e278f...24b3f4 )
by Warwick
04:38 queued 10s
created
classes/admin/class-settings-theme.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 	 * Contructor
39 39
 	 */
40 40
 	public function __construct() {
41
-		add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 );
42
-		add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 );
43
-		add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 );
44
-		add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 );
45
-		add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 );
46
-		add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 );
47
-		add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 );
48
-		add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 );
41
+		add_filter('cmb2_enqueue_css', array($this, 'disable_cmb2_styles'), 1, 1);
42
+		add_action('cmb2_before_form', array($this, 'generate_navigation'), 10, 4);
43
+		add_action('cmb2_before_title_field_row', array($this, 'output_tab_open_div'), 10, 1);
44
+		add_action('cmb2_after_tab_closing_field_row', array($this, 'output_tab_closing_div'), 10, 1);
45
+		add_action('cmb2_render_tab_closing', array($this, 'cmb2_render_callback_for_tab_closing'), 10, 5);
46
+		add_filter('cmb2_sanitize_tab_closing', array($this, 'cmb2_sanitize_tab_closing_callback'), 10, 2);
47
+		add_action('cmb2_after_form', array($this, 'navigation_js'), 10, 4);
48
+		add_filter('cmb2_options_page_redirect_url', array($this, 'add_tab_argument'), 10, 1);
49 49
 	}
50 50
 
51 51
 	/**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public static function get_instance() {
59 59
 		// If the single instance hasn't been set, set it now.
60
-		if ( null == self::$instance ) {
60
+		if (null == self::$instance) {
61 61
 			self::$instance = new self();
62 62
 		}
63 63
 		return self::$instance;
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @return bool $enabled Whether to enable (enqueue) styles.
70 70
 	 */
71
-	public function disable_cmb2_styles( $enabled ) {
72
-		if ( is_admin() ) {
71
+	public function disable_cmb2_styles($enabled) {
72
+		if (is_admin()) {
73 73
 			$current_screen = get_current_screen();
74
-			if ( is_object( $current_screen ) && 'project_page_lsx_projects_options' === $current_screen->id ) {
74
+			if (is_object($current_screen) && 'project_page_lsx_projects_options' === $current_screen->id) {
75 75
 				$enabled = false;
76 76
 			}
77 77
 		}
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 	 * @param object $cmb2_obj
88 88
 	 * @return void
89 89
 	 */
90
-	public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) {
91
-		if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) {
90
+	public function generate_navigation($cmb_id, $object_id, $object_type, $cmb2_obj) {
91
+		if ('lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type) {
92 92
 			$this->navigation      = array();
93 93
 			$this->is_options_page = true;
94
-			if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) {
95
-				foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) {
96
-					if ( 'title' === $field['type'] ) {
97
-						$this->navigation[ $field_index ] = $field['name'];
94
+			if (isset($cmb2_obj->meta_box['fields']) && ! empty($cmb2_obj->meta_box['fields'])) {
95
+				foreach ($cmb2_obj->meta_box['fields'] as $field_index => $field) {
96
+					if ('title' === $field['type']) {
97
+						$this->navigation[$field_index] = $field['name'];
98 98
 					}
99 99
 				}
100 100
 			}
@@ -108,32 +108,32 @@  discard block
 block discarded – undo
108 108
 	 * @return void
109 109
 	 */
110 110
 	public function output_navigation() {
111
-		if ( ! empty( $this->navigation ) ) {
111
+		if ( ! empty($this->navigation)) {
112 112
 			?>
113 113
 			<div class="wp-filter hide-if-no-js">
114 114
 				<ul class="filter-links">
115 115
 					<?php
116 116
 					$first_tab    = true;
117
-					$total        = count( $this->navigation );
117
+					$total        = count($this->navigation);
118 118
 					$count        = 0;
119 119
 					$separator    = ' |';
120 120
 					$selected_tab = '';
121
-					if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) {
122
-						$selected_tab = sanitize_text_field( wp_unslash( $_GET['cmb_tab'] ) );
121
+					if (isset($_GET['cmb_tab']) && '' !== $_GET['cmb_tab']) {
122
+						$selected_tab = sanitize_text_field(wp_unslash($_GET['cmb_tab']));
123 123
 						$selected_tab = 'settings_' . $selected_tab;
124 124
 					}
125
-					foreach ( $this->navigation as $key => $label ) {
125
+					foreach ($this->navigation as $key => $label) {
126 126
 						$count++;
127 127
 						$current_css = '';
128
-						if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) {
128
+						if ((true === $first_tab && '' === $selected_tab) || $key === $selected_tab) {
129 129
 							$first_tab   = false;
130 130
 							$current_css = 'current';
131 131
 						}
132
-						if ( $count === $total ) {
132
+						if ($count === $total) {
133 133
 							$separator = '';
134 134
 						}
135 135
 						?>
136
-							<li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li>
136
+							<li><a href="#" class="<?php echo esc_attr($current_css); ?>" data-sort="<?php echo esc_attr($key); ?>_tab"><?php echo esc_attr($label); ?></a><?php echo esc_attr($separator); ?></li>
137 137
 						<?php
138 138
 					}
139 139
 					?>
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 	 * @param object $field CMB2_Field();
150 150
 	 * @return void
151 151
 	 */
152
-	public function output_tab_open_div( $field ) {
153
-		if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) {
152
+	public function output_tab_open_div($field) {
153
+		if (true === $this->is_options_page && isset($field->args['type']) && 'title' === $field->args['type']) {
154 154
 			?>
155
-			<div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden">
155
+			<div id="<?php echo esc_attr($field->args['id']); ?>_tab" class="tab tab-nav hidden">
156 156
 			<?php
157 157
 		}
158 158
 	}
@@ -163,19 +163,19 @@  discard block
 block discarded – undo
163 163
 	 * @param object $field CMB2_Field();
164 164
 	 * @return void
165 165
 	 */
166
-	public function output_tab_closing_div( $field ) {
167
-		if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) {
166
+	public function output_tab_closing_div($field) {
167
+		if (true === $this->is_options_page && isset($field->args['type']) && 'tab_closing' === $field->args['type']) {
168 168
 			?>
169 169
 			</div>
170 170
 			<?php
171 171
 		}
172 172
 	}
173 173
 
174
-	public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) {
174
+	public function cmb2_render_callback_for_tab_closing($field, $escaped_value, $object_id, $object_type, $field_type_object) {
175 175
 		return;
176 176
 	}
177 177
 
178
-	public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) {
178
+	public function cmb2_sanitize_tab_closing_callback($override_value, $value) {
179 179
 		return '';
180 180
 	}
181 181
 
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @param object $cmb2_obj
189 189
 	 * @return void
190 190
 	 */
191
-	public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) {
192
-		if ( 'lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type ) {
191
+	public function navigation_js($cmb_id, $object_id, $object_type, $cmb2_obj) {
192
+		if ('lsx_projects_settings' === $cmb_id && 'lsx_projects_options' === $object_id && 'options-page' === $object_type) {
193 193
 			?>
194 194
 			<script>
195 195
 				var LSX_PROJECTS_CMB2 = Object.create( null );
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
 	 * @param string $url
272 272
 	 * @return void
273 273
 	 */
274
-	public function add_tab_argument( $url ) {
275
-		if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine
276
-			$tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine
277
-			$tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine
278
-			if ( 'single' !== $tab_selection ) {
279
-				$url = add_query_arg( 'cmb_tab', $tab_selection, $url );
274
+	public function add_tab_argument($url) {
275
+		if (isset($_POST['cmb_tab']) && '' !== $_POST['cmb_tab']) { // @codingStandardsIgnoreLine
276
+			$tab_selection = sanitize_text_field($_POST['cmb_tab']); // @codingStandardsIgnoreLine
277
+			$tab_selection = str_replace(array('settings_', '_tab'), '', $tab_selection); // @codingStandardsIgnoreLine
278
+			if ('single' !== $tab_selection) {
279
+				$url = add_query_arg('cmb_tab', $tab_selection, $url);
280 280
 			} else {
281
-				$url = remove_query_arg( 'cmb_tab', $url );
281
+				$url = remove_query_arg('cmb_tab', $url);
282 282
 			}
283 283
 		}
284 284
 		return $url;
Please login to merge, or discard this patch.