Completed
Push — master ( 3e971c...84d4d7 )
by Mike
02:14
created
includes/class-test-content.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -252,29 +252,29 @@  discard block
 block discarded – undo
252 252
 		}
253 253
 
254 254
 		// Download the file
255
-	    $tmp = \download_url( $url );
255
+		$tmp = \download_url( $url );
256 256
 
257
-	    preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches );
257
+		preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches );
258 258
 
259
-        $file_array['name'] = basename( $matches[0] );
260
-        $file_array['tmp_name'] = $tmp;
259
+		$file_array['name'] = basename( $matches[0] );
260
+		$file_array['tmp_name'] = $tmp;
261 261
 
262
-	    // Check for download errors
263
-	    if ( is_wp_error( $tmp ) ) {
264
-	        unlink( $file_array[ 'tmp_name' ] );
265
-	        return $tmp->get_error_message();
266
-	    }
262
+		// Check for download errors
263
+		if ( is_wp_error( $tmp ) ) {
264
+			unlink( $file_array[ 'tmp_name' ] );
265
+			return $tmp->get_error_message();
266
+		}
267 267
 
268 268
 		// Pull the image into the media library
269
-	    $image_id = media_handle_sideload( $file_array, $post_id );
269
+		$image_id = media_handle_sideload( $file_array, $post_id );
270 270
 
271
-	    // Check for handle sideload errors.
272
-	    if ( is_wp_error( $image_id ) ) {
273
-	        unlink( $file_array['tmp_name'] );
274
-	        return $image_id->get_error_message();
275
-	    }
271
+		// Check for handle sideload errors.
272
+		if ( is_wp_error( $image_id ) ) {
273
+			unlink( $file_array['tmp_name'] );
274
+			return $image_id->get_error_message();
275
+		}
276 276
 
277
-	    return $image_id;
277
+		return $image_id;
278 278
 
279 279
 	}
280 280
 
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 
298 298
 		// If our cURL failed
299 299
 		if ( $curl_response === false ) {
300
-		    $info = curl_getinfo( $curl );
301
-		    curl_close( $curl );
302
-		    die( 'error occured during curl exec. Additional info: ' . var_export( $info ) );
300
+			$info = curl_getinfo( $curl );
301
+			curl_close( $curl );
302
+			die( 'error occured during curl exec. Additional info: ' . var_export( $info ) );
303 303
 		}
304 304
 
305 305
 		curl_close( $curl );
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  * @subpackage Evans
15 15
  * @author     Old Town Media
16 16
  */
