-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathea-share-count.php
183 lines (158 loc) · 4.03 KB
/
ea-share-count.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
/**
* Plugin Name: EA Share Count
* Plugin URI: https://github.com/jaredatch/EA-Share-Count
* GitHub URI: jaredatch/EA-Share-Count
* Description: A lean plugin for quickly retrieving, caching, and displaying various social sharing counts and buttons.
* Author: Bill Erickson & Jared Atchison
* Version: 1.8.0
*
* EA Share Count is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* EA Share Count is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EA Share Count. If not, see <http://www.gnu.org/licenses/>.
*
* @package EA_ShareCount
* @author Bill Erickson & Jared Atchison
* @since 1.0.0
* @license GPL-2.0+
* @copyright Copyright (c) 2015
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Main class
*
* @since 1.0.0
* @package EA_Share_Count
*/
final class EA_Share_Count {
/**
* Instance of the class.
*
* @since 1.0.0
* @var object
*/
private static $instance;
/**
* Plugin version.
*
* @since 1.0.0
* @var string
*/
private $version = '1.8.0';
/**
* Core instance
*
* @since 1.3.0
* @var object
*/
public $core;
/**
* Admin instance
*
* @since 1.3.0
* @var object
*/
public $admin;
/**
* Front-end instance
*
* @since 1.3.0
* @var object
*/
public $front;
/**
* Share Count Instance.
*
* @since 1.0.0
* @return EA_Share_Count
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof EA_Share_Count ) ) {
self::$instance = new EA_Share_Count;
self::$instance->constants();
self::$instance->includes();
add_action( 'init', array( self::$instance, 'init' ) );
}
return self::$instance;
}
/**
* Define some constants.
*
* @since 1.3.0
*/
public function constants() {
// Version
define( 'EA_SHARE_COUNT_VERSION', $this->version );
// Directory path
define( 'EA_SHARE_COUNT_DIR', plugin_dir_path( __FILE__ ) );
// Directory URL
define( 'EA_SHARE_COUNT_URL', plugin_dir_url( __FILE__ ) );
// Base name
define( 'EA_SHARE_COUNT_BASE', plugin_basename( __FILE__ ) );
// Plugin root file
define( 'EA_SHARE_COUNT_FILE', __FILE__ );
}
/**
* Load includes.
*
* @since 1.3.0
*/
public function includes() {
require_once EA_SHARE_COUNT_DIR . 'includes/class-install.php';
require_once EA_SHARE_COUNT_DIR . 'includes/class-core.php';
require_once EA_SHARE_COUNT_DIR . 'includes/class-admin.php';
require_once EA_SHARE_COUNT_DIR . 'includes/class-front.php';
require_once EA_SHARE_COUNT_DIR . 'includes/github-updater.php';
}
/**
* Bootstap.
*
* @since 1.3.0
*/
public function init() {
$this->core = new EA_Share_Count_Core;
$this->admin = new EA_Share_Count_Admin;
$this->front = new EA_Share_Count_Front;
}
/**
* Helper to access link method directly, for backwards compatibility.
*
* @since 1.3.0
* @return string
*/
public function link( $types = 'facebook', $id = false, $echo = true, $style = 'generic', $round = 2, $show_empty = '' ) {
return $this->front->link( $types, $id, $echo, $style, $round, $show_empty );
}
/**
* Helper to access count method directly, for backwards compatibility.
*
* @since 1.3.0
* @return string
*/
public function count( $id = false, $type = 'facebook', $echo = false, $round = 2 ) {
return $this->core->count( $id, $type, $echo, $round );
}
}
/**
* The function provides access to the sharing methods.
*
* Use this function like you would a global variable, except without needing
* to declare the global.
*
* @since 1.0.0
* @return object
*/
function ea_share() {
return EA_Share_Count::instance();
}
ea_share();