Terms::actions_section()   B
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 37
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 20
nc 3
nop 0
dl 0
loc 37
rs 8.8571
c 0
b 0
f 0
1
<?php
2
namespace DummyPress\Views;
3
use DummyPress\Abstracts as Abs;
4
5
/**
6
 * Generate view for creating and deleting terms.
7
 *
8
 * @abstract
9
 * @package    WordPress
10
 * @subpackage Test Content
11
 * @author     Mike Selander
12
 */
13
class Terms extends Abs\View {
14
15
	public function __construct() {
16
17
		$this->title	= __( 'Terms', 'dummybot' );
18
		$this->type		= 'term';
19
		$this->priority	= 2;
20
21
	}
22
23
24
	/**
25
	 * Our sections action block - button to create and delete.
26
	 *
27
	 * @access protected
28
	 *
29
	 * @return string HTML content.
30
	 */
31
	protected function actions_section() {
32
		$html = '';
33
34
		$taxonomies = get_taxonomies();
35
36
		foreach ( $taxonomies as $tax ) :
37
38
			$skipped_taxonomies = array(
39
				'post_format',				// We shouldn't be making random post format classes
40
				'product_shipping_class',	// These aren't used visually and are therefore skipped
41
				'nav_menu',					// Menus are handled seperately of taxonomies
42
			);
43
44
			// Skip banned taxonomies
45
			if ( in_array( $tax, $skipped_taxonomies ) ) {
46
				continue;
47
			}
48
49
			$taxonomy = get_taxonomy( $tax );
50
51
			$html .= "<div class='test-data-cpt'>";
52
53
				$html .= "<h3>";
54
55
				$html .= "<span class='label'>" . esc_html( $taxonomy->labels->name ) . "</span>";
56
57
				$html .= $this->build_button( 'create', $tax, __( 'Create', 'dummybot' ) . " " . $taxonomy->labels->name );
58
				$html .= $this->build_button( 'delete', $tax, __( 'Delete', 'dummybot' ) . " " . $taxonomy->labels->name );
59
60
				$html .= "</h3>";
61
62
			$html .= "</div>";
63
64
		endforeach;
65
66
		return $html;
67
	}
68
69
}
70