SoundCloud Is Gold - Version 1.0.6

Version Description

  • Now you can browse and add Sets and your favorites ;)
Download this release

Release Info

Developer realTM
Plugin Icon wp plugin SoundCloud Is Gold
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

readme.txt CHANGED
@@ -4,25 +4,27 @@ Donate link: http://www.mightymess.com/soundcloud-is-gold-wordpress-plugin
4
  Tags: soundcloud, integrated, media, shortcode, browse, design, easy, simple, music, sound, js, live preview, flash, html5
5
  Requires at least: 3.2
6
  Tested up to: 3.2.1
7
- Stable tag: 1.0.5
8
 
9
- Browse through your soundcloud tracks from a tab in the post's 'upload media'. Select, add a track to your post. Live preview, easy.
10
 
11
  == Description ==
12
 
13
  **Now with soundcloud's official html5 player!**
14
 
15
- **Soundcloud is Gold** integrates perfectly into wordpress. Browse through your soundcloud tracks from the 'Soundcloud is gold' tab in the post's 'upload media' popup window. Select, set and add track to your post using the soundcloud player. Live Preview, easy, smart and straightforward.
16
  You can set default settings in the option page, choose your defaut soundcloud player (Mini, Standard, Artwork, Html5), it's width, add extra classes for you CSS lovers, show comments, autoplay and your favorite color.
17
  You'll also be able to set players to different settings before adding to your post if you fancy a one off change.
18
 
19
  **Soundcloud is Gold** use a shortcode but the "Soundcloud is Gold" tab will write it for you dynamicly as you select parameters, and on top of this it will provide a nice live preview of your player so you know what does what. When done just press the 'insert soundcloud player' and it will added to your post just like when you're adding a photo or gallery.
20
 
