Guest User

Untitled

a guest
Sep 24th, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class td_mega_menu extends td_block {
  5.  
  6.  
  7. function __construct() {
  8. $this->block_id = 'td_mega_menu';
  9. add_shortcode('td_mega_menu', array($this, 'render'));
  10. }
  11.  
  12.  
  13. function render($atts){
  14. $this->block_uid = td_global::td_generate_unique_id(); //update unique id on each render
  15. extract(shortcode_atts(
  16. array(
  17. 'limit' => 5,
  18. 'sort' => '',
  19. 'category_id' => '',
  20. 'category_ids' => '',
  21. 'custom_title' => '',
  22. 'custom_url' => '',
  23. 'hide_title' => '',
  24. 'show_child_cat' => '',
  25. 'tag_slug' => '',
  26. 'header_color' => ''
  27. ),$atts));
  28.  
  29. $buffy = ''; //output buffer
  30. $td_unique_id = td_global::td_generate_unique_id();
  31.  
  32.  
  33. //custom categories
  34.  
  35. //get subcategories, it returns false if there are no categories
  36. $get_block_sub_cats = $this->get_block_sub_cats($atts, $td_unique_id);
  37. $buffy_categories = '';
  38. $td_no_subcats_class = '';
  39. //we have subcategories
  40. if ($get_block_sub_cats !== false) {
  41. $td_no_subcats_class = ' td-no-subcats';
  42. $atts['limit'] = 5; //alter the loop because we don't have space now with the categories
  43. }
  44.  
  45. //end custom categories
  46.  
  47.  
  48.  
  49. $td_query = &td_data_source::get_wp_query($atts); //by ref do the query
  50.  
  51. //get the js for this block
  52. $buffy .= $this->get_block_js($atts, $td_query);
  53.  
  54. $buffy .= '<div class="td_block_wrap td_block_mega_menu' . $td_no_subcats_class . '">';
  55.  
  56. //get the block title
  57. //$buffy .= $this->get_block_title($atts);
  58.  
  59. //add the categories IF we have some
  60. $buffy .= $buffy_categories;
  61.  
  62.  
  63.  
  64.  
  65. $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner animated fadeInDown">';
  66. //inner content of the block
  67. $buffy .= $this->inner($td_query->posts);
  68. $buffy .= '</div>';
  69.  
  70. $buffy .= $this->get_block_pagination($atts, $td_unique_id);
  71. //get the ajax pagination for this block
  72.  
  73. $buffy .= '<div class="clearfix"></div>';
  74.  
  75. $buffy .= '</div> <!-- ./block1 -->';
  76. return $buffy;
  77. }
  78.  
  79. function inner($posts, $td_column_number = '') {
  80.  
  81. $buffy = '';
  82.  
  83.  
  84. if (!empty($posts)) {
  85. foreach ($posts as $post) {
  86. $td_module_mega_menu = new td_module_mega_menu($post);
  87. $buffy .= $td_module_mega_menu->render();
  88. }
  89. }
  90.  
  91. return $buffy;
  92. }
  93. }
  94.  
  95.  
  96.  
  97. td_global_blocks::add_instance('td_mega_menu', new td_mega_menu());
Advertisement
Add Comment
Please, Sign In to add comment