Completed
Push — master ( e1139d...01ce3b )
by Mike
02:22
created

Plugin   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A get_definitions() 0 3 1
A set_definitions() 0 6 1
A register_hooks() 0 10 2
A load_textdomain() 0 3 1
1
<?php
2
namespace testContent;
3
4
/**
5
 * Class to load hooks and set/get base plugin definitions.
6
 *
7
 * @package    WordPress
8
 * @subpackage Evans
9
 * @author     Old Town Media
10
 */
11
class Plugin{
12
13
	/**
14
	 * Plugin definitions.
15
	 *
16
	 * @var object
17
	 */
18
	protected $definitions;
19
20
21
	/**
22
	 * Retrieve the plugin definitions from the main plugin directory.
23
	 *
24
	 * @return object Defitions
25
	 */
26
	public function get_definitions() {
27
		return $this->definitions;
28
	}
29
30
31
	/**
32
	 * Set the plugin definitions.
33
	 *
34
	 * @param  object $definitions Information about the plugin
35
	 * @return object $this
36
	 */
37
	public function set_definitions( $definitions ) {
38
39
		$this->definitions = $definitions;
40
		return $this;
41
42
	}
43
44
45
	/**
46
	 * Register hook function.
47
	 *
48
	 * @param  object $provider Hook provider.
49
	 * @return object $this
50
	 */
51
	public function register_hooks( $provider ) {
52
53
		if ( method_exists( $provider, 'set_plugin' ) ) {
54
			$provider->set_plugin( $this );
55
		}
56
57
		$provider->hooks();
58
		return $this;
59
60
	}
61
62
	/**
63
	 * Load the textdomain for this plugin if translation is available
64
	 *
65
	 * @see load_plugin_textdomain
66
	 */
67
	public function load_textdomain() {
68
	    load_plugin_textdomain( 'otm-test-content', FALSE, basename( dirname( $this->definitions->file ) ) . '/languages/' );
69
	}
70
71
}
72