21
- Check out my [TM soundcloud profile](http://www.soundcloud.com/t-m), more [mighty mess](http://www.mightymess.com) and if you love it rate it on the [Soundcloud is Gold wordpress plugin page](http://wordpress.org/extend/plugins/soundcloud-is-gold/). If you use it and want to help, [donations are always welcomed](http://www.mightymess.com/soundcloud-is-gold-wordpress-plugin) or you could just drop a line on [Soundcloud is Gold](http://www.mightymess.com/soundcloud-is-gold-wordpress-plugin) and show some love :)
 
 
22
 
23
  = Features =
24
 
25
- * Browse through your soundcloud tracks from a tab in the media upload window (see screenshot), no need to go back and forth between soundcloud and your website.
26
  * Live Preview in the Tab, see what does what instantly (see screenshot).
27
  * Integrates perfectly with wordpress media upload by using the same listing style that you get with the images (see screenshot).
28
  * See track's info directly in the tab (description, url, cover, etc...).
@@ -35,8 +37,9 @@ Check out my [TM soundcloud profile](http://www.soundcloud.com/t-m), more [might
35
  * Player's Colors
36
  * Use shortcode
37
  * Plugin construct shortode for you, no need to remember any syntax.
38
- * Implement Soundcloud Html5 player (beta)
39
- * Follow WP developpers guidelines (enqueue scripts and styles just for the plugin, clean code, commented, secure and leave no trace when uninstall )
 
40
 
41
  = Advantages against pasting embed code from soundcloud =
42
 
@@ -51,11 +54,9 @@ That's just my opinion of course...
51
  * V1.1: Advance Settings (change background color and comments color, playcounts, buy link, font, wmode, etc, show/hide styled shortcode, number of tracks per page)
52
  * Add Widget
53
  * if no id is specified in the shortcode (e.g [soundcloud]), display the latest track.
54
- * Posibility to access and add 'favorites' to post (thanks Bernd for the idea).
55
  * Possibility to add multiple users for thoses with multiple soundcloud account.
56
  * Possibility to set a different user in the 'Soundcloud is Gold tab' to add tracks from different people.
57
  * Add Soundcloud default Width to the options
58
- * Style sortcode in TinyMCE (editor) because it would be cool and neat;
59
  * Trigger live preview when changing Soundcloud user name
60
  * Live search while typing a name in the user name field. So if you're looking for someone it's kind of easier.
61
  * Add 'activities' to a widget
@@ -129,10 +130,12 @@ When upgrading from 1.0.1 and earlier: All shortcode attributes are now lowercas
129
 
130
  == Changelog ==
131
 
 
 
 
132
  = 1.0.5 =
133
  * New Soundcloud official Html5 player! Woop Woop!
134
 
135
-
136
  = 1.0.4 =
137
  * Faster loading of the tab (only load player's preview when click on 'show')
138
  * Pagination as people with more than 50 tracks couldn't access the rest of their tracks (25 tracks per page)
4
  Tags: soundcloud, integrated, media, shortcode, browse, design, easy, simple, music, sound, js, live preview, flash, html5
5
  Requires at least: 3.2
6
  Tested up to: 3.2.1
7
+ Stable tag: 1.0.6
8
 
9
+ Browse through your soundcloud tracks, sets and favourites. Select and add tracks, sets or favourites to your posts. Live preview, easy.
10
 
11
  == Description ==
12
 
13
  **Now with soundcloud's official html5 player!**
14
 
15
+ **Soundcloud is Gold** integrates perfectly into wordpress. Browse through your soundcloud tracks, sets and favorites from the 'Soundcloud is gold' tab in the post's 'upload media' popup window. Select, set and add track, sets, favorites to your post using the soundcloud player. Live Preview, easy, smart and straightforward.
16
  You can set default settings in the option page, choose your defaut soundcloud player (Mini, Standard, Artwork, Html5), it's width, add extra classes for you CSS lovers, show comments, autoplay and your favorite color.
17
  You'll also be able to set players to different settings before adding to your post if you fancy a one off change.
18
 
19
  **Soundcloud is Gold** use a shortcode but the "Soundcloud is Gold" tab will write it for you dynamicly as you select parameters, and on top of this it will provide a nice live preview of your player so you know what does what. When done just press the 'insert soundcloud player' and it will added to your post just like when you're adding a photo or gallery.
20
 
21
+ Check out my [TM soundcloud profile](http://www.soundcloud.com/t-m), more [mighty mess](http://www.mightymess.com) and if you love it please rate it on the [Soundcloud is Gold wordpress plugin page](http://wordpress.org/extend/plugins/soundcloud-is-gold/). If you use it and want to help, [donations are always welcomed](http://www.mightymess.com/soundcloud-is-gold-wordpress-plugin) or you could like, tweet or just drop a line on [Soundcloud is Gold](http://www.mightymess.com/soundcloud-is-gold-wordpress-plugin) and show some love :)
22
+
23
+ Latest developments updates on twitter: [#soundcloudisgold](https://twitter.com/#!/search/realtime/%23soundcloudisgold) or follow me on [twitter](http://twitter.com/#!/mighty_mess)
24
 
25
  = Features =
26
 
27
+ * Browse through your soundcloud tracks, sets and favorites from a tab in the media upload window (see screenshot), no need to go back and forth between soundcloud and your website.
28
  * Live Preview in the Tab, see what does what instantly (see screenshot).
29
  * Integrates perfectly with wordpress media upload by using the same listing style that you get with the images (see screenshot).
30
  * See track's info directly in the tab (description, url, cover, etc...).
37
  * Player's Colors
38
  * Use shortcode
39
  * Plugin construct shortode for you, no need to remember any syntax.
40
+ * Style sortcode for neat layout in your editor.
41
+ * Implement Soundcloud Html5 player (beta).
42
+ * Follow WP developpers guidelines (enqueue scripts and styles just for the plugin, clean code, commented, secure and leave no trace when uninstall ).
43
 
44
  = Advantages against pasting embed code from soundcloud =
45
 
54
  * V1.1: Advance Settings (change background color and comments color, playcounts, buy link, font, wmode, etc, show/hide styled shortcode, number of tracks per page)
55
  * Add Widget
56
  * if no id is specified in the shortcode (e.g [soundcloud]), display the latest track.
 
57
  * Possibility to add multiple users for thoses with multiple soundcloud account.
58
  * Possibility to set a different user in the 'Soundcloud is Gold tab' to add tracks from different people.
59
  * Add Soundcloud default Width to the options
 
60
  * Trigger live preview when changing Soundcloud user name
61
  * Live search while typing a name in the user name field. So if you're looking for someone it's kind of easier.
62
  * Add 'activities' to a widget
130
 
131
  == Changelog ==
132
 
133
+ = 1.0.6 =
134
+ * Now you can browse and add Sets and your favorites ;)
135
+
136
  = 1.0.5 =
137
  * New Soundcloud official Html5 player! Woop Woop!
138
 
 
139
  = 1.0.4 =
140
  * Faster loading of the tab (only load player's preview when click on 'show')
141
  * Pagination as people with more than 50 tracks couldn't access the rest of their tracks (25 tracks per page)
soundcloud-is-gold-css.css CHANGED
@@ -434,12 +434,14 @@ select.soundcloudMMInput option{
434
 
435
 
436
  /******************** TAB *****************/
437
- #soundcloudMMPagination{
438
  margin:1em;
 
439
  }
440
- #soundcloudMMPagination .pagination-links a{
441
  margin-right:5px;
442
  }
 
443
  .soundcloudMMColorPicker .soundcloudMMColorPickerClose{
444
  display: block;
445
  padding: 6% 2%;
434
 
435
 
436
  /******************** TAB *****************/
437
+ #soundcloudMMTabActions{
438
  margin:1em;
439
+ width:623px;
440
  }
441
+ #soundcloudMMTabActions #tablenav #tablenav-pages .pagination-links a, #soundcloudMMTabActions #tablenav #tablenav-pages .pagination-links .paging-input{
442
  margin-right:5px;
443
  }
444
+
445
  .soundcloudMMColorPicker .soundcloudMMColorPickerClose{
446
  display: block;
447
  padding: 6% 2%;
soundcloud-is-gold-functions.php CHANGED
@@ -40,11 +40,14 @@ function get_soundcloud_is_gold_default_settings_for_js(){
40
  echo 'soundcloudIsGoldClasses_default = "'.get_option('soundcloud_is_gold_classes').'"; ';
41
  echo 'soundcloudIsGoldColor_default = "'.get_option('soundcloud_is_gold_color').'"; ';
42
  }
43
- function get_soundcloudIsGoldUserTrackNumber(){
44
  $soundcloudIsGoldApiCall = 'http://api.soundcloud.com/users/'.get_option('soundcloud_is_gold_user').'.xml?client_id=9rD2GrGrajkmkw5eYFDp2g';
45
  $soundcloudIsGoldApiResponse = get_soundcloud_is_gold_api_response($soundcloudIsGoldApiCall);
46
- return $soundcloudIsGoldApiResponse['response']->{'track-count'};
47
- }
 
 
 
48
  function get_soundcloud_is_gold_api_response($soundcloudIsGoldApiCall){
49
  //Set Error default message && default XML state
50
  $soundcloudIsGoldRespError = false;
@@ -92,19 +95,29 @@ function soundcloud_is_gold_pagination($totalItems, $currentPage, $perPage, $pos
92
  $disableFirst = ($currentPage == $firstPage) ? ' disabled' : '';
93
  $disableLast = ($currentPage == $lastPage) ? ' disabled' : '';
94
 
95
- $output = '<div id="soundcloudMMPagination">';
96
- $output .= '<div class="tablenav">';
97
- $output .= '<div class="tablenav-pages"><span class="displaying-num">'.$totalItems.' tracks</span>';
98
  $output .= '<span class="pagination-links"><a href="?post_id='.$post_ID.'&tab=soundcloud_is_gold&paged='.$firstPage.'&TB_iframe=1&width=640&height=584" title="Go to the first page" class="first-page'.$disableFirst.'">&laquo;</a>';
99
  $output .= '<a href="?post_id='.$post_ID.'&tab=soundcloud_is_gold&paged='.$prevPage.'&TB_iframe=1&width=640&height=584" title="Go to the previous page" class="prev-page'.$disableFirst.'">&lsaquo;</a>';
100
  $output .= '<span class="paging-input">page '.$currentPage.' of <span class="total-pages">'.$lastPage.'</span></span>';
101
  $output .= '<a href="?post_id='.$post_ID.'&tab=soundcloud_is_gold&paged='.$nextPage.'&TB_iframe=1&width=640&height=584" title="Go to the next page" class="next-page'.$disableLast.'">&rsaquo;</a>';
102
  $output .= '<a href="?post_id='.$post_ID.'&tab=soundcloud_is_gold&paged='.$lastPage.'&TB_iframe=1&width=640&height=584" title="Go to the last page" class="last-page'.$disableLast.'">&raquo;</a></span></div>';
103
- $output .= '</div>';
104
- $output .= '</div>';
105
 
106
  return $output;
107
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  /*Add Soundcloud is Gold Plugin to TinyMce*/
109
  function soundcloud_is_gold_mce_plugin($plugin_array) {
110
  $plugin_array['soundcloudIsGold'] = SIG_PLUGIN_DIR.'tinymce-plugin/soundcloud-is-gold-editor_plugin.js';
@@ -160,22 +173,14 @@ add_action('media_upload_soundcloud_is_gold', 'soundcloud_is_gold_media_menu_han
160
  /*Add Soundcloud Button to Upload/Insert*/
161
  function plugin_media_button($context) {
162
  global $post_ID;
163
- $plugin_media_button = ' %s' . '<a id="add_soundcloud_is_gold" title="Insert Soundcloud Player" href="media-upload.php?post_id='.$post_ID.'&tab=soundcloud_is_gold&paged=1&TB_iframe=1&width=640&height=584" class="thickbox"><img alt="Insert Soundcloud Player" src="'.SIG_PLUGIN_DIR.'soundcloud-is-gold-icon.png"></a>';
164
  return sprintf($context, $plugin_media_button);
165
  }
166
  add_filter('media_buttons_context', 'plugin_media_button');
167
 
168
  /** Populate the new Soundcloud is Gold Tab **/
169
  function get_soundcloud_is_gold_user_tracks(){
170
-
171
- $soundcloudIsGoldPage = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : '1';
172
- $post_id = $_REQUEST['post_id'];
173
- $soundcloudIsGoldTracksPerPage = 25;
174
- $soundcloudIsGoldApiOffset = $soundcloudIsGoldTracksPerPage*($soundcloudIsGoldPage-1);
175
- $soundcloudIsGoldPagination = soundcloud_is_gold_pagination(get_soundcloudIsGoldUserTrackNumber(), $soundcloudIsGoldPage, $soundcloudIsGoldTracksPerPage, $post_id);
176
-
177
- $soundcloudIsGoldApiCall = 'http://api.soundcloud.com/users/'.get_option('soundcloud_is_gold_user').'/tracks.xml?limit='.$soundcloudIsGoldTracksPerPage.'&offset='.$soundcloudIsGoldApiOffset.'&client_id=9rD2GrGrajkmkw5eYFDp2g';
178
-
179
  $soundcloudIsGoldUser = get_option('soundcloud_is_gold_user');
180
  $soundcloudIsGoldSettings = get_option('soundcloud_is_gold_settings');
181
  $soundcloudIsGoldPlayerType = get_option('soundcloud_is_gold_playerType');
@@ -184,10 +189,32 @@ function get_soundcloud_is_gold_user_tracks(){
184
  $soundcloudIsGoldWidth = get_soundcloud_is_gold_default_width($soundcloudIsGoldWidthSettings);
185
  $soundcloudIsGoldClasses = get_option('soundcloud_is_gold_classes');
186
  $soundcloudIsGoldColor = get_option('soundcloud_is_gold_color');
187
-
188
- //Pagination
189
- echo (isset($soundcloudIsGoldPagination)) ? $soundcloudIsGoldPagination : '';
190
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  //Sorting Menu
192
  echo '<form id="library-form" class="media-upload-form validate" action="" method="post" enctype="multipart/form-data"><div id="media-items" class="media-items-'.$post_id.'">';
193
  ?>
@@ -211,7 +238,6 @@ function get_soundcloud_is_gold_user_tracks(){
211
  </script>
212
 
213
  <?php
214
- $soundcloudIsGoldApiResponse = get_soundcloud_is_gold_api_response($soundcloudIsGoldApiCall);
215
  if (isset($soundcloudIsGoldApiResponse['response']) && $soundcloudIsGoldApiResponse['response']) {
216
  foreach($soundcloudIsGoldApiResponse['response'] as $soundcloudIsGoldtrack): ?>
217
 
@@ -219,7 +245,7 @@ function get_soundcloud_is_gold_user_tracks(){
219
  <a href="#" class="toggle describe-toggle-on soundcloud" id="show-<?php echo $soundcloudIsGoldtrack->id ?>">Show</a>
220
  <a href="#" class="toggle describe-toggle-off soundcloudMM">Hide</a>
221
  <div class="filename new"><span class="title soundcloudMMTitle" id="soundcloudMMTitle-<?php echo $soundcloudIsGoldtrack->id ?>"><?php echo $soundcloudIsGoldtrack->title ?></span></div>
222
- <table class="slidetoggle describe startclosed soundcloudMMWrapper">
223
  <thead id="media-head-<?php echo $soundcloudIsGoldtrack->id ?>" class="media-item-info">
224
  <tr valign="top">
225
  <td id="thumbnail-head-<?php echo $soundcloudIsGoldtrack->id ?>" class="A1B1">
@@ -362,10 +388,11 @@ function soundcloud_is_gold_shortcode($atts){
362
  'width' => get_soundcloud_is_gold_default_width(get_option('soundcloud_is_gold_width_settings')),
363
  'classes' => get_option('soundcloud_is_gold_classes'),
364
  'playertype' => get_option('soundcloud_is_gold_playerType'),
365
- 'color' => get_option('soundcloud_is_gold_color')
 
366
  ), $atts )
367
  );
368
- return soundcloud_is_gold_player($id, $autoplay, $comments, $width, $classes, $playertype, $color, $artwork);
369
  }
370
 
371
 
@@ -380,13 +407,13 @@ function soundcloud_is_gold_shortcode($atts){
380
  /** Preview **/
381
  add_action('wp_ajax_soundcloud_is_gold_player_preview', 'soundcloud_is_gold_player_preview');
382
  function soundcloud_is_gold_player_preview(){
383
- if(isset($_POST['request'])) echo soundcloud_is_gold_player($_POST['ID'], $_POST['autoPlay'], $_POST['comments'], $_POST['width'], $_POST['classes'], $_POST['playerType'], $_POST['color'], $_POST['artwork']);
384
  die;
385
  }
386
 
387
 
388
  /** The Player **/
389
- function soundcloud_is_gold_player($id, $autoPlay, $comments, $width, $classes, $playerTypes, $color, $artwork){
390
 
391
  //Default values: Needed when not called trough shortode (like in the ajax preview)
392
  $soundcloudIsGoldSettings = get_option('soundcloud_is_gold_settings');
@@ -397,13 +424,15 @@ function soundcloud_is_gold_player($id, $autoPlay, $comments, $width, $classes,
397
  if(!isset($classes)) $classes = get_option('soundcloud_is_gold_classes');
398
  if(!isset($playerTypes)) $playerTypes = get_option('soundcloud_is_gold_playerType');
399
  if(!isset($color)) $color = get_option('soundcloud_is_gold_color');
 
 
400
  $html5Player = false;
401
 
402
  $color = str_replace('#', '', $color);
403
 
404
  switch($playerTypes){
405
  case 'Standard':
406
- $height = '81px';
407
  $playerType = 'standard';
408
  break;
409
  case 'Artwork':
@@ -411,11 +440,11 @@ function soundcloud_is_gold_player($id, $autoPlay, $comments, $width, $classes,
411
  $playerType = 'artwork';
412
  break;
413
  case 'Mini':
414
- $playerType = 'tiny';
415
  $height = '18px';
 
416
  break;
417
  case 'html5':
418
- $height = '166px';
419
  $html5Player = true;
420
  break;
421
  }
@@ -425,15 +454,15 @@ function soundcloud_is_gold_player($id, $autoPlay, $comments, $width, $classes,
425
  //Flash Player
426
  if(!$html5Player){
427
  $player .= '<object height="'.$height.'" width="'.$width.'">';
428
- $player .= '<param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F'.$id.'&amp;auto_play='.$autoPlay.'&amp;player_type='.$playerType.'&amp;show_comments='.$comments.'&amp;color='.$color.'"></param>';
429
  $player .= '<param name="allowscriptaccess" value="always"></param>';
430
  $player .= '<param name="wmode" value="transparent"></param>';
431
- $player .= '<embed wmode="transparent" allowscriptaccess="always" height="'.$height.'" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F'.$id.'&amp;auto_play='.$autoPlay.'&amp;player_type='.$playerType.'&amp;show_comments='.$comments.'&amp;color='.$color.'" type="application/x-shockwave-flash" width="'.$width.'"></embed>';
432
  $player .= '</object>';
433
  }
434
  //Html5 Player
435
  else{
436
- $player .= '<iframe width="'.$width.'" height="'.$height.'" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F'.$id.'&amp;auto_play='.$autoPlay.'&amp;show_artwork='.$artwork.'&amp;color='.$color.'"></iframe>';
437
  }
438
  $player .= '</div>';
439
 
@@ -447,7 +476,7 @@ function soundcloud_is_gold_player($id, $autoPlay, $comments, $width, $classes,
447
  add_action('wp_ajax_get_soundcloud_player', 'get_soundcloud_player');
448
  add_action('wp_ajax_nopriv_get_soundcloud_player', 'get_soundcloud_player');
449
  function get_soundcloud_player(){
450
- echo soundcloud_is_gold_player($_POST['id'], $_POST['width'], $_POST['comments'], $_POST['autoPlay'], $_POST['type'], $_POST['color']);
451
  die();
452
 
453
  }
40
  echo 'soundcloudIsGoldClasses_default = "'.get_option('soundcloud_is_gold_classes').'"; ';
41
  echo 'soundcloudIsGoldColor_default = "'.get_option('soundcloud_is_gold_color').'"; ';
42
  }
43
+ function get_soundcloudIsGoldUserNumber(){
44
  $soundcloudIsGoldApiCall = 'http://api.soundcloud.com/users/'.get_option('soundcloud_is_gold_user').'.xml?client_id=9rD2GrGrajkmkw5eYFDp2g';
45
  $soundcloudIsGoldApiResponse = get_soundcloud_is_gold_api_response($soundcloudIsGoldApiCall);
46
+ $result['tracks'] = ($soundcloudIsGoldApiResponse['response']->{'track-count'} == 0) ? '0' : $soundcloudIsGoldApiResponse['response']->{'track-count'};
47
+ $result['sets'] = ($soundcloudIsGoldApiResponse['response']->{'playlist-count'} == 0) ? '0' : $soundcloudIsGoldApiResponse['response']->{'playlist-count'};
48
+ $result['favorites'] = ($soundcloudIsGoldApiResponse['response']->{'public-favorites-count'} == 0) ? '0' : $soundcloudIsGoldApiResponse['response']->{'public-favorites-count'};
49
+ return $result;
50
+ }
51
  function get_soundcloud_is_gold_api_response($soundcloudIsGoldApiCall){
52
  //Set Error default message && default XML state
53
  $soundcloudIsGoldRespError = false;
95
  $disableFirst = ($currentPage == $firstPage) ? ' disabled' : '';
96
  $disableLast = ($currentPage == $lastPage) ? ' disabled' : '';
97
 
98
+ $output = '<div class="tablenav-pages"><span class="displaying-num">'.$totalItems.' tracks</span>';
 
 
99
  $output .= '<span class="pagination-links"><a href="?post_id='.$post_ID.'&tab=soundcloud_is_gold&paged='.$firstPage.'&TB_iframe=1&width=640&height=584" title="Go to the first page" class="first-page'.$disableFirst.'">&laquo;</a>';
100
  $output .= '<a href="?post_id='.$post_ID.'&tab=soundcloud_is_gold&paged='.$prevPage.'&TB_iframe=1&width=640&height=584" title="Go to the previous page" class="prev-page'.$disableFirst.'">&lsaquo;</a>';
101
  $output .= '<span class="paging-input">page '.$currentPage.' of <span class="total-pages">'.$lastPage.'</span></span>';
102
  $output .= '<a href="?post_id='.$post_ID.'&tab=soundcloud_is_gold&paged='.$nextPage.'&TB_iframe=1&width=640&height=584" title="Go to the next page" class="next-page'.$disableLast.'">&rsaquo;</a>';
103
  $output .= '<a href="?post_id='.$post_ID.'&tab=soundcloud_is_gold&paged='.$lastPage.'&TB_iframe=1&width=640&height=584" title="Go to the last page" class="last-page'.$disableLast.'">&raquo;</a></span></div>';
 
 
104
 
105
  return $output;
106
  }
107
+ /*Select Tracks / Favorites / Sets
108
+ */
109
+ function soundcloud_is_gold_select_tracks_favs_sets($selectedFormat, $soundcloudIsGoldNumbers, $post_ID){
110
+ $formats = array('tracks', 'sets', 'favorites');
111
+ $output = '<ul id="soundcloudMMSelectTracksFavsSets" class="subsubsub">';
112
+ foreach($formats as $key => $format){
113
+ $current = ($format == $selectedFormat) ? 'current' : '';
114
+ $seperator = ($key != 0) ? ' | ' : ' ';
115
+ $output .= $seperator.'<li><a href="?post_id='.$post_ID.'&tab=soundcloud_is_gold&selectFormat='.$format.'&paged=1" class="'.$current.'">'.$format.' <span class="count">('.$soundcloudIsGoldNumbers[$format].')</span></a></li>';
116
+ }
117
+ $output .= '</ul>';
118
+ return $output;
119
+ }
120
+
121
  /*Add Soundcloud is Gold Plugin to TinyMce*/
122
  function soundcloud_is_gold_mce_plugin($plugin_array) {
123
  $plugin_array['soundcloudIsGold'] = SIG_PLUGIN_DIR.'tinymce-plugin/soundcloud-is-gold-editor_plugin.js';
173
  /*Add Soundcloud Button to Upload/Insert*/
174
  function plugin_media_button($context) {
175
  global $post_ID;
176
+ $plugin_media_button = ' %s' . '<a id="add_soundcloud_is_gold" title="Insert Soundcloud Player" href="media-upload.php?post_id='.$post_ID.'&tab=soundcloud_is_gold&selectFormat=tracks&paged=1&TB_iframe=1&width=640&height=584" class="thickbox"><img alt="Insert Soundcloud Player" src="'.SIG_PLUGIN_DIR.'soundcloud-is-gold-icon.png"></a>';
177
  return sprintf($context, $plugin_media_button);
178
  }
179
  add_filter('media_buttons_context', 'plugin_media_button');
180
 
181
  /** Populate the new Soundcloud is Gold Tab **/
182
  function get_soundcloud_is_gold_user_tracks(){
183
+ //Default Settings
 
 
 
 
 
 
 
 
184
  $soundcloudIsGoldUser = get_option('soundcloud_is_gold_user');
185
  $soundcloudIsGoldSettings = get_option('soundcloud_is_gold_settings');
186
  $soundcloudIsGoldPlayerType = get_option('soundcloud_is_gold_playerType');
189
  $soundcloudIsGoldWidth = get_soundcloud_is_gold_default_width($soundcloudIsGoldWidthSettings);
190
  $soundcloudIsGoldClasses = get_option('soundcloud_is_gold_classes');
191
  $soundcloudIsGoldColor = get_option('soundcloud_is_gold_color');
192
+
193
+ //Default Pagination Settings
194
+ $soundcloudIsGoldTracksPerPage = 25;
195
+ $soundcloudIsGoldPage = isset($_REQUEST['paged']) ? $_REQUEST['paged'] : '1';
196
+ $post_id = $_REQUEST['post_id'];
197
+ $soundcloudIsGoldApiOffset = $soundcloudIsGoldTracksPerPage*($soundcloudIsGoldPage-1);
198
+
199
+ //API Call
200
+ $soundcloudIsGoldSelectedFormat = isset($_REQUEST['selectFormat']) ? $_REQUEST['selectFormat'] : 'tracks';
201
+ if($soundcloudIsGoldSelectedFormat == 'tracks') $soundcloudIsGoldApiCall = 'http://api.soundcloud.com/users/'.get_option('soundcloud_is_gold_user').'/tracks.xml?limit='.$soundcloudIsGoldTracksPerPage.'&offset='.$soundcloudIsGoldApiOffset.'&client_id=9rD2GrGrajkmkw5eYFDp2g';
202
+ if($soundcloudIsGoldSelectedFormat == 'sets') $soundcloudIsGoldApiCall = 'http://api.soundcloud.com/users/'.get_option('soundcloud_is_gold_user').'/playlists.xml?limit='.$soundcloudIsGoldTracksPerPage.'&offset='.$soundcloudIsGoldApiOffset.'&client_id=9rD2GrGrajkmkw5eYFDp2g';
203
+ if($soundcloudIsGoldSelectedFormat == 'favorites') $soundcloudIsGoldApiCall = 'http://api.soundcloud.com/users/'.get_option('soundcloud_is_gold_user').'/favorites.xml?limit='.$soundcloudIsGoldTracksPerPage.'&offset='.$soundcloudIsGoldApiOffset.'&client_id=9rD2GrGrajkmkw5eYFDp2g';
204
+ $soundcloudIsGoldApiResponse = get_soundcloud_is_gold_api_response($soundcloudIsGoldApiCall);
205
+
206
+ //Pagination and Actions
207
+ $soundcloudIsGoldNumbers = get_soundcloudIsGoldUserNumber($soundcloudIsGoldSelectedFormat);
208
+ $soundcloudIsGoldPagination = soundcloud_is_gold_pagination($soundcloudIsGoldNumbers[$soundcloudIsGoldSelectedFormat], $soundcloudIsGoldPage, $soundcloudIsGoldTracksPerPage, $post_id);
209
+ $soundcloudIsGoldSelectTracksFavsSets = soundcloud_is_gold_select_tracks_favs_sets($soundcloudIsGoldSelectedFormat, $soundcloudIsGoldNumbers, $post_id);
210
+
211
+ echo '<div id="soundcloudMMTabActions" class="tablenav">';
212
+ //Select Tracks / Sets / Favs
213
+ echo (isset($soundcloudIsGoldSelectTracksFavsSets)) ? $soundcloudIsGoldSelectTracksFavsSets : '';
214
+ //Pagination
215
+ echo (isset($soundcloudIsGoldPagination)) ? $soundcloudIsGoldPagination : '';
216
+ echo '</div>';
217
+
218
  //Sorting Menu
219
  echo '<form id="library-form" class="media-upload-form validate" action="" method="post" enctype="multipart/form-data"><div id="media-items" class="media-items-'.$post_id.'">';
220
  ?>
238
  </script>
239
 
240
  <?php
 
241
  if (isset($soundcloudIsGoldApiResponse['response']) && $soundcloudIsGoldApiResponse['response']) {
242
  foreach($soundcloudIsGoldApiResponse['response'] as $soundcloudIsGoldtrack): ?>
243
 
245
  <a href="#" class="toggle describe-toggle-on soundcloud" id="show-<?php echo $soundcloudIsGoldtrack->id ?>">Show</a>
246
  <a href="#" class="toggle describe-toggle-off soundcloudMM">Hide</a>
247
  <div class="filename new"><span class="title soundcloudMMTitle" id="soundcloudMMTitle-<?php echo $soundcloudIsGoldtrack->id ?>"><?php echo $soundcloudIsGoldtrack->title ?></span></div>
248
+ <table class="slidetoggle describe startclosed soundcloudMMWrapper <?php echo $soundcloudIsGoldSelectedFormat ?>">
249
  <thead id="media-head-<?php echo $soundcloudIsGoldtrack->id ?>" class="media-item-info">
250
  <tr valign="top">
251
  <td id="thumbnail-head-<?php echo $soundcloudIsGoldtrack->id ?>" class="A1B1">
388
  'width' => get_soundcloud_is_gold_default_width(get_option('soundcloud_is_gold_width_settings')),
389
  'classes' => get_option('soundcloud_is_gold_classes'),
390
  'playertype' => get_option('soundcloud_is_gold_playerType'),
391
+ 'color' => get_option('soundcloud_is_gold_color'),
392
+ 'format' => 'tracks'
393
  ), $atts )
394
  );
395
+ return soundcloud_is_gold_player($id, $autoplay, $comments, $width, $classes, $playertype, $color, $artwork, $format);
396
  }
397
 
398
 
407
  /** Preview **/
408
  add_action('wp_ajax_soundcloud_is_gold_player_preview', 'soundcloud_is_gold_player_preview');
409
  function soundcloud_is_gold_player_preview(){
410
+ if(isset($_POST['request'])) echo soundcloud_is_gold_player($_POST['ID'], $_POST['autoPlay'], $_POST['comments'], $_POST['width'], $_POST['classes'], $_POST['playerType'], $_POST['color'], $_POST['artwork'], $_POST['format']);
411
  die;
412
  }
413
 
414
 
415
  /** The Player **/
416
+ function soundcloud_is_gold_player($id, $autoPlay, $comments, $width, $classes, $playerTypes, $color, $artwork, $format){
417
 
418
  //Default values: Needed when not called trough shortode (like in the ajax preview)
419
  $soundcloudIsGoldSettings = get_option('soundcloud_is_gold_settings');
424
  if(!isset($classes)) $classes = get_option('soundcloud_is_gold_classes');
425
  if(!isset($playerTypes)) $playerTypes = get_option('soundcloud_is_gold_playerType');
426
  if(!isset($color)) $color = get_option('soundcloud_is_gold_color');
427
+ if(!isset($format)) $format = 'tracks';
428
+ elseif($format == 'sets' || $format == 'set') $format = 'playlists';
429
  $html5Player = false;
430
 
431
  $color = str_replace('#', '', $color);
432
 
433
  switch($playerTypes){
434
  case 'Standard':
435
+ $height = ($format == 'tracks') ? '81px' : '165px';
436
  $playerType = 'standard';
437
  break;
438
  case 'Artwork':
440
  $playerType = 'artwork';
441
  break;
442
  case 'Mini':
 
443
  $height = '18px';
444
+ $playerType = 'tiny';
445
  break;
446
  case 'html5':
447
+ $height = ($format == 'tracks') ? '166px' : '450px';
448
  $html5Player = true;
449
  break;
450
  }
454
  //Flash Player
455
  if(!$html5Player){
456
  $player .= '<object height="'.$height.'" width="'.$width.'">';
457
+ $player .= '<param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2F'.$format.'%2F'.$id.'&amp;auto_play='.$autoPlay.'&amp;player_type='.$playerType.'&amp;show_comments='.$comments.'&amp;color='.$color.'"></param>';
458
  $player .= '<param name="allowscriptaccess" value="always"></param>';
459
  $player .= '<param name="wmode" value="transparent"></param>';
460
+ $player .= '<embed wmode="transparent" allowscriptaccess="always" height="'.$height.'" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2F'.$format.'%2F'.$id.'&amp;auto_play='.$autoPlay.'&amp;player_type='.$playerType.'&amp;show_comments='.$comments.'&amp;color='.$color.'" type="application/x-shockwave-flash" width="'.$width.'"></embed>';
461
  $player .= '</object>';
462
  }
463
  //Html5 Player
464
  else{
465
+ $player .= '<iframe width="'.$width.'" height="'.$height.'" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2F'.$format.'%2F'.$id.'&amp;auto_play='.$autoPlay.'&amp;show_artwork='.$artwork.'&amp;color='.$color.'"></iframe>';
466
  }
467
  $player .= '</div>';
468
 
476
  add_action('wp_ajax_get_soundcloud_player', 'get_soundcloud_player');
477
  add_action('wp_ajax_nopriv_get_soundcloud_player', 'get_soundcloud_player');
478
  function get_soundcloud_player(){
479
+ echo soundcloud_is_gold_player($_POST['id'], $_POST['width'], $_POST['comments'], $_POST['autoPlay'], $_POST['type'], $_POST['color'], $_POST['format']);
480
  die();
481
 
482
  }
soundcloud-is-gold-js.js CHANGED
@@ -49,20 +49,24 @@ jQuery(document).ready(function($){
49
  else comments = true;
50
  if($('.soundcloudMMShowArtwork:checked', parent).val() == undefined) artwork = false;
51
  else artwork = true;
52
-
53
  //Set width
54
  if($(".soundcloudMMWpWidth", parent).is(":checked")) width = $('.soundcloudMMWidth option:selected', parent).val();
55
  if($(".soundcloudMMCustomWidth", parent).is(":checked")) width = $('input.soundcloudMMWidth', parent).val();
56
-
57
  classes = $('.soundcloudMMClasses', parent).val();
58
- $('.soundcloudMMPlayerType', parent).each(function(){
 
59
  if( $(this).attr('checked') == 'checked' ) playerType = $(this).val();
60
  });
 
61
  color = $('.soundcloudMMColor', parent).val();
 
 
 
62
  //Set Shortocode Attributes
63
- if(!parent.hasClass('soundcloudMMOptions')) shortcode(parent, autoPlay, comments, width, classes, playerType, color, artwork);
64
  //Refresh Preview if reuqested
65
- if(refresh) preview(parent, autoPlay, comments, width, classes, playerType, color, artwork);
66
 
67
  };
68
 
@@ -88,7 +92,7 @@ jQuery(document).ready(function($){
88
  /********************************************/
89
  /** SHORTCODE **/
90
  /********************************************/
91
- function shortcode(parent, autoPlay, comments, width, classes, playerType, color, artwork){
92
  var shortcode = "soundcloud id='"+getID($('.soundcloudMMId', parent))+"'";
93
  if(comments != soundcloudIsGoldComments_default) shortcode += " comments='"+comments+"'";
94
  if(artwork != soundcloudIsGoldArtwork_default) shortcode += " artwork='"+artwork+"'";
@@ -97,6 +101,7 @@ jQuery(document).ready(function($){
97
  if(width != soundcloudIsGoldWidth_default) shortcode += " width='"+width+"'";
98
  if(classes != soundcloudIsGoldClasses_default) shortcode += " classes='"+classes+"'";
99
  if(color != soundcloudIsGoldColor_default) shortcode += " color='"+color+"'";
 
100
 
101
  $('.soundcloudMMShortcode', parent).val("["+shortcode+"]");
102
  }
@@ -104,20 +109,22 @@ jQuery(document).ready(function($){
104
  /********************************************/
105
  /** PREVIEW **/
106
  /********************************************/
107
- function preview(parent, autoPlay, comments, width, classes, playerType, color, artwork){
108
  //Animate transition
109
  switch(playerType){
110
  case 'Mini':
111
  newHeight = '18px';
112
  break;
113
  case 'Standard':
114
- newHeight = '81px';
 
115
  break;
116
  case 'Artwork':
117
  newHeight = width;
118
  break;
119
  case 'html5':
120
- newHeight = '166px';
 
121
  break;
122
  }
123
  //Tell user it's loading
@@ -141,7 +148,8 @@ jQuery(document).ready(function($){
141
  width: width,
142
  classes: classes,
143
  playerType: playerType,
144
- color: color
 
145
  };
146
  jQuery.post(ajaxurl, myData, function(response) {
147
  if(response){
49
  else comments = true;
50
  if($('.soundcloudMMShowArtwork:checked', parent).val() == undefined) artwork = false;
51
  else artwork = true;
 
52
  //Set width
53
  if($(".soundcloudMMWpWidth", parent).is(":checked")) width = $('.soundcloudMMWidth option:selected', parent).val();
54
  if($(".soundcloudMMCustomWidth", parent).is(":checked")) width = $('input.soundcloudMMWidth', parent).val();
55
+ //Class
56
  classes = $('.soundcloudMMClasses', parent).val();
57
+ //Player Type
58
+ $('.soundcloudMMPlayerType', parent).each(function(){
59
  if( $(this).attr('checked') == 'checked' ) playerType = $(this).val();
60
  });
61
+ //Color
62
  color = $('.soundcloudMMColor', parent).val();
63
+ //Format
64
+ if($('.soundcloudMMWrapper').hasClass('sets')) format = 'sets';
65
+ else format = 'tracks';
66
  //Set Shortocode Attributes
67
+ if(!parent.hasClass('soundcloudMMOptions')) shortcode(parent, autoPlay, comments, width, classes, playerType, color, artwork, format);
68
  //Refresh Preview if reuqested
69
+ if(refresh) preview(parent, autoPlay, comments, width, classes, playerType, color, artwork, format);
70
 
71
  };
72
 
92
  /********************************************/
93
  /** SHORTCODE **/
94
  /********************************************/
95
+ function shortcode(parent, autoPlay, comments, width, classes, playerType, color, artwork, format){
96
  var shortcode = "soundcloud id='"+getID($('.soundcloudMMId', parent))+"'";
97
  if(comments != soundcloudIsGoldComments_default) shortcode += " comments='"+comments+"'";
98
  if(artwork != soundcloudIsGoldArtwork_default) shortcode += " artwork='"+artwork+"'";
101
  if(width != soundcloudIsGoldWidth_default) shortcode += " width='"+width+"'";
102
  if(classes != soundcloudIsGoldClasses_default) shortcode += " classes='"+classes+"'";
103
  if(color != soundcloudIsGoldColor_default) shortcode += " color='"+color+"'";
104
+ if(format != 'tracks') shortcode += " format='set'";
105
 
106
  $('.soundcloudMMShortcode', parent).val("["+shortcode+"]");
107
  }
109
  /********************************************/
110
  /** PREVIEW **/
111
  /********************************************/
112
+ function preview(parent, autoPlay, comments, width, classes, playerType, color, artwork, format){
113
  //Animate transition
114
  switch(playerType){
115
  case 'Mini':
116
  newHeight = '18px';
117
  break;
118
  case 'Standard':
119
+ if(format == 'tracks') newHeight = '81px';
120
+ else newHeight = '165px';
121
  break;
122
  case 'Artwork':
123
  newHeight = width;
124
  break;
125
  case 'html5':
126
+ if(format == 'tracks') newHeight = '166px';
127
+ else newHeight = '450px';
128
  break;
129
  }
130
  //Tell user it's loading
148
  width: width,
149
  classes: classes,
150
  playerType: playerType,
151
+ color: color,
152
+ format: format
153
  };
154
  jQuery.post(ajaxurl, myData, function(response) {
155
  if(response){
soundcloud-is-gold.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: Soundcloud is Gold
4
  Plugin URI: http://www.mightymess.com/soundcloud-is-gold-wordpress-plugin
5
- Description: <strong><a href="http://www.mightymess.com/soundcloud-is-gold-wordpress-plugin">Soundcloud is gold</a></strong> integrates perfectly into wordpress. Browse through your soundcloud tracks from the 'soundcloud is gold' tab with the post's 'upload media' popup window. Select, set and add track to your post using the soundcloud player. Live Preview, easy, smart and straightforward. You can set default settings in the option page, choose your defaut soundcloud player (Mini, Standard, Artwork, html5), its width, extra classes for you CSS lovers and your favorite colors. You'll still be able to set players to different settings before adding to your post if you fancy a one off change. Now with Html5 player!
6
- Version: 1.0.5
7
  Author: Thomas Michalak at Mighty Mess
8
  Author URI: http://www.mightymess.com/thomas-michalak
9
  License: GPL2 or Later
@@ -12,7 +12,7 @@ License: GPL2 or Later
12
  /*
13
  Default Sizes
14
  mini: h = 18, w = 100%
15
- standard: h = 81, w = 100%
16
  artwork: h = 300, w = 300
17
  html5: h=166, w=100%
18
  */
2
  /*
3
  Plugin Name: Soundcloud is Gold
4
  Plugin URI: http://www.mightymess.com/soundcloud-is-gold-wordpress-plugin
5
+ Description: <strong><a href="http://www.mightymess.com/soundcloud-is-gold-wordpress-plugin">Soundcloud is gold</a></strong> integrates perfectly into wordpress. Browse through your soundcloud tracks, sets and favorites from the 'soundcloud is gold' tab with the post's 'upload media' popup window. Select, set and add track, sets or favorites to your post using the soundcloud player. Live Preview, easy, smart and straightforward. You can set default settings in the option page, choose your defaut soundcloud player (Mini, Standard, Artwork, html5), its width, extra classes for you CSS lovers and your favorite colors. You'll still be able to set players to different settings before adding to your post if you fancy a one off change. Now with Html5 player!
6
+ Version: 1.0.6
7
  Author: Thomas Michalak at Mighty Mess
8
  Author URI: http://www.mightymess.com/thomas-michalak
9
  License: GPL2 or Later
12
  /*
13
  Default Sizes
14
  mini: h = 18, w = 100%
15
+ standard: h = 81 (165), w = 100%
16
  artwork: h = 300, w = 300
17
  html5: h=166, w=100%
18
  */