Skip to main content

WordPress

To add the Lura Player to a WordPress website using a plugin, you can use the following steps:

1. Create a new directory in the wp-content/plugins folder of your WordPress installation and name it lura-player.

2. Create a new file in the lura-player directory and name it lura-player.php. This will be the main plugin file.

3. Open the lura-player.php file in a text editor and paste the following code:

<?php

/**
* Plugin Name: Lura Player
* Plugin URI: https://www.akta.tech
* Description: A plugin to add the Lura Player to WordPress pages and posts.
* Version: 1.0
* Author: Akta Tech
* Author URI: https://www.akta.tech
* License: EULA
*/

function lura_player_script()
{
wp_enqueue_script('lura-player-loader', 'https://w3.mp.lura.live/lura-player/web/latest/lura-player.js');
}
add_action('wp_enqueue_scripts', 'lura_player_script');

function lura_player_shortcode($atts)
{
$a = shortcode_atts(array(
'config' => '',
'width' => '640',
'height' => '360'
), $atts);

$randid = bin2hex(random_bytes(10));

$output = '
<div id="' . $randid . '" style="width: ' . $a['width'] . 'px; height: ' . $a['height'] . 'px"></div>
<script>
const luraPlayer = new lura.Player("' . $randid . '");
luraPlayer.setConfig(' . $a['config'] . ');
</script>';
return $output;
}
add_shortcode('lura_player', 'lura_player_shortcode');

4. Save the changes to the lura-player.php file. The plugin should now be installed in your WordPress site. To add the Lura Player to a page or post, you can use the following shortcode:

[lura_player config='{"lura":{"appKey":"PqSpQb9pFu1A_v4qrMnRNwcXJGoFMO0B02BwGBQ4Zwa0_uMdXPXrqjnlSbJbkv8duDNk2-c3JbOXq2auBscWP1GyvlWlgFcIzaO6QFG74nY","assetId":"5179686"}}']

Note that you need to replace the placeholder value for the "config" property with your own Lura Player config.

That's it! You should now see the Lura Player embedded in your WordPress website.