Skip to content

Commit d4b6d62

Browse files
committed
Use Hook_Registry
1 parent 9e67cc8 commit d4b6d62

15 files changed

+318
-43
lines changed

includes/admin/class-activator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace WebberZone\Knowledge_Base\Admin;
1313

1414
use WebberZone\Knowledge_Base\CPT;
15+
use WebberZone\Knowledge_Base\Util\Hook_Registry;
1516

1617
/**
1718
* Class Activator
@@ -26,7 +27,7 @@ class Activator {
2627
* @since 3.3.0
2728
*/
2829
public function __construct() {
29-
add_action( 'wp_initialize_site', array( $this, 'activate_new_site' ) );
30+
Hook_Registry::add_action( 'wp_initialize_site', array( $this, 'activate_new_site' ) );
3031
}
3132

3233
/**

includes/admin/class-admin-columns.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace WebberZone\Knowledge_Base\Admin;
99

10+
use WebberZone\Knowledge_Base\Util\Hook_Registry;
11+
1012
// If this file is called directly, abort.
1113
if ( ! defined( 'WPINC' ) ) {
1214
die;
@@ -25,20 +27,20 @@ class Admin_Columns {
2527
* @since 2.3.0
2628
*/
2729
public function __construct() {
28-
add_filter( 'manage_edit-wzkb_category_columns', array( $this, 'tax_columns' ) );
29-
add_filter( 'manage_edit-wzkb_category_sortable_columns', array( $this, 'tax_sortable_columns' ) );
30-
add_filter( 'manage_edit-wzkb_tag_columns', array( $this, 'tax_columns' ) );
31-
add_filter( 'manage_edit-wzkb_tag_sortable_columns', array( $this, 'tax_sortable_columns' ) );
30+
Hook_Registry::add_filter( 'manage_edit-wzkb_category_columns', array( $this, 'tax_columns' ) );
31+
Hook_Registry::add_filter( 'manage_edit-wzkb_category_sortable_columns', array( $this, 'tax_sortable_columns' ) );
32+
Hook_Registry::add_filter( 'manage_edit-wzkb_tag_columns', array( $this, 'tax_columns' ) );
33+
Hook_Registry::add_filter( 'manage_edit-wzkb_tag_sortable_columns', array( $this, 'tax_sortable_columns' ) );
3234

33-
add_filter( 'manage_wzkb_category_custom_column', array( $this, 'tax_id' ), 10, 3 );
34-
add_filter( 'manage_wzkb_tag_custom_column', array( $this, 'tax_id' ), 10, 3 );
35+
Hook_Registry::add_filter( 'manage_wzkb_category_custom_column', array( $this, 'tax_id' ), 10, 3 );
36+
Hook_Registry::add_filter( 'manage_wzkb_tag_custom_column', array( $this, 'tax_id' ), 10, 3 );
3537

3638
// Register Product filter for Articles admin screen.
37-
add_action( 'restrict_manage_posts', array( $this, 'add_product_filter_dropdown' ) );
38-
add_action( 'pre_get_posts', array( $this, 'filter_articles_by_product' ) );
39+
Hook_Registry::add_action( 'restrict_manage_posts', array( $this, 'add_product_filter_dropdown' ) );
40+
Hook_Registry::add_action( 'pre_get_posts', array( $this, 'filter_articles_by_product' ) );
3941

4042
// Add sorting.
41-
add_filter( 'terms_clauses', array( $this, 'sort_terms_by_product' ), 10, 2 );
43+
Hook_Registry::add_filter( 'terms_clauses', array( $this, 'sort_terms_by_product' ), 10, 2 );
4244
}
4345

