Skip to content

Instantly share code, notes, and snippets.

@justinrainbow
Forked from aforwark/flashpanels.php
Created April 25, 2012 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinrainbow/2492025 to your computer and use it in GitHub Desktop.
Save justinrainbow/2492025 to your computer and use it in GitHub Desktop.
flash panel plugin
<?php
/*
Plugin Name: Flash Panels
Description: This plugin handles the flash panels that can be used on SheKnows Blogs
*/
class FlashPanelPostType
{
private $args = array(
'labels' => array(),
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'author', 'revisions', 'thumbnail'),
'taxonomies' => array( 'category', 'post_tag', 'page-category' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
public function init()
{
$this->args['labels'] = array(
'name' => _x( 'Flash Panels', 'flash_panel' ),
'singular_name' => _x( 'Flash Panel', 'flash_panel' ),
'add_new' => _x( 'Add New', 'flash_panel' ),
'add_new_item' => _x( 'Add New flash panel', 'flash_panel' ),
'edit_item' => _x( 'Edit flash panel', 'flash_panel' ),
'new_item' => _x( 'New flash panel', 'flash_panel' ),
'view_item' => _x( 'View flash panel', 'flash_panel' ),
'search_items' => _x( 'Search flash panels', 'flash_panel' ),
'not_found' => _x( 'No flash panels found', 'flash_panel' ),
'not_found_in_trash' => _x( 'No flash panels found in Trash', 'flash_panel' ),
'parent_item_colon' => _x( 'Parent flash panel:', 'flash_panel' ),
'menu_name' => _x( 'Flash Panels', 'flash_panel' ),
);
register_post_type( 'flashpanel', $this->args );
}
}
$_fp = new FlashPanelPostType();
add_action('init', array($_fp, 'init'));
function get_flashpanels($limit = 9) {
$flashpanels = new WP_Query(array(
'post_type' => array('flash_panel'),
'orderby' => 'menu_order',
'order' => 'ASC',
'nopaging' => true
));
$stache = new \Mustache();
$tmpl = <<<TMPL
<li>
<div class="entry-excerpt">
<a href="{{ permalink }}">{{ title }}</a>
<span class="bubble"></span>
</div>
</li>
TMPL;
while ($flashpanels->have_posts()) {
$flashpanels->the_post();
echo $stache->render($tmpl, array(
'permalink' => the_permalink(),
'title' => the_title('', '', false)
));
}
wp_reset_query(); // Important! Omitting this borks the main loop.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment