Music Player for WooCommerce - Version 1.0.178

Version Description

  • Modifies the preload behavior to avoid affecting server performance.
Download this release

Release Info

Developer codepeople
Plugin Icon 128x128 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 CHANGED
@@ -1,84 +1,82 @@
1
- <?php
2
- if(!class_exists('WCMP_COMPACTAUDIOPLAYER_ADDON'))
3
- {
4
- class WCMP_COMPACTAUDIOPLAYER_ADDON
5
- {
6
- private $_wcmp;
7
-
8
- function __construct($wcmp)
9
- {
10
- $this->_wcmp = $wcmp;
11
- add_action('wcmp_addon_general_settings', array($this, 'general_settings'));
12
- add_action('wcmp_save_setting', array($this, 'save_general_settings'));
13
- add_filter('wcmp_audio_tag', array($this, 'generate_player'), 99, 4);
14
- add_filter('wcmp_widget_audio_tag', array($this, 'generate_player'), 99, 4);
15
- add_filter('wcmp_product_attr', array($this, 'product_attr'), 99, 3);
16
- add_filter('wcmp_global_attr', array($this, 'global_attr'), 99, 2);
17
- } // End __construct
18
-
19
- private function _player_exists()
20
- {
21
- return defined('SC_AUDIO_PLUGIN_VERSION');
22
- } // End _player_exists
23
-
24
- private function _is_enabled()
25
- {
26
- return get_option('wcmp_addon_player') == 'compactaudioplayer';
27
- } // End _is_enabled
28
-
29
- public function general_settings()
30
- {
31
- $enabled = ($this->_player_exists() && $this->_is_enabled());
32
-
33
- 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>'.__('Use "Compact Audio Player" instead of the current plugin players', 'music-player-for-woocommerce').'</b><br><i>'.
34
- ($this->_player_exists()
35
- ? __('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')
36
- : __('The "Compact WP Audio Player" plugin is not installed on your WordPress.', 'music-player-for-woocommerce')
37
- )
38
- .'</i></td></tr>';
39
- } // End general_settings
40
-
41
- public function save_general_settings()
42
- {
43
- if($this->_player_exists())
44
- {
45
- if(isset($_POST['wcmp_addon_player'])) update_option('wcmp_addon_player', sanitize_text_field($_POST['wcmp_addon_player']));
46
- else delete_option('wcmp_addon_player');
47
- }
48
- } // End save_general_settings
49
-
50
- public function generate_player($player, $product_id, $file_index, $url)
51
- {
52
- if($this->_player_exists() && $this->_is_enabled())
53
- return do_shortcode('[sc_embed_player fileurl="'.esc_attr($url).'"]');
54
- return $player;
55
- } // End generate_player
56
-
57
- public function product_attr($value, $product_id, $attribute)
58
- {
59
- if(
60
- !is_admin() &&
61
- $this->_player_exists() &&
62
- $this->_is_enabled() &&
63
- $attribute == '_wcmp_player_controls'
64
- ) return 'button';
65
-
66
- return $value;
67
- } // End product_attr
68
-
69
- public function global_attr($value, $attribute)
70
- {
71
- if(
72
- !is_admin() &&
73
- $this->_player_exists() &&
74
- $this->_is_enabled() &&
75
- $attribute == '_wcmp_player_controls'
76
- ) return 'button';
77
-
78
- return $value;
79
- } // End global_attr
80
-
81
- } // End WCMP_COMPACTAUDIOPLAYER_ADDON
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
- class WCMP_CPMEDIAPLAYER_ADDON
5
- {
6
- private $_wcmp;
7
-
8
- function __construct($wcmp)
9
- {
10
- $this->_wcmp = $wcmp;
11
- add_action('wcmp_addon_general_settings', array($this, 'general_settings'));
12
- add_action('wcmp_save_setting', array($this, 'save_general_settings'));
13
- add_filter('wcmp_audio_tag', array($this, 'generate_player'), 99, 4);
14
- add_filter('wcmp_widget_audio_tag', array($this, 'generate_player'), 99, 4);
15
- add_filter('wcmp_product_attr', array($this, 'product_attr'), 99, 3);
16
- add_filter('wcmp_global_attr', array($this, 'global_attr'), 99, 2);
17
- } // End __construct
18
-
19
- private function _player_exists()
20
- {
21
- return defined('CPMP_VERSION');
22
- } // End _player_exists
23
-
24
- private function _is_enabled()
25
- {
26
- return get_option('wcmp_addon_player') == 'cpmediaplayer';
27
- } // End _is_enabled
28
-
29
- private function _load_skins($selected_option)
30
- {
31
- // Skins
32
- $options = '';
33
- if(defined('CPMP_PLUGIN_DIR'))
34
- {
35
- $skins = array();
36
- $skin_dir = CPMP_PLUGIN_DIR.'/skins';
37
- if(file_exists($skin_dir))
38
- {
39
- $d = dir($skin_dir);
40
- while (false !== ($entry = $d->read()))
41
- {
42
- if($entry != '.' && $entry != '..' && is_dir($skin_dir.'/'.$entry))
43
- {
44
- $this_skin = $skin_dir.'/'.$entry.'/';
45
- if(file_exists($this_skin))
46
- {
47
- $skin_data = parse_ini_file($this_skin.'config.ini', true);
48
- $options .='<option value="'.$skin_data['id'].'" '.($skin_data['id'] == $selected_option ? 'SELECTED' : '').'>'.esc_html($skin_data['name']).'</option>';
49
- }
50
- }
51
- }
52
- $d->close();
53
- }
54
- }
55
- return $options;
56
- } // End _load_skins
57
-
58
- private function _get_skin()
59
- {
60
- return get_option('wcmp_cpmediaplayer_addon_skin', 'classic-skin');
61
- } // End _get_skin
62
-
63
- private function _set_skin($v)
64
- {
65
- update_option('wcmp_cpmediaplayer_addon_skin', $v);
66
- } // End _set_skin
67
-
68
- public function general_settings()
69
- {
70
- $enabled = ($this->_player_exists() && $this->_is_enabled());
71
-
72
- 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>'.__('Use "CP Media Player" instead of the current plugin players', 'music-player-for-woocommerce').'</b><br>
73
- '.__('Select player skin', 'music-player-for-woocommerce').': <select name="wcmp_cpmediaplayer_addon_skin" '.($this->_player_exists() ? '' : ' DISABLED').'>'.$this->_load_skins($this->_get_skin()).'</select>
74
- <br><i>'.
75
- ($this->_player_exists()
76
- ? __('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')
77
- : __('The "CP Media Player" plugin is not installed on your WordPress.', 'music-player-for-woocommerce')
78
- )
79
- .'</i></td></tr>';
80
- } // End general_settings
81
-
82
- public function save_general_settings()
83
- {
84
- if($this->_player_exists())
85
- {
86
- if(isset($_POST['wcmp_addon_player'])) update_option('wcmp_addon_player', sanitize_text_field($_POST['wcmp_addon_player']));
87
- else delete_option('wcmp_addon_player');
88
-
89
- if(isset($_POST['wcmp_cpmediaplayer_addon_skin'])) $this->_set_skin(sanitize_text_field($_POST['wcmp_cpmediaplayer_addon_skin']));
90
- }
91
- } // End save_general_settings
92
-
93
- public function generate_player($player, $product_id, $file_index, $url)
94
- {
95
- if($this->_player_exists() && $this->_is_enabled())
96
- {
97
- wp_enqueue_style('wcmp-ap-cp-media-player-style', plugin_dir_url(__FILE__).'ap-cp-media-player/style.css');
98
- return do_shortcode('[cpm-player skin="'.esc_attr($this->_get_skin()).'" playlist="false" type="audio"][cpm-item file="'.esc_attr($url).'"][/cpm-player]');
99
- }
100
- return $player;
101
- } // End generate_player
102
-
103
- public function product_attr($value, $product_id, $attribute)
104
- {
105
- if(
106
- !is_admin() &&
107
- $this->_player_exists() &&
108
- $this->_is_enabled() &&
109
- $attribute == '_wcmp_player_controls'
110
- ) return 'all';
111
-
112
- return $value;
113
- } // End product_attr
114
-
115
- public function global_attr($value, $attribute)
116
- {
117
- if(
118
- !is_admin() &&
119
- $this->_player_exists() &&
120
- $this->_is_enabled() &&
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
- class WCMP_HTML5AUDIOPLAYER_ADDON
5
- {
6
- private $_wcmp;
7
- private $_player_flag = false;
8
-
9
- function __construct($wcmp)
10
- {
11
- $this->_wcmp = $wcmp;
12
- add_action('wcmp_addon_general_settings', array($this, 'general_settings'));
13
- add_action('wcmp_save_setting', array($this, 'save_general_settings'));
14
- add_filter('wcmp_audio_tag', array($this, 'generate_player'), 99, 4);
15
- add_filter('wcmp_widget_audio_tag', array($this, 'generate_player'), 99, 4);
16
- add_filter('wcmp_product_attr', array($this, 'product_attr'), 99, 3);
17
- add_filter('wcmp_global_attr', array($this, 'global_attr'), 99, 2);
18
- add_action('wp_footer', array($this, 'add_script'));
19
- } // End __construct
20
-
21
- private function _player_exists()
22
- {
23
- return class_exists('H5APPlayer\Template\Player');
24
- } // End _player_exists
25
-
26
- private function _is_enabled()
27
- {
28
- return get_option('wcmp_addon_player') == 'html5audioplayer';
29
- } // End _is_enabled
30
-
31
- public function general_settings()
32
- {
33
- $enabled = ($this->_player_exists() && $this->_is_enabled());
34
-
35
- 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>'.__('Use "HTML5 Audio Player" instead of the current plugin players', 'music-player-for-woocommerce').'</b><br><i>'.
36
- ($this->_player_exists()
37
- ? __('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')
38
- : __('The "HTML5 Audio Player" plugin is not installed on your WordPress.', 'music-player-for-woocommerce')
39
- )
40
- .'</i></td></tr>';
41
- } // End general_settings
42
-
43
- public function save_general_settings()
44
- {
45
- if($this->_player_exists())
46
- {
47
- if(isset($_POST['wcmp_addon_player'])) update_option('wcmp_addon_player', sanitize_text_field($_POST['wcmp_addon_player']));
48
- else delete_option('wcmp_addon_player');
49
- }
50
- } // End save_general_settings
51
-
52
- public function generate_player($player, $product_id, $file_index, $url)
53
- {
54
- if($this->_player_exists() && $this->_is_enabled())
55
- {
56
- wp_enqueue_style('wcmp-ap-html5-audio-player-style', plugin_dir_url(__FILE__).'ap-html5-audio-player/style.css');
57
- $this->_player_flag = true;
58
- $d = '';
59
- if(preg_match('/data-duration="[^"]+"/', $player,$matches))
60
- {
61
- $d = $matches[0];
62
- }
63
-
64
- return str_replace('<audio', '<audio '.$d.' ', H5APPlayer\Template\Player::html(
65
- [
66
- 'template' => [
67
- 'attr' => '',
68
- 'width' => 'auto',
69
- 'source' => $url
70
- ]
71
- ]
72
- ));
73
- }
74
- return $player;
75
- } // End generate_player
76
-
77
- public function product_attr($value, $product_id, $attribute)
78
- {
79
- if(
80
- !is_admin() &&
81
- $this->_player_exists() &&
82
- $this->_is_enabled() &&
83
- $attribute == '_wcmp_player_controls'
84
- ) return 'all';
85
-
86
- return $value;
87
- } // End product_attr
88
-
89
- public function global_attr($value, $attribute)
90
- {
91
- if(
92
- !is_admin() &&
93
- $this->_player_exists() &&
94
- $this->_is_enabled() &&
95
- $attribute == '_wcmp_player_controls'
96
- ) return 'all';
97
-
98
- return $value;
99
- } // End global_attr
100
-
101
- public function add_script()
102
- {
103
- if($this->_player_flag)
104
- 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>';
105
- } // End add_script
106
-
107
- } // End WCMP_HTML5AUDIOPLAYER_ADDON
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
- class WCMP_MP3JPLAYER_ADDON
5
- {
6
- private $_wcmp;
7
-
8
- function __construct($wcmp)
9
- {
10
- $this->_wcmp = $wcmp;
11
- add_action('wcmp_addon_general_settings', array($this, 'general_settings'));
12
- add_action('wcmp_save_setting', array($this, 'save_general_settings'));
13
- add_filter('wcmp_audio_tag', array($this, 'generate_player'), 99, 4);
14
- add_filter('wcmp_widget_audio_tag', array($this, 'generate_player'), 99, 4);
15
- add_filter('wcmp_product_attr', array($this, 'product_attr'), 99, 3);
16
- add_filter('wcmp_global_attr', array($this, 'global_attr'), 99, 2);
17
- } // End __construct
18
-
19
- private function _player_exists()
20
- {
21
- return class_exists('MP3j_Front');
22
- } // End _player_exists
23
-
24
- private function _is_enabled()
25
- {
26
- return get_option('wcmp_addon_player') == 'mp3jplayer';
27
- } // End _is_enabled
28
-
29
- public function general_settings()
30
- {
31
- $enabled = ($this->_player_exists() && $this->_is_enabled());
32
-
33
- 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>'.__('Use "MP3 jPlayer" instead of the current plugin players', 'music-player-for-woocommerce').'</b><br><i>'.
34
- ($this->_player_exists()
35
- ? __('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')
36
- : __('The "MP3 jPlayer" plugin is not installed on your WordPress.', 'music-player-for-woocommerce')
37
- )
38
- .'</i></td></tr>';
39
- } // End general_settings
40
-
41
- public function save_general_settings()
42
- {
43
- if($this->_player_exists())
44
- {
45
- if(isset($_POST['wcmp_addon_player'])) update_option('wcmp_addon_player', sanitize_text_field($_POST['wcmp_addon_player']));
46
- else delete_option('wcmp_addon_player');
47
- }
48
- } // End save_general_settings
49
-
50
- public function generate_player($player, $product_id, $file_index, $url)
51
- {
52
- if($this->_player_exists() && $this->_is_enabled())
53
- {
54
- wp_enqueue_style('wcmp-ap-mp3-jplayer-style', plugin_dir_url(__FILE__).'ap-mp3-jplayer/style.css');
55
- if(!preg_match('/^http(s?)\:/i', $url))
56
- $url = 'http'.(is_ssl() ? 's' : '' ).'://'.$_SERVER['HTTP_HOST'].$url;
57
- if(!preg_match('/\.mp3$/i', $url))
58
- $url .= (strpos($url, '?') === false ? '?' : '&').'file.mp3';
59
- return do_shortcode('[mp3-jplayer tracks="'.str_replace('"', '\"', $url).'" title="" width="100%" style="fullbars notitle nopopoutbutton" height="30px"]');
60
- }
61
- return $player;
62
- } // End generate_player
63
-
64
- public function product_attr($value, $product_id, $attribute)
65
- {
66
- if(
67
- !is_admin() &&
68
- $this->_player_exists() &&
69
- $this->_is_enabled() &&
70
- $attribute == '_wcmp_player_controls'
71
- ) return 'all';
72
-
73
- return $value;
74
- } // End product_attr
75
-
76
- public function global_attr($value, $attribute)
77
- {
78
- if(
79
- !is_admin() &&
80
- $this->_player_exists() &&
81
- $this->_is_enabled() &&
82
- $attribute == '_wcmp_player_controls'
83
- ) return 'all';
84
-
85
- return $value;
86
- } // End global_attr
87
-
88
- } // End WCMP_MP3JPLAYER_ADDON
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
- class WCMP_DOKAN_ADDON
5
- {
6
- private $_wcmp;
7
-
8
- function __construct($wcmp)
9
- {
10
- $this->_wcmp = $wcmp;
11
-
12
- if(get_option('wcmp_dokan_enabled', 1) && !get_option('wcmp_dokan_hide_settings', 0))
13
- {
14
- add_action('dokan_product_edit_after_main',array($this, 'product_settings'));
15
- add_action('dokan_process_product_meta',array($this, 'save_product_settings'));
16
- }
17
- add_action( 'dokan_product_deleted', array($this, 'delete_product'));
18
- add_action('wcmp_addon_general_settings', array($this, 'general_settings'));
19
- add_action('wcmp_save_setting', array($this, 'save_general_settings'));
20
- } // End __construct
21
-
22
- public function general_settings()
23
- {
24
- $wcmp_dokan_enabled = get_option('wcmp_dokan_enabled', 1);
25
- $wcmp_dokan_hide_settings = get_option('wcmp_dokan_hide_settings', 0);
26
- 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>'.__('Activate the Dokan add-on', 'music-player-for-woocommerce').'</b><br><i>'.__('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>
27
- <input type="checkbox" aria-label="'.esc_attr(__('Hide settings', 'music-player-for-woocommerce')).'" name="wcmp_dokan_hide_settings" '.($wcmp_dokan_hide_settings ? 'CHECKED' : '').'> '.__('Hides the players settings from vendors interface.', 'music-player-for-woocommerce').'</td></tr>';
28
- } // End general_setting
29
-
30
- public function save_general_settings()
31
- {
32
- update_option('wcmp_dokan_enabled', (!empty($_POST['wcmp_dokan_enabled'])) ? 1 : 0);
33
- update_option('wcmp_dokan_hide_settings', (!empty($_POST['wcmp_dokan_hide_settings'])) ? 1 : 0);
34
- } // End save_general_settings
35
-
36
- public function product_settings()
37
- {
38
- global $wcmp_dokan_flag;
39
- $wcmp_dokan_flag = true;
40
-
41
- wp_enqueue_style('wcmp-dokan', plugin_dir_url(__FILE__).'dokan/style.css');
42
- include dirname(__FILE__).'/dokan/player_options.php';
43
- } // End product_settings
44
-
45
- public function save_product_settings($post_id)
46
- {
47
- global $wcmp_dokan_flag;
48
- $wcmp_dokan_flag = true;
49
-
50
- $post = get_post($post_id);
51
- $this->_wcmp->save_post($post_id, $post, true);
52
- } // End save_product_settings
53
-
54
- public function delete_product($post_id)
55
- {
56
- $this->_wcmp->delete_post($post_id);
57
- } // End delete_product
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
- class WCMP_WCFM_ADDON
5
- {
6
- private $_wcmp;
7
-
8
- function __construct($wcmp)
9
- {
10
- $this->_wcmp = $wcmp;
11
-
12
- if(get_option('wcmp_wcfm_enabled', 1) && !get_option('wcmp_wcfm_hide_settings', 0))
13
- {
14
- add_action('after_wcfm_products_downloadable',array($this, 'product_settings'), 10, 2);
15
- add_action('save_post_product', array($this, 'save_product_settings'), 10, 3);
16
- }
17
- add_action('wp_ajax_delete_wcfm_product', array($this, 'delete_product'));
18
- add_action('wcmp_addon_general_settings', array($this, 'general_settings'));
19
- add_action('wcmp_save_setting', array($this, 'save_general_settings'));
20
- } // End __construct
21
-
22
- public function general_settings()
23
- {
24
- $wcmp_wcfm_enabled = get_option('wcmp_wcfm_enabled', 1);
25
- $wcmp_wcfm_hide_settings = get_option('wcmp_wcfm_hide_settings', 0);
26
- 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>'.__('Activate the WCFM add-on', 'music-player-for-woocommerce').'</b><br><i>'.__('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>
27
- <input type="checkbox" aria-label="'.esc_attr(__('Hide settings', 'music-player-for-woocommerce')).'" name="wcmp_wcfm_hide_settings" '.($wcmp_wcfm_hide_settings ? 'CHECKED' : '').'> '.__('Hides the players settings from vendors interface.', 'music-player-for-woocommerce').'</td></tr>';
28
- } // End general_settings
29
-
30
- public function save_general_settings()
31
- {
32
- update_option('wcmp_wcfm_enabled', (!empty($_POST['wcmp_wcfm_enabled'])) ? 1 : 0);
33
- update_option('wcmp_wcfm_hide_settings', (!empty($_POST['wcmp_wcfm_hide_settings'])) ? 1 : 0);
34
- } // End save_general_settings
35
-
36
- public function product_settings($product_id, $product_type)
37
- {
38
- global $wcmp_wcfm_flag;
39
- $wcmp_wcfm_flag = true;
40
-
41
- $post = get_post( $product_id );
42
- wp_enqueue_style('wcmp-wcfm-css', plugin_dir_url(__FILE__).'wcfm/style.css');
43
- wp_enqueue_script('wcmp-wcfm-js', plugin_dir_url(__FILE__).'wcfm/script.js');
44
- ?>
45
- <div class="page_collapsible simple variable grouped" id="wcfm_products_manage_form_wcmp_head"><label class="wcfmfa fa-object-group"></label><?php _e('Music Player', 'music-player-for-woocommerce'); ?><span></span></div>
46
- <div class="wcfm-container simple variable grouped">
47
- <div id="wcfm_products_manage_form_wcmp_expander" class="wcfm-content">
48
- <input type="hidden" name="wcmp_nonce" value="<?php echo wp_create_nonce('wcmp_updating_product'); ?>" />
49
- <?php
50
- include_once dirname(__FILE__).'/../views/player_options.php';
51
- ?>
52
- </div>
53
- </div>
54
- <!-- end collapsible -->
55
- <div class="wcfm_clearfix"></div>
56
- <?php
57
- } // End product_settings
58
-
59
- public function save_product_settings($post_id, $post, $update)
60
- {
61
- if(!empty($_POST['wcfm_products_manage_form']))
62
- {
63
- global $wcmp_wcfm_flag;
64
- $wcmp_wcfm_flag = true;
65
- $arr = wp_parse_args($_POST['wcfm_products_manage_form']);
66
- if(!empty($arr))
67
- {
68
- $_POST = array_replace_recursive($_POST, $arr);
69
- $_REQUEST = array_replace_recursive($_REQUEST, $arr);
70
-
71
- $post = wc_get_product( $post_id );
72
- $this->_wcmp->save_post($post_id, $post, true);
73
- }
74
- }
75
- } // End save_product_settings
76
-
77
- public function delete_product()
78
- {
79
- $proid = @intval($_POST['proid']);
80
- if($proid) $this->_wcmp->delete_post($proid);
81
- } // End delete_product
82
-
83
- //******************** PRIVATE METHODS ************************
84
-
85
-
86
- } // End WCMP_WCFM_ADDON
87
- }
88
-
89
- new WCMP_WCFM_ADDON($wcmp);
 
 
 
 
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
- class WCMP_WCVENDORS_ADDON
5
- {
6
- private $_wcmp;
7
-
8
- function __construct($wcmp)
9
- {
10
- $this->_wcmp = $wcmp;
11
- add_action('admin_init', 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
- {
17
- global $wcmp_wcv_flag;
18
- $wcmp_wcv_flag = true;
19
- if(!get_option('wcmp_wcv_enabled', 1) || get_option('wcmp_wcv_hide_settings', 0))
20
- {
21
- remove_meta_box('wcmp_woocommerce_metabox', 'product', 'normal');
22
- }
23
- }
24
- }
25
- },99);
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
- $wcmp_wcv_enabled = get_option('wcmp_wcv_enabled', 1);
35
- $wcmp_wcv_hide_settings = get_option('wcmp_wcv_hide_settings', 0);
36
- 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>'.__('Activate the WC Vendors add-on (Experimental add-on)', 'music-player-for-woocommerce').'</b><br><i>'.__('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>
37
- <input type="checkbox" aria-label="'.esc_attr(__('Hide settings', 'music-player-for-woocommerce')).'" name="wcmp_wcv_hide_settings" '.($wcmp_wcv_hide_settings ? 'CHECKED' : '').'> '.__('Hides the players settings from vendors interface.', 'music-player-for-woocommerce').'</td></tr>';
38
- } // End general_settings
39
-
40
- public function save_general_settings()
41
- {
42
- update_option('wcmp_wcv_enabled', (!empty($_POST['wcmp_wcv_enabled'])) ? 1 : 0);
43
- update_option('wcmp_wcv_hide_settings', (!empty($_POST['wcmp_wcv_hide_settings'])) ? 1 : 0);
44
- } // End save_general_settings
45
-
46
- public function delete_product($post_id)
47
- {
48
- $this->_wcmp->delete_post($post_id);
49
- } // End delete_product
50
-
51
- } // End WCMP_WCVENDORS_ADDON
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.177
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.177
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.177' );
444
- wp_enqueue_style( 'wcmp-style', plugin_dir_url( __FILE__ ) . 'css/style.css', array(), '1.0.177' );
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.177' );
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.177' );
669
- wp_enqueue_script( 'wcmp-playlist-widget-script', plugin_dir_url( __FILE__ ) . 'widgets/playlist_widget/js/public.js', array(), '1.0.177' );
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
  (