Last active
August 29, 2015 14:00
-
-
Save carmichaelize/11008956 to your computer and use it in GitHub Desktop.
Wordpress Shortcode Wrapper
This file contains hidden or 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 | |
class shortcode { | |
//Shortcode name | |
public $name = 'shortcode_name' | |
//Default attributes | |
public $args = array(); | |
//Shortcode function | |
public function shortcode_function( $args, $content ){ | |
//Merge and extract $args | |
extract( shortcode_atts( $this->args, $args ) ); | |
//Validate data | |
if( !$content ) return false; | |
//Edit and/or echo data | |
echo $content; | |
} | |
public function __construct(){ | |
//Add shortcode | |
add_shortcode( $this->name, array( &$this, 'shortcode_function' ) ); | |
} | |
} | |
new shortcode(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment