use tab instead of different settings pages
This commit is contained in:
parent
62c99c87a3
commit
2a8cd2a54f
3 changed files with 24 additions and 26 deletions
|
@ -1,4 +1,4 @@
|
||||||
.settings_page_activitypub-settings .notice-info {
|
.settings_page_activitypub .notice {
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,7 @@
|
||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings_page_activitypub #wpcontent,
|
.settings_page_activitypub #wpcontent {
|
||||||
.settings_page_activitypub-settings #wpcontent {
|
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,25 +21,15 @@ class Admin {
|
||||||
* Add admin menu entry
|
* Add admin menu entry
|
||||||
*/
|
*/
|
||||||
public static function admin_menu() {
|
public static function admin_menu() {
|
||||||
$settings_page = \add_submenu_page(
|
$settings_page = \add_options_page(
|
||||||
null,
|
|
||||||
'ActivityPub Settings',
|
|
||||||
'ActivityPub',
|
|
||||||
'manage_options',
|
|
||||||
'activitypub-settings',
|
|
||||||
array( '\Activitypub\Admin', 'settings_page' )
|
|
||||||
);
|
|
||||||
|
|
||||||
$welcome_page = \add_options_page(
|
|
||||||
'Welcome',
|
'Welcome',
|
||||||
'ActivityPub',
|
'ActivityPub',
|
||||||
'manage_options',
|
'manage_options',
|
||||||
'activitypub',
|
'activitypub',
|
||||||
array( '\Activitypub\Admin', 'welcome_page' )
|
array( '\Activitypub\Admin', 'settings_page' )
|
||||||
);
|
);
|
||||||
|
|
||||||
\add_action( 'load-' . $settings_page, array( '\Activitypub\Admin', 'add_settings_help_tab' ) );
|
\add_action( 'load-' . $settings_page, array( '\Activitypub\Admin', 'add_settings_help_tab' ) );
|
||||||
\add_action( 'load-' . $welcome_page, array( '\Activitypub\Admin', 'add_settings_help_tab' ) );
|
|
||||||
|
|
||||||
$followers_list_page = \add_users_page( \__( 'Followers', 'activitypub' ), \__( 'Followers (Fediverse)', 'activitypub' ), 'read', 'activitypub-followers-list', array( '\Activitypub\Admin', 'followers_list_page' ) );
|
$followers_list_page = \add_users_page( \__( 'Followers', 'activitypub' ), \__( 'Followers (Fediverse)', 'activitypub' ), 'read', 'activitypub-followers-list', array( '\Activitypub\Admin', 'followers_list_page' ) );
|
||||||
|
|
||||||
|
@ -50,18 +40,27 @@ class Admin {
|
||||||
* Load settings page
|
* Load settings page
|
||||||
*/
|
*/
|
||||||
public static function settings_page() {
|
public static function settings_page() {
|
||||||
\load_template( \dirname( __FILE__ ) . '/../templates/settings.php' );
|
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
}
|
if ( empty( $_GET['tab'] ) ) {
|
||||||
|
$tab = 'welcome';
|
||||||
|
} else {
|
||||||
|
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||||
|
$tab = sanitize_key( $_GET['tab'] );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
switch ( $tab ) {
|
||||||
* Load welcome page
|
case 'settings':
|
||||||
*/
|
\load_template( \dirname( __FILE__ ) . '/../templates/settings.php' );
|
||||||
public static function welcome_page() {
|
break;
|
||||||
wp_enqueue_script( 'plugin-install' );
|
case 'welcome':
|
||||||
add_thickbox();
|
default:
|
||||||
wp_enqueue_script( 'updates' );
|
wp_enqueue_script( 'plugin-install' );
|
||||||
|
add_thickbox();
|
||||||
|
wp_enqueue_script( 'updates' );
|
||||||
|
|
||||||
\load_template( \dirname( __FILE__ ) . '/../templates/welcome.php' );
|
\load_template( \dirname( __FILE__ ) . '/../templates/welcome.php' );
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<?php \esc_html_e( 'Welcome', 'activitypub' ); ?>
|
<?php \esc_html_e( 'Welcome', 'activitypub' ); ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="<?php echo \esc_url_raw( admin_url( 'options-general.php?page=activitypub-settings' ) ); ?>" class="activitypub-settings-tab <?php echo \esc_attr( $args['settings'] ); ?>">
|
<a href="<?php echo \esc_url_raw( admin_url( 'options-general.php?page=activitypub&tab=settings' ) ); ?>" class="activitypub-settings-tab <?php echo \esc_attr( $args['settings'] ); ?>">
|
||||||
<?php \esc_html_e( 'Settings', 'activitypub' ); ?>
|
<?php \esc_html_e( 'Settings', 'activitypub' ); ?>
|
||||||
</a>
|
</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
Loading…
Reference in a new issue