How to allow audio files with GET parameters in the audio shortcode?

There’s an interesting question on WordPress Stackexchange regarding the audio shortcode .

It looks like it doesn’t support sources with GET parameters.

Here are two examples:

1) Without GET parameters the audio player displays:

where the shortcode is:

[audio src=""]

2) With GET parameters it only shows the audio link:

where the shortcode is:

[audio src=""]

I managed to work around it with the following code snippet:

 * Allow unrecognize audio sources hosted on ''.
 * @see

add_filter( 'wp_audio_shortcode_override',
    function( $html, $atts )
        if( '' === parse_url( $atts['src'], PHP_URL_HOST ) )
            add_filter( 'wp_audio_extensions', 'wpse_152316_wp_audio_extensions' );
        return $html;
, PHP_INT_MAX, 2 );

function wpse_152316_wp_audio_extensions( $ext )
    remove_filter( current_filter(), __FUNCTION__ );
    $ext[] = '';
    return $ext;

A simple plugin to run JetPack locally

We don’t need to modify the wp-config.php file as before with:

define ('JETPACK_DEV_DEBUG', true);

to run JetPack in the development mode.

By using the jetpack_development_mode filter described here, we can construct this simple plugin:

 * Plugin Name: Run JetPack locally
 * Plugin URI:
 * Author:      birgire
 * Version:     0.0.3

// Activate the development mode:

to make your life easier 😉 and it’s available on GitHub.

