Skip to content

Instantly share code, notes, and snippets.

@davidkryzaniak
Last active December 20, 2015 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidkryzaniak/6043945 to your computer and use it in GitHub Desktop.
Save davidkryzaniak/6043945 to your computer and use it in GitHub Desktop.
Generic WP ShortCode Boilerplate (OOP)
<?php
/**
* Plugin Name: ShortCode
*
* Usage: [MyShortcode]
*/
class myShortCode {
public function __construct(){
add_shortcode('MyShortcode', array($this, 'shortCodeFunction'));
}
public function shortCodeFunction(){
return 'Hello, World';
}
}
$doShortCode = new myShortCode();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment