Completed
Push — master ( ef04cf...199149 )
by Mike
02:19
created
includes/class-test-content.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -417,29 +417,29 @@  discard block
 block discarded – undo
417 417
 		}
418 418
 
419 419
 		// Download the file
420
-	    $tmp = \download_url( $url );
420
+		$tmp = \download_url( $url );
421 421
 
422
-	    preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches );
422
+		preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches );
423 423
 
424
-        $file_array['name'] = basename( $matches[0] );
425
-        $file_array['tmp_name'] = $tmp;
424
+		$file_array['name'] = basename( $matches[0] );
425
+		$file_array['tmp_name'] = $tmp;
426 426
 
427
-	    // Check for download errors
428
-	    if ( is_wp_error( $tmp ) ) {
429
-	        unlink( $file_array[ 'tmp_name' ] );
430
-	        error_log( $tmp->get_error_message() );
431
-	    }
427
+		// Check for download errors
428
+		if ( is_wp_error( $tmp ) ) {
429
+			unlink( $file_array[ 'tmp_name' ] );
430
+			error_log( $tmp->get_error_message() );
431
+		}
432 432
 
433 433
 		// Pull the image into the media library
434
-	    $image_id = media_handle_sideload( $file_array, $post_id );
434
+		$image_id = media_handle_sideload( $file_array, $post_id );
435 435
 
436
-	    // Check for handle sideload errors.
437
-	    if ( is_wp_error( $image_id ) ) {
438
-	        unlink( $file_array['tmp_name'] );
439
-	        error_log( $image_id->get_error_message() );
440
-	    }
436
+		// Check for handle sideload errors.
437
+		if ( is_wp_error( $image_id ) ) {
438
+			unlink( $file_array['tmp_name'] );
439
+			error_log( $image_id->get_error_message() );
440
+		}
441 441
 
442
-	    return apply_filters( "tc_image_data", $image_id );
442
+		return apply_filters( "tc_image_data", $image_id );
443 443
 
444 444
 	}
445 445
 
@@ -462,9 +462,9 @@  discard block
 block discarded – undo
462 462
 
463 463
 		// If our cURL failed
464 464
 		if ( $curl_response === false ) {
465
-		    $info = curl_getinfo( $curl );
466
-		    curl_close( $curl );
467
-		    die( 'error occured during curl exec. Additional info: ' . var_export( $info ) );
465
+			$info = curl_getinfo( $curl );
466
+			curl_close( $curl );
467
+			die( 'error occured during curl exec. Additional info: ' . var_export( $info ) );
468 468
 		}
469 469
 
470 470
 		curl_close( $curl );
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 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 apply_filters( "tc_title_data", substr( $title, 0, -1 ) );
79
+		return apply_filters("tc_title_data", 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
 
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
 
351 351
 		);
352 352
 
353
-		for( $i = 1; $i < 6; $i++ ){
354
-			$content .= $random_content_types[rand( 0, 12 )];
353
+		for ($i = 1; $i < 6; $i++) {
354
+			$content .= $random_content_types[rand(0, 12)];
355 355
 		}
356 356
 
357
-		return apply_filters( "tc_paragraphs_data", $content );
357
+		return apply_filters("tc_paragraphs_data", $content);
358 358
 
359 359
 	}
360 360
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @return string Plain text paragraphs.
368 368
 	 */
