Skip to content

Commit db3b992

Browse files
committed
initilize cbxphpdompdf plugin
0 parents  commit db3b992

File tree

304 files changed

+150199
-0
lines changed

Some content is hidden

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

304 files changed

+150199
-0
lines changed

README.txt

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
=== CBX PhpSpreadSheet Library ===
2+
Contributors: codeboxr,manchumahara
3+
Requires at least: 3.5
4+
Tested up to: 5.8.3
5+
Stable tag: 1.0.2
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 5.6 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.2 =
63+
* Updated the phpspreadsheet package to latest V1.21.0
64+
65+
= 1.0.1 =
66+
* Updated the phpspreadsheet package to latest
67+
68+
= 1.0.0 =
69+
* First public release

cbxphpdompdf.php

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
<?php
2+
3+
/**
4+
* The plugin bootstrap file
5+
*
6+
* This file is read by WordPress to generate the plugin information in the plugin
7+
* admin area. This file also includes all of the dependencies used by the plugin,
8+
* registers the activation and deactivation functions, and defines a function
9+
* that starts the plugin.
10+
*
11+
* @link http://codeboxr.com
12+
* @since 1.0.0
13+
* @package cbxphpdompdf
14+
*
15+
* @wordpress-plugin
16+
* Plugin Name: CBX PHPDomPDF Library
17+
* Plugin URI: https://codeboxr.com/php-dompdf-library-wordpress-plugin/
18+
* Description: A pure PHP library for reading and writing pdp files https://github.com/dompdf/dompdf
19+
* Version: 1.0.0
20+
* Author: Codeboxr
21+
* Author URI: https://github.com/PHPOffice/PhpDomPDF
22+
* License: GPL-2.0+
23+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
24+
* Text Domain: cbxphpdompdf
25+
* Domain Path: /languages
26+
*/
27+
28+
// If this file is called directly, abort.
29+
if ( ! defined( 'WPINC' ) ) {
30+
die;
31+
}
32+
33+
defined( 'CBXPHPDOMPDF_PLUGIN_NAME' ) or define( 'CBXPHPDOMPDF_PLUGIN_NAME', 'cbxphpdompdf' );
34+
defined( 'CBXPHPDOMPDF_PLUGIN_VERSION' ) or define( 'CBXPHPDOMPDF_PLUGIN_VERSION', '1.0.0' );
35+
defined( 'CBXPHPDOMPDF_BASE_NAME' ) or define( 'CBXPHPDOMPDF_BASE_NAME', plugin_basename( __FILE__ ) );
36+
defined( 'CBXPHPDOMPDF_ROOT_PATH' ) or define( 'CBXPHPDOMPDF_ROOT_PATH', plugin_dir_path( __FILE__ ) );
37+
defined( 'CBXPHPDOMPDF_ROOT_URL' ) or define( 'CBXPHPDOMPDF_ROOT_URL', plugin_dir_url( __FILE__ ) );
38+
39+
register_activation_hook( __FILE__, array( 'CBXPhpDomPDP', 'activation' ) );
40+
41+
/**
42+
* Class CBXPhpDomPDP
43+
*/
44+
class CBXPhpDomPDP {
45+
function __construct() {
46+
//load text domain
47+
load_plugin_textdomain('cbxphpdompdf', false, dirname(plugin_basename(__FILE__)) . '/languages/');
48+
49+
add_filter( 'plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2 );
50+
}
51+
52+
/**
53+
* Activation hook
54+
*/
55+
public static function activation() {
56+
/*$requirements = array(
57+
'PHP 7.1.0' => version_compare(PHP_VERSION, '7.1.0', '>='),
58+
'PHP extension XML' => extension_loaded('xml'),
59+
'PHP extension xmlwriter' => extension_loaded('xmlwriter'),
60+
'PHP extension mbstring' => extension_loaded('mbstring'),
61+
'PHP extension ZipArchive' => extension_loaded('zip'),
62+
'PHP extension GD (optional)' => extension_loaded('gd'),
63+
'PHP extension dom (optional)' => extension_loaded('dom'),
64+
);*/
65+
66+
if (!CBXPhpDomPDP::php_version_check()) {
67+
68+
// Deactivate the plugin
69+
deactivate_plugins(__FILE__);
70+
71+
// Throw an error in the wordpress admin console
72+
$error_message = __('This plugin requires PHP version 7.1 or newer', 'cbxphpdompdf');
73+
die($error_message);
74+
}
75+
76+
if (!CBXPhpDomPDP::php_zip_enabled_check()) {
77+
78+
// Deactivate the plugin
79+
deactivate_plugins(__FILE__);
80+
81+
// Throw an error in the wordpress admin console
82+
$error_message = __('This plugin requires PHP php_zip extension installed and enabled', 'cbxphpdompdf');
83+
die($error_message);
84+
}
85+
86+
if (!CBXPhpDomPDP::php_xml_enabled_check()) {
87+
88+
// Deactivate the plugin
89+
deactivate_plugins(__FILE__);
90+
91+
// Throw an error in the wordpress admin console
92+
$error_message = __('This plugin requires PHP php_xml extension installed and enabled', 'cbxphpdompdf');
93+
die($error_message);
94+
}
95+
96+
if (!CBXPhpDomPDP::php_gd_enabled_check()) {
97+
98+
// Deactivate the plugin
99+
deactivate_plugins(__FILE__);
100+
101+
// Throw an error in the wordpress admin console
102+
$error_message = __('This plugin requires PHP php_gd2 extension installed and enabled', 'cbxphpdompdf');
103+
die($error_message);
104+
}
105+
106+
if (!CBXPhpDomPDP::php_mbstring_enabled_check()) {
107+
108+
// Deactivate the plugin
109+
deactivate_plugins(__FILE__);
110+
111+
// Throw an error in the wordpress admin console
112+
$error_message = __('This plugin requires PHP php_MBString extension installed and enabled', 'cbxphpdompdf');
113+
die($error_message);
114+
}
115+
116+
if (!CBXPhpDomPDP::php_dom_enabled_check()) {
117+
118+
// Deactivate the plugin
119+
deactivate_plugins(__FILE__);
120+
121+
// Throw an error in the wordpress admin console
122+
$error_message = __('This plugin requires PHP DOM extension installed and enabled', 'cbxphpdompdf');
123+
die($error_message);
124+
}
125+
126+
}//end method activation
127+
128+
/**
129+
* PHP version compatibility check
130+
*
131+
* @return bool
132+
*/
133+
public static function php_version_check(){
134+
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
135+
return false;
136+
}
137+
138+
return true;
139+
}//end method php_version_check
140+
141+
/**
142+
* php_zip enabled check
143+
*
144+
* @return bool
145+
*/
146+
public static function php_zip_enabled_check(){
147+
if (extension_loaded('zip')) {
148+
return true;
149+
}
150+
return false;
151+
}//end method php_zip_enabled_check
152+
153+
/**
154+
* php_xml enabled check
155+
*
156+
* @return bool
157+
*/
158+
public static function php_xml_enabled_check(){
159+
if (extension_loaded('xml')) {
160+
return true;
161+
}
162+
return false;
163+
}//end method php_xml_enabled_check
164+
165+
/**
166+
* php_gd2 enabled check
167+
*
168+
* @return bool
169+
*/
170+
public static function php_gd_enabled_check(){
171+
if (extension_loaded('gd')) {
172+
return true;
173+
}
174+
return false;
175+
}//end method php_gd_enabled_check
176+
177+
/**
178+
* php_mbstring enabled check
179+
*
180+
* @return bool
181+
*/
182+
public static function php_mbstring_enabled_check(){
183+
if (extension_loaded('mbstring')) {
184+
return true;
185+
}
186+
return false;
187+
}//end method php_mbstring_enabled_check
188+
189+
/**
190+
* php_dom enabled check
191+
*
192+
* @return bool
193+
*/
194+
public static function php_dom_enabled_check(){
195+
if (extension_loaded('dom')) {
196+
return true;
197+
}
198+
return false;
199+
}//end method php_dom_enabled_check
200+
201+
/**
202+
* Plugin support and doc page url
203+
*
204+
* @param $links
205+
* @param $file
206+
*
207+
* @return array
208+
*/
209+
public function plugin_row_meta( $links, $file ) {
210+
211+
if ( strpos( $file, 'cbxphpdompdf.php' ) !== false ) {
212+
$new_links = array(
213+
'support' => '<a href="https://codeboxr.com/php-dompdf-library-wordpress-plugin/" target="_blank">'.esc_html__('Support', 'cbxphpdompdf').'</a>',
214+
'doc' => '<a href="https://github.com/dompdf/dompdf" target="_blank">'.esc_html__('PHP Dompdf Doc', 'cbxphpdompdf').'</a>'
215+
);
216+
217+
$links = array_merge( $links, $new_links );
218+
}
219+
220+
return $links;
221+
}
222+
223+
}//end method CBXPhpDomPDP
224+
225+
226+
function cbxphpdompdf_load_plugin() {
227+
new CBXPhpDomPDP();
228+
}
229+
230+
add_action( 'plugins_loaded', 'cbxphpdompdf_load_plugin', 5 );

composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"config": {
3+
"vendor-dir": "lib/vendor"
4+
},
5+
"require": {
6+
"dompdf/dompdf": "^2.0"
7+
}
8+
}

0 commit comments

Comments
 (0)