Changeset 8085 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/notification.php
- Timestamp:
- 01/16/2019 03:36:24 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/notification.php
r8084 r8085 5 5 6 6 if ( defined( 'WPORG_SANDBOXED' ) && WPORG_SANDBOXED ) { 7 // If this is sandbox and then send notification of owner of sandbox (as long as sandbox username and slack username matches) 7 // If this is sandbox and then send notification of owner of sandbox (as long as sandbox username and slack username matches). 8 8 if ( defined( 'SANDBOX_SLACK_USERNAME' ) ) { 9 9 $slack_username = SANDBOX_SLACK_USERNAME; 10 10 } else { 11 $slack_username = "@". str_replace( array( '.dev.ord', '.dev' ), '', WPORG_SANDBOXED );11 $slack_username = '@' . str_replace( array( '.dev.ord', '.dev' ), '', WPORG_SANDBOXED ); 12 12 } 13 13 define( 'COMMUNITY_TEAM_SLACK', $slack_username ); … … 22 22 * 23 23 * @param string $channel Name of the channel we want to send the notification to. 24 * @param array $attachment Attachment object 24 * @param array $attachment Attachment object. 25 25 * 26 26 * @return bool|string 27 27 */ 28 function wcpt_slack_notify ( $channel, $attachment ) {28 function wcpt_slack_notify( $channel, $attachment ) { 29 29 if ( ! class_exists( 'Dotorg\Slack\Send' ) ) { 30 30 return false; … … 44 44 * See the structure of attachment here: https://api.slack.com/docs/message-attachments 45 45 * 46 * @param string $message Main text to send in the notification 47 * @param string $ event_label Label for the event. Would probably be one of `WordCamp` or `Meetup`.46 * @param string $message Main text to send in the notification. 47 * @param string $title Title of the notification. 48 48 * 49 49 * @return array 50 50 */ 51 function create_event_attachment ( $message, $title ) {51 function create_event_attachment( $message, $title ) { 52 52 // Not translating because this will be send to Slack. 53 53 return array( 54 "title"=> $title,55 "text"=> $message,54 'title' => $title, 55 'text' => $message, 56 56 ); 57 57 } 58 58 59 /** 60 * Returns an attachment object to customize notification for slack. 61 * See https://api.slack.com/docs/message-attachments 62 * 63 * @param string $message Text that should be in the attachment. 64 * @param int $event_id Post ID of the event. Will be used to gather props. 65 * @param string $title TItle of the message. 66 * 67 * @return array 68 */ 59 69 function create_event_status_attachment( $message, $event_id, $title ) { 60 70 $props = get_props_for_event( $event_id ); 61 71 62 $props_string = implode( ", ", $props ); 72 $props_string = implode( ', ', $props ); 73 63 74 return array( 64 "title"=> $title,65 "text"=> $message,66 "fields"=> array(75 'title' => $title, 76 'text' => $message, 77 'fields' => array( 67 78 array( 68 79 "title" => "Application processed by", … … 82 93 * @return array Array of usernames of people who have participated in vetting this application 83 94 */ 84 function get_props_for_event ( $event_id ) {95 function get_props_for_event( $event_id ) { 85 96 $user_ids = array(); 86 97 … … 97 108 $user_nicenames = get_user_nicenames_from_ids( $user_ids ); 98 109 99 // remove bot user `wordcamp` 110 // remove bot user `wordcamp`. 100 111 $user_nicenames = array_diff( $user_nicenames, array( 'wordcamp' ) ); 101 112 return $user_nicenames; … … 105 116 * Return user names for list of user ids provided in the function 106 117 * 107 * @param array $user_ids List of user_ids 118 * @param array $user_ids List of user_ids. 108 119 * 109 120 * @return array List of user nicenames … … 114 125 } 115 126 116 $user_query = new WP_User_Query( array( 'include' => $user_ids, 'fields' => array( 'user_nicename' ), ) ); 127 $user_query = new WP_User_Query( 128 array( 129 'include' => $user_ids, 130 'fields' => array( 'user_nicename' ), 131 ) 132 ); 117 133 118 134 $users = $user_query->get_results();
Note: See TracChangeset
for help on using the changeset viewer.