4446
/**

includes/admin/class-admin.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WebberZone\Knowledge_Base\Admin;
1111

1212
use WebberZone\Knowledge_Base\Util\Cache;
13+
use WebberZone\Knowledge_Base\Util\Hook_Registry;
1314

1415
// If this file is called directly, abort.
1516
if ( ! defined( 'WPINC' ) ) {
@@ -90,11 +91,11 @@ public function __construct() {
9091
* @since 2.3.0
9192
*/
9293
public function hooks() {
93-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
94-
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
95-
add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10, 1 );
96-
add_filter( 'admin_head', array( $this, 'admin_head' ) );
97-
add_action( 'admin_footer', array( $this, 'maybe_add_button_to_post_list' ) );
94+
Hook_Registry::add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
95+
Hook_Registry::add_action( 'admin_notices', array( $this, 'admin_notices' ) );
96+
Hook_Registry::add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10, 1 );
97+
Hook_Registry::add_filter( 'admin_head', array( $this, 'admin_head' ) );
98+
Hook_Registry::add_action( 'admin_footer', array( $this, 'maybe_add_button_to_post_list' ) );
9899
}
99100

100101
/**

includes/admin/class-product-migrator.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace WebberZone\Knowledge_Base\Admin;
99

10+
use WebberZone\Knowledge_Base\Util\Hook_Registry;
11+
1012
if ( ! defined( 'WPINC' ) ) {
1113
die;
1214
}
@@ -49,10 +51,10 @@ class Product_Migrator {
4951
* Constructor: Hook admin notices and menu.
5052
*/
5153
public function __construct() {
52-
add_action( 'admin_notices', array( $this, 'maybe_show_enable_notice' ) );
53-
add_action( 'admin_menu', array( $this, 'register_migration_wizard_page' ) );
54-
add_action( 'wp_ajax_wzkb_dismiss_product_notice', array( $this, 'dismiss_product_notice' ) );
55-
add_action( 'wp_ajax_wzkb_product_migration_batch', array( $this, 'handle_migration_batch' ) );
54+
Hook_Registry::add_action( 'admin_notices', array( $this, 'maybe_show_enable_notice' ) );
55+
Hook_Registry::add_action( 'admin_menu', array( $this, 'register_migration_wizard_page' ) );
56+
Hook_Registry::add_action( 'wp_ajax_wzkb_dismiss_product_notice', array( $this, 'dismiss_product_notice' ) );
57+
Hook_Registry::add_action( 'wp_ajax_wzkb_product_migration_batch', array( $this, 'handle_migration_batch' ) );
5658
}
5759

5860
/**
@@ -111,7 +113,7 @@ public function register_migration_wizard_page() {
111113
'wzkb-product-migration',
112114
array( $this, 'render_migration_wizard' ),
113115
);
114-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
116+
Hook_Registry::add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
115117
}
116118

117119
/**

includes/admin/class-settings.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace WebberZone\Knowledge_Base\Admin;
1111

12+
use WebberZone\Knowledge_Base\Util\Hook_Registry;
13+
1214
// If this file is called directly, abort.
1315
if ( ! defined( 'WPINC' ) ) {
1416
die;
@@ -140,13 +142,13 @@ public function __construct() {
140142
self::$prefix = 'wzkb';
141143
$this->menu_slug = 'wzkb-settings';
142144

143-
add_action( 'admin_menu', array( $this, 'initialise_settings' ) );
144-
add_action( 'admin_head', array( $this, 'admin_head' ), 11 );
145-
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 11, 2 );
146-
add_filter( 'plugin_action_links_' . plugin_basename( WZKB_PLUGIN_FILE ), array( $this, 'plugin_actions_links' ) );
147-
add_filter( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 99 );
145+
Hook_Registry::add_action( 'admin_menu', array( $this, 'initialise_settings' ) );
146+
Hook_Registry::add_action( 'admin_head', array( $this, 'admin_head' ), 11 );
147+
Hook_Registry::add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 11, 2 );
148+
Hook_Registry::add_filter( 'plugin_action_links_' . plugin_basename( WZKB_PLUGIN_FILE ), array( $this, 'plugin_actions_links' ) );
149+
Hook_Registry::add_filter( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 99 );
148150

149-
add_filter( self::$prefix . '_settings_sanitize', array( $this, 'change_settings_on_save' ), 99 );
151+
Hook_Registry::add_filter( self::$prefix . '_settings_sanitize', array( $this, 'change_settings_on_save' ), 99 );
150152
}
151153

152154
/**

includes/blocks/class-blocks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
namespace WebberZone\Knowledge_Base\Blocks;
1010

11+
use WebberZone\Knowledge_Base\Util\Hook_Registry;
1112
use WebberZone\Knowledge_Base\Frontend\Display;
12-
use WebberZone\Knowledge_Base\Frontend\Breadcrumbs;
1313

1414
// If this file is called directly, abort.
1515
if ( ! defined( 'WPINC' ) ) {
@@ -29,7 +29,7 @@ class Blocks {
2929
* @since 2.3.0
3030
*/
3131
public function __construct() {
32-
add_action( 'init', array( $this, 'register_blocks' ) );
32+
Hook_Registry::add_action( 'init', array( $this, 'register_blocks' ) );
3333
}
3434

