Wordpress Theme Widgets

The Widgets in the Wordpress theme for Capitularia.

PHP

themes/Capitularia/widgets/cap-widgets.php

Capitularia Theme Widgets

themes/Capitularia/widgets/class-archive-nav-menu-widget.php

Capitularia Theme Archive Navigation Menu Widget

class Archive_Nav_Menu_Widget

A navigation menu widget for a custom archives menu.

To display the post archives with our custom dynamic menu we need to have the list of archives somewhere in the HTML page for the menu to grab. This wrapper injects that list into the HTML page inside a hidden block and then lets the menu do its thing.

property menu_id
__construct()
widget(args, instance)

themes/Capitularia/widgets/class-categories-nav-menu-widget.php

Capitularia Theme Categories Navigation Menu Widget

class Categories_Nav_Menu_Widget

A navigation menu widget for a custom categories menu.

To display the post categories with our custom dynamic menu we need to have the list of categories somewhere in the HTML page for the menu to grab. This wrapper injects that list into the HTML page inside a hidden block and then lets the menu do its thing.

property menu_id
__construct()
widget(args, instance)

themes/Capitularia/widgets/class-frontpage-image-widget.php

Capitularia Front Page Image Widget

class Frontpage_Image_Widget

An image widget for the front page.

property class

(string) HTML class of widget container and body.

property options

((callable|string)[]) Contains data to build the fields in the ‘settings’ form.

May be edited in descendand classes to output different fields.

__construct()

Constructor

__construct(id, name, widget_ops)

Constructor

Parameters:
  • id (string) – The widget’s id.

  • name (string) – Name for the widget displayed on the configuration page.

  • widget_ops (array) – Widget options. See wp_register_sidebar_widget () for information on accepted arguments.

normalize(text)

Ensure text is a string.

Parameters:
  • text (string|null) – The input.

Returns:

The text or ‘’

Return type:

string

strip_tags(text)

Strip HTML tags from text.

Parameters:
  • text (string|null) – The input.

Returns:

The stripped input.

Return type:

string

sanitize(text)

Sanitize HTML text.

Parameters:
  • text (string|null) – The input.

Returns:

The sanitized input.

Return type:

string

Make an HTML <a>

Parameters:
  • text (string) – The link text.

  • href (string) – The link href.

  • classes (string) – The link classes.

Returns:

The HTML link.

Return type:

string

the_widget_title(args, instance)

Echo the widget title.

Parameters:
  • args (array) – Array of arguments to configure the display of the widget.

  • instance (array) – The widget’s instance settings.

Return type:

void

the_widget_body(args, instance)

Echo the widget body.

Parameters:
  • args (array) – Array of arguments to configure the display of the widget.

  • instance (array) – The widget’s instance settings.

Return type:

void

the_widget_image(dummy_args, instance)

Output the widget image.

Replaces a leading ~ with the theme image directory url, eg. ~/logo.png => https://server/path/to/images/logo.png

Parameters:
  • dummy_args (array) – (unused) Display arguments including ‘before_title’, ‘after_title’, ‘before_widget’, and ‘after_widget’.

  • instance (array) – Settings for the current widget instance.

Return type:

void

widget(args, instance)

Output the widget.

Parameters:
  • args (array) – Display arguments including ‘before_title’, ‘after_title’, ‘before_widget’, and ‘after_widget’.

  • instance (array) – Settings for the current widget instance.

Return type:

void

the_option(instance, name, caption, placeholder)

Output one option field on the admin page.

Parameters:
  • instance (object) – The instance

  • name (string) – Option field name

  • caption (string) – Option field caption

  • placeholder (string) – Option field placeholder

Return type:

void

update(new_instance, old_instance)

Handles updating settings for the current widget instance.

Parameters:
  • new_instance (array) – New settings for this instance as input by the user via WP_Widget::form ().

  • old_instance (array) – Old settings for this instance.

Returns:

Settings to save.

Return type:

array

form(instance)

Outputs the widget settings form.

Parameters:
  • instance (array) – Current settings.

Return type:

void

themes/Capitularia/widgets/class-frontpage-logo-widget.php

Capitularia Front Page Logo Widget

class Frontpage_Logo_Widget

A logo widget for the front page.

property class

(string) HTML class of widget container and body.

property options

((callable|string)[]) Contains data to build the fields in the ‘settings’ form.

May be edited in descendand classes to output different fields.

__construct()

Constructor

Make an HTML <a>

