Skip to content

Commit

Permalink
Add a filter so the list of tabs can be extended.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbillion committed Jan 12, 2025
1 parent f80b500 commit 25ea333
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1009,23 +1009,25 @@ function action_handle_posts() {
* @return void
*/
function action_admin_menu() {
$schedules = add_options_page(
$tabs = [];

Check failure on line 1012 in src/bootstrap.php

View workflow job for this annotation

GitHub Actions / PHP / 8.3

Short array syntax is not allowed
$tabs[] = add_options_page(
esc_html__( 'Cron Schedules', 'wp-crontrol' ),
esc_html__( 'Cron Schedules', 'wp-crontrol' ),
'manage_options',
'wp-crontrol-schedules',
__NAMESPACE__ . '\admin_options_page'
);
$events = add_management_page(
$tabs[] = add_management_page(
esc_html__( 'Cron Events', 'wp-crontrol' ),
esc_html__( 'Cron Events', 'wp-crontrol' ),
'manage_options',
'wp-crontrol',
__NAMESPACE__ . '\admin_manage_page'
);

add_action( "load-{$schedules}", __NAMESPACE__ . '\admin_help_tab' );
add_action( "load-{$events}", __NAMESPACE__ . '\admin_help_tab' );
foreach ( $tabs as $tab ) {
add_action( "load-{$tab}", __NAMESPACE__ . '\admin_help_tab' );
}
}

/**
Expand Down Expand Up @@ -2149,21 +2151,25 @@ function do_tabs() {
),
);

$links = apply_filters( 'crontrol/links', $links );

?>
<div id="crontrol-header">
<nav class="nav-tab-wrapper">
<?php
foreach ( $links as $id => $link ) {
if ( ! empty( $tabs[ $id ] ) ) {
printf(
'<a href="%s" class="nav-tab nav-tab-active">%s</a>',
'<a href="%1$s" class="nav-tab nav-tab-active" id="crontrol_tab_%2$s">%3$s</a>',
esc_url( $link[0] ),
esc_attr( $id ),
esc_html( $link[1] )
);
} else {
printf(
'<a href="%s" class="nav-tab">%s</a>',
'<a href="%1$s" class="nav-tab" id="crontrol_tab_%2$s">%3$s</a>',
esc_url( $link[0] ),
esc_attr( $id ),
esc_html( $link[1] )
);
}
Expand Down

0 comments on commit 25ea333

Please sign in to comment.