PluginProbe
FV Player 8 / trunk
FV Player 8 vtrunk
trunk 8.0.18 8.0.19 8.0.20 8.0.21 8.0.25 8.0.27 8.1 8.1.3
fv-player / models / tutor-lms.class.php

tutor-lms.class.php in FV Player 8 trunk, at models/tutor-lms.class.php

82 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class FV_Player_Tutor_LMS {
8
9 function __construct() {
10 add_action( 'plugins_loaded', array( $this, 'loader' ), 11 );
11
12 add_action( 'tutor_after_course_builder_load', array( $this, 'load_editor' ) );
13
14 add_filter( 'tutor_preferred_video_sources', array( $this, 'preferred_video_sources' ) );
15
16 add_action( 'tutor_after_course_builder_load', array( $this, 'load_editor' ) );
17 }
18
19 /**
20 * We put the "Shortcode" option at the top of the video type select box.
21 *
22 * That keeps our integration JavaScript simpler as it does not have to change the React-based video source selector.
23 *
24 * Simply removing the video types which we do not like would break the editing of the existing lessons if they use them.
25 */
26 function preferred_video_sources( $video_sources ) {
27 $shortcode = array(
28 'shortcode' => $video_sources['shortcode']
29 );
30
31 unset( $video_sources['shortcode'] );
32
33 $video_sources = array_merge( $shortcode, $video_sources );
34
35 return $video_sources;
36 }
37
38 function load_editor() {
39 wp_enqueue_script(
40 'fv-player-tutor-lms-editor',
41 plugins_url( 'js/fv-player-tutor-lms-editor.js', dirname(__FILE__) ),
42 array( 'tutor-course-builder' ),
43 filemtime( plugin_dir_path( __FILE__ ) . '../js/fv-player-tutor-lms-editor.js' ),
44 true
45 );
46
47 fv_wp_flowplayer_edit_form_after_editor();
48 fv_player_shortcode_editor_scripts_enqueue();
49 }
50
51 function loader() {
52 // Capture the shortcode output and setup capture for the end of the shortcode
53 add_action( 'tutor_lesson/single/before/video/shortcode', array( $this, 'shortcode_before' ), 0 );
54 }
55
56 public function shortcode_before() {
57 ob_start();
58
59 // Capture the end of the shortcode output and remove the classes
60 add_action( 'tutor_lesson/single/after/video/shortcode', array( $this, 'shortcode_after' ), 1000 );
61 }
62
63 public function shortcode_after() {
64
65 $html = ob_get_clean();
66
67 /**
68 * We remove the classes tutor-ratio tutor-ratio-16x9 as they force their children elements to be 16:9.
69 * That way FV Player with playlist items does not appear properly.
70 */
71 if ( stripos( $html, 'freedomplayer' ) !== false ) {
72 $html = str_replace( '<div class="tutor-ratio tutor-ratio-16x9">', '<div class="fv-player-tutor-lms" data-original-class="tutor-ratio tutor-ratio-16x9">', $html );
73 }
74
75 // Output the modified HTML
76 echo $html;
77 }
78
79 }
80
81 new FV_Player_Tutor_LMS;
82