Skip to content

Instantly share code, notes, and snippets.

@raidenz
Created February 4, 2015 16:49
Show Gist options
  • Save raidenz/37caeaba8c778df2aedf to your computer and use it in GitHub Desktop.
Save raidenz/37caeaba8c778df2aedf to your computer and use it in GitHub Desktop.
shortcode.class.php
<?php
#PLUGIN SHORTCODE MANAGEMENT
class hslider_shortcodes{
#CLASS VARS
private $shortcode; //plugin shortcode is the same as the plugin name
private $plugin_dir;
private $plugin_url;
private $display;
private $frontend;
//denadd blank
private $plugin_prefix;
#CONSTRUCT
public function __construct($plugin_name,$plugin_dir,$plugin_url){
$this->shortcode = $plugin_name;
$this->plugin_dir = $plugin_dir;
$this->plugin_url = $plugin_url;
$this->display = new hslider_display($this->plugin_dir);
$this->frontend = new hslider_frontend();
}
#INITIALISE SHORTCODE LISTENER
public function initialise_shortcode_listener(){
//remove shortcode listener
remove_shortcode($this->shortcode);
//add shortcode listener
add_shortcode($this->shortcode, array(&$this,'use_shortcode'));
//denadd test
//echo 'telo'.$this->plugin_url;
}
#USE SHORTCODE
public function use_shortcode($atts){ //all front-end code can be initialised here...
//load front-end css
//$this->load_frontend_css();
//denadd use wp enqueue
//moved to plugin_setup.class.php
//load front-end scripts
//$this->load_frontend_javascript();
//denadd
//moved to plugin_setup.class.php
//define content
$content = $this->frontend->get_shortcode_content($atts);
//display content on front-end
return $this->display->output_frontend($content); //this ensure output buffering takes place
}
#IMPLEMENT FRONT-END CSS
private function load_frontend_css(){
//front-end css
//denadd move to plugin_setup.class.php
//wp_enqueue_style($this->plugin_prefix .'userstyles');
}
#IMPLEMENT FRONT-END JS
private function load_frontend_javascript(){
//front-end javascript
//moved to plugin_setup.class.php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment