Last active
December 21, 2015 16:49
-
-
Save grappler/6336435 to your computer and use it in GitHub Desktop.
This short plugin allows users to display content according to the device the page is being viewed on.
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 | |
/** | |
* | |
* @package Adaptive Shortcode | |
* @author Ulrich Pogson <grapplerulrich@gmail.com> | |
* @license GPL-2.0+ | |
* @link http://ulrich.pogson.ch | |
* @copyright 2013 Ulrich Pogson | |
* | |
* @wordpress-plugin | |
* Plugin Name: Adaptive Shortcode | |
* Plugin URI: https://gist.github.com/grappler/6336435 | |
* Description: This short plugin allows users to display content according to the device the page is being viewed on. | |
* Version: 1.0.0 | |
* Author: Ulrich Pogson | |
* Author URI: http://ulrich.pogson.ch | |
* License: GPL-2.0+ | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt | |
*/ | |
/** | |
* Add Shortcode for mobile content | |
* | |
* @example [is_mobile][/is_mobile] | |
*/ | |
function is_mobile_shortcode( $atts , $content = null ) { | |
if ( wp_is_mobile() ) { | |
return do_shortcode( $content ); | |
} | |
} | |
add_shortcode( 'is_mobile', 'is_mobile_shortcode' ); | |
/** | |
* Add Shortcode for desktop content | |
* | |
* @example [is_desktop][/is_desktop] | |
*/ | |
function is_desktop_shortcode( $atts , $content = null ) { | |
if ( ! wp_is_mobile() ) { | |
return do_shortcode( $content ); | |
} | |
} | |
add_shortcode( 'is_desktop', 'is_desktop_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment