Changeset 566171
- Timestamp:
- 07/01/2012 07:48:16 PM (14 years ago)
- Location:
- jetpack-easy-playlists
- Files:
-
- 3 added
- 2 edited
-
tags/2.1 (added)
-
tags/2.1/jetpack_easy_playlists.php (added)
-
tags/2.1/readme.txt (added)
-
trunk/jetpack_easy_playlists.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
jetpack-easy-playlists/trunk/jetpack_easy_playlists.php
r565420 r566171 4 4 Plugin URI: http://www.jamesfishwick.com/software/auto-jetpack-playlist/ 5 5 Description: A simple [audio] shortcode wrapper to generate playlists automatically from mp3s attached to your post/page. Requires Jetpack. 6 Version: 2. 16 Version: 2.2 7 7 Author: James Fishwick 8 8 Author URI: http://www.jamesfishwick.com/ 9 9 License: GPL2 10 10 */ 11 /* Copyright 2012 James Fishwick (email : fishwick@gmail.com)11 /* Copyright 2012 James Fishwick fishwick@gmail.com 12 12 13 13 This program is free software; you can redistribute it and/or modify … … 35 35 $required_plugin = 'jetpack/jetpack.php'; 36 36 $dependant_plugin = 'easy_jetpack_playlists/easy_jetpack_playlists.php'; 37 38 37 39 38 40 // If this plugin is being activated … … 89 91 return implode( $separator, $string ); 90 92 } 93 function var_to_str($in) 94 { 95 if(is_bool($in)) 96 { 97 if($in) 98 return "true"; 99 else 100 return "false"; 101 } 102 else 103 return $in; 104 } 105 106 function is_mp3( $file ) { 107 $extension = end( explode( ".", $file->guid ) ); 108 return ($extension == "mp3"); 109 } 91 110 111 function get_ID_by_slug($page_slug) { 112 $page = get_page_by_path($page_slug); 113 if ($page) { 114 return $page->ID; 115 } else { 116 return null; 117 } 118 } 119 92 120 add_shortcode('jplaylist', 'easyjp_playlists'); 93 121 94 122 function easyjp_playlists( $atts ) { 95 96 if( class_exists( 'AudioShortcode' ) && method_exists( 'AudioShortcode', 'audio_shortcode' ) ) { 97 123 //if( class_exists( 'AudioShortcode' ) && method_exists( 'AudioShortcode', 'audio_shortcode' ) ) { 124 //if ( function_exists('Jetpack::get_active_modules') ) { 125 if( in_array("shortcodes", Jetpack::get_active_modules()) ) { 126 98 127 // these will store location, and artist and title info for the player 99 128 $urls = $titles = $artists = array(); 129 $pidset = false; 100 130 101 // prepares attributes to be passed in the way [audio] wants them 131 132 // from what post/page are we getting the attachments? -- pid att 133 if ( isset($atts['pid']) ) { 134 $pidset = true; 135 $pid = $atts['pid']; 136 unset( $atts['pid'] ); 137 $pid = ( is_numeric($pid) ? $pid : url_to_postid($pid) ); 138 139 140 } 141 142 else { 143 $pid = get_the_ID(); 144 } 145 146 // prepares attributes to be passed in the way [audio] wants them. To do: filter atts? 102 147 $results = array_implode('=',"|", $atts); 103 148 104 // gets all the audio attachments. To do: only return mp3s149 // gets all the audio attachments. 105 150 $attachments = get_children( array( 106 'post_parent' => get_the_ID(),151 'post_parent' => $pid, 107 152 'post_type' => 'attachment', 108 153 'numberposts' => -1, // show all -1 109 154 'post_status' => 'inherit', 110 'post_mime_type' => 'audio ',155 'post_mime_type' => 'audio/mpeg,', 111 156 'order' => 'ASC', 112 157 'orderby' => 'menu_order ASC' 113 158 ) ); 114 159 160 $attachments = array_filter($attachments, "is_mp3"); // only mp3s can be used in playlists. filter out other audio (mime won't get this all right) 161 162 if ($attachments) { 163 115 164 // push all the data in to the arryas 116 165 foreach ( $attachments as $attachment_id => $attachment ) { 166 117 167 array_push($urls, wp_get_attachment_url( $attachment_id )); // url of each mp3 118 168 array_push($titles, get_the_title($attachment_id)); // gets the title of the mp3. This is the literal title in the media library … … 130 180 $shortcode = '<!-- audio shortcode is [audio '.$comma_separated_urls.'|titles='.$comma_separated_titles.'|artists='.$comma_separated_artists.'|'.$results.'] -->'; 131 181 return $playlist.PHP_EOL.$shortcode; 182 } 183 184 else { 185 $jep_error_msg = "Sorry pal, no mp3s found for your playlist. "; 186 if ($pidset) {$jep_error_msg .=" Check your page/post id?";} 187 return "<p><strong style='color:red'>".$jep_error_msg."</strong></p>"; 188 } 189 132 190 } 133 191 else { 134 return "<p><strong style='color:red'>Whoops, your playlist won't work without Jetpack !</strong></p>";192 return "<p><strong style='color:red'>Whoops, your playlist won't work without Jetpack's shortcode functionality!</strong></p>"; 135 193 } 136 194 }?> -
jetpack-easy-playlists/trunk/readme.txt
r565420 r566171 5 5 Requires at least: 3.4 6 6 Tested up to: 3.4.1 7 Stable tag: 2. 17 Stable tag: 2.2 8 8 9 9 Generate playlists automatically from mp3s attached to your post/page. Requires Jetpack. … … 11 11 == Description == 12 12 13 14 13 Audio support in Wordpress makes me cry. No native player, the fields in the Media library seem wrong for audio, and let's not get into ID3 tag reading. The audio shortcode and player provided by Jetpack is a step in the right direction. However, the ability to directly create a player or playlist on a post/page from attached mp3s makes me sad again. Writing that shortcode is nasty business for anything beyond a file or two. 15 14 16 And what about the [gallery] shortcode for images? So easy to round up all your attached pictures and display them all automagically. Why no love for audio?15 And what about the [gallery] shortcode for images? So easy to round up all your attached pictures and display them all automagically. Why no love for [audio[? 17 16 18 This plugin acts as a wrapper for Jetpack's [audio] shortcode. It rounds up all the mp3s attached to your post/page and adds them as a playlist in the Jetpack player. Simply attach your mp3s to your post/page and use the shortcode "[jplaylist]" where you want your playlist. 17 This plugin acts as a wrapper for Jetpack's [audio] shortcode. It rounds up all the mp3s attached to your post/page and adds them as a playlist in the Jetpack player. Simply attach your mp3s to your post/page and use the shortcode "[jplaylist]" where you want your playlist 18 19 JEP supports all the options that [audio] does, and now allows you to call up attachments from other pages/posts. 19 20 20 21 Requires [Jetpack](http://jetpack.me/). 21 22 22 23 [Plugin Homepage](http://www.jamesfishwick.com/software/auto-jetpack-playlist/) 23 24 **Updated to fix "unexpected $end" bug and to work with 3.4.25 24 26 25 … … 58 57 [jplaylist bgcolor=000000|lefticon=00ff00|righticon=FF0000|animation=no|loop=yes] 59 58 59 = Can I use attachments from a different page/post? = 60 61 Sure. You use the "pid" attribute with a post/page id or permalink slug. 62 63 Examples: 64 65 [jplaylist pid="173"] 66 [jplaylist pid="software/jetpack-easy-playlists/"] 67 68 [More details](http://jamesfishwick.com/2012/jetpack-easy-playlists-update/) 69 60 70 = Can you support my favorite player WordPess player plugin xyz? = 61 71 … … 67 77 68 78 == Changelog == 79 80 = 2.2 = 81 * More robust check for Jetpack and shortcodes module to avoid future bugs ala http://jamesfishwick.com/2012/jetpack-easy-playlists-update/ 82 * Filters out non-mp3 audio files 83 * You can call playlists from other posts with the "pid" attribute 84 * Smarter error messages 85 86 = 2.1 = 87 * Cleaned up code and properly updated readme 69 88 70 89 = 2.0 =
Note: See TracChangeset
for help on using the changeset viewer.