Skip to content

Commit 8750db6

Browse files
committed
Omit able player if defined class is set.
See #13
1 parent 23aea22 commit 8750db6

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

src/assets/css/admin.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@
158158
padding: 10px;
159159
}
160160

161+
.ableplayer-tabs .label-number,
162+
.ableplayer-tabs .label-select,
163+
.ableplayer-tabs .label-text {
164+
display: block;
165+
}
166+
167+
.ableplayer-input-description {
168+
display: inline-flex;
169+
align-items: center;
170+
border-left: 4px solid #72aee6;
171+
box-shadow: 0 3px 6px #ddd;
172+
padding: 4px;
173+
}
174+
161175
@media screen and ( width < 481px ) {
162176
.ableplayer-tabs.vertical {
163177
display: flex;

src/assets/js/media.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ if ( 0 !== ableplayer_selectors.length ) {
99
const mediaEls = document.querySelectorAll( ableplayer_selectors );
1010
if ( mediaEls ) {
1111
mediaEls.forEach((el,index,listObj) => {
12-
el.removeAttribute( 'controls' );
13-
if ( ! el.hasAttribute( 'data-able-player' ) ) {
14-
el.setAttribute( 'data-able-player', 'true' );
15-
}
16-
if ( ! el.hasAttribute( 'id' ) ) {
17-
el.setAttribute( 'id', 'able-player-id-' + index );
12+
let excludeClass = ableplayer.settings.exclude_class;
13+
if ( excludeClass !== '' && el.classList.contains( excludeClass ) || el.closest( 'figure' ).classList.contains( excludeClass ) ) {
14+
el.classList.add( 'ableplayer-skipped' );
15+
} else {
16+
el.removeAttribute( 'controls' );
17+
18+
if ( ! el.hasAttribute( 'data-able-player' ) ) {
19+
el.setAttribute( 'data-able-player', 'true' );
20+
}
21+
if ( ! el.hasAttribute( 'id' ) ) {
22+
el.setAttribute( 'id', 'able-player-id-' + index );
23+
}
1824
}
1925
});
2026
}

src/inc/settings.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ function ableplayer_update_settings( $post ) {
249249
$settings = array();
250250
$replace_video = ( ! empty( $post['replace_video'] ) && 'on' === $post['replace_video'] ) ? 'true' : 'false';
251251
$replace_audio = ( ! empty( $post['replace_audio'] ) && 'on' === $post['replace_audio'] ) ? 'true' : 'false';
252+
$exclude_class = ( ! empty( $post['exclude_class'] ) ) ? sanitize_text_field( $post['exclude_class'] ) : '';
252253
$replace_playlists = ( ! empty( $post['replace_playlists'] ) && 'on' === $post['replace_playlists'] ) ? 'true' : 'false';
253254
$youtube_nocookie = ( ! empty( $post['youtube_nocookie'] ) && 'on' === $post['youtube_nocookie'] ) ? 'true' : 'false';
254255
$play_inline = ( ! empty( $post['play_inline'] ) && 'on' === $post['play_inline'] ) ? 'true' : 'false';
@@ -260,6 +261,7 @@ function ableplayer_update_settings( $post ) {
260261

261262
$settings['replace_video'] = $replace_video;
262263
$settings['replace_audio'] = $replace_audio;
264+
$settings['exclude_class'] = $exclude_class;
263265
$settings['replace_playlists'] = $replace_playlists;
264266
$settings['youtube_nocookie'] = $youtube_nocookie;
265267
$settings['seek_interval'] = $seek_interval;
@@ -333,6 +335,18 @@ function ableplayer_settings_form() {
333335
</p>
334336
<p>
335337
<?php
338+
ableplayer_settings_field(
339+
array(
340+
'name' => 'exclude_class',
341+
'label' => __( 'Exclude class from Able Player parsing', 'ableplayer' ),
342+
'note' => __( 'Disable Able Player on <code>video</code> or <code>audio</code> elements with this class or with a parent element with the class.', 'ableplayer' ),
343+
'type' => 'text',
344+
)
345+
);
346+
?>
347+
</p>
348+
<p>
349+
<?php
336350
ableplayer_settings_field(
337351
array(
338352
'name' => 'replace_playlists',
@@ -556,6 +570,7 @@ function ableplayer_default_settings() {
556570
$settings = array(
557571
'replace_video' => 'false',
558572
'replace_audio' => 'false',
573+
'exclude_class' => '',
559574
'replace_playlists' => 'false',
560575
'youtube_nocookie' => 'false',
561576
'play_inline' => 'true',

0 commit comments

Comments
 (0)