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 (#32)
by
unknown
02:05
created
hm-post-repeat.php 1 patch
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -35,41 +35,41 @@  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 links to admin screen for each CPT that supports Repeatable Posts.
45
-add_action( 'init', function() {
46
-	foreach ( repeating_post_types() as $post_type ) {
47
-		add_filter( "views_edit-{$post_type}", __NAMESPACE__ . '\admin_table_views_links' );
45
+add_action('init', function() {
46
+	foreach (repeating_post_types() as $post_type) {
47
+		add_filter("views_edit-{$post_type}", __NAMESPACE__.'\admin_table_views_links');
48 48
 	}
49 49
 } );
50 50
 
51 51
 // Display only Repeatable Posts in admin table view for registered view links.
52
-add_filter( 'pre_get_posts',    __NAMESPACE__ . '\admin_table_repeat_type_posts_query' );
52
+add_filter('pre_get_posts', __NAMESPACE__.'\admin_table_repeat_type_posts_query');
53 53
 
54 54
 // Add a row link to view all Repeat posts for the current Repeating post.
55
-add_filter( 'post_row_actions', __NAMESPACE__ . '\admin_table_row_actions_view_repeat_posts', 10, 2 );
56
-add_action( 'wp',               __NAMESPACE__ . '\admin_table_count_repeat_posts_for_row_links' );
55
+add_filter('post_row_actions', __NAMESPACE__.'\admin_table_row_actions_view_repeat_posts', 10, 2);
56
+add_action('wp', __NAMESPACE__.'\admin_table_count_repeat_posts_for_row_links');
57 57
 
58 58
 /**
59 59
  * Enqueue the scripts and styles that are needed by this plugin.
60 60
  */
61
-function enqueue_scripts( $hook ) {
61
+function enqueue_scripts($hook) {
62 62
 
63 63
 	// Ensure we only load them on the edit post and add new post admin screens
64
-	if ( ! in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
64
+	if ( ! in_array($hook, array('post.php', 'post-new.php'))) {
65 65
 		return;
66 66
 	}
67 67
 
68
-	$plugin_data = get_plugin_data( __FILE__ );
69
-	$plugin_dir_url = plugin_dir_url( __FILE__ );
68
+	$plugin_data = get_plugin_data(__FILE__);
69
+	$plugin_dir_url = plugin_dir_url(__FILE__);
70 70
 
71
-	wp_enqueue_script( 'hm-post-repeat', $plugin_dir_url . 'hm-post-repeat.js', 'jquery', $plugin_data['Version'], true );
72
-	wp_enqueue_style( 'hm-post-repeat', $plugin_dir_url . 'hm-post-repeat.css', array(), $plugin_data['Version'] );
71
+	wp_enqueue_script('hm-post-repeat', $plugin_dir_url.'hm-post-repeat.js', 'jquery', $plugin_data['Version'], true);
72
+	wp_enqueue_style('hm-post-repeat', $plugin_dir_url.'hm-post-repeat.css', array(), $plugin_data['Version']);
73 73
 
74 74
 }
75 75
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function publish_box_ui() {
83 83
 
84
-	if ( ! in_array( get_post_type(), repeating_post_types() ) ) {
84
+	if ( ! in_array(get_post_type(), repeating_post_types())) {
85 85
 		return;
86 86
 	} ?>
87 87
 
@@ -89,31 +89,31 @@  discard block
 block discarded – undo
89 89
 
90 90
 		<span class="dashicons dashicons-controls-repeat"></span>
91 91
 
92
-		<?php esc_html_e( 'Repeat:', 'hm-post-repeat' ); ?>
92
+		<?php esc_html_e('Repeat:', 'hm-post-repeat'); ?>
93 93
 
94
-		<?php if ( is_repeat_post( get_the_id() ) ) : ?>
94
+		<?php if (is_repeat_post(get_the_id())) : ?>
95 95
 
96
-			<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>
96
+			<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>
97 97
 
98 98
 		<?php else : ?>
99 99
 
100
-			<?php $repeating_schedule = get_repeating_schedule( get_the_id() ); ?>
101
-			<?php $is_repeating_post = is_repeating_post( get_the_id() ) && isset( $repeating_schedule ); ?>
100
+			<?php $repeating_schedule = get_repeating_schedule(get_the_id()); ?>
101
+			<?php $is_repeating_post = is_repeating_post(get_the_id()) && isset($repeating_schedule); ?>
102 102
 
103
-			<strong><?php echo ! $is_repeating_post ? esc_html__( 'No', 'hm-post-repeat' ) : esc_html( $repeating_schedule['display'] ); ?></strong>
103
+			<strong><?php echo ! $is_repeating_post ? esc_html__('No', 'hm-post-repeat') : esc_html($repeating_schedule['display']); ?></strong>
104 104
 
105
-			<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>
105
+			<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>
106 106
 
107 107
 			<span class="hide-if-js" id="hm-post-repeat">
108 108
 
109 109
 				<select name="hm-post-repeat">
110
-					<option<?php selected( ! $is_repeating_post ); ?> value="no"><?php esc_html_e( 'No', 'hm-post-repeat' ); ?></option>
111
-					<?php foreach ( get_repeating_schedules() as $schedule_slug => $schedule ) : ?>
112
-						<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>
110
+					<option<?php selected( ! $is_repeating_post); ?> value="no"><?php esc_html_e('No', 'hm-post-repeat'); ?></option>
111
+					<?php foreach (get_repeating_schedules() as $schedule_slug => $schedule) : ?>
112
+						<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>
113 113
 					<?php endforeach; ?>
114 114
 				</select>
115 115
 
116
-				<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>
116
+				<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>
117 117
 
118 118
 			</span>
119 119
 
@@ -132,21 +132,21 @@  discard block
 block discarded – undo
132 132
  * @param WP_Post $post        The post object to get / return the states.
133 133
  * @return array The array of post states with ours added.
134 134
  */
135
-function admin_table_row_post_states( $post_states, $post ) {
135
+function admin_table_row_post_states($post_states, $post) {
136 136
 
137
-	if ( is_repeating_post( $post->ID ) ) {
137
+	if (is_repeating_post($post->ID)) {
138 138
 
139 139
 		// If the schedule has been removed since publishing, let the user know.
140
-		if ( get_repeating_schedule( $post->ID ) ) {
141
-			$post_states['hm-post-repeat'] = __( 'Repeating', 'hm-post-repeat' );
140
+		if (get_repeating_schedule($post->ID)) {
141
+			$post_states['hm-post-repeat'] = __('Repeating', 'hm-post-repeat');
142 142
 		} else {
143
-			$post_states['hm-post-repeat'] = __( 'Invalid Repeating Schedule', 'hm-post-repeat' );
143
+			$post_states['hm-post-repeat'] = __('Invalid Repeating Schedule', 'hm-post-repeat');
144 144
 		}
145 145
 
146 146
 	}
147 147
 
148
-	if ( is_repeat_post( $post->ID ) ) {
149
-		$post_states['hm-post-repeat'] = __( 'Repeat', 'hm-post-repeat' );
148
+	if (is_repeat_post($post->ID)) {
149
+		$post_states['hm-post-repeat'] = __('Repeat', 'hm-post-repeat');
150 150
 	}
151 151
 
152 152
 	return $post_states;
@@ -160,23 +160,23 @@  discard block
 block discarded – undo
160 160
  * @param int    $post_id             The ID of the post.
161 161
  * @param string $post_repeat_setting Used to manually set the repeating schedule from tests.
162 162
  */
163
-function save_post_repeating_status( $post_id = null, $post_repeat_setting = null ) {
163
+function save_post_repeating_status($post_id = null, $post_repeat_setting = null) {
164 164
 
165
-	if ( is_null( $post_repeat_setting ) ) {
166
-		$post_repeat_setting = isset( $_POST['hm-post-repeat'] ) ? sanitize_text_field( $_POST['hm-post-repeat'] ) : '';
165
+	if (is_null($post_repeat_setting)) {
166
+		$post_repeat_setting = isset($_POST['hm-post-repeat']) ? sanitize_text_field($_POST['hm-post-repeat']) : '';
167 167
 	}
168 168
 
169
-	if ( ! in_array( get_post_type( $post_id ), repeating_post_types() ) || empty( $post_repeat_setting ) ) {
169
+	if ( ! in_array(get_post_type($post_id), repeating_post_types()) || empty($post_repeat_setting)) {
170 170
 		return;
171 171
 	}
172 172
 
173
-	if ( 'no' === $post_repeat_setting ) {
174
-		delete_post_meta( $post_id, 'hm-post-repeat' );
173
+	if ('no' === $post_repeat_setting) {
174
+		delete_post_meta($post_id, 'hm-post-repeat');
175 175
 	}
176 176
 
177 177
 	// Make sure we have a valid schedule.
178
-	elseif ( in_array( $post_repeat_setting, array_keys( get_repeating_schedules() ) ) ) {
179
-		update_post_meta( $post_id, 'hm-post-repeat', $post_repeat_setting );
178
+	elseif (in_array($post_repeat_setting, array_keys(get_repeating_schedules()))) {
179
+		update_post_meta($post_id, 'hm-post-repeat', $post_repeat_setting);
180 180
 	}
181 181
 
182 182
 }
@@ -192,50 +192,50 @@  discard block
 block discarded – undo
192 192
  *
193 193
  * @param int $post_id The ID of the post.
194 194
  */
195
-function create_next_repeat_post( $post_id ) {
195
+function create_next_repeat_post($post_id) {
196 196
 
197
-	if ( ! in_array( get_post_type( $post_id ), repeating_post_types() ) ) {
197
+	if ( ! in_array(get_post_type($post_id), repeating_post_types())) {
198 198
 		return false;
199 199
 	}
200 200
 
201
-	if ( 'publish' !== get_post_status( $post_id ) ) {
201
+	if ('publish' !== get_post_status($post_id)) {
202 202
 		return false;
203 203
 	}
204 204
 
205
-	$original_post_id = get_repeating_post( $post_id );
205
+	$original_post_id = get_repeating_post($post_id);
206 206
 
207 207
 	// Bail if we're not publishing a repeat(ing) post
208
-	if ( ! $original_post_id ) {
208
+	if ( ! $original_post_id) {
209 209
 		return false;
210 210
 	}
211 211
 
212
-	$original_post = get_post( $original_post_id, ARRAY_A );
212
+	$original_post = get_post($original_post_id, ARRAY_A);
213 213
 
214 214
 	// If there is already a repeat post scheduled don't create another one
215
-	if ( get_next_scheduled_repeat_post( $original_post['ID'] ) ) {
215
+	if (get_next_scheduled_repeat_post($original_post['ID'])) {
216 216
 		return false;
217 217
 	}
218 218
 
219 219
 	// Bail if the saved schedule doesn't exist
220
-	$repeating_schedule = get_repeating_schedule( $original_post['ID'] );
220
+	$repeating_schedule = get_repeating_schedule($original_post['ID']);
221 221
 
222
-	if ( ! $repeating_schedule ) {
222
+	if ( ! $repeating_schedule) {
223 223
 		return false;
224 224
 	}
225 225
 
226 226
 	// Bail if the original post isn't already published
227
-	if ( 'publish' !== $original_post['post_status'] ) {
227
+	if ('publish' !== $original_post['post_status']) {
228 228
 		return false;
229 229
 	}
230 230
 
231 231
 	$next_post = $original_post;
232 232
 
233 233
 	// Create the repeat post as a copy of the original, but ignore some fields
234
-	unset( $next_post['ID'] );
235
-	unset( $next_post['guid'] );
236
-	unset( $next_post['post_date_gmt'] );
237
-	unset( $next_post['post_modified'] );
238
-	unset( $next_post['post_modified_gmt'] );
234
+	unset($next_post['ID']);
235
+	unset($next_post['guid']);
236
+	unset($next_post['post_date_gmt']);
237
+	unset($next_post['post_modified']);
238
+	unset($next_post['post_modified_gmt']);
239 239
 
240 240
 	// We set the post_parent to the original post_id, so they're related
241 241
 	$next_post['post_parent'] = $original_post['ID'];
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 	$next_post['post_status'] = 'future';
245 245
 
246 246
 	// Use the date of the current post being saved as the base
247
-	$next_post['post_date'] = date( 'Y-m-d H:i:s', strtotime( get_post_field( 'post_date', $post_id ) . ' + ' . $repeating_schedule['interval'] ) );
247
+	$next_post['post_date'] = date('Y-m-d H:i:s', strtotime(get_post_field('post_date', $post_id).' + '.$repeating_schedule['interval']));
248 248
 
249 249
 	// Make sure the next post will be in the future
250
-	if ( strtotime( $next_post['post_date'] ) <= time() ) {
250
+	if (strtotime($next_post['post_date']) <= time()) {
251 251
 		return false;
252 252
 	}
253 253
 
@@ -258,39 +258,39 @@  discard block
 block discarded – undo
258 258
 	 * @param array $repeating_schedule Repeating schedule info.
259 259
 	 * @param array $original_post      The original repeating post.
260 260
 	 */
261
-	$next_post = apply_filters( 'hm_post_repeat_edit_repeat_post', $next_post, $repeating_schedule, $original_post );
261
+	$next_post = apply_filters('hm_post_repeat_edit_repeat_post', $next_post, $repeating_schedule, $original_post);
262 262
 
263 263
 	// All checks done, get that post scheduled!
264
-	$next_post_id = wp_insert_post( wp_slash( $next_post ), true );
264
+	$next_post_id = wp_insert_post(wp_slash($next_post), true);
265 265
 
266
-	if ( is_wp_error( $next_post_id ) ) {
266
+	if (is_wp_error($next_post_id)) {
267 267
 		return false;
268 268
 	}
269 269
 
270 270
 	// Mirror any post_meta
271
-	$post_meta = get_post_meta( $original_post['ID'] );
271
+	$post_meta = get_post_meta($original_post['ID']);
272 272
 
273
-	if ( $post_meta  ) {
273
+	if ($post_meta) {
274 274
 
275 275
 		// Ignore some internal meta fields
276
-		unset( $post_meta['_edit_lock'] );
277
-		unset( $post_meta['_edit_last'] );
276
+		unset($post_meta['_edit_lock']);
277
+		unset($post_meta['_edit_last']);
278 278
 
279 279
 		// Don't copy the post repeat meta as only the original post should have that
280
-		unset( $post_meta['hm-post-repeat'] );
280
+		unset($post_meta['hm-post-repeat']);
281 281
 
282
-		foreach ( $post_meta as $key => $values ) {
283
-			foreach ( $values as $value ) {
284
-				add_post_meta( $next_post_id, $key, maybe_unserialize( $value ) );
282
+		foreach ($post_meta as $key => $values) {
283
+			foreach ($values as $value) {
284
+				add_post_meta($next_post_id, $key, maybe_unserialize($value));
285 285
 			}
286 286
 		}
287 287
 	}
288 288
 
289 289
 	// Mirror any term relationships
290
-	$taxonomies = get_object_taxonomies( $original_post['post_type'] );
290
+	$taxonomies = get_object_taxonomies($original_post['post_type']);
291 291
 
292
-	foreach ( $taxonomies as $taxonomy ) {
293
-		wp_set_object_terms( $next_post_id, wp_list_pluck( wp_get_object_terms( $original_post['ID'], $taxonomy ), 'slug' ), $taxonomy );
292
+	foreach ($taxonomies as $taxonomy) {
293
+		wp_set_object_terms($next_post_id, wp_list_pluck(wp_get_object_terms($original_post['ID'], $taxonomy), 'slug'), $taxonomy);
294 294
 	}
295 295
 
296 296
 	return $next_post_id;
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 *
312 312
 	 * @param string[] $post_types Post type slugs.
313 313
 	 */
314
-	return apply_filters( 'hm_post_repeat_post_types', array( 'post' ) );
314
+	return apply_filters('hm_post_repeat_post_types', array('post'));
315 315
 
316 316
 }
317 317
 
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
 	 *
328 328
 	 * @param array[] $schedules Schedule array items.
329 329
 	 */
330
-	$schedules = apply_filters( 'hm_post_repeat_schedules', array(
331
-		'daily'   => array( 'interval' => '1 day',   'display' => __( 'Daily',   'hm-post-repeat' ) ),
332
-		'weekly'  => array( 'interval' => '1 week',  'display' => __( 'Weekly',  'hm-post-repeat' ) ),
333
-		'monthly' => array( 'interval' => '1 month', 'display' => __( 'Monthly', 'hm-post-repeat' ) ),
334
-	) );
330
+	$schedules = apply_filters('hm_post_repeat_schedules', array(
331
+		'daily'   => array('interval' => '1 day', 'display' => __('Daily', 'hm-post-repeat')),
332
+		'weekly'  => array('interval' => '1 week', 'display' => __('Weekly', 'hm-post-repeat')),
333
+		'monthly' => array('interval' => '1 month', 'display' => __('Monthly', 'hm-post-repeat')),
334
+	));
335 335
 
336
-	foreach ( $schedules as $slug => &$schedule ) {
336
+	foreach ($schedules as $slug => &$schedule) {
337 337
 		$schedule['slug'] = $slug;
338 338
 	}
339 339
 
@@ -347,22 +347,22 @@  discard block
 block discarded – undo
347 347
  * @param int $post_id The id of the post you want to check.
348 348
  * @return array|null The schedule to repeat by, or null if invalid.
349 349
  */
350
-function get_repeating_schedule( $post_id ) {
350
+function get_repeating_schedule($post_id) {
351 351
 
352
-	if ( ! is_repeating_post( $post_id ) ) {
352
+	if ( ! is_repeating_post($post_id)) {
353 353
 		return;
354 354
 	}
355 355
 
356
-	$repeating_schedule = get_post_meta( $post_id, 'hm-post-repeat', true );
356
+	$repeating_schedule = get_post_meta($post_id, 'hm-post-repeat', true);
357 357
 	$schedules = get_repeating_schedules();
358 358
 
359 359
 	// Backwards compatibility with 0.3 when we only supported weekly
360
-	if ( '1' === $repeating_schedule ) {
360
+	if ('1' === $repeating_schedule) {
361 361
 		$repeating_schedule = 'weekly';
362 362
 	}
363 363
 
364
-	if ( array_key_exists( $repeating_schedule, $schedules ) ) {
365
-		return $schedules[ $repeating_schedule ];
364
+	if (array_key_exists($repeating_schedule, $schedules)) {
365
+		return $schedules[$repeating_schedule];
366 366
 	}
367 367
 
368 368
 }
@@ -376,17 +376,17 @@  discard block
 block discarded – undo
376 376
  *
377 377
  * @return bool Whether the passed post_id is a repeating post or not.
378 378
  */
379
-function is_repeating_post( $post_id ) {
379
+function is_repeating_post($post_id) {
380 380
 
381 381
 	// We check $_POST data so that this function works inside a `save_post` hook when the post_meta hasn't yet been saved.
382
-	if ( isset( $_POST['hm-post-repeat'] ) && isset( $_POST['ID'] ) && $_POST['ID'] === $post_id ) {
382
+	if (isset($_POST['hm-post-repeat']) && isset($_POST['ID']) && $_POST['ID'] === $post_id) {
383 383
 		return true;
384 384
 	}
385 385
 
386 386
 	// For saved posts - Repeating post has meta key and does NOT have a parent.
387
-	$post_parent = get_post_field( 'post_parent', $post_id );
387
+	$post_parent = get_post_field('post_parent', $post_id);
388 388
 
389
-	if ( ! $post_parent && get_post_meta( $post_id, 'hm-post-repeat', true ) ) {
389
+	if ( ! $post_parent && get_post_meta($post_id, 'hm-post-repeat', true)) {
390 390
 		return true;
391 391
 	}
392 392
 
@@ -403,12 +403,12 @@  discard block
 block discarded – undo
403 403
  *
404 404
  * @return bool Whether the passed post_id is a repeat post or not.
405 405
  */
406
-function is_repeat_post( $post_id ) {
406
+function is_repeat_post($post_id) {
407 407
 
408 408
 	// Repeat post has meta key and has a parent.
409
-	$post_parent = get_post_field( 'post_parent', $post_id );
409
+	$post_parent = get_post_field('post_parent', $post_id);
410 410
 
411
-	if ( $post_parent && get_post_meta( $post_parent, 'hm-post-repeat', true ) ) {
411
+	if ($post_parent && get_post_meta($post_parent, 'hm-post-repeat', true)) {
412 412
 		return true;
413 413
 	}
414 414
 
@@ -422,13 +422,13 @@  discard block
 block discarded – undo
422 422
  * @param int $post_id The id of a repeat or repeating post
423 423
  * @return Int|Bool Return the ID of the next repeat post_id or false if it can't find one
424 424
  */
425
-function get_next_scheduled_repeat_post( $post_id ) {
425
+function get_next_scheduled_repeat_post($post_id) {
426 426
 
427
-	$post = get_post( get_repeating_post( $post_id ) );
427
+	$post = get_post(get_repeating_post($post_id));
428 428
 
429
-	$repeat_posts = get_posts( array( 'post_status' => 'future', 'post_parent' => $post->ID ) );
429
+	$repeat_posts = get_posts(array('post_status' => 'future', 'post_parent' => $post->ID));
430 430
 
431
-	if ( isset( $repeat_posts[0] ) ) {
431
+	if (isset($repeat_posts[0])) {
432 432
 	 	return $repeat_posts[0];
433 433
 	}
434 434
 
@@ -442,17 +442,17 @@  discard block
 block discarded – undo
442 442
  * @param int $post_id The id of a repeat or repeating post
443 443
  * @return Int|Bool Return the original repeating post_id or false if it can't find it
444 444
  */
445
-function get_repeating_post( $post_id ) {
445
+function get_repeating_post($post_id) {
446 446
 
447 447
 	$original_post_id = false;
448 448
 
449 449
 	// Are we publishing a repeat post
450
-	if ( is_repeat_post( $post_id ) ) {
451
-		$original_post_id = get_post( $post_id )->post_parent;
450
+	if (is_repeat_post($post_id)) {
451
+		$original_post_id = get_post($post_id)->post_parent;
452 452
 	}
453 453
 
454 454
 	// Or the original
455
-	elseif ( is_repeating_post( $post_id ) ) {
455
+	elseif (is_repeating_post($post_id)) {
456 456
 		$original_post_id = $post_id;
457 457
 	}
458 458
 
@@ -470,10 +470,10 @@  discard block
 block discarded – undo
470 470
  *
471 471
  * @return array Available list of table views with custom added views per repeat type.
472 472
  */
473
-function admin_table_views_links( $views ) {
473
+function admin_table_views_links($views) {
474 474
 
475 475
 	// Add status link for each repeat type.
476
-	foreach ( get_available_repeat_types() as $repeat_type => $repeat_desc ) {
476
+	foreach (get_available_repeat_types() as $repeat_type => $repeat_desc) {
477 477
 
478 478
 		$url_args = array(
479 479
 			'post_type'      => get_current_screen()->post_type,
@@ -481,12 +481,12 @@  discard block
 block discarded – undo
481 481
 		);
482 482
 
483 483
 		// Custom WP_Query to get posts count of repeat type.
484
-		$repeat_type_query = new \WP_Query( get_repeat_type_query_params( $repeat_type ) );
484
+		$repeat_type_query = new \WP_Query(get_repeat_type_query_params($repeat_type));
485 485
 
486 486
 		$link_label = sprintf(
487 487
 				'%s <span class="count">(%s)</span>',
488
-			esc_html( $repeat_desc ),
489
-			esc_html( number_format_i18n( $repeat_type_query->post_count ) )
488
+			esc_html($repeat_desc),
489
+			esc_html(number_format_i18n($repeat_type_query->post_count))
490 490
 		);
491 491
 
492 492
 		/**
@@ -497,19 +497,19 @@  discard block
 block discarded – undo
497 497
 		$class_html = '';
498 498
 		if (
499 499
 			get_repeat_type_url_param() === $repeat_type &&
500
-			! isset( $_GET['post_parent'] )
500
+			! isset($_GET['post_parent'])
501 501
 		) {
502 502
 			$class_html = ' class="current"';
503 503
 		}
504 504
 
505 505
 		$link_html = sprintf(
506 506
 			'<a href="%s"%s>%s</a>',
507
-			esc_url( add_query_arg( $url_args, 'edit.php' ) ),
507
+			esc_url(add_query_arg($url_args, 'edit.php')),
508 508
 			$class_html, // html - hardcoded, no need to escape.
509 509
 			$link_label  // html - escaped earlier in the code.
510 510
 		);
511 511
 
512
-		$views[ $repeat_type ] = $link_html;
512
+		$views[$repeat_type] = $link_html;
513 513
 	}
514 514
 
515 515
 	return $views;
@@ -527,26 +527,26 @@  discard block
 block discarded – undo
527 527
  *
528 528
  * @return mixed Main admin query with edited params to get posts of specified repeat type.
529 529
  */
530
-function admin_table_repeat_type_posts_query( $wp_query ) {
530
+function admin_table_repeat_type_posts_query($wp_query) {
531 531
 
532 532
 	// Stop - if not admin or not main query (there are secondary WP_Query for counting posts for view links, etc).
533
-	if ( ! is_admin() || ! $wp_query->is_main_query() ) {
533
+	if ( ! is_admin() || ! $wp_query->is_main_query()) {
534 534
 		return $wp_query;
535 535
 	}
536 536
 
537 537
 	// Get URL query param for repeat type and check it's valid.
538 538
 	$repeat_type = get_repeat_type_url_param();
539 539
 
540
-	if ( ! $repeat_type || ! is_allowed_repeat_type( $repeat_type ) ) {
540
+	if ( ! $repeat_type || ! is_allowed_repeat_type($repeat_type)) {
541 541
 		return $wp_query;
542 542
 	}
543 543
 
544 544
 	// Repeat post display - only displaying Repeat posts for a specific Repeating post.
545
-	$post_parent_id = isset( $_GET['post_parent'] ) ? intval( $_GET['post_parent'] ) : 0;
545
+	$post_parent_id = isset($_GET['post_parent']) ? intval($_GET['post_parent']) : 0;
546 546
 
547 547
 	// Add WP_Query param depending on displayed repeat type.
548
-	foreach ( get_repeat_type_query_params( $repeat_type, $post_parent_id ) as $key => $value ) {
549
-		$wp_query->set( $key, $value );
548
+	foreach (get_repeat_type_query_params($repeat_type, $post_parent_id) as $key => $value) {
549
+		$wp_query->set($key, $value);
550 550
 	}
551 551
 
552 552
 	return $wp_query;
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
  *
562 562
  * @return array Array of custom WP_Query params.
563 563
  */
564
-function get_repeat_type_query_params( $repeat_type, $post_parent_id = 0 ) {
564
+function get_repeat_type_query_params($repeat_type, $post_parent_id = 0) {
565 565
 
566 566
 	$query['post_type'] = get_current_screen()->post_type;
567 567
 
@@ -573,15 +573,15 @@  discard block
 block discarded – undo
573 573
 			),
574 574
 	);
575 575
 
576
-	if ( $repeat_type === 'repeat' ) {
577
-		$query['post_parent__not_in'] = array( 0 );
576
+	if ($repeat_type === 'repeat') {
577
+		$query['post_parent__not_in'] = array(0);
578 578
 
579
-	} elseif ( $repeat_type === 'repeating' ) {
580
-		$query['post_parent__in'] = array( 0 );
579
+	} elseif ($repeat_type === 'repeating') {
580
+		$query['post_parent__in'] = array(0);
581 581
 	}
582 582
 
583 583
 	// Repeat post display - only displaying Repeat posts for specific Repeating post.
584
-	if ( $post_parent_id ) {
584
+	if ($post_parent_id) {
585 585
 		$query['post_parent']         = $post_parent_id;
586 586
 		$query['post_parent__not_in'] = '';
587 587
 		$query['post_parent__in']     = '';
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
  * @return string Sanitized string of repeat type being displayed.
598 598
  */
599 599
 function get_repeat_type_url_param() {
600
-	return isset( $_GET['hm-post-repeat'] ) ? sanitize_text_field( $_GET['hm-post-repeat'] ) : '';
600
+	return isset($_GET['hm-post-repeat']) ? sanitize_text_field($_GET['hm-post-repeat']) : '';
601 601
 }
602 602
 
603 603
 /**
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
  */
608 608
 function get_available_repeat_types() {
609 609
 	return array(
610
-		'repeating' => __( 'Repeating', 'hm-post-repeat' ),
611
-		'repeat'    => __( 'Repeat', 'hm-post-repeat' ),
610
+		'repeating' => __('Repeating', 'hm-post-repeat'),
611
+		'repeat'    => __('Repeat', 'hm-post-repeat'),
612 612
 	);
613 613
 }
614 614
 
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
  * @return bool True if repeat type is valid,
621 621
  *              False otherwise.
622 622
  */
623
-function is_allowed_repeat_type( $repeat_type ) {
624
-	return in_array( $repeat_type, array_keys( get_available_repeat_types() ) );
623
+function is_allowed_repeat_type($repeat_type) {
624
+	return in_array($repeat_type, array_keys(get_available_repeat_types()));
625 625
 }
626 626
 
627 627
 /**
@@ -639,10 +639,10 @@  discard block
 block discarded – undo
639 639
  *
640 640
  * @return array An array of row action links with added link to view Repeat posts and there count.
641 641
  */
642
-function admin_table_row_actions_view_repeat_posts( $actions, $post ) {
642
+function admin_table_row_actions_view_repeat_posts($actions, $post) {
643 643
 	global $repeat_posts_count;
644 644
 
645
-	if ( ! is_repeating_post( $post->ID ) ) {
645
+	if ( ! is_repeating_post($post->ID)) {
646 646
 		return $actions;
647 647
 	}
648 648
 
@@ -653,44 +653,44 @@  discard block
 block discarded – undo
653 653
 		'post_parent'    => $post->ID,
654 654
 	);
655 655
 
656
-	$count = $repeat_posts_count[ $post->ID ];
656
+	$count = $repeat_posts_count[$post->ID];
657 657
 
658 658
 	// Repeating post has got some Repeat posts - display the link to view them with the count.
659
-	if ( $count ) {
659
+	if ($count) {
660 660
 		$actions['view_repeat'] = sprintf(
661 661
 			'<a href="%s" aria-label="%s">%s</a>',
662
-			esc_url( add_query_arg( $url_args, 'edit.php' ) ),
663
-			esc_attr( sprintf(
662
+			esc_url(add_query_arg($url_args, 'edit.php')),
663
+			esc_attr(sprintf(
664 664
 				_n(
665 665
 					'View %d repeat post',
666 666
 					'View %d repeat posts',
667 667
 					$count,
668 668
 					'hm-post-repeat'
669 669
 				),
670
-				number_format_i18n( $count )
671
-			) ),
672
-			esc_html( sprintf(
670
+				number_format_i18n($count)
671
+			)),
672
+			esc_html(sprintf(
673 673
 				_n(
674 674
 					'%d repeat post',
675 675
 					'%d repeat posts',
676 676
 					$count,
677 677
 					'hm-post-repeat'
678 678
 				),
679
-				number_format_i18n( $count )
680
-			) )
679
+				number_format_i18n($count)
680
+			))
681 681
 		);
682 682
 	}
683 683
 	// Repeating post has no Repeat posts - display text, not a link.
684 684
 	else {
685
-		$actions['view_repeat'] = esc_html( sprintf(
685
+		$actions['view_repeat'] = esc_html(sprintf(
686 686
 			_n(
687 687
 				'%d repeat post',
688 688
 				'%d repeat posts',
689 689
 				$count,
690 690
 				'hm-post-repeat'
691 691
 			),
692
-			number_format_i18n( $count )
693
-		) );
692
+			number_format_i18n($count)
693
+		));
694 694
 	}
695 695
 
696 696
 	return $actions;
@@ -712,30 +712,30 @@  discard block
 block discarded – undo
712 712
 	global $wp_query, $repeat_posts_count;
713 713
 
714 714
 	// Stop - if current page is not admin page displaying Repeating posts.
715
-	if ( ! is_admin() && get_repeat_type_url_param() !== 'repeating' ) {
715
+	if ( ! is_admin() && get_repeat_type_url_param() !== 'repeating') {
716 716
 		return;
717 717
 	}
718 718
 
719 719
 	// Stop - if no Repeating posts found to display.
720
-	if ( ! $wp_query->posts || ! count( $wp_query->posts ) ) {
720
+	if ( ! $wp_query->posts || ! count($wp_query->posts)) {
721 721
 		return;
722 722
 	}
723 723
 
724 724
 	// Get currently displayed Repeating posts IDs on the screen.
725
-	$repeating_ids = wp_list_pluck( $wp_query->posts, 'ID' );
725
+	$repeating_ids = wp_list_pluck($wp_query->posts, 'ID');
726 726
 
727 727
 	// Get Repeating posts' corresponding Repeat posts so we can count them.
728
-	$repeat_posts_query = new \WP_Query( array( 'post_parent__in' => $repeating_ids ) );
728
+	$repeat_posts_query = new \WP_Query(array('post_parent__in' => $repeating_ids));
729 729
 	$repeat_posts       = $repeat_posts_query->posts;
730 730
 
731 731
 	// Create array with keys as Repeating post IDs and 0 values.
732 732
 	$repeat_posts_count = array();
733
-	foreach ( $repeating_ids as $repeating_id ) {
734
-		$repeat_posts_count[ $repeating_id ] = 0;
733
+	foreach ($repeating_ids as $repeating_id) {
734
+		$repeat_posts_count[$repeating_id] = 0;
735 735
 	}
736 736
 
737 737
 	// Count for each Repeating ID, how many Repeat posts there are.
738
-	foreach ( $repeat_posts as $repeat_post ) {
739
-		$repeat_posts_count[ $repeat_post->post_parent ] += 1;
738
+	foreach ($repeat_posts as $repeat_post) {
739
+		$repeat_posts_count[$repeat_post->post_parent] += 1;
740 740
 	}
741 741
 }
Please login to merge, or discard this patch.