Advertisement
alchymyth

categorymenu.inc commented

Nov 16th, 2012
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.72 KB | None | 0 0
  1. <ul id="category_menu">
  2. <!-- BEGIN Home Menu Item -->
  3. <li class="home" style="width:82px;"><a href="http://www.livinghealthynews.org" title="Living Healthy News."><b>&nbsp;&nbsp;Home</b></a></li>
  4. <!-- End Home Menu Item -->
  5. <?php
  6. class cat_style_sex
  7. {
  8.    public $link_style_tag = 'class="cat_sex"';
  9.    public $text_style_tag = 'text_cat_sex';
  10.    public $border_top_style_tag = 'cat_sex_li';
  11.    public $border_bottom_style_tag = 'border-bottom: solid 4px #EE2C21;';
  12. }
  13. class cat_style_spirit
  14. {
  15.    public $link_style_tag = 'class="cat_spirit"';
  16.    public $text_style_tag = 'text_cat_spirit';
  17.    public $border_top_style_tag = 'cat_spirit_li';
  18.    public $border_bottom_style_tag = 'border-bottom: solid 4px #66ccff;';
  19. }
  20. class cat_style_great
  21. {
  22.    public $link_style_tag = 'class="cat_great"';
  23.    public $text_style_tag = 'text_cat_great';
  24.    public $border_top_style_tag = 'cat_great_li';
  25.    public $border_bottom_style_tag = 'border-bottom: solid 4px #a97d5d;';
  26. }
  27. class cat_style_well
  28. {
  29.    public $link_style_tag = 'class="cat_well"';
  30.    public $text_style_tag = 'text_cat_well';
  31.    public $border_top_style_tag = 'cat_well_li';
  32.    public $border_bottom_style_tag = 'border-bottom: solid 4px #ffa500;';
  33. }
  34. class cat_style_active
  35. {
  36.    public $link_style_tag = 'class="cat_active"';
  37.    public $text_style_tag = 'text_cat_active';
  38.    public $border_top_style_tag = 'cat_active_li';
  39.    public $border_bottom_style_tag = 'border-bottom: solid 4px #00cc33;';
  40. }
  41.  
  42. $lrIdx             = 1; //left align tab dropdown if less than 4, else right align by appending _l or _r to class="dropdown_2columns"
  43. $idx_offset        = 0;
  44. $cat_args          = array(
  45.    'orderby' => 'name',
  46.    'order' => 'ASC'
  47. );
  48. $categories        = get_categories($cat_args);
  49. $parent_categories = Array();
  50. foreach ($categories as $category) {
  51.    if ($category->parent == 0) {
  52.       $parent_categories[] = $category;
  53.    } //$category->parent == 0
  54. } //$categories as $category
  55.  
  56. //for each category, show 5 posts
  57. foreach ($parent_categories as $category) {
  58.    $style_modifier_class = null;
  59.    $style_class_exists   = False;
  60.    $cat_args             = array(
  61.       'type' => 'post',
  62.       'child_of' => $category->term_id,
  63.       'orderby' => 'name',
  64.       'order' => 'ASC',
  65.       'hide_empty' => 1,
  66.       'hierarchical' => 1,
  67.       'exclude' => '',
  68.       'include' => '',
  69.       'number' => '',
  70.       'taxonomy' => 'category',
  71.       'pad_counts' => false
  72.    );
  73.    
  74.    $sub_categories = get_categories($cat_args);
  75.    $sub_cat_ids    = Array();
  76.    foreach ($sub_categories as $sub_category) {
  77.       array_push($sub_cat_ids, $sub_category->term_id);
  78.    } //$sub_categories as $sub_category
  79.    array_push($sub_cat_ids, $category->term_id);
  80.    $post_args           = array( //EDIT: question: are these the args for 'get_posts()' later in the code?
  81.       'numberposts' => 5,
  82.       'category__in' => $sub_cat_ids,
  83.       'caller_get_posts' => 1,
  84.       'orderby' => 'post_date',
  85.       'order' => 'DESC',
  86.       'post_status' => 'publish',
  87.       'suppress_filters' => true
  88.    );
  89.    $split               = explode(' ', strtolower($category->name));
  90.    $style_mod_class_pfx = $split[count($split) - 1];
  91.    if (class_exists('cat_style_' . $style_mod_class_pfx)) {
  92.       $class                = new ReflectionClass('cat_style_' . $style_mod_class_pfx);
  93.       $style_modifier_class = $class->newInstanceArgs();
  94.       $style_class_exists   = True;
  95.    } //class_exists('cat_style_' . $style_mod_class_pfx)
  96.    
  97.    $dyn_style_tag_menu            = '';
  98.    $dyn_style_tag_menu_text       = '';
  99.    $dyn_style_tag_menu_border     = '';
  100.    $dyn_style_tag_menu_border_btm = '';
  101.    if ($style_class_exists == True) {
  102.       $dyn_style_tag_menu            = $style_modifier_class->link_style_tag;
  103.       $dyn_style_tag_menu_text       = $style_modifier_class->text_style_tag;
  104.       $dyn_style_tag_menu_border     = $style_modifier_class->border_style_tag;
  105.       $dyn_style_tag_menu_border_btm = $style_modifier_class->border_bottom_style_tag;
  106.    } //$style_class_exists == True
  107.    
  108.    // category tab
  109.    echo '<!-- BEGIN ' . $category->name . ' Menu Item -->';
  110.    echo '<li class="' . $dyn_style_tag_menu_border . '"><a href="' . get_category_link($category->term_id) . '" title="' . strip_tags(category_description($category->term_id)) . '" ';
  111.    echo '>'; //$dyn_style_tag_menu . '>';
  112.    echo $category->name;
  113.    echo '</a>';
  114.    
  115.    // set the
  116.    $posit_offset = -$lrIdx;
  117.    $posit_offset *= 128.2;
  118.    $posit_offset += 120;
  119.    $lrIdx++;
  120. ?>
  121.         <div class="dropdown_2columns" style="left:<?php
  122.    echo $posit_offset;
  123. ?>px;<?php
  124.    echo $dyn_style_tag_menu_border;
  125. ?>;<?php
  126.    echo $dyn_style_tag_menu_border_btm;
  127. ?>"><!-- BEGIN 2 COLUMN MENU DROPDOWN CONTAINER -->
  128.          <div class="dropdown_2columns_inner_lft"><!-- BEGIN LEFT COLUMN -->
  129.  
  130. <?php
  131.    $posts = get_posts($args); //EDIT: where is $args defined? is that meant to be $post_args ??//
  132.    shuffle($posts);
  133.    $numItems = count($posts);
  134.    $i        = 0;
  135.    if ($posts) {
  136.       foreach ($posts as $post) {
  137.          setup_postdata($post);
  138. ?>
  139.          <div class="<?php
  140.          echo (++$i == $numItems) ? 'col_1_last' : 'col_1';
  141. ?>">
  142.          <h3 class="category_menu_post_excerpt_title"><a class="category_menu_tab_link" href="<?php
  143.          echo get_permalink($post->ID); //EDIT changed to 'get_permalink();'
  144. ?>" rel="bookmark" title="<?php
  145.          the_title_attribute();
  146. ?>"><?php
  147.          the_title();
  148. ?></a></h3><!-- Post Title -->
  149.                <p class="category_menu_post_excerpt_byline"><?php
  150.          the_time('F jS, Y');
  151. ?> by <?php
  152.          the_author();
  153. ?></p>
  154.                <p class="category_menu_post_excerpt"><?php
  155.          the_excerpt();
  156. ?></p> <!-- Post Excerpt -->
  157.             </div>
  158. <?php
  159.       } // foreach ($posts as $post)
  160. ?>
  161.          <div class="dropdown_2columns_inner_lft_btm, <?php
  162.       echo $dyn_style_tag_menu_text;
  163. ?>">
  164.             <a href="<?php
  165.       echo get_category_link($category->term_id);
  166. ?>" title="<?php
  167.       echo strip_tags(category_description($category->term_id));
  168. ?>">
  169.                Go to <?php
  170.       echo $category->name;
  171. ?> >
  172.             </a>
  173.          </div>
  174. <?php
  175.    } // if ($posts)
  176. ?>
  177.  
  178.          </div><!-- END LEFT COLUMN -->
  179.          <div class="dropdown_2columns_inner_rt"><!-- BEGIN RIGHT COLUMN -->
  180. <?php
  181.    if (count($sub_categories) > 0) {
  182. ?>
  183.            <p class="dropdown_2columns_inner_rt_title, <?php
  184.       echo $dyn_style_tag_menu_text;
  185. ?>">More in <?php
  186.       echo $category->name;
  187. ?></p>
  188. <?php
  189.    } // if(count  
  190. ?>
  191. <?php
  192.    foreach ($sub_categories as $sub_category) {
  193. ?>
  194.                  <div class="col_2_subcategory, col_2">
  195.  <?php
  196.       echo '<a href="' . get_category_link($sub_category->term_id) . '" class="col_2_subcategory, ' . $dyn_style_tag_menu_text . '" title="' . strip_tags(category_description($sub_category->term_id)) . '" >' . trim($sub_category->name) . '</a>';
  197. ?>
  198.                   </div>
  199. <?php
  200.    } //foreach($sub_categories as $sub_category)
  201. ?>
  202.             <div class="col_2_tags" >
  203.             <p class="dropdown_2columns_inner_rt_title, <?php
  204.    echo $dyn_style_tag_menu_text;
  205. ?>"><span>Trending in <?php
  206.    echo $category->name;
  207. ?></span></p>
  208. <?php
  209.    $args = array(
  210.       'smallest' => 10,
  211.       'largest' => 12,
  212.       'unit' => 'pt',
  213.       'number' => 8,
  214.       'format' => 'flat',
  215.       'orderby' => 'name',
  216.       'order' => 'ASC',
  217.       'exclude' => '',
  218.       'include' => '',
  219.       'cat' => $category->term_id
  220.    );
  221.    tdotf_cat_tag_cloud($args);
  222. ?>
  223.  
  224. <?php
  225. } // foreach($categories
  226. wp_reset_query();
  227. ?>
  228.             </div>
  229.          </div>
  230. <!-- END RIGHT COLUMN -->
  231.         </div><!-- END 2 COLUMN MENU DROPDOWN CONTAINER -->
  232.     </li><!-- End <?php
  233. $category->name;
  234. ?> Menu Item -->
  235. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement