PluginProbe ʕ •ᴥ•ʔ
Music Player for WooCommerce / 1.8.0
Music Player for WooCommerce v1.8.0
1.8.3 1.8.2 1.8.1 1.1.10 1.1.11 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.11 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 trunk 1.0.173 1.0.174 1.0.175 1.0.176 1.0.177 1.0.178 1.0.179 1.0.180 1.0.181 1.0.182 1.0.183 1.0.184 1.0.185 1.0.186 1.0.187 1.0.188 1.0.189 1.0.190 1.0.191 1.0.192 1.0.193 1.0.194 1.0.195 1.0.196 1.0.197 1.1.0 1.1.1
music-player-for-woocommerce / addons / ap-cp-media-player.addon.php
music-player-for-woocommerce / addons Last commit date
ap-cp-media-player 4 months ago ap-html5-audio-player 4 months ago ap-mp3-jplayer 4 months ago dokan 4 months ago wcfm 4 months ago wcv 4 months ago ap-compact-audio-player.addon.php 4 months ago ap-cp-media-player.addon.php 4 months ago ap-html5-audio-player.addon.php 4 months ago ap-mp3-jplayer.addon.php 4 months ago dokan.addon.php 4 months ago mvx.addon.php 4 months ago wcfm.addon.php 4 months ago wcv.addon.php 4 months ago
ap-cp-media-player.addon.php
121 lines
1 <?php
2 if ( ! class_exists( 'WCMP_CPMEDIAPLAYER_ADDON' ) ) {
3 class WCMP_CPMEDIAPLAYER_ADDON {
4
5 private $_wcmp;
6
7 public function __construct( $wcmp ) {
8 $this->_wcmp = $wcmp;
9 add_action( 'wcmp_addon_general_settings', array( $this, 'general_settings' ) );
10 add_action( 'wcmp_save_setting', array( $this, 'save_general_settings' ) );
11 add_filter( 'wcmp_audio_tag', array( $this, 'generate_player' ), 99, 4 );
12 add_filter( 'wcmp_widget_audio_tag', array( $this, 'generate_player' ), 99, 4 );
13 add_filter( 'wcmp_product_attr', array( $this, 'product_attr' ), 99, 3 );
14 add_filter( 'wcmp_global_attr', array( $this, 'global_attr' ), 99, 2 );
15 } // End __construct
16
17 private function _player_exists() {
18 return defined( 'CPMP_VERSION' );
19 } // End _player_exists
20
21 private function _is_enabled() {
22 return get_option( 'wcmp_addon_player' ) == 'cpmediaplayer';
23 } // End _is_enabled
24
25 private function _load_skins( $selected_option ) {
26 // Skins
27 $options = '';
28 if ( defined( 'CPMP_PLUGIN_DIR' ) ) {
29 $skins = array();
30 $skin_dir = CPMP_PLUGIN_DIR . '/skins';
31 if ( file_exists( $skin_dir ) ) {
32 $d = dir( $skin_dir );
33 while ( false !== ( $entry = $d->read() ) ) {
34 if ( '.' != $entry && '..' != $entry && is_dir( $skin_dir . '/' . $entry ) ) {
35 $this_skin = $skin_dir . '/' . $entry . '/';
36 if ( file_exists( $this_skin ) ) {
37 $skin_data = parse_ini_file( $this_skin . 'config.ini', true );
38 $options .= '<option value="' . $skin_data['id'] . '" ' . ( $skin_data['id'] == $selected_option ? 'SELECTED' : '' ) . '>' . esc_html( $skin_data['name'] ) . '</option>';
39 }
40 }
41 }
42 $d->close();
43 }
44 }
45 return $options;
46 } // End _load_skins
47
48 private function _get_skin() {
49 return get_option( 'wcmp_cpmediaplayer_addon_skin', 'classic-skin' );
50 } // End _get_skin
51
52 private function _set_skin( $v ) {
53 update_option( 'wcmp_cpmediaplayer_addon_skin', $v );
54 } // End _set_skin
55
56 public function general_settings() {
57 $enabled = ( $this->_player_exists() && $this->_is_enabled() );
58
59 print '<tr><td><input aria-label="' . esc_attr__( 'Use CP Media Player instead of the current plugin players', 'music-player-for-woocommerce' ) . '" type="radio" value="cpmediaplayer" name="wcmp_addon_player" ' . ( $enabled ? 'CHECKED' : '' ) . ( $this->_player_exists() ? '' : ' DISABLED' ) . ' class="wcmp_radio"></td><td width="100%"><b>' . esc_html__( 'Use "CP Media Player" instead of the current plugin players', 'music-player-for-woocommerce' ) . '</b><br>
60 ' . esc_html__( 'Select player skin', 'music-player-for-woocommerce' ) . ': <select name="wcmp_cpmediaplayer_addon_skin" ' . ( $this->_player_exists() ? '' : ' DISABLED' ) . '>' . $this->_load_skins( $this->_get_skin() ) . '</select>
61 <br><i>' .
62 ( $this->_player_exists()
63 ? __( 'The player functions configured above do not apply, except for audio protection if applicable.<br>This player <b>will take precedence</b> over the player configured in the products\' settings.', 'music-player-for-woocommerce' ) // phpcs:ignore WordPress.Security.EscapeOutput
64 : esc_html__( 'The "CP Media Player" plugin is not installed on your WordPress.', 'music-player-for-woocommerce' )
65 )
66 . '</i></td></tr>';
67 } // End general_settings
68
69 public function save_general_settings() {
70 if ( $this->_player_exists() ) {
71 if ( isset( $_POST['wcmp_addon_player'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
72 update_option( 'wcmp_addon_player', sanitize_text_field( wp_unslash( $_POST['wcmp_addon_player'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
73 } else {
74 delete_option( 'wcmp_addon_player' );
75 }
76
77 if ( isset( $_POST['wcmp_cpmediaplayer_addon_skin'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
78 $this->_set_skin( sanitize_text_field( wp_unslash( $_POST['wcmp_cpmediaplayer_addon_skin'] ) ) ); // phpcs:ignore WordPress.Security.NonceVerification
79 }
80 }
81 } // End save_general_settings
82
83 public function generate_player( $player, $product_id, $file_index, $url ) {
84 if ( $this->_player_exists() && $this->_is_enabled() ) {
85 wp_enqueue_style( 'wcmp-ap-cp-media-player-style', plugin_dir_url( __FILE__ ) . 'ap-cp-media-player/style.css', array(), WCMP_VERSION );
86 return do_shortcode( '[cpm-player skin="' . esc_attr( $this->_get_skin() ) . '" playlist="false" type="audio"][cpm-item file="' . esc_attr( $url ) . '"][/cpm-player]' );
87 }
88 return $player;
89 } // End generate_player
90
91 public function product_attr( $value, $product_id, $attribute ) {
92 if (
93 ! is_admin() &&
94 $this->_player_exists() &&
95 $this->_is_enabled() &&
96 '_wcmp_player_controls' == $attribute
97 ) {
98 return 'all';
99 }
100
101 return $value;
102 } // End product_attr
103
104 public function global_attr( $value, $attribute ) {
105 if (
106 ! is_admin() &&
107 $this->_player_exists() &&
108 $this->_is_enabled() &&
109 '_wcmp_player_controls' == $attribute
110 ) {
111 return 'all';
112 }
113
114 return $value;
115 } // End global_attr
116
117 } // End WCMP_CPMEDIAPLAYER_ADDON
118 }
119
120 new WCMP_CPMEDIAPLAYER_ADDON( $wcmp );
121