Esempio n. 1
0
 /**
  * Constructor for the class it  register the view and  model class
  * used to implement then MVC pattern
  *
  */
 protected function __construct()
 {
     $this->view = SlideshowView::getSingleton();
     $this->model = SlideshowModel::getSingleton();
     //Init the plugin
     add_action('init', array(&$this, 'initPlugin'));
     // View actions
     add_action('add_meta_boxes', array(&$this->view, 'registerMetabox'));
     add_shortcode('slideshow', array(&$this->view, 'slideshowShortcode'));
     add_filter('template_include', array(&$this->view, 'slideshowTemplate'), 1, 1);
     add_action('wp_enqueue_scripts', array(&$this->view, 'includeScripts'));
     add_filter('single_template', array(&$this->view, 'slideshowDefaultTemplate'));
     // Model actions
     add_action('save_post', array(&$this->model, 'saveSlideshow'));
     add_action('restrict_manage_posts', array(&$this->model, 'filterSlideshows'));
     add_filter('parse_query', array(&$this->model, 'modifyQuery'));
     // Customize taxonomy forms
     add_filter("admin_footer-edit-tags.php", array(&$this->model, 'slideGroupForm'));
     // Modify default columns
     add_filter("manage_edit-" . SLIDESHOW_POST_TYPE . "_columns", array(&$this->model, 'slideColumns'));
     // Add new column  to the custom post type
     add_action("manage_posts_custom_column", array(&$this->model, 'slideCustomColumns'), 10, 2);
     // Modify default columns
     add_filter("manage_edit-" . SLIDESHOW_TAXONOMY_TYPE . "_columns", array(&$this->model, 'slideGroupColumns'));
     // Add new column  to the taxonomy
     add_filter("manage_" . SLIDESHOW_TAXONOMY_TYPE . "_custom_column", array(&$this->model, 'slideGroupCustomColumns'), 10, 3);
 }
Esempio n. 2
0
 /**
  * Search for the shortcode in all  the post and pages and return the 
  * url of the content that includes the shortcode
  * 
  * @param string $template the actual template url
  */
 public function slideshowTemplate($template)
 {
     global $wp_query;
     // If the post type is in-slideshow post type search for the shortcode in all the  pages and post
     if (get_post_type() === "in-slideshow") {
         // Get the link to the shortcode
         $link = SlideshowModel::getSingleton()->searchShortcode($wp_query);
         // Redirect the user to the link
         if ($link != "") {
             //Get the post
             $post = $wp_query->posts[0];
             update_option("in_slide_actual", $post->ID);
             wp_redirect($link);
             exit;
         }
     }
     return $template;
 }