| Server IP : 167.179.152.94 / Your IP : 216.73.216.169 Web Server : Apache/2.4.66 (Debian) System : Linux 6d8cbb3dc321 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64 User : ( 1000) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/plugins/html5-audio-player/inc/Base/ |
Upload File : |
<?php
namespace H5APPlayer\Base;
class Loader
{
public function register()
{
add_action('wp_head', [$this, 'loadAssets']);
}
public function loadAssets()
{
?>
<script>
function h5vpLoader({
id,
source,
type
}) {
const element = document.getElementById(id);
if (!element && !window.srcLoaded) {
if (type === 'script') {
const script = document.createElement('script');
script.src = `<?php echo esc_url(H5AP_PRO_PLUGIN_DIR) ?>${source}`;
script.id = id;
document.getElementsByTagName("head")[0].appendChild(script);
}
if (type === 'css') {
const link = document.createElement('link');
link.href = `<?php echo esc_url(H5AP_PRO_PLUGIN_DIR) ?>${source}`;
link.rel = 'stylesheet';
document.getElementsByTagName("head")[0].appendChild(link);
}
}
}
function loadHVPAssets() {
const assets = [{
id: 'h5ap-public-css',
source: 'assets/css/style.css',
type: 'css'
},
{
id: 'bplugins-plyrio-css',
source: 'assets/css/player.min.css',
type: 'css'
},
{
id: 'bplugins-plyrio-js',
source: 'assets/js/plyr-v3.7.2.js',
type: 'script'
},
{
id: 'h5ap-player-js',
source: 'dist/player.js',
type: 'script'
},
];
if (typeof hpublic === 'undefined') {
const script = document.createElement('script');
script.innerText = `var hpublic = {siteUrl: '<?php echo esc_url(site_url()) ?>', userId: <?php echo esc_html(get_current_user_id()) ?>}`;
document.getElementsByTagName("head")[0].appendChild(script);
}
assets.map(item => h5vpLoader(item));
}
document.addEventListener('DOMContentLoaded', function() {
const isPlayer = document.querySelector(".h5ap_player");
if (isPlayer) {
loadHVPAssets();
}
})
</script>
<?php
}
}