Completed
Push — feature/codesniffer-fixes ( c7a4f1...41059d )
by Scott Kingsley
13:22
created

Pods_Table_Storage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 14 3
A add_pod_type() 0 6 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 25 and the first side effect is on line 19.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Name: Table Storage
4
 *
5
 * Description: Enable a custom database table for your custom fields on Post Types, Media, Taxonomies, Users, and
6
 * Comments.
7
 *
8
 * Version: 2.3
9
 *
10
 * Category: Advanced
11
 *
12
 * Tableless Mode: No
13
 *
14
 * @package    Pods\Components
15
 * @subpackage Advanced Content Types
16
 */
17
18
if ( class_exists( 'Pods_Table_Storage' ) ) {
19
	return;
20
}
21
22
/**
23
 * Class Pods_Table_Storage
24
 */
25
class Pods_Table_Storage extends PodsComponent {
26
27
	/**
28
	 * {@inheritdoc}
29
	 */
30
	public function init() {
31
32
		if ( ! pods_tableless() ) {
33
			add_filter( 'pods_admin_setup_add_create_storage', '__return_true' );
34
			add_filter( 'pods_admin_setup_add_create_taxonomy_storage', '__return_true' );
35
36
			add_filter( 'pods_admin_setup_add_extend_storage', '__return_true' );
37
			add_filter( 'pods_admin_setup_add_extend_taxonomy_storage', '__return_true' );
38
39
			if ( ! function_exists( 'get_term_meta' ) ) {
40
				add_filter( 'pods_admin_setup_add_extend_pod_type', array( $this, 'add_pod_type' ) );
41
			}
42
		}
43
	}
44
45
	/**
46
	 * Enable Taxonomy extending option in setup-add.php
47
	 *
48
	 * @param array $data Pod Type options
49
	 *
50
	 * @return array
51
	 */
52
	public function add_pod_type( $data ) {
53
54
		$data['taxonomy'] = __( 'Taxonomies (Categories, Tags, etc..)', 'pods' );
55
56
		return $data;
57
	}
58
59
}
60