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 | * Author: Chris Olbekson <chris@x-team.com> |
---|
7 | * Version: 1.0 |
---|
8 | * Author URI: http://x-team.com |
---|
9 | */ |
---|
10 | |
---|
11 | if ( ! is_network_admin() ) |
---|
12 | exit; |
---|
13 | |
---|
14 | function network_site_tabs_test() { |
---|
15 | global $_registered_pages; |
---|
16 | add_filter( 'network_edit_site_tabs', 'filter_network_tabs', 10, 3 ); |
---|
17 | $hookname = get_plugin_page_hookname( 'wp_test_tab', '' ); |
---|
18 | $_registered_pages[$hookname] = true; |
---|
19 | if ( isset( $_GET['page'] ) && $_GET['page'] == 'wp_test_tab' ) |
---|
20 | add_action( $hookname, 'test_tab_callback' ); |
---|
21 | |
---|
22 | } |
---|
23 | add_action( 'network_admin_menu', 'network_site_tabs_test' ); |
---|
24 | |
---|
25 | function filter_network_tabs( $tabs, $id, $pagenow ) { |
---|
26 | $tabs['test-tab'] = array( 'label' => __( 'Test Tab' ), 'menu-slug' => 'wp_test_tab', 'callback-function' => 'test_tab_callback' ); |
---|
27 | |
---|
28 | return $tabs; |
---|
29 | } |
---|
30 | |
---|
31 | function test_tab_callback() { |
---|
32 | $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
---|
33 | $site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) ); |
---|
34 | $title_site_url_linked = sprintf( __( 'Edit Site: <a href="%1$s">%2$s</a>' ), get_blogaddress_by_id( $id ), $site_url_no_http ); |
---|
35 | ?> |
---|
36 | <div class="wrap"> |
---|
37 | <h2 id="edit-site"><?php echo $title_site_url_linked ?></h2> |
---|
38 | <h3 class="nav-tab-wrapper"> |
---|
39 | <?php if ( function_exists( 'network_edit_site_tabs' ) ) |
---|
40 | network_edit_site_tabs( $id ); |
---|
41 | ?> |
---|
42 | </h3> |
---|
43 | </div> |
---|
44 | <?php |
---|
45 | } |
---|
46 | |
---|