Version Description
- Modifies the preload behavior to avoid affecting server performance.
Download this release
Release Info
Developer | codepeople |
Plugin | Music Player for WooCommerce |
Version | 1.0.178 |
Comparing to | |
See all releases |
Code changes from version 1.0.177 to 1.0.178
- addons/ap-compact-audio-player.addon.php +82 -84
- addons/ap-cp-media-player.addon.php +120 -130
- addons/ap-html5-audio-player.addon.php +109 -110
- addons/ap-mp3-jplayer.addon.php +89 -91
- addons/dokan.addon.php +57 -65
- addons/wcfm.addon.php +93 -89
- addons/wcv.addon.php +51 -54
- readme.txt +5 -1
- wcmp.php +22 -6
addons/ap-compact-audio-player.addon.php
CHANGED
@@ -1,84 +1,82 @@
|
|
1 |
-
<?php
|
2 |
-
if(!class_exists('WCMP_COMPACTAUDIOPLAYER_ADDON'))
|
3 |
-
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
$this
|
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 |
-
new WCMP_COMPACTAUDIOPLAYER_ADDON($wcmp);
|
1 |
+
<?php
|
2 |
+
if ( ! class_exists( 'WCMP_COMPACTAUDIOPLAYER_ADDON' ) ) {
|
3 |
+
class WCMP_COMPACTAUDIOPLAYER_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( 'SC_AUDIO_PLUGIN_VERSION' );
|
19 |
+
} // End _player_exists
|
20 |
+
|
21 |
+
private function _is_enabled() {
|
22 |
+
return get_option( 'wcmp_addon_player' ) == 'compactaudioplayer';
|
23 |
+
} // End _is_enabled
|
24 |
+
|
25 |
+
public function general_settings() {
|
26 |
+
$enabled = ( $this->_player_exists() && $this->_is_enabled() );
|
27 |
+
|
28 |
+
print '<tr><td><input aria-label="' . esc_attr__( 'Use Compact Audio Player instead of the current plugin players', 'music-player-for-woocommerce' ) . '" type="radio" value="compactaudioplayer" name="wcmp_addon_player" ' . ( $enabled ? 'CHECKED' : '' ) . ( $this->_player_exists() ? '' : ' DISABLED' ) . ' class="wcmp_radio"></td><td width="100%"><b>' . esc_html__( 'Use "Compact Audio Player" instead of the current plugin players', 'music-player-for-woocommerce' ) . '</b><br><i>' .
|
29 |
+
( $this->_player_exists()
|
30 |
+
? __( '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' )
|
31 |
+
: esc_html__( 'The "Compact WP Audio Player" plugin is not installed on your WordPress.', 'music-player-for-woocommerce' )
|
32 |
+
)
|
33 |
+
. '</i></td></tr>';
|
34 |
+
} // End general_settings
|
35 |
+
|
36 |
+
public function save_general_settings() {
|
37 |
+
if ( $this->_player_exists() ) {
|
38 |
+
if ( isset( $_POST['wcmp_addon_player'] ) ) {
|
39 |
+
update_option( 'wcmp_addon_player', sanitize_text_field( wp_unslash( $_POST['wcmp_addon_player'] ) ) );
|
40 |
+
} else {
|
41 |
+
delete_option( 'wcmp_addon_player' );
|
42 |
+
}
|
43 |
+
}
|
44 |
+
} // End save_general_settings
|
45 |
+
|
46 |
+
public function generate_player( $player, $product_id, $file_index, $url ) {
|
47 |
+
if ( $this->_player_exists() && $this->_is_enabled() ) {
|
48 |
+
return do_shortcode( '[sc_embed_player fileurl="' . esc_attr( $url ) . '"]' );
|
49 |
+
}
|
50 |
+
return $player;
|
51 |
+
} // End generate_player
|
52 |
+
|
53 |
+
public function product_attr( $value, $product_id, $attribute ) {
|
54 |
+
if (
|
55 |
+
! is_admin() &&
|
56 |
+
$this->_player_exists() &&
|
57 |
+
$this->_is_enabled() &&
|
58 |
+
'_wcmp_player_controls' == $attribute
|
59 |
+
) {
|
60 |
+
return 'button';
|
61 |
+
}
|
62 |
+
|
63 |
+
return $value;
|
64 |
+
} // End product_attr
|
65 |
+
|
66 |
+
public function global_attr( $value, $attribute ) {
|
67 |
+
if (
|
68 |
+
! is_admin() &&
|
69 |
+
$this->_player_exists() &&
|
70 |
+
$this->_is_enabled() &&
|
71 |
+
'_wcmp_player_controls' == $attribute
|
72 |
+
) {
|
73 |
+
return 'button';
|
74 |
+
}
|
75 |
+
|
76 |
+
return $value;
|
77 |
+
} // End global_attr
|
78 |
+
|
79 |
+
} // End WCMP_COMPACTAUDIOPLAYER_ADDON
|
80 |
+
}
|
81 |
+
|
82 |
+
new WCMP_COMPACTAUDIOPLAYER_ADDON( $wcmp );
|
|
|
|
addons/ap-cp-media-player.addon.php
CHANGED
@@ -1,130 +1,120 @@
|
|
1 |
-
<?php
|
2 |
-
if(!class_exists('WCMP_CPMEDIAPLAYER_ADDON'))
|
3 |
-
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
$this
|
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 |
-
if($this->_player_exists())
|
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 |
-
$attribute == '_wcmp_player_controls'
|
122 |
-
) return 'all';
|
123 |
-
|
124 |
-
return $value;
|
125 |
-
} // End global_attr
|
126 |
-
|
127 |
-
} // End WCMP_CPMEDIAPLAYER_ADDON
|
128 |
-
}
|
129 |
-
|
130 |
-
new WCMP_CPMEDIAPLAYER_ADDON($wcmp);
|
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' ) . '>' . esc_html( $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' )
|
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'] ) ) {
|
72 |
+
update_option( 'wcmp_addon_player', sanitize_text_field( wp_unslash( $_POST['wcmp_addon_player'] ) ) );
|
73 |
+
} else {
|
74 |
+
delete_option( 'wcmp_addon_player' );
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( isset( $_POST['wcmp_cpmediaplayer_addon_skin'] ) ) {
|
78 |
+
$this->_set_skin( sanitize_text_field( wp_unslash( $_POST['wcmp_cpmediaplayer_addon_skin'] ) ) );
|
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(), '1.0.178' );
|
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 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addons/ap-html5-audio-player.addon.php
CHANGED
@@ -1,110 +1,109 @@
|
|
1 |
-
<?php
|
2 |
-
if(!class_exists('WCMP_HTML5AUDIOPLAYER_ADDON'))
|
3 |
-
{
|
4 |
-
|
5 |
-
|
6 |
-
private $
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
$this
|
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 |
-
new WCMP_HTML5AUDIOPLAYER_ADDON($wcmp);
|
1 |
+
<?php
|
2 |
+
if ( ! class_exists( 'WCMP_HTML5AUDIOPLAYER_ADDON' ) ) {
|
3 |
+
class WCMP_HTML5AUDIOPLAYER_ADDON {
|
4 |
+
|
5 |
+
private $_wcmp;
|
6 |
+
private $_player_flag = false;
|
7 |
+
|
8 |
+
public function __construct( $wcmp ) {
|
9 |
+
$this->_wcmp = $wcmp;
|
10 |
+
add_action( 'wcmp_addon_general_settings', array( $this, 'general_settings' ) );
|
11 |
+
add_action( 'wcmp_save_setting', array( $this, 'save_general_settings' ) );
|
12 |
+
add_filter( 'wcmp_audio_tag', array( $this, 'generate_player' ), 99, 4 );
|
13 |
+
add_filter( 'wcmp_widget_audio_tag', array( $this, 'generate_player' ), 99, 4 );
|
14 |
+
add_filter( 'wcmp_product_attr', array( $this, 'product_attr' ), 99, 3 );
|
15 |
+
add_filter( 'wcmp_global_attr', array( $this, 'global_attr' ), 99, 2 );
|
16 |
+
add_action( 'wp_footer', array( $this, 'add_script' ) );
|
17 |
+
} // End __construct
|
18 |
+
|
19 |
+
private function _player_exists() {
|
20 |
+
return class_exists( 'H5APPlayer\Template\Player' );
|
21 |
+
} // End _player_exists
|
22 |
+
|
23 |
+
private function _is_enabled() {
|
24 |
+
return get_option( 'wcmp_addon_player' ) == 'html5audioplayer';
|
25 |
+
} // End _is_enabled
|
26 |
+
|
27 |
+
public function general_settings() {
|
28 |
+
$enabled = ( $this->_player_exists() && $this->_is_enabled() );
|
29 |
+
|
30 |
+
print '<tr><td><input aria-label="' . esc_attr__( 'Use HTML5 Audio Player instead of the current plugin players', 'music-player-for-woocommerce' ) . '" type="radio" value="html5audioplayer" name="wcmp_addon_player" ' . ( $enabled ? 'CHECKED' : '' ) . ( $this->_player_exists() ? '' : ' DISABLED' ) . ' class="wcmp_radio"></td><td width="100%"><b>' . esc_html__( 'Use "HTML5 Audio Player" instead of the current plugin players', 'music-player-for-woocommerce' ) . '</b><br><i>' .
|
31 |
+
( $this->_player_exists()
|
32 |
+
? __( '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' )
|
33 |
+
: esc_html__( 'The "HTML5 Audio Player" plugin is not installed on your WordPress.', 'music-player-for-woocommerce' )
|
34 |
+
)
|
35 |
+
. '</i></td></tr>';
|
36 |
+
} // End general_settings
|
37 |
+
|
38 |
+
public function save_general_settings() {
|
39 |
+
if ( $this->_player_exists() ) {
|
40 |
+
if ( isset( $_POST['wcmp_addon_player'] ) ) {
|
41 |
+
update_option( 'wcmp_addon_player', sanitize_text_field( wp_unslash( $_POST['wcmp_addon_player'] ) ) );
|
42 |
+
} else {
|
43 |
+
delete_option( 'wcmp_addon_player' );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
} // End save_general_settings
|
47 |
+
|
48 |
+
public function generate_player( $player, $product_id, $file_index, $url ) {
|
49 |
+
if ( $this->_player_exists() && $this->_is_enabled() ) {
|
50 |
+
wp_enqueue_style( 'wcmp-ap-html5-audio-player-style', plugin_dir_url( __FILE__ ) . 'ap-html5-audio-player/style.css', array(), '1.0.178' );
|
51 |
+
$this->_player_flag = true;
|
52 |
+
$d = '';
|
53 |
+
if ( preg_match( '/data-duration="[^"]+"/', $player, $matches ) ) {
|
54 |
+
$d = $matches[0];
|
55 |
+
}
|
56 |
+
|
57 |
+
return str_replace(
|
58 |
+
'<audio',
|
59 |
+
'<audio ' . $d . ' ',
|
60 |
+
H5APPlayer\Template\Player::html(
|
61 |
+
array(
|
62 |
+
'template' => array(
|
63 |
+
'attr' => '',
|
64 |
+
'width' => 'auto',
|
65 |
+
'source' => $url,
|
66 |
+
),
|
67 |
+
)
|
68 |
+
)
|
69 |
+
);
|
70 |
+
}
|
71 |
+
return $player;
|
72 |
+
} // End generate_player
|
73 |
+
|
74 |
+
public function product_attr( $value, $product_id, $attribute ) {
|
75 |
+
if (
|
76 |
+
! is_admin() &&
|
77 |
+
$this->_player_exists() &&
|
78 |
+
$this->_is_enabled() &&
|
79 |
+
'_wcmp_player_controls' == $attribute
|
80 |
+
) {
|
81 |
+
return 'all';
|
82 |
+
}
|
83 |
+
|
84 |
+
return $value;
|
85 |
+
} // End product_attr
|
86 |
+
|
87 |
+
public function global_attr( $value, $attribute ) {
|
88 |
+
if (
|
89 |
+
! is_admin() &&
|
90 |
+
$this->_player_exists() &&
|
91 |
+
$this->_is_enabled() &&
|
92 |
+
'_wcmp_player_controls' == $attribute
|
93 |
+
) {
|
94 |
+
return 'all';
|
95 |
+
}
|
96 |
+
|
97 |
+
return $value;
|
98 |
+
} // End global_attr
|
99 |
+
|
100 |
+
public function add_script() {
|
101 |
+
if ( $this->_player_flag ) {
|
102 |
+
print '<script>jQuery("audio[data-duration]").on("timeupdate", function(){var d = jQuery(this).data("duration"), c = jQuery(this).closest(".plyr--audio"); if(c.length) c.find(".plyr__time--duration").html(d);})</script>';
|
103 |
+
}
|
104 |
+
} // End add_script
|
105 |
+
|
106 |
+
} // End WCMP_HTML5AUDIOPLAYER_ADDON
|
107 |
+
}
|
108 |
+
|
109 |
+
new WCMP_HTML5AUDIOPLAYER_ADDON( $wcmp );
|
|
addons/ap-mp3-jplayer.addon.php
CHANGED
@@ -1,91 +1,89 @@
|
|
1 |
-
<?php
|
2 |
-
if(!class_exists('WCMP_MP3JPLAYER_ADDON'))
|
3 |
-
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
$this
|
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 |
-
new WCMP_MP3JPLAYER_ADDON($wcmp);
|
1 |
+
<?php
|
2 |
+
if ( ! class_exists( 'WCMP_MP3JPLAYER_ADDON' ) ) {
|
3 |
+
class WCMP_MP3JPLAYER_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 class_exists( 'MP3j_Front' );
|
19 |
+
} // End _player_exists
|
20 |
+
|
21 |
+
private function _is_enabled() {
|
22 |
+
return get_option( 'wcmp_addon_player' ) == 'mp3jplayer';
|
23 |
+
} // End _is_enabled
|
24 |
+
|
25 |
+
public function general_settings() {
|
26 |
+
$enabled = ( $this->_player_exists() && $this->_is_enabled() );
|
27 |
+
|
28 |
+
print '<tr><td><input aria-label="' . esc_attr__( 'Use MP3 jPlayer instead of the current plugin players', 'music-player-for-woocommerce' ) . '" type="radio" value="mp3jplayer" name="wcmp_addon_player" ' . ( $enabled ? 'CHECKED' : '' ) . ( $this->_player_exists() ? '' : ' DISABLED' ) . ' class="wcmp_radio"></td><td width="100%"><b>' . esc_html__( 'Use "MP3 jPlayer" instead of the current plugin players', 'music-player-for-woocommerce' ) . '</b><br><i>' .
|
29 |
+
( $this->_player_exists()
|
30 |
+
? __( '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' )
|
31 |
+
: esc_html__( 'The "MP3 jPlayer" plugin is not installed on your WordPress.', 'music-player-for-woocommerce' )
|
32 |
+
)
|
33 |
+
. '</i></td></tr>';
|
34 |
+
} // End general_settings
|
35 |
+
|
36 |
+
public function save_general_settings() {
|
37 |
+
if ( $this->_player_exists() ) {
|
38 |
+
if ( isset( $_POST['wcmp_addon_player'] ) ) {
|
39 |
+
update_option( 'wcmp_addon_player', sanitize_text_field( wp_unslash( $_POST['wcmp_addon_player'] ) ) );
|
40 |
+
} else {
|
41 |
+
delete_option( 'wcmp_addon_player' );
|
42 |
+
}
|
43 |
+
}
|
44 |
+
} // End save_general_settings
|
45 |
+
|
46 |
+
public function generate_player( $player, $product_id, $file_index, $url ) {
|
47 |
+
if ( $this->_player_exists() && $this->_is_enabled() ) {
|
48 |
+
wp_enqueue_style( 'wcmp-ap-mp3-jplayer-style', plugin_dir_url( __FILE__ ) . 'ap-mp3-jplayer/style.css', array(), '1.0.178' );
|
49 |
+
if ( ! preg_match( '/^http(s?)\:/i', $url ) && isset( $_SERVER['HTTP_HOST'] ) ) {
|
50 |
+
$url = 'http' . ( is_ssl() ? 's' : '' ) . '://' . sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) . $url;
|
51 |
+
}
|
52 |
+
if ( ! preg_match( '/\.mp3$/i', $url ) ) {
|
53 |
+
$url .= ( strpos( $url, '?' ) === false ? '?' : '&' ) . 'file.mp3';
|
54 |
+
}
|
55 |
+
return do_shortcode( '[mp3-jplayer tracks="' . str_replace( '"', '\"', $url ) . '" title="" width="100%" style="fullbars notitle nopopoutbutton" height="30px"]' );
|
56 |
+
}
|
57 |
+
return $player;
|
58 |
+
} // End generate_player
|
59 |
+
|
60 |
+
public function product_attr( $value, $product_id, $attribute ) {
|
61 |
+
if (
|
62 |
+
! is_admin() &&
|
63 |
+
$this->_player_exists() &&
|
64 |
+
$this->_is_enabled() &&
|
65 |
+
'_wcmp_player_controls' == $attribute
|
66 |
+
) {
|
67 |
+
return 'all';
|
68 |
+
}
|
69 |
+
|
70 |
+
return $value;
|
71 |
+
} // End product_attr
|
72 |
+
|
73 |
+
public function global_attr( $value, $attribute ) {
|
74 |
+
if (
|
75 |
+
! is_admin() &&
|
76 |
+
$this->_player_exists() &&
|
77 |
+
$this->_is_enabled() &&
|
78 |
+
'_wcmp_player_controls' == $attribute
|
79 |
+
) {
|
80 |
+
return 'all';
|
81 |
+
}
|
82 |
+
|
83 |
+
return $value;
|
84 |
+
} // End global_attr
|
85 |
+
|
86 |
+
} // End WCMP_MP3JPLAYER_ADDON
|
87 |
+
}
|
88 |
+
|
89 |
+
new WCMP_MP3JPLAYER_ADDON( $wcmp );
|
|
|
|
addons/dokan.addon.php
CHANGED
@@ -1,65 +1,57 @@
|
|
1 |
-
<?php
|
2 |
-
if(!class_exists('WCMP_DOKAN_ADDON'))
|
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 |
-
//******************** PRIVATE METHODS ************************
|
60 |
-
|
61 |
-
|
62 |
-
} // End WCMP_CLOUD_DRIVE_ADDON
|
63 |
-
}
|
64 |
-
|
65 |
-
new WCMP_DOKAN_ADDON($wcmp);
|
1 |
+
<?php
|
2 |
+
if ( ! class_exists( 'WCMP_DOKAN_ADDON' ) ) {
|
3 |
+
class WCMP_DOKAN_ADDON {
|
4 |
+
|
5 |
+
private $_wcmp;
|
6 |
+
|
7 |
+
public function __construct( $wcmp ) {
|
8 |
+
$this->_wcmp = $wcmp;
|
9 |
+
|
10 |
+
if ( get_option( 'wcmp_dokan_enabled', 1 ) && ! get_option( 'wcmp_dokan_hide_settings', 0 ) ) {
|
11 |
+
add_action( 'dokan_product_edit_after_main', array( $this, 'product_settings' ) );
|
12 |
+
add_action( 'dokan_process_product_meta', array( $this, 'save_product_settings' ) );
|
13 |
+
}
|
14 |
+
add_action( 'dokan_product_deleted', array( $this, 'delete_product' ) );
|
15 |
+
add_action( 'wcmp_addon_general_settings', array( $this, 'general_settings' ) );
|
16 |
+
add_action( 'wcmp_save_setting', array( $this, 'save_general_settings' ) );
|
17 |
+
} // End __construct
|
18 |
+
|
19 |
+
public function general_settings() {
|
20 |
+
$wcmp_dokan_enabled = get_option( 'wcmp_dokan_enabled', 1 );
|
21 |
+
$wcmp_dokan_hide_settings = get_option( 'wcmp_dokan_hide_settings', 0 );
|
22 |
+
print '<tr><td><input aria-label="' . esc_attr__( 'Activate the Dokan add-on', 'music-player-for-woocommerce' ) . '" type="checkbox" name="wcmp_dokan_enabled" ' . ( $wcmp_dokan_enabled ? 'CHECKED' : '' ) . '></td><td width="100%"><b>' . esc_html__( 'Activate the Dokan add-on', 'music-player-for-woocommerce' ) . '</b><br><i>' . esc_html__( 'If the "Dokan Multivendor" plugin is installed on the website, check the checkbox to allow vendors to configure their music players.', 'music-player-for-woocommerce' ) . '</i><br><br>
|
23 |
+
<input type="checkbox" aria-label="' . esc_attr__( 'Hide settings', 'music-player-for-woocommerce' ) . '" name="wcmp_dokan_hide_settings" ' . ( $wcmp_dokan_hide_settings ? 'CHECKED' : '' ) . '> ' . esc_html__( 'Hides the players settings from vendors interface.', 'music-player-for-woocommerce' ) . '</td></tr>';
|
24 |
+
} // End general_setting
|
25 |
+
|
26 |
+
public function save_general_settings() {
|
27 |
+
update_option( 'wcmp_dokan_enabled', ( ! empty( $_POST['wcmp_dokan_enabled'] ) ) ? 1 : 0 );
|
28 |
+
update_option( 'wcmp_dokan_hide_settings', ( ! empty( $_POST['wcmp_dokan_hide_settings'] ) ) ? 1 : 0 );
|
29 |
+
} // End save_general_settings
|
30 |
+
|
31 |
+
public function product_settings() {
|
32 |
+
global $wcmp_dokan_flag;
|
33 |
+
$wcmp_dokan_flag = true;
|
34 |
+
|
35 |
+
wp_enqueue_style( 'wcmp-dokan', plugin_dir_url( __FILE__ ) . 'dokan/style.css', array(), '1.0.178' );
|
36 |
+
include dirname( __FILE__ ) . '/dokan/player_options.php';
|
37 |
+
} // End product_settings
|
38 |
+
|
39 |
+
public function save_product_settings( $post_id ) {
|
40 |
+
global $wcmp_dokan_flag;
|
41 |
+
$wcmp_dokan_flag = true;
|
42 |
+
|
43 |
+
$post = get_post( $post_id );
|
44 |
+
$this->_wcmp->save_post( $post_id, $post, true );
|
45 |
+
} // End save_product_settings
|
46 |
+
|
47 |
+
public function delete_product( $post_id ) {
|
48 |
+
$this->_wcmp->delete_post( $post_id );
|
49 |
+
} // End delete_product
|
50 |
+
|
51 |
+
// ******************** PRIVATE METHODS ************************
|
52 |
+
|
53 |
+
|
54 |
+
} // End WCMP_CLOUD_DRIVE_ADDON
|
55 |
+
}
|
56 |
+
|
57 |
+
new WCMP_DOKAN_ADDON( $wcmp );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addons/wcfm.addon.php
CHANGED
@@ -1,89 +1,93 @@
|
|
1 |
-
<?php
|
2 |
-
if(!class_exists('WCMP_WCFM_ADDON'))
|
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 |
-
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! class_exists( 'WCMP_WCFM_ADDON' ) ) {
|
3 |
+
class WCMP_WCFM_ADDON {
|
4 |
+
|
5 |
+
private $_wcmp;
|
6 |
+
|
7 |
+
public function __construct( $wcmp ) {
|
8 |
+
$this->_wcmp = $wcmp;
|
9 |
+
|
10 |
+
if ( get_option( 'wcmp_wcfm_enabled', 1 ) && ! get_option( 'wcmp_wcfm_hide_settings', 0 ) ) {
|
11 |
+
add_action( 'after_wcfm_products_downloadable', array( $this, 'product_settings' ), 10, 2 );
|
12 |
+
add_action( 'save_post_product', array( $this, 'save_product_settings' ), 10, 3 );
|
13 |
+
}
|
14 |
+
add_action( 'wp_ajax_delete_wcfm_product', array( $this, 'delete_product' ) );
|
15 |
+
add_action( 'wcmp_addon_general_settings', array( $this, 'general_settings' ) );
|
16 |
+
add_action( 'wcmp_save_setting', array( $this, 'save_general_settings' ) );
|
17 |
+
} // End __construct
|
18 |
+
|
19 |
+
private function recursive_sanitize_text_field( $array ) {
|
20 |
+
foreach ( $array as $key => &$value ) {
|
21 |
+
if ( is_array( $value ) ) {
|
22 |
+
$value = $this->recursive_sanitize_text_field( $value );
|
23 |
+
} else {
|
24 |
+
$value = sanitize_text_field( wp_unslash( $value ) );
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return $array;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function general_settings() {
|
32 |
+
$wcmp_wcfm_enabled = get_option( 'wcmp_wcfm_enabled', 1 );
|
33 |
+
$wcmp_wcfm_hide_settings = get_option( 'wcmp_wcfm_hide_settings', 0 );
|
34 |
+
print '<tr><td><input aria-label="' . esc_attr__( 'Activate the WCFM add-on', 'music-player-for-woocommerce' ) . '" type="checkbox" name="wcmp_wcfm_enabled" ' . ( $wcmp_wcfm_enabled ? 'CHECKED' : '' ) . '></td><td width="100%"><b>' . esc_html__( 'Activate the WCFM add-on', 'music-player-for-woocommerce' ) . '</b><br><i>' . esc_html__( 'If the "WCFM - Marketplace" plugin is installed on the website, check the checkbox to allow vendors to configure their music players.', 'music-player-for-woocommerce' ) . '</i><br><br>
|
35 |
+
<input type="checkbox" aria-label="' . esc_attr__( 'Hide settings', 'music-player-for-woocommerce' ) . '" name="wcmp_wcfm_hide_settings" ' . ( $wcmp_wcfm_hide_settings ? 'CHECKED' : '' ) . '> ' . esc_html__( 'Hides the players settings from vendors interface.', 'music-player-for-woocommerce' ) . '</td></tr>';
|
36 |
+
} // End general_settings
|
37 |
+
|
38 |
+
public function save_general_settings() {
|
39 |
+
update_option( 'wcmp_wcfm_enabled', ( ! empty( $_POST['wcmp_wcfm_enabled'] ) ) ? 1 : 0 );
|
40 |
+
update_option( 'wcmp_wcfm_hide_settings', ( ! empty( $_POST['wcmp_wcfm_hide_settings'] ) ) ? 1 : 0 );
|
41 |
+
} // End save_general_settings
|
42 |
+
|
43 |
+
public function product_settings( $product_id, $product_type ) {
|
44 |
+
global $wcmp_wcfm_flag;
|
45 |
+
$wcmp_wcfm_flag = true;
|
46 |
+
|
47 |
+
$post = get_post( $product_id );
|
48 |
+
wp_enqueue_style( 'wcmp-wcfm-css', plugin_dir_url( __FILE__ ) . 'wcfm/style.css', array(), '1.0.178' );
|
49 |
+
wp_enqueue_script( 'wcmp-wcfm-js', plugin_dir_url( __FILE__ ) . 'wcfm/script.js', array(), '1.0.178' );
|
50 |
+
?>
|
51 |
+
<div class="page_collapsible simple variable grouped" id="wcfm_products_manage_form_wcmp_head"><label class="wcfmfa fa-object-group"></label><?php esc_html_e( 'Music Player', 'music-player-for-woocommerce' ); ?><span></span></div>
|
52 |
+
<div class="wcfm-container simple variable grouped">
|
53 |
+
<div id="wcfm_products_manage_form_wcmp_expander" class="wcfm-content">
|
54 |
+
<input type="hidden" name="wcmp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wcmp_updating_product' ) ); ?>" />
|
55 |
+
<?php
|
56 |
+
include_once dirname( __FILE__ ) . '/../views/player_options.php';
|
57 |
+
?>
|
58 |
+
</div>
|
59 |
+
</div>
|
60 |
+
<!-- end collapsible -->
|
61 |
+
<div class="wcfm_clearfix"></div>
|
62 |
+
<?php
|
63 |
+
} // End product_settings
|
64 |
+
|
65 |
+
public function save_product_settings( $post_id, $post, $update ) {
|
66 |
+
if ( ! empty( $_POST['wcfm_products_manage_form'] ) ) {
|
67 |
+
global $wcmp_wcfm_flag;
|
68 |
+
$wcmp_wcfm_flag = true;
|
69 |
+
$arr = wp_parse_args( is_array( $_POST['wcfm_products_manage_form'] ) ? $this->recursive_sanitize_text_field( $_POST['wcfm_products_manage_form'] ) : sanitize_text_field( wp_unslash( $_POST['wcfm_products_manage_form'] ) ) );
|
70 |
+
if ( ! empty( $arr ) ) {
|
71 |
+
$_POST = array_replace_recursive( $_POST, $arr );
|
72 |
+
$_REQUEST = array_replace_recursive( $_REQUEST, $arr );
|
73 |
+
|
74 |
+
$post = wc_get_product( $post_id );
|
75 |
+
$this->_wcmp->save_post( $post_id, $post, true );
|
76 |
+
}
|
77 |
+
}
|
78 |
+
} // End save_product_settings
|
79 |
+
|
80 |
+
public function delete_product() {
|
81 |
+
$proid = isset( $_POST['proid'] ) && is_numeric( $_POST['proid'] ) ? intval( $_POST['proid'] ) : 0;
|
82 |
+
if ( $proid ) {
|
83 |
+
$this->_wcmp->delete_post( $proid );
|
84 |
+
}
|
85 |
+
} // End delete_product
|
86 |
+
|
87 |
+
// ******************** PRIVATE METHODS ************************
|
88 |
+
|
89 |
+
|
90 |
+
} // End WCMP_WCFM_ADDON
|
91 |
+
}
|
92 |
+
|
93 |
+
new WCMP_WCFM_ADDON( $wcmp );
|
addons/wcv.addon.php
CHANGED
@@ -1,54 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
if(!class_exists('WCMP_WCVENDORS_ADDON'))
|
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 |
-
add_action('wcv_delete_post', array($this, 'delete_product'));
|
28 |
-
add_action('wcmp_addon_general_settings', array($this, 'general_settings'));
|
29 |
-
add_action('wcmp_save_setting', array($this, 'save_general_settings'));
|
30 |
-
} // End __construct
|
31 |
-
|
32 |
-
public function general_settings()
|
33 |
-
|
34 |
-
$
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
new WCMP_WCVENDORS_ADDON($wcmp);
|
1 |
+
<?php
|
2 |
+
if ( ! class_exists( 'WCMP_WCVENDORS_ADDON' ) ) {
|
3 |
+
class WCMP_WCVENDORS_ADDON {
|
4 |
+
|
5 |
+
private $_wcmp;
|
6 |
+
|
7 |
+
public function __construct( $wcmp ) {
|
8 |
+
$this->_wcmp = $wcmp;
|
9 |
+
add_action(
|
10 |
+
'admin_init',
|
11 |
+
function() {
|
12 |
+
if ( get_current_user_id() ) {
|
13 |
+
$user = wp_get_current_user();
|
14 |
+
$roles = (array) $user->roles;
|
15 |
+
if ( in_array( 'vendor', $roles ) && class_exists( 'WC_Vendors' ) ) {
|
16 |
+
global $wcmp_wcv_flag;
|
17 |
+
$wcmp_wcv_flag = true;
|
18 |
+
if ( ! get_option( 'wcmp_wcv_enabled', 1 ) || get_option( 'wcmp_wcv_hide_settings', 0 ) ) {
|
19 |
+
remove_meta_box( 'wcmp_woocommerce_metabox', 'product', 'normal' );
|
20 |
+
}
|
21 |
+
}
|
22 |
+
}
|
23 |
+
},
|
24 |
+
99
|
25 |
+
);
|
26 |
+
|
27 |
+
add_action( 'wcv_delete_post', array( $this, 'delete_product' ) );
|
28 |
+
add_action( 'wcmp_addon_general_settings', array( $this, 'general_settings' ) );
|
29 |
+
add_action( 'wcmp_save_setting', array( $this, 'save_general_settings' ) );
|
30 |
+
} // End __construct
|
31 |
+
|
32 |
+
public function general_settings() {
|
33 |
+
$wcmp_wcv_enabled = get_option( 'wcmp_wcv_enabled', 1 );
|
34 |
+
$wcmp_wcv_hide_settings = get_option( 'wcmp_wcv_hide_settings', 0 );
|
35 |
+
print '<tr><td><input aria-label="' . esc_attr__( 'Activate the WC Vendors add-on', 'music-player-for-woocommerce' ) . '" type="checkbox" name="wcmp_wcv_enabled" ' . ( $wcmp_wcv_enabled ? 'CHECKED' : '' ) . '></td><td width="100%"><b>' . esc_html__( 'Activate the WC Vendors add-on (Experimental add-on)', 'music-player-for-woocommerce' ) . '</b><br><i>' . esc_html__( 'If the "WC Vendors" plugin is installed on the website, check the checkbox to allow vendors to configure their music players.', 'music-player-for-woocommerce' ) . '</i><br><br>
|
36 |
+
<input type="checkbox" aria-label="' . esc_attr__( 'Hide settings', 'music-player-for-woocommerce' ) . '" name="wcmp_wcv_hide_settings" ' . ( $wcmp_wcv_hide_settings ? 'CHECKED' : '' ) . '> ' . esc_html__( 'Hides the players settings from vendors interface.', 'music-player-for-woocommerce' ) . '</td></tr>';
|
37 |
+
} // End general_settings
|
38 |
+
|
39 |
+
public function save_general_settings() {
|
40 |
+
update_option( 'wcmp_wcv_enabled', ( ! empty( $_POST['wcmp_wcv_enabled'] ) ) ? 1 : 0 );
|
41 |
+
update_option( 'wcmp_wcv_hide_settings', ( ! empty( $_POST['wcmp_wcv_hide_settings'] ) ) ? 1 : 0 );
|
42 |
+
} // End save_general_settings
|
43 |
+
|
44 |
+
public function delete_product( $post_id ) {
|
45 |
+
$this->_wcmp->delete_post( $post_id );
|
46 |
+
} // End delete_product
|
47 |
+
|
48 |
+
} // End WCMP_WCVENDORS_ADDON
|
49 |
+
}
|
50 |
+
|
51 |
+
new WCMP_WCVENDORS_ADDON( $wcmp );
|
|
|
|
|
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wcmp.dwbooster.com
|
|
4 |
Tags:WooCommerce,music player,audio,music,song,player,audio player,media player,mp3,m3u,m3u8,wav,oga,ogg,dokan,wcfm
|
5 |
Requires at least: 3.5.0
|
6 |
Tested up to: 6.0
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -226,6 +226,10 @@ Each time save the data of a product, the files for demo are deleted and generat
|
|
226 |
|
227 |
== Changelog ==
|
228 |
|
|
|
|
|
|
|
|
|
229 |
= 1.0.177 =
|
230 |
|
231 |
* Implements the integration with Google Analytics 4.
|
4 |
Tags:WooCommerce,music player,audio,music,song,player,audio player,media player,mp3,m3u,m3u8,wav,oga,ogg,dokan,wcfm
|
5 |
Requires at least: 3.5.0
|
6 |
Tested up to: 6.0
|
7 |
+
Stable tag: 1.0.178
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
226 |
|
227 |
== Changelog ==
|
228 |
|
229 |
+
= 1.0.178 =
|
230 |
+
|
231 |
+
* Modifies the preload behavior to avoid affecting server performance.
|
232 |
+
|
233 |
= 1.0.177 =
|
234 |
|
235 |
* Implements the integration with Google Analytics 4.
|
wcmp.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Music Player for WooCommerce
|
4 |
Plugin URI: https://wcmp.dwbooster.com
|
5 |
-
Version: 1.0.
|
6 |
Text Domain: music-player-for-woocommerce
|
7 |
Author: CodePeople
|
8 |
Author URI: https://wcmp.dwbooster.com
|
@@ -47,6 +47,8 @@ if ( ! class_exists( 'WooCommerceMusicPlayer' ) ) {
|
|
47 |
|
48 |
private $_force_hook_title = 0;
|
49 |
|
|
|
|
|
50 |
/**
|
51 |
* WCMP constructor
|
52 |
*
|
@@ -134,6 +136,8 @@ if ( ! class_exists( 'WooCommerceMusicPlayer' ) ) {
|
|
134 |
}
|
135 |
|
136 |
if ( ! is_admin() ) {
|
|
|
|
|
137 |
// Define the shortcode for the playlist_widget
|
138 |
add_shortcode( 'wcmp-playlist', array( &$this, 'replace_playlist_shortcode' ) );
|
139 |
$this->_preview();
|
@@ -440,11 +444,11 @@ if ( ! class_exists( 'WooCommerceMusicPlayer' ) ) {
|
|
440 |
|
441 |
// Registering resources
|
442 |
wp_enqueue_style( 'wp-mediaelement' );
|
443 |
-
wp_enqueue_style( 'wp-mediaelement-skins', 'https://cdnjs.cloudflare.com/ajax/libs/mediaelement/2.23.5/mejs-skins.min.css', array(), '1.0.
|
444 |
-
wp_enqueue_style( 'wcmp-style', plugin_dir_url( __FILE__ ) . 'css/style.css', array(), '1.0.
|
445 |
wp_enqueue_script( 'jquery' );
|
446 |
wp_enqueue_script( 'wp-mediaelement' );
|
447 |
-
wp_enqueue_script( 'wcmp-script', plugin_dir_url( __FILE__ ) . 'js/public.js', array( 'jquery', 'wp-mediaelement' ), '1.0.
|
448 |
|
449 |
$play_all = $GLOBALS['WooCommerceMusicPlayer']->get_global_attr(
|
450 |
'_wcmp_play_all',
|
@@ -665,8 +669,8 @@ if ( ! class_exists( 'WooCommerceMusicPlayer' ) ) {
|
|
665 |
// Enqueue resources
|
666 |
|
667 |
$this->enqueue_resources();
|
668 |
-
wp_enqueue_style( 'wcmp-playlist-widget-style', plugin_dir_url( __FILE__ ) . 'widgets/playlist_widget/css/style.css', array(), '1.0.
|
669 |
-
wp_enqueue_script( 'wcmp-playlist-widget-script', plugin_dir_url( __FILE__ ) . 'widgets/playlist_widget/js/public.js', array(), '1.0.
|
670 |
wp_localize_script(
|
671 |
'wcmp-playlist-widget-script',
|
672 |
'wcmp_widget_settings',
|
@@ -826,6 +830,17 @@ if ( ! class_exists( 'WooCommerceMusicPlayer' ) ) {
|
|
826 |
return $allowedposttags;
|
827 |
} // End allowed_html_tags
|
828 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
829 |
// ******************** WOOCOMMERCE ACTIONS ************************
|
830 |
|
831 |
public function woocommerce_product_title( $title, $product ) {
|
@@ -864,6 +879,7 @@ if ( ! class_exists( 'WooCommerceMusicPlayer' ) ) {
|
|
864 |
// This option is only for compatibility with versions previous to 1.0.28
|
865 |
$GLOBALS['WooCommerceMusicPlayer']->get_global_attr( 'preload', 'none' )
|
866 |
);
|
|
|
867 |
|
868 |
return '<audio ' . (
|
869 |
(
|
2 |
/*
|
3 |
Plugin Name: Music Player for WooCommerce
|
4 |
Plugin URI: https://wcmp.dwbooster.com
|
5 |
+
Version: 1.0.178
|
6 |
Text Domain: music-player-for-woocommerce
|
7 |
Author: CodePeople
|
8 |
Author URI: https://wcmp.dwbooster.com
|
47 |
|
48 |
private $_force_hook_title = 0;
|
49 |
|
50 |
+
private $_preload_times = 0; // Multiple preloads with demo generators can affect the server performance
|
51 |
+
|
52 |
/**
|
53 |
* WCMP constructor
|
54 |
*
|
136 |
}
|
137 |
|
138 |
if ( ! is_admin() ) {
|
139 |
+
add_filter( 'wcmp_preload', array( $this, 'preload' ), 10, 2 );
|
140 |
+
|
141 |
// Define the shortcode for the playlist_widget
|
142 |
add_shortcode( 'wcmp-playlist', array( &$this, 'replace_playlist_shortcode' ) );
|
143 |
$this->_preview();
|
444 |
|
445 |
// Registering resources
|
446 |
wp_enqueue_style( 'wp-mediaelement' );
|
447 |
+
wp_enqueue_style( 'wp-mediaelement-skins', 'https://cdnjs.cloudflare.com/ajax/libs/mediaelement/2.23.5/mejs-skins.min.css', array(), '1.0.178' );
|
448 |
+
wp_enqueue_style( 'wcmp-style', plugin_dir_url( __FILE__ ) . 'css/style.css', array(), '1.0.178' );
|
449 |
wp_enqueue_script( 'jquery' );
|
450 |
wp_enqueue_script( 'wp-mediaelement' );
|
451 |
+
wp_enqueue_script( 'wcmp-script', plugin_dir_url( __FILE__ ) . 'js/public.js', array( 'jquery', 'wp-mediaelement' ), '1.0.178' );
|
452 |
|
453 |
$play_all = $GLOBALS['WooCommerceMusicPlayer']->get_global_attr(
|
454 |
'_wcmp_play_all',
|
669 |
// Enqueue resources
|
670 |
|
671 |
$this->enqueue_resources();
|
672 |
+
wp_enqueue_style( 'wcmp-playlist-widget-style', plugin_dir_url( __FILE__ ) . 'widgets/playlist_widget/css/style.css', array(), '1.0.178' );
|
673 |
+
wp_enqueue_script( 'wcmp-playlist-widget-script', plugin_dir_url( __FILE__ ) . 'widgets/playlist_widget/js/public.js', array(), '1.0.178' );
|
674 |
wp_localize_script(
|
675 |
'wcmp-playlist-widget-script',
|
676 |
'wcmp_widget_settings',
|
830 |
return $allowedposttags;
|
831 |
} // End allowed_html_tags
|
832 |
|
833 |
+
public function preload ( $preload, $audio_url ) {
|
834 |
+
$result = $preload;
|
835 |
+
if ( strpos( $audio_url, 'wcmp-action=play' ) !== false ) {
|
836 |
+
if ( $this->_preload_times ) {
|
837 |
+
$result = 'none';
|
838 |
+
}
|
839 |
+
$this->_preload_times++;
|
840 |
+
}
|
841 |
+
return $result;
|
842 |
+
} // End preload
|
843 |
+
|
844 |
// ******************** WOOCOMMERCE ACTIONS ************************
|
845 |
|
846 |
public function woocommerce_product_title( $title, $product ) {
|
879 |
// This option is only for compatibility with versions previous to 1.0.28
|
880 |
$GLOBALS['WooCommerceMusicPlayer']->get_global_attr( 'preload', 'none' )
|
881 |
);
|
882 |
+
$preload = apply_filters( 'wcmp_preload', $preload, $audio_url );
|
883 |
|
884 |
return '<audio ' . (
|
885 |
(
|