Guest User

Untitled

a guest
Jan 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. <?php
  2. global $woo_options;
  3. $post_types_to_loop_through = array();
  4. $posts_to_exclude = array();
  5. $categories_panel_entries = $woo_options['woo_categories_panel_entries'];
  6. $more_listings_setting = $woo_options['woo_more_listings_area'];
  7. $wp_custom_post_types_args = array();
  8. $wp_custom_post_types = get_post_types($wp_custom_post_types_args,'objects');
  9. foreach ($wp_custom_post_types as $post_type_item) {
  10. $cpt_test = get_option('woo_categories_panel_post_types_'.$post_type_item->name);
  11. if ($cpt_test == 'true') {
  12. $cpt_nice_name = $post_type_item->labels->name;
  13. $cpt_has_archive = $post_type_item->has_archive;
  14. $post_types_to_loop_through[$post_type_item->name] = array('nice_name' => $cpt_nice_name, 'has_archive' => $cpt_has_archive);
  15. }
  16. }
  17.  
  18. $section_counter = 0;
  19.  
  20. foreach ($post_types_to_loop_through as $post_type_item => $post_type_item_nice_name) {
  21. $taxonomies = get_object_taxonomies($post_type_item);
  22. $block_counter = 0;
  23. $args = array();
  24. ?>
  25.  
  26. <div class="listings <?php /*if ($section_counter > 0) { echo 'bordertop'; }*/ ?>">
  27. <h2 class="cufon"><?php printf( __( '%s Categories', 'woothemes' ), $post_type_item_nice_name['nice_name'] ); ?></h2>
  28.  
  29. <?php
  30. // NEW AND IMPROVED QUERY
  31. $all_terms = get_terms( $taxonomies, $args );
  32.  
  33. $block_counter = 0;
  34. foreach ( $all_terms as $all_term) {
  35.  
  36. $tax_test = get_option('woo_categories_panel_taxonomies_'.$all_term->taxonomy);
  37.  
  38. if ( ($tax_test == 'true') && ($block_counter <= $categories_panel_entries) ) {
  39.  
  40. $post_images = array();
  41. $posts_aray = array();
  42.  
  43. $term_name = $all_term->name;
  44. $term_slug = $all_term->slug;
  45. $term_id = $all_term->term_id;
  46. $term_link = get_term_link( $all_term, $all_term->taxonomy );
  47. $counter_value = $all_term->count;
  48. ?>
  49. <div class="block">
  50. <a href="<?php echo $term_link; ?>">
  51. <?php
  52. $block_counter++;
  53.  
  54.  
  55. woo_taxonomy_image($post_images,$term_link);
  56.  
  57. $php_formatting = "m\/d\/Y";
  58. $post_item_date = strtotime($post_date_raw);
  59. ?>
  60. </a>
  61. <h2><a href="<?php echo $term_link; ?>"><?php echo $term_name ?> <br/><span>(<?php echo $counter_value; ?> Listings)</span></a></h2>
  62. <p><?php _e('Latest listing ', 'woothemes') ?><?php echo date($php_formatting,$post_item_date); ?></p>
  63. </div><!-- /.block -->
  64. <?php
  65. if ( $block_counter % 3 == 0 ) {
  66. ?>
  67. <div class="fix"></div>
  68. <?php
  69. } // End IF Statement
  70.  
  71. } // End IF Statement
  72.  
  73. ?>
  74. <?php
  75.  
  76.  
  77. } // End For Loop
  78.  
  79. ?>
  80.  
  81. <div class="fix"></div>
  82.  
  83. <?php if ( $block_counter > 0 ) { ?>
  84.  
  85. <?php
  86. $view_all_link = '';
  87. // Check if CPT taxonomy landing page exists
  88. $page_exists = false;
  89. $listings_cpt_page = get_option('woo_listings_cpt_page');
  90. if ( $listings_cpt_page != '' ) {
  91. $page_test = get_page($listings_cpt_page);
  92. if ( isset($page_test) && ( $page_test->post_status == 'publish' ) ) {
  93. $page_exists = true;
  94. } else {
  95. $page_exists = false;
  96. }
  97. } // End If Statement
  98. if ( $page_exists ) {
  99. $view_all_link = get_permalink($listings_cpt_page).'?landing_page='.$post_type_item;
  100. } else {
  101. $view_all_link = get_post_type_archive_link( $post_type_item );
  102. }
  103. ?>
  104. <h3 class="banner"><a href="<?php echo $view_all_link; ?>" title="<?php printf( __( 'View all %s categories', 'woothemes' ), $post_type_item_nice_name['nice_name'] ); ?>"><?php printf( __( 'View all %s categories', 'woothemes' ), $post_type_item_nice_name['nice_name'] ); ?></a></h3>
  105.  
  106. <?php } else { ?>
  107. <p class="woo-sc-box note" style="margin:20px 20px;"><?php _e('Please add some posts in order for this panel to work correctly. You must assign the post to these taxonomies for it to work.','woothemes'); ?></p>
  108. <?php } ?>
  109.  
  110. </div><!-- /.listings -->
  111.  
  112. <div class="fix"></div>
  113.  
  114. <?php } // End FOR Loop ?>
Add Comment
Please, Sign In to add comment