PluginProbe ʕ •ᴥ•ʔ
Aruba HiSpeed Cache / 3.0.15
Aruba HiSpeed Cache v3.0.15
3.0.15 3.0.14 3.0.13 1.2.4 1.2.5 1.2.6 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.19 2.0.20 2.0.21 2.0.22 2.0.23 2.0.24 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3
aruba-hispeed-cache / src / Events / AHSC_Terms.php
aruba-hispeed-cache / src / Events Last commit date
AHSC_Comments.php 5 months ago AHSC_Deferer.php 5 months ago AHSC_Plugins.php 5 months ago AHSC_PostType.php 3 days ago AHSC_Terms.php 3 days ago AHSC_Themes.php 5 months ago
AHSC_Terms.php
144 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 global $pagenow,$ahsc_term_target;
6 $ahsc_nav_purged=false;
7 if( 'nav-menus.php' !== $pagenow){
8 //if(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_archive_on_del']){
9 if(is_array(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']) && AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_archive_on_edit']){
10 /**
11 * Fires when deleting a term, before any modifications are made to posts or terms.
12 */
13 \add_action( 'pre_delete_term', 'ahsc_set_term_uri' , 200, 2 );
14
15 /**
16 * Fires after a term has been delete, and the term cache has been cleaned.
17 */
18 \add_action( 'delete_term', 'ahsc_purge_archive_on_delete' , 200, 0 );
19 }
20 }
21
22 if ( ! ahsc_current_theme_is_fse_theme() && 'nav-menus.php' === $pagenow ) {
23 if(is_array(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']) && AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_archive_on_edit']||
24 AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_archive_on_del' ]){
25
26 \add_action( 'wp_update_nav_menu', 'ahsc_update_nav_menu' , 200, 0 );
27 }
28 }
29
30 if( 'nav-menus.php' !== $pagenow) {
31 if ( is_array(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']) && AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_archive_on_edit'] ) {
32 \add_action( 'edited_term', 'ahsc_purge_archive_on_edit' , 200, 3 );
33 }
34 }
35
36 /**
37 * Fires when deleting a term, before any modifications are made to posts or terms.
38 *
39 * @param int $term Term ID.
40 * @param string $taxonomy Taxonomy name.
41 * @return void
42 */
43 function ahsc_set_term_uri( $term, $taxonomy ) {
44 global $ahsc_term_target;
45 $ahsc_term_target = \get_term_link( $term, $taxonomy );
46 }
47
48 /**
49 * Fires after a term has been updated, and the term cache has been cleaned.
50 *
51 * @see https://developer.wordpress.org/reference/hooks/delete_term/.
52 *
53 * param int $term Term ID.
54 * param int $tt_id Term taxonomy ID.
55 * param string $taxonomy Taxonomy slug.
56 * param WP_Term $deleted_term Copy of the already-deleted term.
57 * param array $object_ids List of term object IDs.
58 *
59 * @return void
60 */
61 function ahsc_purge_archive_on_delete() {
62 global $ahsc_term_target;
63 $cleaner = new \ArubaSPA\HiSpeedCache\Purger\WpPurger();
64 $cleaner->setPurger( AHSC_PURGER );
65 //$option = $this->container->get_service( 'ahsc_get_option' );
66
67 if ( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_homepage_on_del']) {
68 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
69 // Logger.
70 AHSC_log( 'hook::edited_term::home', __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
71 // Logger.
72 }
73 $cleaner->purgeAll();
74 return;
75 }
76
77 $target = $ahsc_term_target;
78 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
79 // Logger.
80 AHSC_log( 'hook::edited_term::' . $target, __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
81 // Logger.
82 }
83 $cleaner->purgeUrl( $target );
84 }
85
86 /**
87 * Fires after a nav menu has been updated, and the term cache has been cleaned.
88 *
89 * @see https://developer.wordpress.org/reference/hooks/wp_update_nav_menu/
90 *
91 * param int $menu_id ID of the updated menu.
92 * param array $menu_data An array of menu data.
93 *
94 * @return void
95 */
96 function ahsc_update_nav_menu() {
97 global $ahsc_nav_purged;
98 if ( ! $ahsc_nav_purged ) {
99 $cleaner = new \ArubaSPA\HiSpeedCache\Purger\WpPurger();
100 $cleaner->setPurger( AHSC_PURGER );
101 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
102 // Logger.
103 AHSC_log( 'hook::wp_update_nav_menu::home', __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
104 // Logger.
105 }
106 $cleaner->purgeAll();
107 }
108 $ahsc_nav_purged = true;
109 }
110
111 /**
112 * Fires after a term has been updated, and the term cache has been cleaned.
113 *
114 * @see https://developer.wordpress.org/reference/hooks/edited_term/.
115 *
116 * @param int $term_id Term ID.
117 * @param int $tt_id Term taxonomy ID.
118 * @param string $taxonomy Taxonomy slug.
119 *
120 * @return void
121 */
122 function ahsc_purge_archive_on_edit( $term_id, $tt_id, $taxonomy ) {
123
124 $cleaner = new \ArubaSPA\HiSpeedCache\Purger\WpPurger();
125 $cleaner->setPurger( AHSC_PURGER );
126 //$option = $this->container->get_service( 'ahsc_get_option' );
127 if ( AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_homepage_on_edit']) {
128 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
129 // Logger.
130 AHSC_log( 'hook::edited_term::home', __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
131 // Logger.
132 }
133 $cleaner->purgeAll();
134 return;
135 }
136
137 $target = \get_term_link( $term_id, $taxonomy );
138 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
139 // Logger.
140 AHSC_log( 'hook::edited_term::' . $target, __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
141 // Logger.
142 }
143 $cleaner->purgeUrl( $target );
144 }