-
Notifications
You must be signed in to change notification settings - Fork 1
/
wpbase-youtube.php
83 lines (58 loc) · 2.06 KB
/
wpbase-youtube.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/* Plugin Name: WPBase Youtube Site Plugin
Plugin URI: http://wpoven.com/
Description: Uses Youtube GData api to create a site, Has vidfetch integration for video conversion.
Version: 1.0
Author: Bakers
Author URI: http://wpoven.com/
License: GPLv2 or later
*/
if(is_admin()) {
include('wpbase-youtube-admin.php');
}
include( 'includes/common.php' );
include ('wpbase-widget.php');
include ('wpbase-youtube-init.php');
include ('wpbase-youtube-main.php');
function wpbyURLHandler(&$wp) {
// override videos and video and redirect to same page
global $yPath;
$request = $_SERVER['REQUEST_URI'];
if (strstr($request, '/videos/') || strstr($request, '/video/')) {
$parts = explode('/videos/', $request);
if (count($parts) > 1) {
$wp->query_vars = array('page'=>'','pagename'=>'videos');
$yPath = explode('/', "list/" . $parts[1]);
}
$parts = explode('/video/', $request);
if (count($parts) > 1) {
$wp->query_vars = array('page'=>'','pagename'=>'videos');
$yPath = explode('/', "view/" . $parts[1]);
}
if(empty($yPath[1])) {
$yPath[0] = 'home';
}
}
}
// All the hooks
register_uninstall_hook(__FILE__,'wpbyUninstall');
register_activation_hook(__FILE__, 'wpbyActivation');
register_deactivation_hook(__FILE__, 'wpbyDeactivation');
// Shortcodes
add_shortcode('wpbase-youtube', 'wpbyContent');
// All filters
//add_filter('the_content', 'wpbyContent',19);
//add_filter('the_title', 'wpbyTitle',20);
add_filter('wp_title', 'wpbyPTitle',21,2);
// All Actions
if(is_admin()) {
add_action('admin_menu', 'wpbyOptionsMenu');
add_action( 'admin_init', 'wpbySettings' );
} else {
add_action('parse_request', 'wpbyURLHandler');
add_action('wp_enqueue_scripts', 'wpbyMedia',20);
add_action('wp', 'wpbyDispatcher');
}
add_action('widgets_init','wpbyWidget');
$plugin_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/' ;
load_plugin_textdomain( 'wpby', false, $plugin_dir );