@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @subpackage Evans |
18 | 18 | * @author Old Town Media |
19 | 19 | */ |
20 | -class ConnectionTest{ |
|
20 | +class ConnectionTest { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Run all of our connection tests. |
@@ -26,33 +26,33 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return boolean Status of connection to Internet/Splashbase. |
28 | 28 | */ |
29 | - public function test(){ |
|
29 | + public function test() { |
|
30 | 30 | |
31 | 31 | /* |
32 | 32 | * Make sure that we're looking at the correct admin page |
33 | 33 | */ |
34 | - if ( ! $this->check_admin_page() ){ |
|
34 | + if (!$this->check_admin_page()) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | /* |
39 | 39 | * Test #1 - Check for Airplane Mode plugin status |
40 | 40 | */ |
41 | - if ( ! $this->check_airplane_mode() ){ |
|
41 | + if (!$this->check_airplane_mode()) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | |
45 | 45 | /* |
46 | 46 | * Test #2 - Check Internet connection in general |
47 | 47 | */ |
48 | - if ( ! $this->check_internet() ){ |
|
48 | + if (!$this->check_internet()) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | |
52 | 52 | /* |
53 | 53 | * Test #3 - Check External URL itself (Splashbase here) |
54 | 54 | */ |
55 | - if ( ! $this->check_external_url( 'http://www.splashbase.co/api/v1/images/' ) ){ |
|
55 | + if (!$this->check_external_url('http://www.splashbase.co/api/v1/images/')) { |
|
56 | 56 | return false; |
57 | 57 | } |
58 | 58 | |
@@ -75,22 +75,22 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return boolean Whether or not we're in the right place. |
77 | 77 | */ |
78 | - private function check_admin_page(){ |
|
78 | + private function check_admin_page() { |
|
79 | 79 | global $current_screen; |
80 | 80 | |
81 | 81 | // Only run if we're in the admin page |
82 | - if ( !is_admin() ){ |
|
82 | + if (!is_admin()) { |
|
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | |
86 | 86 | // Get the current admin screen & verify that we're on the right one |
87 | 87 | // before continuing. |
88 | - if ( isset ( $current_screen ) && 'tools_page_create-test-data' != $current_screen->base ){ |
|
88 | + if (isset ($current_screen) && 'tools_page_create-test-data' != $current_screen->base) { |
|
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
92 | - $last_uri_bit = explode( '=', $_SERVER['REQUEST_URI'] ); |
|
93 | - if ( 'create-test-data' != end( $last_uri_bit ) ){ |
|
92 | + $last_uri_bit = explode('=', $_SERVER['REQUEST_URI']); |
|
93 | + if ('create-test-data' != end($last_uri_bit)) { |
|
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return boolean Connected or not. |
110 | 110 | */ |
111 | - private function check_airplane_mode(){ |
|
111 | + private function check_airplane_mode() { |
|
112 | 112 | |
113 | - if ( class_exists( 'Airplane_Mode_Core' ) ){ |
|
113 | + if (class_exists('Airplane_Mode_Core')) { |
|
114 | 114 | // Is airplane mode active? |
115 | - $airplane_mode = get_site_option( 'airplane-mode' ); |
|
115 | + $airplane_mode = get_site_option('airplane-mode'); |
|
116 | 116 | |
117 | - if ( $airplane_mode === 'on' ){ |
|
117 | + if ($airplane_mode === 'on') { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | } |
@@ -133,17 +133,17 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return boolean Connected or not. |
135 | 135 | */ |
136 | - private function check_internet(){ |
|
136 | + private function check_internet() { |
|
137 | 137 | |
138 | 138 | // Attempt to open a socket connection to Google |
139 | - $connected = @fsockopen( "www.google.com", 80 ); |
|
139 | + $connected = @fsockopen("www.google.com", 80); |
|
140 | 140 | |
141 | - if ( !$connected ){ |
|
141 | + if (!$connected) { |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | |
145 | 145 | // Close out our 1st test |
146 | - fclose( $connected ); |
|
146 | + fclose($connected); |
|
147 | 147 | |
148 | 148 | return true; |
149 | 149 | |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | * @param string $url External URL to attempt to reach. |
161 | 161 | * @return boolean Connected or not. |
162 | 162 | */ |
163 | - private function check_external_url( $url ){ |
|
163 | + private function check_external_url($url) { |
|
164 | 164 | |
165 | - $test_url = esc_url( $url ); |
|
166 | - $response = wp_remote_get( $test_url ); |
|
165 | + $test_url = esc_url($url); |
|
166 | + $response = wp_remote_get($test_url); |
|
167 | 167 | |
168 | - if ( !is_array( $response ) ){ |
|
168 | + if (!is_array($response)) { |
|
169 | 169 | return false; |
170 | 170 | } |
171 | 171 |
@@ -3,16 +3,16 @@ |
||
3 | 3 | use testContent as test; |
4 | 4 | |
5 | 5 | // If uninstall is not called from WordPress, exit |
6 | -if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
6 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
7 | 7 | exit(); |
8 | 8 | } |
9 | 9 | |
10 | 10 | // Check if the current user has priveledges to run this method |
11 | -if ( ! current_user_can( 'activate_plugins' ) ){ |
|
11 | +if (!current_user_can('activate_plugins')) { |
|
12 | 12 | return; |
13 | 13 | } |
14 | 14 | |
15 | -require dirname( __FILE__ ) . '/includes/class-delete.php'; |
|
15 | +require dirname(__FILE__).'/includes/class-delete.php'; |
|
16 | 16 | $delete = new test\Delete; |
17 | 17 | |
18 | 18 | // Delete all the things |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage Evans |
9 | 9 | * @author Old Town Media |
10 | 10 | */ |
11 | -class Plugin{ |
|
11 | +class Plugin { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Plugin definitions. |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param object $definitions Information about the plugin |
35 | 35 | * @return object $this |
36 | 36 | */ |
37 | - public function set_definitions( $definitions ) { |
|
37 | + public function set_definitions($definitions) { |
|
38 | 38 | |
39 | 39 | $this->definitions = $definitions; |
40 | 40 | return $this; |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @param object $provider Hook provider. |
49 | 49 | * @return object $this |
50 | 50 | */ |
51 | - public function register_hooks( $provider ) { |
|
51 | + public function register_hooks($provider) { |
|
52 | 52 | |
53 | - if ( method_exists( $provider, 'set_plugin' ) ) { |
|
54 | - $provider->set_plugin( $this ); |
|
53 | + if (method_exists($provider, 'set_plugin')) { |
|
54 | + $provider->set_plugin($this); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $provider->hooks(); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param object $provider Hook provider. |
67 | 67 | * @return object $this |
68 | 68 | */ |
69 | - public function register_views( $provider ) { |
|
69 | + public function register_views($provider) { |
|
70 | 70 | |
71 | 71 | $provider->register_view(); |
72 | 72 | return $this; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @see load_plugin_textdomain |
81 | 81 | */ |
82 | 82 | public function load_textdomain() { |
83 | - load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' ); |
|
83 | + load_plugin_textdomain('otm-test-content', FALSE, basename(dirname($this->definitions->file)).'/languages/'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | } |
@@ -14,7 +14,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param string $class Class name. |
23 | 23 | */ |
24 | -function test_content_autoloader( $class ) { |
|
25 | - $namespace = explode( '\\', $class ); |
|
24 | +function test_content_autoloader($class) { |
|
25 | + $namespace = explode('\\', $class); |
|
26 | 26 | |
27 | - if ( __NAMESPACE__ !== $namespace[0] ){ |
|
27 | + if (__NAMESPACE__ !== $namespace[0]) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
31 | - $class = str_replace( __NAMESPACE__ . '\\', '', $class ); |
|
31 | + $class = str_replace(__NAMESPACE__.'\\', '', $class); |
|
32 | 32 | |
33 | 33 | $nss = array( |
34 | 34 | 'Abstracts', |
@@ -36,20 +36,20 @@ discard block |
||
36 | 36 | 'Views' |
37 | 37 | ); |
38 | 38 | |
39 | - if ( in_array( $namespace[1], $nss ) ){ |
|
40 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '/\1', $class ) ); |
|
41 | - $class = str_replace( '\\', '', $class ); |
|
42 | - $file = dirname( __FILE__ ) . '/' . $class . '.php'; |
|
39 | + if (in_array($namespace[1], $nss)) { |
|
40 | + $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '/\1', $class)); |
|
41 | + $class = str_replace('\\', '', $class); |
|
42 | + $file = dirname(__FILE__).'/'.$class.'.php'; |
|
43 | 43 | } else { |
44 | - $class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) ); |
|
45 | - $file = dirname( __FILE__ ) . '/includes/class-' . $class . '.php'; |
|
44 | + $class = strtolower(preg_replace('/(?<!^)([A-Z])/', '-\\1', $class)); |
|
45 | + $file = dirname(__FILE__).'/includes/class-'.$class.'.php'; |
|
46 | 46 | } |
47 | 47 | |
48 | - if ( is_readable( $file ) ) { |
|
49 | - require_once( $file ); |
|
48 | + if (is_readable($file)) { |
|
49 | + require_once($file); |
|
50 | 50 | } |
51 | 51 | } |
52 | - spl_autoload_register( __NAMESPACE__ . '\test_content_autoloader' ); |
|
52 | + spl_autoload_register(__NAMESPACE__.'\test_content_autoloader'); |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | function plugin() { |
62 | 62 | static $instance; |
63 | 63 | |
64 | - if ( null === $instance ) { |
|
64 | + if (null === $instance) { |
|
65 | 65 | $instance = new Plugin(); |
66 | 66 | } |
67 | 67 | |
@@ -71,19 +71,19 @@ discard block |
||
71 | 71 | // Set our definitions for later use |
72 | 72 | plugin()->set_definitions( |
73 | 73 | (object) array( |
74 | - 'basename' => plugin_basename( __FILE__ ), |
|
75 | - 'directory' => plugin_dir_path( __FILE__ ), |
|
74 | + 'basename' => plugin_basename(__FILE__), |
|
75 | + 'directory' => plugin_dir_path(__FILE__), |
|
76 | 76 | 'file' => __FILE__, |
77 | 77 | 'slug' => 'structure', |
78 | - 'url' => plugin_dir_url( __FILE__ ) |
|
78 | + 'url' => plugin_dir_url(__FILE__) |
|
79 | 79 | ) |
80 | 80 | ); |
81 | 81 | |
82 | 82 | // Register hook providers and views. |
83 | - plugin()->register_hooks( new AdminPage() ) |
|
84 | - ->register_views( new Views\Posts() ) |
|
85 | - ->register_views( new Views\Terms() ) |
|
86 | - ->register_views( new Views\Various() ); |
|
83 | + plugin()->register_hooks(new AdminPage()) |
|
84 | + ->register_views(new Views\Posts()) |
|
85 | + ->register_views(new Views\Terms()) |
|
86 | + ->register_views(new Views\Various()); |
|
87 | 87 | |
88 | 88 | // Load textdomain hook |
89 | -add_action( 'plugins_loaded', array( plugin(), 'load_textdomain' ) ); |
|
89 | +add_action('plugins_loaded', array(plugin(), 'load_textdomain')); |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Terms extends Abs\View{ |
|
13 | +class Terms extends Abs\View { |
|
14 | 14 | |
15 | 15 | protected $title = 'Terms'; |
16 | 16 | protected $type = 'term'; |
17 | - protected $priority = 2; |
|
17 | + protected $priority = 2; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | /** |
@@ -24,25 +24,25 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return string HTML content. |
26 | 26 | */ |
27 | - protected function actions_section(){ |
|
27 | + protected function actions_section() { |
|
28 | 28 | $html = ''; |
29 | 29 | |
30 | 30 | $taxonomies = get_taxonomies(); |
31 | 31 | |
32 | - foreach ( $taxonomies as $tax ) : |
|
32 | + foreach ($taxonomies as $tax) : |
|
33 | 33 | |
34 | 34 | $skipped_taxonomies = array( |
35 | - 'post_format', // We shouldn't be making random post format classes |
|
36 | - 'product_shipping_class', // These aren't used visually and are therefore skipped |
|
37 | - 'nav_menu', // Menus are handled seperately of taxonomies |
|
35 | + 'post_format', // We shouldn't be making random post format classes |
|
36 | + 'product_shipping_class', // These aren't used visually and are therefore skipped |
|
37 | + 'nav_menu', // Menus are handled seperately of taxonomies |
|
38 | 38 | ); |
39 | 39 | |
40 | 40 | // Skip banned taxonomies |
41 | - if ( in_array( $tax, $skipped_taxonomies ) ){ |
|
41 | + if (in_array($tax, $skipped_taxonomies)) { |
|
42 | 42 | continue; |
43 | 43 | } |
44 | 44 | |
45 | - $taxonomy = get_taxonomy( $tax ); |
|
45 | + $taxonomy = get_taxonomy($tax); |
|
46 | 46 | |
47 | 47 | $html .= "<div class='test-data-cpt'>"; |
48 | 48 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | |
51 | 51 | $html .= "<span class='label'>".$taxonomy->labels->name."</span>"; |
52 | 52 | |
53 | - $html .= $this->build_button( 'create', $tax, __( 'Create', 'otm-test-content' )." ".$taxonomy->labels->name ); |
|
54 | - $html .= $this->build_button( 'delete', $tax, __( 'Delete', 'otm-test-content' )." ".$taxonomy->labels->name ); |
|
53 | + $html .= $this->build_button('create', $tax, __('Create', 'otm-test-content')." ".$taxonomy->labels->name); |
|
54 | + $html .= $this->build_button('delete', $tax, __('Delete', 'otm-test-content')." ".$taxonomy->labels->name); |
|
55 | 55 | |
56 | 56 | $html .= "</h3>"; |
57 | 57 |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Posts extends Abs\View{ |
|
13 | +class Posts extends Abs\View { |
|
14 | 14 | |
15 | 15 | protected $title = 'Posts'; |
16 | 16 | protected $type = 'post'; |
17 | - protected $priority = 1; |
|
17 | + protected $priority = 1; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Our sections action block - button to create and delete. |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string HTML content. |
25 | 25 | */ |
26 | - protected function actions_section(){ |
|
26 | + protected function actions_section() { |
|
27 | 27 | $html = ''; |
28 | 28 | |
29 | 29 | // Loop through every post type available on the site |
30 | - $post_types = get_post_types( array( 'public' => true ), 'objects' ); |
|
30 | + $post_types = get_post_types(array('public' => true), 'objects'); |
|
31 | 31 | |
32 | - foreach ( $post_types as $post_type ) : |
|
32 | + foreach ($post_types as $post_type) : |
|
33 | 33 | |
34 | 34 | $skipped_cpts = array( |
35 | 35 | 'attachment' |
36 | 36 | ); |
37 | 37 | |
38 | 38 | // Skip banned cpts |
39 | - if ( in_array( $post_type->name, $skipped_cpts ) ){ |
|
39 | + if (in_array($post_type->name, $skipped_cpts)) { |
|
40 | 40 | continue; |
41 | 41 | } |
42 | 42 | |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | $html .= "<h3>"; |
46 | 46 | |
47 | - $html .= "<span class='label'>" . $post_type->labels->name . "</span>"; |
|
48 | - $html .= $this->build_button( 'create', $post_type->name, __( 'Create Test Data', 'otm-test-content' ) ); |
|
49 | - $html .= $this->build_button( 'delete', $post_type->name, __( 'Delete Test Data', 'otm-test-content' ) ); |
|
47 | + $html .= "<span class='label'>".$post_type->labels->name."</span>"; |
|
48 | + $html .= $this->build_button('create', $post_type->name, __('Create Test Data', 'otm-test-content')); |
|
49 | + $html .= $this->build_button('delete', $post_type->name, __('Delete Test Data', 'otm-test-content')); |
|
50 | 50 | |
51 | 51 | $html .= "</h3>"; |
52 | 52 |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | * @subpackage Test Content |
11 | 11 | * @author Old Town Media |
12 | 12 | */ |
13 | -class Various extends Abs\View{ |
|
13 | +class Various extends Abs\View { |
|
14 | 14 | |
15 | 15 | protected $title = 'Various'; |
16 | 16 | protected $type = 'all'; |
17 | - protected $priority = 3; |
|
17 | + protected $priority = 3; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | /** |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return string HTML content. |
26 | 26 | */ |
27 | - protected function actions_section(){ |
|
27 | + protected function actions_section() { |
|
28 | 28 | $html = ''; |
29 | 29 | |
30 | 30 | $html .= "<div class='test-data-cpt'>"; |
31 | 31 | |
32 | 32 | $html .= "<h3>"; |
33 | 33 | |
34 | - $html .= "<span class='label'>" . __( 'Clean Site', 'otm-test-content' ) . "</span>"; |
|
35 | - $html .= $this->build_button( 'delete', 'all', __( 'Delete All Test Data', 'otm-test-content' ) ); |
|
34 | + $html .= "<span class='label'>".__('Clean Site', 'otm-test-content')."</span>"; |
|
35 | + $html .= $this->build_button('delete', 'all', __('Delete All Test Data', 'otm-test-content')); |
|
36 | 36 | |
37 | 37 | $html .= "</h3>"; |
38 | 38 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param string $html Existing HTML content. |
51 | 51 | * @return string HTML section content. |
52 | 52 | */ |
53 | - protected function options_section( $html = '' ){ |
|
53 | + protected function options_section($html = '') { |
|
54 | 54 | return $html; |
55 | 55 | } |
56 | 56 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @subpackage Evans |
13 | 13 | * @author Old Town Media |
14 | 14 | */ |
15 | -class Term extends Abs\Type{ |
|
15 | +class Term extends Abs\Type { |
|
16 | 16 | |
17 | 17 | protected $type = 'term'; |
18 | 18 | |
@@ -31,25 +31,25 @@ discard block |
||
31 | 31 | * @param boolean $echo Whether or not to echo. Optional. |
32 | 32 | * @param int $num Optional. Number of posts to create. |
33 | 33 | */ |
34 | - public function create_objects( $slug, $connection, $echo = false, $num = '' ){ |
|
34 | + public function create_objects($slug, $connection, $echo = false, $num = '') { |
|
35 | 35 | |
36 | 36 | // If we're missing a custom post type id - don't do anything |
37 | - if ( empty( $slug ) ){ |
|
37 | + if (empty($slug)) { |
|
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | 41 | // If we forgot to put in a quantity, make one for us |
42 | - if ( empty( $num ) ){ |
|
43 | - $num = rand( 5, 30 ); |
|
42 | + if (empty($num)) { |
|
43 | + $num = rand(5, 30); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // Create test terms |
47 | - for( $i = 0; $i < $num; $i++ ){ |
|
47 | + for ($i = 0; $i < $num; $i++) { |
|
48 | 48 | |
49 | - $return = $this->create_test_object( $slug ); |
|
49 | + $return = $this->create_test_object($slug); |
|
50 | 50 | |
51 | - if ( $echo === true ){ |
|
52 | - echo \json_encode( $return ); |
|
51 | + if ($echo === true) { |
|
52 | + echo \json_encode($return); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | } |
@@ -70,27 +70,27 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @param string $slug a custom post type ID. |
72 | 72 | */ |
73 | - private function create_test_object( $slug ){ |
|
73 | + private function create_test_object($slug) { |
|
74 | 74 | |
75 | 75 | // Get a random title |
76 | - $title = apply_filters( "tc_{$slug}_term_title", TestContent::title() ); |
|
76 | + $title = apply_filters("tc_{$slug}_term_title", TestContent::title()); |
|
77 | 77 | |
78 | 78 | $return = wp_insert_term( |
79 | 79 | $title, |
80 | 80 | $slug, |
81 | - apply_filters( "tc_{$slug}_term_arguments", array( |
|
81 | + apply_filters("tc_{$slug}_term_arguments", array( |
|
82 | 82 | 'description'=> TestContent::title(), |
83 | - 'slug' => sanitize_title( $title ), |
|
83 | + 'slug' => sanitize_title($title), |
|
84 | 84 | ) |
85 | 85 | ) |
86 | 86 | ); |
87 | 87 | |
88 | 88 | // Then, set a test content flag on the new post for later deletion |
89 | - add_term_meta( $return['term_id'], 'evans_test_content', '__test__', true ); |
|
89 | + add_term_meta($return['term_id'], 'evans_test_content', '__test__', true); |
|
90 | 90 | |
91 | 91 | // Check if we have errors and return them or created message |
92 | - if ( is_wp_error( $return ) ){ |
|
93 | - error_log( $return->get_error_message() ); |
|
92 | + if (is_wp_error($return)) { |
|
93 | + error_log($return->get_error_message()); |
|
94 | 94 | return $return; |
95 | 95 | } else { |
96 | 96 | return array( |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | 'object' => 'term', |
99 | 99 | 'tid' => $return['term_id'], |
100 | 100 | 'taxonomy' => $slug, |
101 | - 'link_edit' => admin_url( '/edit-tags.php?action=edit&taxonomy='.$slug.'&tag_ID='.$return['term_id'] ), |
|
102 | - 'link_view' => get_term_link( $return['term_id'] ) |
|
101 | + 'link_edit' => admin_url('/edit-tags.php?action=edit&taxonomy='.$slug.'&tag_ID='.$return['term_id']), |
|
102 | + 'link_view' => get_term_link($return['term_id']) |
|
103 | 103 | ); |
104 | 104 | } |
105 | 105 | |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | * @param string $slug a custom post type ID. |
118 | 118 | * @param boolean $echo Whether or not to echo the result |
119 | 119 | */ |
120 | - public function delete( $slug, $echo = false ){ |
|
120 | + public function delete($slug, $echo = false) { |
|
121 | 121 | |
122 | - $delete = new Delete; |
|
122 | + $delete = new Delete; |
|
123 | 123 | |
124 | 124 | // Make sure that the current user is logged in & has full permissions. |
125 | - if ( !$delete->user_can_delete() ){ |
|
125 | + if (!$delete->user_can_delete()) { |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Check that $cptslg has a string. |
130 | - if ( empty( $slug ) ){ |
|
130 | + if (empty($slug)) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
@@ -143,15 +143,15 @@ discard block |
||
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 |
||
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 | - 'message' => __( 'Deleted', 'otm-test-content' ) . ' ' . $taxonomy->labels->name |
|
172 | + 'message' => __('Deleted', 'otm-test-content').' '.$taxonomy->labels->name |
|
173 | 173 | ); |
174 | 174 | |
175 | - echo \json_encode( $events ); |
|
175 | + echo \json_encode($events); |
|
176 | 176 | |
177 | 177 | } |
178 | 178 |