Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

andy_woz on "Rewrite shortcode if mobile device."

$
0
0

Hi I have an older site that uses a flash based audio player proprietary shortcode in the page content. What I'd like to do is to switch to an HTML5 audio player for mobile devices. I guess I'd be looking for a filter to replace shortcode content based on device?

I know wordpress has an wp_is_mobile() function. Could that be used to rewrite shortcodes in the content?

I'd need to change shortcodes in the format [audio:http://myaudiosource.com/filename.mp3|titles=My audio Title]
to
[audio src="http://myaudiosource.com/filename.mp3|titles=My audio Title"]
for mobile devices, assuming the |titles part wouldn't break the player.

Maybe I could do a preg_replace() just not sure how to target the shortcodes in a function.

Thanks!


Viewing all articles
Browse latest Browse all 8245

Trending Articles