Created
January 19, 2015 18:41
-
-
Save metinsaylan/627e16adddba42e23d84 to your computer and use it in GitHub Desktop.
WordPress desktoponly and mobileonly shortcodes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// [desktoponly] shortcode | |
add_shortcode('desktoponly', 'shailan_desktop_only_shortcode'); | |
function shailan_desktop_only_shortcode($atts, $content = null){ | |
if( !wp_is_mobile() ){ | |
return wpautop( do_shortcode( $content ) ); | |
} else { | |
return null; | |
} | |
} | |
// [mobileonly] shortcode | |
add_shortcode('mobileonly', 'shailan_mobile_only_shortcode'); | |
function shailan_mobile_only_shortcode($atts, $content = null){ | |
if( wp_is_mobile() ){ | |
return wpautop( do_shortcode( $content ) ); | |
} else { | |
return null; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment