Soundy Background Music - Version 3.1

Version Description

   -    March 3rd, 2015 = * Media Library button calls now new WordPress File Uploader.

Download this release

Release Info

Developer bducouedic
Plugin Icon 128x128 Soundy Background Music
Version 3.1
Comparing to
See all releases

Code changes from version 3.0 to 3.1

Files changed (3) hide show
  1. js/back-end.js +71 -60
  2. readme.txt +5 -2
  3. soundy.php +7 -7
js/back-end.js CHANGED
@@ -152,8 +152,36 @@ war_SoundyAdmin.prototype.initSoundTrack = function()
152
 
153
  jQuery( '#war_soundy_audio_file_url' ).change( function()
154
  {
155
- jQuery( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked', true );
156
- jQuery( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  } );
158
 
159
  jQuery( '#war_soundy_audio_type' ).change( function()
@@ -264,6 +292,12 @@ war_SoundyAdmin.prototype.initAudioTitle = function()
264
  jQuery( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
265
  } );
266
 
 
 
 
 
 
 
267
  jQuery( '#war_soundy_audio_title_default' ).change( function() // called when Default radio button is clicked
268
  {
269
  jQuery( '#war_soundy_audio_title' ).val( _this.default_audio_title );
@@ -789,65 +823,42 @@ war_SoundyAdmin.prototype.bindMediaUploader = function( field_name, button_name,
789
 
790
  jQuery( '#' + button_name ).click( function()
791
  {
792
- jQuery( '#TB_window' ).html( '' ); // to avoid multiple title bars
793
- tb_show( '', 'media-upload.php?type=' + field_type + '&TB_iframe=true');
794
 
795
- window.send_to_editor = function( html )
796
- {
797
- if( field_type == 'image' )
798
- {
799
- var url = jQuery( 'img', html ).attr( 'src' );
800
- jQuery( '#' + field_name + '_img' ).attr( 'src', url );
801
- }
802
- else if( field_type == 'audio' )
803
- {
804
- var url = jQuery( html ).attr( 'href' );
805
- var file_extension = url.substr( url.lastIndexOf( '.' ) + 1 );
806
- switch( file_extension )
807
- {
808
- case 'mp3':
809
- case 'mpeg':
810
- var audio_type = 'mpeg';
811
- break;
812
- case 'ogg':
813
- var audio_type = 'ogg';
814
- break;
815
- case 'wav':
816
- var audio_type = 'wav';
817
- break;
818
- default:
819
- alert( 'Audio field_type Error' );
820
- return;
821
- }
822
- var player_was_playing = ! jQuery( '#war_soundy_audio_player' )[ 0 ].paused;
823
- jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
824
- jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
825
- jQuery( '#war_soundy_audio_player' )[ 0 ].load();
826
- if( player_was_playing ) jQuery( '#war_soundy_audio_player' )[ 0 ].play();
827
- jQuery( '#war_soundy_audio_type' ).val( 'audio/' + audio_type );
828
-
829
- var title = jQuery( html ).text().trim();
830
- if( title != '' )
831
- {
832
- jQuery( '#war_soundy_audio_title' ).val( title );
833
- }
834
- }
835
-
836
- var jq = jQuery( '#' + field_name );
837
- jq.val( url );
838
- jq.change();
839
-
840
- tb_remove();
841
- if( jQuery( '#war_soundy_soundtrack_default' ).length ) // war_soundy_soundtrack_default exists if meta box
842
- {
843
- jQuery( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked', true );
844
- jQuery( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
845
- jQuery( 'input[name=war_soundy_audio_title_def][value=custom]' ).prop( 'checked', true );
846
- jQuery( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
847
- }
848
- }
849
-
850
- return false;
851
  } );
852
  }
853
 
152
 
153
  jQuery( '#war_soundy_audio_file_url' ).change( function()
154
  {
155
+ var url = this.value;
156
+
157
+ var file_extension = url.substr( url.lastIndexOf( '.' ) + 1 );
158
+ switch( file_extension )
159
+ {
160
+ case 'mp3':
161
+ case 'mpeg':
162
+ var audio_type = 'mpeg';
163
+ break;
164
+ case 'ogg':
165
+ var audio_type = 'ogg';
166
+ break;
167
+ case 'wav':
168
+ var audio_type = 'wav';
169
+ break;
170
+ default:
171
+ alert( 'Audio field_type Error' );
172
+ return;
173
+ }
174
+ var player_was_playing = ! jQuery( '#war_soundy_audio_player' )[ 0 ].paused;
175
+ jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
176
+ jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
177
+ jQuery( '#war_soundy_audio_player' )[ 0 ].load();
178
+ if( player_was_playing ) jQuery( '#war_soundy_audio_player' )[ 0 ].play();
179
+ jQuery( '#war_soundy_audio_type' ).val( 'audio/' + audio_type );
180
+ if( jQuery( '#war_soundy_soundtrack_default' ).length ) // war_soundy_soundtrack_default exists if meta box
181
+ {
182
+ jQuery( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked', true );
183
+ jQuery( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
184
+ }
185
  } );
186
 
187
  jQuery( '#war_soundy_audio_type' ).change( function()
292
  jQuery( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
293
  } );
294
 
295
+ jQuery( '#war_soundy_audio_title' ).change( function()
296
+ {
297
+ jQuery( 'input[name=war_soundy_audio_title_def][value=custom]' ).prop( 'checked', true );
298
+ jQuery( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
299
+ } );
300
+
301
  jQuery( '#war_soundy_audio_title_default' ).change( function() // called when Default radio button is clicked
302
  {
303
  jQuery( '#war_soundy_audio_title' ).val( _this.default_audio_title );
823
 
824
  jQuery( '#' + button_name ).click( function()
825
  {
826
+ event.preventDefault();
 
827
 
828
+ var custom_uploader = wp.media(
829
+ {
830
+ title: field_type == 'audio' ? 'Media Library Audio Files' : 'Media Library Image Files',
831
+ button:
832
+ {
833
+ text: field_type == 'audio' ? 'Insert Audio File' : 'Insert Image File'
834
+ },
835
+ multiple: false,
836
+ library:
837
+ {
838
+ type: field_type
839
+ }
840
+ } );
841
+ custom_uploader.on( 'select',
842
+ function()
843
+ {
844
+ var attachment = custom_uploader.state().get( 'selection' ).first().toJSON();
845
+ var url = attachment.url;
846
+ var title = attachment.title.trim();
847
+ if( field_type == 'image' )
848
+ {
849
+ jQuery( '#' + field_name + '_img' ).attr( 'src', url );
850
+ }
851
+ else if( field_type == 'audio' )
852
+ {
853
+ jQuery( '#war_soundy_audio_title' ).val( title );
854
+ jQuery( '#war_soundy_audio_title' ).change();
855
+ }
856
+ var jq = jQuery( '#' + field_name );
857
+ jq.val( url );
858
+ jq.change();
859
+ } );
860
+ custom_uploader.open();
861
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
  } );
863
  }
864
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: bducouedic
3
  Tags: audio, sound, music, background, soundtrack, background sound, background audio, background music, posts, pages
4
  Requires at least: 3.6
5
- Tested up to: 4.1
6
- Stable tag: 3.0
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate link: http://webartisan.ch/en/products/soundy-background-music/free-wordpress-plugin/#wa_donate
@@ -168,6 +168,9 @@ This happens when the PHP parser version is too old. Soundy needs PHP 5.3 or hig
168
 
169
  = Changelog =
170
 
 
 
 
171
  = 3.0    -    January 3rd, 2015 =
172
  * Play/Pause button size and corner positioning can now be made responsive in "Button Responsiveness" tab of plugin settings page.
173
 
2
  Contributors: bducouedic
3
  Tags: audio, sound, music, background, soundtrack, background sound, background audio, background music, posts, pages
4
  Requires at least: 3.6
5
+ Tested up to: 4.4
6
+ Stable tag: 3.1
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate link: http://webartisan.ch/en/products/soundy-background-music/free-wordpress-plugin/#wa_donate
168
 
169
  = Changelog =
170
 
171
+ = 3.1    -    March 3rd, 2015 =
172
+ * Media Library button calls now new WordPress File Uploader.
173
+
174
  = 3.0    -    January 3rd, 2015 =
175
  * Play/Pause button size and corner positioning can now be made responsive in "Button Responsiveness" tab of plugin settings page.
176
 
soundy.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  /**
3
  * @package Soundy_Background_Music
4
- * @version 3.0
5
  */
6
  /*
7
  Plugin Name: Soundy Background Music
8
  Plugin URI: http://www.webartisan.ch/en/products/soundy-background-music/free-wordpress-plugin/
9
  Description: This plugin allows administrators and authors to set a background sound on any post or page.
10
- Version: 3.0
11
  Author: Bertrand du Couédic
12
  Author URI: http://webartisan.ch/en/about
13
  License: GPL2
@@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
  class WarSoundy
32
  {
33
  public $soundy_type = 'free';
34
- public $soundy_version = '3.0';
35
  public $soundy_free_wp_home_url = 'http://wordpress.org/plugins/soundy-background-music/';
36
  public $sdy_pl_free_wp_home_url = 'http://wordpress.org/plugins/soundy-audio-playlist/';
37
  public $soundy_pro_home_url = 'http://webartisan.ch/products/soundy-background-music/pro-wordpress-plugin/';
@@ -318,7 +318,7 @@ class WarSoundy
318
  public function admin_scripts( $hook )
319
  {
320
  wp_register_script( 'soundy-jquery-form', $this->plugin_url . '/js/jquery.form.js' );
321
- wp_register_script( 'soundy-back-end', $this->plugin_url . '/js/back-end.js', array( 'jquery', 'media-upload', 'thickbox' ) );
322
 
323
  wp_enqueue_script( 'jquery' );
324
  wp_enqueue_script( 'jquery-ui-core' );
@@ -331,9 +331,9 @@ class WarSoundy
331
 
332
  wp_enqueue_script( 'soundy-jquery-form' );
333
  wp_enqueue_script( 'soundy-back-end' );
334
- wp_enqueue_script( 'thickbox' );
335
- wp_enqueue_script( 'button-upload' );
336
-
337
  wp_register_style( 'jquery-ui', $this->plugin_url . '/css/jquery-ui-1.10.4/jquery-ui.css' );
338
  wp_register_style( 'soundy', $this->plugin_url . '/css/style-back-end.css' );
339
  if( $this->check_user_agent( 'firefox' ) )
1
  <?php
2
  /**
3
  * @package Soundy_Background_Music
4
+ * @version 3.1
5
  */
6
  /*
7
  Plugin Name: Soundy Background Music
8
  Plugin URI: http://www.webartisan.ch/en/products/soundy-background-music/free-wordpress-plugin/
9
  Description: This plugin allows administrators and authors to set a background sound on any post or page.
10
+ Version: 3.1
11
  Author: Bertrand du Couédic
12
  Author URI: http://webartisan.ch/en/about
13
  License: GPL2
31
  class WarSoundy
32
  {
33
  public $soundy_type = 'free';
34
+ public $soundy_version = '3.1';
35
  public $soundy_free_wp_home_url = 'http://wordpress.org/plugins/soundy-background-music/';
36
  public $sdy_pl_free_wp_home_url = 'http://wordpress.org/plugins/soundy-audio-playlist/';
37
  public $soundy_pro_home_url = 'http://webartisan.ch/products/soundy-background-music/pro-wordpress-plugin/';
318
  public function admin_scripts( $hook )
319
  {
320
  wp_register_script( 'soundy-jquery-form', $this->plugin_url . '/js/jquery.form.js' );
321
+ wp_register_script( 'soundy-back-end', $this->plugin_url . '/js/back-end.js', array( 'jquery' ) );
322
 
323
  wp_enqueue_script( 'jquery' );
324
  wp_enqueue_script( 'jquery-ui-core' );
331
 
332
  wp_enqueue_script( 'soundy-jquery-form' );
333
  wp_enqueue_script( 'soundy-back-end' );
334
+
335
+ wp_enqueue_media();
336
+
337
  wp_register_style( 'jquery-ui', $this->plugin_url . '/css/jquery-ui-1.10.4/jquery-ui.css' );
338
  wp_register_style( 'soundy', $this->plugin_url . '/css/style-back-end.css' );
339
  if( $this->check_user_agent( 'firefox' ) )