refactor: run Rector ORDER
setlist
This commit is contained in:
parent
667d8dada9
commit
114121a7e2
9 changed files with 542 additions and 568 deletions
|
@ -69,6 +69,121 @@ abstract class Engine {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
abstract public function get_priority(): int;
|
||||
/**
|
||||
* Registers a sub-page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function register_sub_page(): void {
|
||||
global $submenu;
|
||||
|
||||
if ( array_key_exists( plugin_basename( Init::MAIN_MENU_SLUG ), $submenu ) ) {
|
||||
foreach ( $submenu[ plugin_basename( Init::MAIN_MENU_SLUG ) ] as $sub_menu ) {
|
||||
if ( plugin_basename( Init::MAIN_MENU_SLUG . $this->get_sub_page_slug() ) === $sub_menu[2] ) {
|
||||
remove_submenu_page( Init::MAIN_MENU_SLUG, Init::MAIN_MENU_SLUG . $this->get_sub_page_slug() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->sub_page_hook = add_submenu_page(
|
||||
Init::MAIN_MENU_SLUG,
|
||||
$this->get_sub_page_title(),
|
||||
$this->get_sub_page_title(),
|
||||
'manage_options',
|
||||
Init::MAIN_MENU_SLUG . $this->get_sub_page_slug(),
|
||||
fn() => $this->display_content()
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Registers all sections for a sub-page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function register_sections(): void {
|
||||
foreach ( $this->get_sections() as $section ) {
|
||||
// Append tab to the tab-array.
|
||||
$this->sections[ $section['id'] ] = $section;
|
||||
add_settings_section(
|
||||
$section['id'],
|
||||
'',
|
||||
fn() => $this->description(),
|
||||
$section['id']
|
||||
);
|
||||
$this->register_meta_boxes( $section['id'] );
|
||||
}
|
||||
}
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
/**
|
||||
* Displays the content of specific sub-page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Review nonce verification.
|
||||
*/
|
||||
public function display_content(): void {
|
||||
$this->append_scripts();
|
||||
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->sections );
|
||||
$active_section = $this->sections[ $active_section_id ];
|
||||
|
||||
// Store settings.
|
||||
$settings_updated = false;
|
||||
if ( array_key_exists( 'save-settings', $_POST ) && 'save' === $_POST['save-settings'] ) {
|
||||
unset( $_POST['save-settings'] );
|
||||
unset( $_POST['submit'] );
|
||||
$settings_updated = $this->save_settings();
|
||||
}
|
||||
|
||||
// Display all sections and highlight the active section.
|
||||
echo '<div class="wrap">';
|
||||
echo '<h2 class="nav-tab-wrapper">';
|
||||
// Iterate through all register sections.
|
||||
foreach ( $this->sections as $id => $description ) {
|
||||
echo sprintf(
|
||||
'<a class="nav-tab%s" href="?page=%s&t=%s">%s</a>',
|
||||
( $id === $active_section['id'] ) ? ' nav-tab-active' : '',
|
||||
Init::MAIN_MENU_SLUG,
|
||||
$id,
|
||||
$description['title']
|
||||
);
|
||||
}
|
||||
echo '</h2><br/>';
|
||||
|
||||
if ( $settings_updated ) {
|
||||
echo sprintf( '<div id="message" class="updated">%s</div>', __( 'Settings saved', 'footnotes' ) );
|
||||
}
|
||||
|
||||
// Form to submit the active section.
|
||||
echo '<!--suppress HtmlUnknownTarget --><form method="post" action="">';
|
||||
echo '<input type="hidden" name="save-settings" value="save" />';
|
||||
// Outputs the settings field of the active section.
|
||||
do_settings_sections( $active_section['id'] );
|
||||
do_meta_boxes( $active_section['id'], 'main', null );
|
||||
|
||||
// Add submit button to active section if defined.
|
||||
if ( $active_section['submit'] ) {
|
||||
submit_button();
|
||||
}
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
// Echo JavaScript for the expand/collapse function of the meta boxes.
|
||||
echo '<script type="text/javascript">';
|
||||
echo 'jQuery(document).ready(function ($) {';
|
||||
echo 'jQuery(".footnotes-color-picker").wpColorPicker();';
|
||||
echo "jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');";
|
||||
echo "postboxes.add_postbox_toggles('" . $this->sub_page_hook . "');";
|
||||
echo '});';
|
||||
echo '</script>';
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
/**
|
||||
* Output the description of a section. May be overwritten in any section.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Required? Should be `abstract`?
|
||||
*/
|
||||
public function description(): void {
|
||||
// Default no description will be displayed.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique slug of the child sub-page.
|
||||
|
@ -170,186 +285,6 @@ abstract class Engine {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a sub-page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function register_sub_page(): void {
|
||||
global $submenu;
|
||||
|
||||
if ( array_key_exists( plugin_basename( Init::MAIN_MENU_SLUG ), $submenu ) ) {
|
||||
foreach ( $submenu[ plugin_basename( Init::MAIN_MENU_SLUG ) ] as $sub_menu ) {
|
||||
if ( plugin_basename( Init::MAIN_MENU_SLUG . $this->get_sub_page_slug() ) === $sub_menu[2] ) {
|
||||
remove_submenu_page( Init::MAIN_MENU_SLUG, Init::MAIN_MENU_SLUG . $this->get_sub_page_slug() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->sub_page_hook = add_submenu_page(
|
||||
Init::MAIN_MENU_SLUG,
|
||||
$this->get_sub_page_title(),
|
||||
$this->get_sub_page_title(),
|
||||
'manage_options',
|
||||
Init::MAIN_MENU_SLUG . $this->get_sub_page_slug(),
|
||||
fn() => $this->display_content()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all sections for a sub-page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function register_sections(): void {
|
||||
foreach ( $this->get_sections() as $section ) {
|
||||
// Append tab to the tab-array.
|
||||
$this->sections[ $section['id'] ] = $section;
|
||||
add_settings_section(
|
||||
$section['id'],
|
||||
'',
|
||||
fn() => $this->description(),
|
||||
$section['id']
|
||||
);
|
||||
$this->register_meta_boxes( $section['id'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all Meta boxes for a sub-page.
|
||||
*
|
||||
* @access private
|
||||
* @param string $parent_id Parent section unique ID.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
private function register_meta_boxes( string $parent_id ): void {
|
||||
// Iterate through each meta box.
|
||||
foreach ( $this->get_meta_boxes() as $meta_box ) {
|
||||
if ( $parent_id !== $meta_box['parent'] ) {
|
||||
continue;
|
||||
}
|
||||
add_meta_box(
|
||||
$parent_id . '-' . $meta_box['id'],
|
||||
$meta_box['title'],
|
||||
array( $this, $meta_box['callback'] ),
|
||||
$parent_id,
|
||||
'main'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Append JavaScript and CSS files for specific sub-page.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Move to {@see Includes\Admin}.
|
||||
*/
|
||||
private function append_scripts(): void {
|
||||
wp_enqueue_script( 'postbox' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
wp_enqueue_script( 'wp-color-picker' );
|
||||
}
|
||||
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
/**
|
||||
* Displays the content of specific sub-page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Review nonce verification.
|
||||
*/
|
||||
public function display_content(): void {
|
||||
$this->append_scripts();
|
||||
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->sections );
|
||||
$active_section = $this->sections[ $active_section_id ];
|
||||
|
||||
// Store settings.
|
||||
$settings_updated = false;
|
||||
if ( array_key_exists( 'save-settings', $_POST ) && 'save' === $_POST['save-settings'] ) {
|
||||
unset( $_POST['save-settings'] );
|
||||
unset( $_POST['submit'] );
|
||||
$settings_updated = $this->save_settings();
|
||||
}
|
||||
|
||||
// Display all sections and highlight the active section.
|
||||
echo '<div class="wrap">';
|
||||
echo '<h2 class="nav-tab-wrapper">';
|
||||
// Iterate through all register sections.
|
||||
foreach ( $this->sections as $id => $description ) {
|
||||
echo sprintf(
|
||||
'<a class="nav-tab%s" href="?page=%s&t=%s">%s</a>',
|
||||
( $id === $active_section['id'] ) ? ' nav-tab-active' : '',
|
||||
Init::MAIN_MENU_SLUG,
|
||||
$id,
|
||||
$description['title']
|
||||
);
|
||||
}
|
||||
echo '</h2><br/>';
|
||||
|
||||
if ( $settings_updated ) {
|
||||
echo sprintf( '<div id="message" class="updated">%s</div>', __( 'Settings saved', 'footnotes' ) );
|
||||
}
|
||||
|
||||
// Form to submit the active section.
|
||||
echo '<!--suppress HtmlUnknownTarget --><form method="post" action="">';
|
||||
echo '<input type="hidden" name="save-settings" value="save" />';
|
||||
// Outputs the settings field of the active section.
|
||||
do_settings_sections( $active_section['id'] );
|
||||
do_meta_boxes( $active_section['id'], 'main', null );
|
||||
|
||||
// Add submit button to active section if defined.
|
||||
if ( $active_section['submit'] ) {
|
||||
submit_button();
|
||||
}
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
// Echo JavaScript for the expand/collapse function of the meta boxes.
|
||||
echo '<script type="text/javascript">';
|
||||
echo 'jQuery(document).ready(function ($) {';
|
||||
echo 'jQuery(".footnotes-color-picker").wpColorPicker();';
|
||||
echo "jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');";
|
||||
echo "postboxes.add_postbox_toggles('" . $this->sub_page_hook . "');";
|
||||
echo '});';
|
||||
echo '</script>';
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
/**
|
||||
* Save all plugin settings.
|
||||
*
|
||||
* @access private
|
||||
* @return bool `true` on save success, else `false`.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Review nonce verification.
|
||||
*/
|
||||
private function save_settings(): bool {
|
||||
$new_settings = array();
|
||||
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->sections );
|
||||
$active_section = $this->sections[ $active_section_id ];
|
||||
|
||||
foreach ( array_keys( Includes\Settings::instance()->get_defaults( $active_section['container'] ) ) as $key ) {
|
||||
$new_settings[ $key ] = array_key_exists( $key, $_POST ) ? wp_unslash( $_POST[ $key ] ) : '';
|
||||
}
|
||||
// Update settings.
|
||||
return Includes\Settings::instance()->save_options( $active_section['container'], $new_settings );
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
|
||||
/**
|
||||
* Output the description of a section. May be overwritten in any section.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Required? Should be `abstract`?
|
||||
*/
|
||||
public function description(): void {
|
||||
// Default no description will be displayed.
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a specified setting.
|
||||
*
|
||||
|
@ -582,5 +517,63 @@ abstract class Engine {
|
|||
$max
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Registers all Meta boxes for a sub-page.
|
||||
*
|
||||
* @access private
|
||||
* @param string $parent_id Parent section unique ID.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
private function register_meta_boxes( string $parent_id ): void {
|
||||
// Iterate through each meta box.
|
||||
foreach ( $this->get_meta_boxes() as $meta_box ) {
|
||||
if ( $parent_id !== $meta_box['parent'] ) {
|
||||
continue;
|
||||
}
|
||||
add_meta_box(
|
||||
$parent_id . '-' . $meta_box['id'],
|
||||
$meta_box['title'],
|
||||
array( $this, $meta_box['callback'] ),
|
||||
$parent_id,
|
||||
'main'
|
||||
);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Append JavaScript and CSS files for specific sub-page.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Move to {@see Includes\Admin}.
|
||||
*/
|
||||
private function append_scripts(): void {
|
||||
wp_enqueue_script( 'postbox' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
wp_enqueue_script( 'wp-color-picker' );
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
/**
|
||||
* Save all plugin settings.
|
||||
*
|
||||
* @access private
|
||||
* @return bool `true` on save success, else `false`.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @todo Review nonce verification.
|
||||
*/
|
||||
private function save_settings(): bool {
|
||||
$new_settings = array();
|
||||
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->sections );
|
||||
$active_section = $this->sections[ $active_section_id ];
|
||||
|
||||
foreach ( array_keys( Includes\Settings::instance()->get_defaults( $active_section['container'] ) ) as $key ) {
|
||||
$new_settings[ $key ] = array_key_exists( $key, $_POST ) ? wp_unslash( $_POST[ $key ] ) : '';
|
||||
}
|
||||
// Update settings.
|
||||
return Includes\Settings::instance()->save_options( $active_section['container'], $new_settings );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -86,36 +86,6 @@ class Init {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the required dependencies for the layouts pages.
|
||||
*
|
||||
* Include the following files that make up the plugin:
|
||||
*
|
||||
* - {@see Includes\Config}: defines plugin constants;
|
||||
* - {@see Includes\Settings}: defines configurable plugin settings; and
|
||||
* - {@see Settings}: defines the plugin settings page.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
private function load_dependencies(): void {
|
||||
/**
|
||||
* Defines plugin constants.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__, 2 ) ) . 'includes/class-config.php';
|
||||
|
||||
/**
|
||||
* Defines configurable plugin settings.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__, 2 ) ) . 'includes/class-settings.php';
|
||||
|
||||
/**
|
||||
* Represents the plugin settings dashboard page.
|
||||
*/
|
||||
require_once plugin_dir_path( __DIR__ ) . 'layout/class-settings.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the settings and initialises the settings page.
|
||||
*
|
||||
|
@ -207,5 +177,34 @@ class Init {
|
|||
);
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Load the required dependencies for the layouts pages.
|
||||
*
|
||||
* Include the following files that make up the plugin:
|
||||
*
|
||||
* - {@see Includes\Config}: defines plugin constants;
|
||||
* - {@see Includes\Settings}: defines configurable plugin settings; and
|
||||
* - {@see Settings}: defines the plugin settings page.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
private function load_dependencies(): void {
|
||||
/**
|
||||
* Defines plugin constants.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__, 2 ) ) . 'includes/class-config.php';
|
||||
|
||||
/**
|
||||
* Defines configurable plugin settings.
|
||||
*/
|
||||
require_once plugin_dir_path( dirname( __FILE__, 2 ) ) . 'includes/class-settings.php';
|
||||
|
||||
/**
|
||||
* Represents the plugin settings dashboard page.
|
||||
*/
|
||||
require_once plugin_dir_path( __DIR__ ) . 'layout/class-settings.php';
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||
}
|
||||
|
|
|
@ -57,100 +57,6 @@ class Settings extends Engine {
|
|||
return 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique slug of the sub-page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @return string
|
||||
*/
|
||||
protected function get_sub_page_slug(): string {
|
||||
return '-' . $this->plugin_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title of the sub-page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @return string
|
||||
*/
|
||||
protected function get_sub_page_title(): string {
|
||||
return \footnotes\includes\Config::PLUGIN_PUBLIC_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all registered sections for the sub-page.
|
||||
*
|
||||
* @see Engine::add_section() For more information on the section array format.
|
||||
* @return array[] All of the registered sections.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 2.1.6 Remove conditional rendering of ‘Expert’ tab.
|
||||
*/
|
||||
protected function get_sections(): array {
|
||||
$tabs = array();
|
||||
|
||||
// Sync tab name with mirror in task.php.
|
||||
$tabs[] = $this->add_section( 'settings', __( 'General settings', 'footnotes' ), 0, true );
|
||||
|
||||
// Sync tab name with mirror in public function custom_css_migration().
|
||||
$tabs[] = $this->add_section( 'customize', __( 'Referrers and tooltips', 'footnotes' ), 1, true );
|
||||
|
||||
$tabs[] = $this->add_section( 'expert', __( 'Scope and priority', 'footnotes' ), 2, true );
|
||||
$tabs[] = $this->add_section( 'customcss', __( 'Custom CSS', 'footnotes' ), 3, true );
|
||||
$tabs[] = $this->add_section( 'how-to', __( 'Quick start guide', 'footnotes' ), 4, false );
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all registered meta boxes for each section of the sub-page.
|
||||
*
|
||||
* @see Engine::add_meta_box() For more information on the
|
||||
* meta box array format.
|
||||
* @return array[] All of the registered meta boxes.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 2.2.0 Re-order and rename tabs.
|
||||
*/
|
||||
protected function get_meta_boxes(): array {
|
||||
$meta_boxes = array();
|
||||
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'amp-compat', __( 'AMP compatibility', 'footnotes' ), 'amp_compat' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'start-end', __( 'Footnote start and end short codes', 'footnotes' ), 'start_end' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'numbering', __( 'Footnotes numbering', 'footnotes' ), 'numbering' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'scrolling', __( 'Scrolling behavior', 'footnotes' ), 'scrolling' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'hard-links', __( 'URL fragment ID configuration', 'footnotes' ), 'hard_links' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'reference-container', __( 'Reference container', 'footnotes' ), 'reference_container' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'excerpts', __( 'Footnotes in excerpts', 'footnotes' ), 'excerpts' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'love', \footnotes\includes\Config::PLUGIN_HEADING_NAME . ' ' . \footnotes\includes\Config::LOVE_SYMBOL_HEADING, 'love' );
|
||||
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'hyperlink-arrow', __( 'Backlink symbol', 'footnotes' ), 'hyperlink_arrow' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'superscript', __( 'Referrers', 'footnotes' ), 'superscript' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'label-solution', __( 'Referrers in labels', 'footnotes' ), 'label_solution' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box', __( 'Tooltips', 'footnotes' ), 'mouseover_box' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-position', __( 'Tooltip position', 'footnotes' ), 'mouseover_box_position' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-dimensions', __( 'Tooltip dimensions', 'footnotes' ), 'mouseover_box_dimensions' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-timing', __( 'Tooltip timing', 'footnotes' ), 'mouseover_box_timing' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-truncation', __( 'Tooltip truncation', 'footnotes' ), 'mouseover_box_truncation' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-text', __( 'Tooltip text', 'footnotes' ), 'mouseover_box_text' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-appearance', __( 'Tooltip appearance', 'footnotes' ), 'mouseover_box_appearance' );
|
||||
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'custom-css', __( 'Your existing Custom CSS code', 'footnotes' ), 'custom_css' );
|
||||
}
|
||||
|
||||
$meta_boxes[] = $this->add_meta_box( 'expert', 'lookup', __( 'WordPress hooks with priority level', 'footnotes' ), 'lookup_hooks' );
|
||||
|
||||
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
|
||||
$meta_boxes[] = $this->add_meta_box( 'customcss', 'custom-css-migration', __( 'Your existing Custom CSS code', 'footnotes' ), 'custom_css_migration' );
|
||||
}
|
||||
$meta_boxes[] = $this->add_meta_box( 'customcss', 'custom-css-new', __( 'Custom CSS', 'footnotes' ), 'custom_css_new' );
|
||||
|
||||
$meta_boxes[] = $this->add_meta_box( 'how-to', 'help', __( 'Brief introduction: How to use the plugin', 'footnotes' ), 'help' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'how-to', 'donate', __( 'Help us to improve our Plugin', 'footnotes' ), 'donate' );
|
||||
|
||||
return $meta_boxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the AMP compatibility mode option.
|
||||
*
|
||||
|
@ -1309,4 +1215,94 @@ class Settings extends Engine {
|
|||
echo $template->get_content();
|
||||
// phpcs:enable
|
||||
}
|
||||
/**
|
||||
* Returns the unique slug of the sub-page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @return string
|
||||
*/
|
||||
protected function get_sub_page_slug(): string {
|
||||
return '-' . $this->plugin_name;
|
||||
}
|
||||
/**
|
||||
* Returns the title of the sub-page.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @return string
|
||||
*/
|
||||
protected function get_sub_page_title(): string {
|
||||
return \footnotes\includes\Config::PLUGIN_PUBLIC_NAME;
|
||||
}
|
||||
/**
|
||||
* Returns an array of all registered sections for the sub-page.
|
||||
*
|
||||
* @see Engine::add_section() For more information on the section array format.
|
||||
* @return array[] All of the registered sections.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 2.1.6 Remove conditional rendering of ‘Expert’ tab.
|
||||
*/
|
||||
protected function get_sections(): array {
|
||||
$tabs = array();
|
||||
|
||||
// Sync tab name with mirror in task.php.
|
||||
$tabs[] = $this->add_section( 'settings', __( 'General settings', 'footnotes' ), 0, true );
|
||||
|
||||
// Sync tab name with mirror in public function custom_css_migration().
|
||||
$tabs[] = $this->add_section( 'customize', __( 'Referrers and tooltips', 'footnotes' ), 1, true );
|
||||
|
||||
$tabs[] = $this->add_section( 'expert', __( 'Scope and priority', 'footnotes' ), 2, true );
|
||||
$tabs[] = $this->add_section( 'customcss', __( 'Custom CSS', 'footnotes' ), 3, true );
|
||||
$tabs[] = $this->add_section( 'how-to', __( 'Quick start guide', 'footnotes' ), 4, false );
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
/**
|
||||
* Returns an array of all registered meta boxes for each section of the sub-page.
|
||||
*
|
||||
* @see Engine::add_meta_box() For more information on the
|
||||
* meta box array format.
|
||||
* @return array[] All of the registered meta boxes.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 2.2.0 Re-order and rename tabs.
|
||||
*/
|
||||
protected function get_meta_boxes(): array {
|
||||
$meta_boxes = array();
|
||||
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'amp-compat', __( 'AMP compatibility', 'footnotes' ), 'amp_compat' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'start-end', __( 'Footnote start and end short codes', 'footnotes' ), 'start_end' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'numbering', __( 'Footnotes numbering', 'footnotes' ), 'numbering' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'scrolling', __( 'Scrolling behavior', 'footnotes' ), 'scrolling' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'hard-links', __( 'URL fragment ID configuration', 'footnotes' ), 'hard_links' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'reference-container', __( 'Reference container', 'footnotes' ), 'reference_container' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'excerpts', __( 'Footnotes in excerpts', 'footnotes' ), 'excerpts' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'settings', 'love', \footnotes\includes\Config::PLUGIN_HEADING_NAME . ' ' . \footnotes\includes\Config::LOVE_SYMBOL_HEADING, 'love' );
|
||||
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'hyperlink-arrow', __( 'Backlink symbol', 'footnotes' ), 'hyperlink_arrow' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'superscript', __( 'Referrers', 'footnotes' ), 'superscript' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'label-solution', __( 'Referrers in labels', 'footnotes' ), 'label_solution' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box', __( 'Tooltips', 'footnotes' ), 'mouseover_box' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-position', __( 'Tooltip position', 'footnotes' ), 'mouseover_box_position' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-dimensions', __( 'Tooltip dimensions', 'footnotes' ), 'mouseover_box_dimensions' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-timing', __( 'Tooltip timing', 'footnotes' ), 'mouseover_box_timing' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-truncation', __( 'Tooltip truncation', 'footnotes' ), 'mouseover_box_truncation' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-text', __( 'Tooltip text', 'footnotes' ), 'mouseover_box_text' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-appearance', __( 'Tooltip appearance', 'footnotes' ), 'mouseover_box_appearance' );
|
||||
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
|
||||
$meta_boxes[] = $this->add_meta_box( 'customize', 'custom-css', __( 'Your existing Custom CSS code', 'footnotes' ), 'custom_css' );
|
||||
}
|
||||
|
||||
$meta_boxes[] = $this->add_meta_box( 'expert', 'lookup', __( 'WordPress hooks with priority level', 'footnotes' ), 'lookup_hooks' );
|
||||
|
||||
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
|
||||
$meta_boxes[] = $this->add_meta_box( 'customcss', 'custom-css-migration', __( 'Your existing Custom CSS code', 'footnotes' ), 'custom_css_migration' );
|
||||
}
|
||||
$meta_boxes[] = $this->add_meta_box( 'customcss', 'custom-css-new', __( 'Custom CSS', 'footnotes' ), 'custom_css_new' );
|
||||
|
||||
$meta_boxes[] = $this->add_meta_box( 'how-to', 'help', __( 'Brief introduction: How to use the plugin', 'footnotes' ), 'help' );
|
||||
$meta_boxes[] = $this->add_meta_box( 'how-to', 'donate', __( 'Help us to improve our Plugin', 'footnotes' ), 'donate' );
|
||||
|
||||
return $meta_boxes;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue