2021-04-26 22:57:04 +01:00
< ? php
2021-02-23 16:00:59 +00:00
/**
2021-04-30 18:03:15 +01:00
* Widgets : Footnotes_Widget_Base class
2021-02-23 16:00:59 +00:00
*
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-02-23 16:00:59 +00:00
*/
/**
2021-04-30 18:03:15 +01:00
* Base class to be extended by all widget sub - classes .
2021-02-23 16:00:59 +00:00
*
2021-04-30 18:03:15 +01:00
* Any sub - class must override the appropriate method ( s ) provided by
* { @ link https :// developer . wordpress . org / reference / classes / wp_widget / #description `WP_Widget`}.
2021-04-27 10:05:51 +01:00
*
2021-04-30 18:03:15 +01:00
* @ abstract
*
* @ package footnotes\public\widget
* @ since 1.5 . 0
* @ todo Review implemenation of Widgets API .
2021-02-23 16:00:59 +00:00
*/
2021-04-19 12:16:05 +01:00
abstract class Footnotes_Widget_Base extends WP_Widget {
2021-02-23 16:00:59 +00:00
/**
* Returns an unique ID as string used for the Widget Base ID .
*
2021-04-30 18:03:15 +01:00
* @ abstract
* @ since 1.5 . 0
*
* @ return string
2021-02-23 16:00:59 +00:00
*/
2021-02-23 16:44:18 +00:00
abstract protected function get_id ();
2021-02-23 16:00:59 +00:00
/**
* Returns the Public name of child Widget to be displayed in the Configuration page .
*
2021-04-30 18:03:15 +01:00
* @ abstract
* @ since 1.5 . 0
*
* @ return string
2021-02-23 16:00:59 +00:00
*/
2021-02-23 16:44:18 +00:00
abstract protected function get_name ();
2021-02-23 16:00:59 +00:00
/**
* Returns the Description of the child widget .
*
2021-04-30 18:03:15 +01:00
* @ abstract
* @ since 1.5 . 0
*
* @ return string
2021-02-23 16:00:59 +00:00
*/
2021-02-23 16:44:18 +00:00
abstract protected function get_description ();
2021-02-23 16:00:59 +00:00
/**
* Returns the width of the Widget . Default width is 250 pixel .
*
2021-04-30 18:03:15 +01:00
* @ since 1.5 . 0
*
* @ return int
2021-02-23 16:00:59 +00:00
*/
2021-02-23 16:44:18 +00:00
protected function get_widget_width () {
2021-02-23 16:00:59 +00:00
return 250 ;
}
2021-04-30 18:03:15 +01:00
2021-02-23 16:00:59 +00:00
/**
2021-04-30 18:03:15 +01:00
* Registers the child Widget to WordPress .
2021-02-23 16:44:18 +00:00
*
2021-04-30 18:03:15 +01:00
* @ since 1.5 . 0
2021-02-23 16:00:59 +00:00
*/
public function __construct () {
2021-04-19 12:15:17 +01:00
$l_arr_widget_options = array (
2021-02-23 16:44:18 +00:00
'classname' => __CLASS__ ,
'description' => $this -> get_description (),
);
2021-04-19 12:15:17 +01:00
$l_arr_control_options = array (
2021-02-23 16:44:18 +00:00
'id_base' => strtolower ( $this -> get_id () ),
'width' => $this -> get_widget_width (),
);
// Registers the Widget.
2021-02-23 16:00:59 +00:00
parent :: __construct (
2021-02-23 16:44:18 +00:00
strtolower ( $this -> get_id () ), // Unique ID for the widget, has to be lowercase.
$this -> get_name (), // Plugin name to be displayed.
2021-04-19 12:15:17 +01:00
$l_arr_widget_options , // Optional Widget Options.
$l_arr_control_options // Optional Widget Control Options.
2021-02-23 16:44:18 +00:00
);
2021-02-23 16:00:59 +00:00
}
2021-04-30 18:03:15 +01:00
2021-02-23 16:00:59 +00:00
}