Posts   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 48
rs 10
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B actions_section() 0 33 3
1
<?php
2
namespace testContent\Views;
3
use testContent\Abstracts as Abs;
4
5
/**
6
 * Generate view for creating and deleting posts.
7
 *
8
 * @abstract
9
 * @package    WordPress
10
 * @subpackage Test Content
11
 * @author     Old Town Media
12
 */
13
class Posts extends Abs\View{
14
15
	protected $title	= 'Posts';
16
	protected $type		= 'post';
17
	protected $priority	= 1;
18
19
	/**
20
	 * Our sections action block - button to create and delete.
21
	 *
22
	 * @access protected
23
	 *
24
	 * @return string HTML content.
25
	 */
26
	protected function actions_section(){
27
		$html = '';
28
29
		// Loop through every post type available on the site
30
		$post_types = get_post_types( array( 'public' => true ), 'objects' );
31
32
		foreach ( $post_types as $post_type ) :
33
34
			$skipped_cpts = array(
35
				'attachment'
36
			);
37
38
			// Skip banned cpts
39
			if ( in_array( $post_type->name, $skipped_cpts ) ){
40
				continue;
41
			}
42
43
			$html .= "<div class='test-data-cpt'>";
44
45
				$html .= "<h3>";
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' ) );
50
51
				$html .= "</h3>";
52
53
			$html .= "</div>";
54
55
		endforeach;
56
57
		return $html;
58
	}
59
60
}
61