369
-	public static function plain_text(){
369
+	public static function plain_text() {
370 370
 
371 371
 		$paragraphs = array(
372 372
 			'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.',
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 			'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.',
382 382
 		);
383 383
 
384
-		return apply_filters( "tc_plain_text_data", $paragraphs[ rand( 0, 9 ) ] );
384
+		return apply_filters("tc_plain_text_data", $paragraphs[rand(0, 9)]);
385 385
 
386 386
 	}
387 387
 
@@ -397,49 +397,49 @@  discard block
 block discarded – undo
397 397
 	 * @param int $post_id Post ID.
398 398
 	 * @return mixed Attachment ID or WP Error.
399 399
 	 */
400
-	public static function image( $post_id ){
400
+	public static function image($post_id) {
401 401
 		$file_array = array();
402 402
 
403 403
 		// Get the image from the API
404 404
 		$url = self::get_image_link();
405 405
 
406 406
 		// If the returned string is empty or it's not a string, try again.
407
-		if ( empty( $url ) || !is_string( $url ) ){
407
+		if (empty($url) || !is_string($url)) {
408 408
 
409 409
 			// Try again
410 410
 			$url = self::get_image_link();
411 411
 
412 412
 			// If it fails again, just give up
413
-			if ( empty( $url ) || !is_string( $url ) ){
413
+			if (empty($url) || !is_string($url)) {
414 414
 				return;
415 415
 			}
416 416
 
417 417
 		}
418 418
 
419 419
 		// Download the file
420
-	    $tmp = \download_url( $url );
420
+	    $tmp = \download_url($url);
421 421
 
422
-	    preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches );
422
+	    preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches);
423 423
 
424
-        $file_array['name'] = basename( $matches[0] );
424
+        $file_array['name'] = basename($matches[0]);
425 425
         $file_array['tmp_name'] = $tmp;
426 426
 
427 427
 	    // Check for download errors
428
-	    if ( is_wp_error( $tmp ) ) {
429
-	        unlink( $file_array[ 'tmp_name' ] );
430
-	        error_log( $tmp->get_error_message() );
428
+	    if (is_wp_error($tmp)) {
429
+	        unlink($file_array['tmp_name']);
430
+	        error_log($tmp->get_error_message());
431 431
 	    }
432 432
 
433 433
 		// Pull the image into the media library
434
-	    $image_id = media_handle_sideload( $file_array, $post_id );
434
+	    $image_id = media_handle_sideload($file_array, $post_id);
435 435
 
436 436
 	    // Check for handle sideload errors.
437
-	    if ( is_wp_error( $image_id ) ) {
438
-	        unlink( $file_array['tmp_name'] );
439
-	        error_log( $image_id->get_error_message() );
437
+	    if (is_wp_error($image_id)) {
438
+	        unlink($file_array['tmp_name']);
439
+	        error_log($image_id->get_error_message());
440 440
 	    }
441 441
 
442
-	    return apply_filters( "tc_image_data", $image_id );
442
+	    return apply_filters("tc_image_data", $image_id);
443 443
 
444 444
 	}
445 445
 
@@ -451,31 +451,31 @@  discard block
 block discarded – undo
451 451
 	 *
452 452
 	 * @return string Image URL.
453 453
 	 */
454
-	private static function get_image_link(){
454
+	private static function get_image_link() {
455 455
 
456 456
 		// cURL an image API for a completely random photo
457
-		$curl = curl_init( "http://www.splashbase.co/api/v1/images/random?images_only=true" );
457
+		$curl = curl_init("http://www.splashbase.co/api/v1/images/random?images_only=true");
458 458
 
459
-		curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
459
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
460 460
 
461
-		$curl_response = curl_exec( $curl );
461
+		$curl_response = curl_exec($curl);
462 462
 
463 463
 		// If our cURL failed
464
-		if ( $curl_response === false ) {
465
-		    $info = curl_getinfo( $curl );
466
-		    curl_close( $curl );
467
-		    die( 'error occured during curl exec. Additional info: ' . var_export( $info ) );
464
+		if ($curl_response === false) {
465
+		    $info = curl_getinfo($curl);
466
+		    curl_close($curl);
467
+		    die('error occured during curl exec. Additional info: '.var_export($info));
468 468
 		}
469 469
 
470
-		curl_close( $curl );
470
+		curl_close($curl);
471 471
 
472 472
 		// Decode the data
473
-		$response = json_decode( $curl_response, true );
473
+		$response = json_decode($curl_response, true);
474 474
 
475 475
 		// Check to make sure that the return contains a valid image extensions
476 476
 		preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $response['url'], $matches);
477 477
 
478
-		if ( !empty( $matches ) ){
478
+		if (!empty($matches)) {
479 479
 			return $response['url'];
480 480
 		}
481 481
 
@@ -490,12 +490,12 @@  discard block
 block discarded – undo
490 490
 	 * @param string $format PHP Date format.
491 491
 	 * @return mixed Date in the format requested.
492 492
 	 */
493
-	public static function date( $format ){
493
+	public static function date($format) {
494 494
 
495
-		$num_days = rand( 1, 60 );
496
-		$date = date( $format, strtotime( " +$num_days days" ) );
495
+		$num_days = rand(1, 60);
496
+		$date = date($format, strtotime(" +$num_days days"));
497 497
 
498
-		return apply_filters( "tc_date_data", $date );
498
+		return apply_filters("tc_date_data", $date);
499 499
 
500 500
 	}
501 501
 
@@ -507,19 +507,19 @@  discard block
 block discarded – undo
507 507
 	 *
508 508
 	 * @return string Time string
509 509
 	 */
510
-	public static function time(){
510
+	public static function time() {
511 511
 
512 512
 		$times = array(
513 513
 			'8:00 am',
514 514
 			'5:00PM',
515 515
 			'13:00',
516 516
 			'2015',
517
-			date( 'G:i', strtotime( " +".rand( 4, 24 )." hours" ) ),
518
-			date( 'g:i', strtotime( " +".rand( 4, 24 )." hours" ) ),
519
-			date( 'G:i A', strtotime( " +".rand( 4, 24 )." hours" ) )
517
+			date('G:i', strtotime(" +".rand(4, 24)." hours")),
518
+			date('g:i', strtotime(" +".rand(4, 24)." hours")),
519
+			date('G:i A', strtotime(" +".rand(4, 24)." hours"))
520 520
 		);
521 521
 
522
-		return apply_filters( "tc_time_data", $times[ rand( 0, 6 ) ] );
522
+		return apply_filters("tc_time_data", $times[rand(0, 6)]);
523 523
 
524 524
 	}
525 525
 
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 	 *
532 532
 	 * @return string Timezone
533 533
 	 */
534
-	public static function timezone(){
534
+	public static function timezone() {
535 535
 
536 536
 		$timezones = array(
537 537
 			'America/Denver',
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 			'UTC'
550 550
 		);
551 551
 
552
-		return apply_filters( "tc_timezone_data", $timezones[ rand( 0, 12 ) ] );
552
+		return apply_filters("tc_timezone_data", $timezones[rand(0, 12)]);
553 553
 
554 554
 	}
555 555
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	 *
563 563
 	 * @return string Phone #.
564 564
 	 */
565
-	public static function phone(){
565
+	public static function phone() {
566 566
 
567 567
 		$phone_numbers = array(
568 568
 			'7203893101',
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 			'+43 780 0047112'
579 579
 		);
580 580
 
581
-		return apply_filters( "tc_phone_data", $phone_numbers[ rand( 0, 10 ) ] );
581
+		return apply_filters("tc_phone_data", $phone_numbers[rand(0, 10)]);
582 582
 
583 583
 	}
584 584
 
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	 *
591 591
 	 * @return string Email address.
592 592
 	 */
593
-	public static function email(){
593
+	public static function email() {
594 594
 
595 595
 		$email_addresses = array(
596 596
 			'[email protected]',
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 			'[email protected]'
604 604
 		);
605 605
 
606
-		return apply_filters( "tc_email_data", $email_addresses[ rand( 0, 7 ) ] );
606
+		return apply_filters("tc_email_data", $email_addresses[rand(0, 7)]);
607 607
 
608 608
 	}
609 609
 
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
 	 *
618 618
 	 * @return string URL.
619 619
 	 */
620
-	public static function link(){
620
+	public static function link() {
621 621
 
622 622
 		$links = array(
623 623
 			'http://google.com',
624 624
 			'https://www.twitter.com',
625
-			site_url( '/?iam=anextravariable' ),
625
+			site_url('/?iam=anextravariable'),
626 626
 			'github.com',
627 627
 			'http://filebase.com',
628 628
 			'www.oldtownmediainc.com',
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 			'https://www.eff.org'
631 631
 		);
632 632
 
633
-		return apply_filters( "tc_link_data", $links[ rand( 0, 7 ) ] );
633
+		return apply_filters("tc_link_data", $links[rand(0, 7)]);
634 634
 
635 635
 	}
636 636
 
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 	 *
642 642
 	 * @return string URL.
643 643
 	 */
644
-	public static function oembed(){
644
+	public static function oembed() {
645 645
 
646 646
 		$links = array(
647 647
 			'https://www.youtube.com/watch?v=A85-YQsm6pY',
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 			'https://www.instagram.com/p/-eyLo0RMfX',
653 653
 		);
654 654
 
655
-		return apply_filters( "tc_oembed_data", $links[ rand( 0, 5 ) ] );
655
+		return apply_filters("tc_oembed_data", $links[rand(0, 5)]);
656 656
 
657 657
 	}
658 658
 
@@ -666,10 +666,10 @@  discard block
 block discarded – undo
666 666
 	 * @param	string $type Video service to get link from
667 667
 	 * @return	string URL.
668 668
 	 */
669
-	public static function video( $type ){
669
+	public static function video($type) {
670 670
 
671 671
 		// Switch through our video types. Expecting to add more in the future
672
-		switch( $type ){
672
+		switch ($type) {
673 673
 
674 674
 			// YouTube videos
675 675
 			case 'youtube' :
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 
711 711
 		}
712 712
 
713
-		return apply_filters( "tc_video_data", $links[ rand( 0, 8 ) ] );
713
+		return apply_filters("tc_video_data", $links[rand(0, 8)]);
714 714
 
715 715
 	}
716 716
 
Please login to merge, or discard this patch.
includes/class-create-term.php 1 patch
Spacing   +18 added lines, -18 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,27 +64,27 @@  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
-		$title = apply_filters( "tc_{$slug}_term_title", TestContent::title() );
70
+		$title = apply_filters("tc_{$slug}_term_title", TestContent::title());
71 71
 
72 72
 		$return = wp_insert_term(
73 73
 			$title,
74 74
 			$slug,
75
-			apply_filters( "tc_{$slug}_term_arguments", array(
75
+			apply_filters("tc_{$slug}_term_arguments", array(
76 76
 					'description'=> TestContent::title(),
77
-					'slug' => sanitize_title( $title ),
77
+					'slug' => sanitize_title($title),
78 78
 				)
79 79
 			)
80 80
 		);
81 81
 
82 82
 		// Then, set a test content flag on the new post for later deletion
83
-		add_term_meta( $return['term_id'], 'evans_test_content', '__test__', true );
83
+		add_term_meta($return['term_id'], 'evans_test_content', '__test__', true);
84 84
 
85 85
 		// Check if we have errors and return them or created message
86
-		if ( is_wp_error( $return ) ){
87
-			error_log( $return->get_error_message() );
86
+		if (is_wp_error($return)) {
87
+			error_log($return->get_error_message());
88 88
 			return $return;
89 89
 		} else {
90 90
 			return array(
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 				'object'	=> 'term',
93 93
 				'tid'		=> $return['term_id'],
94 94
 				'taxonomy'	=> $slug,
95
-				'link_edit'	=> admin_url( '/edit-tags.php?action=edit&taxonomy='.$slug.'&tag_ID='.$return['term_id'] ),
96
-				'link_view'	=> get_term_link( $return['term_id'] )
95
+				'link_edit'	=> admin_url('/edit-tags.php?action=edit&taxonomy='.$slug.'&tag_ID='.$return['term_id']),
96
+				'link_view'	=> get_term_link($return['term_id'])
97 97
 			);
98 98
 		}
99 99
 
Please login to merge, or discard this patch.