@@ -172,6 +172,10 @@ public static function ensureIndex( string $table_name, string $index_name,
172172 }
173173 }
174174
175+ public static function getHookName (string $ hook_slug ) : string {
176+ return 'wp2static_ ' . $ hook_slug ;
177+ }
178+
175179 public static function getTableName (string $ table_slug ) : string {
176180 global $ wpdb ;
177181
@@ -284,7 +288,9 @@ public function deleteDeployCache() : void {
284288 public static function wp2staticUISaveOptions () : void {
285289 CoreOptions::savePosted ( 'core ' );
286290
287- do_action ( 'wp2static_addon_ui_save_options ' );
291+ do_action (
292+ Controller::getHookName ( 'addon_ui_save_options ' )
293+ );
288294
289295 check_admin_referer ( 'wp2static-ui-options ' );
290296
@@ -437,7 +443,9 @@ public static function wp2staticStaticSiteShow() : void {
437443 public static function wp2staticUISaveJobOptions () : void {
438444 CoreOptions::savePosted ( 'jobs ' );
439445
440- do_action ( 'wp2static_addon_ui_save_job_options ' );
446+ do_action (
447+ Controller::getHookName ( 'addon_ui_save_job_options ' )
448+ );
441449
442450 check_admin_referer ( 'wp2static-ui-job-options ' );
443451
@@ -461,7 +469,9 @@ public static function wp2staticTrashedPostHandler() : void {
461469 public static function wp2staticUISaveAdvancedOptions () : void {
462470 CoreOptions::savePosted ( 'advanced ' );
463471
464- do_action ( 'wp2static_addon_ui_save_advanced_options ' );
472+ do_action (
473+ Controller::getHookName ( 'addon_ui_save_advanced_options ' )
474+ );
465475
466476 check_admin_referer ( 'wp2static-ui-advanced-options ' );
467477
@@ -620,13 +630,16 @@ public static function wp2staticProcessQueue() : void {
620630 } else {
621631 WsLog::l ( 'Starting deployment ' );
622632 do_action (
623- ' wp2static_deploy ' ,
633+ Controller:: getHookName ( ' deploy ' ) ,
624634 ProcessedSite::getPath (),
625635 $ deployer
626636 );
627637 }
628638 WsLog::l ( 'Starting post-deployment actions ' );
629- do_action ( 'wp2static_post_deploy_trigger ' , $ deployer );
639+ do_action (
640+ Controller::getHookName ( 'post_deploy_trigger ' ),
641+ $ deployer
642+ );
630643
631644 break ;
632645 case 'direct_deploy ' :
@@ -675,8 +688,8 @@ public static function wp2staticProcessQueue() : void {
675688 * Make a non-blocking POST request to run wp2staticProcessQueue.
676689 */
677690 public static function wp2staticProcessQueueAdminPost () : void {
678- $ url = admin_url ( 'admin-post.php ' ) . '?action=wp2static_process_queue ' ;
679- $ nonce = wp_create_nonce ( ' wp2static_process_queue ' );
691+ $ url = admin_url ( 'admin-post.php ' ) . '?action= ' . self :: getHookName ( ' process_queue ' ) ;
692+ $ nonce = wp_create_nonce ( self :: getHookName ( ' process_queue ' ) );
680693 $ result = wp_remote_post (
681694 $ url ,
682695 [
@@ -719,13 +732,16 @@ public static function wp2staticHeadless() : void {
719732 } else {
720733 WsLog::l ( 'Starting deployment ' );
721734 do_action (
722- ' wp2static_deploy ' ,
735+ Controller:: getHookName ( ' deploy ' ) ,
723736 ProcessedSite::getPath (),
724737 $ deployer
725738 );
726739 }
727740 WsLog::l ( 'Starting post-deployment actions ' );
728- do_action ( 'wp2static_post_deploy_trigger ' , $ deployer );
741+ do_action (
742+ Controller::getHookName ( 'post_deploy_trigger ' ),
743+ $ deployer
744+ );
729745 }
730746
731747 public static function invalidateSingleURLCache (
@@ -795,9 +811,18 @@ public static function webhookDeployNotification() : void {
795811 'method ' => CoreOptions::getValue ( 'completionWebhookMethod ' ),
796812 'timeout ' => 30 ,
797813 'user-agent ' =>
798- apply_filters ( 'wp2static_deploy_webhook_user_agent ' , 'WP2Static.com ' ),
799- 'body ' => apply_filters ( 'wp2static_deploy_webhook_body ' , $ body ),
800- 'headers ' => apply_filters ( 'wp2static_deploy_webhook_headers ' , [] ),
814+ apply_filters (
815+ Controller::getHookName ( 'deploy_webhook_user_agent ' ),
816+ 'WP2Static.com '
817+ ),
818+ 'body ' => apply_filters (
819+ Controller::getHookName ( 'deploy_webhook_body ' ),
820+ $ body
821+ ),
822+ 'headers ' => apply_filters (
823+ Controller::getHookName ( 'deploy_webhook_headers ' ),
824+ []
825+ ),
801826 ]
802827 );
803828
@@ -807,7 +832,7 @@ public static function webhookDeployNotification() : void {
807832 }
808833
809834 public static function wp2staticRun () : void {
810- check_ajax_referer ( ' wp2static-run-page ' , 'security ' );
835+ check_ajax_referer ( Controller:: getHookName ( ' run_page ' ) , 'security ' );
811836
812837 WsLog::l ( 'Running full workflow from UI ' );
813838
@@ -820,7 +845,7 @@ public static function wp2staticCrawl() : void {
820845 $ crawlers = Addons::getType ( 'crawl ' );
821846 $ crawler_slug = empty ( $ crawlers ) ? 'wp2static ' : $ crawlers [0 ]->slug ;
822847 do_action (
823- ' wp2static_crawl ' ,
848+ Controller:: getHookName ( ' crawl ' ) ,
824849 $ crawler_slug
825850 );
826851 WsLog::l ( 'Crawling completed ' );
@@ -830,7 +855,7 @@ public static function wp2staticCrawl() : void {
830855 * Give logs to UI
831856 */
832857 public static function wp2staticPollLog () : void {
833- check_ajax_referer ( ' wp2static-run-page ' , 'security ' );
858+ check_ajax_referer ( Controller:: getHookName ( ' run_page ' ) , 'security ' );
834859
835860 $ logs = WsLog::poll ();
836861
0 commit comments