Make WordPress Core

Ticket #15800: network-tab-tester-15800.php

File network-tab-tester-15800.php, 1.5 KB (added by Bueltge, 12 years ago)

Tab tester, readable simple source

Line 
1<?php
2/**
3 * Plugin Name: Network Tab Patch Test Case
4 * Plugin URI: https://core.trac.wordpress.org/ticket/15800
5 * Description: Test use case for the patch to allow extension of network site tabs
6 */
7
8if ( ! is_network_admin() ) {
9 return NULL;
10}
11
12add_action( 'network_admin_menu', 'ticket15800_network_site_tabs' );
13function ticket15800_network_site_tabs() {
14
15 add_filter( 'network_edit_site_tabs', 'ticket15800_filter_network_site_tabs', 10, 3 );
16
17 if ( isset( $_GET[ 'page' ] ) && 'test_tab' === $_GET[ 'page' ] ) {
18 global $_registered_pages;
19 // Set true, that you have the rights to see the content
20 $_registered_pages[ 'admin_page_test_tab' ] = TRUE;
21
22 add_action( 'admin_page_test_tab', 'ticket15800_callback' );
23 }
24}
25
26/**
27 * Add new tab
28 *
29 * @param $tabs
30 * @param $id
31 * @param $pagenow
32 *
33 * @return mixed
34 */
35function ticket15800_filter_network_site_tabs( $tabs, $id, $pagenow ) {
36
37 $tabs[ 'test15800-tab' ] = array(
38 'label' => __( 'Test', 'textdomain' ),
39 'menu-slug' => 'test_tab',
40 'callback-function' => 'ticket15800_callback',
41 );
42
43 return $tabs;
44}
45
46/**
47 * Get the new site settings page
48 *
49 * @return void
50 */
51function ticket15800_callback() {
52
53 if ( isset( $_REQUEST[ 'id' ] ) ) {
54 $id = intval( $_REQUEST[ 'id' ] );
55 } else {
56 $id = 0;
57 }
58
59 ?>
60 <div class="wrap">
61 <h2>Test for Ticket 15800</h2>
62
63 <h3 class="nav-tab-wrapper">
64 <?php network_edit_site_tabs( $id ); ?>
65 </h3>
66
67 <p>Content ...</p>
68 </div>
69<?php
70}