/** * Redirects the link from an embedded player, feed, or an html * download link to the actual file * * @param PluginHandler $handler. Primarily used to get the handler vars * @return Nothing. * @TODO make sure $podcast actually holds a valid feed * @TODO make sure $method is valid */ public function action_plugin_act_podcast_media( $handler ) { $podcast = $handler->handler_vars['podcast_name']; $post = Post::get( array( 'slug' => $handler->handler_vars['post_name'] ) ); $method = $handler->handler_vars['method']; $filename = $handler->handler_vars['filename']; $info = $post->info->{$podcast}; if( !empty( $info ) && isset( $info['enclosure'] ) ) { $url = $info['enclosure']; // allow plugins to act. mostly good for stats Plugins::act( 'podcast_redirect', $podcast, $post, $method, $filename ); $mimetype = Utils::mimetype( $url ); header( 'Cache-Control: no-cache, must-revalidate' ); // HTTP/1.1 header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); header( 'Pragma:no-cache'); // HTTP/1.0 header( 'Content-type: ' . $mimetype ); header('Content-Length: '. $info['size'] ); Utils::redirect( $url ); } } /** * Actions to be carried out when the site is accessed * and the plugin is active. */ public function action_init() { $this->load_text_domain( 'podcast' ); $this->add_template( 'podcast.multiple', dirname( __FILE__ ) . '/templates/rawphp/podcast.multiple.php' ); $this->add_template( 'podcast.single', dirname( __FILE__ ) . '/templates/rawphp/podcast.single.php' ); $this->add_template( 'podcast.multiple', dirname( __FILE__ ) . '/templates/hi/podcast.multiple.php' ); $this->add_template( 'podcast.single', dirname( __FILE__ ) . '/templates/hi/podcast.single.php' ); $this->add_rule("'podcast'/podcast_name/post_name/method/filename", 'podcast_media'); }