diff --git a/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/pages/debrief-survey.php b/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/pages/debrief-survey.php new file mode 100644 index 0000000000..ac916cf6e1 --- /dev/null +++ b/public_html/wp-content/plugins/wordcamp-organizer-survey/includes/pages/debrief-survey.php @@ -0,0 +1,341 @@ +ID ) { + // Allow it, and delete the option if the page is force-deleted. + if ( $force_delete ) { + delete_option( SURVEY_PAGE_ID ); + return $check; + } + + return false; + } + + return $check; +} + +/** + * Get the content of the survey page. + * + * @return string + */ +function get_page_content() { + return << +

If you recently organized a WordPress event, please take the survey below to share your feedback about your experience.

+ + + +
+
+ + + +
+

Part I. General Information

+ + + +
+ + + +
+ +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + + + +
+ + + +
+ + + + + + + +
+ + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+ + + +
+

Part II. Budget

+ + + +
+ + + + + + + +
+ + + +
+ + + + + +
+ + + +
+ + + +
+ + + + + + + +
+ + + +
+
+ + + +
+

Part III. Opinions

+ + + +
+ + + +
+ + + +
+ + + + + +
+ + + +
+ + + +
+ + + + + +
+ + + +
+ + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+
+ + + +

Thank you so much for sharing your feedback and providing an excellent experience to your community, we are very grateful for your contribution to the WordPress open source project!

+ + +
+ +EOT; +} + +/** + * Turns on the page by changing its status to 'publish'. + * + * @return int|WP_Error + */ +function publish_survey_page() { + return wp_update_post( array( + 'ID' => get_option( SURVEY_PAGE_ID ), + 'post_status' => 'publish', + ) ); +} + +/** + * Generate a link to the front end feedback UI for a particular session. + * + * @return string|bool + */ +// function get_survey_page_url() { +// return get_permalink( get_option( SURVEY_PAGE_ID ) ); +// } + + +/** + * Create the Survey page, save ID into an option. + */ +function add_page() { + $page_id = get_option( SURVEY_PAGE_ID ); + + if ( $page_id ) { + return; + } + + $page_id = wp_insert_post( array( + 'post_title' => __( 'Organizer Survey (event debrief)', 'wordcamporg' ), + 'post_name' => __( 'organizer debrief survey', 'wordcamporg' ), + 'post_content' => get_page_content(), + 'post_status' => 'draft', + 'post_type' => 'page', + ) ); + + if ( $page_id > 0 ) { + update_option( SURVEY_PAGE_ID, $page_id ); + } +} + +/** + * Turns off the page by changing its status to 'draft'. + */ +function disable_page() { + $page_id = get_option( SURVEY_PAGE_ID ); + + if ( ! $page_id ) { + return; + } + + return wp_update_post( array( + 'ID' => $page_id, + 'post_status' => 'draft', + ) ); +} + +/** + * Delete the Survey page and associated meta data. + */ +function delete_page() { + $page_id = get_option( SURVEY_PAGE_ID ); + wp_delete_post( $page_id, true ); + delete_option( SURVEY_PAGE_ID ); +} 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 9eab675094..3ece74759e 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,8 +12,8 @@ namespace WordCamp\OrganizerSurvey; +use function WordCamp\OrganizerSurvey\DebriefSurvey\{add_page, delete_page}; // use function WordCamp\OrganizerSurvey\Email\{add_email, delete_email}; -// use function WordCamp\OrganizerSurvey\Page\{add_page, delete_page}; defined( 'WPINC' ) || die(); @@ -21,7 +21,7 @@ * Local dependencies. */ // require_once get_includes_path() . 'email.php'; -// require_once get_includes_path() . 'page.php'; +require_once get_includes_path() . 'pages/debrief-survey.php'; /** * Plugin deactivation hook. @@ -78,12 +78,12 @@ function load() { * @return void */ function activate_on_current_site() { - // add_page(); + add_page(); // add_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. - // delete_option( 'rewrite_rules' ); + // 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. + delete_option( 'rewrite_rules' ); } /** @@ -122,7 +122,7 @@ function deactivate_on_network() { * @return void */ function deactivate_on_current_site() { - // delete_page(); + delete_page(); // delete_email(); }