refactor: namespace everything
This commit is contained in:
parent
6683c0b169
commit
ce41cd8353
21 changed files with 939 additions and 839 deletions
94
src/public/widget/class-base.php
Normal file
94
src/public/widget/class-base.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* Widgets: Base class
|
||||
*
|
||||
* The Widget subpackage is composed of the {@see Base}
|
||||
* abstract class, which is extended by the {@see Reference_Container}
|
||||
* sub-class.
|
||||
*
|
||||
* @package footnotes
|
||||
* @since 1.5.0
|
||||
*/
|
||||
|
||||
namespace footnotes\general\Widget;
|
||||
use footnotes\includes as Includes;
|
||||
|
||||
/**
|
||||
* Base class to be extended by all widget sub-classes.
|
||||
*
|
||||
* Any sub-class must override the appropriate method(s) provided by
|
||||
* {@link https://developer.wordpress.org/reference/classes/wp_widget/#description `WP_Widget`}.
|
||||
*
|
||||
* @abstract
|
||||
*
|
||||
* @package footnotes
|
||||
* @since 1.5.0
|
||||
* @todo Review implemenation of Widgets API.
|
||||
*/
|
||||
abstract class Base extends \WP_Widget {
|
||||
|
||||
/**
|
||||
* Returns an unique ID as string used for the Widget Base ID.
|
||||
*
|
||||
* @abstract
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function get_id();
|
||||
|
||||
/**
|
||||
* Returns the Public name of child Widget to be displayed in the Configuration page.
|
||||
*
|
||||
* @abstract
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function get_name();
|
||||
|
||||
/**
|
||||
* Returns the Description of the child widget.
|
||||
*
|
||||
* @abstract
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function get_description();
|
||||
|
||||
/**
|
||||
* Returns the width of the Widget. Default width is 250 pixel.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get_widget_width() {
|
||||
return 250;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the child Widget to WordPress.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function __construct() {
|
||||
$l_arr_widget_options = array(
|
||||
'classname' => __CLASS__,
|
||||
'description' => $this->get_description(),
|
||||
);
|
||||
$l_arr_control_options = array(
|
||||
'id_base' => strtolower( $this->get_id() ),
|
||||
'width' => $this->get_widget_width(),
|
||||
);
|
||||
// Registers the Widget.
|
||||
parent::__construct(
|
||||
strtolower( $this->get_id() ), // Unique ID for the widget, has to be lowercase.
|
||||
$this->get_name(), // Plugin name to be displayed.
|
||||
$l_arr_widget_options, // Optional Widget Options.
|
||||
$l_arr_control_options // Optional Widget Control Options.
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue