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 );
0 commit comments