Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class td_mega_menu extends td_block {
- function __construct() {
- $this->block_id = 'td_mega_menu';
- add_shortcode('td_mega_menu', array($this, 'render'));
- }
- function render($atts){
- $this->block_uid = td_global::td_generate_unique_id(); //update unique id on each render
- extract(shortcode_atts(
- array(
- 'limit' => 5,
- 'sort' => '',
- 'category_id' => '',
- 'category_ids' => '',
- 'custom_title' => '',
- 'custom_url' => '',
- 'hide_title' => '',
- 'show_child_cat' => '',
- 'tag_slug' => '',
- 'header_color' => ''
- ),$atts));
- $buffy = ''; //output buffer
- $td_unique_id = td_global::td_generate_unique_id();
- //custom categories
- //get subcategories, it returns false if there are no categories
- $get_block_sub_cats = $this->get_block_sub_cats($atts, $td_unique_id);
- $buffy_categories = '';
- $td_no_subcats_class = '';
- //we have subcategories
- if ($get_block_sub_cats !== false) {
- $td_no_subcats_class = ' td-no-subcats';
- $atts['limit'] = 5; //alter the loop because we don't have space now with the categories
- }
- //end custom categories
- $td_query = &td_data_source::get_wp_query($atts); //by ref do the query
- //get the js for this block
- $buffy .= $this->get_block_js($atts, $td_query);
- $buffy .= '<div class="td_block_wrap td_block_mega_menu' . $td_no_subcats_class . '">';
- //get the block title
- //$buffy .= $this->get_block_title($atts);
- //add the categories IF we have some
- $buffy .= $buffy_categories;
- $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner animated fadeInDown">';
- //inner content of the block
- $buffy .= $this->inner($td_query->posts);
- $buffy .= '</div>';
- $buffy .= $this->get_block_pagination($atts, $td_unique_id);
- //get the ajax pagination for this block
- $buffy .= '<div class="clearfix"></div>';
- $buffy .= '</div> <!-- ./block1 -->';
- return $buffy;
- }
- function inner($posts, $td_column_number = '') {
- $buffy = '';
- if (!empty($posts)) {
- foreach ($posts as $post) {
- $td_module_mega_menu = new td_module_mega_menu($post);
- $buffy .= $td_module_mega_menu->render();
- }
- }
- return $buffy;
- }
- }
- td_global_blocks::add_instance('td_mega_menu', new td_mega_menu());
Advertisement
Add Comment
Please, Sign In to add comment