Skip to content

Commit 2c1c204

Browse files
committed
phpspreadsheet version 1.0.8 released
1 parent 79e8d51 commit 2c1c204

File tree

886 files changed

+19343
-63362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

886 files changed

+19343
-63362
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ The plugin check php version, php_zip, php_xml and php_gd2 library compatible or
2323
How to use:
2424

2525
````
26-
if ( defined('CBXPHPSPREADSHEET_PLUGIN_NAME') && file_exists( CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php' ) ) {
26+
if ( defined('CBXPHPSPREADSHEET_PLUGIN_NAME') && cbxphpspreadsheet_loadable() ) {
2727
2828
//Include PHPExcel
29-
require_once( CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php' );
29+
require_once( CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php' ); //or use 'cbxphpspreadsheet_load();'
3030
3131
//now take instance
3232
$objPHPExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

README.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
=== CBX PhpSpreadSheet Library ===
22
Contributors: codeboxr, manchumahara
3-
Requires at least: 3.5
4-
Tested up to: 6.6.2
5-
Stable tag: 1.0.6
3+
Requires at least: 5.3
4+
Tested up to: 6.7.1
5+
Stable tag: 1.0.8
66
License: MIT
77
License URI: https://github.com/codeboxrcodehub/cbxphpspreadsheet/blob/master/LICENSE.txt
88

@@ -31,9 +31,10 @@ The plugin check php version, php_zip, php_xml and php_gd2 library compatible or
3131
How to use:
3232

3333
`
34-
if ( defined('CBXPHPSPREADSHEET_PLUGIN_NAME') && file_exists( CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php' ) ) {
34+
if ( defined('CBXPHPSPREADSHEET_PLUGIN_NAME') && cbxphpspreadsheet_loadable() ) {
35+
3536
//Include PHPExcel
36-
require_once( CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php' );
37+
require_once( CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php' ); //or use 'cbxphpspreadsheet_load();'
3738

3839
//now take instance
3940
$objPHPExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
@@ -51,6 +52,13 @@ if ( defined('CBXPHPSPREADSHEET_PLUGIN_NAME') && file_exists( CBXPHPSPREADSHEET_
5152

5253

5354
== Changelog ==
55+
= 1.0.8 =
56+
* Dependency vendor packages updated to latest
57+
* Added some helper functions for better environment checking
58+
59+
= 1.0.7 =
60+
* Dependency vendor packages updated to latest
61+
5462
= 1.0.6 =
5563
* Dependency vendor packages updated to latest
5664

cbxphpspreadsheet.php

Lines changed: 130 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* Plugin Name: CBX PhpSpreadSheet Library
1717
* Plugin URI: https://codeboxr.com/php-spreadsheet-library-wordpress-plugin/
1818
* Description: A pure PHP library for reading and writing spreadsheet files https://phpspreadsheet.readthedocs.io/
19-
* Version: 1.0.6
20-
* Requires PHP: 7.4
19+
* Version: 1.0.8
20+
* Requires PHP: 8.1.99
2121
* Author: Codeboxr
2222
* Author URI: https://github.com/PHPOffice/PhpSpreadsheet
2323
* License: GPL-2.0+
@@ -26,143 +26,172 @@
2626
* Domain Path: /languages
2727
*/
2828

29-
use Cbx\Phpspreadsheet\Hooks;
3029

31-
if (!defined('WPINC')) {
32-
die;
30+
31+
if ( ! defined( 'WPINC' ) ) {
32+
die;
3333
}
3434

35-
defined('CBXPHPSPREADSHEET_PLUGIN_NAME') or define('CBXPHPSPREADSHEET_PLUGIN_NAME', 'cbxphpspreadsheet');
36-
defined('CBXPHPSPREADSHEET_PLUGIN_VERSION') or define('CBXPHPSPREADSHEET_PLUGIN_VERSION', '1.0.6');
37-
defined('CBXPHPSPREADSHEET_BASE_NAME') or define('CBXPHPSPREADSHEET_BASE_NAME', plugin_basename(__FILE__));
38-
defined('CBXPHPSPREADSHEET_ROOT_PATH') or define('CBXPHPSPREADSHEET_ROOT_PATH', plugin_dir_path(__FILE__));
39-
defined('CBXPHPSPREADSHEET_ROOT_URL') or define('CBXPHPSPREADSHEET_ROOT_URL', plugin_dir_url(__FILE__));
35+
defined( 'CBXPHPSPREADSHEET_PLUGIN_NAME' ) or define( 'CBXPHPSPREADSHEET_PLUGIN_NAME', 'cbxphpspreadsheet' );
36+
defined( 'CBXPHPSPREADSHEET_PLUGIN_VERSION' ) or define( 'CBXPHPSPREADSHEET_PLUGIN_VERSION', '1.0.8' );
37+
defined( 'CBXPHPSPREADSHEET_BASE_NAME' ) or define( 'CBXPHPSPREADSHEET_BASE_NAME', plugin_basename( __FILE__ ) );
38+
defined( 'CBXPHPSPREADSHEET_ROOT_PATH' ) or define( 'CBXPHPSPREADSHEET_ROOT_PATH', plugin_dir_path( __FILE__ ) );
39+
defined( 'CBXPHPSPREADSHEET_ROOT_URL' ) or define( 'CBXPHPSPREADSHEET_ROOT_URL', plugin_dir_url( __FILE__ ) );
4040

41-
register_activation_hook(__FILE__, ['CBXPhpSpreadSheet', 'activation']);
42-
require_once CBXPHPSPREADSHEET_ROOT_PATH . "lib/vendor/autoload.php";
41+
register_activation_hook( __FILE__, [ 'CBXPhpSpreadSheet', 'activation' ] );
4342

44-
add_action('admin_notices', ['CBXPhpSpreadSheet', 'activation_error_display']);
4543

4644
/**
4745
* Class CBXPhpSpreadSheet
4846
*/
49-
class CBXPhpSpreadSheet
50-
{
51-
public function __construct()
52-
{
53-
// Load text domain
54-
load_plugin_textdomain('cbxphpspreadsheet', false, dirname(plugin_basename(__FILE__)) . '/languages/');
55-
56-
// Add custom row meta links
57-
add_filter('plugin_row_meta', [$this, 'plugin_row_meta'], 10, 2);
47+
class CBXPhpSpreadSheet {
48+
public function __construct() {
49+
// Load text domain
50+
load_plugin_textdomain( 'cbxphpspreadsheet', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
5851

59-
new Hooks();
60-
}//end constructor
52+
// Add custom row meta links
53+
add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 );
54+
add_action( 'admin_notices', [ $this, 'activation_error_display' ] );
55+
}//end constructor
6156

6257
/**
6358
* Activation hook
6459
*
6560
* @return void
6661
*/
67-
public static function activation()
68-
{
69-
$errors = [];
70-
71-
if (!self::php_version_check()) {
72-
$errors[] = __('This plugin requires PHP version 7.4 or newer.', 'cbxphpspreadsheet');
73-
}
62+
public static function activation() {
63+
$errors = [];
64+
65+
if ( ! self::php_version_check() ) {
66+
$errors[] = esc_html__( 'CBX PhpSpreadSheet Library plugin requires PHP version 8.1.99 or newer.', 'cbxphpspreadsheet' );
67+
}
7468

75-
if (!self::extension_check(['zip', 'xml', 'gd'])) {
76-
$errors[] = __('This plugin requires PHP extensions: Zip, XML, and GD2.', 'cbxphpspreadsheet');
77-
}
69+
if ( ! self::extension_check( [ 'zip', 'xml', 'gd' ] ) ) {
70+
$errors[] = esc_html__( 'CBX PhpSpreadSheet Library plugin requires PHP extensions: Zip, XML, and GD2.', 'cbxphpspreadsheet' );
71+
}
7872

79-
if (sizeof($errors) > 0) {
80-
update_option('cbxphpspreadsheet_activation_error', $errors);
81-
deactivate_plugins(plugin_basename(__FILE__));
73+
if ( sizeof( $errors ) > 0 ) {
74+
update_option( 'cbxphpspreadsheet_activation_error', $errors );
75+
//deactivate_plugins(plugin_basename(__FILE__));
8276

83-
//wp_die('Plugin not activated due to dependency not fulfilled.');
77+
//wp_die('Plugin not activated due to dependency not fulfilled.');
8478

85-
//die();
86-
}
87-
}//end method activation
79+
//die();
80+
}
81+
}//end method activation
8882

8983
/**
9084
* Show error
9185
*
9286
* @return void
9387
*/
94-
public static function activation_error_display(){
88+
public function activation_error_display() {
9589
// Only display on specific admin pages (e.g., plugins page)
9690
$screen = get_current_screen();
97-
if ($screen && $screen->id === 'plugins') {
98-
$errors = get_option('cbxphpspreadsheet_activation_error');
99-
if ($errors) {
100-
if(is_array($errors) && sizeof($errors) > 0){
101-
foreach ($errors as $error){
102-
echo '<div class="notice notice-error is-dismissible"><p>' . esc_html($error) . '</p></div>';
91+
if ( $screen && $screen->id === 'plugins' ) {
92+
$errors = get_option( 'cbxphpspreadsheet_activation_error' );
93+
if ( $errors ) {
94+
if ( is_array( $errors ) && sizeof( $errors ) > 0 ) {
95+
foreach ( $errors as $error ) {
96+
echo '<div class="notice notice-error is-dismissible"><p>' . esc_html( $error ) . '</p></div>';
10397
}
10498
}
10599

106-
delete_option('cbxphpspreadsheet_activation_error');
107-
deactivate_plugins('cbxphpspreadsheet/cbxphpspreadsheet.php');
100+
delete_option( 'cbxphpspreadsheet_activation_error' );
101+
//deactivate_plugins('cbxphpspreadsheet/cbxphpspreadsheet.php');
108102
}
109103
}
110104
}//end method activation_error_display
111105

112-
/**
113-
* Check PHP version compatibility
114-
*
115-
* @return bool
116-
*/
117-
private static function php_version_check()
118-
{
119-
return version_compare(PHP_VERSION, '7.4.0', '>=');
120-
}//end method php_version_check
121-
122-
/**
123-
* Check if required PHP extensions are enabled
124-
*
125-
* @param array $extensions
126-
* @return bool
127-
*/
128-
private static function extension_check($extensions)
129-
{
130-
foreach ($extensions as $extension) {
131-
if (!extension_loaded($extension)) {
132-
return false;
133-
}
134-
}
135-
return true;
136-
}//end method extension_check
137-
138-
/**
139-
* Add support and documentation links to the plugin row meta
140-
*
141-
* @param array $links
142-
* @param string $file
143-
* @return array
144-
*/
145-
public function plugin_row_meta($links, $file)
146-
{
147-
if (strpos($file, 'cbxphpspreadsheet.php') !== false) {
148-
$new_links = [
149-
'support' => '<a href="https://codeboxr.com/php-spreadsheet-library-wordpress-plugin/" target="_blank">' . esc_html__('Support', 'cbxphpspreadsheet') . '</a>',
150-
'doc' => '<a href="https://phpspreadsheet.readthedocs.io/en/latest/" target="_blank">' . esc_html__('PHP Spreadsheet Doc', 'cbxphpspreadsheet') . '</a>',
151-
];
152-
153-
$links = array_merge($links, $new_links);
154-
}
155-
156-
return $links;
157-
}
158-
}
106+
/**
107+
* Check PHP version compatibility
108+
*
109+
* @return bool
110+
*/
111+
private static function php_version_check() {
112+
//return version_compare( PHP_VERSION, '8.1.99', '>=' );
113+
return false;
114+
}//end method php_version_check
115+
116+
/**
117+
* Check if required PHP extensions are enabled
118+
*
119+
* @param array $extensions
120+
*
121+
* @return bool
122+
*/
123+
private static function extension_check( $extensions ) {
124+
foreach ( $extensions as $extension ) {
125+
if ( ! extension_loaded( $extension ) ) {
126+
return false;
127+
}
128+
}
129+
130+
return true;
131+
}//end method extension_check
132+
133+
/**
134+
* Is the environment ready for the phpspreadsheet package
135+
*
136+
* @return bool
137+
*/
138+
public static function environment_ready() {
139+
return self::php_version_check() && self::extension_check( [ 'zip', 'xml', 'gd' ]);
140+
}//end method environment_ready
141+
142+
/**
143+
* Add support and documentation links to the plugin row meta
144+
*
145+
* @param array $links
146+
* @param string $file
147+
*
148+
* @return array
149+
*/
150+
public function plugin_row_meta( $links, $file ) {
151+
if ( strpos( $file, 'cbxphpspreadsheet.php' ) !== false ) {
152+
$new_links = [
153+
'support' => '<a href="https://codeboxr.com/php-spreadsheet-library-wordpress-plugin/" target="_blank">' . esc_html__( 'Support', 'cbxphpspreadsheet' ) . '</a>',
154+
'doc' => '<a href="https://phpspreadsheet.readthedocs.io/en/latest/" target="_blank">' . esc_html__( 'PHP Spreadsheet Doc', 'cbxphpspreadsheet' ) . '</a>',
155+
];
156+
157+
$links = array_merge( $links, $new_links );
158+
}
159+
160+
return $links;
161+
}
162+
}//end class CBXPhpSpreadSheet
159163

160164
/**
161165
* Initialize the plugin
162166
*/
163-
function cbxphpspreadsheet_load_plugin()
164-
{
165-
new CBXPhpSpreadSheet();
167+
function cbxphpspreadsheet_load_plugin() {
168+
new CBXPhpSpreadSheet();
169+
}
170+
171+
add_action( 'plugins_loaded', 'cbxphpspreadsheet_load_plugin', 5 );
172+
173+
174+
if(!function_exists('cbxphpspreadsheet_loadable')){
175+
/**
176+
* Check if the enviroment ready for phpspreadsheet library
177+
*
178+
* @return bool
179+
*/
180+
function cbxphpspreadsheet_loadable(){
181+
return CBXPhpSpreadSheet::environment_ready();
182+
}//end function cbxphpspreadsheet_loadable
183+
}
184+
185+
if(!function_exists('cbxphpspreadsheet_load')){
186+
/**
187+
* If the enviroment is ready then load the autoloaded
188+
*
189+
* @return void
190+
*/
191+
function cbxphpspreadsheet_load(){
192+
if(CBXPhpSpreadSheet::environment_ready()){
193+
require_once CBXPHPSPREADSHEET_ROOT_PATH . "lib/vendor/autoload.php";
194+
}
195+
}//end function cbxphpspreadsheet_load
166196
}
167197

168-
add_action('plugins_loaded', 'cbxphpspreadsheet_load_plugin', 5);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"vendor-dir": "lib/vendor"
88
},
99
"require": {
10-
"phpoffice/phpspreadsheet": "^1.29",
10+
"phpoffice/phpspreadsheet": "^3.8",
1111
"myclabs/php-enum": "^1.8",
1212
"symfony/polyfill-mbstring": "^1.28"
1313
},

0 commit comments

Comments
 (0)