Changeset 3408298
- Timestamp:
- 12/02/2025 05:07:36 PM (4 months ago)
- Location:
- mhm-lazyloadvideo/trunk
- Files:
-
- 2 edited
-
Plugin.php (modified) (8 diffs)
-
README.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
mhm-lazyloadvideo/trunk/Plugin.php
r1976698 r3408298 1 1 <?php 2 2 /* 3 Plugin Name: Lazy load video players 4 Plugin URI: https:// github.com/mhmli/mhm-lazyloadvideo3 Plugin Name: Lazy load video players (UNMAINTAINED) 4 Plugin URI: https://wordpress.org/plugins/mhm-lazyloadvideo/ 5 5 Description: Modifies the HTML output of any video players embedded in the content area using the oEmbed technique. Any video player which is included on the page will only be loaded if/when it is visible within the current browser window. Requires JavaScript. The original player will be displayed if JavaScript is inactive on the page. 6 6 Author: Mark Howells-Mead … … 24 24 public function dump($var, $die = false) 25 25 { 26 echo '<pre>' .print_r($var, 1).'</pre>';26 echo '<pre>' . print_r($var, 1) . '</pre>'; 27 27 if ($die) { 28 28 die(); … … 38 38 { 39 39 if (!function_exists('get_plugins')) { 40 require_once ABSPATH .'wp-admin/includes/plugin.php';40 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 41 41 } 42 $plugin_folder = get_plugins('/' .plugin_basename(dirname(__FILE__)));42 $plugin_folder = get_plugins('/' . plugin_basename(dirname(__FILE__))); 43 43 $plugin_file = basename((__FILE__)); 44 44 … … 53 53 public function lazyloader() 54 54 { 55 $scriptpath = plugins_url('Resources/Public/JavaScript/mhmlazyloadvideo.js?v' .$this->version, __FILE__);55 $scriptpath = plugins_url('Resources/Public/JavaScript/mhmlazyloadvideo.js?v' . $this->version, __FILE__); 56 56 57 echo '<script>(function(i,s,o,g,r,a,m){i["mhmlazyloadvideo_script"]=r;i[r]=i[r]||function(){' .58 '(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),' .59 'm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)' .60 '})(window,document,"script","' .$scriptpath.'","mhmlazyloadvideo");</script>';57 echo '<script>(function(i,s,o,g,r,a,m){i["mhmlazyloadvideo_script"]=r;i[r]=i[r]||function(){' . 58 '(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),' . 59 'm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)' . 60 '})(window,document,"script","' . $scriptpath . '","mhmlazyloadvideo");</script>'; 61 61 } 62 62 … … 70 70 public function initLazyLoad($playerID) 71 71 { 72 return '<script data-plugin="mhm_lazyloadvideo">mhmlazyloadvideo("' .$playerID.'");</script>';72 return '<script data-plugin="mhm_lazyloadvideo">mhmlazyloadvideo("' . $playerID . '");</script>'; 73 73 } 74 74 … … 84 84 public function lazyLoadVideo($html, $url) 85 85 { 86 $html_was = '<noscript>' .$html.'</noscript>';86 $html_was = '<noscript>' . $html . '</noscript>'; 87 87 88 88 $host = parse_url($url, PHP_URL_HOST); … … 91 91 case 'www.vimeo.com': 92 92 $uniqueID = uniqid(); 93 $html = str_replace(' src="', ' data-mhmlazyloadvideo="' .$uniqueID.'" data-src="', $html).$this->initLazyLoad($uniqueID).$html_was;93 $html = str_replace(' src="', ' data-mhmlazyloadvideo="' . $uniqueID . '" data-src="', $html) . $this->initLazyLoad($uniqueID) . $html_was; 94 94 break; 95 95 … … 98 98 case 'youtu.be': 99 99 $uniqueID = uniqid(); 100 $html = str_replace(' src="', ' data-mhmlazyloadvideo="' .$uniqueID.'" data-src="', $html).$this->initLazyLoad($uniqueID).$html_was;100 $html = str_replace(' src="', ' data-mhmlazyloadvideo="' . $uniqueID . '" data-src="', $html) . $this->initLazyLoad($uniqueID) . $html_was; 101 101 break; 102 102 } -
mhm-lazyloadvideo/trunk/README.txt
r1976697 r3408298 10 10 11 11 == Description == 12 13 ** This plugin is no longer maintained. ** 12 14 13 15 Modifies the HTML output of any video players which have been embedded in the content area or in the site using the oEmbed technique. Any video player which is included on the page will only be loaded if/when it is/becomes visible within the current browser window.
Note: See TracChangeset
for help on using the changeset viewer.