forked from jhackett1/smoke-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.php
56 lines (49 loc) · 1.53 KB
/
player.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/*
Plugin Name: Smoke Radio Player
Plugin URI: https://github.com/jhackett1/smoke-player
Description: The pop-out live player for Smoke Radio, with show metadata information. Automatically adds a link to the Radio main menu.
Version: 1.0.0
Author: Joshua Hackett
Author URI: http://joshuahackett.com
*/
// Flush URL rewrites on activation
// function player_rewrite_flush() {
// player_add_rewrite_rules();
// flush_rewrite_rules();
// }
// register_activation_hook( __FILE__, 'player_rewrite_flush' );
// Recognise /player in the URL
function player_add_rewrite_rules() {
add_rewrite_rule('player','/index.php?player','top');
}
add_action('init', 'player_add_rewrite_rules');
// Wordpress recognises the 'player' var
function player_query_vars($vars) {
$vars[] = 'player';
return $vars;
}
add_filter('query_vars', 'player_query_vars');
// Assign player template template if the var is found
function player_template_include( &$wp ) {
if (array_key_exists('player', $wp->query_vars)) {
include 'player-template.php';
exit();
}
return;
}
add_filter('parse_request', 'player_template_include');
// Now add a link to the right menu
add_filter('wp_nav_menu_items', 'player_menu_link', 10, 2);
function player_menu_link( $items, $args ) {
if ($args->theme_location == 'main_radio') {
$items .= <<<EOD
<li class="radio"><a href="javascript: void(0)"
onclick="window.open('/player',
'windowname1',
'width=350, height=600');
return false;">Listen live</a></li>
EOD;
}
return $items;
}