-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathedd-sale-price.php
141 lines (118 loc) · 2.63 KB
/
edd-sale-price.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* Plugin Name: EDD Sale Price
* Plugin URI: https://jeroensormani.com
* Description: Put your digital products on sale.
* Version: 1.0.5.2
* Author: Jeroen Sormani
* Author URI: https://jeroensormani.com/
* Text Domain: edd-sale-price
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Class EDD_Sale_Price.
*
* Main EDD_Sale_Price class initializes the plugin.
*
* @class EDD_Sale_Price
* @version 1.0.0
* @author Jeroen Sormani
*/
class EDD_Sale_Price {
/**
* Plugin version.
*
* @since 1.0.0
* @var string $version Plugin version number.
*/
public $version = '1.0.5.2';
/**
* Plugin file.
*
* @since 1.0.0
* @var string $file Plugin file path.
*/
public $file = __FILE__;
/**
* Instance of EDD_Sale_Price.
*
* @since 1.0.0
* @access private
* @var object $instance The instance of EDD_Sale_Price.
*/
private static $instance;
public EDDSP_Sale_Price $price;
public EDDSP_Admin_Product $admin_product;
/**
* Construct.
*
* Initialize the class and plugin.
*
* @since 1.0.0
*/
public function __construct() {
$this->init();
}
/**
* Instance.
*
* An global instance of the class. Used to retrieve the instance
* to use on other files/plugins/themes.
*
* @since 1.0.0
* @return object Instance of the class.
*/
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Init.
*
* Initialize plugin parts.
*
* @since 1.0.0
*/
public function init() {
// Load textdomain
$this->load_textdomain();
/**
* Sale price class
*/
require_once plugin_dir_path( __FILE__ ) . '/includes/class-eddsp-sale-price.php';
$this->price = new EDDSP_Sale_Price();
if ( is_admin() ) {
require_once plugin_dir_path( __FILE__ ) . '/includes/admin/class-eddsp-admin-product.php';
$this->admin_product = new EDDSP_Admin_Product();
}
}
/**
* Textdomain.
*
* Load the textdomain based on WP language.
*
* @since 1.0.0
*/
public function load_textdomain() {
load_plugin_textdomain( 'edd-sale-price', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
}
if ( ! function_exists( 'EDD_Sale_Price' ) ) {
/**
* The main function responsible for returning the EDD_Sale_Price object.
*
* Use this function like you would a global variable, except without needing to declare the global.
*
* Example: <?php EDD_Sale_Price()->method_name(); ?>
*
* @since 1.0.0
*
* @return object EDD_Sale_Price class object.
*/
function EDD_Sale_Price() {
return EDD_Sale_Price::instance();
}
}
EDD_Sale_Price();