| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
class FV_Player_LMS_Teaching { |
| 8 |
private $is_enabled = false; |
| 9 |
|
| 10 |
function __construct() { |
| 11 |
add_action( 'plugins_loaded', array( $this, 'loader' ), 11 ); |
| 12 |
} |
| 13 |
|
| 14 |
function loader() { |
| 15 |
add_filter( 'fv_player_item', array( $this, 'check_meta' ), 11, 3 ); |
| 16 |
add_filter( 'fv_flowplayer_attributes', array( $this, 'edit_attributes' ), 11, 3 ); |
| 17 |
} |
| 18 |
|
| 19 |
function check_meta( $aItem, $index, $aArgs ) { |
| 20 |
global $fv_fp; |
| 21 |
|
| 22 |
// shortcode args |
| 23 |
if( isset( $aArgs['lms_teaching '] ) ) { |
| 24 |
if( $aArgs['lms_teaching '] == 'yes' || $aArgs['lms_teaching '] == 'true' ) { |
| 25 |
$this->is_enabled = true; |
| 26 |
} else { |
| 27 |
$this->is_enabled = false; |
| 28 |
} |
| 29 |
} else { |
| 30 |
|
| 31 |
$meta_setting = 'default'; // setting for specific player |
| 32 |
if ($fv_fp->current_player() && count($fv_fp->current_player()->getMetaData())) { |
| 33 |
foreach ($fv_fp->current_player()->getMetaData() as $meta_object) { |
| 34 |
if( strcmp( $meta_object->getMetaKey(), 'lms_teaching' ) == 0 ) { |
| 35 |
$meta_setting = $meta_object->getMetaValue(); |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
if( $meta_setting == 'true' ) { |
| 41 |
$this->is_enabled = true; |
| 42 |
} else { |
| 43 |
$this->is_enabled = false; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
return $aItem; |
| 48 |
} |
| 49 |
|
| 50 |
function edit_attributes( $attributes, $media, $fv_fp ) { |
| 51 |
if( $this->is_enabled && is_user_logged_in() ) { |
| 52 |
$attributes['data-lms_teaching'] = true; |
| 53 |
|
| 54 |
// if( strpos( $attributes['class'], 'no-controlbar' ) == false ) { |
| 55 |
// $attributes['class'] .= ' no-controlbar'; |
| 56 |
// } |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
return $attributes; |
| 61 |
} |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
new FV_Player_LMS_Teaching; |
| 66 |
|