Completed
Push — master ( 02d311...e3ebdf )
by Mike
02:15
created
includes/class-create-post.php 1 patch
Spacing   +90 added lines, -90 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,55 +263,55 @@  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 added the old way
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
 
288 288
 		}
289 289
 
290 290
 		// Loop through all metaboxes added the new way
291
-		foreach ( \CMB2_Boxes::get_all() as $cmb ) {
291
+		foreach (\CMB2_Boxes::get_all() as $cmb) {
292 292
 
293 293
 			// Create the default
294 294
 			$match = false;
295 295
 
296 296
 			// Establish correct cmb types
297
-			if ( is_string( $cmb->meta_box['object_types'] ) ){
298
-				if ( $cmb->meta_box['object_types'] == $slug ){
297
+			if (is_string($cmb->meta_box['object_types'])) {
298
+				if ($cmb->meta_box['object_types'] == $slug) {
299 299
 					$match = true;
300 300
 				}
301 301
 			} else {
302
-				if ( in_array( $slug, $cmb->meta_box['object_types'] ) ){
302
+				if (in_array($slug, $cmb->meta_box['object_types'])) {
303 303
 					$match = true;
304 304
 				}
305 305
 			}
306 306
 
307
-			if ( $match !== true ){
307
+			if ($match !== true) {
308 308
 				continue;
309 309
 			}
310 310
 
311
-			if ( empty( $fields ) ){
311
+			if (empty($fields)) {
312 312
 				$fields = $cmb->meta_box['fields'];
313 313
 			} else {
314
-				$fields = array_merge( $fields, $cmb->meta_box['fields'] );
314
+				$fields = array_merge($fields, $cmb->meta_box['fields']);
315 315
 			}
316 316
 
317 317
 		}
@@ -335,25 +335,25 @@  discard block
 block discarded – undo
335 335
 	 * @param string $slug a custom post type ID.
336 336
 	 * @return array Array of fields.
337 337
 	 */
338
-	private function get_cmb1_metaboxes( $slug ){
338
+	private function get_cmb1_metaboxes($slug) {
339 339
 
340 340
 		$fields = array();
341 341
 
342 342
 		// Get all metaboxes from CMB2 library
343
-		$all_metaboxes = apply_filters( 'cmb_meta_boxes', array() );
343
+		$all_metaboxes = apply_filters('cmb_meta_boxes', array());
344 344
 
345 345
 		// Loop through all possible sets of metaboxes
346
-		foreach ( $all_metaboxes as $metabox_array ){
346
+		foreach ($all_metaboxes as $metabox_array) {
347 347
 
348 348
 			// If the custom post type ID matches this set of fields, set & stop
349
-			if ( in_array( $slug, $metabox_array['pages'] ) ) {
349
+			if (in_array($slug, $metabox_array['pages'])) {
350 350
 
351 351
 				// If this is the first group of fields, simply set the value
352 352
 				// Else, merge this group with the previous one
353
-				if ( empty( $fields ) ){
353
+				if (empty($fields)) {
354 354
 					$fields = $metabox_array['fields'];
355 355
 				} else {
356
-					$fields = array_merge( $fields, $metabox_array['fields'] );
356
+					$fields = array_merge($fields, $metabox_array['fields']);
357 357
 				}
358 358
 			}
359 359
 
@@ -378,36 +378,36 @@  discard block
 block discarded – undo
378 378
 	 * @param int $post_id Single post ID.
379 379
 	 * @param array $cmb custom metabox array from CMB2.
380 380
 	 */
381
-	private function random_metabox_content( $post_id, $cmb ){
381
+	private function random_metabox_content($post_id, $cmb) {
382 382
 		$value = '';
383 383
 
384 384
 		// First check that our post ID & cmb array aren't empty
385
-		if ( empty( $cmb ) || empty( $post_id ) ){
385
+		if (empty($cmb) || empty($post_id)) {
386 386
 			return;
387 387
 		}
388 388
 
389 389
 		// Fetch the appropriate type of data and return
390
-		switch( $cmb['type'] ){
390
+		switch ($cmb['type']) {
391 391
 
392 392
 			case 'text':
393 393
 			case 'text_small':
394 394
 			case 'text_medium':
395 395
 
396 396
 				// If phone is in the id, fetch a phone #
397
-				if ( stripos( $cmb['id'], 'phone' ) ){
397
+				if (stripos($cmb['id'], 'phone')) {
398 398
 					$value = TestContent::phone();
399 399
 
400 400
 				// If email is in the id, fetch an email address
401
-				} elseif ( stripos( $cmb['id'], 'email' ) ){
401
+				} elseif (stripos($cmb['id'], 'email')) {
402 402
 					$value = TestContent::email();
403 403
 
404 404
 				// If time is in the id, fetch a time string
405
-				} elseif ( stripos( $cmb['id'], 'time' ) ){
405
+				} elseif (stripos($cmb['id'], 'time')) {
406 406
 					$value = TestContent::time();
407 407
 
408 408
 				// Otherwise, just a random text string
409 409
 				} else {
410
-					$value = TestContent::title( rand( 10, 50 ) );
410
+					$value = TestContent::title(rand(10, 50));
411 411
 				}
412 412
 
413 413
 				break;
@@ -434,14 +434,14 @@  discard block
 block discarded – undo
434 434
 
435 435
 			case 'text_date':
436 436
 
437
-				$value = TestContent::date( 'm/d/Y' );
437
+				$value = TestContent::date('m/d/Y');
438 438
 
439 439
 				break;
440 440
 
441 441
 			case 'text_date_timestamp':
442 442
 			case 'text_datetime_timestamp':
443 443
 
444
-				$value = TestContent::date( 'U' );
444
+				$value = TestContent::date('U');
445 445
 
446 446
 				break;
447 447
 
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 
450 450
 			case 'text_money':
451 451
 
452
-				$value = rand( 0, 100000 );
452
+				$value = rand(0, 100000);
453 453
 
454 454
 				break;
455 455
 
456 456
 			case 'test_colorpicker':
457 457
 
458
-				$value = '#' . str_pad( dechex( mt_rand( 0, 0xFFFFFF ) ), 6, '0', STR_PAD_LEFT );
458
+				$value = '#'.str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
459 459
 
460 460
 				break;
461 461
 
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 			case 'radio':
473 473
 
474 474
 				// Grab a random item out of the array and return the key
475
-				$new_val = array_slice( $cmb['options'], rand( 0, count( $cmb['options'] ) ), 1 );
476
-				$value = key( $new_val );
475
+				$new_val = array_slice($cmb['options'], rand(0, count($cmb['options'])), 1);
476
+				$value = key($new_val);
477 477
 
478 478
 				break;
479 479
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			case 'checkbox':
485 485
 
486 486
 				// 50/50 odds of being turned on
487
-				if ( rand( 0, 1 ) == 1 ){
487
+				if (rand(0, 1) == 1) {
488 488
 					$value = 'on';
489 489
 				}
490 490
 
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
 				$new_option = array();
496 496
 
497 497
 				// Loop through each of our options
498
-				foreach ( $cmb['options'] as $key => $value ){
498
+				foreach ($cmb['options'] as $key => $value) {
499 499
 
500 500
 					// 50/50 chance of being included
501
-					if ( rand( 0, 1 ) ){
501
+					if (rand(0, 1)) {
502 502
 						$new_option[] = $key;
503 503
 					}
504 504
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 
517 517
 			case 'file':
518 518
 
519
-				$value = TestContent::image( $post_id );
519
+				$value = TestContent::image($post_id);
520 520
 
521 521
 				break;
522 522
 
@@ -531,19 +531,19 @@  discard block
 block discarded – undo
531 531
 		}
532 532
 
533 533
 		// Value must exist to attempt to insert
534
-		if ( !empty( $value ) && !is_wp_error( $value ) ){
534
+		if (!empty($value) && !is_wp_error($value)) {
535 535
 
536 536
 			// Files must be treated separately - they use the attachment ID
537 537
 			// & url of media for separate cmb values
538
-			if ( $cmb['type'] != 'file' ){
539
-				add_post_meta( $post_id, $cmb['id'], $value, true );
538
+			if ($cmb['type'] != 'file') {
539
+				add_post_meta($post_id, $cmb['id'], $value, true);
540 540
 			} else {
541
-				add_post_meta( $post_id, $cmb['id'].'_id', $value, true );
542
-				add_post_meta( $post_id, $cmb['id'], wp_get_attachment_url( $value ), true );
541
+				add_post_meta($post_id, $cmb['id'].'_id', $value, true);
542
+				add_post_meta($post_id, $cmb['id'], wp_get_attachment_url($value), true);
543 543
 			}
544 544
 
545 545
 		// If we're dealing with a WP Error object, just return the message for debugging
546
-		} elseif ( is_wp_error( $value ) ){
546
+		} elseif (is_wp_error($value)) {
547 547
 			return $value->get_error_message();
548 548
 		}
549 549
 
Please login to merge, or discard this patch.
includes/class-test-content.php 1 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
 
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 
352 352
 		);
353 353
 
354
-		for( $i = 1; $i < 6; $i++ ){
355
-			$content .= $random_content_types[rand( 0, 11 )];
354
+		for ($i = 1; $i < 6; $i++) {
355
+			$content .= $random_content_types[rand(0, 11)];
356 356
 		}
357 357
 
358 358
 		return $content;
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	 *
368 368
 	 * @return string Plain text paragraphs.
369 369
 	 */
370
-	public static function plain_text(){
370
+	public static function plain_text() {
371 371
 
372 372
 		$paragraphs = array(
373 373
 			'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.',
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 			'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.',
383 383
 		);
384 384
 
385
-		return $paragraphs[ rand( 0, 9 ) ];
385
+		return $paragraphs[rand(0, 9)];
386 386
 
387 387
 	}
388 388
 
@@ -398,45 +398,45 @@  discard block
 block discarded – undo
398 398
 	 * @param int $post_id Post ID.
399 399
 	 * @return mixed Attachment ID or WP Error.
400 400
 	 */
401
-	public static function image( $post_id ){
401
+	public static function image($post_id) {
402 402
 		$file_array = array();
403 403
 
404 404
 		// Get the image from the API
405 405
 		$url = self::get_image_link();
406 406
 
407 407
 		// If the returned string is empty or it's not a string, try again.
408
-		if ( empty( $url ) || !is_string( $url ) ){
408
+		if (empty($url) || !is_string($url)) {
409 409
 
410 410
 			// Try again
411 411
 			$url = self::get_image_link();
412 412
 
413 413
 			// If it fails again, just give up
414
-			if ( empty( $url ) || !is_string( $url ) ){
414
+			if (empty($url) || !is_string($url)) {
415 415
 				return;
416 416
 			}
417 417
 
418 418
 		}
419 419
 
420 420
 		// Download the file
421
-	    $tmp = \download_url( $url );
421
+	    $tmp = \download_url($url);
422 422
 
423
-	    preg_match( '/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches );
423
+	    preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches);
424 424
 
425
-        $file_array['name'] = basename( $matches[0] );
425
+        $file_array['name'] = basename($matches[0]);
426 426
         $file_array['tmp_name'] = $tmp;
427 427
 
428 428
 	    // Check for download errors
429
-	    if ( is_wp_error( $tmp ) ) {
430
-	        unlink( $file_array[ 'tmp_name' ] );
429
+	    if (is_wp_error($tmp)) {
430
+	        unlink($file_array['tmp_name']);
431 431
 	        return $tmp->get_error_message();
432 432
 	    }
433 433
 
434 434
 		// Pull the image into the media library
435
-	    $image_id = media_handle_sideload( $file_array, $post_id );
435
+	    $image_id = media_handle_sideload($file_array, $post_id);
436 436
 
437 437
 	    // Check for handle sideload errors.
438
-	    if ( is_wp_error( $image_id ) ) {
439
-	        unlink( $file_array['tmp_name'] );
438
+	    if (is_wp_error($image_id)) {
439
+	        unlink($file_array['tmp_name']);
440 440
 	        return $image_id->get_error_message();
441 441
 	    }
442 442
 
@@ -452,31 +452,31 @@  discard block
 block discarded – undo
452 452
 	 *
453 453
 	 * @return string Image URL.
454 454
 	 */
455
-	private static function get_image_link(){
455
+	private static function get_image_link() {
456 456
 
457 457
 		// cURL an image API for a completely random photo
458
-		$curl = curl_init( "http://www.splashbase.co/api/v1/images/random?images_only=true" );
458
+		$curl = curl_init("http://www.splashbase.co/api/v1/images/random?images_only=true");
459 459
 
460
-		curl_setopt( $curl, CURLOPT_RETURNTRANSFER, TRUE );
460
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
461 461
 
462
-		$curl_response = curl_exec( $curl );
462
+		$curl_response = curl_exec($curl);
463 463
 
464 464
 		// If our cURL failed
465
-		if ( $curl_response === false ) {
466
-		    $info = curl_getinfo( $curl );
467
-		    curl_close( $curl );
468
-		    die( 'error occured during curl exec. Additional info: ' . var_export( $info ) );
465
+		if ($curl_response === false) {
466
+		    $info = curl_getinfo($curl);
467
+		    curl_close($curl);
468
+		    die('error occured during curl exec. Additional info: '.var_export($info));
469 469
 		}
470 470
 
471
-		curl_close( $curl );
471
+		curl_close($curl);
472 472
 
473 473
 		// Decode the data
474
-		$response = json_decode( $curl_response, true );
474
+		$response = json_decode($curl_response, true);
475 475
 
476 476
 		// Check to make sure that the return contains a valid image extensions
477 477
 		preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $response['url'], $matches);
478 478
 
479
-		if ( !empty( $matches ) ){
479
+		if (!empty($matches)) {
480 480
 			return $response['url'];
481 481
 		}
482 482
 
@@ -491,10 +491,10 @@  discard block
 block discarded – undo
491 491
 	 * @param string $format PHP Date format.
492 492
 	 * @return mixed Date in the format requested.
493 493
 	 */
494
-	public static function date( $format ){
494
+	public static function date($format) {
495 495
 
496
-		$num_days = rand( 1, 60 );
497
-		return date( $format, strtotime( " +$num_days days" ) );
496
+		$num_days = rand(1, 60);
497
+		return date($format, strtotime(" +$num_days days"));
498 498
 
499 499
 	}
500 500
 
@@ -506,19 +506,19 @@  discard block
 block discarded – undo
506 506
 	 *
507 507
 	 * @return string Time string
508 508
 	 */
509
-	public static function time(){
509
+	public static function time() {
510 510
 
511 511
 		$times = array(
512 512
 			'8:00 am',
513 513
 			'5:00PM',
514 514
 			'13:00',
515 515
 			'2015',
516
-			date( 'G:i', strtotime( " +".rand( 4, 24 )." hours" ) ),
517
-			date( 'g:i', strtotime( " +".rand( 4, 24 )." hours" ) ),
518
-			date( 'G:i A', strtotime( " +".rand( 4, 24 )." hours" ) )
516
+			date('G:i', strtotime(" +".rand(4, 24)." hours")),
517
+			date('g:i', strtotime(" +".rand(4, 24)." hours")),
518
+			date('G:i A', strtotime(" +".rand(4, 24)." hours"))
519 519
 		);
520 520
 
521
-		return $times[ rand( 0, 6 ) ];
521
+		return $times[rand(0, 6)];
522 522
 
523 523
 	}
524 524
 
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 *
531 531
 	 * @return string Timezone
532 532
 	 */
533
-	public static function timezone(){
533
+	public static function timezone() {
534 534
 
535 535
 		$timezones = array(
536 536
 			'America/Denver',
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 			'UTC'
549 549
 		);
550 550
 
551
-		return $timezones[ rand( 0, 12 ) ];
551
+		return $timezones[rand(0, 12)];
552 552
 
553 553
 	}
554 554
 
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 	 *
562 562
 	 * @return string Phone #.
563 563
 	 */
564
-	public static function phone(){
564
+	public static function phone() {
565 565
 
566 566
 		$phone_numbers = array(
567 567
 			'7203893101',
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 			'+43 780 0047112'
578 578
 		);
579 579
 
580
-		return $phone_numbers[ rand( 0, 10 ) ];
580
+		return $phone_numbers[rand(0, 10)];
581 581
 
582 582
 	}
583 583
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 	 *
590 590
 	 * @return string Email address.
591 591
 	 */
592
-	public static function email(){
592
+	public static function email() {
593 593
 
594 594
 		$email_addresses = array(
595 595
 			'[email protected]',
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 			'[email protected]'
603 603
 		);
604 604
 
605
-		return $email_addresses[ rand( 0, 7 ) ];
605
+		return $email_addresses[rand(0, 7)];
606 606
 
607 607
 	}
608 608
 
@@ -616,12 +616,12 @@  discard block
 block discarded – undo
616 616
 	 *
617 617
 	 * @return string URL.
618 618
 	 */
619
-	public static function link(){
619
+	public static function link() {
620 620
 
621 621
 		$links = array(
622 622
 			'http://google.com',
623 623
 			'https://www.twitter.com',
624
-			site_url( '/?iam=anextravariable' ),
624
+			site_url('/?iam=anextravariable'),
625 625
 			'github.com',
626 626
 			'http://filebase.com',
627 627
 			'www.oldtownmediainc.com',
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			'https://www.eff.org'
630 630
 		);
631 631
 
632
-		return $links[ rand( 0, 7 ) ];
632
+		return $links[rand(0, 7)];
633 633
 
634 634
 	}
635 635
 
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	 *
641 641
 	 * @return string URL.
642 642
 	 */
643
-	public static function oembed(){
643
+	public static function oembed() {
644 644
 
645 645
 		$links = array(
646 646
 			'https://www.youtube.com/watch?v=A85-YQsm6pY',
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 			'https://www.instagram.com/p/-eyLo0RMfX',
652 652
 		);
653 653
 
654
-		return $links[ rand( 0, 5 ) ];
654
+		return $links[rand(0, 5)];
655 655
 
656 656
 	}
657 657
 
@@ -665,10 +665,10 @@  discard block
 block discarded – undo
665 665
 	 * @param	string $type Video service to get link from
666 666
 	 * @return	string URL.
667 667
 	 */
668
-	public static function video( $type ){
668
+	public static function video($type) {
669 669
 
670 670
 		// Switch through our video types. Expecting to add more in the future
671
-		switch( $type ){
671
+		switch ($type) {
672 672
 
673 673
 			// YouTube videos
674 674
 			case 'youtube' :
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 
710 710
 		}
711 711
 
712
-		return $links[ rand( 0, 8 ) ];
712
+		return $links[rand(0, 8)];
713 713
 
714 714
 	}
715 715
 
Please login to merge, or discard this patch.
includes/class-admin-page.php 1 patch
Spacing   +72 added lines, -72 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
 	 * file
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @see admin_menu, wp_ajax actions
28 28
 	 */
29
-	public function hooks( $file ){
29
+	public function hooks($file) {
30 30
 
31 31
 		$this->file = $file;
32 32
 
33
-		add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
34
-		add_action( 'admin_menu' , array( $this, 'add_menu_item' ) );
35
-		add_action( 'wp_ajax_handle_test_data', array( $this, 'handle_test_data_callback' ) );
36
-		add_filter( 'plugin_action_links_' . plugin_basename( $file ) , array( $this, 'add_settings_link' ) );
37
-		add_action( 'admin_notices', array( $this, 'internet_connected_admin_notice' ) );
33
+		add_action('plugins_loaded', array($this, 'load_textdomain'));
34
+		add_action('admin_menu', array($this, 'add_menu_item'));
35
+		add_action('wp_ajax_handle_test_data', array($this, 'handle_test_data_callback'));
36
+		add_filter('plugin_action_links_'.plugin_basename($file), array($this, 'add_settings_link'));
37
+		add_action('admin_notices', array($this, 'internet_connected_admin_notice'));
38 38
 
39 39
 	}
40 40
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @see load_plugin_textdomain
46 46
 	 */
47 47
 	public function load_textdomain() {
48
-	    load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->file ) ) . '/languages/' );
48
+	    load_plugin_textdomain('otm-test-content', FALSE, basename(dirname($this->file)).'/languages/');
49 49
 	}
50 50
 
51 51
 
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
 
59 59
 		$page = add_submenu_page(
60 60
 			'tools.php',
61
-			__( 'Create Test Content', 'otm-test-content' ),
62
-			__( 'Test Content', 'otm-test-content' ),
61
+			__('Create Test Content', 'otm-test-content'),
62
+			__('Test Content', 'otm-test-content'),
63 63
 			'manage_options',
64 64
 			'create-test-data',
65
-			array( $this, 'admin_page' )
65
+			array($this, 'admin_page')
66 66
 		);
67 67
 
68
-		add_action( 'admin_print_styles-' . $page, array( $this, 'load_scripts' ) );
68
+		add_action('admin_print_styles-'.$page, array($this, 'load_scripts'));
69 69
 
70 70
 	}
71 71
 
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	 * @param  array $links Existing links
76 76
 	 * @return array 		Modified links
77 77
 	 */
78
-	public function add_settings_link( $links ) {
78
+	public function add_settings_link($links) {
79 79
 
80
-		$settings_link = '<a href="tools.php?page=create-test-data">' . __( 'Build Test Content', 'otm-test-content' ) . '</a>';
81
-  		array_push( $links, $settings_link );
80
+		$settings_link = '<a href="tools.php?page=create-test-data">'.__('Build Test Content', 'otm-test-content').'</a>';
81
+  		array_push($links, $settings_link);
82 82
   		return $links;
83 83
 
84 84
 	}
@@ -91,24 +91,24 @@  discard block
 block discarded – undo
91 91
 	 * Internet, and the test fails displays a notice informing the user that
92 92
 	 * images will not pull into test data.
93 93
 	 */
94
-	public function internet_connected_admin_notice(){
94
+	public function internet_connected_admin_notice() {
95 95
 
96 96
 		// Get the current admin screen & verify that we're on the right one
97 97
 		// before continuing.
98 98
 		$screen = get_current_screen();
99 99
 
100
-		if ( $screen->base != 'tools_page_create-test-data' ){
100
+		if ($screen->base != 'tools_page_create-test-data') {
101 101
 			return;
102 102
 		}
103 103
 
104 104
 		// Check the response
105
-		if ( $this->test_splashbase_api() ) {
105
+		if ($this->test_splashbase_api()) {
106 106
 			// We got a response so early return
107 107
 			return;
108 108
 		} else {
109 109
 			// We didn't get a reponse so print the notice out
110 110
 			echo '<div class="notice notice-error is-dismissible">';
111
-		        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>';
111
+		        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>';
112 112
 		    echo '</div>';
113 113
 		}
114 114
 
@@ -131,30 +131,30 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return boolean Status of connection to Splashbase.
133 133
 	 */
134
-	private function test_splashbase_api(){
134
+	private function test_splashbase_api() {
135 135
 
136 136
 		/*
137 137
 		 * Test #1 - Check Internet connection in general
138 138
 		 */
139 139
 		// Attempt to open a socket connection to Google
140
-		$connected = @fsockopen( "www.google.com", 80 );
140
+		$connected = @fsockopen("www.google.com", 80);
141 141
 
142
-		if ( !$connected ){
142
+		if (!$connected) {
143 143
 			return false;
144 144
 		}
145 145
 
146 146
 		// Close out our 1st test
147
-		fclose( $connected );
147
+		fclose($connected);
148 148
 
149 149
 
150 150
 		/*
151 151
 		 * Test #2 - Check for Airplane Mode plugin status
152 152
 		 */
153
-		if ( class_exists( 'Airplane_Mode_Core' ) ){
153
+		if (class_exists('Airplane_Mode_Core')) {
154 154
 			// Is airplane mode active?
155
-			$airplane_mode = get_site_option( 'airplane-mode' );
155
+			$airplane_mode = get_site_option('airplane-mode');
156 156
 
157
-			if ( $airplane_mode === 'on' ){
157
+			if ($airplane_mode === 'on') {
158 158
 				return false;
159 159
 			}
160 160
 		}
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 		 * Test #3 - Check Splashbase itself
165 165
 		 */
166 166
 		$test_url = 'http://www.splashbase.co/api/v1/images/';
167
-		$response = wp_remote_get( $test_url );
167
+		$response = wp_remote_get($test_url);
168 168
 
169
-		if ( !is_array( $response ) ){
169
+		if (!is_array($response)) {
170 170
 			return false;
171 171
 		}
172 172
 
@@ -179,19 +179,19 @@  discard block
 block discarded – undo
179 179
 	/**
180 180
 	 * Load our script in the admin section and serve in data.
181 181
 	 */
182
-	public function load_scripts(){
182
+	public function load_scripts() {
183 183
 
184
-		wp_enqueue_script( 'test-content-js', plugins_url( 'assets/admin.js' , dirname( __FILE__ ) ) );
185
-		wp_enqueue_style( 'test-content-css', plugins_url( 'assets/admin.css' , dirname( __FILE__ ) ) );
184
+		wp_enqueue_script('test-content-js', plugins_url('assets/admin.js', dirname(__FILE__)));
185
+		wp_enqueue_style('test-content-css', plugins_url('assets/admin.css', dirname(__FILE__)));
186 186
 
187 187
 		$data = array(
188
-			'nonce'			=> wp_create_nonce( 'handle-test-data' ),
189
-			'createdStr'	=> __( 'Created', 'otm-test-content' ),
190
-			'deletedStr'	=> __( 'Deleting', 'otm-test-content' ),
191
-			'creatingStr'	=> __( 'Creating', 'otm-test-content' ),
188
+			'nonce'			=> wp_create_nonce('handle-test-data'),
189
+			'createdStr'	=> __('Created', 'otm-test-content'),
190
+			'deletedStr'	=> __('Deleting', 'otm-test-content'),
191
+			'creatingStr'	=> __('Creating', 'otm-test-content'),
192 192
 		);
193 193
 
194
-		wp_localize_script( 'test-content-js', 'test_content', $data );
194
+		wp_localize_script('test-content-js', 'test_content', $data);
195 195
 
196 196
 	}
197 197
 
@@ -203,21 +203,21 @@  discard block
 block discarded – undo
203 203
 	 */
204 204
 	public function handle_test_data_callback() {
205 205
 
206
-		$action		= $_REQUEST['todo'];
207
-		$nonce		= $_REQUEST['nonce'];
206
+		$action = $_REQUEST['todo'];
207
+		$nonce = $_REQUEST['nonce'];
208 208
 
209 209
 		// Verify that we have a proper logged in user and it's the right person
210
-		if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'handle-test-data' ) ){
210
+		if (empty($nonce) || !wp_verify_nonce($nonce, 'handle-test-data')) {
211 211
 			return;
212 212
 		}
213 213
 
214
-		if ( $action == 'delete' ){
214
+		if ($action == 'delete') {
215 215
 
216
-			$this->deletion_routing( $_REQUEST );
216
+			$this->deletion_routing($_REQUEST);
217 217
 
218
-		} elseif ( $action == 'create' ){
218
+		} elseif ($action == 'create') {
219 219
 
220
-			$this->creation_routing( $_REQUEST );
220
+			$this->creation_routing($_REQUEST);
221 221
 
222 222
 		}
223 223
 
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
 	 * Choose which type of creation needs to be accomplished and route through
231 231
 	 * the correct class.
232 232
 	 */
233
-	private function creation_routing( $data ){
233
+	private function creation_routing($data) {
234 234
 
235
-		if ( $data['type'] == 'post' ){
235
+		if ($data['type'] == 'post') {
236 236
 
237 237
 			$create_content = new CreatePost;
238
-			$create_content->create_post_type_content( $data['slug'], true, 1 );
238
+			$create_content->create_post_type_content($data['slug'], true, 1);
239 239
 
240
-		} elseif( $data['type'] == 'term' ){
240
+		} elseif ($data['type'] == 'term') {
241 241
 
242 242
 			$create_content = new CreateTerm;
243
-			$create_content->create_terms( $data['slug'], true, 1 );
243
+			$create_content->create_terms($data['slug'], true, 1);
244 244
 
245 245
 		}
246 246
 
@@ -251,17 +251,17 @@  discard block
 block discarded – undo
251 251
 	 * Choose which type of deletion needs to be accomplished and route through
252 252
 	 * the correct method of Delete.
253 253
 	 */
254
-	private function deletion_routing( $data ){
254
+	private function deletion_routing($data) {
255 255
 
256 256
 		$delete_content = new Delete;
257 257
 
258
-		if ( $data['type'] == 'post' ){
258
+		if ($data['type'] == 'post') {
259 259
 
260
-			$delete_content->delete_posts( $data['slug'], true );
260
+			$delete_content->delete_posts($data['slug'], true);
261 261
 
262
-		} elseif ( $data['type'] == 'term' ){
262
+		} elseif ($data['type'] == 'term') {
263 263
 
264
-			$delete_content->delete_terms( $data['slug'], true );
264
+			$delete_content->delete_terms($data['slug'], true);
265 265
 
266 266
 		}
267 267
 
@@ -271,35 +271,35 @@  discard block
 block discarded – undo
271 271
 	/**
272 272
 	 * Print out our admin page to control test data.
273 273
 	 */
274
-	public function admin_page(){
274
+	public function admin_page() {
275 275
 
276 276
 		$html = "";
277 277
 
278
-		$html .= '<div class="wrap" id="options_editor">' . "\n";
278
+		$html .= '<div class="wrap" id="options_editor">'."\n";
279 279
 
280
-			$html .= '<h2>' . __( 'Create Test Data' , 'otm-test-content' ) . '</h2>' . "\n";
280
+			$html .= '<h2>'.__('Create Test Data', 'otm-test-content').'</h2>'."\n";
281 281
 
282 282
 			// Loop through all other cpts
283
-			$post_types = get_post_types( array( 'public' => true ), 'objects' );
283
+			$post_types = get_post_types(array('public' => true), 'objects');
284 284
 
285 285
 			$html .= "<div>";
286 286
 
287 287
 			$html .= "<div class='test-data-cpt'>";
288 288
 				$html .= "<h3>";
289
-					$html .= "<span class='label'>".__( 'Quantity', 'otm-test-content' )."</span>";
290
-					$html .= "<input type='number' value='0' id='quantity-adjustment'> <small><i>".__( 'Set to 0 to keep random', 'otm-test-content' )."</i></small>";
289
+					$html .= "<span class='label'>".__('Quantity', 'otm-test-content')."</span>";
290
+					$html .= "<input type='number' value='0' id='quantity-adjustment'> <small><i>".__('Set to 0 to keep random', 'otm-test-content')."</i></small>";
291 291
 				$html .= "</h3>";
292 292
 			$html .= "</div>";
293 293
 
294 294
 			// Loop through every post type available on the site
295
-			foreach ( $post_types as $post_type ) {
295
+			foreach ($post_types as $post_type) {
296 296
 
297 297
 				$skipped_cpts = array(
298 298
 					'attachment'
299 299
 				);
300 300
 
301 301
 				// Skip banned cpts
302
-				if ( in_array( $post_type->name, $skipped_cpts ) ){
302
+				if (in_array($post_type->name, $skipped_cpts)) {
303 303
 					continue;
304 304
 				}
305 305
 
@@ -308,38 +308,38 @@  discard block
 block discarded – undo
308 308
 					// Create row for the post/page/cpt
309 309
 					$html .= "<h3>";
310 310
 
311
-						$html .= "<span class='label'>" . $post_type->labels->name . "</span>";
312
-						$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>";
313
-						$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>";
311
+						$html .= "<span class='label'>".$post_type->labels->name."</span>";
312
+						$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>";
313
+						$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>";
314 314
 
315 315
 					$html .= "</h3>";
316 316
 
317 317
 					// Create row for each taxonomy associated with the post/page/cpt
318
-					$taxonomies = get_object_taxonomies( $post_type->name );
318
+					$taxonomies = get_object_taxonomies($post_type->name);
319 319
 
320
-						if ( !empty( $taxonomies ) ){
320
+						if (!empty($taxonomies)) {
321 321
 
322
-							foreach( $taxonomies as $tax ){
322
+							foreach ($taxonomies as $tax) {
323 323
 
324 324
 								$html .= "<h3 class='term-box'>";
325 325
 
326 326
 								$skipped_taxonomies = array(
327
-									'post_format',				// We shouldn't be making random post format classes
327
+									'post_format', // We shouldn't be making random post format classes
328 328
 									'product_shipping_class'	// These aren't used visually and are therefore skipped
329 329
 								);
330 330
 
331 331
 								// Skip banned taxonomies
332
-								if ( in_array( $tax, $skipped_taxonomies ) ){
332
+								if (in_array($tax, $skipped_taxonomies)) {
333 333
 									continue;
334 334
 								}
335 335
 
336
-								$taxonomy = get_taxonomy( $tax );
336
+								$taxonomy = get_taxonomy($tax);
337 337
 
338 338
 								$html .= "<span class='label'>".$taxonomy->labels->name."</span>";
339 339
 
340
-								$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>";
340
+								$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>";
341 341
 
342
-								$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>";
342
+								$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>";
343 343
 
344 344
 								$html .= "</h3>";
345 345
 
Please login to merge, or discard this patch.