[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> class-wp-admin-notice-collector.php (summary)

Administration API: WP_Admin_Notice_Collector class

File Size: 165 lines (4 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Admin_Notice_Collector:: (7 methods):
  init()
  capture_notice()
  get_notices()
  get_notice_count()
  reset()
  add_title_placeholder()
  inject_notice_count()


Class: WP_Admin_Notice_Collector  - X-Ref

Capture admin notices generated in PHP during a request.

Notices are captured via the {@see 'wp_admin_notice_markup'} filter.
a title placeholder is inserted into the admin page's `<title>` tag,
the admin page title is modified via the {@see 'admin_title'}
filter, the admin page is wrapped in an output buffer, and an
`ob_start()` callback replaces the placeholder with the final count once
the buffer is flushed.

init()   X-Ref
Registers the hooks used to collect notices and to annotate the admin title.


capture_notice( $markup, $message, $args )   X-Ref
Captures a single admin notice without altering its markup.

Hooked to the {@see 'wp_admin_notice_markup'} filter.

return: string The unmodified markup, so the filter remains transparent.
param: string $markup  The HTML markup for the admin notice.
param: string $message The message for the admin notice.
param: array  $args    The arguments for the admin notice.

get_notices()   X-Ref
Returns all notices captured during the current request.

return: array[] Array of captured notices. Each entry contains the

get_notice_count()   X-Ref
Returns the number of notices captured during the current request.

return: int Notice count.

reset()   X-Ref
Clears all previously captured notices.


add_title_placeholder( $admin_title, $title )   X-Ref
Prepends a title placeholder via the {@see 'admin_title'} filter.

The real count isn't known yet at this point, since notices are usually
produced later in the page. inject_notice_count() resolves it.

return: string The admin title with the placeholder prepended.
param: string $admin_title The page title, with extra context added.
param: string $title       The original page title.

inject_notice_count( $buffer )   X-Ref
Replaces the title placeholder with the final notice count.

Used as an `ob_start()` callback so it runs once the full page - including
any notices printed after `<title>` - has been buffered.

return: string The page output with the placeholder resolved.
param: string $buffer The full buffered page output.



Generated : Sun Oct 11 08:20:32 2026 Cross-referenced by PHPXref