GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#31)
by
unknown
01:41
created
hm-post-repeat.php 1 patch
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -35,31 +35,31 @@  discard block
 block discarded – undo
35 35
 /**
36 36
  * Setup the actions and filters required by this class.
37 37
  */
38
-add_action( 'post_submitbox_misc_actions', __NAMESPACE__ . '\publish_box_ui' );
39
-add_action( 'save_post',                   __NAMESPACE__ . '\save_post_repeating_status', 10 );
40
-add_action( 'save_post',                   __NAMESPACE__ . '\create_next_repeat_post', 11 );
41
-add_action( 'admin_enqueue_scripts',       __NAMESPACE__ . '\enqueue_scripts' );
42
-add_filter( 'display_post_states',         __NAMESPACE__ . '\admin_table_row_post_states', 10, 2 );
38
+add_action('post_submitbox_misc_actions', __NAMESPACE__.'\publish_box_ui');
39
+add_action('save_post', __NAMESPACE__.'\save_post_repeating_status', 10);
40
+add_action('save_post', __NAMESPACE__.'\create_next_repeat_post', 11);
41
+add_action('admin_enqueue_scripts', __NAMESPACE__.'\enqueue_scripts');
42
+add_filter('display_post_states', __NAMESPACE__.'\admin_table_row_post_states', 10, 2);
43 43
 
44 44
 // Add repeat type table view to admin screen.
45
-add_filter( 'views_edit-post',             __NAMESPACE__ . '\admin_table_views_links' );
46
-add_filter( 'pre_get_posts',               __NAMESPACE__ . '\admin_table_repeat_type_posts_query' );
45
+add_filter('views_edit-post', __NAMESPACE__.'\admin_table_views_links');
46
+add_filter('pre_get_posts', __NAMESPACE__.'\admin_table_repeat_type_posts_query');
47 47
 
48 48
 /**
49 49
  * Enqueue the scripts and styles that are needed by this plugin.
50 50
  */
