Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the slack bot title. #1066

Merged
merged 6 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions public_html/wp-content/mu-plugins/3-helpers-misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

defined( 'WPINC' ) || die();
use function WordCamp\Logger\log;
use function WordCamp\Sunrise\get_top_level_domain;

/*
* Miscellaneous helper functions.
Expand All @@ -25,6 +26,19 @@ function is_wordcamp_type( $type ) {
}
}

/**
* Return whether the url is for a Next-Gen site.
*
* @param string $url The Url to test.
*
* @return bool Returns true if the url matches events url structure.
*/
function is_event_url( $url ) {
$url = wp_parse_url( filter_var( $url, FILTER_VALIDATE_URL ) );
$tld = get_top_level_domain();
return "events.wordpress.$tld" === $url['host'];
}

/**
* Get the current environment.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,14 +773,15 @@ public static function notify_new_wordcamp_in_slack( $wordcamp ) {
}

// Not translating any string because they will be sent to slack.
$city = get_post_meta( $wordcamp->ID, 'Location', true );
$start_date = get_post_meta( $wordcamp->ID, 'Start Date (YYYY-mm-dd)', true );
$wordcamp_url = get_post_meta( $wordcamp->ID, 'URL', true );
$title = 'New WordCamp scheduled!!!';
$is_event = is_event_url( $wordcamp_url );
$title = sprintf( 'New %s scheduled!!!', $is_event ? 'Next Generation Event' : 'WordCamp' );

$message = sprintf(
"<%s|WordCamp $city> has been scheduled for a start date of %s. :tada: :community: :WordPress:\n\n%s",
"<%s|%s> has been scheduled for a start date of %s. :tada: :community: :WordPress:\n\n%s",
$wordcamp_url,
$wordcamp->post_title,
gmdate( 'F j, Y', $start_date ),
$wordcamp_url
);
Expand Down
Loading