3535
/**

includes/class-cpt.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace WebberZone\Knowledge_Base;
99

10+
use WebberZone\Knowledge_Base\Util\Hook_Registry;
11+
1012
// If this file is called directly, abort.
1113
if ( ! defined( 'WPINC' ) ) {
1214
die;
@@ -25,8 +27,8 @@ class CPT {
2527
* @since 2.3.0
2628
*/
2729
public function __construct() {
28-
add_action( 'init', array( $this, 'register_post_type' ) );
29-
add_action( 'init', array( $this, 'register_taxonomies' ) );
30+
Hook_Registry::add_action( 'init', array( $this, 'register_post_type' ) );
31+
Hook_Registry::add_action( 'init', array( $this, 'register_taxonomies' ) );
3032
}
3133

3234
/**

includes/class-main.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use WebberZone\Knowledge_Base\Admin\Admin;
1111
use WebberZone\Knowledge_Base\Pro\Pro;
12+
use WebberZone\Knowledge_Base\Util\Hook_Registry;
1213

1314
if ( ! defined( 'WPINC' ) ) {
1415
exit;
@@ -195,8 +196,8 @@ private function init() {
195196
* @since 2.3.0
196197
*/
197198
public function hooks() {
198-
add_action( 'init', array( $this, 'initiate_plugin' ) );
199-
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
199+
Hook_Registry::add_action( 'init', array( $this, 'initiate_plugin' ) );
200+
Hook_Registry::add_action( 'widgets_init', array( $this, 'register_widgets' ) );
200201
}
201202

202203
/**

includes/class-options-api.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace WebberZone\Knowledge_Base;
1111

12+
use WebberZone\Knowledge_Base\Util\Hook_Registry;
13+
1214
if ( ! defined( 'WPINC' ) ) {
1315
die;
1416
}
@@ -50,7 +52,7 @@ class Options_API {
5052
* @since 3.0.0
5153
*/
5254
public static function init() {
53-
add_action( 'wp_ajax_' . self::FILTER_PREFIX . '_tags_search', array( __CLASS__, 'tags_search' ) );
55+
Hook_Registry::add_action( 'wp_ajax_' . self::FILTER_PREFIX . '_tags_search', array( __CLASS__, 'tags_search' ) );
5456
}
5557

5658
/**

includes/frontend/class-feed.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace WebberZone\Knowledge_Base\Frontend;
99

10+
use WebberZone\Knowledge_Base\Util\Hook_Registry;
11+
1012
// If this file is called directly, abort.
1113
if ( ! defined( 'WPINC' ) ) {
1214
die;
@@ -21,7 +23,7 @@ class Feed {
2123
* Constructor.
2224
*/
2325
public function __construct() {
24-
add_filter( 'request', array( $this, 'in_feed' ), 11 );
26+
Hook_Registry::add_filter( 'request', array( $this, 'in_feed' ), 11 );
2527
}
2628

2729
/**

0 commit comments

Comments
 (0)