Changeset 3780926
- Timestamp:
- 11/02/2026 10:48:22 PM (4 hours ago)
- Location:
- pilot-announcement-bar/trunk
- Files:
-
- 2 edited
-
announcement-pilot.php (modified) (8 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pilot-announcement-bar/trunk/announcement-pilot.php
r3777392 r3780926 3 3 * Plugin Name: Pilot Announcement Bar – Announcement Bar & Notification Bar 4 4 * Description: Create a clear, branded announcement bar for your WordPress website. 5 * Version: 1.2. 05 * Version: 1.2.1 6 6 * Author: Plano Apps 7 7 * Text Domain: announcement-pilot … … 17 17 final class Plugin { 18 18 const SLUG = 'announcement-pilot'; 19 const VERSION = '1.2. 0';19 const VERSION = '1.2.1'; 20 20 21 21 public static function boot() { … … 37 37 'position' => 'top', 'devices' => 'all', 'font_size' => 16, 38 38 'mobile_font_size' => 16, 'padding_y' => 14, 'bold' => false, 'dismissible' => true, 39 'hide_theme_bar' => true, 'theme_bar_selectors' => '', 39 40 ); 40 41 } … … 43 44 $input = is_array( $input ) ? $input : array(); 44 45 $clean = self::defaults(); 45 foreach ( array( 'enabled', 'bold', 'dismissible' ) as $key ) {46 foreach ( array( 'enabled', 'bold', 'dismissible', 'hide_theme_bar' ) as $key ) { 46 47 $clean[ $key ] = isset( $input[ $key ] ) && is_scalar( $input[ $key ] ) && in_array( (string) $input[ $key ], array( '1', 'true' ), true ); 47 48 } … … 74 75 $clean['url'] = esc_url_raw( $url, array( 'http', 'https' ) ); 75 76 } 77 } 78 if ( isset( $input['theme_bar_selectors'] ) && is_scalar( $input['theme_bar_selectors'] ) ) { 79 // CSS selectors only: no braces, semicolons, at-rules or markup. 80 $selectors = (string) $input['theme_bar_selectors']; 81 $selectors = preg_replace( '/[\x00-\x1f\x7f{}<>;@\\\\"]/', '', $selectors ); 82 $selectors = trim( preg_replace( '/\s+/', ' ', $selectors ) ); 83 $clean['theme_bar_selectors'] = substr( $selectors, 0, 300 ); 76 84 } 77 85 return $clean; … … 368 376 <section class="ap-panel" data-ap-panel="announcements" hidden> 369 377 <div class="ap-page-head"><div><h1><?php esc_html_e( 'Announcements', 'announcement-pilot' ); ?></h1><p><?php esc_html_e( 'Write, style and publish your bar.', 'announcement-pilot' ); ?></p></div></div> 370 <details class="ap-card ap-guide" <?php echo false === get_option( 'ap_settings', false ) ? 'open' : ''; ?>><summary>Get started in three steps</summary><ol><li><strong>Write your message.</strong> Choose a template or enter your own announcement. The button is optional.</li><li><strong>Check the preview.</strong> Try Desktop and Mobile, choose your colours and placement, and check the contrast feedback.</li><li><strong>Publish when ready.</strong> Select “Show this announcement on my website”, then “Save announcement”. Use “View website” to check the result.</li></ol><p class="ap-help"> Already have an announcement bar? Turn it off in your theme settings to avoid duplicates. To unpublish ours, clear the show checkbox and save. You can reopen this guide any time.</p></details>378 <details class="ap-card ap-guide" <?php echo false === get_option( 'ap_settings', false ) ? 'open' : ''; ?>><summary>Get started in three steps</summary><ol><li><strong>Write your message.</strong> Choose a template or enter your own announcement. The button is optional.</li><li><strong>Check the preview.</strong> Try Desktop and Mobile, choose your colours and placement, and check the contrast feedback.</li><li><strong>Publish when ready.</strong> Select “Show this announcement on my website”, then “Save announcement”. Use “View website” to check the result.</li></ol><p class="ap-help">If you also have an announcement bar in your theme, turn on “Hide my theme’s own announcement bar” above so visitors never see two bars. To unpublish ours, clear the show checkbox and save. You can reopen this guide any time.</p></details> 371 379 372 380 <form id="ap-settings" method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>"> … … 408 416 <section class="ap-card"><h2><?php esc_html_e( 'Placement & behaviour', 'announcement-pilot' ); ?></h2><div class="ap-fields"> 409 417 <?php foreach ( array( 'position' => array( 'Top of page', array( 'top' => 'Top of page', 'bottom' => 'Bottom of page' ) ), 'devices' => array( 'Show on', array( 'all' => 'All devices', 'desktop' => 'Desktop only', 'mobile' => 'Mobile only' ) ) ) as $key => $field ) { ?><div class="ap-field"><label for="ap-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( 'position' === $key ? 'Position' : $field[0] ); ?></label><select id="ap-<?php echo esc_attr( $key ); ?>" name="ap_settings[<?php echo esc_attr( $key ); ?>]"><?php foreach ( $field[1] as $value => $label ) { ?><option value="<?php echo esc_attr( $value ); ?>" <?php selected( $s[ $key ], $value ); ?>><?php echo esc_html( $label ); ?></option><?php } ?></select></div><?php } ?> 410 </div><?php self::checkbox( ' dismissible', __( 'Visitors can close the announcement', 'announcement-pilot' ), $s ); ?><div class="ap-actions"><?php submit_button( __( 'Save announcement', 'announcement-pilot' ), 'primary', 'submit', false ); ?></div></section>418 </div><?php self::checkbox( 'hide_theme_bar', __( "Hide my theme's own announcement bar so visitors never see two bars", 'announcement-pilot' ), $s ); ?><p class="ap-help">We hide the common announcement bar markup used by WordPress themes. If your theme still shows its own bar, add its CSS selector below.</p><?php self::field( 'theme_bar_selectors', __( 'Extra CSS selectors to hide (optional)', 'announcement-pilot' ), $s ); ?><?php self::checkbox( 'dismissible', __( 'Visitors can close the announcement', 'announcement-pilot' ), $s ); ?><div class="ap-actions"><?php submit_button( __( 'Save announcement', 'announcement-pilot' ), 'primary', 'submit', false ); ?></div></section> 411 419 </div><section class="ap-card"><h2><?php esc_html_e( 'Live preview', 'announcement-pilot' ); ?></h2><div id="ap-preview-size" role="group" aria-label="Preview device"><button type="button" data-ap-device="desktop">Desktop</button><button type="button" data-ap-device="mobile">Mobile</button></div><div id="ap-preview"></div><p id="ap-preview-status" aria-live="polite"></p><p id="ap-contrast-status" class="ap-help" aria-live="polite"></p></section></div> 412 420 </form> … … 524 532 if ( $rendered || ! $s['enabled'] || '' === trim( $s['message'] ) || is_admin() || is_feed() || ! apply_filters( 'announcement_pilot_should_render', true, $s ) ) { return; } 525 533 $rendered = true; 534 if ( ! empty( $s['hide_theme_bar'] ) ) { 535 $selectors = array( 536 '.announcement-bar:not(.ap-site-bar)', 537 '.announcement-bar-wrapper', 538 '.announcement-banner', 539 '.header-announcement', 540 '.header-announcements', 541 '.site-announcement', 542 '.site-announcement-bar', 543 '.top-announcement', 544 '.top-announcement-bar', 545 '[class*="announcement-bar"]:not(.ap-site-bar)', 546 '[id*="announcement-bar"]:not(.ap-site-bar)', 547 '[class*="announcement-banner"]', 548 '[data-announcement-bar]', 549 ); 550 if ( '' !== trim( (string) $s['theme_bar_selectors'] ) ) { 551 $selectors[] = $s['theme_bar_selectors']; 552 } 553 echo '<style id="announcement-pilot-theme-bar">' . implode( ',', $selectors ) . '{display:none!important}</style>'; 554 } 526 555 $style = sprintf( '--ap-bg:%s;--ap-color:%s;--ap-btn-bg:%s;--ap-btn-color:%s;--ap-font:%dpx;--ap-mobile-font:%dpx;--ap-space:%dpx;--ap-weight:%d;', $s['background'], $s['color'], $s['button_background'], $s['button_color'], $s['font_size'], $s['mobile_font_size'], $s['padding_y'], $s['bold'] ? 700 : 400 ); 527 556 echo '<aside id="announcement-pilot-bar" class="ap-site-bar ap-site-bar--' . esc_attr( $s['position'] ) . ' ap-site-bar--' . esc_attr( $s['devices'] ) . '" aria-label="' . esc_attr__( 'Announcement', 'announcement-pilot' ) . '" style="' . esc_attr( $style ) . '"><span class="ap-site-message">' . esc_html( $s['message'] ) . '</span>'; -
pilot-announcement-bar/trunk/readme.txt
r3777392 r3780926 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.2. 07 Stable tag: 1.2.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 32 32 33 33 = Does this change theme files or hide another announcement bar? = 34 No. It uses standard WordPress hooks. Disable a theme's existing bar in the theme settings if you do not want both bars to appear.34 By default, yes. The plugin hides common theme announcement bar markup with CSS while its own bar is live, so visitors see one bar. You can turn this off under Placement & behaviour, and add your theme's CSS selector if its bar uses unusual markup. 35 35 36 36 = Does closing a bar set cookies? = … … 46 46 47 47 == Changelog == 48 49 = 1.2.1 = 50 * Automatically hides your theme's own announcement bar when the plugin bar is live, so visitors never see two bars. 51 * Added an option to turn that off and a field for extra CSS selectors if your theme uses unusual markup. 48 52 49 53 = 1.2.0 =
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)