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 (#36)
by
unknown
02:11
created
hm-post-repeat.php 1 patch
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -35,36 +35,36 @@  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__ . '\manage_repeat_post', 10 );
40
-add_action( 'admin_enqueue_scripts',       __NAMESPACE__ . '\enqueue_scripts' );
41
-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__.'\manage_repeat_post', 10);
40
+add_action('admin_enqueue_scripts', __NAMESPACE__.'\enqueue_scripts');
41
+add_filter('display_post_states', __NAMESPACE__.'\admin_table_row_post_states', 10, 2);
42 42
 
43 43
 // Add repeat type table view links to admin screen for each CPT that supports Repeatable Posts.
44
-add_action( 'init', function() {
45
-	foreach ( repeating_post_types() as $post_type ) {
46
-		add_filter( "views_edit-{$post_type}", __NAMESPACE__ . '\admin_table_views_links' );
44
+add_action('init', function() {
45
+	foreach (repeating_post_types() as $post_type) {
46
+		add_filter("views_edit-{$post_type}", __NAMESPACE__.'\admin_table_views_links');
47 47
 	}
48 48
 } );
49 49
 
50 50
 // Display only Repeatable Posts in admin table view for registered view links.
51
-add_filter( 'pre_get_posts', __NAMESPACE__ . '\admin_table_repeat_type_posts_query' );
51
+add_filter('pre_get_posts', __NAMESPACE__.'\admin_table_repeat_type_posts_query');
52 52
 
53 53
 /**
54 54
  * Enqueue the scripts and styles that are needed by this plugin.
55 55
  */
56
-function enqueue_scripts( $hook ) {
56
+function enqueue_scripts($hook) {
57 57
 
58 58
 	// Ensure we only load them on the edit post and add new post admin screens
59
-	if ( ! in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
59
+	if ( ! in_array($hook, array('post.php', 'post-new.php'))) {
60 60
 		return;
61 61
 	}
62 62
 
63
-	$plugin_data = get_plugin_data( __FILE__ );
64
-	$plugin_dir_url = plugin_dir_url( __FILE__ );
63
+	$plugin_data = get_plugin_data(__FILE__);
64
+	$plugin_dir_url = plugin_dir_url(__FILE__);
65 65
 
66
-	wp_enqueue_script( 'hm-post-repeat', $plugin_dir_url . 'hm-post-repeat.js', 'jquery', $plugin_data['Version'], true );
67
-	wp_enqueue_style( 'hm-post-repeat', $plugin_dir_url . 'hm-post-repeat.css', array(), $plugin_data['Version'] );
66
+	wp_enqueue_script('hm-post-repeat', $plugin_dir_url.'hm-post-repeat.js', 'jquery', $plugin_data['Version'], true);
67
+	wp_enqueue_style('hm-post-repeat', $plugin_dir_url.'hm-post-repeat.css', array(), $plugin_data['Version']);
68 68
 
69 69
 }
70 70
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
  */
77 77
 function publish_box_ui() {
78 78
 
79
-	if ( ! in_array( get_post_type(), repeating_post_types() ) ) {
79
+	if ( ! in_array(get_post_type(), repeating_post_types())) {
80 80
 		return;
81 81
 	} ?>
82 82
 
@@ -84,31 +84,31 @@  discard block
 block discarded – undo
84 84
 
85 85
 		<span class="dashicons dashicons-controls-repeat"></span>
86 86
 
87
-		<?php esc_html_e( 'Repeat:', 'hm-post-repeat' ); ?>
87
+		<?php esc_html_e('Repeat:', 'hm-post-repeat'); ?>
88 88
 
89
-		<?php if ( is_repeat_post( get_the_id() ) ) : ?>
89
+		<?php if (is_repeat_post(get_the_id())) : ?>
90 90
 
91
-			<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>
91
+			<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>
92 92
 
93 93
 		<?php else : ?>
94 94
 
95
-			<?php $repeating_schedule = get_repeating_schedule( get_the_id() ); ?>
96
-			<?php $is_repeating_post = is_repeating_post( get_the_id() ) && isset( $repeating_schedule ); ?>
95
+			<?php $repeating_schedule = get_repeating_schedule(get_the_id()); ?>
96
+			<?php $is_repeating_post = is_repeating_post(get_the_id()) && isset($repeating_schedule); ?>
97 97
 
98
-			<strong><?php echo ! $is_repeating_post ? esc_html__( 'No', 'hm-post-repeat' ) : esc_html( $repeating_schedule['display'] ); ?></strong>
98
+			<strong><?php echo ! $is_repeating_post ? esc_html__('No', 'hm-post-repeat') : esc_html($repeating_schedule['display']); ?></strong>
99 99
 
100
-			<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>
100
+			<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>
101 101
 
102 102
 			<span class="hide-if-js" id="hm-post-repeat">
103 103
 
104 104
 				<select name="hm-post-repeat">
105
-					<option<?php selected( ! $is_repeating_post ); ?> value="no"><?php esc_html_e( 'No', 'hm-post-repeat' ); ?></option>
106
-					<?php foreach ( get_repeating_schedules() as $schedule_slug => $schedule ) : ?>
107
-						<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>
105
+					<option<?php selected( ! $is_repeating_post); ?> value="no"><?php esc_html_e('No', 'hm-post-repeat'); ?></option>
106
+					<?php foreach (get_repeating_schedules() as $schedule_slug => $schedule) : ?>
107
+						<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>
108 108
 					<?php endforeach; ?>
109 109
 				</select>
110 110
 
111
-				<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>
111
+				<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>
112 112
 
113 113
 			</span>
114 114
 
@@ -127,21 +127,21 @@  discard block
 block discarded – undo
127 127
  * @param WP_Post $post        The post object to get / return the states.
128 128
  * @return array The array of post states with ours added.
129 129
  */
130
-function admin_table_row_post_states( $post_states, $post ) {
130
+function admin_table_row_post_states($post_states, $post) {
131 131
 
132
-	if ( is_repeating_post( $post->ID ) ) {
132
+	if (is_repeating_post($post->ID)) {
133 133
 
134 134
 		// If the schedule has been removed since publishing, let the user know.
135
-		if ( get_repeating_schedule( $post->ID ) ) {
136
-			$post_states['hm-post-repeat'] = __( 'Repeating', 'hm-post-repeat' );
135
+		if (get_repeating_schedule($post->ID)) {
136
+			$post_states['hm-post-repeat'] = __('Repeating', 'hm-post-repeat');
137 137
 		} else {
138
-			$post_states['hm-post-repeat'] = __( 'Invalid Repeating Schedule', 'hm-post-repeat' );
138
+			$post_states['hm-post-repeat'] = __('Invalid Repeating Schedule', 'hm-post-repeat');
139 139
 		}
140 140
 
141 141
 	}
142 142
 
143
-	if ( is_repeat_post( $post->ID ) ) {
144
-		$post_states['hm-post-repeat'] = __( 'Repeat', 'hm-post-repeat' );
143
+	if (is_repeat_post($post->ID)) {
144
+		$post_states['hm-post-repeat'] = __('Repeat', 'hm-post-repeat');
145 145
 	}
146 146
 
147 147
 	return $post_states;
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
  * @param string $post_repeat_setting Repeating Schedule setting (daily, weekly, etc).
159 159
  *                                    NB: Used to manually set the Repeating Schedule for a post from tests.
160 160
  */
161
-function manage_repeat_post( $post_id = null, $post_repeat_setting = null ) {
161
+function manage_repeat_post($post_id = null, $post_repeat_setting = null) {
162 162
 
163 163
 	// Not running a phpunit test - check if Repeating Schedule setting value is present when saving a post.
164
-	if ( is_null( $post_repeat_setting ) ) {
165
-		$post_repeat_setting = isset( $_POST['hm-post-repeat'] ) ? sanitize_text_field( $_POST['hm-post-repeat'] ) : '';
164
+	if (is_null($post_repeat_setting)) {
165
+		$post_repeat_setting = isset($_POST['hm-post-repeat']) ? sanitize_text_field($_POST['hm-post-repeat']) : '';
166 166
 	}
167 167
 
168 168
 	/**
@@ -172,26 +172,26 @@  discard block
 block discarded – undo
172 172
 	 * 3. Not processing a Repeating post (i.e. Repeating Schedule isn't specified).
173 173
 	 */
174 174
 	if (
175
-			! in_array( get_post_type( $post_id ), repeating_post_types() ) ||
176
-			( ! is_repeat_post( $post_id ) && empty( $post_repeat_setting ) )
175
+			! in_array(get_post_type($post_id), repeating_post_types()) ||
176
+			( ! is_repeat_post($post_id) && empty($post_repeat_setting))
177 177
 	) {
178 178
 		return;
179 179
 	}
180 180
 
181 181
 	// Repeating post - save the specified Repeating Schedule and manage a Repeat post.
182
-	if ( $post_repeat_setting ) {
182
+	if ($post_repeat_setting) {
183 183
 
184 184
 		// Repeating Schedule is removed - i.e. the post is no longer Repeating.
185
-		if ( 'no' === $post_repeat_setting ) {
185
+		if ('no' === $post_repeat_setting) {
186 186
 
187 187
 			// Remove post meta from the Repeating post.
188
-			delete_post_meta( $post_id, 'hm-post-repeat' );
188
+			delete_post_meta($post_id, 'hm-post-repeat');
189 189
 
190 190
 			// Clean up the currently scheduled Repeat post if any.
191
-			delete_next_scheduled_repeat_post( $post_id );
191
+			delete_next_scheduled_repeat_post($post_id);
192 192
 		}
193 193
 		// Repeating Schedule is specified and valid - save it to post's meta and manage a Repeat post.
194
-		elseif ( in_array( $post_repeat_setting, array_keys( get_repeating_schedules() ) ) ) {
194
+		elseif (in_array($post_repeat_setting, array_keys(get_repeating_schedules()))) {
195 195
 
196 196
 			/**
197 197
 			 * Clean up the currently scheduled Repeat post if any. This takes care of cases when:
@@ -200,20 +200,20 @@  discard block
 block discarded – undo
200 200
 			 *
201 201
 			 * In such cases, the next scheduled post should reflect these changes.
202 202
 			 */
203
-			delete_next_scheduled_repeat_post( $post_id );
203
+			delete_next_scheduled_repeat_post($post_id);
204 204
 
205 205
 			// Update a Repeating Schedule for the current post.
206
-			update_post_meta( $post_id, 'hm-post-repeat', $post_repeat_setting );
206
+			update_post_meta($post_id, 'hm-post-repeat', $post_repeat_setting);
207 207
 
208 208
 			// Schedule a Repeat post.
209
-			create_next_repeat_post( $post_id );
209
+			create_next_repeat_post($post_id);
210 210
 		}
211 211
 	}
212 212
 
213 213
 	// Repeat post - is published, schedule a next Repeat post.
214
-	if ( is_repeat_post( $post_id ) && 'publish' === get_post_status( $post_id ) ) {
214
+	if (is_repeat_post($post_id) && 'publish' === get_post_status($post_id)) {
215 215
 
216
-		create_next_repeat_post( $post_id );
216
+		create_next_repeat_post($post_id);
217 217
 	}
218 218
 }
219 219
 
@@ -231,53 +231,53 @@  discard block
 block discarded – undo
231 231
  *                       WP_Error if a Repeat post could not be created.
232 232
  *                       Terminate function execution if conditions are not met.
233 233
  */
234
-function create_next_repeat_post( $post_id ) {
234
+function create_next_repeat_post($post_id) {
235 235
 
236 236
 	// Stop - post type doesn't support Repeating Posts feature.
237
-	if ( ! in_array( get_post_type( $post_id ), repeating_post_types() ) ) {
237
+	if ( ! in_array(get_post_type($post_id), repeating_post_types())) {
238 238
 		return false;
239 239
 	}
240 240
 
241 241
 	// Stop - the current post isn't being published.
242
-	if ( 'publish' !== get_post_status( $post_id ) ) {
242
+	if ('publish' !== get_post_status($post_id)) {
243 243
 		return false;
244 244
 	}
245 245
 
246 246
 	// Get the Repeating post ID for the current post being saved (which in turn can be a Repeating or Repeat post).
247
-	$original_post_id = get_repeating_post( $post_id );
247
+	$original_post_id = get_repeating_post($post_id);
248 248
 
249
-	if ( ! $original_post_id ) {
249
+	if ( ! $original_post_id) {
250 250
 		return false;
251 251
 	}
252 252
 
253 253
 	// Get the original Repeating post.
254
-	$original_post = get_post( $original_post_id, ARRAY_A );
254
+	$original_post = get_post($original_post_id, ARRAY_A);
255 255
 
256 256
 	// Stop - the original Repeating post isn't already published.
257
-	if ( 'publish' !== $original_post['post_status'] ) {
257
+	if ('publish' !== $original_post['post_status']) {
258 258
 		return false;
259 259
 	}
260 260
 
261 261
 	// Stop - there is already a Repeat post scheduled don't create another one.
262
-	if ( get_next_scheduled_repeat_post( $original_post['ID'] ) ) {
262
+	if (get_next_scheduled_repeat_post($original_post['ID'])) {
263 263
 		return false;
264 264
 	}
265 265
 
266 266
 	// Get Repeating Schedule.
267
-	$repeating_schedule = get_repeating_schedule( $original_post['ID'] );
267
+	$repeating_schedule = get_repeating_schedule($original_post['ID']);
268 268
 
269
-	if ( ! $repeating_schedule ) {
269
+	if ( ! $repeating_schedule) {
270 270
 		return false;
271 271
 	}
272 272
 
273 273
 	$next_post = $original_post;
274 274
 
275 275
 	// Create the Repeat post as a copy of the original, but ignore some fields.
276
-	unset( $next_post['ID'] );
277
-	unset( $next_post['guid'] );
278
-	unset( $next_post['post_date_gmt'] );
279
-	unset( $next_post['post_modified'] );
280
-	unset( $next_post['post_modified_gmt'] );
276
+	unset($next_post['ID']);
277
+	unset($next_post['guid']);
278
+	unset($next_post['post_date_gmt']);
279
+	unset($next_post['post_modified']);
280
+	unset($next_post['post_modified_gmt']);
281 281
 
282 282
 	// Set the post_parent to the original Repeating post_id, so they're related.
283 283
 	$next_post['post_parent'] = $original_post['ID'];
@@ -286,10 +286,10 @@  discard block
 block discarded – undo
286 286
 	$next_post['post_status'] = 'future';
287 287
 
288 288
 	// Use the date of the current post being saved as the base.
289
-	$next_post['post_date'] = date( 'Y-m-d H:i:s', strtotime( get_post_field( 'post_date', $post_id ) . ' + ' . $repeating_schedule['interval'] ) );
289
+	$next_post['post_date'] = date('Y-m-d H:i:s', strtotime(get_post_field('post_date', $post_id).' + '.$repeating_schedule['interval']));
290 290
 
291 291
 	// Make sure the next post will be in the future from the current time.
292
-	if ( strtotime( $next_post['post_date'] ) <= time() ) {
292
+	if (strtotime($next_post['post_date']) <= time()) {
293 293
 		return false;
294 294
 	}
295 295
 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 * @param array $repeating_schedule Repeating schedule info.
301 301
 	 * @param array $original_post      The original repeating post.
302 302
 	 */
303
-	$next_post = apply_filters( 'hm_post_repeat_edit_repeat_post', $next_post, $repeating_schedule, $original_post );
303
+	$next_post = apply_filters('hm_post_repeat_edit_repeat_post', $next_post, $repeating_schedule, $original_post);
304 304
 
305 305
 	/**
306 306
 	 * Remove and then re-add our custom functionality hooked in into `save_post` filter.
@@ -309,41 +309,41 @@  discard block
 block discarded – undo
309 309
 	 *
310 310
 	 * We want our custom functionality to run on the `save_post` filter only once.
311 311
 	 */
312
-	remove_action( 'save_post', __NAMESPACE__ . '\\manage_repeat_post' );
312
+	remove_action('save_post', __NAMESPACE__.'\\manage_repeat_post');
313 313
 
314 314
 	// All checks done, get that post scheduled!
315
-	$next_post_id = wp_insert_post( wp_slash( $next_post ), true );
315
+	$next_post_id = wp_insert_post(wp_slash($next_post), true);
316 316
 
317
-	add_action( 'save_post', __NAMESPACE__ . '\\manage_repeat_post' );
317
+	add_action('save_post', __NAMESPACE__.'\\manage_repeat_post');
318 318
 
319
-	if ( is_wp_error( $next_post_id ) ) {
319
+	if (is_wp_error($next_post_id)) {
320 320
 		return false;
321 321
 	}
322 322
 
323 323
 	// Mirror any post meta.
324
-	$post_meta = get_post_meta( $original_post['ID'] );
324
+	$post_meta = get_post_meta($original_post['ID']);
325 325
 
326
-	if ( $post_meta ) {
326
+	if ($post_meta) {
327 327
 
328 328
 		// Ignore some internal meta fields.
329
-		unset( $post_meta['_edit_lock'] );
330
-		unset( $post_meta['_edit_last'] );
329
+		unset($post_meta['_edit_lock']);
330
+		unset($post_meta['_edit_last']);
331 331
 
332 332
 		// Don't copy the post Repeating Schedule meta as only the original Repeating post should have that.
333
-		unset( $post_meta['hm-post-repeat'] );
333
+		unset($post_meta['hm-post-repeat']);
334 334
 
335
-		foreach ( $post_meta as $key => $values ) {
336
-			foreach ( $values as $value ) {
337
-				add_post_meta( $next_post_id, $key, maybe_unserialize( $value ) );
335
+		foreach ($post_meta as $key => $values) {
336
+			foreach ($values as $value) {
337
+				add_post_meta($next_post_id, $key, maybe_unserialize($value));
338 338
 			}
339 339
 		}
340 340
 	}
341 341
 
342 342
 	// Mirror any term relationships.
343
-	$taxonomies = get_object_taxonomies( $original_post['post_type'] );
343
+	$taxonomies = get_object_taxonomies($original_post['post_type']);
344 344
 
345
-	foreach ( $taxonomies as $taxonomy ) {
346
-		wp_set_object_terms( $next_post_id, wp_list_pluck( wp_get_object_terms( $original_post['ID'], $taxonomy ), 'slug' ), $taxonomy );
345
+	foreach ($taxonomies as $taxonomy) {
346
+		wp_set_object_terms($next_post_id, wp_list_pluck(wp_get_object_terms($original_post['ID'], $taxonomy), 'slug'), $taxonomy);
347 347
 	}
348 348
 
349 349
 	return $next_post_id;
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 *
364 364
 	 * @param string[] $post_types Post type slugs.
365 365
 	 */
366
-	return apply_filters( 'hm_post_repeat_post_types', array( 'post' ) );
366
+	return apply_filters('hm_post_repeat_post_types', array('post'));
367 367
 
368 368
 }
369 369
 
@@ -379,13 +379,13 @@  discard block
 block discarded – undo
379 379
 	 *
380 380
 	 * @param array[] $schedules Schedule array items.
381 381
 	 */
382
-	$schedules = apply_filters( 'hm_post_repeat_schedules', array(
383
-		'daily'   => array( 'interval' => '1 day',   'display' => __( 'Daily',   'hm-post-repeat' ) ),
384
-		'weekly'  => array( 'interval' => '1 week',  'display' => __( 'Weekly',  'hm-post-repeat' ) ),
385
-		'monthly' => array( 'interval' => '1 month', 'display' => __( 'Monthly', 'hm-post-repeat' ) ),
386
-	) );
382
+	$schedules = apply_filters('hm_post_repeat_schedules', array(
383
+		'daily'   => array('interval' => '1 day', 'display' => __('Daily', 'hm-post-repeat')),
384
+		'weekly'  => array('interval' => '1 week', 'display' => __('Weekly', 'hm-post-repeat')),
385
+		'monthly' => array('interval' => '1 month', 'display' => __('Monthly', 'hm-post-repeat')),
386
+	));
387 387
 
388
-	foreach ( $schedules as $slug => &$schedule ) {
388
+	foreach ($schedules as $slug => &$schedule) {
389 389
 		$schedule['slug'] = $slug;
390 390
 	}
391 391
 
@@ -399,22 +399,22 @@  discard block
 block discarded – undo
399 399
  * @param int $post_id The id of the post you want to check.
400 400
  * @return array|null The schedule to repeat by, or null if invalid.
401 401
  */
402
-function get_repeating_schedule( $post_id ) {
402
+function get_repeating_schedule($post_id) {
403 403
 
404
-	if ( ! is_repeating_post( $post_id ) ) {
404
+	if ( ! is_repeating_post($post_id)) {
405 405
 		return;
406 406
 	}
407 407
 
408
-	$repeating_schedule = get_post_meta( $post_id, 'hm-post-repeat', true );
408
+	$repeating_schedule = get_post_meta($post_id, 'hm-post-repeat', true);
409 409
 	$schedules = get_repeating_schedules();
410 410
 
411 411
 	// Backwards compatibility with 0.3 when we only supported weekly
412
-	if ( '1' === $repeating_schedule ) {
412
+	if ('1' === $repeating_schedule) {
413 413
 		$repeating_schedule = 'weekly';
414 414
 	}
415 415
 
416
-	if ( array_key_exists( $repeating_schedule, $schedules ) ) {
417
-		return $schedules[ $repeating_schedule ];
416
+	if (array_key_exists($repeating_schedule, $schedules)) {
417
+		return $schedules[$repeating_schedule];
418 418
 	}
419 419
 
420 420
 }
@@ -427,14 +427,14 @@  discard block
 block discarded – undo
427 427
  * @param int $post_id The id of the post you want to check.
428 428
  * @return bool Whether the passed post_id is a repeating post or not.
429 429
  */
430
-function is_repeating_post( $post_id ) {
430
+function is_repeating_post($post_id) {
431 431
 
432 432
 	// We check $_POST data so that this function works inside a `save_post` hook when the post_meta hasn't yet been saved
433
-	if ( isset( $_POST['hm-post-repeat'] ) && isset( $_POST['ID'] ) && $_POST['ID'] === $post_id ) {
433
+	if (isset($_POST['hm-post-repeat']) && isset($_POST['ID']) && $_POST['ID'] === $post_id) {
434 434
 		return true;
435 435
 	}
436 436
 
437
-	if ( get_post_meta( $post_id, 'hm-post-repeat', true ) ) {
437
+	if (get_post_meta($post_id, 'hm-post-repeat', true)) {
438 438
 		return true;
439 439
 	}
440 440
 
@@ -450,11 +450,11 @@  discard block
 block discarded – undo
450 450
  * @param int $post_id The id of the post you want to check.
451 451
  * @return bool Whether the passed post_id is a repeat post or not.
452 452
  */
453
-function is_repeat_post( $post_id ) {
453
+function is_repeat_post($post_id) {
454 454
 
455
-	$post_parent = get_post_field( 'post_parent', $post_id );
455
+	$post_parent = get_post_field('post_parent', $post_id);
456 456
 
457
-	if ( $post_parent && get_post_meta( $post_parent, 'hm-post-repeat', true ) ) {
457
+	if ($post_parent && get_post_meta($post_parent, 'hm-post-repeat', true)) {
458 458
 		return true;
459 459
 	}
460 460
 
@@ -466,14 +466,14 @@  discard block
 block discarded – undo
466 466
  *
467 467
  * @param $post_id The ID of a Repeat or Repeating post to delete scheduled posts for.
468 468
  */
469
-function delete_next_scheduled_repeat_post( $post_id ) {
469
+function delete_next_scheduled_repeat_post($post_id) {
470 470
 
471 471
 	// TO DO: will it ever be more than 1 scheduled post?
472
-	$next_repeat_post = get_next_scheduled_repeat_post( $post_id );
472
+	$next_repeat_post = get_next_scheduled_repeat_post($post_id);
473 473
 
474
-	if ( $next_repeat_post ) {
474
+	if ($next_repeat_post) {
475 475
 		// TO DO: should we trash or permanently delete? I think permanently delete.
476
-		wp_delete_post( $next_repeat_post->ID, true );
476
+		wp_delete_post($next_repeat_post->ID, true);
477 477
 	}
478 478
 }
479 479
 
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
  *
485 485
  * @return int|bool Return the ID of the next repeat post_id or false if it can't find one.
486 486
  */
487
-function get_next_scheduled_repeat_post( $post_id ) {
487
+function get_next_scheduled_repeat_post($post_id) {
488 488
 
489
-	$post = get_post( get_repeating_post( $post_id ) );
489
+	$post = get_post(get_repeating_post($post_id));
490 490
 
491
-	$repeat_posts = get_posts( array( 'post_status' => 'future', 'post_parent' => $post->ID ) );
491
+	$repeat_posts = get_posts(array('post_status' => 'future', 'post_parent' => $post->ID));
492 492
 
493
-	if ( isset( $repeat_posts[0] ) ) {
493
+	if (isset($repeat_posts[0])) {
494 494
 		return $repeat_posts[0];
495 495
 	}
496 496
 
@@ -504,17 +504,17 @@  discard block
 block discarded – undo
504 504
  *
505 505
  * @return int|bool Return the original repeating post_id or false if it can't find it.
506 506
  */
507
-function get_repeating_post( $post_id ) {
507
+function get_repeating_post($post_id) {
508 508
 
509 509
 	$original_post_id = false;
510 510
 
511 511
 	// Are we publishing a Repeat post.
512
-	if ( is_repeat_post( $post_id ) ) {
513
-		$original_post_id = get_post( $post_id )->post_parent;
512
+	if (is_repeat_post($post_id)) {
513
+		$original_post_id = get_post($post_id)->post_parent;
514 514
 	}
515 515
 
516 516
 	// Or the original Repeating post.
517
-	elseif ( is_repeating_post( $post_id ) ) {
517
+	elseif (is_repeating_post($post_id)) {
518 518
 		$original_post_id = $post_id;
519 519
 	}
520 520
 
@@ -531,10 +531,10 @@  discard block
 block discarded – undo
531 531
  *
532 532
  * @return array Available list of table views with custom added views per repeat type.
533 533
  */
534
-function admin_table_views_links( $views ) {
534
+function admin_table_views_links($views) {
535 535
 
536 536
 	// Add status link for each repeat type.
537
-	foreach ( get_available_repeat_types() as $repeat_type => $repeat_desc ) {
537
+	foreach (get_available_repeat_types() as $repeat_type => $repeat_desc) {
538 538
 
539 539
 		$url_args = array(
540 540
 			'post_type'      => get_current_screen()->post_type,
@@ -542,25 +542,25 @@  discard block
 block discarded – undo
542 542
 		);
543 543
 
544 544
 		// Custom WP_Query to get posts count of repeat type.
545
-		$repeat_type_query = new \WP_Query( get_repeat_type_query_params( $repeat_type ) );
545
+		$repeat_type_query = new \WP_Query(get_repeat_type_query_params($repeat_type));
546 546
 
547 547
 		$link_label = sprintf(
548 548
 				'%s <span class="count">(%s)</span>',
549
-			esc_html( $repeat_desc ),
550
-			esc_html( number_format_i18n( $repeat_type_query->post_count ) )
549
+			esc_html($repeat_desc),
550
+			esc_html(number_format_i18n($repeat_type_query->post_count))
551 551
 		);
552 552
 
553 553
 		// Add current class to the link to highlight it when it's selected.
554
-		$class_html = ( get_repeat_type_url_param() === $repeat_type ) ? ' class="current"' : '';
554
+		$class_html = (get_repeat_type_url_param() === $repeat_type) ? ' class="current"' : '';
555 555
 
556 556
 		$link_html = sprintf(
557 557
 			'<a href="%s"%s>%s</a>',
558
-			esc_url( add_query_arg( $url_args, 'edit.php' ) ),
558
+			esc_url(add_query_arg($url_args, 'edit.php')),
559 559
 			$class_html, // html - hardcoded, no need to escape.
560 560
 			$link_label  // html - escaped earlier in the code.
561 561
 		);
562 562
 
563
-		$views[ $repeat_type ] = $link_html;
563
+		$views[$repeat_type] = $link_html;
564 564
 	}
565 565
 
566 566
 	return $views;
@@ -574,23 +574,23 @@  discard block
 block discarded – undo
574 574
  *
575 575
  * @return mixed Main admin query with edited params to get posts of specified repeat type.
576 576
  */
577
-function admin_table_repeat_type_posts_query( $wp_query ) {
577
+function admin_table_repeat_type_posts_query($wp_query) {
578 578
 
579 579
 	// Stop - if not admin or not main query (there are secondary WP_Query for counting posts for view links, etc).
580
-	if ( ! is_admin() || ! $wp_query->is_main_query() ) {
580
+	if ( ! is_admin() || ! $wp_query->is_main_query()) {
581 581
 		return $wp_query;
582 582
 	}
583 583
 
584 584
 	// Get URL query param for repeat type and check it's valid.
585 585
 	$repeat_type = get_repeat_type_url_param();
586 586
 
587
-	if ( ! $repeat_type || ! is_allowed_repeat_type( $repeat_type ) ) {
587
+	if ( ! $repeat_type || ! is_allowed_repeat_type($repeat_type)) {
588 588
 		return $wp_query;
589 589
 	}
590 590
 
591 591
 	// Add a table view link per each repeat type.
592
-	foreach ( get_repeat_type_query_params( $repeat_type ) as $key => $value ) {
593
-		$wp_query->set( $key, $value );
592
+	foreach (get_repeat_type_query_params($repeat_type) as $key => $value) {
593
+		$wp_query->set($key, $value);
594 594
 	}
595 595
 
596 596
 	return $wp_query;
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
  *
605 605
  * @return array Array of custom WP_Query params.
606 606
  */
607
-function get_repeat_type_query_params( $repeat_type ) {
607
+function get_repeat_type_query_params($repeat_type) {
608 608
 
609 609
 	$query['post_type'] = get_current_screen()->post_type;
610 610
 
@@ -616,11 +616,11 @@  discard block
 block discarded – undo
616 616
 			),
617 617
 	);
618 618
 
619
-	if ( $repeat_type === 'repeat' ) {
620
-		$query['post_parent__not_in'] = array( 0 );
619
+	if ($repeat_type === 'repeat') {
620
+		$query['post_parent__not_in'] = array(0);
621 621
 
622
-	} elseif ( $repeat_type === 'repeating' ) {
623
-		$query['post_parent__in'] = array( 0 );
622
+	} elseif ($repeat_type === 'repeating') {
623
+		$query['post_parent__in'] = array(0);
624 624
 	}
625 625
 
626 626
 	return $query;
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
  * @return string Sanitized string of repeat type being displayed.
634 634
  */
635 635
 function get_repeat_type_url_param() {
636
-	return isset( $_GET['hm-post-repeat'] ) ? sanitize_text_field( $_GET['hm-post-repeat'] ) : '';
636
+	return isset($_GET['hm-post-repeat']) ? sanitize_text_field($_GET['hm-post-repeat']) : '';
637 637
 }
638 638
 
639 639
 /**
@@ -643,8 +643,8 @@  discard block
 block discarded – undo
643 643
  */
644 644
 function get_available_repeat_types() {
645 645
 	return array(
646
-		'repeating' => __( 'Repeating', 'hm-post-repeat' ),
647
-		'repeat'    => __( 'Repeat', 'hm-post-repeat' ),
646
+		'repeating' => __('Repeating', 'hm-post-repeat'),
647
+		'repeat'    => __('Repeat', 'hm-post-repeat'),
648 648
 	);
649 649
 }
650 650
 
@@ -656,6 +656,6 @@  discard block
 block discarded – undo
656 656
  * @return bool True if repeat type is valid,
657 657
  *              False otherwise.
658 658
  */
659
-function is_allowed_repeat_type( $repeat_type ) {
660
-	return in_array( $repeat_type, array_keys( get_available_repeat_types() ) );
659
+function is_allowed_repeat_type($repeat_type) {
660
+	return in_array($repeat_type, array_keys(get_available_repeat_types()));
661 661
 }
Please login to merge, or discard this patch.