Completed
Push — master ( 84cd3f...1a4147 )
by Leon
01:15
created

Discontinued_Products   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 62
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 3
A woocommerce_loaded() 0 8 1
A plugins_loaded() 0 7 1
A include_template_functions() 0 4 1
1
<?php
2
/**
3
 * Discontinued_Products Class.
4
 *
5
 * @package woocommerce
6
 * @since 1.1.7
7
 */
8
9
if ( ! class_exists( 'Discontinued_Products' ) ) {
10
11
	/**
12
	 * The main WooCommerce Discontinued Products Class.
13
	 * Check if WooCommerce is active, load functions and other files.
14
	 *
15
	 * @since 1.0.0
16
	 */
17
	class Discontinued_Products {
18
19
		/**
20
		 * Inititiate the Discontinued_Products Class.
21
		 *
22
		 * @since 1.0.0
23
		 */
24
		public function __construct() {
25
			// Called only after woocommerce has finished loading.
26
			add_action( 'woocommerce_init', array( $this, 'woocommerce_loaded' ) );
27
			// Called after all plugins have loaded.
28
			add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
29
30
			// Called just before the woocommerce template functions are included.
31
			add_action( 'init', array( $this, 'include_template_functions' ), 20 );
32
33
			// Indicates we are running the admin.
34
			if ( is_admin() ) {
35
				is_admin();
36
			}
37
38
			// Indicates we are being served over ssl.
39
			if ( is_ssl() ) {
40
				is_ssl();
41
			}
42
43
			// Take care of anything else that needs to be done immediately upon plugin instantiation, here in the constructor.
44
		}
45
46
		/**
47
		 * Take care of anything that needs woocommerce to be loaded.
48
		 * For instance, if you need access to the $woocommerce global
49
		 */
50
		public function woocommerce_loaded() {
51
52
			include DP_PATH . 'includes/class-dp-csv-import-export.php';
53
			include DP_PATH . 'includes/class-dp-discontinued-product.php';
54
			include DP_PATH . 'includes/class-dp-settings.php';
55
			include DP_PATH . 'includes/class-dp-shortcode-discontinued.php';
56
			include DP_PATH . 'includes/class-dp-taxonomy.php';
57
		}
58
59
		/**
60
		 * Take care of anything that needs all plugins to be loaded
61
		 */
62
		public function plugins_loaded() {
63
64
			/**
65
			 * Localisation
66
			 */
67
			load_plugin_textdomain( 'discontinued-products', false, dirname( plugin_basename( __FILE__ ) ) . '/' );
68
		}
69
70
		/**
71
		 * Override any of the template functions from woocommerce/woocommerce-template.php
72
		 * with our own template functions file
73
		 */
74
		public function include_template_functions() {
75
76
			include DP_PATH . 'woocommerce-template.php';
77
		}
78
	}
79
}
80