Completed
Push — master ( ef04cf...199149 )
by Mike
02:19
created

Posts::actions_section()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 33
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 17
c 2
b 0
f 0
nc 3
nop 0
dl 0
loc 33
rs 8.8571
1
<?php
2
namespace testContent\Views;
3
4
/**
5
 * Generate view for creating and deleting posts.
6
 *
7
 * @abstract
8
 * @package    WordPress
9
 * @subpackage Test Content
10
 * @author     Old Town Media
11
 */
12
class Posts extends View{
13
14
	protected $title	= 'Posts';
15
	protected $type		= 'post';
16
	protected $priority	= 1;
17
18
	/**
19
	 * Our sections action block - button to create and delete.
20
	 *
21
	 * @access protected
22
	 *
23
	 * @return string HTML content.
24
	 */
25
	protected function actions_section(){
26
		$html = '';
27
28
		// Loop through every post type available on the site
29
		$post_types = get_post_types( array( 'public' => true ), 'objects' );
30
31
		foreach ( $post_types as $post_type ) :
32
33
			$skipped_cpts = array(
34
				'attachment'
35
			);
36
37
			// Skip banned cpts
38
			if ( in_array( $post_type->name, $skipped_cpts ) ){
39
				continue;
40
			}
41
42
			$html .= "<div class='test-data-cpt'>";
43
44
				$html .= "<h3>";
45
46
					$html .= "<span class='label'>" . $post_type->labels->name . "</span>";
47
					$html .= $this->build_button( 'create', $post_type->name, __( 'Create Test Data', 'otm-test-content' ) );
48
					$html .= $this->build_button( 'delete', $post_type->name, __( 'Delete Test Data', 'otm-test-content' ) );
49
50
				$html .= "</h3>";
51
52
			$html .= "</div>";
53
54
		endforeach;
55
56
		return $html;
57
	}
58
59
}
60