diff --git a/web/app/mu-plugins/mitlib-post/data/location/group_58e22931ab9f5.json b/web/app/mu-plugins/mitlib-post/data/location/group_58e22931ab9f5.json index 6f2163e8..1d5e720e 100644 --- a/web/app/mu-plugins/mitlib-post/data/location/group_58e22931ab9f5.json +++ b/web/app/mu-plugins/mitlib-post/data/location/group_58e22931ab9f5.json @@ -40,6 +40,25 @@ "tabs": "all", "delay": 0 }, + { + "key": "field_6643c15f0075d", + "label": "Alert Frontpage", + "name": "alert_frontpage", + "type": "wysiwyg", + "instructions": "This field is shown only on the front page hours widget. The content is automatically wrapped in a paragraph tag. The only allowed HTML tag is for links (a tags).", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "tabs": "all", + "toolbar": "full", + "media_upload": 0, + "delay": 0 + }, { "key": "field_24", "label": "Display Page", @@ -990,5 +1009,5 @@ "active": true, "description": "", "show_in_rest": 0, - "modified": 1671581913 + "modified": 1715716606 } \ No newline at end of file diff --git a/web/app/plugins/mitlib-pull-hours/src/class-display-widget-frontpage.php b/web/app/plugins/mitlib-pull-hours/src/class-display-widget-frontpage.php index 0500b6ba..0cf1ffce 100644 --- a/web/app/plugins/mitlib-pull-hours/src/class-display-widget-frontpage.php +++ b/web/app/plugins/mitlib-pull-hours/src/class-display-widget-frontpage.php @@ -83,6 +83,44 @@ public static function init() { register_widget( 'Mitlib\PullHours\Display_Widget_Frontpage' ); } + /** + * This function accepts the post ID of a location record, which will be used + * to check if that location has its alert populated. If either of the two + * fields for the location alert (alert_title or alert_content) are populated, + * that content will be shown in a div. + * + * The function does not return anything. + * + * @param string $location_id The ID of a location record to look up. + * + * @return void + */ + public function location_alert( $location_id ) { + $allowed_html = array( + 'a' => array( + 'href' => array(), + ), + 'p' => array(), + ); + + $query_args = array( + 'post_type' => 'location', + 'p' => $location_id, + 'post_status' => 'publish', + ); + $locations = new \WP_Query( $query_args ); + + while ( $locations->have_posts() ) { + $locations->the_post(); + $alert_frontpage = get_field( 'alert_frontpage' ); + if ( $alert_frontpage ) { + echo '