Skip to content

Commit 600702a

Browse files
committed
Remove wp2static name from admin hook handlers
Prep for name change.
1 parent 10bb0d7 commit 600702a

6 files changed

Lines changed: 72 additions & 71 deletions

File tree

src/CLI.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public function crawl( array $args, array $assoc_args ): void {
397397
WP_CLI::error( 'No arguments or parameters are accepted for this command.' );
398398
}
399399
Options::init();
400-
Controller::wp2staticCrawl();
400+
Controller::crawl();
401401
}
402402

403403
/**
@@ -428,7 +428,7 @@ public function process_queue(): void {
428428
} else {
429429
WP_CLI::line( ' Processing ' . $job_count . ' job' . ( $job_count > 1 ? 's' : '' ) );
430430

431-
Controller::wp2staticProcessQueue();
431+
Controller::processQueue();
432432

433433
WP_CLI::success( 'Done processing queue' );
434434
}
@@ -776,7 +776,7 @@ public function addons( array $args, array $assoc_args ): void {
776776
}
777777

778778
// TODO Output details on if addon was enabled or disabled
779-
Controller::wp2staticToggleAddon( $addon_slug );
779+
Controller::adminToggleAddon( $addon_slug );
780780
}
781781
}
782782
}

src/Controller.php

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public function deleteDeployCache(): void {
291291
DeployCache::truncate();
292292
}
293293

294-
public static function wp2staticUISaveOptions(): void {
294+
public static function UISaveOptions(): void {
295295
Options::savePosted( 'core' );
296296

297297
do_action(
@@ -304,7 +304,7 @@ public static function wp2staticUISaveOptions(): void {
304304
exit;
305305
}
306306

307-
public static function wp2staticDetectedFilesDelete(): void {
307+
public static function adminDetectedFilesDelete(): void {
308308
check_admin_referer( 'wp2static-caches-page' );
309309

310310
DetectedFiles::truncate();
@@ -313,14 +313,14 @@ public static function wp2staticDetectedFilesDelete(): void {
313313
exit;
314314
}
315315

316-
public static function wp2staticDetectedFilesShow(): void {
316+
public static function adminDetectedFilesShow(): void {
317317
check_admin_referer( 'wp2static-caches-page' );
318318

319319
wp_safe_redirect( admin_url( 'admin.php?page=wp2static-detected-files' ) );
320320
exit;
321321
}
322322

323-
public static function wp2staticDeleteJobsQueue(): void {
323+
public static function adminDeleteJobsQueue(): void {
324324
check_admin_referer( 'wp2static-ui-job-options' );
325325

326326
JobQueue::truncate();
@@ -329,7 +329,7 @@ public static function wp2staticDeleteJobsQueue(): void {
329329
exit;
330330
}
331331

332-
public static function wp2staticDeleteAllCaches(): void {
332+
public static function adminDeleteAllCaches(): void {
333333
check_admin_referer( 'wp2static-caches-page' );
334334

335335
self::deleteAllCaches();
@@ -346,18 +346,18 @@ public static function deleteAllCaches(): void {
346346
DeployCache::truncate();
347347
}
348348

349-
public static function wp2staticProcessJobsQueue(): void {
349+
public static function adminProcessJobsQueue(): void {
350350
check_admin_referer( 'wp2static-ui-job-options' );
351351

352352
WsLog::l( 'Manually processing JobQueue' );
353353

354-
self::wp2staticProcessQueue();
354+
self::processQueue();
355355

356356
wp_safe_redirect( admin_url( 'admin.php?page=wp2static-jobs' ) );
357357
exit;
358358
}
359359

360-
public static function wp2staticDeployCacheDelete(): void {
360+
public static function adminDeployCacheDelete(): void {
361361
check_admin_referer( 'wp2static-caches-page' );
362362

363363
$deploy_namespace = strval( filter_input( INPUT_POST, 'deploy_namespace' ) );
@@ -371,7 +371,7 @@ public static function wp2staticDeployCacheDelete(): void {
371371
exit;
372372
}
373373

374-
public static function wp2staticDeployCacheShow(): void {
374+
public static function adminDeployCacheShow(): void {
375375
check_admin_referer( 'wp2static-caches-page' );
376376

377377
$deploy_namespace = strval( filter_input( INPUT_POST, 'deploy_namespace' ) );
@@ -389,7 +389,7 @@ public static function wp2staticDeployCacheShow(): void {
389389
exit;
390390
}
391391

392-
public static function wp2staticCrawledFilesDelete(): void {
392+
public static function adminCrawledFilesDelete(): void {
393393
check_admin_referer( 'wp2static-caches-page' );
394394

395395
CrawledFiles::truncate();
@@ -398,14 +398,14 @@ public static function wp2staticCrawledFilesDelete(): void {
398398
exit;
399399
}
400400

401-
public static function wp2staticCrawledFilesShow(): void {
401+
public static function adminCrawledFilesShow(): void {
402402
check_admin_referer( 'wp2static-caches-page' );
403403

404404
wp_safe_redirect( admin_url( 'admin.php?page=wp2static-crawled-files' ) );
405405
exit;
406406
}
407407

408-
public static function wp2staticPostProcessedSiteDelete(): void {
408+
public static function adminPostProcessedSiteDelete(): void {
409409
check_admin_referer( 'wp2static-caches-page' );
410410

411411
ProcessedSite::delete();
@@ -414,14 +414,14 @@ public static function wp2staticPostProcessedSiteDelete(): void {
414414
exit;
415415
}
416416

417-
public static function wp2staticPostProcessedSiteShow(): void {
417+
public static function adminPostProcessedSiteShow(): void {
418418
check_admin_referer( 'wp2static-caches-page' );
419419

420420
wp_safe_redirect( admin_url( 'admin.php?page=wp2static-post-processed-site' ) );
421421
exit;
422422
}
423423

424-
public static function wp2staticLogDelete(): void {
424+
public static function adminLogDelete(): void {
425425
check_admin_referer( 'wp2static-log-page' );
426426

427427
WsLog::truncate();
@@ -430,7 +430,7 @@ public static function wp2staticLogDelete(): void {
430430
exit;
431431
}
432432

433-
public static function wp2staticStaticSiteDelete(): void {
433+
public static function adminStaticSiteDelete(): void {
434434
check_admin_referer( 'wp2static-caches-page' );
435435

436436
StaticSite::delete();
@@ -439,14 +439,14 @@ public static function wp2staticStaticSiteDelete(): void {
439439
exit;
440440
}
441441

442-
public static function wp2staticStaticSiteShow(): void {
442+
public static function adminStaticSiteShow(): void {
443443
check_admin_referer( 'wp2static-caches-page' );
444444

445445
wp_safe_redirect( admin_url( 'admin.php?page=wp2static-static-site' ) );
446446
exit;
447447
}
448448

449-
public static function wp2staticUISaveJobOptions(): void {
449+
public static function adminUISaveJobsOptions(): void {
450450
Options::savePosted( 'jobs' );
451451

452452
do_action(
@@ -459,20 +459,20 @@ public static function wp2staticUISaveJobOptions(): void {
459459
exit;
460460
}
461461

462-
public static function wp2staticSavePostHandler( int $post_id ): void {
462+
public static function savePostHandler( int $post_id ): void {
463463
if ( Options::getValue( 'queueJobOnPostSave' ) &&
464464
get_post_status( $post_id ) === 'publish' ) {
465465
self::wp2staticEnqueueJobs( $post_id );
466466
}
467467
}
468468

469-
public static function wp2staticTrashedPostHandler(): void {
469+
public static function trashedPostHandler(): void {
470470
if ( Options::getValue( 'queueJobOnPostDelete' ) ) {
471471
self::wp2staticEnqueueJobs();
472472
}
473473
}
474474

475-
public static function wp2staticUISaveAdvancedOptions(): void {
475+
public static function adminUISaveAdvancedOptions(): void {
476476
Options::savePosted( 'advanced' );
477477

478478
do_action(
@@ -504,14 +504,14 @@ public static function wp2staticEnqueueJobs( ?int $post_id = null ): void {
504504

505505
$immediate_mode = intval( Options::getValue( 'processQueueImmediately' ) );
506506
if ( $immediate_mode === 1 ) {
507-
self::wp2staticProcessQueueAdminPost();
507+
self::processQueueAdminPost();
508508
} elseif ( $immediate_mode === 2 ) {
509509
shell_exec( 'wp wp2static process_queue > /dev/null 2>&1 &' );
510510
usleep( 100000 ); // 100,000 microseconds = 0.1 seconds
511511
}
512512
}
513513

514-
public static function wp2staticToggleAddon( string $addon_slug = null ): void {
514+
public static function adminToggleAddon( string $addon_slug = null ): void {
515515
if ( defined( 'WP_CLI' ) ) {
516516
if ( ! $addon_slug ) {
517517
throw WsLog::ex(
@@ -560,7 +560,7 @@ public static function wp2staticToggleAddon( string $addon_slug = null ): void {
560560
exit;
561561
}
562562

563-
public static function wp2staticManuallyEnqueueJobs(): void {
563+
public static function adminManuallyEnqueueJobs(): void {
564564
check_admin_referer( 'wp2static-manually-enqueue-jobs' );
565565

566566
// TODO: consider using a transient based notifications system to
@@ -577,7 +577,7 @@ public static function wp2staticManuallyEnqueueJobs(): void {
577577
Should only process at most 4 jobs here (1 per type), with
578578
earlier jobs of the same type having been "squashed" first
579579
*/
580-
public static function wp2staticProcessQueue(): void {
580+
public static function processQueue(): void {
581581
global $wpdb;
582582

583583
WsLog::deleteOldLogs();
@@ -616,7 +616,7 @@ public static function wp2staticProcessQueue(): void {
616616
WsLog::l( "URL detection completed ($detected_count URLs detected)" );
617617
break;
618618
case 'crawl':
619-
self::wp2staticCrawl();
619+
self::crawl();
620620
break;
621621
case 'post_process':
622622
WsLog::l( 'Starting post-processing' );
@@ -687,9 +687,9 @@ public static function wp2staticProcessQueue(): void {
687687
}
688688

689689
/**
690-
* Make a non-blocking POST request to run wp2staticProcessQueue.
690+
* Make a non-blocking POST request to run processQueue.
691691
*/
692-
public static function wp2staticProcessQueueAdminPost(): void {
692+
public static function processQueueAdminPost(): void {
693693
$url = admin_url( 'admin-post.php' ) . '?action=' . self::getHookName( 'process_queue' );
694694
$nonce = wp_create_nonce( self::getHookName( 'process_queue' ) );
695695
$result = wp_remote_post(
@@ -705,19 +705,19 @@ public static function wp2staticProcessQueueAdminPost(): void {
705705

706706
if ( is_wp_error( $result ) ) {
707707
WsLog::l(
708-
'Error in wp2staticProcessQueueAdminPost. Request to admin-post.php failed: ' .
708+
'Error in processQueueAdminPost. Request to admin-post.php failed: ' .
709709
json_encode( $result->errors )
710710
);
711711
}
712712
}
713713

714-
public static function wp2staticHeadless(): void {
714+
public static function runHeadless(): void {
715715
WsLog::l( 'Running WP2Static in Headless mode' );
716716
WsLog::l( 'Starting URL detection' );
717717
$detected_count = URLDetector::enqueueURLs();
718718
WsLog::l( "URL detection completed ($detected_count URLs detected)" );
719719

720-
self::wp2staticCrawl();
720+
self::crawl();
721721

722722
WsLog::l( 'Starting post-processing' );
723723
$post_processor = new PostProcessor();
@@ -830,17 +830,17 @@ public static function webhookDeployNotification(): void {
830830
);
831831
}
832832

833-
public static function wp2staticRun(): void {
833+
public static function ajaxRun(): void {
834834
check_ajax_referer( self::getHookName( 'run_page' ), 'security' );
835835

836836
WsLog::l( 'Running full workflow from UI' );
837837

838-
self::wp2staticHeadless();
838+
self::runHeadless();
839839

840840
wp_die();
841841
}
842842

843-
public static function wp2staticCrawl(): void {
843+
public static function crawl(): void {
844844
$crawlers = Addons::getType( 'crawl' );
845845
$crawler_slug = empty( $crawlers ) ? 'wp2static' : $crawlers[0]->slug;
846846
do_action(
@@ -853,7 +853,7 @@ public static function wp2staticCrawl(): void {
853853
/**
854854
* Give logs to UI
855855
*/
856-
public static function wp2staticPollLog(): void {
856+
public static function ajaxPollLog(): void {
857857
check_ajax_referer( self::getHookName( 'run_page' ), 'security' );
858858

859859
$logs = WsLog::poll();

src/Crawler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function __construct() {
9696
WsLog::l( 'Starting crawl.' );
9797
}
9898

99-
public static function wp2staticCrawl( string $crawler_slug ): void {
99+
public static function crawl( string $crawler_slug ): void {
100100
global $wpdb;
101101

102102
if ( 'wp2static' === $crawler_slug ) {

src/WPCron.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function clearRecurringEvent(): void {
5757
* @param mixed[] $schedules array of CRON schedules
5858
* @return mixed[] array of CRON schedules
5959
*/
60-
public static function wp2static_custom_cron_schedules( array $schedules ): array {
60+
public static function customCronSchedules( array $schedules ): array {
6161
$schedules['1min'] = [
6262
'interval' => 1 * MINUTE_IN_SECONDS,
6363
'display' => 'Every minute',
@@ -82,7 +82,7 @@ public static function wp2static_custom_cron_schedules( array $schedules ): arra
8282
* @param mixed[] $cron_request WP-Cron request
8383
* @return mixed[] WP-Cron request
8484
*/
85-
public static function wp2static_cron_with_http_basic_auth( array $cron_request ): array {
85+
public static function cronWithBasicAuth( array $cron_request ): array {
8686
$auth_user = Options::getValue( 'basicAuthUser' );
8787
$auth_password = Options::getValue( 'basicAuthPassword' );
8888

0 commit comments

Comments
 (0)