Last active
April 3, 2018 06:20
-
-
Save dcangulo/4599c59975c782ea771b8548fadf63b1 to your computer and use it in GitHub Desktop.
A WordPress plugin shortcode template on both oop and procedural approach. Visit https://www.davidangulo.xyz/ for more information.
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 | |
/* | |
Plugin Name: Example Shortcode Plugin | |
Plugin URI: https://wordpress.org/plugins/ | |
Description: Just another example shortcode plugin. | |
Version: 1.0.0 | |
Author: David Angulo | |
Author URI: https://www.davidangulo.xyz/ | |
*/ | |
class myShortCode { | |
public function __construct() { | |
add_shortcode("my_custom_shortcode",array($this,"myShortCodeRender")); | |
} | |
public function myShortCodeContent() { | |
echo "Hello! I am a custom shortcode."; | |
} | |
public function myShortCodeRender() { | |
ob_start(); | |
$this->myShortCodeContent(); | |
return ob_get_clean(); | |
} | |
} | |
$object = new myShortCode; | |
//Visit the tutorial for more information | |
//https://www.davidangulo.xyz/website-development/how-to-create-custom-wordpress-shortcode-plugin-from-scratch/ |
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 | |
/* | |
Plugin Name: Example Shortcode Plugin | |
Plugin URI: https://wordpress.org/plugins/ | |
Description: Just another example shortcode plugin. | |
Version: 1.0.0 | |
Author: David Angulo | |
Author URI: https://www.davidangulo.xyz/ | |
*/ | |
function myShortCodeContent() { | |
echo "Hello! I am a custom shortcode."; | |
} | |
function myShortCodeRender() { | |
ob_start(); | |
myShortCodeContent(); | |
return ob_get_clean(); | |
} | |
add_shortcode("my_custom_shortcode","myShortCodeRender"); | |
//Visit the tutorial for more information | |
//https://www.davidangulo.xyz/website-development/how-to-create-custom-wordpress-shortcode-plugin-from-scratch/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment