This repository has been archived on 2023-08-16. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
footnotes/src/public/widget/class-footnotes-widget-reference-container.php

114 lines
3 KiB
PHP
Raw Normal View History

<?php // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
/**
2021-04-30 18:03:15 +01:00
* Widgets: Footnotes_Widget_Reference_Container class
*
2021-04-30 18:03:15 +01:00
* The Widget subpackage is composed of the {@see Footnotes_Widget_Base}
* abstract class, which is extended by the {@see Footnotes_Widget_Reference_Container}
* sub-class.
2021-04-27 08:31:37 +01:00
*
2021-04-30 18:03:15 +01:00
* @package footnotes\public\widget
* @since 1.5.0
*/
2021-04-27 08:31:37 +01:00
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'widget/class-footnotes-widget-base.php';
/**
* Registers a Widget to put the Reference Container to the widget area.
*
2021-04-30 18:03:15 +01:00
* @package footnotes\public\widget
* @since 1.5.0
* @see Footnotes_Widget_Base
* @todo Review implemenation of Widgets API.
*/
2021-04-19 12:16:05 +01:00
class Footnotes_Widget_Reference_Container extends Footnotes_Widget_Base {
2021-04-27 09:30:53 +01:00
/**
* The ID of this plugin.
*
2021-04-30 18:03:15 +01:00
* @access private
* @since 2.8.0
* @see Footnotes::$plugin_name
* @var string $plugin_name The ID of this plugin.
2021-04-27 09:30:53 +01:00
*/
private $plugin_name;
2021-04-27 09:54:07 +01:00
2021-04-27 09:30:53 +01:00
/**
* Initialize the class and set its properties.
*
2021-04-30 18:03:15 +01:00
* @since 2.8.0
*
* @param string $plugin_name The name of this plugin.
2021-04-27 09:30:53 +01:00
*/
public function __construct( $plugin_name ) {
parent::__construct();
$this->plugin_name = $plugin_name;
}
/**
* Returns an unique ID as string used for the Widget Base ID.
*
2021-04-30 18:03:15 +01:00
* @see Footnotes_Widget_Base::get_id()
* @since 1.5.0
*
* @return string
*/
protected function get_id() {
return 'footnotes_widget';
}
/**
* Returns the Public name of the Widget to be displayed in the Configuration page.
*
2021-04-30 18:03:15 +01:00
* @see Footnotes_Widget_Base::get_name()
* @since 1.5.0
*
* @return string
*/
protected function get_name() {
2021-04-27 09:30:53 +01:00
return $this->plugin_name;
}
/**
* Returns the Description of the child widget.
*
2021-04-30 18:03:15 +01:00
* @see Footnotes_Widget_Base::get_description()
* @since 1.5.0
*
2021-04-30 18:03:15 +01:00
* @return string
*/
protected function get_description() {
2021-04-30 18:03:15 +01:00
return __( 'The widget defines the position of the reference container if set to &ldquo;widget area&rdquo;.', 'footnotes' );
}
/**
* Outputs the Settings of the Widget.
*
2021-04-30 18:03:15 +01:00
* @link https://developer.wordpress.org/reference/classes/wp_widget/form/ `WP_Widget::form()`
* @since 1.5.0
*
2021-04-30 18:03:15 +01:00
* @param mixed $instance The instance of the widget.
*/
public function form( $instance ) {
2021-04-30 18:03:15 +01:00
echo __( 'The widget defines the position of the reference container if set to &ldquo;widget area&rdquo;.', 'footnotes' );
}
/**
* Outputs the Content of the Widget.
*
2021-04-30 18:03:15 +01:00
* @link https://developer.wordpress.org/reference/classes/wp_widget/widget/ `WP_Widget::widget()`
* @since 1.5.0
*
* @param mixed $args The widget's arguments.
* @param mixed $instance The instance of the widget.
*/
public function widget( $args, $instance ) {
global $footnotes;
// Reference container positioning is set to "widget area".
2021-04-19 12:16:05 +01:00
if ( 'widget' === Footnotes_Settings::instance()->get( Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION ) ) {
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $footnotes->a_obj_task->reference_container();
// phpcs:enable
}
}
}