'Portfolio', 'url' => 'http://awhitebox.com', 'author' => 'Ali B.', 'authorurl' => 'http://awhitebox.com', 'version' => '1.0', 'description' => 'Portolio Content type', 'license' => 'ASL 2.0', ); } public function action_plugin_activation( $plugin_file ) { Post::add_new_type( 'work' ); } public function action_plugin_deactivation( $plugin_file ) { Post::deactivate_post_type( 'work' ); } /** * Actions to be carried out when the site is accessed * and the plugin is active. */ public function action_init() { /* $this->add_template( 'work.multiple', dirname( __FILE__ ) . '/templates/rawphp/podcast.multiple.php' ); $this->add_template( 'work.single', dirname( __FILE__ ) . '/templates/rawphp/podcast.single.php' ); */ } public function filter_rewrite_rules( $rules ) { $rules[] = new RewriteRule( array( 'name' => 'display_work', 'parse_regex' => '%^portfolio/(?P[^/]+)(?:/page/(?P\d+))?/?$%i', 'build_str' => 'portfolio/{$slug}', 'handler' => 'UserThemeHandler', 'action' => 'display_post', 'priority' => 7, 'is_active' => 1, 'description' => 'Displays the Work post', )); $rules[] = new RewriteRule( array( 'name' => 'display_works', 'parse_regex' => '%^portfolio/(?:page/(?P\d+))/?$%i', 'build_str' => 'portfolio/(page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_works', 'priority' => 7, 'is_active' => 1, 'description' => 'Displays the Work posts', )); return $rules; } public function filter_theme_act_display_works( $handled, $theme ) { $paramarray['fallback'] = array( 'work.multiple', 'entries.multiple', 'multiple', 'home', ); $default_filters = array( 'content_type' => Post::type( 'work' ), ); $paramarray['user_filters'] = $default_filters; $theme->act_display( $paramarray ); return true; } public function filter_post_type_display($type, $foruse) { $names = array( 'work' => array( 'singular' => _t( 'Work' ), 'plural' => _t( 'Works' ), ) ); return isset($names[$type][$foruse]) ? $names[$type][$foruse] : $type; } public function filter_template_where_filters( $filters ) { $vars = Controller::get_handler_vars(); if( strlen( $vars['entire_match'] ) && strpos( $vars['entire_match'], 'portfolio/page' ) !== FALSE) { $filters['limit'] = '4'; $filters['content_type'] = 'work'; } return $filters; } } ?>