17
-class TestContent{
17
+class TestContent {
18 18
 
19 19
 	/**
20 20
 	 * Title function.
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param int $num_words Number of words to return.
27 27
 	 * @return string Random title string.
28 28
 	 */
29
-	public static function title( $num_words = '' ){
29
+	public static function title($num_words = '') {
30 30
 
31 31
 		$title = '';
32 32
 
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
 		);
68 68
 
69 69
 		// If we didn't choose a count, make one
70
-		if ( empty( $num_words ) ){
71
-			$num_words = rand( 2, 10 );
70
+		if (empty($num_words)) {
71
+			$num_words = rand(2, 10);
72 72
 		}
73 73
 
74 74
 		// Pull random words
75
-		for( $i = 1; $i <= $num_words; $i++ ){
76
-			$title .= $random_words[ rand( 0, 31 ) ] . " ";
75
+		for ($i = 1; $i <= $num_words; $i++) {
76
+			$title .= $random_words[rand(0, 31)] . " ";
77 77
 		}
78 78
 
79
-		return substr( $title, 0, -1 );
79
+		return substr($title, 0, -1);
80 80
 
81 81
 	}
82 82
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return string Paragraph(s) of text.
91 91
 	 */
92
-	public static function paragraphs(){
92
+	public static function paragraphs() {
93 93
 
94 94
 		$content = '';
95 95
 
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 			'Sed porttitor augue vitae ante posuere sodales iaculis nec neque. Etiam dapibus nulla id vulputate tempus. Quisque tempus nisi dui, a commodo nulla sodales ut. Nulla nec odio tempus, sodales diam quis, feugiat odio. Nulla tincidunt tincidunt turpis, eget cursus felis tempor lacinia. Aenean molestie libero ut erat luctus aliquam. Sed vel enim quis nisl lacinia posuere. Ut fringilla ligula ligula, nec rhoncus mi suscipit id. Praesent volutpat blandit felis, et suscipit elit vulputate sit amet. Morbi sit amet justo quis sem rutrum euismod. Pellentesque at dictum sem, sed condimentum ex. Vivamus massa nisi, convallis in semper sit amet, venenatis convallis lectus. Nunc tristique, ex ac rutrum vehicula, arcu ex efficitur justo, sed euismod ligula nulla ut purus.',
186 186
 		);
187 187
 
188
-		for( $i = 1; $i < 6; $i++ ){
189
-			$content .= $random_content_types[rand( 0, 9 )];
188
+		for ($i = 1; $i < 6; $i++) {
189
+			$content .= $random_content_types[rand(0, 9)];
190 190
 		}
191 191
 
192 192
 		return $content;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @return string Plain text paragraphs.
203 203
 	 */
204
-	public static function plain_text(){
204
+	public static function plain_text() {
205 205
 
206 206
 		$paragraphs = array(
207 207
 			'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean tincidunt luctus eros, a tincidunt massa aliquet sit amet. Sed faucibus, eros non lacinia porttitor, risus odio efficitur sapien, id porta urna massa ac est. Cras efficitur lacinia magna eget tempus. Fusce ex felis, finibus consectetur mi at, finibus rhoncus augue. In ut tortor lacinia, rutrum mauris vel, maximus tortor. Praesent ac arcu nec eros pharetra tristique. Morbi congue leo sed ipsum fermentum vulputate. Ut nulla eros, porta varius pulvinar eget, bibendum quis dolor. Morbi sed diam eu dui semper ornare nec quis nisl.',
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 			'Fusce semper erat tortor, at pulvinar risus luctus suscipit. Phasellus quis enim nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas semper dapibus odio, nec pellentesque sem laoreet sit amet. Maecenas ut enim tellus. Fusce malesuada mattis sem, porta interdum ex fermentum quis. Ut eget quam mi. In molestie volutpat feugiat. Nulla vel viverra nunc. Integer lobortis nisl vitae placerat egestas. Curabitur tristique nulla at libero blandit, a eleifend augue tempus.',
217 217
 		);
218 218
 
219
-		return $paragraphs[ rand( 0, 9 ) ];
219
+		return $paragraphs[rand(0, 9)];
220 220
 
221 221
 	}
222 222
 
@@ -232,45 +232,45 @@  discard block
 block discarded – undo
232 232
 	 * @param int $post_id Post ID.
233 233
 	 * @return mixed Attachment ID or WP Error.
234 234
 	 */
235
-	public static function image( $post_id ){
235
+	public static function image($post_id) {
236 236
 		$file_array = array();
237 237
 
238 238
 		// Get the image from the API
239 239
 		$url = self::get_image_link();
240 240
 
241 241
 		// If the returned string is empty or it's not a string, try again.
242
-		if ( empty( $url ) || !is_string( $url ) ){
242
+		if (empty($url) || !is_string($url)) {
243 243
 
244 244
 			// Try again
245 245
 			$url = self::get_image_link();
246 246
 
247 247
 			// If it fails again, just give up
248
-			if ( empty( $url ) || !is_string( $url ) ){
248
+			if (empty($url) || !is_string($url)) {
249 249
 				return;
250 250
 			}
251 251
 
252 252
 		}
253 253
 
254 254
 		// Download the file
255
-	    $tmp = \download_url( $url );
255
+	    $tmp = \download_url($url);
256 256
 
257
-	    preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches );
257
+	    preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches);
258 258
 
259
-        $file_array['name'] = basename( $matches[0] );
259
+        $file_array['name'] = basename($matches[0]);
260 260
         $file_array['tmp_name'] = $tmp;
261 261
 
262 262
 	    // Check for download errors
263
-	    if ( is_wp_error( $tmp ) ) {
264
-	        unlink( $file_array[ 'tmp_name' ] );
263
+	    if (is_wp_error($tmp)) {
264
+	        unlink($file_array['tmp_name']);
265 265
 	        return $tmp->get_error_message();
266 266
 	    }
267 267
 
268 268
 		// Pull the image into the media library
269
-	    $image_id = media_handle_sideload( $file_array, $post_id );
269
+	    $image_id = media_handle_sideload($file_array, $post_id);
270 270
 
271 271
 	    // Check for handle sideload errors.
272
-	    if ( is_wp_error( $image_id ) ) {
273
-	        unlink( $file_array['tmp_name'] );
272
+	    if (is_wp_error($image_id)) {
273
+	        unlink($file_array['tmp_name']);
274 274
 	        return $image_id->get_error_message();
275 275
 	    }
276 276
 
@@ -286,31 +286,31 @@  discard block
 block discarded – undo
286 286
 	 *
287 287
 	 * @return string Image URL.
288 288
 	 */
289
-	private static function get_image_link(){
289
+	private static function get_image_link() {
290 290
 
291 291
 		// cURL an image API for a completely random photo
292
-		$curl = curl_init( "http://www.splashbase.co/api/v1/images/random?images_only=true" );
292
+		$curl = curl_init("http://www.splashbase.co/api/v1/images/random?images_only=true");
293 293
 
294
-		curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
294
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
295 295
 
296
-		$curl_response = curl_exec( $curl );
296
+		$curl_response = curl_exec($curl);
297 297
 
298 298
 		// If our cURL failed
299
-		if ( $curl_response === false ) {
300
-		    $info = curl_getinfo( $curl );
301
-		    curl_close( $curl );
302
-		    die( 'error occured during curl exec. Additional info: ' . var_export( $info ) );
299
+		if ($curl_response === false) {
300
+		    $info = curl_getinfo($curl);
301
+		    curl_close($curl);
302
+		    die('error occured during curl exec. Additional info: ' . var_export($info));
303 303
 		}
304 304
 
305
-		curl_close( $curl );
305
+		curl_close($curl);
306 306
 
307 307
 		// Decode the data
308
-		$response = json_decode( $curl_response, true );
308
+		$response = json_decode($curl_response, true);
309 309
 
310 310
 		// Check to make sure that the return contains a valid image extensions
311 311
 		preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $response['url'], $matches);
312 312
 
313
-		if ( !empty( $matches ) ){
313
+		if (!empty($matches)) {
314 314
 			return $response['url'];
315 315
 		}
316 316
 
@@ -325,10 +325,10 @@  discard block
 block discarded – undo
325 325
 	 * @param string $format PHP Date format.
326 326
 	 * @return mixed Date in the format requested.
327 327
 	 */
328
-	public static function date( $format ){
328
+	public static function date($format) {
329 329
 
330
-		$num_days = rand( 1, 60 );
331
-		return date( $format, strtotime( " +$num_days days" ) );
330
+		$num_days = rand(1, 60);
331
+		return date($format, strtotime(" +$num_days days"));
332 332
 
333 333
 	}
334 334
 
@@ -340,19 +340,19 @@  discard block
 block discarded – undo
340 340
 	 *
341 341
 	 * @return string Time string
342 342
 	 */
343
-	public static function time(){
343
+	public static function time() {
344 344
 
345 345
 		$times = array(
346 346
 			'8:00 am',
347 347
 			'5:00PM',
348 348
 			'13:00',
349 349
 			'2015',
350
-			date( 'G:i', strtotime( " +".rand( 4, 24 )." hours" ) ),
351
-			date( 'g:i', strtotime( " +".rand( 4, 24 )." hours" ) ),
352
-			date( 'G:i A', strtotime( " +".rand( 4, 24 )." hours" ) )
350
+			date('G:i', strtotime(" +" . rand(4, 24) . " hours")),
351
+			date('g:i', strtotime(" +" . rand(4, 24) . " hours")),
352
+			date('G:i A', strtotime(" +" . rand(4, 24) . " hours"))
353 353
 		);
354 354
 
355
-		return $times[ rand( 0, 6 ) ];
355
+		return $times[rand(0, 6)];
356 356
 
357 357
 	}
358 358
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	 *
365 365
 	 * @return string Timezone
366 366
 	 */
367
-	public static function timezone(){
367
+	public static function timezone() {
368 368
 
369 369
 		$timezones = array(
370 370
 			'America/Denver',
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 			'UTC'
383 383
 		);
384 384
 
385
-		return $timezones[ rand( 0, 12 ) ];
385
+		return $timezones[rand(0, 12)];
386 386
 
387 387
 	}
388 388
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @return string Phone #.
397 397
 	 */
398
-	public static function phone(){
398
+	public static function phone() {
399 399
 
400 400
 		$phone_numbers = array(
401 401
 			'7203893101',
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 			'+43 780 0047112'
412 412
 		);
413 413
 
414
-		return $phone_numbers[ rand( 0, 10 ) ];
414
+		return $phone_numbers[rand(0, 10)];
415 415
 
416 416
 	}
417 417
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 *
424 424
 	 * @return string Email address.
425 425
 	 */
426
-	public static function email(){
426
+	public static function email() {
427 427
 
428 428
 		$email_addresses = array(
429 429
 			'[email protected]',
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 			'[email protected]'
437 437
 		);
438 438
 
439
-		return $email_addresses[ rand( 0, 7 ) ];
439
+		return $email_addresses[rand(0, 7)];
440 440
 
441 441
 	}
442 442
 
@@ -450,12 +450,12 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @return string URL.
452 452
 	 */
453
-	public static function link(){
453
+	public static function link() {
454 454
 
455 455
 		$links = array(
456 456
 			'http://google.com',
457 457
 			'https://www.twitter.com',
458
-			site_url( '/?iam=anextravariable' ),
458
+			site_url('/?iam=anextravariable'),
459 459
 			'github.com',
460 460
 			'http://filebase.com',
461 461
 			'www.oldtownmediainc.com',
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 			'https://www.eff.org'
464 464
 		);
465 465
 
466
-		return $links[ rand( 0, 7 ) ];
466
+		return $links[rand(0, 7)];
467 467
 
468 468
 	}
469 469
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 	 *
475 475
 	 * @return string URL.
476 476
 	 */
477
-	public static function oembed(){
477
+	public static function oembed() {
478 478
 
479 479
 		$links = array(
480 480
 			'https://www.youtube.com/watch?v=A85-YQsm6pY',
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 			'https://www.instagram.com/p/-eyLo0RMfX',
486 486
 		);
487 487
 
488
-		return $links[ rand( 0, 5 ) ];
488
+		return $links[rand(0, 5)];
489 489
 
490 490
 	}
491 491
 
@@ -499,10 +499,10 @@  discard block
 block discarded – undo
499 499
 	 * @param	string $type Video service to get link from
500 500
 	 * @return	string URL.
501 501
 	 */
502
-	public static function video( $type ){
502
+	public static function video($type) {
503 503
 
504 504
 		// Switch through our video types. Expecting to add more in the future
505
-		switch( $type ){
505
+		switch ($type) {
506 506
 
507 507
 			// YouTube videos
508 508
 			case 'youtube' :
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 
544 544
 		}
545 545
 
546
-		return $links[ rand( 0, 8 ) ];
546
+		return $links[rand(0, 8)];
547 547
 
548 548
 	}
549 549
 
Please login to merge, or discard this patch.
includes/class-create-term.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class CreateTerm{
11
+class CreateTerm {
12 12
 
13 13
 	/**
14 14
 	 * Create test data posts.
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
 	 * @param boolean $echo Whether or not to echo. Optional.
26 26
 	 * @param int $num Optional. Number of posts to create.
27 27
 	 */
28
-	public function create_terms( $slug, $echo = false, $num = '' ){
28
+	public function create_terms($slug, $echo = false, $num = '') {
29 29
 
30 30
 		// If we're missing a custom post type id - don't do anything
31
-		if ( empty( $slug ) ){
31
+		if (empty($slug)) {
32 32
 			return;
33 33
 		}
34 34
 
35 35
 		// If we forgot to put in a quantity, make one for us
36
-		if ( empty( $num ) ){
37
-			$num = rand( 5, 30 );
36
+		if (empty($num)) {
37
+			$num = rand(5, 30);
38 38
 		}
39 39
 
40 40
 		// Create test terms
41
-		for( $i = 0; $i < $num; $i++ ){
41
+		for ($i = 0; $i < $num; $i++) {
42 42
 
43
-			$return = $this->create_test_object( $slug );
43
+			$return = $this->create_test_object($slug);
44 44
 
45
-			if ( $echo === true ){
46
-				echo \json_encode( $return );
45
+			if ($echo === true) {
46
+				echo \json_encode($return);
47 47
 			}
48 48
 
49 49
 		}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @param string $slug a custom post type ID.
66 66
 	 */
67
-	private function create_test_object( $slug ){
67
+	private function create_test_object($slug) {
68 68
 
69 69
 		// Get a random title
70 70
 		$title = TestContent::title();
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
 			$slug,
75 75
 			array(
76 76
 				'description'=> TestContent::title(),
77
-				'slug' => sanitize_title( $title ),
77
+				'slug' => sanitize_title($title),
78 78
 			)
79 79
 		);
80 80
 
81 81
 		// Then, set a test content flag on the new post for later deletion
82
-		add_term_meta( $return['term_id'], 'evans_test_content', '__test__', true );
82
+		add_term_meta($return['term_id'], 'evans_test_content', '__test__', true);
83 83
 
84 84
 		// Check if we have errors and return them or created message
85
-		if ( is_wp_error( $return ) ){
85
+		if (is_wp_error($return)) {
86 86
 			return $return;
87 87
 		} else {
88 88
 			return array(
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 				'object'	=> 'term',
91 91
 				'tid'		=> $return['term_id'],
92 92
 				'taxonomy'	=> $slug,
93
-				'link_edit'	=> admin_url( '/edit-tags.php?action=edit&taxonomy='.$slug.'&tag_ID='.$return['term_id'] ),
94
-				'link_view'	=> get_term_link( $return['term_id'] )
93
+				'link_edit'	=> admin_url('/edit-tags.php?action=edit&taxonomy=' . $slug . '&tag_ID=' . $return['term_id']),
94
+				'link_view'	=> get_term_link($return['term_id'])
95 95
 			);
96 96
 		}
97 97
 
Please login to merge, or discard this patch.
test-content.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
  */
22 22
 foreach ( $dirs as $dir ){
23 23
 	foreach ( glob( plugin_dir_path( __FILE__ ) . "/$dir/*.php", GLOB_NOSORT ) as $filename ){
24
-	    require_once $filename;
24
+		require_once $filename;
25 25
 	}
26 26
 }
27 27
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@
 block discarded – undo
19 19
 /*
20 20
  * Loop through our directory array and require any PHP files without individual calls.
21 21
  */
22
-foreach ( $dirs as $dir ){
23
-	foreach ( glob( plugin_dir_path( __FILE__ ) . "/$dir/*.php", GLOB_NOSORT ) as $filename ){
22
+foreach ($dirs as $dir) {
23
+	foreach (glob(plugin_dir_path(__FILE__) . "/$dir/*.php", GLOB_NOSORT) as $filename) {
24 24
 	    require_once $filename;
25 25
 	}
26 26
 }
27 27
 
28 28
 $admin_page = new testContent\AdminPage;
29
-$admin_page->hooks( __FILE__ );
30 29
\ No newline at end of file
30
+$admin_page->hooks(__FILE__);
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-create-post.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class CreatePost{
11
+class CreatePost {
12 12
 
13 13
 	/**
14 14
 	 * Create test data posts.
@@ -25,29 +25,29 @@  discard block
 block discarded – undo
25 25
 	 * @param boolean $echo Whether or not to echo. Optional.
26 26
 	 * @param int $num Optional. Number of posts to create.
27 27
 	 */
28
-	public function create_post_type_content( $slug, $echo = false, $num = '' ){
28
+	public function create_post_type_content($slug, $echo = false, $num = '') {
29 29
 
30 30
 		// If we're missing a custom post type id - don't do anything
31
-		if ( empty( $slug ) ){
31
+		if (empty($slug)) {
32 32
 			return;
33 33
 		}
34 34
 
35 35
 		// Gather the necessary data to create the posts
36
-		$supports 	= $this->get_cpt_supports( $slug );
37
-		$metaboxes	= $this->get_metaboxes( $slug );
36
+		$supports 	= $this->get_cpt_supports($slug);
37
+		$metaboxes	= $this->get_metaboxes($slug);
38 38
 
39 39
 		// If we forgot to put in a quantity, make one for us
40
-		if ( empty( $num ) ){
41
-			$num = rand( 5, 30 );
40
+		if (empty($num)) {
41
+			$num = rand(5, 30);
42 42
 		}
43 43
 
44 44
 		// Create test posts
45
-		for( $i = 0; $i < $num; $i++ ){
45
+		for ($i = 0; $i < $num; $i++) {
46 46
 
47
-			$return = $this->create_test_object( $slug, $supports, $metaboxes );
47
+			$return = $this->create_test_object($slug, $supports, $metaboxes);
48 48
 
49
-			if ( $echo === true ){
50
-				echo \json_encode( $return );
49
+			if ($echo === true) {
50
+				echo \json_encode($return);
51 51
 			}
52 52
 
53 53
 		}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * @param array $supports Features that the post type supports.
71 71
 	 * @param array $supports All CMB2 metaboxes attached to the post type.
72 72
 	 */
73
-	private function create_test_object( $slug, $supports, $metaboxes ){
73
+	private function create_test_object($slug, $supports, $metaboxes) {
74 74
 		$return = '';
75 75
 
76 76
 		// Get a random title
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		// First, insert our post
80 80
 		$post = array(
81
-		  'post_name'      => sanitize_title( $title ),
81
+		  'post_name'      => sanitize_title($title),
82 82
 		  'post_status'    => 'publish',
83 83
 		  'post_type'      => $slug,
84 84
 		  'ping_status'    => 'closed',
@@ -86,51 +86,51 @@  discard block
 block discarded – undo
86 86
 		);
87 87
 
88 88
 		// Add title if supported
89
-		if ( $supports['title'] === true ){
89
+		if ($supports['title'] === true) {
90 90
 			$post['post_title'] = $title;
91 91
 		}
92 92
 
93 93
 		// Add main content if supported
94
-		if ( $supports['editor'] === true ){
94
+		if ($supports['editor'] === true) {
95 95
 			$post['post_content'] = TestContent::paragraphs();
96 96
 		}
97 97
 
98 98
 		// Insert then post object
99
-		$post_id = wp_insert_post( $post );
99
+		$post_id = wp_insert_post($post);
100 100
 
101 101
 		// Then, set a test content flag on the new post for later deletion
102
-		add_post_meta( $post_id, 'evans_test_content', '__test__', true );
102
+		add_post_meta($post_id, 'evans_test_content', '__test__', true);
103 103
 
104 104
 		// Add thumbnail if supported
105
-		if ( $supports['thumbnail'] === true || in_array( $slug, array( 'post', 'page' ) ) ){
106
-			 update_post_meta( $post_id, '_thumbnail_id', TestContent::image( $post_id ) );
105
+		if ($supports['thumbnail'] === true || in_array($slug, array('post', 'page'))) {
106
+			 update_post_meta($post_id, '_thumbnail_id', TestContent::image($post_id));
107 107
 		}
108 108
 
109
-		$taxonomies = get_object_taxonomies( $slug );
109
+		$taxonomies = get_object_taxonomies($slug);
110 110
 
111 111
 		// Assign the post to terms
112
-		if ( !empty( $taxonomies ) ){
113
-			$return .= $this->assign_terms( $post_id, $taxonomies );
112
+		if (!empty($taxonomies)) {
113
+			$return .= $this->assign_terms($post_id, $taxonomies);
114 114
 		}
115 115
 
116 116
 		// Spin up metaboxes
117
-		if ( !empty( $metaboxes ) ){
118
-			foreach ( $metaboxes as $cmb ) :
119
-				$return .= $this->random_metabox_content( $post_id, $cmb );
117
+		if (!empty($metaboxes)) {
118
+			foreach ($metaboxes as $cmb) :
119
+				$return .= $this->random_metabox_content($post_id, $cmb);
120 120
 			endforeach;
121 121
 		}
122 122
 
123 123
 		// Check if we have errors and return them or created message
124
-		if ( is_wp_error( $return ) ){
124
+		if (is_wp_error($return)) {
125 125
 			return $return;
126 126
 		} else {
127 127
 			return array(
128 128
 				'type'		=> 'created',
129 129
 				'object'	=> 'post',
130 130
 				'pid'		=> $post_id,
131
-				'post_type'	=> get_post_type( $post_id ),
132
-				'link_edit'	=> admin_url( '/post.php?post='.$post_id.'&action=edit' ),
133
-				'link_view'	=> get_permalink( $post_id ),
131
+				'post_type'	=> get_post_type($post_id),
132
+				'link_edit'	=> admin_url('/post.php?post=' . $post_id . '&action=edit'),
133
+				'link_view'	=> get_permalink($post_id),
134 134
 			);
135 135
 		}
136 136
 
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
 	 * @param string $slug a custom post type ID.
148 148
 	 * @return array Array of necessary supports booleans.
149 149
 	 */
150
-	private function get_cpt_supports( $slug ){
150
+	private function get_cpt_supports($slug) {
151 151
 
152 152
 		$supports = array(
153
-			'title'		=> post_type_supports( $slug, 'title' ),
154
-			'editor'	=> post_type_supports( $slug, 'editor' ),
155
-			'thumbnail'	=> post_type_supports( $slug, 'thumbnail' )
153
+			'title'		=> post_type_supports($slug, 'title'),
154
+			'editor'	=> post_type_supports($slug, 'editor'),
155
+			'thumbnail'	=> post_type_supports($slug, 'thumbnail')
156 156
 		);
157 157
 
158 158
 		return $supports;
@@ -173,26 +173,26 @@  discard block
 block discarded – undo
173 173
 	 * @param array $taxonomies taxonomies assigned to this cpt.
174 174
 	 * @return object WP Error if there is one.
175 175
 	 */
176
-	private function assign_terms( $post_id, $taxonomies ){
176
+	private function assign_terms($post_id, $taxonomies) {
177 177
 
178 178
 		// Make sure it's an array & has items
179
-		if ( empty( $taxonomies ) || !is_array( $taxonomies ) ){
179
+		if (empty($taxonomies) || !is_array($taxonomies)) {
180 180
 			return;
181 181
 		}
182 182
 
183
-		foreach ( $taxonomies as $tax ){
183
+		foreach ($taxonomies as $tax) {
184 184
 
185 185
 			// Get the individual terms already existing
186
-			$terms = get_terms( $tax, array( 'hide_empty'	=> false ) );
187
-			$count = count( $terms ) - 1;
186
+			$terms = get_terms($tax, array('hide_empty'	=> false));
187
+			$count = count($terms) - 1;
188 188
 
189 189
 			// If there are no terms, skip to the next taxonomy
190
-			if ( empty( $terms ) ){
190
+			if (empty($terms)) {
191 191
 				continue;
192 192
 			}
193 193
 
194 194
 			// Get a random index to use
195
-			$index = rand( 0, $count );
195
+			$index = rand(0, $count);
196 196
 
197 197
 			// Initialize our array
198 198
 			$post_data = array(
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 			);
201 201
 
202 202
 			// Set the term data to update
203
-			$post_data['tax_input'][ $tax ] = array( $terms[$index]->term_id );
203
+			$post_data['tax_input'][$tax] = array($terms[$index]->term_id);
204 204
 
205 205
 			// Update the post with the taxonomy info
206
-			$return = wp_update_post( $post_data );
206
+			$return = wp_update_post($post_data);
207 207
 
208 208
 			// Return the error if it exists
209
-			if ( is_wp_error( $return ) ){
209
+			if (is_wp_error($return)) {
210 210
 				return $return->get_error_messages();
211 211
 			}
212 212
 
@@ -229,18 +229,18 @@  discard block
 block discarded – undo
229 229
 	 * @param string $slug Post Type slug ID.
230 230
 	 * @return array Fields to fill in for our post object.
231 231
 	 */
232
-	private function get_metaboxes( $slug ){
232
+	private function get_metaboxes($slug) {
233 233
 
234 234
 		$fields = array();
235 235
 
236 236
 		// CMB2
237
-		if ( class_exists( 'CMB2', false ) ) {
238
-			$fields = $this->get_cmb2_metaboxes( $slug );
237
+		if (class_exists('CMB2', false)) {
238
+			$fields = $this->get_cmb2_metaboxes($slug);
239 239
 		}
240 240
 
241 241
 		// Custom Metaboxes and Fields (CMB1)
242
-		if ( class_exists( 'cmb_Meta_Box', false ) ) {
243
-			$fields = $this->get_cmb1_metaboxes( $slug );
242
+		if (class_exists('cmb_Meta_Box', false)) {
243
+			$fields = $this->get_cmb1_metaboxes($slug);
244 244
 		}
245 245
 
246 246
 		// Return our array
@@ -263,25 +263,25 @@  discard block
 block discarded – undo
263 263
 	 * @param string $slug a custom post type ID.
264 264
 	 * @return array Array of fields.
265 265
 	 */
266
-	private function get_cmb2_metaboxes( $slug ){
266
+	private function get_cmb2_metaboxes($slug) {
267 267
 
268 268
 		$fields = array();
269 269
 
270 270
 		// Get all metaboxes from CMB2 library
271
-		$all_metaboxes = apply_filters( 'cmb2_meta_boxes', array() );
271
+		$all_metaboxes = apply_filters('cmb2_meta_boxes', array());
272 272
 
273 273
 		// Loop through all possible sets of metaboxes
274
-		foreach ( $all_metaboxes as $metabox_array ){
274
+		foreach ($all_metaboxes as $metabox_array) {
275 275
 
276 276
 			// If the custom post type ID matches this set of fields, set & stop
277
-			if ( in_array( $slug, $metabox_array['object_types'] ) ) {
277
+			if (in_array($slug, $metabox_array['object_types'])) {
278 278
 
279 279
 				// If this is the first group of fields, simply set the value
280 280
 				// Else, merge this group with the previous one
281
-				if ( empty( $fields ) ){
281
+				if (empty($fields)) {
282 282
 					$fields = $metabox_array['fields'];
283 283
 				} else {
284
-					$fields = array_merge( $fields, $metabox_array['fields'] );
284
+					$fields = array_merge($fields, $metabox_array['fields']);
285 285
 				}
286 286
 			}
287 287
 
@@ -306,25 +306,25 @@  discard block
 block discarded – undo
306 306
 	 * @param string $slug a custom post type ID.
307 307
 	 * @return array Array of fields.
308 308
 	 */
309
-	private function get_cmb1_metaboxes( $slug ){
309
+	private function get_cmb1_metaboxes($slug) {
310 310
 
311 311
 		$fields = array();
312 312
 
313 313
 		// Get all metaboxes from CMB2 library
314
-		$all_metaboxes = apply_filters( 'cmb_meta_boxes', array() );
314
+		$all_metaboxes = apply_filters('cmb_meta_boxes', array());
315 315
 
316 316
 		// Loop through all possible sets of metaboxes
317
-		foreach ( $all_metaboxes as $metabox_array ){
317
+		foreach ($all_metaboxes as $metabox_array) {
318 318
 
319 319
 			// If the custom post type ID matches this set of fields, set & stop
320
-			if ( in_array( $slug, $metabox_array['pages'] ) ) {
320
+			if (in_array($slug, $metabox_array['pages'])) {
321 321
 
322 322
 				// If this is the first group of fields, simply set the value
323 323
 				// Else, merge this group with the previous one
324
-				if ( empty( $fields ) ){
324
+				if (empty($fields)) {
325 325
 					$fields = $metabox_array['fields'];
326 326
 				} else {
327
-					$fields = array_merge( $fields, $metabox_array['fields'] );
327
+					$fields = array_merge($fields, $metabox_array['fields']);
328 328
 				}
329 329
 			}
330 330
 
@@ -349,36 +349,36 @@  discard block
 block discarded – undo
349 349
 	 * @param int $post_id Single post ID.
350 350
 	 * @param array $cmb custom metabox array from CMB2.
351 351
 	 */
352
-	private function random_metabox_content( $post_id, $cmb ){
352
+	private function random_metabox_content($post_id, $cmb) {
353 353
 		$value = '';
354 354
 
355 355
 		// First check that our post ID & cmb array aren't empty
356
-		if ( empty( $cmb ) || empty( $post_id ) ){
356
+		if (empty($cmb) || empty($post_id)) {
357 357
 			return;
358 358
 		}
359 359
 
360 360
 		// Fetch the appropriate type of data and return
361
-		switch( $cmb['type'] ){
361
+		switch ($cmb['type']) {
362 362
 
363 363
 			case 'text':
364 364
 			case 'text_small':
365 365
 			case 'text_medium':
366 366
 
367 367
 				// If phone is in the id, fetch a phone #
368
-				if ( stripos( $cmb['id'], 'phone' ) ){
368
+				if (stripos($cmb['id'], 'phone')) {
369 369
 					$value = TestContent::phone();
370 370
 
371 371
 				// If email is in the id, fetch an email address
372
-				} elseif ( stripos( $cmb['id'], 'email' ) ){
372
+				} elseif (stripos($cmb['id'], 'email')) {
373 373
 					$value = TestContent::email();
374 374
 
375 375
 				// If time is in the id, fetch a time string
376
-				} elseif ( stripos( $cmb['id'], 'time' ) ){
376
+				} elseif (stripos($cmb['id'], 'time')) {
377 377
 					$value = TestContent::time();
378 378
 
379 379
 				// Otherwise, just a random text string
380 380
 				} else {
381
-					$value = TestContent::title( rand( 10, 50 ) );
381
+					$value = TestContent::title(rand(10, 50));
382 382
 				}
383 383
 
384 384
 				break;
@@ -405,14 +405,14 @@  discard block
 block discarded – undo
405 405
 
406 406
 			case 'text_date':
407 407
 
408
-				$value = TestContent::date( 'm/d/Y' );
408
+				$value = TestContent::date('m/d/Y');
409 409
 
410 410
 				break;
411 411
 
412 412
 			case 'text_date_timestamp':
413 413
 			case 'text_datetime_timestamp':
414 414
 
415
-				$value = TestContent::date( 'U' );
415
+				$value = TestContent::date('U');
416 416
 
417 417
 				break;
418 418
 
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 
421 421
 			case 'text_money':
422 422
 
423
-				$value = rand( 0, 100000 );
423
+				$value = rand(0, 100000);
424 424
 
425 425
 				break;
426 426
 
427 427
 			case 'test_colorpicker':
428 428
 
429
-				$value = '#' . str_pad( dechex( mt_rand( 0, 0xFFFFFF ) ), 6, '0', STR_PAD_LEFT );
429
+				$value = '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
430 430
 
431 431
 				break;
432 432
 
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 			case 'radio':
444 444
 
445 445
 				// Grab a random item out of the array and return the key
446
-				$new_val = array_slice( $cmb['options'], rand( 0, count( $cmb['options'] ) ), 1 );
447
-				$value = key( $new_val );
446
+				$new_val = array_slice($cmb['options'], rand(0, count($cmb['options'])), 1);
447
+				$value = key($new_val);
448 448
 
449 449
 				break;
450 450
 
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 			case 'checkbox':
456 456
 
457 457
 				// 50/50 odds of being turned on
458
-				if ( rand( 0, 1 ) == 1 ){
458
+				if (rand(0, 1) == 1) {
459 459
 					$value = 'on';
460 460
 				}
461 461
 
@@ -466,10 +466,10 @@  discard block
 block discarded – undo
466 466
 				$new_option = array();
467 467
 
468 468
 				// Loop through each of our options
469
-				foreach ( $cmb['options'] as $key => $value ){
469
+				foreach ($cmb['options'] as $key => $value) {
470 470
 
471 471
 					// 50/50 chance of being included
472
-					if ( rand( 0, 1 ) ){
472
+					if (rand(0, 1)) {
473 473
 						$new_option[] = $key;
474 474
 					}
475 475
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 
488 488
 			case 'file':
489 489
 
490
-				$value = TestContent::image( $post_id );
490
+				$value = TestContent::image($post_id);
491 491
 
492 492
 				break;
493 493
 
@@ -502,19 +502,19 @@  discard block
 block discarded – undo
502 502
 		}
503 503
 
504 504
 		// Value must exist to attempt to insert
505
-		if ( !empty( $value ) && !is_wp_error( $value ) ){
505
+		if (!empty($value) && !is_wp_error($value)) {
506 506
 
507 507
 			// Files must be treated separately - they use the attachment ID
508 508
 			// & url of media for separate cmb values
509
-			if ( $cmb['type'] != 'file' ){
510
-				add_post_meta( $post_id, $cmb['id'], $value, true );
509
+			if ($cmb['type'] != 'file') {
510
+				add_post_meta($post_id, $cmb['id'], $value, true);
511 511
 			} else {
512
-				add_post_meta( $post_id, $cmb['id'].'_id', $value, true );
513
-				add_post_meta( $post_id, $cmb['id'], wp_get_attachment_url( $value ), true );
512
+				add_post_meta($post_id, $cmb['id'] . '_id', $value, true);
513
+				add_post_meta($post_id, $cmb['id'], wp_get_attachment_url($value), true);
514 514
 			}
515 515
 
516 516
 		// If we're dealing with a WP Error object, just return the message for debugging
517
-		} elseif ( is_wp_error( $value ) ){
517
+		} elseif (is_wp_error($value)) {
518 518
 			return $value->get_error_message();
519 519
 		}
520 520
 
Please login to merge, or discard this patch.
includes/class-delete.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -133,14 +133,14 @@
 block discarded – undo
133 133
 
134 134
 		// Query for our terms
135 135
 		$args = array(
136
-		    'hide_empty' => false,
137
-		    'meta_query' => array(
138
-		        array(
139
-		           'key'       => 'evans_test_content',
140
-		           'value'     => '__test__',
141
-		           'compare'   => '='
142
-		        )
143
-		    )
136
+			'hide_empty' => false,
137
+			'meta_query' => array(
138
+				array(
139
+				   'key'       => 'evans_test_content',
140
+				   'value'     => '__test__',
141
+				   'compare'   => '='
142
+				)
143
+			)
144 144
 		);
145 145
 
146 146
 		$terms = get_terms( $slug, $args );
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class Delete{
11
+class Delete {
12 12
 
13 13
 	/**
14 14
 	 * Delete test data posts.
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param string $slug a custom post type ID.
25 25
 	 */
26
-	public function delete_posts( $slug, $echo = false ){
26
+	public function delete_posts($slug, $echo = false) {
27 27
 
28 28
 		// Check that $cptslg has a string.
29 29
 		// Also make sure that the current user is logged in & has full permissions.
30
-		if ( empty( $slug ) || !is_user_logged_in() || !current_user_can( 'delete_posts' ) ){
30
+		if (empty($slug) || !is_user_logged_in() || !current_user_can('delete_posts')) {
31 31
 			return;
32 32
 		}
33 33
 
@@ -44,39 +44,39 @@  discard block
 block discarded – undo
44 44
 			),
45 45
 		);
46 46
 
47
-		$objects = new \WP_Query( $query );
47
+		$objects = new \WP_Query($query);
48 48
 
49
-		if ( $objects->have_posts() ){
49
+		if ($objects->have_posts()) {
50 50
 
51 51
 			$events = array();
52 52
 
53
-			while ( $objects->have_posts() ) : $objects->the_post();
53
+			while ($objects->have_posts()) : $objects->the_post();
54 54
 
55 55
 				// Find any media associated with the test post and delete it as well
56
-				$this->delete_associated_media( get_the_id() );
56
+				$this->delete_associated_media(get_the_id());
57 57
 
58
-				if ( $echo === true ){
58
+				if ($echo === true) {
59 59
 					$events[] = array(
60 60
 						'type'		=> 'deleted',
61 61
 						'pid'		=> get_the_id(),
62
-						'post_type'	=> get_post_type( get_the_id() ),
62
+						'post_type'	=> get_post_type(get_the_id()),
63 63
 						'link'		=> ''
64 64
 					);
65 65
 				}
66 66
 
67 67
 				// Force delete the post
68
-				wp_delete_post( get_the_id(), true );
68
+				wp_delete_post(get_the_id(), true);
69 69
 
70 70
 			endwhile;
71 71
 
72
-			$obj = get_post_type_object( $slug );
72
+			$obj = get_post_type_object($slug);
73 73
 
74 74
 			$events[] = array(
75 75
 				'type'		=> 'general',
76 76
 				'message'	=> 'Deleted ' . $obj->labels->all_items
77 77
 			);
78 78
 
79
-			echo \json_encode( $events );
79
+			echo \json_encode($events);
80 80
 
81 81
 		}
82 82
 
@@ -96,20 +96,20 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @param int $pid a custom post type ID.
98 98
 	 */
99
-	private function delete_associated_media( $pid ){
99
+	private function delete_associated_media($pid) {
100 100
 
101
-		if ( !is_int( $pid ) ){
101
+		if (!is_int($pid)) {
102 102
 			return;
103 103
 		}
104 104
 
105 105
 		// Get our images
106
-		$media = get_attached_media( 'image', $pid );
106
+		$media = get_attached_media('image', $pid);
107 107
 
108
-		if ( !empty( $media ) ){
108
+		if (!empty($media)) {
109 109
 
110 110
 			// Loop through the media & delete each one
111
-			foreach ( $media as $attachment ){
112
-				wp_delete_attachment( $attachment->ID, true );
111
+			foreach ($media as $attachment) {
112
+				wp_delete_attachment($attachment->ID, true);
113 113
 			}
114 114
 
115 115
 		}
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @param string $slug a custom post type ID.
131 131
 	 */
132
-	public function delete_terms( $slug, $echo = false ){
132
+	public function delete_terms($slug, $echo = false) {
133 133
 
134 134
 		// Query for our terms
135 135
 		$args = array(
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
 		    )
144 144
 		);
145 145
 
146
-		$terms = get_terms( $slug, $args );
146
+		$terms = get_terms($slug, $args);
147 147
 
148
-		if ( !empty( $terms ) ){
148
+		if (!empty($terms)) {
149 149
 
150 150
 			$events = array();
151 151
 
152
-			foreach ( $terms as $term ){
152
+			foreach ($terms as $term) {
153 153
 
154
-				if ( $echo === true ){
154
+				if ($echo === true) {
155 155
 					$events[] = array(
156 156
 						'type'		=> 'deleted',
157 157
 						'pid'		=> $term->term_id,
@@ -161,18 +161,18 @@  discard block
 block discarded – undo
161 161
 				}
162 162
 
163 163
 				// Delete our term
164
-				wp_delete_term( $term->term_id, $slug );
164
+				wp_delete_term($term->term_id, $slug);
165 165
 
166 166
 			}
167 167
 
168
-			$taxonomy = get_taxonomy( $slug );
168
+			$taxonomy = get_taxonomy($slug);
169 169
 
170 170
 			$events[] = array(
171 171
 				'type'		=> 'general',
172 172
 				'message'	=> 'Deleted ' . $taxonomy->labels->name
173 173
 			);
174 174
 
175
-			echo \json_encode( $events );
175
+			echo \json_encode($events);
176 176
 
177 177
 		}
178 178
 
Please login to merge, or discard this patch.
includes/class-admin-page.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -89,8 +89,8 @@
 block discarded – undo
89 89
 		} else {
90 90
 			// We didn't get a reponse so print the notice out
91 91
 			echo '<div class="notice notice-error is-dismissible">';
92
-		        echo '<p>'.__( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content' ).'</p>';
93
-		    echo '</div>';
92
+				echo '<p>'.__( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content' ).'</p>';
93
+			echo '</div>';
94 94
 		}
95 95
 
96 96
 	}
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage Evans
9 9
  * @author     Old Town Media
10 10
  */
11
-class AdminPage{
11
+class AdminPage {
12 12
 
13 13
 	/**
14 14
 	 * Hooks function.
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @see admin_menu, wp_ajax actions
19 19
 	 */
20
-	public function hooks( $file ){
20
+	public function hooks($file) {
21 21
 
22
-		add_action( 'admin_menu' , array( $this, 'add_menu_item' ) );
23
-		add_action( 'wp_ajax_handle_test_data', array( $this, 'handle_test_data_callback' ) );
24
-		add_filter( 'plugin_action_links_' . plugin_basename( $file ) , array( $this, 'add_settings_link' ) );
25
-		add_action( 'admin_notices', array( $this, 'internet_connected_admin_notice' ) );
22
+		add_action('admin_menu', array($this, 'add_menu_item'));
23
+		add_action('wp_ajax_handle_test_data', array($this, 'handle_test_data_callback'));
24
+		add_filter('plugin_action_links_' . plugin_basename($file), array($this, 'add_settings_link'));
25
+		add_action('admin_notices', array($this, 'internet_connected_admin_notice'));
26 26
 
27 27
 	}
28 28
 
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 
37 37
 		$page = add_submenu_page(
38 38
 			'tools.php',
39
-			__( 'Create Test Content', 'otm-test-content' ),
40
-			__( 'Test Content', 'otm-test-content' ),
39
+			__('Create Test Content', 'otm-test-content'),
40
+			__('Test Content', 'otm-test-content'),
41 41
 			'manage_options',
42 42
 			'create-test-data',
43
-			array( $this, 'admin_page' )
43
+			array($this, 'admin_page')
44 44
 		);
45 45
 
46
-		add_action( 'admin_print_styles-' . $page, array( $this, 'load_scripts' ) );
46
+		add_action('admin_print_styles-' . $page, array($this, 'load_scripts'));
47 47
 
48 48
 	}
49 49
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 * @param  array $links Existing links
54 54
 	 * @return array 		Modified links
55 55
 	 */
56
-	public function add_settings_link( $links ) {
56
+	public function add_settings_link($links) {
57 57
 
58
-		$settings_link = '<a href="tools.php?page=create-test-data">' . __( 'Build Test Content', 'otm-test-content' ) . '</a>';
59
-  		array_push( $links, $settings_link );
58
+		$settings_link = '<a href="tools.php?page=create-test-data">' . __('Build Test Content', 'otm-test-content') . '</a>';
59
+  		array_push($links, $settings_link);
60 60
   		return $links;
61 61
 
62 62
 	}
@@ -69,28 +69,28 @@  discard block
 block discarded – undo
69 69
 	 * Internet, and the test fails displays a notice informing the user that
70 70
 	 * images will not pull into test data.
71 71
 	 */
72
-	public function internet_connected_admin_notice(){
72
+	public function internet_connected_admin_notice() {
73 73
 
74 74
 		// Get the current admin screen & verify that we're on the right one
75 75
 		// before continuing.
76 76
 		$screen = get_current_screen();
77 77
 
78
-		if ( $screen->base != 'tools_page_create-test-data' ){
78
+		if ($screen->base != 'tools_page_create-test-data') {
79 79
 			return;
80 80
 		}
81 81
 
82 82
 		// Define our test point and try to reach out to the URL
83 83
 		$test_url = 'http://www.splashbase.co/api/v1/images/';
84
-		$response = wp_remote_get( $test_url );
84
+		$response = wp_remote_get($test_url);
85 85
 
86 86
 		// Check the response
87
-		if ( is_array( $response ) ) {
87
+		if (is_array($response)) {
88 88
 			// We got a response so early return
89 89
 			return;
90 90
 		} else {
91 91
 			// We didn't get a reponse so print the notice out
92 92
 			echo '<div class="notice notice-error is-dismissible">';
93
-		        echo '<p>'.__( 'WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content' ).'</p>';
93
+		        echo '<p>' . __('WordPress could not connect to Splashbase and therefore images will not pull into metaboxes/thumbnails. Turn Airplane Mode off or reconnect to the Internet to get images when creating test data.', 'otm-test-content') . '</p>';
94 94
 		    echo '</div>';
95 95
 		}
96 96
 
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
 	/**
101 101
 	 * Load our script in the admin section and serve in data.
102 102
 	 */
103
-	public function load_scripts(){
103
+	public function load_scripts() {
104 104
 
105
-		wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) );
106
-		wp_enqueue_style( 'test-content-css', plugins_url( 'assets/admin.css' , dirname( __FILE__ ) ) );
105
+		wp_enqueue_script('test-content-js', plugins_url('assets/admin.js', dirname(__FILE__)));
106
+		wp_enqueue_style('test-content-css', plugins_url('assets/admin.css', dirname(__FILE__)));
107 107
 
108 108
 		$data = array(
109
-			'nonce'	=> wp_create_nonce( 'handle-test-data' )
109
+			'nonce'	=> wp_create_nonce('handle-test-data')
110 110
 		);
111 111
 
112
-		wp_localize_script( 'test-content-js', 'test_content', $data );
112
+		wp_localize_script('test-content-js', 'test_content', $data);
113 113
 
114 114
 	}
115 115
 
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function handle_test_data_callback() {
123 123
 
124
-		$action		= $_REQUEST['todo'];
125
-		$nonce		= $_REQUEST['nonce'];
124
+		$action = $_REQUEST['todo'];
125
+		$nonce = $_REQUEST['nonce'];
126 126
 
127 127
 		// Verify that we have a proper logged in user and it's the right person
128
-		if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'handle-test-data' ) ){
128
+		if (empty($nonce) || !wp_verify_nonce($nonce, 'handle-test-data')) {
129 129
 			return;
130 130
 		}
131 131
 
132
-		if ( $action == 'delete' ){
132
+		if ($action == 'delete') {
133 133
 
134
-			$this->deletion_routing( $_REQUEST );
134
+			$this->deletion_routing($_REQUEST);
135 135
 
136
-		} elseif ( $action == 'create' ){
136
+		} elseif ($action == 'create') {
137 137
 
138
-			$this->creation_routing( $_REQUEST );
138
+			$this->creation_routing($_REQUEST);
139 139
 
140 140
 		}
141 141
 
@@ -148,17 +148,17 @@  discard block
 block discarded – undo
148 148
 	 * Choose which type of creation needs to be accomplished and route through
149 149
 	 * the correct class.
150 150
 	 */
151
-	private function creation_routing( $data ){
151
+	private function creation_routing($data) {
152 152
 
153
-		if ( $data['type'] == 'post' ){
153
+		if ($data['type'] == 'post') {
154 154
 
155 155
 			$create_content = new CreatePost;
156
-			$create_content->create_post_type_content( $data['slug'], true, 1 );
156
+			$create_content->create_post_type_content($data['slug'], true, 1);
157 157
 
158
-		} elseif( $data['type'] == 'term' ){
158
+		} elseif ($data['type'] == 'term') {
159 159
 
160 160
 			$create_content = new CreateTerm;
161
-			$create_content->create_terms( $data['slug'], true, 1 );
161
+			$create_content->create_terms($data['slug'], true, 1);
162 162
 
163 163
 		}
164 164
 
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
 	 * Choose which type of deletion needs to be accomplished and route through
170 170
 	 * the correct method of Delete.
171 171
 	 */
172
-	private function deletion_routing( $data ){
172
+	private function deletion_routing($data) {
173 173
 
174 174
 		$delete_content = new Delete;
175 175
 
176
-		if ( $data['type'] == 'post' ){
176
+		if ($data['type'] == 'post') {
177 177
 
178
-			$delete_content->delete_posts( $data['slug'], true );
178
+			$delete_content->delete_posts($data['slug'], true);
179 179
 
180
-		} elseif ( $data['type'] == 'term' ){
180
+		} elseif ($data['type'] == 'term') {
181 181
 
182
-			$delete_content->delete_terms( $data['slug'], true );
182
+			$delete_content->delete_terms($data['slug'], true);
183 183
 
184 184
 		}
185 185
 
@@ -189,16 +189,16 @@  discard block
 block discarded – undo
189 189
 	/**
190 190
 	 * Print out our admin page to control test data.
191 191
 	 */
192
-	public function admin_page(){
192
+	public function admin_page() {
193 193
 
194 194
 		$html = "";
195 195
 
196 196
 		$html .= '<div class="wrap" id="options_editor">' . "\n";
197 197
 
198
-			$html .= '<h2>' . __( 'Create Test Data' , 'otm-test-content' ) . '</h2>' . "\n";
198
+			$html .= '<h2>' . __('Create Test Data', 'otm-test-content') . '</h2>' . "\n";
199 199
 
200 200
 			// Loop through all other cpts
201
-			$post_types = get_post_types( array( 'public' => true ), 'objects' );
201
+			$post_types = get_post_types(array('public' => true), 'objects');
202 202
 
203 203
 			$html .= "<div>";
204 204
 
@@ -210,14 +210,14 @@  discard block
 block discarded – undo
210 210
 			$html .= "</div>";
211 211
 
212 212
 			// Loop through every post type available on the site
213
-			foreach ( $post_types as $post_type ) {
213
+			foreach ($post_types as $post_type) {
214 214
 
215 215
 				$skipped_cpts = array(
216 216
 					'attachment'
217 217
 				);
218 218
 
219 219
 				// Skip banned cpts
220
-				if ( in_array( $post_type->name, $skipped_cpts ) ){
220
+				if (in_array($post_type->name, $skipped_cpts)) {
221 221
 					continue;
222 222
 				}
223 223
 
@@ -227,17 +227,17 @@  discard block
 block discarded – undo
227 227
 					$html .= "<h3>";
228 228
 
229 229
 						$html .= "<span class='label'>" . $post_type->labels->name . "</span>";
230
-						$html .= " <a href='javascript:void(0);' data-type='post' data-slug='".$post_type->name."' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-plus'></span> ".__( 'Create Test Data', 'otm-test-content' )."</a>";
231
-						$html .= " <a href='javascript:void(0);' data-type='post' data-slug='".$post_type->name."' data-todo='delete' class='button-primary handle-test-data' /><span class='dashicons dashicons-trash'></span> ".__( 'Delete Test Data', 'otm-test-content' )."</a>";
230
+						$html .= " <a href='javascript:void(0);' data-type='post' data-slug='" . $post_type->name . "' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-plus'></span> " . __('Create Test Data', 'otm-test-content') . "</a>";
231
+						$html .= " <a href='javascript:void(0);' data-type='post' data-slug='" . $post_type->name . "' data-todo='delete' class='button-primary handle-test-data' /><span class='dashicons dashicons-trash'></span> " . __('Delete Test Data', 'otm-test-content') . "</a>";
232 232
 
233 233
 					$html .= "</h3>";
234 234
 
235 235
 					// Create row for each taxonomy associated with the post/page/cpt
236
-					$taxonomies = get_object_taxonomies( $post_type->name );
236
+					$taxonomies = get_object_taxonomies($post_type->name);
237 237
 
238
-						if ( !empty( $taxonomies ) ){
238
+						if (!empty($taxonomies)) {
239 239
 
240
-							foreach( $taxonomies as $tax ){
240
+							foreach ($taxonomies as $tax) {
241 241
 
242 242
 								$html .= "<h3>";
243 243
 
@@ -246,17 +246,17 @@  discard block
 block discarded – undo
246 246
 								);
247 247
 
248 248
 								// Skip banned taxonomies
249
-								if ( in_array( $tax, $skipped_taxonomies ) ){
249
+								if (in_array($tax, $skipped_taxonomies)) {
250 250
 									continue;
251 251
 								}
252 252
 
253
-								$taxonomy = get_taxonomy( $tax );
253
+								$taxonomy = get_taxonomy($tax);
254 254
 
255
-								$html .= "<span class='label term-label'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$taxonomy->labels->name."</span>";
255
+								$html .= "<span class='label term-label'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $taxonomy->labels->name . "</span>";
256 256
 
257
-								$html .= " <a href='javascript:void(0);' data-type='term' data-slug='".$tax."' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-category'></span> ".__( 'Create', 'otm-test-content' )." ".$taxonomy->labels->name."</a>";
257
+								$html .= " <a href='javascript:void(0);' data-type='term' data-slug='" . $tax . "' data-todo='create' class='button-primary handle-test-data' /><span class='dashicons dashicons-category'></span> " . __('Create', 'otm-test-content') . " " . $taxonomy->labels->name . "</a>";
258 258
 
259
-								$html .= " <a href='javascript:void(0);' data-type='term' data-slug='".$tax."' data-todo='delete' class='button-primary handle-test-data' /><span class='dashicons dashicons-trash'></span> ".__( 'Delete', 'otm-test-content' )." ".$taxonomy->labels->name."</a>";
259
+								$html .= " <a href='javascript:void(0);' data-type='term' data-slug='" . $tax . "' data-todo='delete' class='button-primary handle-test-data' /><span class='dashicons dashicons-trash'></span> " . __('Delete', 'otm-test-content') . " " . $taxonomy->labels->name . "</a>";
260 260
 
261 261
 								$html .= "</h3>";
262 262
 
Please login to merge, or discard this patch.