This class method of the JetPack class contains the filter:

	 * Is Jetpack in development (offline) mode?
	public static function is_development_mode() {
		$development_mode = false;

		if ( defined( 'JETPACK_DEV_DEBUG' ) ) {
			$development_mode = JETPACK_DEV_DEBUG;

		elseif ( site_url() && false === strpos( site_url(), '.' ) ) {
			$development_mode = true;

		return apply_filters( 'jetpack_development_mode', $development_mode );

WordPress: Playlist shortcode with external audio or video files

The new [playlist] shortcode  in WordPress 3.9 is great, but we can’t use it for external files.

Here’s a solution I wrote on WPSE to use it for external files.

The plugin is hosted on GitHub.

Here’s version 0.05b for those who use PHP 5.1.x or PHP 5.2.x.

WordPress 4.0 support:

Please update to version 0.0.5+ of the plugin due to some small playlist changes in WordPress 4.0. Thanks.

Version 0.0.6, now supports with autoplay and the GitHub Updater support. It works on WordPress 4.0+.

Version 0.0.7 introduced the new shortcodes [_playlist] and [_track] and the support for the shortcodes [wpse_playlist] and [wpse_trac] will phase out.

The current version is 0.0.9.

Example 1a

This audio playlist:

is generated by the following shortcode:

[_playlist type="audio" tracklist="true" tracknumbers="true" images="true" artist="true"]
    [_track title="Ain't Misbehavin'" src="//" type="audio/mpeg" caption="" description="" image="" meta_artist="Louis Armstrong and His Orchestra" meta_album="78 RPMs and Cylinder Recordings" meta_genre="" meta_length_formatted="3:21" image_src="//" image_width="308" image_height="240" thumb_src="//" thumb_width="308" thumb_height="240"]
    [_track title="Buddy Bolden's Blues" src="//" type="audio/mpeg" caption="" description="" image="" meta_artist="Jelly Roll Morten" meta_album="78 RPMs and Cylinder Recordings" meta_genre="Jazz" meta_length_formatted="2:09"]

Example 1b

Here’s the playlist from example 1a, but with

tracknumbers="false" images="false"

Example 2

Here’s the vanilla version of the above audio playlist:

generated from the shortcode:

[_playlist type="audio" current="no" tracklist="yes" tracknumbers="no" images="no" artist="no"]
    [_track title="Davenport Blues" src="//"]
    [_track title="Dixie Blues" src="//"]

Example 3

Here’s a video playlist:


[_playlist type="video"]
    [_track caption="Live widgets previews in WordPress 3.9" src="//" image_src="/projects/wp-content/uploads/2014/04/widgets_screen.gif"]

Happy listening!


0.0.8 (2015-08-02)
– Fixed: Issue #7 by using true/false instead of 1/0 (Props: @X-PRESSIVE)

0.0.7 (2015-03-08)
– Added: New shortcodes [_playlist] and [_track].
– Deprecated: The support for the shortcodes [wpse_playlist] and [wpse_trac] will phase out.

0.0.6 (2015-03-07)
– Added: Support for the autoplay attribute.
– Added: Support for the GitHub Updater. (Probs: @BlaineMoore)
– Added: More info in the file.
– Changed: Replaced filter_var() with wp_validate_boolean(), so we need WordPress 4.0+.
– Changed: Refactoring regarding late escaping.
– Fixed: Some minor adjustments.

– Fixed: added the missing script class to support WordPress 4.0 (Props: @ruLait)

WordPress developer links

Here are some useful links:

WordPress Codex:

Plugin API/Action Reference: Forums:

WordPress Planet:

Plugin Directory:

Make WordPress:

WordPress TV:

WordPress Answers:

Why is my WordPress so slow? How to identify the problems

Image from’s difficult to give an answer to this kind of question, so I will list general things that have helped me to identify problems of this kind:

Profile everything you can:

The P3 Profiler plugin will profile your plugins:

I also recommend the `Debug bar` (and it’s extensions)

and the `Blackbox` debug bar to profile your *problematic?* queries:

Memory viewer for your hooks:

If you have lot’s of comment’s that are constantly refreshing the cache,
you might also consider using comment services like Facebook / Intense Debate / Disqus / LiveFyre

Use WordPress cache plugins, many good out there.

Test your site with online performance services:

Here is one:

New Relic:

View the log files:

Check all log files you have (php, apache, nginx, mysql, …)

If you have ssh access:

Also consider using `Nginx` instead of `Apache`

You should also check what process is using your resources via ps/top/htop/… (i.e. is it apache or mysql or something else) if you have access to a Linux console

If it’s mysql there is a great script called that can give you hints how to configure it (if you have access to ssh, you can check it with top or htop)

Use APC cache for php

(this article is a work in progress)

Countdown between two unix timestamps

Here is a way to display the day/hour/min difference between two unix timestamps, fx

6 days 6 hours 37 minutes

Here is the above example

echo countdown($current_time,$future_time); 

and here is the function where you can translate/change the labels:

* Calculates the number of days, hours and minutes 
* between two Unix timestamps.  
* The Unix timestamp $t2 should be greater than $t1  
* @param integer $t1 Date with Unix timestamp format.  
* @param integer $t2 Date with Unix timestamp format.  
* @return string Formatted string 
* fx: 3 days 5 hours 23 minutes  
function countdown($t1,$t2){         
        // t2 > t1

        // setup
        $out ="";
        $days_label=" days ";
        $day_label=" day ";
        $hours_label=" hours ";
        $hour_label=" hour ";
        $mins_label=" minutes ";
        $min_label=" minute "i
        $timeup_label=" ho ho - the time is up";

        // calculate

        // find out the labels (singular/plural)

        // output
                $out.= $days.$d_label;
                $out.= $hours.$h_label;
                $out.= $mins.$m_label;
        if($days+$hous+$mins <= 0 ){

        return $out;

Pizza order time – content with weekly opening hours

This forum thread:

gave me an idea of a shortcode that can display content during given opening hours in the week and can handle shortcodes inside it.

Maybe this will grow into a plugin in the near future 😉

The shortcode is

[openinghours] ... some content only available during opening hours ... [/openinghours]

and here is an example of the supported (optional) attributes:

sun="11:00-22:30" // the opening hours every sunday
debug="0" // debug="1" will display debug information
sorry="Sorry, we are closed now. Try again during the opening hours." // text to display when it's closed
holidays="2012-07-04,2012-12-24"  // YYYY-MM-DD, YYYY-MM-DD,...

Here is a full working example (closed every sunday and saturday and open from 09-17 mon-fri. Holidays are 2012-07-04 and 2012-12-24):

[openinghours mon="09:00-17:00" tue="09:00-17:00" wed="09:00-17:00" thu="09:00-17:00" fri="09:00-17:00"  debug="0" holidays="2012-07-04,2012-12-24" sorry="Sorry, we are closed now. Try again during the opening hours."] please order now! [foobar]

Here is the code to paste into the functions.php file:

 * Plugin Name: Opening hours - shortcode
 * Description: A [openinghours] shortcode to display content only on given weekly opening hours.
 * Author:      birgire
 * Author URI:
 * Version:     1.1

function my_openinghours( $atts = array() ,$content = '' ){
        extract( shortcode_atts( array(
                'sun'      => '', // the opening hours every sunday
                'mon'      => '', // the opening hours every monday
                'tue'      => '',
                'wed'      => '',
                'thu'      => '',
                'fri'      => '',
                'sat'      => '',
                'sorry'    => '', // text to display when it's closed
                'debug'    => '0', // debug="1" will display debug information
                'holidays' => '', // fx: holidays="2012-07-04,2012-12-24", the format is YYYY-MM-DD, YYYY-MM-DD,...
        ), $atts ) );

        // Current time:
        $currT      = time();
        $currYMD    = date( "Y-m-d",       $currT );
        $currYMDHIS = date( "Y-m-d H:i:s", $currT );
        $currWD     = date( "w",           $currT );

        // Get the opening hours for today:
        switch ($currWD ){
                case 0:
                        $s = $sun;
                case 1:
                        $s = $mon;
                case 2:
                        $s = $tue;
                case 3:
                        $s = $wed;
                case 4:
                        $s = $thu;
                case 5:
                        $s = $fri;
                case 6:
                        $s = $sat;
                        $s = "";

        // format input
        $out      = esc_attr( $sorry );
        $holidays = esc_attr( $holidays );
        $s        = esc_attr( trim( $s ) );
        $debug    = (int) $debug;

        // do the time checks
        if( strlen( $s ) > 0 ){
                $a = explode( "-", $s );
                if( count( $a ) == 2 ){
                        $from  = $currYMD." ".$a[0].":00";
                        $to    = $currYMD." ".$a[1].":00";
                        $fromT = strtotime( $from );
                        $toT   = strtotime ($to );
                        if( $currT > $fromT && $currT < $toT && false === strpos( $holidays, $currYMD ) ){
                                $out = do_shortcode( $content );

        // Check if we have debug mode on:
        if( $debug ){
                $out .= "<div style='background-color:#ccc;padding:10px;border:1px solid #333;margin:10px;'>Debug: <br/>";
                $out .= sprintf( "from: %s <br/> current: %s <br/> to: %to </div>", $from, $currYMDHIS, $to );
        return $out;


bon appetit 😉


version 1.1
added holidays

version 1.0
inital version (Props: @lemonadejoex, @keesiemeijer)

YouList – Youtube playlist shortcode – wordpress plugin

Download the plugin here:

Support Open Source developement:

The plugin supports both single and multi site WordPress installs.


How to use this plugin?
When you have installed it, you can for example start by pasting this shortcode into your WordPress post editor:

[youlist pid="PL3FF15AA7ED356D9F"]

like this:


and preview the post. Then you can change the pid value to match your own playlist.

The above pid value is taken from this playlist url:

You can then try out the usage examples given below or here:

There is a small playlist icon in the bottom right corner

Showcases (responsive and with hd playback)

Few usage examples:

Example: Adele YouTube playlist with thumbnails

[youlist pid="PL3FF15AA7ED356D9F"]

Example: Adele YouTube playlist with custom styling

[youlist pid="PL3FF15AA7ED356D9F" style="width:400px;height:300px;z-index:1;border:2px solid gold;background-color:orange;padding:10px;"]

Example: Playlist from the search string “higgs boson”

[youlist search="higgs boson"]

Example: Playlist for uploaded videos by the user “mismag822”

[youlist uid="mismag822" listtype="user_uploads"]

Example: Playlist for favorite videos of the user “mismag822”

[youlist uid="mismag822" listtype="user_favorites"]

Example: Three YouTube videos with thumbnails

[youlist vid="ZF_K8D414-Y,sFHXWoawnt0,E2uOGOqIyC4"]

Example: Three YouTube videos without thumbnails

[youlist vid="ZF_K8D414-Y,sFHXWoawnt0,E2uOGOqIyC4" showinfo="0" ]