'', 'variant' => 'info', 'message' => '', 'title' => '', 'actions' => [], 'dismissible' => true, 'pages' => [ 'all' ], ] ); // Ensure pages is an array. if ( ! is_array( $notice['pages'] ) ) { $notice['pages'] = [ $notice['pages'] ]; } // Store the notice. self::$notices[ $notice['id'] ] = $notice; } /** * Get all registered notices. * * @return array Array of notice configurations. * @since 2.5.0 */ public static function get_notices() { return array_values( self::$notices ); } /** * Remove a registered notice. * * @param string $notice_id The notice ID to remove. * @return void * @since 2.5.0 */ public static function remove_notice( $notice_id ) { if ( isset( self::$notices[ $notice_id ] ) ) { unset( self::$notices[ $notice_id ] ); } } /** * Clear all registered notices. * * @return void * @since 2.5.0 */ public static function clear_notices() { self::$notices = []; } /** * Add notices to localized data for React. * * This filter callback adds the notices array to the localized script data * that gets passed to React via window.srfm_admin. * * @param array $localization_data Existing localization data. * @return array Modified localization data with notices. * @since 2.5.0 */ public function add_notices_to_localized_data( $localization_data ) { $localization_data['notices'] = self::get_notices(); return $localization_data; } /** * Helper method to register a notice from existing PHP admin_notices hooks. * * This method simplifies converting existing PHP notices to work with React. * Call this method from your existing admin_notices callback to also register * the notice for React pages. * * Example usage: * ```php * public function my_admin_notice() { * $message = '
' . esc_html__( 'Important notice!', 'sureforms' ) . '
'; * * // Display in PHP (existing behavior - continues to work) * echo '