Admin_Banner
Reusable admin banner helper that is configured via constructor values.
Copy-paste friendly: adjust namespaces and configuration per plugin.
Namespace: WebberZone\AutoClose\Admin
Since: 2.10.1
Source: includes/admin/class-admin-banner.php line 23
Methods
__construct()
Constructor.
Line: 74
public function __construct( array $config );
| Type | Name | Description |
|---|---|---|
array | $config | Configuration arguments for the banner. |
hooks()
Register hooks.
Line: 111
public function hooks( ): void;
Returns: void
maybe_enqueue_styles()
Enqueue banner styles if required on the current screen or page slug.
Line: 119
public function maybe_enqueue_styles( ): void;
Returns: void
render()
Render the admin banner markup when conditions are met.
Line: 140
public function render( ): void;
Returns: void
enqueue_style()
Enqueue the banner stylesheet.
Line: 200
public function enqueue_style( ): void;
Returns: void
should_render_on_screen()
Determine whether the banner should display on the current screen.
Line: 216
public function should_render_on_screen( WP_Screen $screen, string $page_slug ): bool;
| Type | Name | Description |
|---|---|---|
\WP_Screen | $screen | Current admin screen. |
string | $page_slug | Current request page slug. |
Returns: bool
resolve_current_section()
Resolve the banner section to highlight based on current screen or page slug.
Line: 240
public function resolve_current_section( WP_Screen $screen, string $page_slug ): string;
| Type | Name | Description |
|---|---|---|
\WP_Screen | $screen | Current admin screen. |
string | $page_slug | Current request page slug. |
Returns: string
prepare_strings()
Prepare localized strings.
Line: 263
public function prepare_strings( array $strings ): array;
| Type | Name | Description |
|---|---|---|
array | $strings | Raw strings array. |
Returns: array
resolve_wrapper_prefix()
Resolve the wrapper prefix based on base prefix provided.
Line: 280
public function resolve_wrapper_prefix( string $prefix ): string;
| Type | Name | Description |
|---|---|---|
string | $prefix | Base prefix. |
Returns: string
prepare_style_config()
Prepare style configuration.
Line: 295
public function prepare_style_config( array $style ): array;
| Type | Name | Description |
|---|---|---|
array | $style | Style configuration. |
Returns: array
sanitize_sections()
Sanitize the sections configuration.
Line: 323
public function sanitize_sections( array $sections ): array;
| Type | Name | Description |
|---|---|---|
array | $sections | Sections configuration. |
Returns: array
derive_class_names()
Derive class names following the provided prefix alongside the base prefix.
Line: 352
public function derive_class_names( ): array;
Returns: array — array<int, string>>
collect_targets_from_sections()
Collect screen IDs or page slugs from the sections configuration.
Line: 385
public function collect_targets_from_sections( string $target_key ): array;
| Type | Name | Description |
|---|---|---|
string | $target_key | screen_ids |
Returns: array
get_section_link_classes()
Retrieve the CSS classes for a section link.
Line: 405
public function get_section_link_classes( array $section ): array;
| Type | Name | Description |
|---|---|---|
array | $section | Section configuration. |
Returns: array
implode_classes()
Implode a class array into a string.
Line: 426
public function implode_classes( array $classes ): string;
| Type | Name | Description |
|---|---|---|
array | $classes | Class list. |
Returns: string — Class attribute string.
class_attr()
Retrieve a flattened class attribute by key.
Line: 436
public function class_attr( string $key ): string;
| Type | Name | Description |
|---|---|---|
string | $key | Classes array key. |
Returns: string — Class attribute string.
sanitize_handle()
Sanitize a style handle.
Line: 445
public function sanitize_handle( string $handle ): string;
| Type | Name | Description |
|---|---|---|
string | $handle | Raw handle. |
Returns: string
get_request_page_slug()
Get the current page slug from the request.
Line: 452
public function get_request_page_slug( ): string;
Returns: string