51
-function enqueue_scripts( $hook ) {
51
+function enqueue_scripts($hook) {
52 52
 
53 53
 	// Ensure we only load them on the edit post and add new post admin screens
54
-	if ( ! in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
54
+	if ( ! in_array($hook, array('post.php', 'post-new.php'))) {
55 55
 		return;
56 56
 	}
57 57
 
58
-	$plugin_data = get_plugin_data( __FILE__ );
59
-	$plugin_dir_url = plugin_dir_url( __FILE__ );
58
+	$plugin_data = get_plugin_data(__FILE__);
59
+	$plugin_dir_url = plugin_dir_url(__FILE__);
60 60
 
61
-	wp_enqueue_script( 'hm-post-repeat', $plugin_dir_url . 'hm-post-repeat.js', 'jquery', $plugin_data['Version'], true );
62
-	wp_enqueue_style( 'hm-post-repeat', $plugin_dir_url . 'hm-post-repeat.css', array(), $plugin_data['Version'] );
61
+	wp_enqueue_script('hm-post-repeat', $plugin_dir_url.'hm-post-repeat.js', 'jquery', $plugin_data['Version'], true);
62
+	wp_enqueue_style('hm-post-repeat', $plugin_dir_url.'hm-post-repeat.css', array(), $plugin_data['Version']);
63 63
 
64 64
 }
65 65
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function publish_box_ui() {
73 73
 
74
-	if ( ! in_array( get_post_type(), repeating_post_types() ) ) {
74
+	if ( ! in_array(get_post_type(), repeating_post_types())) {
75 75
 		return;
76 76
 	} ?>
77 77
 
@@ -79,31 +79,31 @@  discard block
 block discarded – undo
79 79
 
80 80
 		<span class="dashicons dashicons-controls-repeat"></span>
81 81
 
82
-		<?php esc_html_e( 'Repeat:', 'hm-post-repeat' ); ?>
82
+		<?php esc_html_e('Repeat:', 'hm-post-repeat'); ?>
83 83
 
84
-		<?php if ( is_repeat_post( get_the_id() ) ) : ?>
84
+		<?php if (is_repeat_post(get_the_id())) : ?>
85 85
 
86
-			<strong><?php printf( esc_html__( 'Repeat of %s', 'hm-post-repeat' ), '<a href="' . esc_url( get_edit_post_link( get_post()->post_parent ) ) . '">' . esc_html( get_the_title( get_post_field( 'post_parent', get_the_id() ) ) ) . '</a>' ); ?></strong>
86
+			<strong><?php printf(esc_html__('Repeat of %s', 'hm-post-repeat'), '<a href="'.esc_url(get_edit_post_link(get_post()->post_parent)).'">'.esc_html(get_the_title(get_post_field('post_parent', get_the_id()))).'</a>'); ?></strong>
87 87
 
88 88
 		<?php else : ?>
89 89
 
90
-			<?php $repeating_schedule = get_repeating_schedule( get_the_id() ); ?>
91
-			<?php $is_repeating_post = is_repeating_post( get_the_id() ) && isset( $repeating_schedule ); ?>
90
+			<?php $repeating_schedule = get_repeating_schedule(get_the_id()); ?>
91
+			<?php $is_repeating_post = is_repeating_post(get_the_id()) && isset($repeating_schedule); ?>
92 92
 
93
-			<strong><?php echo ! $is_repeating_post ? esc_html__( 'No', 'hm-post-repeat' ) : esc_html( $repeating_schedule['display'] ); ?></strong>
93
+			<strong><?php echo ! $is_repeating_post ? esc_html__('No', 'hm-post-repeat') : esc_html($repeating_schedule['display']); ?></strong>
94 94
 
95
-			<a href="#hm-post-repeat" class="edit-hm-post-repeat hide-if-no-js"><span aria-hidden="true"><?php esc_html_e( 'Edit', 'hm-post-repeat' ); ?></span> <span class="screen-reader-text"><?php esc_html_e( 'Edit Repeat Settings', 'hm-post-repeat' ); ?></span></a>
95
+			<a href="#hm-post-repeat" class="edit-hm-post-repeat hide-if-no-js"><span aria-hidden="true"><?php esc_html_e('Edit', 'hm-post-repeat'); ?></span> <span class="screen-reader-text"><?php esc_html_e('Edit Repeat Settings', 'hm-post-repeat'); ?></span></a>
96 96
 
97 97
 			<span class="hide-if-js" id="hm-post-repeat">
98 98
 
99 99
 				<select name="hm-post-repeat">
100
-					<option<?php selected( ! $is_repeating_post ); ?> value="no"><?php esc_html_e( 'No', 'hm-post-repeat' ); ?></option>
101
-					<?php foreach ( get_repeating_schedules() as $schedule_slug => $schedule ) : ?>
102
-						<option<?php selected( $is_repeating_post && $schedule_slug === $repeating_schedule['slug'] ); ?> value="<?php echo esc_attr( $schedule_slug ); ?>"><?php echo esc_html( $schedule['display'] ); ?></option>
100
+					<option<?php selected( ! $is_repeating_post); ?> value="no"><?php esc_html_e('No', 'hm-post-repeat'); ?></option>
101
+					<?php foreach (get_repeating_schedules() as $schedule_slug => $schedule) : ?>
102
+						<option<?php selected($is_repeating_post && $schedule_slug === $repeating_schedule['slug']); ?> value="<?php echo esc_attr($schedule_slug); ?>"><?php echo esc_html($schedule['display']); ?></option>
103 103
 					<?php endforeach; ?>
104 104
 				</select>
105 105
 
106
-				<a href="#hm-post-repeat" class="save-post-hm-post-repeat hide-if-no-js button"><?php esc_html_e( 'OK', 'hm-post-repeat' ); ?></a>
106
+				<a href="#hm-post-repeat" class="save-post-hm-post-repeat hide-if-no-js button"><?php esc_html_e('OK', 'hm-post-repeat'); ?></a>
107 107
 
108 108
 			</span>
109 109
 
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
  * @param WP_Post $post        The post object to get / return the states.
123 123
  * @return array The array of post states with ours added.
124 124
  */
125
-function admin_table_row_post_states( $post_states, $post ) {
125
+function admin_table_row_post_states($post_states, $post) {
126 126
 
127
-	if ( is_repeating_post( $post->ID ) ) {
127
+	if (is_repeating_post($post->ID)) {
128 128
 
129 129
 		// If the schedule has been removed since publishing, let the user know.
130
-		if ( get_repeating_schedule( $post->ID ) ) {
131
-			$post_states['hm-post-repeat'] = __( 'Repeating', 'hm-post-repeat' );
130
+		if (get_repeating_schedule($post->ID)) {
131
+			$post_states['hm-post-repeat'] = __('Repeating', 'hm-post-repeat');
132 132
 		} else {
133
-			$post_states['hm-post-repeat'] = __( 'Invalid Repeating Schedule', 'hm-post-repeat' );
133
+			$post_states['hm-post-repeat'] = __('Invalid Repeating Schedule', 'hm-post-repeat');
134 134
 		}
135 135
 
136 136
 	}
137 137
 
138
-	if ( is_repeat_post( $post->ID ) ) {
139
-		$post_states['hm-post-repeat'] = __( 'Repeat', 'hm-post-repeat' );
138
+	if (is_repeat_post($post->ID)) {
139
+		$post_states['hm-post-repeat'] = __('Repeat', 'hm-post-repeat');
140 140
 	}
141 141
 
142 142
 	return $post_states;
@@ -150,23 +150,23 @@  discard block
 block discarded – undo
150 150
  * @param int    $post_id             The ID of the post.
151 151
  * @param string $post_repeat_setting Used to manually set the repeating schedule from tests.
152 152
  */
153
-function save_post_repeating_status( $post_id = null, $post_repeat_setting = null ) {
153
+function save_post_repeating_status($post_id = null, $post_repeat_setting = null) {
154 154
 
155
-	if ( is_null( $post_repeat_setting ) ) {
156
-		$post_repeat_setting = isset( $_POST['hm-post-repeat'] ) ? sanitize_text_field( $_POST['hm-post-repeat'] ) : '';
155
+	if (is_null($post_repeat_setting)) {
156
+		$post_repeat_setting = isset($_POST['hm-post-repeat']) ? sanitize_text_field($_POST['hm-post-repeat']) : '';
157 157
 	}
158 158
 
159
-	if ( ! in_array( get_post_type( $post_id ), repeating_post_types() ) || empty( $post_repeat_setting ) ) {
159
+	if ( ! in_array(get_post_type($post_id), repeating_post_types()) || empty($post_repeat_setting)) {
160 160
 		return;
161 161
 	}
162 162
 
163
-	if ( 'no' === $post_repeat_setting ) {
164
-		delete_post_meta( $post_id, 'hm-post-repeat' );
163
+	if ('no' === $post_repeat_setting) {
164
+		delete_post_meta($post_id, 'hm-post-repeat');
165 165
 	}
166 166
 
167 167
 	// Make sure we have a valid schedule.
168
-	elseif ( in_array( $post_repeat_setting, array_keys( get_repeating_schedules() ) ) ) {
169
-		update_post_meta( $post_id, 'hm-post-repeat', $post_repeat_setting );
168
+	elseif (in_array($post_repeat_setting, array_keys(get_repeating_schedules()))) {
169
+		update_post_meta($post_id, 'hm-post-repeat', $post_repeat_setting);
170 170
 	}
171 171
 
172 172
 }
@@ -182,50 +182,50 @@  discard block
 block discarded – undo
182 182
  *
183 183
  * @param int $post_id The ID of the post.
184 184
  */
185
-function create_next_repeat_post( $post_id ) {
185
+function create_next_repeat_post($post_id) {
186 186
 
187
-	if ( ! in_array( get_post_type( $post_id ), repeating_post_types() ) ) {
187
+	if ( ! in_array(get_post_type($post_id), repeating_post_types())) {
188 188
 		return false;
189 189
 	}
190 190
 
191
-	if ( 'publish' !== get_post_status( $post_id ) ) {
191
+	if ('publish' !== get_post_status($post_id)) {
192 192
 		return false;
193 193
 	}
194 194
 
195
-	$original_post_id = get_repeating_post( $post_id );
195
+	$original_post_id = get_repeating_post($post_id);
196 196
 
197 197
 	// Bail if we're not publishing a repeat(ing) post
198
-	if ( ! $original_post_id ) {
198
+	if ( ! $original_post_id) {
199 199
 		return false;
200 200
 	}
201 201
 
202
-	$original_post = get_post( $original_post_id, ARRAY_A );
202
+	$original_post = get_post($original_post_id, ARRAY_A);
203 203
 
204 204
 	// If there is already a repeat post scheduled don't create another one
205
-	if ( get_next_scheduled_repeat_post( $original_post['ID'] ) ) {
205
+	if (get_next_scheduled_repeat_post($original_post['ID'])) {
206 206
 		return false;
207 207
 	}
208 208
 
209 209
 	// Bail if the saved schedule doesn't exist
210
-	$repeating_schedule = get_repeating_schedule( $original_post['ID'] );
210
+	$repeating_schedule = get_repeating_schedule($original_post['ID']);
211 211
 
212
-	if ( ! $repeating_schedule ) {
212
+	if ( ! $repeating_schedule) {
213 213
 		return false;
214 214
 	}
215 215
 
216 216
 	// Bail if the original post isn't already published
217
-	if ( 'publish' !== $original_post['post_status'] ) {
217
+	if ('publish' !== $original_post['post_status']) {
218 218
 		return false;
219 219
 	}
220 220
 
221 221
 	$next_post = $original_post;
222 222
 
223 223
 	// Create the repeat post as a copy of the original, but ignore some fields
224
-	unset( $next_post['ID'] );
225
-	unset( $next_post['guid'] );
226
-	unset( $next_post['post_date_gmt'] );
227
-	unset( $next_post['post_modified'] );
228
-	unset( $next_post['post_modified_gmt'] );
224
+	unset($next_post['ID']);
225
+	unset($next_post['guid']);
226
+	unset($next_post['post_date_gmt']);
227
+	unset($next_post['post_modified']);
228
+	unset($next_post['post_modified_gmt']);
229 229
 
230 230
 	// We set the post_parent to the original post_id, so they're related
231 231
 	$next_post['post_parent'] = $original_post['ID'];
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 	$next_post['post_status'] = 'future';
235 235
 
236 236
 	// Use the date of the current post being saved as the base
237
-	$next_post['post_date'] = date( 'Y-m-d H:i:s', strtotime( get_post_field( 'post_date', $post_id ) . ' + ' . $repeating_schedule['interval'] ) );
237
+	$next_post['post_date'] = date('Y-m-d H:i:s', strtotime(get_post_field('post_date', $post_id).' + '.$repeating_schedule['interval']));
238 238
 
239 239
 	// Make sure the next post will be in the future
240
-	if ( strtotime( $next_post['post_date'] ) <= time() ) {
240
+	if (strtotime($next_post['post_date']) <= time()) {
241 241
 		return false;
242 242
 	}
243 243
 
@@ -248,39 +248,39 @@  discard block
 block discarded – undo
248 248
 	 * @param array $repeating_schedule Repeating schedule info.
249 249
 	 * @param array $original_post      The original repeating post.
250 250
 	 */
251
-	$next_post = apply_filters( 'hm_post_repeat_edit_repeat_post', $next_post, $repeating_schedule, $original_post );
251
+	$next_post = apply_filters('hm_post_repeat_edit_repeat_post', $next_post, $repeating_schedule, $original_post);
252 252
 
253 253
 	// All checks done, get that post scheduled!
254
-	$next_post_id = wp_insert_post( wp_slash( $next_post ), true );
254
+	$next_post_id = wp_insert_post(wp_slash($next_post), true);
255 255
 
256
-	if ( is_wp_error( $next_post_id ) ) {
256
+	if (is_wp_error($next_post_id)) {
257 257
 		return false;
258 258
 	}
259 259
 
260 260
 	// Mirror any post_meta
261
-	$post_meta = get_post_meta( $original_post['ID'] );
261
+	$post_meta = get_post_meta($original_post['ID']);
262 262
 
263
-	if ( $post_meta  ) {
263
+	if ($post_meta) {
264 264
 
265 265
 		// Ignore some internal meta fields
266
-		unset( $post_meta['_edit_lock'] );
267
-		unset( $post_meta['_edit_last'] );
266
+		unset($post_meta['_edit_lock']);
267
+		unset($post_meta['_edit_last']);
268 268
 
269 269
 		// Don't copy the post repeat meta as only the original post should have that
270
-		unset( $post_meta['hm-post-repeat'] );
270
+		unset($post_meta['hm-post-repeat']);
271 271
 
272
-		foreach ( $post_meta as $key => $values ) {
273
-			foreach ( $values as $value ) {
274
-				add_post_meta( $next_post_id, $key, maybe_unserialize( $value ) );
272
+		foreach ($post_meta as $key => $values) {
273
+			foreach ($values as $value) {
274
+				add_post_meta($next_post_id, $key, maybe_unserialize($value));
275 275
 			}
276 276
 		}
277 277
 	}
278 278
 
279 279
 	// Mirror any term relationships
280
-	$taxonomies = get_object_taxonomies( $original_post['post_type'] );
280
+	$taxonomies = get_object_taxonomies($original_post['post_type']);
281 281
 
282
-	foreach ( $taxonomies as $taxonomy ) {
283
-		wp_set_object_terms( $next_post_id, wp_list_pluck( wp_get_object_terms( $original_post['ID'], $taxonomy ), 'slug' ), $taxonomy );
282
+	foreach ($taxonomies as $taxonomy) {
283
+		wp_set_object_terms($next_post_id, wp_list_pluck(wp_get_object_terms($original_post['ID'], $taxonomy), 'slug'), $taxonomy);
284 284
 	}
285 285
 
286 286
 	return $next_post_id;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 *
302 302
 	 * @param string[] $post_types Post type slugs.
303 303
 	 */
304
-	return apply_filters( 'hm_post_repeat_post_types', array( 'post' ) );
304
+	return apply_filters('hm_post_repeat_post_types', array('post'));
305 305
 
306 306
 }
307 307
 
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
 	 *
318 318
 	 * @param array[] $schedules Schedule array items.
319 319
 	 */
320
-	$schedules = apply_filters( 'hm_post_repeat_schedules', array(
321
-		'daily'   => array( 'interval' => '1 day',   'display' => __( 'Daily',   'hm-post-repeat' ) ),
322
-		'weekly'  => array( 'interval' => '1 week',  'display' => __( 'Weekly',  'hm-post-repeat' ) ),
323
-		'monthly' => array( 'interval' => '1 month', 'display' => __( 'Monthly', 'hm-post-repeat' ) ),
324
-	) );
320
+	$schedules = apply_filters('hm_post_repeat_schedules', array(
321
+		'daily'   => array('interval' => '1 day', 'display' => __('Daily', 'hm-post-repeat')),
322
+		'weekly'  => array('interval' => '1 week', 'display' => __('Weekly', 'hm-post-repeat')),
323
+		'monthly' => array('interval' => '1 month', 'display' => __('Monthly', 'hm-post-repeat')),
324
+	));
325 325
 
326
-	foreach ( $schedules as $slug => &$schedule ) {
326
+	foreach ($schedules as $slug => &$schedule) {
327 327
 		$schedule['slug'] = $slug;
328 328
 	}
329 329
 
@@ -337,22 +337,22 @@  discard block
 block discarded – undo
337 337
  * @param int $post_id The id of the post you want to check.
338 338
  * @return array|null The schedule to repeat by, or null if invalid.
339 339
  */
340
-function get_repeating_schedule( $post_id ) {
340
+function get_repeating_schedule($post_id) {
341 341
 
342
-	if ( ! is_repeating_post( $post_id ) ) {
342
+	if ( ! is_repeating_post($post_id)) {
343 343
 		return;
344 344
 	}
345 345
 
346
-	$repeating_schedule = get_post_meta( $post_id, 'hm-post-repeat', true );
346
+	$repeating_schedule = get_post_meta($post_id, 'hm-post-repeat', true);
347 347
 	$schedules = get_repeating_schedules();
348 348
 
349 349
 	// Backwards compatibility with 0.3 when we only supported weekly
350
-	if ( '1' === $repeating_schedule ) {
350
+	if ('1' === $repeating_schedule) {
351 351
 		$repeating_schedule = 'weekly';
352 352
 	}
353 353
 
354
-	if ( array_key_exists( $repeating_schedule, $schedules ) ) {
355
-		return $schedules[ $repeating_schedule ];
354
+	if (array_key_exists($repeating_schedule, $schedules)) {
355
+		return $schedules[$repeating_schedule];
356 356
 	}
357 357
 
358 358
 }
@@ -365,14 +365,14 @@  discard block
 block discarded – undo
365 365
  * @param int $post_id The id of the post you want to check.
366 366
  * @return bool Whether the passed post_id is a repeating post or not.
367 367
  */
368
-function is_repeating_post( $post_id ) {
368
+function is_repeating_post($post_id) {
369 369
 
370 370
 	// We check $_POST data so that this function works inside a `save_post` hook when the post_meta hasn't yet been saved
371
-	if ( isset( $_POST['hm-post-repeat'] ) && isset( $_POST['ID'] ) && $_POST['ID'] === $post_id ) {
371
+	if (isset($_POST['hm-post-repeat']) && isset($_POST['ID']) && $_POST['ID'] === $post_id) {
372 372
 		return true;
373 373
 	}
374 374
 
375
-	if ( get_post_meta( $post_id, 'hm-post-repeat', true ) ) {
375
+	if (get_post_meta($post_id, 'hm-post-repeat', true)) {
376 376
 		return true;
377 377
 	}
378 378
 
@@ -388,11 +388,11 @@  discard block
 block discarded – undo
388 388
  * @param int $post_id The id of the post you want to check.
389 389
  * @return bool Whether the passed post_id is a repeat post or not.
390 390
  */
391
-function is_repeat_post( $post_id ) {
391
+function is_repeat_post($post_id) {
392 392
 
393
-	$post_parent = get_post_field( 'post_parent', $post_id );
393
+	$post_parent = get_post_field('post_parent', $post_id);
394 394
 
395
-	if ( $post_parent && get_post_meta( $post_parent, 'hm-post-repeat', true ) ) {
395
+	if ($post_parent && get_post_meta($post_parent, 'hm-post-repeat', true)) {
396 396
 		return true;
397 397
 	}
398 398
 
@@ -406,13 +406,13 @@  discard block
 block discarded – undo
406 406
  * @param int $post_id The id of a repeat or repeating post
407 407
  * @return Int|Bool Return the ID of the next repeat post_id or false if it can't find one
408 408
  */
409
-function get_next_scheduled_repeat_post( $post_id ) {
409
+function get_next_scheduled_repeat_post($post_id) {
410 410
 
411
-	$post = get_post( get_repeating_post( $post_id ) );
411
+	$post = get_post(get_repeating_post($post_id));
412 412
 
413
-	$repeat_posts = get_posts( array( 'post_status' => 'future', 'post_parent' => $post->ID ) );
413
+	$repeat_posts = get_posts(array('post_status' => 'future', 'post_parent' => $post->ID));
414 414
 
415
-	if ( isset( $repeat_posts[0] ) ) {
415
+	if (isset($repeat_posts[0])) {
416 416
 	 	return $repeat_posts[0];
417 417
 	}
418 418
 
@@ -426,17 +426,17 @@  discard block
 block discarded – undo
426 426
  * @param int $post_id The id of a repeat or repeating post
427 427
  * @return Int|Bool Return the original repeating post_id or false if it can't find it
428 428
  */
429
-function get_repeating_post( $post_id ) {
429
+function get_repeating_post($post_id) {
430 430
 
431 431
 	$original_post_id = false;
432 432
 
433 433
 	// Are we publishing a repeat post
434
-	if ( is_repeat_post( $post_id ) ) {
435
-		$original_post_id = get_post( $post_id )->post_parent;
434
+	if (is_repeat_post($post_id)) {
435
+		$original_post_id = get_post($post_id)->post_parent;
436 436
 	}
437 437
 
438 438
 	// Or the original
439
-	elseif ( is_repeating_post( $post_id ) ) {
439
+	elseif (is_repeating_post($post_id)) {
440 440
 		$original_post_id = $post_id;
441 441
 	}
442 442
 
@@ -454,12 +454,12 @@  discard block
 block discarded – undo
454 454
  *
455 455
  * @return array Available list of table views with custom added views per repeat type.
456 456
  */
457
-function admin_table_views_links( $views ) {
457
+function admin_table_views_links($views) {
458 458
 
459 459
 	$post_type = get_current_screen()->post_type;
460 460
 
461 461
 	// Add status link for each repeat type.
462
-	foreach ( get_available_repeat_types() as $repeat_type => $repeat_desc ) {
462
+	foreach (get_available_repeat_types() as $repeat_type => $repeat_desc) {
463 463
 
464 464
 		$query_args = array(
465 465
 			'post_type'      => $post_type,
@@ -468,21 +468,21 @@  discard block
 block discarded – undo
468 468
 
469 469
 		// TO DO: add logic for getting the number of the posts correctly.
470 470
 		$link_label = sprintf(
471
-			$repeat_desc . ' <span class="count">(%s)</span>',
472
-			number_format_i18n( 13 )
471
+			$repeat_desc.' <span class="count">(%s)</span>',
472
+			number_format_i18n(13)
473 473
 		);
474 474
 
475 475
 		// Add current class to the link to highlight it when it's selected.
476
-		$class_html = ( $repeat_type === get_repeat_type_url_param() ) ? ' class="current"' : '';
476
+		$class_html = ($repeat_type === get_repeat_type_url_param()) ? ' class="current"' : '';
477 477
 
478 478
 		$link_html = sprintf(
479 479
 			'<a href="%s"%s>%s</a>',
480
-			esc_url( add_query_arg( $query_args, 'edit.php' ) ),
480
+			esc_url(add_query_arg($query_args, 'edit.php')),
481 481
 			$class_html,
482 482
 			$link_label
483 483
 		);
484 484
 
485
-		$views[ $repeat_type ] = $link_html;
485
+		$views[$repeat_type] = $link_html;
486 486
 	}
487 487
 
488 488
 	return $views;
@@ -496,32 +496,32 @@  discard block
 block discarded – undo
496 496
  *
497 497
  * @return mixed Main admin query with edited params to get posts of specified repeat type.
498 498
  */
499
-function admin_table_repeat_type_posts_query( $wp_query ) {
499
+function admin_table_repeat_type_posts_query($wp_query) {
500 500
 
501
-	if ( ! is_admin() ) {
501
+	if ( ! is_admin()) {
502 502
 		return $wp_query;
503 503
 	}
504 504
 
505 505
 	// Get URL query param for repeat type and check it's valid.
506 506
 	$repeat_type = get_repeat_type_url_param();
507 507
 
508
-	if ( ! $repeat_type || ! is_allowed_repeat_type( $repeat_type ) ) {
508
+	if ( ! $repeat_type || ! is_allowed_repeat_type($repeat_type)) {
509 509
 		return $wp_query;
510 510
 	}
511 511
 
512 512
 	// Construct custom query to get posts of specified repeat type.
513
-	$wp_query->set( 'meta_query', array(
513
+	$wp_query->set('meta_query', array(
514 514
 			array(
515 515
 					'key'     => 'hm-post-repeat',
516 516
 					'compare' => 'EXISTS',
517 517
 			),
518
-	) );
518
+	));
519 519
 
520
-	if ( $repeat_type === 'repeat' ) {
521
-		$wp_query->set( 'post_parent__not_in', array( 0 ) );
520
+	if ($repeat_type === 'repeat') {
521
+		$wp_query->set('post_parent__not_in', array(0));
522 522
 
523
-	} elseif ( $repeat_type === 'repeating' ) {
524
-		$wp_query->set( 'post_parent', 0 );
523
+	} elseif ($repeat_type === 'repeating') {
524
+		$wp_query->set('post_parent', 0);
525 525
 	}
526 526
 
527 527
 	return $wp_query;
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
  * @return string Sanitized string of repeat type being displayed.
535 535
  */
536 536
 function get_repeat_type_url_param() {
537
-	return isset( $_GET['hm-post-repeat'] ) ? sanitize_text_field( $_GET['hm-post-repeat'] ) : '';
537
+	return isset($_GET['hm-post-repeat']) ? sanitize_text_field($_GET['hm-post-repeat']) : '';
538 538
 }
539 539
 
540 540
 /**
@@ -544,8 +544,8 @@  discard block
 block discarded – undo
544 544
  */
545 545
 function get_available_repeat_types() {
546 546
 	return array(
547
-		'repeating' => __( 'Repeating', 'hm-post-repeat' ),
548
-		'repeat'    => __( 'Repeat', 'hm-post-repeat' ),
547
+		'repeating' => __('Repeating', 'hm-post-repeat'),
548
+		'repeat'    => __('Repeat', 'hm-post-repeat'),
549 549
 	);
550 550
 }
551 551
 
@@ -557,6 +557,6 @@  discard block
 block discarded – undo
557 557
  * @return bool True if repeat type is valid,
558 558
  *              False otherwise.
559 559
  */
560
-function is_allowed_repeat_type( $repeat_type ) {
561
-	return in_array( $repeat_type, array_keys( get_available_repeat_types() ) );
560
+function is_allowed_repeat_type($repeat_type) {
561
+	return in_array($repeat_type, array_keys(get_available_repeat_types()));
562 562
 }
Please login to merge, or discard this patch.