Skip to content

Commit aae02a2

Browse files
committed
package updated and update checked added
1 parent 6bf498f commit aae02a2

File tree

1,105 files changed

+196468
-71
lines changed

Some content is hidden

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

1,105 files changed

+196468
-71
lines changed

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
=== CBX PhpSpreadSheet Library ===
2+
Contributors: codeboxr,manchumahara, moojomoore
3+
Requires at least: 3.5
4+
Tested up to: 6.4.2
5+
Stable tag: 1.0.5
6+
License: GPLv2 or later
7+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
8+
9+
Open source PhpSpreadSheet php library released as wordpress plugin to use easily
10+
11+
== Description ==
12+
13+
A pure [PHP library for reading and writing spreadsheet files](https://phpspreadsheet.readthedocs.io)
14+
15+
From Codeboxr we wrapped the library as wordpress plugin to easy distribute as wordpress plugin. WordPress now doesn't allow this type library as
16+
plugin but providing a large php package with plugin makes the plugin heavy and troublesome for updates. We hosted this in github so that user can download and later
17+
update easily.
18+
19+
Software requirements
20+
21+
The following software is required to develop using PhpSpreadsheet:
22+
23+
* PHP version 7.4 or newer
24+
* PHP extension php_zip enabled
25+
* PHP extension php_xml enabled
26+
* PHP extension php_gd2 enabled (if not compiled in)
27+
28+
29+
The plugin check php version, php_zip, php_xml and php_gd2 library compatible or installed or not, based on success it activated.
30+
31+
How to use:
32+
33+
`
34+
if ( defined('CBXPHPSPREADSHEET_PLUGIN_NAME') && file_exists( CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php' ) ) {
35+
//Include PHPExcel
36+
require_once( CBXPHPSPREADSHEET_ROOT_PATH . 'lib/vendor/autoload.php' );
37+
38+
//now take instance
39+
$objPHPExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
40+
41+
//do whatever you need to do
42+
}
43+
`
44+
45+
== Installation ==
46+
47+
1. Download the latest zip from here (https://github.com/codeboxrcodehub/cbxphpspreadsheet/releases)
48+
2. [WordPress has clear documentation about how to install a plugin].(https://codex.wordpress.org/Managing_Plugins)
49+
3. After install activate the plugin "CBX PhpSpreadSheet Library" through the 'Plugins' menu in WordPress
50+
4. This plugin doesn't load any library by default, it doesn't create extra folder or menu.
51+
52+
53+
54+
55+
56+
== Screenshots ==
57+
58+
1. yet to come
59+
60+
== Changelog ==
61+
62+
= 1.0.5 =
63+
* Dependency vendor packages updated to latest
64+
65+
= 1.0.4 =
66+
* Updated the phpspreadsheet package to latest V1.29.0
67+
68+
= 1.0.3 =
69+
* Updated the phpspreadsheet package to latest V1.21.0
70+
71+
= 1.0.2 =
72+
* Updated the phpspreadsheet package to latest V1.21.0
73+
74+
= 1.0.1 =
75+
* Updated the phpspreadsheet package to latest
76+
77+
= 1.0.0 =
78+
* First public release

cbxphpspreadsheet.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
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.3
19+
* Version: 1.0.5
2020
* Author: Codeboxr
2121
* Author URI: https://github.com/PHPOffice/PhpSpreadsheet
2222
* License: GPL-2.0+
@@ -34,17 +34,17 @@
3434
}
3535

3636
defined('CBXPHPSPREADSHEET_PLUGIN_NAME') or define('CBXPHPSPREADSHEET_PLUGIN_NAME', 'cbxphpspreadsheet');
37-
defined('CBXPHPSPREADSHEET_PLUGIN_VERSION') or define('CBXPHPSPREADSHEET_PLUGIN_VERSION', '1.0.4');
37+
defined('CBXPHPSPREADSHEET_PLUGIN_VERSION') or define('CBXPHPSPREADSHEET_PLUGIN_VERSION', '1.0.5');
3838
defined('CBXPHPSPREADSHEET_BASE_NAME') or define('CBXPHPSPREADSHEET_BASE_NAME', plugin_basename(__FILE__));
3939
defined('CBXPHPSPREADSHEET_ROOT_PATH') or define('CBXPHPSPREADSHEET_ROOT_PATH', plugin_dir_path(__FILE__));
4040
defined('CBXPHPSPREADSHEET_ROOT_URL') or define('CBXPHPSPREADSHEET_ROOT_URL', plugin_dir_url(__FILE__));
4141

4242

4343
register_activation_hook(__FILE__, array('CBXPhpSpreadSheet', 'activation'));
44+
require_once CBXPHPSPREADSHEET_ROOT_PATH . "lib/vendor/autoload.php";
4445

4546

4647

47-
new Hooks;
4848
/**
4949
* Class CBXPhpSpreadSheet
5050
*/
@@ -57,7 +57,7 @@ function __construct()
5757

5858
add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2);
5959

60-
60+
new Hooks();
6161
}
6262

