From 6d32335da6df8980cd5c07692bf788cd463d1da5 Mon Sep 17 00:00:00 2001 From: ren <18050944+renintw@users.noreply.github.com> Date: Fri, 15 Sep 2023 21:03:04 +0800 Subject: [PATCH] Naming tidy up. --- .../includes/admin-page.php | 15 ++++++------ .../includes/debrief-survey/cron.php | 16 ++++++------- .../includes/debrief-survey/email.php | 2 +- .../includes/debrief-survey/page.php | 2 +- .../wordcamp-organizer-survey.php | 24 ++++++++++++------- 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/admin-page.php b/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/admin-page.php index 346bb36d58..14a882221e 100644 --- a/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/admin-page.php +++ b/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/admin-page.php @@ -10,8 +10,8 @@ use CampTix_Plugin; use function WordCamp\OrganizerSurvey\{get_feature_id}; -use function WordCamp\OrganizerSurvey\DebriefSurvey\Email\{get_email_id}; -use function WordCamp\OrganizerSurvey\DebriefSurvey\Page\{get_page_id}; +use function WordCamp\OrganizerSurvey\DebriefSurvey\Email\get_email_id as get_debrief_survey_email_id; +use function WordCamp\OrganizerSurvey\DebriefSurvey\Page\get_page_id as get_debrief_survey_page_id; add_action( 'init', __NAMESPACE__ . '\init' ); @@ -38,7 +38,7 @@ function admin_menu() { } /** - * Get stats for each feedback for all sites. + * Debrief Survey: Get stats for each feedback for all sites. * * @return array[] An array of custom elements. * Each element has the following structure: @@ -78,18 +78,19 @@ function get_feedback_details() { $query = new \WP_Query( array( 'post_type' => 'feedback', - 'post_parent' => get_page_id(), + 'post_parent' => get_debrief_survey_page_id(), 'posts_per_page' => -1, ) ); - $sent = (int) $camptix->get_sent_email_count( get_email_id() ) ? 'Yes' : 'No'; + $email_id = get_debrief_survey_email_id(); + $sent = (int) $camptix->get_sent_email_count( $email_id ) ? 'Yes' : 'No'; $responses = (int) $query->found_posts; $feedback_details[] = array( 'title' => $blog_details->blogname, 'admin_url' => admin_url(), - 'email_url' => get_edit_post_link( get_email_id() ), - 'responses_url' => admin_url( sprintf( 'edit.php?post_type=feedback&jetpack_form_parent_id=%s', get_page_id() ) ), + 'email_url' => get_edit_post_link( $email_id ), + 'responses_url' => admin_url( sprintf( 'edit.php?post_type=feedback&jetpack_form_parent_id=%s', get_debrief_survey_page_id() ) ), 'sent' => $sent, 'responses' => $responses, ); diff --git a/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/cron.php b/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/cron.php index eb0c5aa742..48682144a9 100644 --- a/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/cron.php +++ b/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/cron.php @@ -13,14 +13,14 @@ * Constants. */ const DAYS_AFTER_TO_SEND = 2; -const TEMP_ATTENDEE_ID = 'organizer_survey_temp_attendee'; +const TEMP_ATTENDEE_ID = 'organizer_debrief_survey_temp_attendee'; /** * Actions & hooks */ add_action( 'init', __NAMESPACE__ . '\schedule_jobs' ); -add_action( 'wc_organizer_survey_email', __NAMESPACE__ . '\queue_organizer_survey' ); -add_action( 'wc_organizer_disable_survey', __NAMESPACE__ . '\disable_organizer_survey' ); +add_action( 'wc_organizer_debrief_survey_email', __NAMESPACE__ . '\queue_organizer_survey' ); +add_action( 'wc_organizer_disable_debrief_survey', __NAMESPACE__ . '\disable_organizer_survey' ); /** * Logs a message to the CampTix email log. @@ -45,8 +45,8 @@ function get_wordcamp_attendees_id() { * Add cron jobs to the schedule. */ function schedule_jobs() { - if ( ! wp_next_scheduled( 'wc_organizer_survey_email' ) ) { - wp_schedule_event( time(), 'daily', 'wc_organizer_survey_email' ); + if ( ! wp_next_scheduled( 'wc_organizer_debrief_survey_email' ) ) { + wp_schedule_event( time(), 'daily', 'wc_organizer_debrief_survey_email' ); } } @@ -190,11 +190,11 @@ function queue_organizer_survey() { log( 'Email status change to `pending`.', $email_id ); } - if ( ! wp_next_scheduled( 'wc_organizer_disable_survey' ) ) { + if ( ! wp_next_scheduled( 'wc_organizer_disable_debrief_survey' ) ) { $next_time = strtotime( '+2 weeks' . wp_timezone_string() ); - wp_schedule_single_event( $next_time, 'wc_organizer_disable_survey' ); + wp_schedule_single_event( $next_time, 'wc_organizer_disable_debrief_survey' ); } // Remove the cron job that queues everything. - wp_clear_scheduled_hook( 'wc_organizer_survey_email' ); + wp_clear_scheduled_hook( 'wc_organizer_debrief_survey_email' ); } diff --git a/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/email.php b/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/email.php index 6969158c10..4f6c7272c9 100644 --- a/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/email.php +++ b/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/email.php @@ -12,7 +12,7 @@ /** * Constants. */ -const EMAIL_KEY_ID = 'organizer_survey_email'; +const EMAIL_KEY_ID = 'organizer_debrief_survey_email'; /** * Return the email ID. diff --git a/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/page.php b/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/page.php index 5363b20ba9..17fca8eb7c 100644 --- a/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/page.php +++ b/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/debrief-survey/page.php @@ -13,7 +13,7 @@ /** * Constants. */ -const SURVEY_PAGE_ID = 'organizer_debrief_survey'; +const SURVEY_PAGE_ID = 'organizer_debrief_survey_page'; /** diff --git a/public_html/wp-content/plugins/wordcamp-organizer-survey/wordcamp-organizer-survey.php b/public_html/wp-content/plugins/wordcamp-organizer-survey/wordcamp-organizer-survey.php index 36952bad30..56e28a0e2e 100644 --- a/public_html/wp-content/plugins/wordcamp-organizer-survey/wordcamp-organizer-survey.php +++ b/public_html/wp-content/plugins/wordcamp-organizer-survey/wordcamp-organizer-survey.php @@ -12,9 +12,11 @@ namespace WordCamp\OrganizerSurvey; -use function WordCamp\OrganizerSurvey\DebriefSurvey\Page\{add_page, delete_page}; -use function WordCamp\OrganizerSurvey\DebriefSurvey\Email\{add_email, delete_email}; -use function WordCamp\OrganizerSurvey\DebriefSurvey\Cron\delete_temp_attendee; +use function WordCamp\OrganizerSurvey\DebriefSurvey\Page\add_page as add_debrief_survey_page; +use function WordCamp\OrganizerSurvey\DebriefSurvey\Page\delete_page as delete_debrief_survey_page; +use function WordCamp\OrganizerSurvey\DebriefSurvey\Email\add_email as add_debrief_survey_email; +use function WordCamp\OrganizerSurvey\DebriefSurvey\Email\delete_email as delete_debrief_survey_email; +use function WordCamp\OrganizerSurvey\DebriefSurvey\Cron\delete_temp_attendee as delete_debrief_survey_temp_attendee; defined( 'WPINC' ) || die(); @@ -53,7 +55,9 @@ function load() { } if ( is_wordcamp_type( 'next-gen' ) ) { - require_once get_includes_path() . 'cron.php'; + // Debrief Survey. + require_once get_includes_path() . 'debrief-survey/cron.php'; + add_action( 'init', __NAMESPACE__ . '\activate_on_current_site' ); } } @@ -64,8 +68,9 @@ function load() { * @return void */ function activate_on_current_site() { - add_page(); - add_email(); + // Debrief Survey. + add_debrief_survey_page(); + add_debrief_survey_email(); // Flushing the rewrite rules is buggy in the context of `switch_to_blog`. // The rules will automatically get recreated on the next request to the site. @@ -108,9 +113,10 @@ function deactivate_on_network() { * @return void */ function deactivate_on_current_site() { - delete_page(); - delete_email(); - delete_temp_attendee(); + // Debrief Survey. + delete_debrief_survey_page(); + delete_debrief_survey_email(); + delete_debrief_survey_temp_attendee(); } /**