Skip to content

Commit

Permalink
Add setting to indicate registration open & auto switch links on sche…
Browse files Browse the repository at this point in the history
…dule banner

Fixes #35
  • Loading branch information
joedolson committed Feb 5, 2024
1 parent 3d749c8 commit 5a30513
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/inc/schedule-output-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,16 @@ function wpcs_event_start( $atts = array() ) {
function wpcs_banner() {
$time = time();
$output = '';
// 10 minutes before start time.
// If more than 10 minutes before start time.
if ( $time < ( strtotime( get_option( 'wpad_start_time', '' ) ) - 600 ) ) {
// Actual start time.
if ( $time < strtotime( get_option( 'wpad_start_time', '' ) ) ) {
$start = gmdate( 'F j, Y', strtotime( get_option( 'wpad_start_time', '' ) ) );
$until = human_time_diff( $time, strtotime( get_option( 'wpad_start_time', '' ) ) );
$append = " - in just <strong>$until</strong>!";
}
$output = "<div class='wpad-callout'><p>WP Accessibility Day starts $start $append <a href='" . esc_url( get_option( 'wpcs_field_registration' ) ) . "'>Register today!</a> </p></div>";
$register_or_signup = ( 'true' === get_option( 'wpcs_registration_open' ) ) ? "<a class='button' href='" . esc_url( get_option( 'wpcs_field_registration' ) ) . "'>Register today!</a>" : ' <a href="' . home_url( 'join-our-email-list' ) . '" class="button">Get notified when registration opens!</a>';
$output = "<div class='wpad-callout'><p>WP Accessibility Day starts $start $append $register_or_signup </p></div>";
}

return $output;
Expand Down
17 changes: 17 additions & 0 deletions src/inc/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ function wpcs_settings_init() {
// register registration URL field in the "wpcs_section_info" section, inside the "wpcs" page.
add_settings_field( 'wpcs_field_registration', 'Registration URL', 'wpcs_field_registration_cb', 'wpa-conference', 'wpcs_section_settings' );

// register registration URL setting for "wpcs" page.
register_setting( 'wpa-conference', 'wpcs_registration_open' );

// register registration URL field in the "wpcs_section_info" section, inside the "wpcs" page.
add_settings_field( 'wpcs_registration_open', 'Registration open', 'wpcs_registration_open_cb', 'wpa-conference', 'wpcs_section_settings' );

// register event start time.
register_setting( 'wpa-conference', 'wpad_start_time' );

Expand Down Expand Up @@ -73,6 +79,17 @@ function wpcs_field_registration_cb() {
<?php
}

/**
* Field registration open callback.
*
* @return void
*/
function wpcs_registration_open_cb() {
?>
<input type="checkbox" id="wpcs_registration_open" name="wpcs_registration_open" value="true" <?php checked( get_option( 'wpcs_registration_open', '' ), 'true', true ); ?> /> <label for="wpcs_registration_open">Registration is currently open</label>
<?php
}

/**
* Field start time callback.
*
Expand Down

0 comments on commit 5a30513

Please sign in to comment.