the_widget_title(dummy_args, dummy_instance)

Echo the widget title.

the_widget_body(dummy_args, dummy_instance)

Echo the widget body.

__construct(id, name, widget_ops)

Constructor

Parameters:
  • id (string) – The widget’s id.

  • name (string) – Name for the widget displayed on the configuration page.

  • widget_ops (array) – Widget options. See wp_register_sidebar_widget () for information on accepted arguments.

normalize(text)

Ensure text is a string.

Parameters:
  • text (string|null) – The input.

Returns:

The text or ‘’

Return type:

string

strip_tags(text)

Strip HTML tags from text.

Parameters:
  • text (string|null) – The input.

Returns:

The stripped input.

Return type:

string

sanitize(text)

Sanitize HTML text.

Parameters:
  • text (string|null) – The input.

Returns:

The sanitized input.

Return type:

string

make_link(text, href, classes)

Make an HTML <a>

Parameters:
  • text (string) – The link text.

  • href (string) – The link href.

  • classes (string) – The link classes.

Returns:

The HTML link.

Return type:

string

the_widget_title(args, instance)

Echo the widget title.

Parameters:
  • args (array) – Array of arguments to configure the display of the widget.

  • instance (array) – The widget’s instance settings.

Return type:

void

the_widget_body(args, instance)

Echo the widget body.

Parameters:
  • args (array) – Array of arguments to configure the display of the widget.

  • instance (array) – The widget’s instance settings.

Return type:

void

the_widget_image(dummy_args, instance)

Output the widget image.

Replaces a leading ~ with the theme image directory url, eg. ~/logo.png => https://server/path/to/images/logo.png

Parameters:
  • dummy_args (array) – (unused) Display arguments including ‘before_title’, ‘after_title’, ‘before_widget’, and ‘after_widget’.

  • instance (array) – Settings for the current widget instance.

Return type:

void

widget(args, instance)

Output the widget.

Parameters:
  • args (array) – Display arguments including ‘before_title’, ‘after_title’, ‘before_widget’, and ‘after_widget’.

  • instance (array) – Settings for the current widget instance.

Return type:

void

the_option(instance, name, caption, placeholder)

Output one option field on the admin page.

Parameters:
  • instance (object) – The instance

  • name (string) – Option field name

  • caption (string) – Option field caption

  • placeholder (string) – Option field placeholder

Return type:

void

update(new_instance, old_instance)

Handles updating settings for the current widget instance.

Parameters:
  • new_instance (array) – New settings for this instance as input by the user via WP_Widget::form ().

  • old_instance (array) – Old settings for this instance.

Returns:

Settings to save.

Return type:

array

form(instance)

Outputs the widget settings form.

Parameters:
  • instance (array) – Current settings.

Return type:

void

themes/Capitularia/widgets/class-frontpage-text-widget.php

Capitularia Front Page Text Widget

class Frontpage_Text_Widget

A text widget for the front page.

property class

(string) HTML class of widget container and body.

property options

((callable|string)[]) Contains data to build the fields in the ‘settings’ form.

May be edited in descendand classes to output different fields.

__construct()

Constructor

the_widget_image(dummy_args, dummy_instance)

Output the widget image.

Replaces a leading ~ with the theme image directory url, eg. ~/logo.png => https://server/path/to/images/logo.png

__construct(id, name, widget_ops)

Constructor

Parameters:
  • id (string) – The widget’s id.

  • name (string) – Name for the widget displayed on the configuration page.

  • widget_ops (array) – Widget options. See wp_register_sidebar_widget () for information on accepted arguments.

normalize(text)

Ensure text is a string.

Parameters:
  • text (string|null) – The input.

Returns:

The text or ‘’

Return type:

string

strip_tags(text)

Strip HTML tags from text.

Parameters:
  • text (string|null) – The input.

Returns:

The stripped input.

Return type:

string

sanitize(text)

Sanitize HTML text.

Parameters:
  • text (string|null) – The input.

Returns:

The sanitized input.

Return type:

string

Make an HTML <a>

Parameters:
  • text (string) – The link text.

  • href (string) – The link href.

  • classes (string) – The link classes.

Returns:

The HTML link.

Return type:

string

the_widget_title(args, instance)

Echo the widget title.

Parameters:
  • args (array) – Array of arguments to configure the display of the widget.

  • instance (array) – The widget’s instance settings.

Return type:

void

the_widget_body(args, instance)

Echo the widget body.

