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