-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcbxphpspreadsheet.php
213 lines (171 loc) · 5.06 KB
/
cbxphpspreadsheet.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link http://codeboxr.com
* @since 1.0.0
* @package cbxphpspreadsheet
*
* @wordpress-plugin
* Plugin Name: CBX PhpSpreadSheet Library
* Plugin URI: https://codeboxr.com/php-spreadsheet-library-wordpress-plugin/
* Description: A pure PHP library for reading and writing spreadsheet files https://phpspreadsheet.readthedocs.io/
* Version: 1.0.6
* Author: Codeboxr
* Author URI: https://github.com/PHPOffice/PhpSpreadsheet
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: cbxphpspreadsheet
* Domain Path: /languages
*/
// If this file is called directly, abort.
use Cbx\Phpspreadsheet\Hooks;
if (!defined('WPINC')) {
die;
}
defined('CBXPHPSPREADSHEET_PLUGIN_NAME') or define('CBXPHPSPREADSHEET_PLUGIN_NAME', 'cbxphpspreadsheet');
defined('CBXPHPSPREADSHEET_PLUGIN_VERSION') or define('CBXPHPSPREADSHEET_PLUGIN_VERSION', '1.0.6');
defined('CBXPHPSPREADSHEET_BASE_NAME') or define('CBXPHPSPREADSHEET_BASE_NAME', plugin_basename(__FILE__));
defined('CBXPHPSPREADSHEET_ROOT_PATH') or define('CBXPHPSPREADSHEET_ROOT_PATH', plugin_dir_path(__FILE__));
defined('CBXPHPSPREADSHEET_ROOT_URL') or define('CBXPHPSPREADSHEET_ROOT_URL', plugin_dir_url(__FILE__));
register_activation_hook(__FILE__, array('CBXPhpSpreadSheet', 'activation'));
require_once CBXPHPSPREADSHEET_ROOT_PATH . "lib/vendor/autoload.php";
/**
* Class CBXPhpSpreadSheet
*/
class CBXPhpSpreadSheet
{
function __construct()
{
//load text domain
load_plugin_textdomain('cbxphpspreadsheet', false, dirname(plugin_basename(__FILE__)) . '/languages/');
add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2);
new Hooks();
}
/**
* Activation hook
*/
public static function activation()
{
if (!CBXPhpSpreadSheet::php_version_check()) {
// Deactivate the plugin
deactivate_plugins(__FILE__);
// Throw an error in the wordpress admin console
$error_message = __('This plugin requires PHP version 7.4 or newer', 'cbxphpspreadsheet');
die($error_message);
}
if (!CBXPhpSpreadSheet::php_zip_enabled_check()) {
// Deactivate the plugin
deactivate_plugins(__FILE__);
// Throw an error in the wordpress admin console
$error_message = __(
'This plugin requires PHP php_zip extension installed and enabled',
'cbxphpspreadsheet'
);
die($error_message);
}
if (!CBXPhpSpreadSheet::php_xml_enabled_check()) {
// Deactivate the plugin
deactivate_plugins(__FILE__);
// Throw an error in the wordpress admin console
$error_message = __(
'This plugin requires PHP php_xml extension installed and enabled',
'cbxphpspreadsheet'
);
die($error_message);
}
if (!CBXPhpSpreadSheet::php_gd_enabled_check()) {
// Deactivate the plugin
deactivate_plugins(__FILE__);
// Throw an error in the wordpress admin console
$error_message = __(
'This plugin requires PHP php_gd2 extension installed and enabled',
'cbxphpspreadsheet'
);
die($error_message);
}
}//end method activation
/**
* PHP version compatibility check
*
* @return bool
*/
public static function php_version_check()
{
if (version_compare(PHP_VERSION, '7.4.0', '<')) {
return false;
}
return true;
}//end method php_version_check
/**
* php_zip enabled check
*
* @return bool
*/
public static function php_zip_enabled_check()
{
if (extension_loaded('zip')) {
return true;
}
return false;
}//end method php_zip_enabled_check
/**
* php_xml enabled check
*
* @return bool
*/
public static function php_xml_enabled_check()
{
if (extension_loaded('xml')) {
return true;
}
return false;
}//end method php_xml_enabled_check
/**
* php_gd2 enabled check
*
* @return bool
*/
public static function php_gd_enabled_check()
{
if (extension_loaded('gd')) {
return true;
}
return false;
}//end method php_gd_enabled_check
/**
* Plugin support and doc page url
*
* @param $links
* @param $file
*
* @return array
*/
public function plugin_row_meta($links, $file)
{
if (strpos($file, 'cbxphpspreadsheet.php') !== false) {
$new_links = array(
'support' => '<a href="https://codeboxr.com/php-spreadsheet-library-wordpress-plugin/" target="_blank">' . esc_html__(
'Support',
'cbxphpspreadsheet'
) . '</a>',
'doc' => '<a href="https://phpspreadsheet.readthedocs.io/en/latest/" target="_blank">' . esc_html__(
'PHP Spreadsheet Doc',
'cbxphpspreadsheet'
) . '</a>'
);
$links = array_merge($links, $new_links);
}
return $links;
}
}//end method CBXPhpSpreadSheet
function cbxphpspreadsheet_load_plugin()
{
new CBXPhpSpreadSheet();
}
add_action('plugins_loaded', 'cbxphpspreadsheet_load_plugin', 5);