-
Notifications
You must be signed in to change notification settings - Fork 0
/
edd-recent-purchases.php
126 lines (107 loc) · 3.87 KB
/
edd-recent-purchases.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
<?php
/**
* Plugin Name: Easy Digital Downloads - Recent Purchases
* Plugin URI: https://wordpress.org/plugins/edd-recent-purchases
* Description: Create and show easy digital downloads recent purchases
* Version: 1.0
* Author: Wow-Company
* Author URI: https://wow-estore.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: edd-recent-purchases
*/
if ( ! defined( 'WPINC' ) ) {die;}
// Declaration Wow-Company class
if( !class_exists( 'Wow_Company' )) {
require_once plugin_dir_path( __FILE__ ) . 'asset/class-wow-company.php';
}
// Uninstall plugin
register_uninstall_hook( __FILE__, array( 'EDD_RECENT_PURCHASES', 'uninstall' ) );
final class EDD_RECENT_PURCHASES {
private static $instance;
const PREF = 'edd_recent_purchases';
public static function uninstall() {
delete_option( self::PREF );
}
/**
* Main Instance.
*
* Insures that only one instance of EDD_RECENT_PURCHASES exists in memory at any one
* time. Also prevents needing to define globals all over the place.
*
* @since 1.0
* @static
* @staticvar array $instance
* @uses EDD_RECENT_PURCHASES::includes() Include the required files.
* @return object|EDD_RECENT_PURCHASES The one true EDD_RECENT_PURCHASES
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof EDD_RECENT_PURCHASES ) ) {
$arg = array(
'plugin_name' => 'EDD Recent Purchases',
'plugin_menu' => 'EDD Recent Purchases',
'plugin_home_url' => 'edd-recent-purchases',
'version' => '1.0',
'base_file' => basename(__FILE__),
'slug' => dirname(plugin_basename(__FILE__)),
'plugin_dir' => plugin_dir_path( __FILE__ ),
'plugin_url' => plugin_dir_url( __FILE__ ),
'pref' => self::PREF,
'shortcode' => 'EDD-Recent-Purchases',
);
self::$instance = new EDD_RECENT_PURCHASES;
add_action( 'wp_enqueue_scripts', array(self::$instance, 'style' ) );
self::$instance->includes();
self::$instance->adminlinks = new WOW_EDD_RECENT_PURCHASES_ADMIN_LINKS($arg);
self::$instance->admin = new WOW_EDD_RECENT_PURCHASES_ADMIN($arg);
self::$instance->shortcode = new WOW_EDD_RECENT_PURCHASES_SHORTCODE($arg);
self::$instance->widget = new WOW_EDD_RECENT_PURCHASES_WIDGET();
}
return self::$instance;
}
function style(){
wp_enqueue_style( 'wow-edd-style', plugins_url('public/css/style.css', __FILE__) );
}
/**
* Throw error on object clone.
*
* The whole idea of the singleton design pattern is that there is a single
* object therefore, we don't want the object to be cloned.
*
* @since 1.0
* @access protected
* @return void
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'edd-recent-purchases' ), '1.0' );
}
/**
* Disable unserializing of the class.
*
* @since 1.0
* @access protected
* @return void
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'edd-recent-purchases' ), '1.0' );
}
/**
* Include required files.
*
* @access private
* @since 1.0
* @return void
*/
private function includes() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-admin-links.php';
require_once plugin_dir_path( __FILE__ ) . 'admin/class-admin.php';
require_once plugin_dir_path( __FILE__ ) . 'public/class-shortcode.php';
require_once plugin_dir_path( __FILE__ ) . 'widget/widget.php';
}
}
function edd_recent_purchases() {
return EDD_RECENT_PURCHASES::instance();
}
edd_recent_purchases();