Alerts: red banners - ucsf-ckm/ucsf-library-ux-and-web-documentation GitHub Wiki

What

These are top level red alert banners meant to appear on all or several pages. These are for high importance and typically a single message.

Where

To make an alert appear at the top of the page, an Amin adds a snippet to Appearance > Elements > Legacy Hooks > After Header

alert

What

  • The snippet can be very basic and just html, or it can be conditional using PHP and the WordPress Conditional Tags. This requires that Execute PHP be checked.
  • More than one hook can be in a section, but they must all be enabled or disabled at the same time.

hooks

Examples

Appears on every page of the site

<!-- Message should read something like "ALERT: We're experiencing problems with PubMed Access. We are working to resolve the issue." -->
<p class="alert">ALERT:  ILL Request will be unavailable between 6-9 am on Tuesday Aug. 14.</p>

Appears on all pages except single posts

<!-- Alert message will appear on all pages except news posts. It should read something like "ALERT: We're experiencing problems with PubMed Access. We are working to resolve the issue." -->

<?php if ( ! is_single() ) : ?>
      <p class="alert">ALERT:  ILL Request will be unavailable between 6-9 am on Tuesday Aug. 14.</p>
<?php endif; ?>

Appears only on single posts

<!-- Alert message will appear only on single news posts -->
<?php if ( is_single() ) : ?>
  <p class="alert">ALERT: Access to all content on the ScienceDirect platform as well as Embase, Reaxys and Compendex is currently down. <br>Apologies for any inconvenience this may cause.
</p>
<?php endif; ?>

Appears only on the main/home page

<!-- Alert message will appear only on the main/home page -->
<?php if ( is_front_page() ) : ?>
    <p class="alert">ALERT: Access to all content on the ScienceDirect platform as well as Embase, Reaxys and Compendex is currently down. <br>Apologies for any inconvenience this may cause.
</p>
<?php endif; ?>

Appears only on the single page noted by title

<?php if ( is_page( 'Getting Full Text Access' ) ) : ?>
    <p class="alert">ALERT: Access to all content on the ScienceDirect platform as well as Embase, Reaxys and Compendex is currently down. <br>Apologies for any inconvenience this may cause.
</p>
<?php endif; ?>