-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudioigniter.php
1422 lines (1207 loc) · 48.2 KB
/
audioigniter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Plugin Name: AudioIgniter
* Plugin URI: https://www.cssigniter.com/plugins/audioigniter/
* Description: AudioIgniter lets you create music playlists and embed them in your WordPress posts, pages or custom post types and serve your audio content in style!
* Author: The CSSIgniter Team
* Author URI: https://www.cssigniter.com
* Version: 2.0.1
* Text Domain: audioigniter
* Domain Path: languages
*
* AudioIgniter is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* AudioIgniter Downloads is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AudioIgniter. If not, see <http://www.gnu.org/licenses/>.
*
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class AudioIgniter {
/**
* AudioIgniter version.
*
* @var string
* @since 1.0.0
* @since 1.7.0 Changed from static to non-static.
*/
public $version = null;
/**
* Instance of this class.
*
* @var AudioIgniter
* @since 1.0.0
*/
protected static $instance = null;
/**
* Sanitizer instance.
*
* @var AudioIgniter_Sanitizer
* @since 1.0.0
*/
public $sanitizer = null;
/**
* The URL directory path (with trailing slash) of the main plugin file.
*
* @var string
* @since 1.0.0
*/
protected static $plugin_url = '';
/**
* The filesystem directory path (with trailing slash) of the main plugin file.
*
* @var string
* @since 1.0.0
*/
protected static $plugin_path = '';
/**
* Playlist post type name.
*
* @var string
* @since 1.0.0
*/
public $post_type = 'ai_playlist';
/**
* AudioIgniter Instance.
*
* Instantiates or reuses an instance of AudioIgniter.
*
* @since 1.0.0
* @static
* @see AudioIgniter()
* @return AudioIgniter - Single instance.
*/
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* AudioIgniter constructor. Intentionally left empty so that instances can be created without
* re-loading of resources (e.g. scripts/styles), or re-registering hooks.
* http://wordpress.stackexchange.com/questions/70055/best-way-to-initiate-a-class-in-a-wp-plugin
* https://gist.github.com/toscho/3804204
*
* @since 1.0.0
*/
public function __construct() {}
/**
* Kickstarts plugin loading.
*
* @since 1.0.0
*/
public function plugin_setup() {
if ( is_null( $this->version ) ) {
if ( ! function_exists( 'get_plugin_data' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugin_data = get_plugin_data( __FILE__, true, false );
$this->version = $plugin_data['Version'];
}
self::$plugin_url = plugin_dir_url( __FILE__ );
self::$plugin_path = plugin_dir_path( __FILE__ );
add_action( 'init', function() {
load_plugin_textdomain( 'audioigniter', false, dirname( self::plugin_basename() ) . '/languages' );
} );
require_once untrailingslashit( $this->plugin_path() ) . '/inc/class-audioigniter-sanitizer.php';
$this->sanitizer = new AudioIgniter_Sanitizer();
// if ( ! class_exists( 'AudioIgniter_Pro', false ) ) {
// require_once untrailingslashit( $this->plugin_path() ) . '/inc/class-audioigniter-admin-page-upsell.php';
// new AudioIgniter_Admin_Page_Upsell();
// }
// Initialization needed in every request.
$this->init();
// Initialization needed in admin requests.
$this->admin_init();
// Initialization needed in frontend requests.
$this->frontend_init();
do_action( 'audioigniter_loaded' );
}
/**
* Registers actions that need to be run on both admin and frontend
*
* @since 1.0.0
*/
protected function init() {
add_action( 'init', array( $this, 'register_post_types' ) );
add_action( 'init', array( $this, 'register_scripts' ) );
add_action( 'init', array( $this, 'register_playlist_endpoint' ) );
add_action( 'init', array( $this, 'register_image_sizes' ) );
add_action( 'init', array( $this, 'register_shortcodes' ) );
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
do_action( 'audioigniter_init' );
}
/**
* Registers actions that need to be run on admin only.
*
* @since 1.0.0
*/
protected function admin_init() {
if ( ! is_admin() ) {
return;
}
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
add_action( 'save_post', array( $this, 'save_post' ) );
add_filter( "manage_{$this->post_type}_posts_columns", array( $this, 'filter_posts_columns' ) );
add_action( "manage_{$this->post_type}_posts_custom_column", array( $this, 'add_custom_columns' ), 10, 2 );
do_action( 'audioigniter_admin_init' );
}
/**
* Registers actions that need to be run on frontend only.
*
* @since 1.0.0
*/
protected function frontend_init() {
if ( is_admin() ) {
return;
}
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'template_redirect', array( $this, 'handle_playlist_endpoint' ) );
do_action( 'audioigniter_frontend_init' );
}
/**
* Register (but not enqueue) all scripts and styles to be used throughout the plugin.
*
* @since 1.0.0
*/
public function register_scripts() {
wp_register_style( 'audioigniter', untrailingslashit( $this->plugin_url() ) . '/player/build/style.css', array(), $this->version );
wp_register_script( 'audioigniter', untrailingslashit( $this->plugin_url() ) . '/player/build/app.js', array(), $this->version, true );
wp_localize_script( 'audioigniter', 'aiStrings', apply_filters( 'audioigniter_aiStrings', array(
/* translators: %s is the track's title. */
'play_title' => esc_html__( 'Play %s', 'audioigniter' ),
/* translators: %s is the track's title. */
'pause_title' => esc_html__( 'Pause %s', 'audioigniter' ),
'previous' => esc_html__( 'Previous track', 'audioigniter' ),
'next' => esc_html__( 'Next track', 'audioigniter' ),
'toggle_list_repeat' => esc_html__( 'Toggle track listing repeat', 'audioigniter' ),
'toggle_track_repeat' => esc_html__( 'Toggle track repeat' ),
'toggle_list_visible' => esc_html__( 'Toggle track listing visibility', 'audioigniter' ),
'buy_track' => esc_html__( 'Buy this track', 'audioigniter' ),
'download_track' => esc_html__( 'Download this track', 'audioigniter' ),
'volume_up' => esc_html__( 'Volume Up', 'audioigniter' ),
'volume_down' => esc_html__( 'Volume Down', 'audioigniter' ),
'open_track_lyrics' => esc_html__( 'Open track lyrics', 'audioigniter' ),
'set_playback_rate' => esc_html__( 'Set playback rate', 'audioigniter' ),
'skip_forward' => esc_html__( 'Skip forward', 'audioigniter' ),
'skip_backward' => esc_html__( 'Skip backward', 'audioigniter' ),
'shuffle' => esc_html__( 'Shuffle', 'audioigniter' ),
) ) );
wp_localize_script( 'audioigniter', 'aiStats', array(
'enabled' => get_option( 'audioigniter_stats_enabled' ) && class_exists( 'AudioIgniter_Pro' ),
'apiUrl' => get_rest_url( null, 'audioigniter/v1' ),
) );
wp_register_style( 'audioigniter-admin', untrailingslashit( $this->plugin_url() ) . '/assets/css/admin-styles.css', array(), $this->version );
wp_register_script( 'audioigniter-admin', untrailingslashit( $this->plugin_url() ) . '/assets/js/audioigniter.js', array(), $this->version, true );
wp_localize_script( 'audioigniter-admin', 'ai_scripts', array(
'messages' => array(
'confirm_clear_tracks' => esc_html__( 'Do you really want to remove all tracks? (This will not delete your audio files).', 'audioigniter' ),
'media_title_upload' => esc_html__( 'Select or upload audio media', 'audioigniter' ),
'media_title_upload_cover' => esc_html__( 'Select a cover image', 'audioigniter' ),
),
) );
wp_register_style( 'audioigniter-admin-settings', untrailingslashit( $this->plugin_url() ) . '/assets/css/admin/settings.css', array(), $this->version );
}
/**
* Enqueues frontend scripts and styles.
*
* @since 1.0.0
*/
public function enqueue_scripts() {
wp_enqueue_style( 'audioigniter' );
wp_enqueue_script( 'audioigniter' );
}
/**
* Enqueues admin scripts and styles.
*
* @since 1.0.0
*/
public function enqueue_admin_scripts( $hook ) {
$screen = get_current_screen();
if ( 'post' === $screen->base && $screen->post_type === $this->post_type ) {
wp_enqueue_media();
wp_enqueue_style( 'audioigniter-admin' );
wp_enqueue_script( 'audioigniter-admin' );
}
// if ( 'ai_playlist_page_audioigniter-upsell' === $screen->id ) {
// wp_enqueue_style( 'audioigniter-admin-settings' );
// }
}
/**
* Post types registration.
*
* @since 1.0.0
*/
public function register_post_types() {
$labels = array(
'name' => esc_html_x( 'Playlists', 'post type general name', 'audioigniter' ),
'singular_name' => esc_html_x( 'Playlist', 'post type singular name', 'audioigniter' ),
'menu_name' => esc_html_x( 'AudioIgniter', 'admin menu', 'audioigniter' ),
'all_items' => esc_html_x( 'All Playlists', 'admin menu', 'audioigniter' ),
'name_admin_bar' => esc_html_x( 'Playlist', 'add new on admin bar', 'audioigniter' ),
'add_new' => esc_html__( 'Add New Playlist', 'audioigniter' ),
'add_new_item' => esc_html__( 'Add New Playlist', 'audioigniter' ),
'edit_item' => esc_html__( 'Edit Playlist', 'audioigniter' ),
'new_item' => esc_html__( 'New Playlist', 'audioigniter' ),
'view_item' => esc_html__( 'View Playlist', 'audioigniter' ),
'search_items' => esc_html__( 'Search Playlists', 'audioigniter' ),
'not_found' => esc_html__( 'No playlists found', 'audioigniter' ),
'not_found_in_trash' => esc_html__( 'No playlists found in the trash', 'audioigniter' ),
);
$args = array(
'labels' => $labels,
'singular_label' => esc_html_x( 'Playlist', 'post type singular name', 'audioigniter' ),
'public' => false,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'has_archive' => false,
'supports' => array( 'title' ),
'menu_icon' => 'dashicons-controls-volumeon',
);
register_post_type( $this->post_type, $args );
}
/**
* Registers metaboxes for the ai_playlist post type.
*
* @since 1.0.0
*/
public function add_meta_boxes() {
add_meta_box( 'ai-meta-box-tracks', esc_html__( 'Tracks', 'audioigniter' ), array( $this, 'metabox_tracks' ), $this->post_type, 'normal', 'high' );
add_meta_box( 'ai-meta-box-settings', esc_html__( 'Settings', 'audioigniter' ), array( $this, 'metabox_settings' ), $this->post_type, 'normal', 'high' );
add_meta_box( 'ai-meta-box-shortcode', esc_html__( 'Shortcode', 'audioigniter' ), array( $this, 'metabox_shortcode' ), $this->post_type, 'side', 'default' );
}
/**
* Echoes the Tracks metabox markup.
*
* @since 1.0.0
*
* @param WP_Post $object
* @param array $box
*/
public function metabox_tracks( $object, $box ) {
$tracks = $this->get_post_meta( $object->ID, '_audioigniter_tracks', array() );
wp_nonce_field( basename( __FILE__ ), $object->post_type . '_nonce' );
?>
<?php $this->metabox_tracks_header(); ?>
<div class="ai-container">
<?php $this->metabox_tracks_field_controls( 'top', $object->ID ); ?>
<?php $container_classes = apply_filters( 'audioigniter_metabox_tracks_container_classes', array( 'ai-fields-container' ) ); ?>
<div class="<?php echo esc_attr( implode( ' ', $container_classes ) ); ?>">
<?php
if ( ! empty( $tracks ) ) {
foreach ( $tracks as $track ) {
$this->metabox_tracks_repeatable_track_field( $track );
}
} else {
$this->metabox_tracks_repeatable_track_field();
}
?>
</div>
<?php $this->metabox_tracks_field_controls( 'bottom', $object->ID ); ?>
</div>
<?php $this->metabox_tracks_footer(); ?>
<?php
}
/**
* Echoes the Tracks metabox header.
*
* @since 1.0.0
*/
protected function metabox_tracks_header() {
?>
<div class="ai-header ai-brand-module">
<div class="ai-row">
<div class="ai-col-left">
<a href="https://www.cssigniter.com/plugins/audioigniter?utm_source=dashboard&utm_medium=link&utm_content=audioigniter&utm_campaign=logo" target="_blank" class="ai-logo">
<img
src="<?php echo esc_url( $this->plugin_url() . 'assets/images/logo.svg' ); ?>"
alt="<?php esc_attr_e( 'AudioIgniter Logo', 'audioigniter' ); ?>"
>
</a>
</div>
<?php if ( apply_filters( 'audioigniter_metabox_tracks_show_upgrade_button', true ) ) : ?>
<div class="ai-col-right">
<div class="ai-brand-module-actions">
<a href="https://www.cssigniter.com/plugins/audioigniter?utm_source=dashboard&utm_medium=link&utm_content=audioigniter&utm_campaign=upgrade-pro" class="ai-btn ai-btn-green" target="_blank">
<?php esc_html_e( 'Upgrade to Pro', 'audioigniter' ); ?>
</a>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php
}
/**
* Echoes the Tracks metabox footer.
*
* @since 1.0.0
*/
protected function metabox_tracks_footer() {
?>
<div class="ai-footer ai-brand-module">
<div class="ai-row">
<div class="ai-col-left">
<ul class="ai-list-inline ai-footer-links">
<?php
$links = apply_filters( 'audioigniter_metabox_tracks_footer_links', array(
'support' => array(
'title' => __( 'Support', 'audioigniter' ),
'url' => 'https://wordpress.org/support/plugin/audioigniter',
),
'documentation' => array(
'title' => __( 'Documentation', 'audioigniter' ),
'url' => 'https://www.cssigniter.com/docs/audioigniter/',
),
'rate_plugin' => array(
'title' => __( 'Rate this plugin', 'audioigniter' ),
'url' => 'https://wordpress.org/support/view/plugin-reviews/audioigniter',
),
) );
foreach ( $links as $link ) {
if ( empty( $link['url'] ) || empty( $link['title'] ) ) {
continue;
}
echo sprintf( '<li><a href="%s" target="_blank">%s</a></li>',
esc_url( $link['url'] ),
esc_html( $link['title'] )
);
}
?>
</ul>
</div>
<div class="ai-col-right">
<?php
$url = 'https://www.cssigniter.com/plugins/audioigniter?utm_source=dashboard&utm_medium=link&utm_content=audioigniter&utm_campaign=footer-link';
/* translators: %s is a URL. */
$copy = sprintf( __( 'Thank you for creating with <a href="%s" target="_blank">AudioIgniter</a>', 'audioigniter' ),
esc_url( $url )
);
?>
<div class="ai-brand-module-actions">
<p class="ai-note"><?php echo wp_kses( $copy, array( 'a' => array( 'href' => true, 'target' => true ) ) ); ?></p>
</div>
</div>
</div>
</div>
<?php
}
protected function metabox_tracks_repeatable_track_field( $track = array() ) {
$track = wp_parse_args( $track, self::get_default_track_values() );
$cover_id = $track['cover_id'];
$title = $track['title'];
$artist = $track['artist'];
$track_url = $track['track_url'];
$buy_link = $track['buy_link'];
$download_url = $track['download_url'];
$download_uses_track_url = (int) $track['download_uses_track_url'];
$cover_url = wp_get_attachment_image_src( intval( $cover_id ), 'thumbnail' );
if ( ! empty( $cover_url[0] ) ) {
$cover_url = $cover_url[0];
$cover_data = wp_prepare_attachment_for_js( intval( $cover_id ) );
} else {
$cover_url = '';
$cover_data = '';
}
$uid = uniqid();
$field_classes = apply_filters( 'audioigniter_metabox_track_classes', array( 'ai-field-repeatable' ), $track_url );
?>
<div class="<?php echo esc_attr( implode( ' ', $field_classes ) ); ?>" data-uid="<?php echo esc_attr( $uid ); ?>">
<div class="ai-field-head">
<?php do_action( 'audioigniter_metabox_tracks_repeatable_track_field_before_title' ); ?>
<span class="ai-field-title"><?php echo wp_kses( $title, array() ); ?></span>
<button type="button" class="ai-field-toggle button-link">
<span class="screen-reader-text">
<?php esc_html_e( 'Toggle track visibility', 'audioigniter' ); ?>
</span>
<span class="toggle-indicator"></span>
</button>
</div>
<div class="ai-field-container">
<div class="ai-field-cover">
<a href="#" class="ai-field-upload-cover <?php echo ! empty( $cover_url ) ? 'ai-has-cover' : ''; ?>">
<span class="ai-remove-cover">
<span class="screen-reader-text">
<?php esc_html_e( 'Remove Cover Image', 'audioigniter' ); ?>
</span>
<span class="dashicons dashicons-no-alt"></span>
</span>
<?php if ( ! empty( $cover_url ) ) : ?>
<img src="<?php echo esc_url( $cover_url ); ?>" alt="<?php echo esc_attr( $cover_data['alt'] ); ?>">
<?php else : ?>
<img src="#" alt="">
<?php endif; ?>
<div class="ai-field-cover-placeholder">
<span class="ai-cover-prompt">
<?php esc_html_e( 'Upload Cover', 'audioigniter' ); ?>
</span>
</div>
</a>
<input
type="hidden"
id="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-cover_id"
name="ai_playlist_tracks[<?php echo esc_attr( $uid ); ?>][cover_id]"
value="<?php echo esc_attr( $cover_id ); ?>"
/>
</div>
<div class="ai-field-split">
<div class="ai-form-field">
<label
for="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-title"
class="screen-reader-text">
<?php esc_html_e( 'Title', 'audioigniter' ); ?>
</label>
<input
type="text"
id="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-title"
class="ai-track-title"
name="ai_playlist_tracks[<?php echo esc_attr( $uid ); ?>][title]"
placeholder="<?php esc_attr_e( 'Title', 'audioigniter' ); ?>"
value="<?php echo esc_attr( $title ); ?>"
/>
</div>
<div class="ai-form-field">
<label
for="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-artist"
class="screen-reader-text">
<?php esc_html_e( 'Artist', 'audioigniter' ); ?>
</label>
<input
type="text"
id="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-artist"
class="ai-track-artist"
name="ai_playlist_tracks[<?php echo esc_attr( $uid ); ?>][artist]"
placeholder="<?php esc_attr_e( 'Artist', 'audioigniter' ); ?>"
value="<?php echo esc_attr( $artist ); ?>"
/>
</div>
<div class="ai-form-field">
<label
for="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-buy_link"
class="screen-reader-text">
<?php esc_html_e( 'Buy link', 'audioigniter' ); ?>
</label>
<input
type="text"
id="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-buy_link"
class="ai-track-buy-link"
name="ai_playlist_tracks[<?php echo esc_attr( $uid ); ?>][buy_link]"
placeholder="<?php esc_attr_e( 'Buy link', 'audioigniter' ); ?>"
value="<?php echo esc_url( $buy_link ); ?>"
/>
</div>
<?php do_action( 'audioigniter_metabox_tracks_repeatable_track_fields_column_1', $track, $uid ); ?>
</div>
<div class="ai-field-split">
<div class="ai-form-field">
<label
for="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-track_url"
class="screen-reader-text">
<?php esc_html_e( 'Audio file or radio stream', 'audioigniter' ); ?>
</label>
<div class="ai-form-field-addon">
<input
type="text"
id="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-track_url"
class="ai-track-url"
name="ai_playlist_tracks[<?php echo esc_attr( $uid ); ?>][track_url]"
placeholder="<?php esc_attr_e( 'Audio file or radio stream', 'audioigniter' ); ?>"
value="<?php echo esc_url( $track_url ); ?>"
/>
<button type="button" class="button ai-upload">
<?php esc_html_e( 'Upload', 'audioigniter' ); ?>
</button>
<?php do_action( 'audioigniter_metabox_tracks_repeatable_track_field_after_track_upload_button' ); ?>
</div>
</div>
<div class="ai-form-field">
<label
for="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-download_url"
class="screen-reader-text">
<?php esc_html_e( 'Download URL', 'audioigniter' ); ?>
</label>
<input
type="text"
id="ai_playlist_tracks-<?php echo esc_attr( $uid ); ?>-download_url"
class="ai-track-download-url"
name="ai_playlist_tracks[<?php echo esc_attr( $uid ); ?>][download_url]"
placeholder="<?php esc_attr_e( 'Download URL', 'audioigniter' ); ?>"
value="<?php echo esc_url( $download_url ); ?>"
<?php if ( $download_uses_track_url ) : ?>
disabled
<?php endif; ?>
/>
<?php do_action( 'audioigniter_metabox_tracks_repeatable_track_field_after_download_url_button', $track, $uid ); ?>
</div>
<?php do_action( 'audioigniter_metabox_tracks_repeatable_track_fields_column_2', $track, $uid ); ?>
<button type="button" class="button ai-remove-field">
<span class="dashicons dashicons-dismiss"></span>
<?php esc_html_e( 'Remove Track', 'audioigniter' ); ?>
</button>
</div>
</div>
</div>
<?php
}
protected function metabox_tracks_field_controls( $location, $post_id ) {
?>
<div class="ai-field-controls-wrap">
<div class="ai-field-controls">
<button type="button" class="button ai-add-field ai-add-field-<?php echo esc_attr( $location ); ?>">
<span class="dashicons dashicons-plus-alt"></span>
<?php esc_html_e( 'Add Track', 'audioigniter' ); ?>
</button>
<?php do_action( 'audioigniter_metabox_tracks_field_controls', $location, $post_id ); ?>
<button type="button" class="button ai-remove-all-fields">
<span class="dashicons dashicons-dismiss"></span>
<?php esc_html_e( 'Clear Playlist', 'audioigniter' ); ?>
</button>
</div>
<div class="ai-field-controls-visibility">
<a href="#" class="ai-fields-expand-all">
<?php esc_html_e( 'Expand All', 'audioigniter' ); ?>
</a>
<a href="#" class="ai-fields-collapse-all">
<?php esc_html_e( 'Collapse All', 'audioigniter' ); ?>
</a>
</div>
</div>
<?php
}
/**
* Echoes the Settings metabox markup.
*
* @version 1.4.0
* @since 1.0.0
*
* @param WP_Post $object
* @param array $box
*/
public function metabox_settings( $object, $box ) {
$type = $this->get_post_meta( $object->ID, '_audioigniter_player_type', 'full' );
$numbers = $this->get_post_meta( $object->ID, '_audioigniter_show_numbers', 1 );
$numbers_reverse = $this->get_post_meta( $object->ID, '_audioigniter_show_numbers_reverse', 0 );
$thumb = $this->get_post_meta( $object->ID, '_audioigniter_show_covers', 1 );
$active_thumb = $this->get_post_meta( $object->ID, '_audioigniter_show_active_cover', 1 );
$artist = $this->get_post_meta( $object->ID, '_audioigniter_show_artist', 1 );
$buy_links = $this->get_post_meta( $object->ID, '_audioigniter_show_buy_links', 1 );
$buy_links_new_target = $this->get_post_meta( $object->ID, '_audioigniter_buy_links_new_target', 1 );
$cycle_tracks = $this->get_post_meta( $object->ID, '_audioigniter_cycle_tracks', 0 );
$track_listing = $this->get_post_meta( $object->ID, '_audioigniter_show_track_listing', 1 );
$track_listing_allow_toggle = $this->get_post_meta( $object->ID, '_audioigniter_allow_track_listing_toggle', 1 );
$track_listing_allow_loop = $this->get_post_meta( $object->ID, '_audioigniter_allow_track_listing_loop', 1 );
$credit = $this->get_post_meta( $object->ID, '_audioigniter_show_credit', 0 );
$limit_tracklisting_height = $this->get_post_meta( $object->ID, '_audioigniter_limit_tracklisting_height', 1 );
$tracklisting_height = $this->get_post_meta( $object->ID, '_audioigniter_tracklisting_height', 185 );
$volume = $this->get_post_meta( $object->ID, '_audioigniter_volume', 100 );
$max_width = $this->get_post_meta( $object->ID, '_audioigniter_max_width' );
wp_nonce_field( basename( __FILE__ ), $object->post_type . '_nonce' );
?>
<div class="ai-module ai-module-settings">
<div class="ai-form-field-group">
<h3 class="ai-form-field-group-title"><?php esc_html_e( 'Player & Track listing', 'audioigniter' ); ?></h3>
<div class="ai-form-field">
<div class="ai-player-type-message ai-info-box"></div>
<label for="_audioigniter_player_type">
<?php esc_html_e( 'Player Type', 'audioigniter' ); ?>
</label>
<select
class="widefat ai-form-select-player-type"
id="_audioigniter_player_type"
name="_audioigniter_player_type"
>
<?php foreach ( $this->get_player_types() as $player_key => $player_type ) : ?>
<option
value="<?php echo esc_attr( $player_key ); ?>"
data-no-support="<?php echo esc_attr( implode( ', ', $player_type['no-support'] ) ); ?>"
data-info="<?php echo esc_attr( $player_type['info'] ); ?>"
<?php selected( $type, $player_key ); ?>
>
<?php echo wp_kses( $player_type['label'], 'strip' ); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_show_track_listing"
name="_audioigniter_show_track_listing"
value="1" <?php checked( $track_listing, true ); ?>
/>
<label for="_audioigniter_show_track_listing">
<?php esc_html_e( 'Show track listing by default', 'audioigniter' ); ?>
</label>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_allow_track_listing_toggle"
name="_audioigniter_allow_track_listing_toggle"
value="1" <?php checked( $track_listing_allow_toggle, true ); ?>
/>
<label for="_audioigniter_allow_track_listing_toggle">
<?php esc_html_e( 'Show track listing visibility toggle button', 'audioigniter' ); ?>
</label>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_show_numbers_revese"
name="_audioigniter_show_numbers_reverse"
value="1" <?php checked( $numbers_reverse, true ); ?>
/>
<label for="_audioigniter_show_numbers_revese">
<?php esc_html_e( 'Reverse track order', 'audioigniter' ); ?>
</label>
</div>
<div class="ai-form-field">
<label for="_audioigniter_volume">
<?php esc_html_e( 'Starting volume', 'audioigniter' ); ?>
</label>
<input
type="number"
min="0"
max="100"
step="10"
id="_audioigniter_volume"
class="ai-track-title"
name="_audioigniter_volume"
placeholder="<?php esc_attr_e( '0-100', 'audioigniter' ); ?>"
value="<?php echo esc_attr( $volume ); ?>"
/>
<p class="ai-field-help">
<?php esc_html_e( 'Enter a value between 0 and 100 in increments of 10', 'audioigniter' ); ?>
</p>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_limit_tracklisting_height"
name="_audioigniter_limit_tracklisting_height"
value="1" <?php checked( $limit_tracklisting_height, true ); ?>
/>
<label for="_audioigniter_limit_tracklisting_height">
<?php esc_html_e( 'Limit track listing height', 'audioigniter' ); ?>
</label>
</div>
<div class="ai-form-field">
<label for="_audioigniter_tracklisting_height">
<?php esc_html_e( 'Track listing height', 'audioigniter' ); ?>
</label>
<input
type="number"
min="10"
step="5"
id="_audioigniter_tracklisting_height"
class="ai-track-title"
name="_audioigniter_tracklisting_height"
placeholder="<?php esc_attr_e( 'Track listing height', 'audioigniter' ); ?>"
value="<?php echo esc_attr( $tracklisting_height ); ?>"
/>
<p class="ai-field-help">
<?php esc_html_e( 'Set a number of pixels', 'audioigniter' ); ?>
</p>
</div>
<div class="ai-form-field">
<label for="_audioigniter_max_width">
<?php esc_html_e( 'Maximum player width', 'audioigniter' ); ?>
</label>
<input
type="number"
id="_audioigniter_max_width"
class="ai-track-title"
name="_audioigniter_max_width"
placeholder="<?php esc_attr_e( 'Automatic width', 'audioigniter' ); ?>"
value="<?php echo esc_attr( $max_width ); ?>"
/>
<p class="ai-field-help">
<?php esc_html_e( 'Set a number of pixels, or leave empty to automatically cover 100% of the available area (recommended).', 'audioigniter' ); ?>
</p>
</div>
<?php do_action( 'audioigniter_metabox_settings_group_player_track_listing_fields', $object, $box ); ?>
</div>
<div class="ai-form-field-group">
<h3 class="ai-form-field-group-title"><?php esc_html_e( 'Tracks', 'audioigniter' ); ?></h3>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_show_numbers"
name="_audioigniter_show_numbers"
value="1" <?php checked( $numbers, true ); ?>
/>
<label for="_audioigniter_show_numbers">
<?php esc_html_e( 'Show track numbers in tracklist', 'audioigniter' ); ?>
</label>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_show_covers"
name="_audioigniter_show_covers"
value="1" <?php checked( $thumb, true ); ?>
/>
<label for="_audioigniter_show_covers">
<?php esc_html_e( 'Show track covers in tracklist', 'audioigniter' ); ?>
</label>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_show_active_cover"
name="_audioigniter_show_active_cover"
value="1" <?php checked( $active_thumb, true ); ?>
/>
<label for="_audioigniter_show_active_cover">
<?php esc_html_e( "Show active track's cover", 'audioigniter' ); ?>
</label>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_show_artist"
name="_audioigniter_show_artist"
value="1" <?php checked( $artist, true ); ?>
/>
<label for="_audioigniter_show_artist">
<?php esc_html_e( 'Show artist names', 'audioigniter' ); ?>
</label>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_show_buy_links"
name="_audioigniter_show_buy_links"
value="1" <?php checked( $buy_links, true ); ?>
/>
<label for="_audioigniter_show_buy_links">
<?php esc_html_e( 'Show track extra buttons (buy link, download button etc)', 'audioigniter' ); ?>
</label>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_buy_links_new_target"
name="_audioigniter_buy_links_new_target"
value="1" <?php checked( $buy_links_new_target, true ); ?>
/>
<label for="_audioigniter_buy_links_new_target">
<?php esc_html_e( 'Open buy links in new window', 'audioigniter' ); ?>
</label>
</div>
<?php do_action( 'audioigniter_metabox_settings_group_tracks_fields', $object, $box ); ?>
</div>
<div class="ai-form-field-group">
<h3 class="ai-form-field-group-title"><?php esc_html_e( 'Track & Track listing repeat', 'audioigniter' ); ?></h3>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_cycle_tracks"
name="_audioigniter_cycle_tracks"
value="1" <?php checked( $cycle_tracks, true ); ?>
/>
<label for="_audioigniter_cycle_tracks">
<?php esc_html_e( 'Repeat track listing enabled by default', 'audioigniter' ); ?>
</label>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_allow_track_listing_loop"
name="_audioigniter_allow_track_listing_loop"
value="1" <?php checked( $track_listing_allow_loop, true ); ?>
/>
<label for="_audioigniter_allow_track_listing_loop">
<?php esc_html_e( 'Show track listing repeat toggle button', 'audioigniter' ); ?>
</label>
</div>
<?php do_action( 'audioigniter_metabox_settings_group_player_track_track_listing_repeat_fields', $object, $box ); ?>
</div>
<div class="ai-form-field">
<input
type="checkbox"
class="ai-checkbox"
id="_audioigniter_show_credit"
name="_audioigniter_show_credit"
value="1" <?php checked( $credit, true ); ?>
/>
<label for="_audioigniter_show_credit">
<?php esc_html_e( 'Show "Powered by AudioIgniter" link', 'audioigniter' ); ?>
</label>
<p class="ai-field-help">
<?php esc_html_e( "We've put a great deal of effort into building this plugin. If you feel like it, let others know about it by enabling this option.", 'audioigniter' ); ?>
</p>
</div>
</div>
<?php
}