PluginProbe ʕ •ᴥ•ʔ
Admin Help Docs / 2.0.0
Admin Help Docs v2.0.0
2.0.1.1 trunk 1.4.3.2 2.0.0 2.0.0.1 2.0.0.2 2.0.1
admin-help-docs / inc / header.php
admin-help-docs / inc Last commit date
css 3 months ago docs 3 months ago img 3 months ago js 3 months ago tabs 3 months ago api.php 3 months ago cleanup.php 3 months ago colors.php 3 months ago deprecated.php 3 months ago header.php 3 months ago helpers.php 3 months ago index.php 3 months ago menu.php 3 months ago plugins-page.php 3 months ago post-type-help-doc-imports.php 3 months ago post-type-help-docs.php 3 months ago shortcodes.php 3 months ago taxonomy-folders.php 3 months ago
header.php
95 lines
1 <?php
2 namespace PluginRx\AdminHelpDocs;
3
4 if ( ! defined( 'ABSPATH' ) ) exit;
5
6 // Logo
7 $logo_url = sanitize_url( get_option( 'helpdocs_logo', '' ) );
8 if ( ! $logo_url ) {
9 $logo_url = Bootstrap::url( 'inc/img/logo.png' );
10 }
11
12 // Version
13 $version = esc_html__( 'Version', 'admin-help-docs' ) . ' ' . esc_attr( Bootstrap::version() );
14
15 // Get the active tab
16 global $current_screen;
17 $real_tab = Menu::get_current_tab();
18
19 if ( ! $real_tab ) {
20 if ( isset( $current_screen->id ) && $current_screen->id == 'edit-' . Folders::$taxonomy ) {
21 $real_tab = 'folders';
22 } elseif ( isset( $current_screen->post_type ) && $current_screen->post_type == HelpDocs::$post_type ) {
23 $real_tab = 'manage';
24 } elseif ( isset( $current_screen->post_type ) && $current_screen->post_type == Imports::$post_type ) {
25 $real_tab = 'imports';
26 } else {
27 $real_tab = 'documentation';
28 }
29 }
30
31 // Highlight 'imports' when on the hidden 'import' editor
32 $active_menu_key = ( $real_tab === 'import' ) ? 'imports' : $real_tab;
33
34 $tabs = Menu::tabs();
35 $current_data = $tabs[ $real_tab ] ?? [];
36 $user_can_view = Helpers::user_can_view();
37 $user_can_edit = Helpers::user_can_edit();
38 ?>
39 <div id="helpdocs-header">
40 <img src="<?php echo esc_url( $logo_url ); ?>" alt="<?php echo esc_attr( Bootstrap::name() ); ?> Logo" title="<?php echo esc_html( $version ); ?>" class="logo">
41
42 <div class="title-cont">
43 <h1 title="<?php echo esc_html( $version ); ?>"><?php echo esc_attr( Helpers::page_title() ); ?></h1>
44 </div>
45
46 <div class="tabs-wrapper">
47 <?php foreach ( $tabs as $key => $tab ) {
48 // Skip if no access
49 if ( ( $key == 'documentation' && ! $user_can_view ) || ( $key != 'documentation' && ! $user_can_edit ) || ( $key === 'support' && ! get_option( 'helpdocs_contact_form' ) ) ) {
50 continue;
51 }
52
53 // Skip if hidden subpage
54 if ( isset( $tab[ 'hidden' ] ) && $tab[ 'hidden' ] == true ) {
55 continue;
56 }
57
58 // The link
59 if ( isset( $tab[ 'link' ] ) && $tab[ 'link' ] != '' ) {
60 $link = $tab[ 'link' ];
61 } else {
62 $link = Bootstrap::tab_url( $key );
63 }
64 ?>
65 <a href="<?php echo esc_url( $link ); ?>" class="helpdocs-tab <?php if ( $active_menu_key === $key ) : ?>helpdocs-tab-active<?php endif; ?>"><?php echo esc_html( $tab[ 'label' ] ?? 'Unknown' ); ?></a>
66 <?php } ?>
67 </div>
68 </div>
69 <div id="helpdocs-subheader">
70 <div class="subheader-left">
71 <h2 class="tab-title"><?php echo esc_html( $current_data[ 'title' ] ?? $current_data[ 'label' ] ?? 'Unknown Tab' ); ?></h2>
72 <?php if ( Helpers::user_can_edit() && isset( $current_data[ 'buttons' ] ) ) { ?>
73 <?php foreach ( $current_data[ 'buttons' ] as $button ) { ?>
74 <?php if ( isset( $button[ 'form' ] ) ) : ?>
75 <?php $disabled = isset( $button[ 'disabled' ] ) && $button[ 'disabled' ] ? 'disabled' : ''; ?>
76 <button id="header_btn_<?php echo esc_attr( $button[ 'id' ] ?? '' ); ?>" type="submit" form="<?php echo esc_attr( $button[ 'form' ] ); ?>" class="tab-button helpdocs-button" <?php echo isset( $button[ 'target' ] ) ? 'target="' . esc_attr( $button[ 'target' ] ) . '"' : ''; ?> <?php echo esc_attr( $disabled ); ?>>
77 <?php echo wp_kses_post( $button[ 'text' ] ?? __( 'Button', 'admin-help-docs' ) ); ?>
78 </button>
79 <?php else : ?>
80 <a href="<?php echo esc_url( $button[ 'link' ] ); ?>" class="tab-button helpdocs-button" <?php echo isset( $button[ 'target' ] ) ? 'target="' . esc_attr( $button[ 'target' ] ) . '"' : ''; ?>><?php echo wp_kses_post( $button[ 'text' ] ?? __( 'Button', 'admin-help-docs' ) ); ?></a>
81 <?php endif; ?>
82 <?php } ?>
83 <?php } ?>
84 <?php do_action( 'helpdocs_subheader_left', $real_tab ); ?>
85 </div>
86 <div class="subheader-right">
87 <?php do_action( 'helpdocs_subheader_right', $real_tab ); ?>
88 </div>
89 </div>
90
91 <?php if ( isset( $_GET[ 'settings-updated' ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>
92 <div id="message" class="updated">
93 <p><strong><?php esc_html_e( 'Settings saved.', 'admin-help-docs' ) ?></strong></p>
94 </div>
95 <?php } ?>