Guest User

Untitled

a guest
Jun 26th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.81 KB | None | 0 0
  1. <!-- CATEGORY page -->
  2. <?php echo td_panel_generator::box_start('Category global settings', true); ?>
  3.  
  4.  
  5. <div class="td-box-description td-box-full">
  6. <p>Set the default layout for all the categories. Note that you can change the layout and settings on each category from Theme panel ⇢ Categories</p>
  7. <ul>
  8. <li>You can view each category page by going to Posts ⇢ Categories ⇢ hover on a category ⇢ select view</li>
  9. <li>This WordPress template is located in <strong>category.php</strong> file.</li>
  10. </ul>
  11. </div>
  12.  
  13.  
  14. <!-- Category template -->
  15. <div class="td-box-row">
  16. <div class="td-box-description">
  17. <span class="td-box-title">Category template</span>
  18. <p>This is the header of the category</p>
  19. </div>
  20. <div class="td-box-control-full">
  21. <?php
  22. echo td_panel_generator::visual_select_o(array(
  23. 'ds' => 'td_option',
  24. 'option_id' => 'tds_category_template',
  25. 'values' => td_api_category_template::_helper_to_panel_values()
  26. ));
  27. ?>
  28. </div>
  29. </div>
  30.  
  31.  
  32.  
  33. <div class="td-box-section-separator"></div>
  34.  
  35. <!-- Category top posts style -->
  36. <div class="td-box-row">
  37. <div class="td-box-description">
  38. <span class="td-box-title">Category top posts style</span>
  39. <p>Set top post style</p>
  40. </div>
  41. <div class="td-box-control-full">
  42. <?php
  43. echo td_panel_generator::visual_select_o(array(
  44. 'ds' => 'td_option',
  45. 'option_id' => 'tds_category_top_posts_style',
  46. 'values' => td_api_category_top_posts_style::_helper_to_panel_values()
  47. ));
  48. ?>
  49. </div>
  50. </div>
  51.  
  52. <?php
  53. // show the $big_grid_styles_list only if we have big grids
  54. // Newsmag as of 10 march is not using $big_grid_styles_list
  55. if (!empty(td_global::$big_grid_styles_list)) {
  56. ?>
  57. <div class="td-box-row">
  58. <div class="td-box-description">
  59. <span class="td-box-title">Category top posts GRID STYLE</span>
  60. <p>Each category grid supports multiple styles</p>
  61. </div>
  62. <div class="td-box-control-full">
  63. <?php
  64.  
  65. $td_grid_style_values = array();
  66. foreach (td_global::$big_grid_styles_list as $big_grid_id => $params) {
  67. $td_grid_style_values []= array(
  68. 'text' => $params['text'],
  69. 'val' => $big_grid_id
  70. );
  71. }
  72. echo td_panel_generator::dropdown(array(
  73. 'ds' => 'td_option',
  74. 'option_id' => 'tds_category_td_grid_style',
  75. 'values' => $td_grid_style_values
  76. ));
  77. ?>
  78. </div>
  79. </div>
  80. <?php } ?>
  81.  
  82. <div class="td-box-section-separator"></div>
  83.  
  84.  
  85. <!-- DISPLAY VIEW -->
  86. <div class="td-box-row">
  87. <div class="td-box-description">
  88. <span class="td-box-title">ARTICLE DISPLAY VIEW</span>
  89. <p>Select a module type, this is how your article list will be displayed</p>
  90. </div>
  91. <div class="td-box-control-full td-panel-module">
  92. <?php
  93. echo td_panel_generator::visual_select_o(array(
  94. 'ds' => 'td_option',
  95. 'option_id' => 'tds_category_page_layout',
  96. 'values' => td_panel_generator::helper_display_modules('enabled_on_loops')
  97. ));
  98. ?>
  99. </div>
  100. </div>
  101.  
  102.  
  103.  
  104. <!-- Custom Sidebar + position -->
  105. <div class="td-box-row">
  106. <div class="td-box-description">
  107. <span class="td-box-title">CUSTOM SIDEBAR + POSITION</span>
  108. <p>Sidebar position and custom sidebars</p>
  109. </div>
  110. <div class="td-box-control-full td-panel-sidebar-pos">
  111. <div class="td-display-inline-block">
  112. <?php
  113. echo td_panel_generator::visual_select_o(array(
  114. 'ds' => 'td_option',
  115. 'option_id' => 'tds_category_sidebar_pos',
  116. 'values' => array(
  117. array('text' => '', 'title' => '', 'val' => 'sidebar_left', 'img' => get_template_directory_uri() . '/includes/wp_booster/wp-admin/images/panel/sidebar-left.png'),
  118. array('text' => '', 'title' => '', 'val' => 'no_sidebar', 'img' => get_template_directory_uri() . '/includes/wp_booster/wp-admin/images/panel/sidebar-full.png'),
  119. array('text' => '', 'title' => '', 'val' => '', 'img' => get_template_directory_uri() . '/includes/wp_booster/wp-admin/images/panel/sidebar-right.png')
  120. )
  121. ));
  122. ?>
  123. <div class="td-panel-control-comment td-text-align-right">Select sidebar position</div>
  124. </div>
  125. <div class="td-display-inline-block td_sidebars_pulldown_align">
  126. <?php
  127. echo td_panel_generator::sidebar_pulldown(array(
  128. 'ds' => 'td_option',
  129. 'option_id' => 'tds_category_sidebar'
  130. ));
  131. ?>
  132. <div class="td-panel-control-comment td-text-align-right">Create or select an existing sidebar</div>
  133. </div>
  134. </div>
  135. </div>
  136. <?php echo td_panel_generator::box_end();?>
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143. <hr>
  144. <div class="td-section-separator">Per category settings</div>
  145.  
  146.  
  147.  
  148.  
  149. <?php
  150.  
  151. // get all the categories
  152. $categories = get_categories(array(
  153. 'hide_empty' => 0
  154. ));
  155.  
  156. // 'walk' all the categories
  157. $td_category_walker_panel = new td_category_walker_panel;
  158. $td_category_walker_panel->walk($categories, 4);
  159.  
  160. // add each category panel
  161. foreach ($td_category_walker_panel->td_category_buffer as $display_category_name => $category_id) {
  162. ?>
  163. <!-- LAYOUT SETTINGS -->
  164. <?php
  165. echo td_panel_generator::ajax_box($display_category_name, array(
  166. 'td_ajax_calling_file' => basename(__FILE__),
  167. 'td_ajax_box_id' => 'td_get_category_section_by_id',
  168. 'category_id' => $category_id
  169. )
  170. );
  171. }//end foreach
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182. /**
  183. * custom walker - it's used only in this panel
  184. * Class td_category_walker_panel
  185. */
  186. class td_category_walker_panel extends Walker {
  187. var $tree_type = 'category';
  188. var $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
  189.  
  190.  
  191. var $td_category_hierarchy = array(); // we store them like so [0] Category 1 - [1] Category 2 - [2] Category 3
  192.  
  193.  
  194. var $td_category_buffer = array();
  195.  
  196. function start_lvl( &$output, $depth = 0, $args = array() ) {
  197.  
  198. }
  199.  
  200. function end_lvl( &$output, $depth = 0, $args = array() ) {
  201.  
  202. }
  203.  
  204.  
  205. function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
  206.  
  207. if (!isset($td_last_category_objects[$depth])) {
  208. $this->td_category_hierarchy[$depth] = $category;
  209. }
  210.  
  211.  
  212. if ($depth == 0) {
  213. //reset the parrents
  214. $this->td_category_hierarchy = array();
  215. //put the
  216. $this->td_category_hierarchy[0] = $category;
  217.  
  218. //add first parent
  219. $this->td_category_buffer['<a href="' . get_category_link($category->term_id) . '" target="_blank" data-is-category-link="yes">' . $category->name . '</a>'] = $category->term_id;
  220. } else {
  221.  
  222. $td_tmp_buffer = '';
  223. $last_cat_id = 0;
  224. $contor_array = 0;
  225. //print_r($this->td_category_hierarchy);
  226. foreach ($this->td_category_hierarchy as $parent_cat_obj) {
  227.  
  228. if ($td_tmp_buffer === '') {
  229. $td_tmp_buffer = '<a href="' . get_category_link($parent_cat_obj->term_id) . '" target="_blank" data-is-category-link="yes">' . $parent_cat_obj->name . '</a>';
  230. $last_cat_id = $parent_cat_obj->term_id;
  231. } else {
  232. if($this->td_category_hierarchy[$contor_array-1]->term_id == $parent_cat_obj->parent) {
  233. $td_tmp_buffer .= '<img src="' . get_template_directory_uri() . '/includes/wp_booster/wp-admin/images/panel/panel-breadcrumb.png" class="td-panel-breadcrumb"/>' . '<a href="' . get_category_link($parent_cat_obj->term_id) . '" target="_blank" data-is-category-link="yes">' . $parent_cat_obj->name . '</a>';
  234. $last_cat_id = $parent_cat_obj->term_id;
  235. }
  236. }
  237.  
  238. $contor_array++;
  239.  
  240. }
  241.  
  242.  
  243. //add child
  244. $this->td_category_buffer[$td_tmp_buffer] = $last_cat_id;
  245.  
  246. }
  247.  
  248.  
  249. }
  250.  
  251.  
  252. function end_el( &$output, $page, $depth = 0, $args = array() ) {
  253.  
  254. }
  255.  
  256. }
Advertisement
Add Comment
Please, Sign In to add comment