Guest User

Untitled

a guest
Jan 9th, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class td_popular_categories extends td_block {
  5.  
  6.  
  7. function __construct() {
  8. $this->block_id = 'td_popular_categories';
  9. add_shortcode('td_popular_categories', array($this, 'render'));
  10. }
  11.  
  12.  
  13. function render($atts){
  14. $this->block_uid = uniqid(); //update unique id on each render
  15. extract(shortcode_atts(
  16. array(
  17. 'limit' => '6',
  18. 'custom_title' => '',
  19. 'custom_url' => '',
  20. 'hide_title' => '',
  21. 'header_color' => ''
  22. ), $atts));
  23.  
  24. $cat_args = array(
  25. 'show_count' => true,
  26. 'orderby' => 'count',
  27. 'hide_empty' => false,
  28. 'order' => 'DESC',
  29. 'number' => $limit,
  30. 'exclude' => get_cat_ID(TD_FEATURED_CAT)
  31. );
  32.  
  33.  
  34. if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
  35. $cat_args['exclude'] = '251, 252, 253, 254, 255, 256, 257, 258, 305, 306, ' . get_cat_ID(TD_FEATURED_CAT);
  36. }
  37.  
  38. $categories = get_categories($cat_args);
  39.  
  40. $buffy = '';
  41.  
  42. $buffy .= '<div class="td_block_wrap td_popular_categories widget widget_categories">';
  43. $buffy .= $this->get_block_title_raw($atts, 'Popular category');
  44.  
  45. if (!empty($categories)) {
  46. $buffy .= '<ul>';
  47. foreach ($categories as $category) {
  48. if ($category->cat_name != 'uncategorized') {
  49. $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
  50. }
  51. }
  52. $buffy .= '</ul>';
  53. }
  54. $buffy .= '</div> <!-- ./block -->';
  55. return $buffy;
  56. }
  57.  
  58. function inner($posts, $td_column_number = '') {
  59.  
  60. }
  61.  
  62.  
  63. function get_map () {
  64. return array(
  65. "name" => __("Popular category", TD_THEME_NAME),
  66. "base" => "td_popular_categories",
  67. "class" => "td_popular_categories",
  68. "controls" => "full",
  69. "category" => __('Blocks', TD_THEME_NAME),
  70. 'icon' => 'icon-pagebuilder-popular_categories',
  71. "params" => array(
  72. array(
  73. "param_name" => "limit",
  74. "type" => "textfield",
  75. "value" => "6",
  76. "heading" => __("Limit the number of categories shown):", TD_THEME_NAME),
  77. "description" => "",
  78. "holder" => "div",
  79. "class" => ""
  80. ),
  81. array(
  82. "type" => "colorpicker",
  83. "holder" => "div",
  84. "class" => "",
  85. "heading" => __("Header color", TD_THEME_NAME),
  86. "param_name" => "header_color",
  87. "value" => '', //Default Red color
  88. "description" => __("Choose a custom header color for this block", TD_THEME_NAME)
  89. ),
  90. array(
  91. "param_name" => "custom_title",
  92. "type" => "textfield",
  93. "value" => "",
  94. "heading" => __("Optional - custom title for this block:", TD_THEME_NAME),
  95. "description" => "",
  96. "holder" => "div",
  97. "class" => ""
  98. ),
  99. array(
  100. "param_name" => "custom_url",
  101. "type" => "textfield",
  102. "value" => "",
  103. "heading" => __("Optional - custom url for this block (when the module title is clicked):", TD_THEME_NAME),
  104. "description" => "",
  105. "holder" => "div",
  106. "class" => ""
  107. ),
  108. array(
  109. "param_name" => "title_style",
  110. "type" => "dropdown",
  111. "value" => array('- default style -' => '', 'Style 1' => 'td_title_style_1'),
  112. "heading" => __("Title style:", TD_THEME_NAME),
  113. "description" => "",
  114. "holder" => "div",
  115. "class" => ""
  116. ),
  117. array(
  118. "param_name" => "hide_title",
  119. "type" => "dropdown",
  120. "value" => array('- Show title -' => '', 'Hide title' => 'hide_title'),
  121. "heading" => __("Hide block title:", TD_THEME_NAME),
  122. "description" => "",
  123. "holder" => "div",
  124. "class" => ""
  125. )
  126. )
  127. );
  128. }
  129.  
  130. }
  131.  
  132.  
  133.  
  134. td_global_blocks::add_instance('td_popular_categories', new td_popular_categories());
  135.  
  136.  
  137.  
  138.  
  139. ?>
Advertisement
Add Comment
Please, Sign In to add comment