refactor: add return types
This commit is contained in:
parent
7d64296b21
commit
c1421d1978
7 changed files with 130 additions and 99 deletions
|
@ -11,6 +11,8 @@
|
|||
* @since 2.8.0
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace footnotes\admin;
|
||||
|
||||
use footnotes\includes as Includes;
|
||||
|
@ -34,7 +36,7 @@ class Admin {
|
|||
* @see Includes\Footnotes::$plugin_name
|
||||
* @var string $plugin_name The ID of this plugin.
|
||||
*/
|
||||
private $plugin_name;
|
||||
private string $plugin_name;
|
||||
|
||||
/**
|
||||
* The version of this plugin.
|
||||
|
@ -44,7 +46,7 @@ class Admin {
|
|||
* @see Includes\Footnotes::$version
|
||||
* @var string $version The current version of this plugin.
|
||||
*/
|
||||
private $version;
|
||||
private string $version;
|
||||
|
||||
/**
|
||||
* The WYSIWYG editor integration object.
|
||||
|
@ -52,7 +54,7 @@ class Admin {
|
|||
* @since 2.8.0
|
||||
* @var WYSIWYG $wysiwyg The WYSIWYG editor integration object.
|
||||
*/
|
||||
public $wysiwyg;
|
||||
public WYSIWYG $wysiwyg;
|
||||
|
||||
/**
|
||||
* Initialize the class and set its properties.
|
||||
|
@ -62,7 +64,7 @@ class Admin {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function __construct( $plugin_name, $version ) {
|
||||
public function __construct( string $plugin_name, string $version ) {
|
||||
|
||||
$this->plugin_name = $plugin_name;
|
||||
$this->version = $version;
|
||||
|
@ -84,7 +86,7 @@ class Admin {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
private function load_dependencies() {
|
||||
private function load_dependencies(): void {
|
||||
/**
|
||||
* The class responsible for WYSIWYG editor integration.
|
||||
*/
|
||||
|
@ -105,7 +107,7 @@ class Admin {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function enqueue_styles() {
|
||||
public function enqueue_styles(): void {
|
||||
|
||||
wp_enqueue_style(
|
||||
$this->plugin_name,
|
||||
|
@ -113,11 +115,12 @@ class Admin {
|
|||
array(),
|
||||
( PRODUCTION_ENV ) ? $this->version : filemtime(
|
||||
plugin_dir_path(
|
||||
dirname( __FILE__ )
|
||||
__FILE__
|
||||
) . 'css/settings.css'
|
||||
),
|
||||
'all'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,7 +128,7 @@ class Admin {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
public function enqueue_scripts(): void {
|
||||
|
||||
wp_enqueue_script(
|
||||
$this->plugin_name,
|
||||
|
@ -133,7 +136,7 @@ class Admin {
|
|||
array(),
|
||||
( PRODUCTION_ENV ) ? $this->version : filemtime(
|
||||
plugin_dir_path(
|
||||
dirname( __FILE__ )
|
||||
__FILE__
|
||||
) . 'js/wysiwyg-editor.js'
|
||||
),
|
||||
false
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* move from `class/` sub-directory to `admin/`.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace footnotes\admin;
|
||||
|
||||
use footnotes\includes as Includes;
|
||||
|
@ -34,7 +36,7 @@ class WYSIWYG {
|
|||
* @since 1.5.0
|
||||
* @todo Should this be `static`?
|
||||
*/
|
||||
public static function new_visual_editor_button( $p_arr_buttons ) {
|
||||
public static function new_visual_editor_button( array $p_arr_buttons ): array {
|
||||
$p_arr_buttons[] = 'footnotes';
|
||||
return $p_arr_buttons;
|
||||
}
|
||||
|
@ -44,7 +46,7 @@ class WYSIWYG {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static function new_plain_text_editor_button() {
|
||||
public static function new_plain_text_editor_button(): void {
|
||||
$l_obj_template = new Includes\Template( \footnotes\includes\Template::C_STR_DASHBOARD, 'editor-button' );
|
||||
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo $l_obj_template->get_content();
|
||||
|
@ -60,7 +62,7 @@ class WYSIWYG {
|
|||
* @since 1.5.0
|
||||
* @todo Should this be `static`?
|
||||
*/
|
||||
public static function include_scripts( $p_arr_plugins ) {
|
||||
public static function include_scripts( array $p_arr_plugins ): array {
|
||||
$p_arr_plugins['footnotes'] = plugins_url( '/../admin/js/wysiwyg-editor' . ( ( PRODUCTION_ENV ) ? '.min' : '' ) . '.js', __FILE__ );
|
||||
return $p_arr_plugins;
|
||||
}
|
||||
|
@ -71,7 +73,7 @@ class WYSIWYG {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static function ajax_callback() {
|
||||
public static function ajax_callback(): void {
|
||||
// Get start and end tag for the footnotes short code.
|
||||
$l_str_starting_tag = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_FOOTNOTES_SHORT_CODE_START );
|
||||
$l_str_ending_tag = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_FOOTNOTES_SHORT_CODE_END );
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* rename `dashboard/` sub-directory to `layout/`.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace footnotes\admin\layout;
|
||||
|
||||
use footnotes\includes as Includes;
|
||||
|
@ -37,7 +39,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
protected $plugin_name;
|
||||
protected string $plugin_name;
|
||||
|
||||
/**
|
||||
* Stores the Hook connection string for the child sub-page.
|
||||
|
@ -47,7 +49,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
protected $a_str_sub_page_hook;
|
||||
protected ?string $a_str_sub_page_hook;
|
||||
|
||||
/**
|
||||
* Stores all Sections for the child sub-page.
|
||||
|
@ -57,7 +59,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
protected $a_arr_sections = array();
|
||||
protected array $a_arr_sections = array();
|
||||
|
||||
/**
|
||||
* Returns a Priority index. Lower numbers have a higher priority.
|
||||
|
@ -67,7 +69,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
abstract public function get_priority();
|
||||
abstract public function get_priority(): int;
|
||||
|
||||
/**
|
||||
* Returns the unique slug of the child sub-page.
|
||||
|
@ -78,7 +80,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
abstract protected function get_sub_page_slug();
|
||||
abstract protected function get_sub_page_slug(): string;
|
||||
|
||||
/**
|
||||
* Returns the title of the child sub-page.
|
||||
|
@ -89,7 +91,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
abstract protected function get_sub_page_title();
|
||||
abstract protected function get_sub_page_title(): string;
|
||||
|
||||
/**
|
||||
* Returns an array of all registered sections for a sub-page.
|
||||
|
@ -100,7 +102,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
abstract protected function get_sections();
|
||||
abstract protected function get_sections(): array;
|
||||
|
||||
/**
|
||||
* Returns an array of all registered meta boxes.
|
||||
|
@ -111,7 +113,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
abstract protected function get_meta_boxes();
|
||||
abstract protected function get_meta_boxes(): array;
|
||||
|
||||
/**
|
||||
* Returns an array describing a sub-page section.
|
||||
|
@ -134,7 +136,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Refactor sections into their own class?
|
||||
*/
|
||||
protected function add_section( $p_str_id, $p_str_title, $p_int_settings_container_index, $p_bool_has_submit_button = true ) {
|
||||
protected function add_section( string $p_str_id, string $p_str_title, int $p_int_settings_container_index, bool $p_bool_has_submit_button = true ): array {
|
||||
return array(
|
||||
'id' => $this->plugin_name . '-' . $p_str_id,
|
||||
'title' => $p_str_title,
|
||||
|
@ -164,7 +166,7 @@ abstract class Engine {
|
|||
* @todo Refactor meta boxes into their own class?
|
||||
* @todo Pass actual functions rather than strings?
|
||||
*/
|
||||
protected function add_meta_box( $p_str_section_id, $p_str_id, $p_str_title, $p_str_callback_function_name ) {
|
||||
protected function add_meta_box( string $p_str_section_id, string $p_str_id, string $p_str_title, string $p_str_callback_function_name ): array {
|
||||
return array(
|
||||
'parent' => $this->plugin_name . '-' . $p_str_section_id,
|
||||
'id' => $p_str_id,
|
||||
|
@ -178,7 +180,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function register_sub_page() {
|
||||
public function register_sub_page(): void {
|
||||
global $submenu;
|
||||
|
||||
if ( array_key_exists( plugin_basename( Init::C_STR_MAIN_MENU_SLUG ), $submenu ) ) {
|
||||
|
@ -206,7 +208,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function register_sections() {
|
||||
public function register_sections(): void {
|
||||
foreach ( $this->get_sections() as $l_arr_section ) {
|
||||
// Append tab to the tab-array.
|
||||
$this->a_arr_sections[ $l_arr_section['id'] ] = $l_arr_section;
|
||||
|
@ -230,7 +232,7 @@ abstract class Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
private function register_meta_boxes( $p_str_parent_id ) {
|
||||
private function register_meta_boxes( string $p_str_parent_id ): void {
|
||||
// Iterate through each meta box.
|
||||
foreach ( $this->get_meta_boxes() as $l_arr_meta_box ) {
|
||||
if ( $p_str_parent_id !== $l_arr_meta_box['parent'] ) {
|
||||
|
@ -254,7 +256,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Move to {@see Includes\Admin}.
|
||||
*/
|
||||
private function append_scripts() {
|
||||
private function append_scripts(): void {
|
||||
wp_enqueue_script( 'postbox' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
wp_enqueue_script( 'wp-color-picker' );
|
||||
|
@ -267,7 +269,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Review nonce verification.
|
||||
*/
|
||||
public function display_content() {
|
||||
public function display_content(): void {
|
||||
$this->append_scripts();
|
||||
|
||||
// Get the current section.
|
||||
|
@ -337,7 +339,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Review nonce verification.
|
||||
*/
|
||||
private function save_settings() {
|
||||
private function save_settings(): bool {
|
||||
$l_arr_new_settings = array();
|
||||
|
||||
// TODO: add nonce verification.
|
||||
|
@ -361,7 +363,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Required? Should be `abstract`?
|
||||
*/
|
||||
public function description() {
|
||||
public function description(): void {
|
||||
// Default no description will be displayed.
|
||||
}
|
||||
|
||||
|
@ -382,7 +384,7 @@ abstract class Engine {
|
|||
* @since 2.5.11 Broken due to accidental removal of `esc_attr()` call.
|
||||
* @since 2.6.1 Restore `esc_attr()` call.
|
||||
*/
|
||||
protected function load_setting( $p_str_setting_key_name ) {
|
||||
protected function load_setting( string $p_str_setting_key_name ): array {
|
||||
// Get current section.
|
||||
reset( $this->a_arr_sections );
|
||||
$p_arr_return = array();
|
||||
|
@ -393,7 +395,7 @@ abstract class Engine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a simple text inside HTML `<span>` element.
|
||||
* Returns a simple text inside a 'span' element.
|
||||
*
|
||||
* @access protected
|
||||
* @param string $p_str_text Message to be surrounded with `<span>` tags.
|
||||
|
@ -402,12 +404,12 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Refactor HTML generation.
|
||||
*/
|
||||
protected function add_text( $p_str_text ) {
|
||||
protected function add_text( string $p_str_text ): string {
|
||||
return sprintf( '<span>%s</span>', $p_str_text );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML tag for an `<input>`/`<select>` label.
|
||||
* Returns the HTML tag for a 'label' element.
|
||||
*
|
||||
* @access protected
|
||||
* @param string $p_str_setting_name Settings key.
|
||||
|
@ -417,7 +419,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Refactor HTML generation.
|
||||
*/
|
||||
protected function add_label( $p_str_setting_name, $p_str_caption ) {
|
||||
protected function add_label( string $p_str_setting_name, string $p_str_caption ): string {
|
||||
if ( empty( $p_str_caption ) ) {
|
||||
return '';
|
||||
}
|
||||
|
@ -437,7 +439,7 @@ abstract class Engine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs the HTML for a text `<input>` element.
|
||||
* Constructs the HTML for a text 'input' element.
|
||||
*
|
||||
* @access protected
|
||||
* @param string $p_str_setting_name Setting key.
|
||||
|
@ -449,7 +451,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Refactor HTML generation.
|
||||
*/
|
||||
protected function add_text_box( $p_str_setting_name, $p_str_max_length = 999, $p_bool_readonly = false, $p_bool_hidden = false ) {
|
||||
protected function add_text_box( string $p_str_setting_name, int $p_str_max_length = 999, bool $p_bool_readonly = false, bool $p_bool_hidden = false ): string {
|
||||
$l_str_style = '';
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
|
@ -468,7 +470,7 @@ abstract class Engine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs the HTML for a checkbox `<input>` element.
|
||||
* Constructs the HTML for a checkbox 'input' element.
|
||||
*
|
||||
* @access protected
|
||||
* @param string $p_str_setting_name Setting key.
|
||||
|
@ -477,7 +479,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Refactor HTML generation.
|
||||
*/
|
||||
protected function add_checkbox( $p_str_setting_name ) {
|
||||
protected function add_checkbox( string $p_str_setting_name ): string {
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
return sprintf(
|
||||
|
@ -489,7 +491,7 @@ abstract class Engine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs the HTML for a `<select>` element.
|
||||
* Constructs the HTML for a 'select' element.
|
||||
*
|
||||
* @access protected
|
||||
* @param string $p_str_setting_name Setting key.
|
||||
|
@ -499,7 +501,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Refactor HTML generation.
|
||||
*/
|
||||
protected function add_select_box( $p_str_setting_name, $p_arr_options ) {
|
||||
protected function add_select_box( string $p_str_setting_name, array $p_arr_options ): string {
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
$l_str_options = '';
|
||||
|
@ -525,7 +527,7 @@ abstract class Engine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs the HTML for a `<textarea>` element.
|
||||
* Constructs the HTML for a 'textarea' element.
|
||||
*
|
||||
* @access protected
|
||||
* @param string $p_str_setting_name Setting key.
|
||||
|
@ -534,7 +536,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Refactor HTML generation.
|
||||
*/
|
||||
protected function add_textarea( $p_str_setting_name ) {
|
||||
protected function add_textarea( $p_str_setting_name ): string {
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
return sprintf(
|
||||
|
@ -546,7 +548,7 @@ abstract class Engine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs the HTML for a text `<input>` element with the colour selection
|
||||
* Constructs the HTML for a text 'input' element with the colour selection
|
||||
* class.
|
||||
*
|
||||
* @access protected
|
||||
|
@ -557,7 +559,7 @@ abstract class Engine {
|
|||
* @todo Refactor HTML generation.
|
||||
* @todo Use proper colorpicker element.
|
||||
*/
|
||||
protected function add_color_selection( $p_str_setting_name ) {
|
||||
protected function add_color_selection( string $p_str_setting_name ): string {
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
return sprintf(
|
||||
|
@ -569,7 +571,7 @@ abstract class Engine {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs the HTML for numeric `<input>` element.
|
||||
* Constructs the HTML for numeric 'input' element.
|
||||
*
|
||||
* @access protected
|
||||
* @param string $p_str_setting_name Setting key.
|
||||
|
@ -581,7 +583,7 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
* @todo Refactor HTML generation.
|
||||
*/
|
||||
protected function add_num_box( $p_str_setting_name, $p_in_min, $p_int_max, $p_bool_deci = false ) {
|
||||
protected function add_num_box( string $p_str_setting_name, int $p_in_min, int $p_int_max, bool $p_bool_deci = false ): string {
|
||||
// Collect data for given settings field.
|
||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* rename `dashboard/` sub-directory to `layout/`.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace footnotes\admin\layout;
|
||||
|
||||
use footnotes\includes as Includes;
|
||||
|
@ -33,7 +35,7 @@ class Init {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
private $plugin_name;
|
||||
private string $plugin_name;
|
||||
|
||||
/**
|
||||
* Slug for the Plugin main menu.
|
||||
|
@ -51,7 +53,7 @@ class Init {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
private $settings_page;
|
||||
private Settings $settings_page;
|
||||
|
||||
/**
|
||||
* Initializes all WordPress hooks for the Plugin Settings.
|
||||
|
@ -61,7 +63,7 @@ class Init {
|
|||
* @since 1.5.0
|
||||
* @since 2.8.0 Added `$plugin_name` parameter.
|
||||
*/
|
||||
public function __construct( $plugin_name ) {
|
||||
public function __construct( string $plugin_name ) {
|
||||
$this->plugin_name = $plugin_name;
|
||||
|
||||
$this->load_dependencies();
|
||||
|
@ -109,7 +111,7 @@ class Init {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
private function load_dependencies() {
|
||||
private function load_dependencies(): void {
|
||||
/**
|
||||
* Defines plugin constants.
|
||||
*/
|
||||
|
@ -131,7 +133,7 @@ class Init {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function initialize_settings() {
|
||||
public function initialize_settings(): void {
|
||||
Includes\Settings::instance()->register_settings();
|
||||
$this->settings_page->register_sections();
|
||||
}
|
||||
|
@ -142,7 +144,7 @@ class Init {
|
|||
* @since 1.5.0
|
||||
* @see http://codex.wordpress.org/Function_Reference/add_menu_page
|
||||
*/
|
||||
public function register_options_submenu() {
|
||||
public function register_options_submenu(): void {
|
||||
add_submenu_page(
|
||||
'options-general.php',
|
||||
'footnotes Settings',
|
||||
|
@ -162,8 +164,8 @@ class Init {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function get_plugin_meta_information() {
|
||||
// TODO: add nonce verification.
|
||||
public function get_plugin_meta_information(): void {
|
||||
// TODO: add nonce verification?
|
||||
|
||||
// Get plugin internal name from POST data.
|
||||
if ( isset( $_POST['plugin'] ) ) {
|
||||
|
|
|
@ -13,9 +13,12 @@
|
|||
* rename `dashboard/` sub-directory to `layout/`.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace footnotes\admin\layout;
|
||||
|
||||
use footnotes\includes as Includes;
|
||||
use footnotes\general as General;
|
||||
|
||||
/**
|
||||
* Provides the abstract class to be extended for page layouts.
|
||||
|
@ -38,7 +41,7 @@ class Settings extends Engine {
|
|||
* @since 2.8.0
|
||||
* @param string $plugin_name The name of this plugin.
|
||||
*/
|
||||
public function __construct( $plugin_name ) {
|
||||
public function __construct( string $plugin_name ) {
|
||||
$this->plugin_name = $plugin_name;
|
||||
}
|
||||
|
||||
|
@ -50,7 +53,7 @@ class Settings extends Engine {
|
|||
* @since 1.5.0
|
||||
* @return int
|
||||
*/
|
||||
public function get_priority() {
|
||||
public function get_priority(): int {
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
@ -60,7 +63,7 @@ class Settings extends Engine {
|
|||
* @since 1.5.0
|
||||
* @return string
|
||||
*/
|
||||
protected function get_sub_page_slug() {
|
||||
protected function get_sub_page_slug(): string {
|
||||
return '-' . $this->plugin_name;
|
||||
}
|
||||
|
||||
|
@ -70,7 +73,7 @@ class Settings extends Engine {
|
|||
* @since 1.5.0
|
||||
* @return string
|
||||
*/
|
||||
protected function get_sub_page_title() {
|
||||
protected function get_sub_page_title(): string {
|
||||
return \footnotes\includes\Config::C_STR_PLUGIN_PUBLIC_NAME;
|
||||
}
|
||||
|
||||
|
@ -83,7 +86,7 @@ class Settings extends Engine {
|
|||
* @since 1.5.0
|
||||
* @since 2.1.6 Remove conditional rendering of ‘Expert’ tab.
|
||||
*/
|
||||
protected function get_sections() {
|
||||
protected function get_sections(): array {
|
||||
$l_arr_tabs = array();
|
||||
|
||||
// Sync tab name with mirror in task.php.
|
||||
|
@ -94,7 +97,7 @@ class Settings extends Engine {
|
|||
|
||||
$l_arr_tabs[] = $this->add_section( 'expert', __( 'Scope and priority', 'footnotes' ), 2, true );
|
||||
$l_arr_tabs[] = $this->add_section( 'customcss', __( 'Custom CSS', 'footnotes' ), 3, true );
|
||||
$l_arr_tabs[] = $this->add_section( 'how-to', __( 'Quick start guide', 'footnotes' ), null, false );
|
||||
$l_arr_tabs[] = $this->add_section( 'how-to', __( 'Quick start guide', 'footnotes' ), 4, false );
|
||||
|
||||
return $l_arr_tabs;
|
||||
}
|
||||
|
@ -109,7 +112,7 @@ class Settings extends Engine {
|
|||
* @since 1.5.0
|
||||
* @since 2.2.0 Re-order and rename tabs.
|
||||
*/
|
||||
protected function get_meta_boxes() {
|
||||
protected function get_meta_boxes(): array {
|
||||
$l_arr_meta_boxes = array();
|
||||
|
||||
$l_arr_meta_boxes[] = $this->add_meta_box( 'settings', 'amp-compat', __( 'AMP compatibility', 'footnotes' ), 'amp_compat' );
|
||||
|
@ -153,7 +156,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.6.0 (release)
|
||||
*/
|
||||
public function amp_compat() {
|
||||
public function amp_compat(): void {
|
||||
|
||||
// Load template file.
|
||||
$l_obj_template = new Includes\Template( \footnotes\includes\Template::C_STR_DASHBOARD, 'settings-amp' );
|
||||
|
@ -180,7 +183,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function reference_container() {
|
||||
public function reference_container(): void {
|
||||
|
||||
// Options for the label element.
|
||||
$l_arr_label_element = array(
|
||||
|
@ -355,7 +358,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function start_end() {
|
||||
public function start_end(): void {
|
||||
// Footnotes start tag short code options.
|
||||
$l_arr_shortcode_start = array(
|
||||
'((' => '((',
|
||||
|
@ -432,7 +435,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function numbering() {
|
||||
public function numbering(): void {
|
||||
// Define some space for the output.
|
||||
$l_str_space = ' ';
|
||||
// Options for the combination of identical footnotes.
|
||||
|
@ -477,7 +480,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function scrolling() {
|
||||
public function scrolling(): void {
|
||||
|
||||
// Options for enabling scroll duration asymmetricity.
|
||||
$l_arr_enable = array(
|
||||
|
@ -533,7 +536,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function hard_links() {
|
||||
public function hard_links(): void {
|
||||
|
||||
// Options for enabling hard links for AMP compat.
|
||||
$l_arr_enable = array(
|
||||
|
@ -585,7 +588,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function love() {
|
||||
public function love(): void {
|
||||
// Options for the acknowledgment display in the footer.
|
||||
$l_arr_love = array(
|
||||
// Logo only.
|
||||
|
@ -631,7 +634,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function excerpts() {
|
||||
public function excerpts(): void {
|
||||
// Options for options select box.
|
||||
$l_arr_excerpt_mode = array(
|
||||
'yes' => __( 'Yes, generate excerpts from posts with effectively processed footnotes and other markup', 'footnotes' ),
|
||||
|
@ -663,7 +666,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function superscript() {
|
||||
public function superscript(): void {
|
||||
// Options for Yes/No select box.
|
||||
$l_arr_enabled = array(
|
||||
'yes' => __( 'Yes', 'footnotes' ),
|
||||
|
@ -708,7 +711,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.5.12
|
||||
*/
|
||||
public function label_solution() {
|
||||
public function label_solution(): void {
|
||||
// Options for the input label issue solution.
|
||||
$l_arr_issue_solutions = array(
|
||||
'none' => __( '0. No problem or solved otherwise', 'footnotes' ),
|
||||
|
@ -737,7 +740,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 1.5.2
|
||||
*/
|
||||
public function mouseover_box() {
|
||||
public function mouseover_box(): void {
|
||||
// Options for Yes/No select box.
|
||||
$l_arr_enabled = array(
|
||||
'yes' => __( 'Yes', 'footnotes' ),
|
||||
|
@ -773,7 +776,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function mouseover_box_position() {
|
||||
public function mouseover_box_position(): void {
|
||||
|
||||
// Options for the Mouse-over box position.
|
||||
$l_arr_position = array(
|
||||
|
@ -828,7 +831,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function mouseover_box_dimensions() {
|
||||
public function mouseover_box_dimensions(): void {
|
||||
|
||||
// Load template file.
|
||||
$l_obj_template = new Includes\Template( \footnotes\includes\Template::C_STR_DASHBOARD, 'mouse-over-box-dimensions' );
|
||||
|
@ -854,7 +857,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function mouseover_box_timing() {
|
||||
public function mouseover_box_timing(): void {
|
||||
|
||||
// Load template file.
|
||||
$l_obj_template = new Includes\Template( \footnotes\includes\Template::C_STR_DASHBOARD, 'mouse-over-box-timing' );
|
||||
|
@ -891,7 +894,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function mouseover_box_truncation() {
|
||||
public function mouseover_box_truncation(): void {
|
||||
// Options for Yes/No select box.
|
||||
$l_arr_enabled = array(
|
||||
'yes' => __( 'Yes', 'footnotes' ),
|
||||
|
@ -928,7 +931,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function mouseover_box_text() {
|
||||
public function mouseover_box_text(): void {
|
||||
// Options for Yes/No select box.
|
||||
$l_arr_enabled = array(
|
||||
'yes' => __( 'Yes', 'footnotes' ),
|
||||
|
@ -970,7 +973,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function mouseover_box_appearance() {
|
||||
public function mouseover_box_appearance(): void {
|
||||
// Options for Yes/No select box.
|
||||
$l_arr_enabled = array(
|
||||
'yes' => __( 'Yes', 'footnotes' ),
|
||||
|
@ -1040,7 +1043,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function hyperlink_arrow() {
|
||||
public function hyperlink_arrow(): void {
|
||||
// Load template file.
|
||||
$l_obj_template = new Includes\Template( \footnotes\includes\Template::C_STR_DASHBOARD, 'customize-hyperlink-arrow' );
|
||||
// Replace all placeholders.
|
||||
|
@ -1104,7 +1107,7 @@ class Settings extends Engine {
|
|||
* @since 2.2.2
|
||||
* @deprecated
|
||||
*/
|
||||
public function custom_css_migration() {
|
||||
public function custom_css_migration(): void {
|
||||
|
||||
// Options for Yes/No select box.
|
||||
$l_arr_enabled = array(
|
||||
|
@ -1140,7 +1143,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 2.2.2
|
||||
*/
|
||||
public function custom_css_new() {
|
||||
public function custom_css_new(): void {
|
||||
// Load template file.
|
||||
$l_obj_template = new Includes\Template( \footnotes\includes\Template::C_STR_DASHBOARD, 'customize-css-new' );
|
||||
// Replace all placeholders.
|
||||
|
@ -1170,7 +1173,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
public function lookup_hooks() {
|
||||
public function lookup_hooks(): void {
|
||||
// Load template file.
|
||||
$l_obj_template = new Includes\Template( \footnotes\includes\Template::C_STR_DASHBOARD, 'expert-lookup' );
|
||||
|
||||
|
@ -1225,9 +1228,11 @@ class Settings extends Engine {
|
|||
* Displays a short introduction to the plugin.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Review in light of admin/public split.
|
||||
*/
|
||||
public function Help() {
|
||||
global $footnotes;
|
||||
public function help(): void {
|
||||
$footnotes = new General\General($this->plugin_name, "foo");
|
||||
|
||||
// Load footnotes starting and end tag.
|
||||
$l_arr_footnote_starting_tag = $this->load_setting( \footnotes\includes\Settings::C_STR_FOOTNOTES_SHORT_CODE_START );
|
||||
$l_arr_footnote_ending_tag = $this->load_setting( \footnotes\includes\Settings::C_STR_FOOTNOTES_SHORT_CODE_END );
|
||||
|
@ -1290,7 +1295,7 @@ class Settings extends Engine {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function donate() {
|
||||
public function donate(): void {
|
||||
// Load template file.
|
||||
$l_obj_template = new Includes\Template( \footnotes\includes\Template::C_STR_DASHBOARD, 'how-to-donate' );
|
||||
// Replace all placeholders.
|
||||
|
|
|
@ -1123,7 +1123,7 @@ class Settings {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
private $a_arr_container = array(
|
||||
private array $a_arr_container = array(
|
||||
'footnotes_storage',
|
||||
'footnotes_storage_custom',
|
||||
'footnotes_storage_expert',
|
||||
|
@ -1136,10 +1136,11 @@ class Settings {
|
|||
* @since 1.5.0
|
||||
* @todo Review. Why are the constants just initialised with these values?
|
||||
* At the very least, we should stop using ‘yes’ to mean `true` etc.
|
||||
* @todo Create `PreferencesSet` class.
|
||||
*
|
||||
* @var (string|int)[]
|
||||
*/
|
||||
private $a_arr_default = array(
|
||||
private array $a_arr_default = array(
|
||||
|
||||
// General settings.
|
||||
'footnotes_storage' => array(
|
||||
|
@ -1327,8 +1328,9 @@ class Settings {
|
|||
* @var (string|int)[]
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Create `PreferencesSet` class.
|
||||
*/
|
||||
private $a_arr_settings = array();
|
||||
private array $a_arr_settings = array();
|
||||
|
||||
/**
|
||||
* Loads all Settings from each WordPress Settings Container.
|
||||
|
@ -1347,7 +1349,7 @@ class Settings {
|
|||
* @since 1.5.0
|
||||
* @todo Remove?
|
||||
*/
|
||||
public static function instance() {
|
||||
public static function instance(): self {
|
||||
// No instance defined yet, load it.
|
||||
if ( ! self::$a_obj_instance ) {
|
||||
self::$a_obj_instance = new self();
|
||||
|
@ -1360,11 +1362,11 @@ class Settings {
|
|||
* Returns the name of a specified Settings Container.
|
||||
*
|
||||
* @param int $p_int_index Settings Container index.
|
||||
* @return str Settings Container name.
|
||||
* @return string Settings Container name.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function get_container( $p_int_index ) {
|
||||
public function get_container( int $p_int_index ): string {
|
||||
return $this->a_arr_container[ $p_int_index ];
|
||||
}
|
||||
|
||||
|
@ -1376,7 +1378,7 @@ class Settings {
|
|||
*
|
||||
* @since 1.5.6
|
||||
*/
|
||||
public function get_defaults( $p_int_index ) {
|
||||
public function get_defaults( int $p_int_index ): array {
|
||||
return $this->a_arr_default[ $this->a_arr_container[ $p_int_index ] ];
|
||||
}
|
||||
|
||||
|
@ -1385,7 +1387,7 @@ class Settings {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
private function load_all() {
|
||||
private function load_all(): void {
|
||||
// Clear current settings.
|
||||
$this->a_arr_settings = array();
|
||||
$num_settings = count( $this->a_arr_container );
|
||||
|
@ -1403,7 +1405,7 @@ class Settings {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
private function load( $p_int_index ) {
|
||||
private function load( int $p_int_index ): array {
|
||||
// Load all settings from container.
|
||||
$l_arr_options = get_option( $this->get_container( $p_int_index ) );
|
||||
// Load all default settings.
|
||||
|
@ -1434,7 +1436,7 @@ class Settings {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function save_options( $p_int_index, $p_arr_new_values ) {
|
||||
public function save_options( int $p_int_index, array $p_arr_new_values ): bool {
|
||||
if ( update_option( $this->get_container( $p_int_index ), $p_arr_new_values ) ) {
|
||||
$this->load_all();
|
||||
return true;
|
||||
|
@ -1449,8 +1451,9 @@ class Settings {
|
|||
* @return string|int|null Setting value, or `null` if setting key is invalid.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Add return type.
|
||||
*/
|
||||
public function get( $p_str_key ) {
|
||||
public function get( string $p_str_key ) {
|
||||
return $this->a_arr_settings[ $p_str_key ] ?? null;
|
||||
}
|
||||
|
||||
|
@ -1461,7 +1464,7 @@ class Settings {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function register_settings() {
|
||||
public function register_settings(): void {
|
||||
// Register all settings.
|
||||
$num_settings = count( $this->a_arr_container );
|
||||
for ( $i = 0; $i < $num_settings; $i++ ) {
|
||||
|
|
|
@ -204,11 +204,25 @@ class General {
|
|||
array(),
|
||||
( PRODUCTION_ENV ) ? $this->version : filemtime(
|
||||
plugin_dir_path(
|
||||
dirname( __FILE__ )
|
||||
__FILE__
|
||||
) . "css/footnotes-{$l_str_tooltip_mode_short}brpl{$l_str_layout_mode}.min.css"
|
||||
),
|
||||
'all'
|
||||
);
|
||||
} else {
|
||||
foreach (array('amp-tooltips', 'common', 'layout-entry-content', 'layout-main-content', 'layout-reference-container', 'tooltips', 'tooltips-alternative') as $val) {
|
||||
wp_enqueue_style(
|
||||
"footnotes-$val",
|
||||
plugin_dir_url( __FILE__ ) . "css/dev-$val.css",
|
||||
array(),
|
||||
filemtime(
|
||||
plugin_dir_path(
|
||||
__FILE__
|
||||
) . "css/dev-$val.css"
|
||||
),
|
||||
'all'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue