Skip to content

Commit 2cd9ba1

Browse files
committed
deploy: 5440d57
1 parent e138df2 commit 2cd9ba1

File tree

5 files changed

+69
-9
lines changed

5 files changed

+69
-9
lines changed

able_player_css.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ <h5>Parameters:</h5>
157157

158158
<dt class="tag-source">Source:</dt>
159159
<dd class="tag-source"><ul class="dummy"><li>
160-
<a href="ableplayer.php.html">ableplayer.php</a>, <a href="ableplayer.php.html#line80">line 80</a>
160+
<a href="ableplayer.php.html">ableplayer.php</a>, <a href="ableplayer.php.html#line81">line 81</a>
161161
</li></ul></dd>
162162

163163

able_player_js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ <h5>Parameters:</h5>
157157

158158
<dt class="tag-source">Source:</dt>
159159
<dd class="tag-source"><ul class="dummy"><li>
160-
<a href="ableplayer.php.html">ableplayer.php</a>, <a href="ableplayer.php.html#line69">line 69</a>
160+
<a href="ableplayer.php.html">ableplayer.php</a>, <a href="ableplayer.php.html#line70">line 70</a>
161161
</li></ul></dd>
162162

163163

ableplayer.php.html

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
define( 'ABLEPLAYER_VERSION', '1.2.2' );
5252

5353
require_once plugin_dir_path( __FILE__ ) . 'inc/settings.php';
54+
require_once plugin_dir_path( __FILE__ ) . 'inc/generator.php';
5455
require_once plugin_dir_path( __FILE__ ) . 'inc/kses.php';
5556

5657
register_activation_hook( __FILE__, 'ableplayer_activation' );
@@ -138,14 +139,26 @@
138139
function ableplayer_admin_scripts() {
139140
$version = ABLEPLAYER_VERSION;
140141
$version = ( SCRIPT_DEBUG ) ? $version . '-' . wp_rand( 1000, 9999 ) : $version;
141-
wp_enqueue_script( 'ableplayer-js', plugins_url( '/assets/js/admin.js', __FILE__ ), array( 'jquery' ), $version, true );
142+
wp_enqueue_script( 'ableplayer-js', plugins_url( '/assets/js/admin.js', __FILE__ ), array( 'jquery', 'wp-a11y', 'clipboard' ), $version, true );
142143
wp_localize_script(
143144
'ableplayer-js',
144145
'ableplayer',
145146
array(
146-
'firstItem' => 'tab_settings',
147+
'posterTitle' => 'Select Poster Image',
148+
'sourceTitle' => 'Select Video',
149+
'captionsTitle' => 'Select Captions',
150+
'subtitlesTitle' => 'Select Subtitles',
151+
'descriptionTitle' => 'Select Description',
152+
'chaptersTitle' => 'Select Chapters',
153+
'buttonName' => 'Choose Media',
154+
'thumbHeight' => '100',
155+
'removed' => __( 'Selected media removed', 'ableplayer' ),
156+
'homeUrl' => home_url(),
147157
)
148158
);
159+
if ( function_exists( 'wp_enqueue_media' ) &amp;&amp; ! did_action( 'wp_enqueue_media' ) ) {
160+
wp_enqueue_media();
161+
}
149162
wp_enqueue_style( 'ableplayer', plugins_url( '/assets/css/admin.css', __FILE__ ), array(), $version );
150163
}
151164
add_action( 'admin_enqueue_scripts', 'ableplayer_admin_scripts' );
@@ -410,6 +423,11 @@
410423
'youtube-nocookie' => '',
411424
'vimeo-id' => '',
412425
'vimeo-desc-id' => '',
426+
'media-id' => '',
427+
'captions' => '',
428+
'subtitles' => '',
429+
'descriptions' => '',
430+
'chapters' => '',
413431
'autoplay' => 'false',
414432
'preload' => 'metadata',
415433
'loop' => 'false',
@@ -430,11 +448,48 @@
430448
'ableplayer'
431449
);
432450

433-
// output.
434-
if ( ! ( $all_atts['youtube-id'] || $all_atts['vimeo-id'] ) ) {
435-
// required fields are missing.
451+
if ( ! ( $all_atts['youtube-id'] || $all_atts['vimeo-id'] || $all_atts['media-id'] ) ) {
452+
// Shortcode must have one of YouTube, Vimeo, or local video source.
436453
return false;
437454
} else {
455+
if ( $all_atts['media-id'] ) {
456+
// If Video ID is set but is not a valid URL,
457+
$media_id = ( is_numeric($all_atts['media-id'] ) ) ? wp_get_attachment_url( $all_atts['media-id'] ) : $all_atts['media-id'];
458+
if ( ! $media_id ) {
459+
return false;
460+
} else {
461+
$type = get_post_mime_type( $media_id );
462+
$source = '&lt;source type="' . esc_attr( $type ) . '" src="' . esc_url( $media_id ) . '">';
463+
}
464+
}
465+
466+
$tracks = array();
467+
$kinds = array(
468+
'captions' => __( 'Captions', 'ableplayer' ),
469+
'subtitles' => __( 'Subtitles', 'ableplayer' ),
470+
'description' => __( 'Description', 'ableplayer' ),
471+
'chapters' => __( 'Chapters', 'ableplayer' ),
472+
);
473+
// Switch locale to BCP47 syntax.
474+
$default_lang = str_replace( '_', '-', get_locale() );
475+
if ( $all_atts['captions'] || $all_atts['subtitles'] || $all_atts['description'] || $all_atts['chapters'] ) {
476+
foreach ( $kinds as $kind => $default_label ) {
477+
$track = '';
478+
if ( ! empty( $all_atts[ $kind ] ) ) {
479+
$data = explode( '|', $all_atts[ $kind ] );
480+
if ( empty( $data[0] ) ) {
481+
continue;
482+
}
483+
// Optional lang and language.
484+
$srclang = ( isset( $data[1] ) &amp;&amp; ! empty( $data[1] ) ) ? $data[1] : $default_lang;
485+
$srclabel = ( isset( $data[2] ) &amp;&amp; ! empty( $data[2] ) ) ? $data[2] : $default_label;
486+
$src = ( is_numeric( $data[0] ) ) ? wp_get_attachment_url( $data[0] ) : $data[0];
487+
$track = '&lt;track kind="' . $kind . '" srclang="' . esc_attr( $srclang ) . '" srclabel="' . esc_attr( $srclabel ) . '" src="' . esc_url( $src ) . '">';
488+
$tracks[] = $track;
489+
}
490+
}
491+
}
492+
438493
// build a video player.
439494
$o = '&lt;video ';
440495
$o .= ' id="' . esc_attr( $all_atts['id'] ) . '"';
@@ -502,6 +557,11 @@
502557
}
503558
$o .= '>';
504559

560+
$o .= $source;
561+
562+
if ( ! empty( $tracks ) ) {
563+
$o .= implode( PHP_EOL, $tracks );
564+
}
505565
// enclosing tags.
506566
if ( ! is_null( $content ) ) {
507567
// run shortcode parser recursively.

ableplayer_dependencies.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ <h5>Parameters:</h5>
157157

158158
<dt class="tag-source">Source:</dt>
159159
<dd class="tag-source"><ul class="dummy"><li>
160-
<a href="ableplayer.php.html">ableplayer.php</a>, <a href="ableplayer.php.html#line93">line 93</a>
160+
<a href="ableplayer.php.html">ableplayer.php</a>, <a href="ableplayer.php.html#line94">line 94</a>
161161
</li></ul></dd>
162162

163163

ableplayer_parameters.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ <h5>Parameters:</h5>
136136

137137
<dt class="tag-source">Source:</dt>
138138
<dd class="tag-source"><ul class="dummy"><li>
139-
<a href="ableplayer.php.html">ableplayer.php</a>, <a href="ableplayer.php.html#line335">line 335</a>
139+
<a href="ableplayer.php.html">ableplayer.php</a>, <a href="ableplayer.php.html#line348">line 348</a>
140140
</li></ul></dd>
141141

142142

0 commit comments

Comments
 (0)