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_Comments.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_Comments.php
149 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 /** check for controll options delete comment*/
6 /*if(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_page_on_deleted_comment']){
7 \add_action( 'deleted_comment', 'ahsc_purge_page_on_deleted_comment' , 200, 2 );
8 \add_action( 'rest_delete_comment', 'ahsc_purge_page_on_deleted_comment_rest' , 200, 3 );
9 }*/
10 /** check for controll options new comment*/
11 if(is_array(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']) && AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_page_on_new_comment']){
12 \add_action( 'deleted_comment', 'ahsc_purge_page_on_deleted_comment' , 200, 2 );
13 \add_action( 'rest_delete_comment', 'ahsc_purge_page_on_deleted_comment_rest' , 200, 3 );
14
15 \add_action( 'wp_insert_comment', 'ahsc_purge_page_on_new_comment' , 200, 2 );
16 \add_action( 'rest_insert_comment', 'ahsc_purge_page_on_new_comment_rest' , 200, 3 );
17 \add_action( 'transition_comment_status','ahsc_purge_page_on_transition_comment_status' , 200, 3 );
18 }
19 /*
20 if(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_page_on_deleted_comment'] ||
21 AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_page_on_new_comment']){
22 \add_action( 'transition_comment_status','ahsc_purge_page_on_transition_comment_status' , 200, 3 );
23 }*/
24
25 /**
26 * Issues a call, via the 'WpPurger' class, to the proxy cache cleaner.
27 *
28 * @param int $id the comment id.
29 * @param \WP_Comment $comment comment object.
30 *
31 * @return void
32 */
33 function ahsc_purge_page_on_deleted_comment( $id, $comment ) {
34 $cleaner =new \ArubaSPA\HiSpeedCache\Purger\WpPurger();
35 $cleaner->setPurger( AHSC_PURGER );
36 $_post_id = $comment->comment_post_ID;
37 $target = \get_permalink( $_post_id );
38
39 if(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_homepage_on_edit']){
40 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
41 // Logger.
42 AHSC_log( 'hook::deleted_comment::home' . $target, __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
43 // Logger.
44 }
45 $cleaner->purgeAll();
46 return;
47 }
48
49 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
50 // Logger.
51 AHSC_log( 'hook::deleted_comment::' . $target, __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
52 // Logger.
53 }
54 $cleaner->purgeUrl( $target );
55 }
56
57 /**
58 * Wrap for rest delete comment.
59 *
60 * @param WP_Comment $comment .
61 * @param WP_REST_Request $request .
62 * @param boolean $creating .
63 * @return void
64 */
65 function ahsc_purge_page_on_deleted_comment_rest( $comment, $request, $creating ) {
66 ahsc_purge_page_on_deleted_comment( $comment->comment_ID, $comment );
67 }
68
69
70 /**
71 * Issues a call, via the 'WpPurger' class, to the proxy cache cleaner.
72 *
73 * @param int $id the comment id.
74 * @param \WP_Comment $comment comment object.
75 *
76 * @return void
77 */
78 function ahsc_purge_page_on_new_comment( $id, $comment ) {
79 $cleaner =new \ArubaSPA\HiSpeedCache\Purger\WpPurger();
80 $cleaner->setPurger( AHSC_PURGER );
81 $_post_id = $comment->comment_post_ID;
82 $target = \get_permalink( $_post_id );
83
84 if(AHSC_CONSTANT['ARUBA_HISPEED_CACHE_OPTIONS']['ahsc_purge_homepage_on_edit']){
85 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
86 AHSC_log( 'hook::wp_insert_comment::home', __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
87 // Logger.
88 }
89 $cleaner->purgeAll();
90 return;
91 }
92
93 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
94 // Logger.
95 AHSC_log( 'hook::wp_insert_comment::' . $target, __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
96 // Logger.
97 }
98 $cleaner->purgeUrl( $target );
99 }
100
101 /**
102 * Wrap for rest insert comment.
103 *
104 * @param WP_Comment $comment .
105 * @param WP_REST_Request $request .
106 * @param boolean $creating .
107 * @return void
108 */
109 function ahsc_purge_page_on_new_comment_rest( $comment, $request, $creating ) {
110 ahsc_purge_page_on_new_comment( $comment->comment_ID, $comment );
111 }
112
113 /**
114 * Ahsc_purge_page_on_transition_comment_status
115 * Purge the cache of item or site on canghe status of the comment
116 *
117 * @param int|string $new_status new status .
118 * @param int|string $old_status old status .
119 * @param \WP_Comment $comment comment object .
120 *
121 * @return void
122 */
123 function ahsc_purge_page_on_transition_comment_status( $new_status, $old_status, $comment ) {
124 $cleaner =new \ArubaSPA\HiSpeedCache\Purger\WpPurger();
125 $cleaner->setPurger( AHSC_PURGER );
126 $_post_id = $comment->comment_post_ID;
127 $target = \get_permalink( $_post_id );
128
129 if ( 'approved' === $new_status ) {
130 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
131 // Logger.
132 AHSC_log( 'hook:approved:transition_comment_status::' . $target, __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
133 // Logger.
134 }
135 $cleaner->purgeUrl( $target );
136 return;
137 }
138
139 if ( 'trash' === $new_status ) {
140 if ( 'approved' === $old_status ) {
141 if(class_exists('ArubaSPA\HiSpeedCache\Debug\Logger')) {
142 // Logger.
143 AHSC_log( 'hook:trash:transition_comment_status::' . $target, __NAMESPACE__ . '::' . __FUNCTION__, 'debug' );
144 // Logger.
145 }
146 $cleaner->purgeUrl( $target );
147 }
148 }
149 }