JezK
Edit File: NotificationBlocks.php
<?php namespace WPForms\Emails; use WPForms\Admin\Notifications\Notifications; /** * Notification class. * This class is responsible for displaying the notification block in the email summaries. * * @since 1.8.8 */ class NotificationBlocks { /** * Notifications class instance. * * @since 1.8.8 * * @var Notifications */ private $notifications; /** * Class constructor. * Initializes the Notifications class instance. * * @since 1.8.8 */ public function __construct() { // Store the instance of the "Notifications" class. $this->notifications = wpforms()->obj( 'notifications' ); } /** * Retrieves the notification block from the feed, considering shown notifications and license type. * * @since 1.8.8 * * @return array */ public function get_block(): array { // Check if the user has access to notifications. // If the user has disabled announcements, return an empty array. if ( ! $this->notifications || ! $this->notifications->has_access() ) { return []; } // Get the response array from the notifications. $notifications = $this->notifications->get_option(); // Check if 'feed' key is present and non-empty. if ( empty( $notifications['feed'] ) || ! is_array( $notifications['feed'] ) ) { return []; } // Remove items from $feed where their id index is in `shown_notifications` option value. $feed = $this->filter_feed( $notifications['feed'] ); // Sort the array of items using usort and the custom comparison function. $feed = $this->sort_feed( $feed ); // Get the very first item from the $feed. $block = reset( $feed ); // Check if $block is empty. if ( empty( $block ) ) { return []; } // Return the notification block. return $this->prepare_and_sanitize_content( $block ); } /** * Save the shown notification block if it's not empty. * * @since 1.8.8 * * @param array $notification The notification to be saved. */ public function maybe_remember_shown_block( array $notification ) { // Check if the notification or its ID is empty. if ( empty( $notification ) || empty( $notification['id'] ) ) { // If the notification or its ID is empty, return early. return; } // Get shown notifications from options. $shown_notifications = (array) get_option( 'wpforms_email_summaries_shown_notifications', [] ); // Add the notification id to the $shown_notifications array. $shown_notifications[] = (int) $notification['id']; // Update the shown notifications in the options. // Avoid autoloading the option, as it's not needed. update_option( 'wpforms_email_summaries_shown_notifications', $shown_notifications, false ); } /** * Filter the feed to remove shown notifications. * * @since 1.8.8 * * @param array $feed The feed to filter. * * @return array */ private function filter_feed( array $feed ): array { $shown_notifications = (array) get_option( 'wpforms_email_summaries_shown_notifications', [] ); return array_filter( $feed, static function ( $item ) use ( $shown_notifications ) { return ! in_array( $item['id'], $shown_notifications, true ); } ); } /** * Sort the feed in descending order by start date. * * @since 1.8.8 * * @param array $feed The feed to sort. * * @return array */ private function sort_feed( array $feed ): array { usort( $feed, static function ( $a, $b ) { return strtotime( $b['start'] ) - strtotime( $a['start'] ); } ); return $feed; } /** * Prepare and sanitize content for display. * * @since 1.8.8 * * @param string|array $content The content to be prepared and sanitized. * * @return string|array */ private function prepare_and_sanitize_content( $content ) { // If the content is empty, return as is. if ( empty( $content ) ) { return $content; } // If the content is already a string, sanitize and return it. if ( is_string( $content ) ) { // Define allowed HTML tags and attributes. $content_allowed_tags = $this->notifications->get_allowed_tags(); // For design consistency, remove the 'p' tag from the allowed tags. unset( $content_allowed_tags['p'] ); // Apply wp_kses() for sanitization. return wp_kses( $content, $content_allowed_tags ); } // If the content is an array with the 'content' index, modify and sanitize it. if ( is_array( $content ) && isset( $content['content'] ) ) { // Sanitize the content of the array. $content['content'] = $this->prepare_and_sanitize_content( $content['content'] ); // Return the modified array. return $content; } // If the content is not a string or an array with 'content' index, return the content as is. return $content; } }
BanaBridge News
https://validator.w3.org/feed/docs/rss2.html
Court Orders Ex-Weah Protocol Chief Jailed on US$8 Million Bail, Sends 15 Jurors to Prison Over Misconduct
Women Renew Call for War and Economic Crimes Court at Liberia’s Historic Peace Prayer Site
Finance Minister Ngafuan Urges Transparency, Accountability as Liberia Advances ARREST Agenda at UN Retreat
PPCC Donates ICT Equipment to 50 Government Institutions to Expand Electronic Procurement System
Liberia Commissions €100,000 Elemental Analyzer to Strengthen Environmental Research and Food Security
EPA Ends 16 Years of Renting with Purchase of Permanent Headquarters
West African Tax Bodies Deepen Partnership to Boost Revenue Mobilization, Launch Carbon Tax Study
Liberia Hosts Sierra Leone Procurement Delegation for E-GP Reform Study Tour
World Bank Praises Liberia’s Central Bank for Economic Stability and Private Sector Progress
Liberians See Slight Improvement in Corruption Fight, But Graft Still Viewed as Widespread, CENTAL Report Finds
Canada Afrique Care Foundation Set for Official Launch, Expanding Free Mental Health Access Across Canada and Africa
Weah Claims Liberia Has Become a “Narco State” as Opposition Rallies Behind Calls for Independent Probe into US$19 Million Cocaine Bust
EPA Boss Calls for Stronger Student Engagement, Unveils Push for Academic Partnership at UL Climate Symposium
Education Minister Urges Students to Embrace Tax Responsibility at National Student Tax Day
CDC Secretary General Urges U.S. Government to Review Support to Liberia National Police
Liberia Partners with CACFO to Expand Mental Health Services Ahead of Global Launch
Wreh-Toe Appointed Board Chair of CACFO as Foundation Strengthens Mental Health Push
GIABA Opens New Information Center Headquarters in Abidjan
Liberia Wins Fresh Backing as World Bank Group Executive Praises Progress, Pushes Faster Project Delivery
LRA Honors Liberia’s Top Taxpayers as Revenue Collections Hit Historic High
Root Cause in Question as Border Tensions Persist After Conakry Peace Deal
From Enforcement to Innovation: EPA Marks 2025 as a Defining Year for Liberia’s Environment
Weah Declares ‘Road to 2029 Begins Today’ as CDC Marks 22nd Anniversary in Zwedru
500 Documented Governance Failures: Activist Publishes Sweeping End-of-Year Indictment of Boakai Administration
CDC Calls for Probe into Border Crisis, Cites Alleged Mining Activities
Liberia Moves to Strengthen Small Businesses with $672,000 Packaging Solution Initiative
Former Public Works Minister Ruth Coker Collins Defends Zwedru Corridor Strategy, Calls for “Facts Over Rhetoric” in Infrastructure Debate
Power Shake-Up in CDC Diaspora: NEC Dissolves CDC-USA Interim Leadership, Appoints Rev. Muin to Lead U.S. Chapter
Tweah Reemerges, Sparks Fierce National Debate Over Governance and Liberia’s Future
Koijee Slams Tribal Politics and Political Manipulation in Lofa, Accuses Boakai Government
Mali and Burkina Faso Impose Reciprocal Travel Ban on U.S. Citizens
Guinea Election: A Turn Toward Continuity Amid Questions of Democratic Credibility
Liberia’s Revenue Grows Stronger as LRA Exceeds National Target for Second Year
Liberia’s Gender Legal Landscape: Laws in Place, Systems Lag Far Behind
Liberia’s Economy Gains Momentum as CBL Governor Highlights Progress at ECOWAS Meeting
Liberia Positions Itself for Eco Currency Entry as Economy Expands by 5.1%
From Overcrowded Classrooms to Renewal: NPA Mobilizes $1 Million to Transform UL
Ex-Public Works Minister Ruth Coker Collins Slams Ministry’s “Lack of Capacity,” Defends Her Infrastructure Record
CDC Expels Three Senior Members, Citing Alleged Alignment With Government and Undermining Party Ideology
UL to Celebrate 75 Years of Excellence
Saudi Fund Advances Liberia’s Push for Major Infrastructure Development
West African Financial Leaders Convene in Monrovia for ECOWAS Statutory Meetings
Unlocking Liberia’s Potential: Government Launches Major Revenue and Transparency Reforms
Incremental Gains, Enduring Impunity: Liberia’s CPI Improvement Fails the Test of Reform
Boakai’s Call for Unity Faces Scrutiny as Opposition, Citizens Question Actions Behind the Words
REMAPSEN Liberia Set to Strengthen Health and Environmental Reporting
Energy Sector Women Step Into the Spotlight at Liberia’s International Women’s Day Celebration
FeJAL Concludes Three-Day Retreat, Honors Outstanding Women Journalists
Dr. Rasha Kelej Named Among Africa’s 100 Most Influential Leaders
LAVA Honored for Strengthening Liberia–U.S. Ties at 2025 Military Ball