WP_Backstage_Widget_Base
extends WP_Widget
in package
WP Backstage Widget Base
Sets up a global widget that all WP Backstage widgets use as their base by adding hooks and filters for the form, the output, and saving of instances.
Tags
Table of Contents
- $args : array<string|int, mixed>
- Args
- $slug : array<string|int, mixed>
- Slug
- __construct() : void
- Construct
- form() : mixed
- Form
- update() : mixed
- Update
- widget() : mixed
- Widget
Properties
$args
Args
protected
array<string|int, mixed>
$args
= array()
The array of all args on the instance.
Tags
$slug
Slug
protected
array<string|int, mixed>
$slug
= ''
The widget slug.
Tags
Methods
__construct()
Construct
public
__construct([string $slug = '' ][, array<string|int, mixed> $args = array() ]) : void
Constructs the widget and calls the parent widgets constructor.
Parameters
- $slug : string = ''
-
The widget's slug.
- $args : array<string|int, mixed> = array()
-
The widget's args.
Tags
Return values
void —form()
Form
public
form(array<string|int, mixed> $instance) : mixed
This is the function that renders the "back end" of the widget. It adds an action for WP Backstage to render the form fields. This allows for this class to be used for all WP Backstage widgets.
Parameters
- $instance : array<string|int, mixed>
-
The stored settings of this widget instance.
Tags
Return values
mixed —update()
Update
public
update(array<string|int, mixed> $new_instance, array<string|int, mixed> $old_instance) : mixed
This is the function that saves the instance of the widget. It adds a filter for WP Backstage to save the form fields, passing the new instance and old instance. This allows for this class to be used for all WP Backstage widgets.
Parameters
- $new_instance : array<string|int, mixed>
-
The new settings to store.
- $old_instance : array<string|int, mixed>
-
The currentylu stored settings.
Tags
Return values
mixed —widget()
Widget
public
widget(array<string|int, mixed> $args, array<string|int, mixed> $instance) : mixed
This is the function that renders the "front end" of the widget. It
outputs the before_widget
and after_widget
args, and adds an action
for the developer to render the front end. This allows for this class
to be used for all WP Backstage widgets.
Parameters
- $args : array<string|int, mixed>
-
The arguments of the widget as configured when registering the widget area.
- $instance : array<string|int, mixed>
-
The stored settings of this widget instance.