-
Notifications
You must be signed in to change notification settings - Fork 10
/
lyte_helper.php_example
117 lines (102 loc) · 4.15 KB
/
lyte_helper.php_example
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/*
Plugin Name: Lyte Helper
Plugin URI: http://blog.futtta.be/category/wp-youtube-lyte/
Description: Lyte Helper contains some helper functions to make WP YouTube Lyte even more flexible
Author: Frank Goossens (futtta)
Version: 0.2
Author URI: http://blog.futtta.be/
*/
/**
available filter hooks: lyte_settings, lyte_content_preparse, lyte_match_preparse_fragment, lyte_match_postparse_template, lyte_content_postparse, lyte_css, lyte_docaptions, lyte_match_thumburl
available action hooks; lyte_actionsfilters
*/
/** force widget text to be parsed as well using lyte_actionsfilters action */
// add_action('lyte_actionsfilters','lyte_force_widgets',10,0);
function lyte_force_widgets() {
add_filter('widget_text', 'lyte_parse', 4);
}
/** force wp youtube lyte to act on normal youtube url's as well using lyte_content_preparse filter */
// add_filter('lyte_content_preparse','lyte_force_nonhttpv',10,1);
function lyte_force_nonhttpv($content) {
$content=preg_replace('/^https?:\/\/(www.)?youtu(be.com|.be)\/(watch\?v=)?/m','httpv://www.youtube.com/watch?v=',$content);
return $content;
}
/** force hqThumb for all lytes using lyte_match_preparse_fragment */
// add_filter('lyte_match_preparse_fragment','lyte_force_hqthumb',10,1);
function lyte_force_hqthumb($httpv) {
if (strpos($httpv,"hqThumb")===FALSE) {
if (strpos($httpv,"#")===FALSE) {
$httpv.="#hqThumb=1";
} else {
$httpv.="&hqThumb=1";
}
}
return $httpv;
}
/** force showinfo=0 for all lytes using lyte_match_preparse_fragment filter */
// add_filter('lyte_match_preparse_fragment','lyte_force_noinfo',10,1);
function lyte_force_noinfo($httpv) {
if (strpos($httpv,"showinfo")===FALSE) {
if (strpos($httpv,"#")===FALSE) {
$httpv.="#showinfo=0";
} else {
$httpv.="&showinfo=0";
}
}
return $httpv;
}
/** add clickable video thumbnail to excerpt.*/
// add_filter('lyte_match_postparse_template','lyte_override_excerpt_template',10,2);
function lyte_override_excerpt_template($content,$type) {
global $lyteSettings, $vid, $postID;
if ($type==="excerpt") {
$content = "<a href=\"".get_permalink( $postID )."\"><img src=\"".$lyteSettings['scheme']."://i.ytimg.com/vi/".$vid."/0.jpg\" alt=\"YouTube Video\"></a>";
}
return $content;
}
/** change setting from within code using lyte_settings filter */
// add_filter('lyte_settings','lyte_change_settings',10,1);
function lyte_change_settings($settingsArray) {
$settingsArray['links']="0";
return $settingsArray;
}
/** disable captions lookup */
// add_filter('lyte_docaptions','lyte_nocaptions',10,0);
function lyte_nocaptions() {
return false;
}
/** force lyte javascript (which includes css) to be loaded in head instead of footer */
// lyte_force_jshead();
function lyte_force_jshead() {
add_filter('wp_head', lyte_init);
global $lynited;
$lynited=true;
}
/** function to filter out httpv/a links from description tag as generated by all in one seo pack */
// add_filter('aioseop_description','lyte_filter_aioseop_description');
function lyte_filter_aioseop_description($description) {
return preg_replace('/\shttp(v|a):\/\/([^\s<]*)/','',$description);
}
/** function to override thumbnail used for a video */
// add_filter('lyte_match_thumburl','lyte_my_own_thumburl');
function lyte_my_own_thumburl($thumb) {
return "http://images.vrt.be/mobile320/2014/08/05/8570f3aa-1c9e-11e4-b923-00163edf75b7.jpg";
}
/** change lyte css, for example to load Robota fond and force bottom control visible */
// add_filter('lyte_css','fgo_lyte_change_css',10,1);
function fgo_lyte_change_css($lyte_css) {
// import robota
$lyte_css="@import url(https://fonts.googleapis.com/css?family=Roboto&subset=latin,latin-ext);".$lyte_css;
// show bottom control
$lyte_css.=" .ctrl{display:block !important;}";
return $lyte_css;
}
/** don't do lyte on mobile to avoid users having to press play twice */
// add_filter('lyte_do_mobile','no_lyte_on_mobile',10,0);
function no_lyte_on_mobile(){
return false;
}
/** activate internal lazy loader if you don't have another one configured on your site; the default for this filter is false */
//add_filter('lyte_use_internal_lazyloader','__return_true');
?>