Sync plugins from current page
Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
		
							
								
								
									
										113
									
								
								wp-content/plugins/wp-youtube-lyte/lyte_helper.php_example
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								wp-content/plugins/wp-youtube-lyte/lyte_helper.php_example
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,113 @@ | ||||
| <?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; | ||||
| 	} | ||||
| ?> | ||||
		Reference in New Issue
	
	Block a user