Skip to content

Commit 1855c7d

Browse files
committed
update checker added
1 parent db3b992 commit 1855c7d

File tree

7 files changed

+316
-46
lines changed

7 files changed

+316
-46
lines changed

cbxphpdompdf.php

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,48 @@
2626
*/
2727

2828
// If this file is called directly, abort.
29-
if ( ! defined( 'WPINC' ) ) {
29+
if (!defined('WPINC')) {
3030
die;
3131
}
32+
use Cbx\Phpdompdf\Hooks;
3233

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__ ) );
34+
defined('CBXPHPDOMPDF_PLUGIN_NAME') or define('CBXPHPDOMPDF_PLUGIN_NAME', 'cbxphpdompdf');
35+
defined('CBXPHPDOMPDF_PLUGIN_VERSION') or define('CBXPHPDOMPDF_PLUGIN_VERSION', '1.0.0');
36+
defined('CBXPHPDOMPDF_BASE_NAME') or define('CBXPHPDOMPDF_BASE_NAME', plugin_basename(__FILE__));
37+
defined('CBXPHPDOMPDF_ROOT_PATH') or define('CBXPHPDOMPDF_ROOT_PATH', plugin_dir_path(__FILE__));
38+
defined('CBXPHPDOMPDF_ROOT_URL') or define('CBXPHPDOMPDF_ROOT_URL', plugin_dir_url(__FILE__));
3839

39-
register_activation_hook( __FILE__, array( 'CBXPhpDomPDP', 'activation' ) );
40+
register_activation_hook(__FILE__, array('CBXPhpDomPDP', 'activation'));
41+
require_once CBXPHPDOMPDF_ROOT_PATH . "lib/vendor/autoload.php";
4042

41-
/**
42-
* Class CBXPhpDomPDP
43-
*/
44-
class CBXPhpDomPDP {
45-
function __construct() {
43+
/**
44+
* Class CBXPhpDomPDP
45+
*/
46+
class CBXPhpDomPDP
47+
{
48+
function __construct()
49+
{
4650
//load text domain
4751
load_plugin_textdomain('cbxphpdompdf', false, dirname(plugin_basename(__FILE__)) . '/languages/');
4852

49-
add_filter( 'plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2 );
53+
add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 2);
54+
new Hooks();
5055
}
5156

5257
/**
5358
* Activation hook
5459
*/
55-
public static function activation() {
60+
public static function activation()
61+
{
5662
/*$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-
);*/
63+
'PHP 7.1.0' => version_compare(PHP_VERSION, '7.1.0', '>='),
64+
'PHP extension XML' => extension_loaded('xml'),
65+
'PHP extension xmlwriter' => extension_loaded('xmlwriter'),
66+
'PHP extension mbstring' => extension_loaded('mbstring'),
67+
'PHP extension ZipArchive' => extension_loaded('zip'),
68+
'PHP extension GD (optional)' => extension_loaded('gd'),
69+
'PHP extension dom (optional)' => extension_loaded('dom'),
70+
);*/
6571

6672
if (!CBXPhpDomPDP::php_version_check()) {
6773

@@ -130,7 +136,8 @@ public static function activation() {
130136
*
131137
* @return bool
132138
*/
133-
public static function php_version_check(){
139+
public static function php_version_check()
140+
{
134141
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
135142
return false;
136143
}
@@ -143,7 +150,8 @@ public static function php_version_check(){
143150
*
144151
* @return bool
145152
*/
146-
public static function php_zip_enabled_check(){
153+
public static function php_zip_enabled_check()
154+
{
147155
if (extension_loaded('zip')) {
148156
return true;
149157
}
@@ -155,7 +163,8 @@ public static function php_zip_enabled_check(){
155163
*
156164
* @return bool
157165
*/
158-
public static function php_xml_enabled_check(){
166+
public static function php_xml_enabled_check()
167+
{
159168
if (extension_loaded('xml')) {
160169
return true;
161170
}
@@ -167,7 +176,8 @@ public static function php_xml_enabled_check(){
167176
*
168177
* @return bool
169178
*/
170-
public static function php_gd_enabled_check(){
179+
public static function php_gd_enabled_check()
180+
{
171181
if (extension_loaded('gd')) {
172182
return true;
173183
}
@@ -179,7 +189,8 @@ public static function php_gd_enabled_check(){
179189
*
180190
* @return bool
181191
*/
182-
public static function php_mbstring_enabled_check(){
192+
public static function php_mbstring_enabled_check()
193+
{
183194
if (extension_loaded('mbstring')) {
184195
return true;
185196
}
@@ -191,7 +202,8 @@ public static function php_mbstring_enabled_check(){
191202
*
192203
* @return bool
193204
*/
194-
public static function php_dom_enabled_check(){
205+
public static function php_dom_enabled_check()
206+
{
195207
if (extension_loaded('dom')) {
196208
return true;
197209
}
@@ -206,15 +218,16 @@ public static function php_dom_enabled_check(){
206218
*
207219
* @return array
208220
*/
209-
public function plugin_row_meta( $links, $file ) {
221+
public function plugin_row_meta($links, $file)
222+
{
210223

211-
if ( strpos( $file, 'cbxphpdompdf.php' ) !== false ) {
224+
if (strpos($file, 'cbxphpdompdf.php') !== false) {
212225
$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>'
226+
'support' => '<a href="https://codeboxr.com/php-dompdf-library-wordpress-plugin/" target="_blank">' . esc_html__('Support', 'cbxphpdompdf') . '</a>',
227+
'doc' => '<a href="https://github.com/dompdf/dompdf" target="_blank">' . esc_html__('PHP Dompdf Doc', 'cbxphpdompdf') . '</a>'
215228
);
216229

217-
$links = array_merge( $links, $new_links );
230+
$links = array_merge($links, $new_links);
218231
}
219232

220233
return $links;
@@ -223,8 +236,9 @@ public function plugin_row_meta( $links, $file ) {
223236
}//end method CBXPhpDomPDP
224237

225238

226-
function cbxphpdompdf_load_plugin() {
239+
function cbxphpdompdf_load_plugin()
240+
{
227241
new CBXPhpDomPDP();
228242
}
229243

230-
add_action( 'plugins_loaded', 'cbxphpdompdf_load_plugin', 5 );
244+
add_action('plugins_loaded', 'cbxphpdompdf_load_plugin', 5);

composer.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
2-
"config": {
3-
"vendor-dir": "lib/vendor"
2+
"config": {
3+
"vendor-dir": "lib/vendor"
4+
},
5+
"require": {
6+
"dompdf/dompdf": "^2.0"
7+
},
8+
"autoload": {
9+
"psr-4": {
10+
"Cbx\\Phpdompdf\\": "includes/"
411
},
5-
"require": {
6-
"dompdf/dompdf": "^2.0"
7-
}
12+
"files": []
13+
}
814
}

includes/Hooks.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Cbx\Phpdompdf;
4+
5+
6+
class Hooks
7+
{
8+
9+
public function __construct()
10+
{
11+
$this->update_checker();
12+
}
13+
14+
public function update_checker()
15+
{
16+
$updater = new PDUpdater(CBXPHPDOMPDF_ROOT_PATH . 'cbxphpdompdf.php');
17+
$updater->set_username('codeboxrcodehub');
18+
$updater->set_repository('cbxphpdompdf');
19+
$updater->authorize('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');
20+
$updater->initialize();
21+
22+
return;
23+
}//end method update_checker
24+
}//end class Hooks

0 commit comments

Comments
 (0)