6363
/**

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"type": "library",
55
"license": "MIT",
66
"config": {
7-
"vendor-dir": "lib"
7+
"vendor-dir": "lib/vendor"
88
},
99
"require": {
1010
"phpoffice/phpspreadsheet": "^1.29",

includes/Hooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function update_checker() {
1313
$updater = new PDUpdater( CBXPHPSPREADSHEET_ROOT_PATH . 'cbxphpspreadsheet.php' );
1414
$updater->set_username( 'codeboxrcodehub' );
1515
$updater->set_repository( 'cbxphpspreadsheet' );
16-
$updater->authorize( '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' );
16+
$updater->authorize( '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' );
1717
$updater->initialize();
1818

1919
return;

includes/PDUpdater.php

Lines changed: 95 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Cbx\Phpspreadsheet;
34

45
class PDUpdater
@@ -42,6 +43,46 @@ public function authorize($token)
4243
$this->authorize_token = $token;
4344
}//end function authorize
4445

46+
public function initialize()
47+
{
48+
add_filter('pre_set_site_transient_update_plugins', [$this, 'modify_transient'], 10, 1);
49+
add_filter('plugins_api', [$this, 'plugin_popup'], 10, 3);
50+
add_filter('upgrader_post_install', [$this, 'after_install'], 10, 3);
51+
add_filter("http_request_args", [$this, "addHeaders"], 10, 3);
52+
}//end function get_repository_info
53+
54+
public function modify_transient($transient)
55+
{
56+
if (property_exists($transient, 'checked')) {
57+
if ($checked = $transient->checked) {
58+
$this->get_repository_info();
59+
if (isset($this->github_response['tag_name'])) {
60+
$tag_name = str_replace("v", "", $this->github_response['tag_name']);
61+
$tag_name = str_replace("V", "", $tag_name);
62+
$out_of_date = version_compare($tag_name, $checked[$this->basename], 'gt');
63+
64+
if ($out_of_date) {
65+
$new_files = $this->github_response['zipball_url'];
66+
$slug = current(explode('/', $this->basename));
67+
68+
$plugin = [
69+
'url' => $this->plugin['PluginURI'],
70+
'slug' => $slug,
71+
'package' => $new_files,
72+
'new_version' => $tag_name
73+
];
74+
// print_r($plugin);
75+
// exit;
76+
$transient->response[$this->basename] = (object) $plugin;
77+
}
78+
}
79+
80+
}
81+
}
82+
83+
return $transient;
84+
}//end function initialize
85+
4586
private function get_repository_info()
4687
{
4788
if (is_null($this->github_response)) {
@@ -71,93 +112,74 @@ private function get_repository_info()
71112

72113
$response = json_decode($response, true);
73114

115+
74116
if (is_array($response)) {
75117
$response = current($response);
76118
}
77119

78-
if ($this->authorize_token) {
79-
$response['zipball_url'] = add_query_arg('access_token', $this->authorize_token, $response['zipball_url']);
120+
if ($this->authorize_token && isset($response['zipball_url'])) {
121+
$response['zipball_url'] = add_query_arg(
122+
'access_token',
123+
$this->authorize_token,
124+
$response['zipball_url']
125+
);
126+
$this->github_response = $response;
80127
}
81-
82-
$this->github_response = $response;
83128
}
84-
}//end function get_repository_info
129+
}//end function modify_transient
85130

86-
public function initialize()
131+
public function plugin_popup($result, $action, $args)
87132
{
88-
add_filter('pre_set_site_transient_update_plugins', [$this, 'modify_transient'], 10, 1);
89-
add_filter('plugins_api', [$this, 'plugin_popup'], 10, 3);
90-
add_filter('upgrader_post_install', [$this, 'after_install'], 10, 3);
91-
add_filter("http_request_args", [$this, "addHeaders"], 10, 3);
92-
}//end function initialize
133+
if ($action !== 'plugin_information') {
134+
return false;
135+
}
93136

94-
public function modify_transient($transient)
95-
{
96-
if (property_exists($transient, 'checked')) {
97-
if ($checked = $transient->checked) {
137+
if (!empty($args->slug)) {
138+
if ($args->slug == current(explode('/', $this->basename))) {
98139
$this->get_repository_info();
99140

100-
$tag_name = str_replace("v", "", $this->github_response['tag_name']);
101-
$tag_name = str_replace("V", "", $tag_name);
102-
$out_of_date = version_compare($tag_name, $checked[$this->basename], 'gt');
103-
104-
if ($out_of_date) {
105-
$new_files = $this->github_response['zipball_url'];
141+
if (isset($this->github_response['zipball_url'])) {
106142
$slug = current(explode('/', $this->basename));
107143

144+
$tag_name = str_replace("v", "", $this->github_response['tag_name']);
145+
$tag_name = str_replace("V", "", $tag_name);
146+
108147
$plugin = [
109-
'url' => $this->plugin['PluginURI'],
148+
'name' => isset($this->plugin['Name']) ? $this->plugin['Name'] : '',
110149
'slug' => $slug,
111-
'package' => $new_files,
112-
'new_version' => $tag_name
150+
'requires' => '5.3',
151+
'tested' => '5.4',
152+
'version' => $tag_name,
153+
'author' => $this->plugin['Author'],
154+
'author_profile' => $this->plugin['AuthorURI'],
155+
'last_updated' => $this->github_response['published_at'],
156+
'homepage' => $this->plugin['PluginURI'],
157+
'short_description' => isset($this->plugin['Description']) ? $this->plugin['Description'] : '',
158+
'sections' => [
159+
'Description' => isset($this->plugin['Description']) ? $this->plugin['Description'] : '',
160+
'Updates' => isset($this->github_response['body']) ? $this->github_response['body'] : '',
161+
],
162+
'download_link' => $this->github_response['zipball_url']
113163
];
114164

115-
$transient->response[$this->basename] = (object) $plugin;
165+
return (object) $plugin;
116166
}
117-
}
118-
}
119-
120-
return $transient;
121-
}//end function modify_transient
122167

123-
public function plugin_popup($result, $action, $args)
124-
{
125-
if ($action !== 'plugin_information') {
126-
return false;
127-
}
128-
if (!empty($args->slug)) {
129-
if ($args->slug == current(explode('/', $this->basename))) {
130-
$this->get_repository_info();
131-
$slug = current(explode('/', $this->basename));
132-
133-
$tag_name = str_replace("v", "", $this->github_response['tag_name']);
134-
$tag_name = str_replace("V", "", $tag_name);
135-
136-
$plugin = [
137-
'name' => isset($this->plugin['Name']) ? $this->plugin['Name'] : '',
138-
'slug' => $slug,
139-
'requires' => '5.3',
140-
'tested' => '5.4',
141-
'version' => $tag_name,
142-
'author' => $this->plugin['Author'],
143-
'author_profile' => $this->plugin['AuthorURI'],
144-
'last_updated' => $this->github_response['published_at'],
145-
'homepage' => $this->plugin['PluginURI'],
146-
'short_description' => isset($this->plugin['Description']) ? $this->plugin['Description'] : '',
147-
'sections' => [
148-
'Description' => isset($this->plugin['Description']) ? $this->plugin['Description'] : '',
149-
'Updates' => isset($this->github_response['body']) ? $this->github_response['body'] : '',
150-
],
151-
'download_link' => $this->github_response['zipball_url']
152-
];
153-
154-
return (object) $plugin;
155168
}
156169
}
157170

158171
return $result;
159172
}//end function plugin_popup
160173

174+
/**
175+
* Take care on after plugin install
176+
*
177+
* @param $response
178+
* @param $hook_extra
179+
* @param $result
180+
*
181+
* @return mixed
182+
*/
161183
public function after_install($response, $hook_extra, $result)
162184
{
163185
global $wp_filesystem;
@@ -173,16 +195,24 @@ public function after_install($response, $hook_extra, $result)
173195
return $result;
174196
}//end function after_install
175197

198+
/**
199+
* Add github authorization token for plugin download from github
200+
*
201+
* @param $parsed_args
202+
* @param $url
203+
*
204+
* @return mixed
205+
*/
176206
public function addHeaders($parsed_args, $url)
177207
{
178208
if (empty($parsed_args['headers'])) {
179209
$parsed_args['headers'] = [];
180210
}
181211

182-
if (strpos($url, "https://api.github.com/repos/{$this->username}/{$this->repository}") !== FALSE) {
212+
if (strpos($url, "https://api.github.com/repos/{$this->username}/{$this->repository}") !== false) {
183213
$parsed_args['headers']['Authorization'] = "token $this->authorize_token";
184-
185214
}
215+
186216
return $parsed_args;
187217
}//end function addHeaders
188-
}// end class PDUpdater
218+
}//end class PDUpdater

lib/vendor/autoload.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
// autoload.php @generated by Composer
4+
5+
if (PHP_VERSION_ID < 50600) {
6+
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
7+
exit(1);
8+
}
9+
10+
require_once __DIR__ . '/composer/autoload_real.php';
11+
12+
return ComposerAutoloaderInit00806fe69736e9cf42743640feeffa67::getLoader();

0 commit comments

Comments
 (0)