PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.11.1
WpStream – Live Streaming, Video on Demand, Pay Per View v4.11.1
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
wpstream / includes / class-wpstream-templates.php

class-wpstream-templates.php in WpStream – Live Streaming, Video on Demand, Pay Per View 4.11.1, at includes/class-wpstream-templates.php

98 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Template loader for the WpStream plugin
5 *
6 * @package wpstream-plugin
7 */
8
9 class WpStream_Template_Loader {
10 public function __construct() {
11 add_filter( 'theme_page_templates', array( $this, 'wpstream_add_page_templates' ), 100 ); // Higher priority
12 add_filter( 'template_include', array( $this, 'include_templates' ) );
13 add_action( 'wp_enqueue_scripts', array( $this, 'maybe_enqueue_dashboard_scripts' ) );
14 }
15
16 public function wpstream_add_page_templates( $templates ) {
17 if ( get_template() === 'hello-wpstream' ) {
18 // Add the Dashboard template
19 $templates['wpstream-theme-dashboard.php'] = __('WpStream Dashboard Page', 'wpstream');
20 }
21
22 return $templates;
23 }
24
25 public function include_templates( $template ) {
26 if ( is_page() && get_template() === 'hello-wpstream' ) {
27 $page_template = get_page_template_slug();
28
29 if ( 'wpstream-theme-dashboard.php' === $page_template ) {
30 $file = WPSTREAM_PLUGIN_PATH . 'hello-wpstream/page-templates/wpstream-theme-dashboard.php';
31
32 if ( file_exists( $file ) ) {
33 return $file;
34 }
35 }
36 }
37
38 // Single templates for custom post types
39 if ( get_template() === 'hello-wpstream' ) {
40 $single_template_path = WPSTREAM_PLUGIN_PATH . 'hello-wpstream/single-templates/';
41
42 if ( is_singular( 'wpstream_product' ) ) {
43 $template_file = $single_template_path . 'single-wpstream_product.php';
44 if ( file_exists( $template_file ) ) {
45 $template = $template_file;
46 }
47 }
48
49 if ( is_singular( 'wpstream_product_vod' ) ) {
50 $template_file = $single_template_path . 'single-wpstream_product_vod.php';
51 if ( file_exists( $template_file ) ) {
52 $template = $template_file;
53 }
54 }
55
56 if ( is_singular( 'wpstream_bundles' ) ) {
57 $template_file = $single_template_path . 'single-wpstream_bundles.php';
58 if ( file_exists( $template_file ) ) {
59 $template = $template_file;
60 }
61 }
62 }
63
64 return $template;
65 }
66
67 public function maybe_enqueue_dashboard_scripts() {
68 if ( 'wpstream-theme-dashboard.php' === get_page_template_slug() && get_template() === 'hello-wpstream' ) {
69 $modified_theme_js = gmdate( 'YmdHi', filemtime( WPSTREAM_PLUGIN_PATH . 'hello-wpstream/js/theme-dashboard.js' ) );
70 wp_enqueue_script( 'jquery-ui-sortable' );
71
72 wp_enqueue_script( 'wpstream_theme-dashboard-js', WPSTREAM_PLUGIN_DIR_URL . 'hello-wpstream/js/theme-dashboard.js', array( 'jquery' ), $modified_theme_js, true );
73 wp_localize_script(
74 'wpstream_theme-dashboard-js',
75 'wpstreamDashboardVars',
76 array(
77 'admin_url' => get_admin_url(),
78 'saving' => esc_html__( 'Updating your details....', 'hello-wpstream' ),
79 'saved' => esc_html__( 'The changes were saved', 'hello-wpstream' ),
80 'notsaved' => esc_html__( 'Something did not not work. Please try again.', 'hello-wpstream' ),
81 'createchannel' => esc_html__( 'We are creating the channel. The page will refresh after this is done.', 'hello-wpstream' ),
82 )
83 );
84
85 $modificated_ajax_upload_js = gmdate( 'YmdHi', filemtime( WPSTREAM_PLUGIN_PATH . 'hello-wpstream/js/ajax-upload.js' ) );
86 wp_enqueue_script(
87 'ajax-upload',
88 WPSTREAM_PLUGIN_DIR_URL . 'hello-wpstream/js/ajax-upload.js',
89 array(
90 'jquery',
91 'plupload-handlers',
92 ),
93 $modificated_ajax_upload_js,
94 true
95 );
96 }
97 }
98 }