Parameters:
  • args (array) – Array of arguments to configure the display of the widget.

  • instance (array) – The widget’s instance settings.

Return type:

void

the_widget_image(dummy_args, instance)

Output the widget image.

Replaces a leading ~ with the theme image directory url, eg. ~/logo.png => https://server/path/to/images/logo.png

Parameters:
  • dummy_args (array) – (unused) Display arguments including ‘before_title’, ‘after_title’, ‘before_widget’, and ‘after_widget’.

  • instance (array) – Settings for the current widget instance.

Return type:

void

widget(args, instance)

Output the widget.

Parameters:
  • args (array) – Display arguments including ‘before_title’, ‘after_title’, ‘before_widget’, and ‘after_widget’.

  • instance (array) – Settings for the current widget instance.

Return type:

void

the_option(instance, name, caption, placeholder)

Output one option field on the admin page.

Parameters:
  • instance (object) – The instance

  • name (string) – Option field name

  • caption (string) – Option field caption

  • placeholder (string) – Option field placeholder

Return type:

void

update(new_instance, old_instance)

Handles updating settings for the current widget instance.

Parameters:
  • new_instance (array) – New settings for this instance as input by the user via WP_Widget::form ().

  • old_instance (array) – Old settings for this instance.

Returns:

Settings to save.

Return type:

array

form(instance)

Outputs the widget settings form.

Parameters:
  • instance (array) – Current settings.

Return type:

void

themes/Capitularia/widgets/class-frontpage-widget-base.php

Capitularia Theme Widgets

class Frontpage_Widget_Base

Base class for the front page widgets.

property class

(string) HTML class of widget container and body.

property options

((callable|string)[]) Contains data to build the fields in the ‘settings’ form.

May be edited in descendand classes to output different fields.

__construct(id, name, widget_ops)

Constructor

Parameters:
  • id (string) – The widget’s id.

  • name (string) – Name for the widget displayed on the configuration page.

  • widget_ops (array) – Widget options. See wp_register_sidebar_widget () for information on accepted arguments.

normalize(text)

Ensure text is a string.

Parameters:
  • text (string|null) – The input.

Returns:

The text or ‘’

Return type:

string

strip_tags(text)

Strip HTML tags from text.

Parameters:
  • text (string|null) – The input.

Returns:

The stripped input.

Return type:

string

sanitize(text)

Sanitize HTML text.

Parameters:
  • text (string|null) – The input.

Returns:

The sanitized input.

Return type:

string

Make an HTML <a>

Parameters:
  • text (string) – The link text.

  • href (string) – The link href.

  • classes (string) – The link classes.

Returns:

The HTML link.

Return type:

string

the_widget_title(args, instance)

Echo the widget title.

Parameters:
  • args (array) – Array of arguments to configure the display of the widget.

  • instance (array) – The widget’s instance settings.

Return type:

void

the_widget_body(args, instance)

Echo the widget body.

Parameters:
  • args (array) – Array of arguments to configure the display of the widget.

  • instance (array) – The widget’s instance settings.

Return type:

void

the_widget_image(dummy_args, instance)

Output the widget image.

Replaces a leading ~ with the theme image directory url, eg. ~/logo.png => https://server/path/to/images/logo.png

Parameters:
  • dummy_args (array) – (unused) Display arguments including ‘before_title’, ‘after_title’, ‘before_widget’, and ‘after_widget’.

  • instance (array) – Settings for the current widget instance.

Return type:

void

widget(args, instance)

Output the widget.

Parameters:
  • args (array) – Display arguments including ‘before_title’, ‘after_title’, ‘before_widget’, and ‘after_widget’.

  • instance (array) – Settings for the current widget instance.

Return type:

void

the_option(instance, name, caption, placeholder)

Output one option field on the admin page.

Parameters:
  • instance (object) – The instance

  • name (string) – Option field name

  • caption (string) – Option field caption

  • placeholder (string) – Option field placeholder

Return type:

void

update(new_instance, old_instance)

Handles updating settings for the current widget instance.

Parameters:
  • new_instance (array) – New settings for this instance as input by the user via WP_Widget::form ().

  • old_instance (array) – Old settings for this instance.

Returns:

Settings to save.

Return type:

array

form(instance)

Outputs the widget settings form.

Parameters:
  • instance (array) – Current settings.

Return type:

void

themes/Capitularia/widgets/class-sticky-nav-menu-widget.php

Capitularia Theme Sticky Navigation Menu Widget

A sticky navigation menu widget for the sidebar.

Javascript