Skip to content

Instantly share code, notes, and snippets.

@carmichaelize
Last active August 29, 2015 14:00
Show Gist options
  • Save carmichaelize/11008956 to your computer and use it in GitHub Desktop.
Save carmichaelize/11008956 to your computer and use it in GitHub Desktop.
Wordpress Shortcode Wrapper
<?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