Skip to content

Commit da052cb

Browse files
committed
update checker added
1 parent f6a8f0b commit da052cb

File tree

4 files changed

+329
-68
lines changed

4 files changed

+329
-68
lines changed

cbxtaxonomy.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Plugin Name: CBX Taxonomy
1717
* Plugin URI: https://wordpress.org/plugins/cbxtaxonomy
1818
* Description: Custom taxonomy system for custom table/custom object types. This feature plugin is required for CBXResume, CBXJob and others codeboxr's plugins.
19-
* Version: 1.0.1
19+
* Version: 1.0.0
2020
* Requires at least: 3.5
2121
* Requires PHP: 7.4
2222
* Author: Codeboxr
@@ -28,47 +28,50 @@
2828
*/
2929

3030
// If this file is called directly, abort.
31-
if ( ! defined( 'WPINC' ) ) {
31+
if (!defined('WPINC')) {
3232
die;
3333
}
3434

35-
defined( 'CBXTAXONOMY_PLUGIN_NAME' ) or define( 'CBXTAXONOMY_PLUGIN_NAME', 'cbxtaxonomy' );
36-
defined( 'CBXTAXONOMY_PLUGIN_VERSION' ) or define( 'CBXTAXONOMY_PLUGIN_VERSION', '1.0.1' );
37-
defined( 'CBXTAXONOMY_BASE_NAME' ) or define( 'CBXTAXONOMY_BASE_NAME', plugin_basename( __FILE__ ) );
38-
defined( 'CBXTAXONOMY_ROOT_PATH' ) or define( 'CBXTAXONOMY_ROOT_PATH', plugin_dir_path( __FILE__ ) );
39-
defined( 'CBXTAXONOMY_ROOT_URL' ) or define( 'CBXTAXONOMY_ROOT_URL', plugin_dir_url( __FILE__ ) );
40-
defined( 'CBXTAXONOMY_DEV_MODE' ) or define( 'CBXTAXONOMY_DEV_MODE', true );
35+
defined('CBXTAXONOMY_PLUGIN_NAME') or define('CBXTAXONOMY_PLUGIN_NAME', 'cbxtaxonomy');
36+
defined('CBXTAXONOMY_PLUGIN_VERSION') or define('CBXTAXONOMY_PLUGIN_VERSION', '1.0.0');
37+
defined('CBXTAXONOMY_BASE_NAME') or define('CBXTAXONOMY_BASE_NAME', plugin_basename(__FILE__));
38+
defined('CBXTAXONOMY_ROOT_PATH') or define('CBXTAXONOMY_ROOT_PATH', plugin_dir_path(__FILE__));
39+
defined('CBXTAXONOMY_ROOT_URL') or define('CBXTAXONOMY_ROOT_URL', plugin_dir_url(__FILE__));
40+
defined('CBXTAXONOMY_DEV_MODE') or define('CBXTAXONOMY_DEV_MODE', true);
4141

4242
require_once CBXTAXONOMY_ROOT_PATH . "lib/autoload.php";
4343

44-
register_activation_hook( __FILE__, 'activate_cbxtaxonomy' );
45-
register_deactivation_hook( __FILE__, 'deactivate_cbxtaxonomy' );
44+
register_activation_hook(__FILE__, 'activate_cbxtaxonomy');
45+
register_deactivation_hook(__FILE__, 'deactivate_cbxtaxonomy');
4646

4747
/**
4848
* * The code that runs during plugin activation.
4949
* The code that runs during plugin deactivation.
5050
*/
51-
function activate_cbxtaxonomy() {
51+
function activate_cbxtaxonomy()
52+
{
5253
\Cbx\Taxonomy\CBXTaxonomyHelper::load_orm();
5354
\Cbx\Taxonomy\CBXTaxonomyHelper::active_plugin();
5455
}
5556

5657
/**
5758
* The code that runs during plugin deactivation.
5859
*/
59-
function deactivate_cbxtaxonomy() {
60+
function deactivate_cbxtaxonomy()
61+
{
6062
\Cbx\Taxonomy\CBXTaxonomyHelper::load_orm();
6163
}
6264

6365

6466
/**
6567
* Init cbxtaxonomy plugin
6668
*/
67-
function cbxtaxonomy() {
68-
if ( defined( 'CBXTAXONOMY_PLUGIN_NAME' ) ) {
69+
function cbxtaxonomy()
70+
{
71+
if (defined('CBXTAXONOMY_PLUGIN_NAME')) {
6972
\Cbx\Taxonomy\CBXTaxonomy::instance();
7073
}
7174
}//end function cbxtaxonomy
7275

73-
add_action( 'plugins_loaded', 'cbxtaxonomy' );
76+
add_action('plugins_loaded', 'cbxtaxonomy');
7477

includes/CBXTaxonomy.php

Lines changed: 69 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* @package Cbx\Taxonomy
88
* @since 1.0.0
99
*/
10-
class CBXTaxonomy {
10+
class CBXTaxonomy
11+
{
1112

1213
/**
1314
* @var null
@@ -32,13 +33,15 @@ class CBXTaxonomy {
3233
*
3334
* @since 1.0.0
3435
*/
35-
public function __construct() {
36-
$this->version = CBXTAXONOMY_PLUGIN_VERSION;
36+
public function __construct()
37+
{
38+
$this->version = CBXTAXONOMY_PLUGIN_VERSION;
3739
$this->plugin_name = CBXTAXONOMY_PLUGIN_NAME;
3840

3941
//$this->unit_testing();
4042
$this->load_orm();
4143
$this->load_plugin_textdomain();
44+
$this->hooks = new Hooks();
4245
}//end of method constructor
4346

4447
/**
@@ -47,8 +50,9 @@ public function __construct() {
4750
* @return CBXTaxonomy
4851
* @since 1.0.0
4952
*/
50-
public static function instance() {
51-
if ( is_null( self::$instance ) ) {
53+
public static function instance()
54+
{
55+
if (is_null(self::$instance)) {
5256
self::$instance = new self();
5357
}
5458

@@ -60,53 +64,56 @@ public static function instance() {
6064
*
6165
* @since 1.0.0
6266
*/
63-
public function load_plugin_textdomain() {
64-
load_plugin_textdomain( 'cbxtaxonomy', false, CBXTAXONOMY_ROOT_PATH . 'languages/' );
67+
public function load_plugin_textdomain()
68+
{
69+
load_plugin_textdomain('cbxtaxonomy', false, CBXTAXONOMY_ROOT_PATH . 'languages/');
6570
}//end method load_plugin_textdomain
6671

6772
/**
6873
* Load ORM using helper class
6974
*
7075
* @since 1.0.0
7176
*/
72-
public function load_orm() {
77+
public function load_orm()
78+
{
7379
$taxonomy_helper = new CBXTaxonomyHelper();
74-
add_action( 'init', [ $taxonomy_helper, 'load_orm' ] );
80+
add_action('init', [$taxonomy_helper, 'load_orm']);
7581
} // end of load_orm
7682

7783
/**
7884
* Run test hooks
7985
*
8086
* @since 1.0.0
8187
*/
82-
public function unit_testing() {
83-
if ( CBXTAXONOMY_DEV_MODE ) {
84-
add_action( 'cbxtaxonomy_taxable_delete_before', [
88+
public function unit_testing()
89+
{
90+
if (CBXTAXONOMY_DEV_MODE) {
91+
add_action('cbxtaxonomy_taxable_delete_before', [
8592
$this,
8693
'cbxtaxonomy_taxable_delete_before_test'
87-
], 10, 3 );
88-
add_action( 'cbxtaxonomy_taxable_delete_after', [ $this, 'cbxtaxonomy_taxable_delete_after_test' ], 10, 3 );
89-
add_action( 'cbxtaxonomy_taxable_delete_failed', [
94+
], 10, 3);
95+
add_action('cbxtaxonomy_taxable_delete_after', [$this, 'cbxtaxonomy_taxable_delete_after_test'], 10, 3);
96+
add_action('cbxtaxonomy_taxable_delete_failed', [
9097
$this,
9198
'cbxtaxonomy_taxable_delete_failed_test'
92-
], 10, 3 );
99+
], 10, 3);
93100

94-
add_action( 'cbxtaxonomy_taxonomy_delete_before', [
101+
add_action('cbxtaxonomy_taxonomy_delete_before', [
95102
$this,
96103
'cbxtaxonomy_taxonomy_delete_before_test'
97-
], 10, 3 );
98-
add_action( 'cbxtaxonomy_taxonomy_delete_after', [
104+
], 10, 3);
105+
add_action('cbxtaxonomy_taxonomy_delete_after', [
99106
$this,
100107
'cbxtaxonomy_taxonomy_delete_after_test'
101-
], 10, 3 );
102-
add_action( 'cbxtaxonomy_taxonomy_delete_failed', [
108+
], 10, 3);
109+
add_action('cbxtaxonomy_taxonomy_delete_failed', [
103110
$this,
104111
'cbxtaxonomy_taxonomy_delete_failed_test'
105-
], 10, 3 );
112+
], 10, 3);
106113

107-
add_action( 'cbxtaxonomy_taxonomy_save_before', [ $this, 'cbxtaxonomy_taxonomy_save_before_test' ], 10, 2 );
108-
add_action( 'cbxtaxonomy_taxonomy_save_after', [ $this, 'cbxtaxonomy_taxonomy_save_after_test' ], 10, 2 );
109-
add_action( 'cbxtaxonomy_taxonomy_save_failed', [ $this, 'cbxtaxonomy_taxonomy_save_failed_test' ], 10, 2 );
114+
add_action('cbxtaxonomy_taxonomy_save_before', [$this, 'cbxtaxonomy_taxonomy_save_before_test'], 10, 2);
115+
add_action('cbxtaxonomy_taxonomy_save_after', [$this, 'cbxtaxonomy_taxonomy_save_after_test'], 10, 2);
116+
add_action('cbxtaxonomy_taxonomy_save_failed', [$this, 'cbxtaxonomy_taxonomy_save_failed_test'], 10, 2);
110117
}
111118
} // end of unit_testing
112119

@@ -119,9 +126,10 @@ public function unit_testing() {
119126
*
120127
* @since 1.0.0
121128
*/
122-
public function cbxtaxonomy_taxable_delete_before_test( $taxonomy_id, $type, $data ) {
123-
if ( function_exists( 'write_log' ) ) {
124-
write_log( 'before taxable delete hook $taxonomy_id=' . $taxonomy_id . ' $type=' . $type );
129+
public function cbxtaxonomy_taxable_delete_before_test($taxonomy_id, $type, $data)
130+
{
131+
if (function_exists('write_log')) {
132+
write_log('before taxable delete hook $taxonomy_id=' . $taxonomy_id . ' $type=' . $type);
125133
}
126134
}//end of cbxtaxonomy_taxable_delete_before_test
127135

@@ -134,9 +142,10 @@ public function cbxtaxonomy_taxable_delete_before_test( $taxonomy_id, $type, $da
134142
*
135143
* @since 1.0.0
136144
*/
137-
public function cbxtaxonomy_taxable_delete_after_test( $taxonomy_id, $type, $data ) {
138-
if ( function_exists( 'write_log' ) ) {
139-
write_log( 'before taxable delete hook $taxonomy_id=' . $taxonomy_id . ' $type=' . $type );
145+
public function cbxtaxonomy_taxable_delete_after_test($taxonomy_id, $type, $data)
146+
{
147+
if (function_exists('write_log')) {
148+
write_log('before taxable delete hook $taxonomy_id=' . $taxonomy_id . ' $type=' . $type);
140149
}
141150

142151
}//end of cbxtaxonomy_taxable_delete_after_test
@@ -150,9 +159,10 @@ public function cbxtaxonomy_taxable_delete_after_test( $taxonomy_id, $type, $dat
150159
*
151160
* @since 1.0.0
152161
*/
153-
public function cbxtaxonomy_taxable_delete_failed_test( $taxonomy_id, $type, $data ) {
154-
if ( function_exists( 'write_log' ) ) {
155-
write_log( 'before taxable delete hook $taxonomy_id=' . $taxonomy_id . ' $type=' . $type );
162+
public function cbxtaxonomy_taxable_delete_failed_test($taxonomy_id, $type, $data)
163+
{
164+
if (function_exists('write_log')) {
165+
write_log('before taxable delete hook $taxonomy_id=' . $taxonomy_id . ' $type=' . $type);
156166
}
157167

158168
}//end of cbxtaxonomy_taxable_delete_failed_test
@@ -166,9 +176,10 @@ public function cbxtaxonomy_taxable_delete_failed_test( $taxonomy_id, $type, $da
166176
*
167177
* @since 1.0.0
168178
*/
169-
public function cbxtaxonomy_taxonomy_delete_before_test( $id, $type, $data ) {
170-
if ( function_exists( 'write_log' ) ) {
171-
write_log( $id . " here is the id => " . $type );
179+
public function cbxtaxonomy_taxonomy_delete_before_test($id, $type, $data)
180+
{
181+
if (function_exists('write_log')) {
182+
write_log($id . " here is the id => " . $type);
172183
}
173184
}//end of cbxtaxonomy_taxonomy_delete_before_test
174185

@@ -181,9 +192,10 @@ public function cbxtaxonomy_taxonomy_delete_before_test( $id, $type, $data ) {
181192
*
182193
* @since 1.0.0
183194
*/
184-
public function cbxtaxonomy_taxonomy_delete_after_test( $id, $type, $data ) {
185-
if ( function_exists( 'write_log' ) ) {
186-
write_log( $id . " here is the id => " . $type );
195+
public function cbxtaxonomy_taxonomy_delete_after_test($id, $type, $data)
196+
{
197+
if (function_exists('write_log')) {
198+
write_log($id . " here is the id => " . $type);
187199
}
188200
}//end of cbxtaxonomy_taxonomy_delete_after_test
189201

@@ -196,9 +208,10 @@ public function cbxtaxonomy_taxonomy_delete_after_test( $id, $type, $data ) {
196208
*
197209
* @since 1.0.0
198210
*/
199-
public function cbxtaxonomy_taxonomy_delete_failed_test( $id, $type, $data ) {
200-
if ( function_exists( 'write_log' ) ) {
201-
write_log( $id . " here is the id => " . $type );
211+
public function cbxtaxonomy_taxonomy_delete_failed_test($id, $type, $data)
212+
{
213+
if (function_exists('write_log')) {
214+
write_log($id . " here is the id => " . $type);
202215
}
203216
}//end of cbxtaxonomy_taxonomy_delete_failed_test
204217

@@ -210,11 +223,12 @@ public function cbxtaxonomy_taxonomy_delete_failed_test( $id, $type, $data ) {
210223
*
211224
* @since 1.0.0
212225
*/
213-
public function cbxtaxonomy_taxonomy_save_before_test( $type, $data ) {
214-
if ( function_exists( 'write_log' ) ) {
215-
write_log( "taxonomy save here is the id => " . $type );
226+
public function cbxtaxonomy_taxonomy_save_before_test($type, $data)
227+
{
228+
if (function_exists('write_log')) {
229+
write_log("taxonomy save here is the id => " . $type);
216230
} else {
217-
error_log( "taxonomy save here is the id => " . $type );
231+
error_log("taxonomy save here is the id => " . $type);
218232
}
219233
}//end of cbxtaxonomy_taxonomy_save_before_test
220234

@@ -226,9 +240,10 @@ public function cbxtaxonomy_taxonomy_save_before_test( $type, $data ) {
226240
*
227241
* @since 1.0.0
228242
*/
229-
public function cbxtaxonomy_taxonomy_save_after_test( $type, $data ) {
230-
if ( function_exists( 'write_log' ) ) {
231-
write_log( "taxonomy save here is the id => " . $type );
243+
public function cbxtaxonomy_taxonomy_save_after_test($type, $data)
244+
{
245+
if (function_exists('write_log')) {
246+
write_log("taxonomy save here is the id => " . $type);
232247
}
233248
}//end of cbxtaxonomy_taxonomy_save_after_test
234249

@@ -240,9 +255,10 @@ public function cbxtaxonomy_taxonomy_save_after_test( $type, $data ) {
240255
*
241256
* @since 1.0.0
242257
*/
243-
public function cbxtaxonomy_taxonomy_save_failed_test( $type, $data ) {
244-
if ( function_exists( 'write_log' ) ) {
245-
write_log( "taxonomy save here is the id => " . $type );
258+
public function cbxtaxonomy_taxonomy_save_failed_test($type, $data)
259+
{
260+
if (function_exists('write_log')) {
261+
write_log("taxonomy save here is the id => " . $type);
246262
}
247263
}//end of cbxtaxonomy_taxonomy_save_failed_test
248264

includes/Hooks.php

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

0 commit comments

Comments
 (0)