rejuancse

taxonomy-league

Dec 19th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 30.63 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) )
  3.   exit; // Exit if accessed directly
  4.   get_header();
  5. ?>
  6.  
  7.   <section id="main">
  8.  
  9.  <?php
  10.   $queried_object = get_queried_object();
  11.   $league_id[] = $queried_object;
  12.   ?>
  13.           <?php
  14.           if(is_array($league_id)):
  15.               if(isset($league_id[0]->slug)): //slug
  16.           ?>
  17.  
  18.           <!-- ********************************** Banner Start ************************************ -->    
  19.                     <?php
  20.                       $d = date("Y-m-d h:i");
  21.                       $args = array(
  22.                                   'post_type'     => 'fixture_reasult',
  23.                                   'posts_per_page'  => 1,
  24.                                   'tax_query' => array(
  25.                                             array(
  26.                                               'taxonomy' => 'league',
  27.                                               'field'    => 'slug', //slug
  28.                                               'terms'    => $league_id[0]->slug,
  29.                                              )
  30.                                           ),
  31.                                   'meta_query' => array(
  32.                                             array(
  33.                                                 'key' => 'themeum_datetime',
  34.                                                 'value' => $d,
  35.                                                 'type' => 'date',
  36.                                                 'compare' => '>'
  37.                                             )
  38.                                     ),
  39.                                   'meta_key'          => 'themeum_datetime',
  40.                                   'orderby'           => 'meta_value',
  41.                                   'order'             => 'ASC'
  42.                                 );
  43.                       $posts = get_posts($args);
  44.  
  45.                       $club1 = $club2 = $date1 = $date2 = $date3 = $gmt = '';
  46.                       foreach ($posts as $post){
  47.                           setup_postdata( $post );
  48.                           $date1 = get_post_meta( get_the_ID(),'themeum_datetime',true );
  49.                           $team1 = get_post_meta( get_the_ID(),'team_1_group',true );
  50.                           $team2 = get_post_meta( get_the_ID(),'team_2_group',true );
  51.                           $gmt = get_post_meta( get_the_ID(),'themeum_gmt',true );
  52.  
  53.                           $club1 = $team1['themeum_club_name1'];
  54.                           $club2 = $team2['themeum_club_name2'];
  55.  
  56.                           }
  57.                       wp_reset_postdata();
  58.  
  59.                       if($date1 != ''){
  60.                         $date1 = date_format(date_create($date1), 'd M Y h:i A');
  61.                         $date2 = date_format(date_create($date1), 'h:i A');
  62.                         $date3 = date_format(date_create($date1), 'Y');
  63.                       }
  64.  
  65.                      
  66.                      
  67.                     ?>
  68.  
  69.           <div class="match-banner league-banner sub-title" style="background-image:url(<?php echo esc_url($themeum_options['league-banner']['url']); ?>);background-size: cover;background-position: 50% 50%;padding:100px 0 50px">
  70.               <div class="container">
  71.  
  72.                   <div class="text-center">
  73.                   <?php if(count($posts) >= 1): ?>
  74.                       <h2 class="match-detail-league-title"><?php _e('Next Match','themeum-soccer'); ?> - <?php if( $date1 != '' ){ echo esc_attr($date1).' '.esc_attr($gmt); } ?></h2>
  75.                   <?php else: ?>
  76.                       <h2 class="match-detail-league-title"><?php single_term_title(); ?></h2>
  77.                   <?php endif; ?>
  78.  
  79.                   </div>
  80.                   <div class="row">
  81.                       <div class="col-xs-12 col-sm-5">
  82.                           <div class="matech-team pull-right">
  83.                               <div class="icon-left">
  84.                                   <?php if( $club1 != '' ): ?><img width="61" src="<?php echo esc_url(themeum_logo_url_by_id($club1)); ?>" alt="<?php echo esc_attr(themeum_get_title_by_id($club1)); ?>"><?php endif; ?>
  85.                               </div>
  86.                               <div class="title">
  87.                                   <?php if( $club1 != '' ): ?><h4><?php echo esc_attr(themeum_get_title_by_id($club1)); ?></h4><?php endif; ?>
  88.                               </div>
  89.                           </div>
  90.                       </div>
  91.                      
  92.                       <?php if(count($posts) >= 1): ?>
  93.                       <div class="col-xs-12 col-sm-2 score league">
  94.                           <span> VS </span>
  95.                           <span class="time"><?php if( $date2 != '' ){ echo esc_attr($date2).' '.esc_attr($gmt); } ?></span>
  96.                       </div>
  97.                       <?php endif; ?>
  98.  
  99.                       <div class="col-xs-12 col-sm-5">
  100.                           <div class="matech-team pull-left">
  101.                               <div class="title">
  102.                                   <?php if( $club2 != '' ): ?><h4 class="title"><?php echo esc_attr(themeum_get_title_by_id($club2)); ?></h4><?php endif; ?>
  103.                               </div>
  104.                               <div class="icon-right">
  105.                                   <?php if( $club2 != '' ): ?><img width="61" src="<?php if( $club2 != '' ){ echo esc_url(themeum_logo_url_by_id($club2)); } ?>" alt="<?php echo esc_attr(themeum_get_title_by_id($club2)); ?>"><?php endif; ?>
  106.                               </div>
  107.                           </div>
  108.                       </div>
  109.                   </div>
  110.               </div> <!--container-->
  111.           </div> <!--match-banner-->
  112.           <!-- ********************************** Banner Stop ************************************ -->
  113.  
  114.  
  115.  
  116.           <div class="match-details">
  117.                 <div class="container">
  118.                     <div class="match-details-inner">
  119.                         <div class="match-details-tab" role="tabpanel">
  120.                             <!-- Nav tabs -->
  121.                             <div class="fixture-middles text-center">
  122.                                 <h3><?php echo single_term_title(); ?><?php if( $date3!= '' ){  echo ' - '.esc_attr($date3); } ?></h3>
  123.                             </div>
  124.                             <ul class="nav nav-tabs match-details-tab-nav" role="tablist">
  125.                                 <li role="presentation" class="active"><a href="#fixtures" aria-controls="fixtures" role="tab" data-toggle="tab"><?php _e('Fixtures','themeum-soccer');?></a></li>
  126.                                 <li role="presentation"><a href="#results" aria-controls="results" role="tab" data-toggle="tab"><?php _e('Results','themeum-soccer');?></a></li>
  127.                                 <li role="presentation"><a href="#standings" aria-controls="standings" role="tab" data-toggle="tab"><?php _e('Standings','themeum-soccer');?></a></li>
  128.                                 <li role="presentation"><a href="#teams" aria-controls="teams" role="tab" data-toggle="tab"><?php _e('Teams','themeum-soccer');?></a></li>
  129.                             </ul>
  130.  
  131.  
  132.  
  133.                             <!-- Tab panes -->
  134.                             <div class="tab-content match-details-tab-content">
  135.  
  136.  
  137.  
  138.  
  139.                                 <!-- ********************************** Fixture ************************************ -->
  140.                                 <div role="tabpanel" class="tab-pane fade in active" id="fixtures">
  141.                                     <?php
  142.                                     if(is_array($league_id)){
  143.  
  144.                                         if(isset($league_id[0]->slug)){
  145.                                           //echo $league_id[0]->term_id;
  146.                                               $args = array(
  147.                                                       'post_type'     => 'fixture_reasult',
  148.                                                       'posts_per_page'  => -1,
  149.                                                       'tax_query' => array(
  150.                                                                 array(
  151.                                                                   'taxonomy' => 'league',
  152.                                                                   'field'    => 'slug',
  153.                                                                   'terms'    => $league_id[0]->slug,
  154.                                                                 ),
  155.                                                               ),
  156.                                                       'meta_key'          => 'themeum_datetime',
  157.                                                       'orderby'           => 'meta_value',
  158.                                                       'order'             => 'DESC'
  159.                                                     );
  160.                                                 $posts = get_posts($args);
  161.                                                 $output = '';
  162.  
  163.                                                 $output = '<div class="fixture-teams">';
  164.                                                   $output .= '<div class="fixture-teams-list">';
  165.                                                       $output .= '<div class="row">';
  166.                                                           $output .= '<h3 class="fixture-title">'.__('Fixture','themeum-soccer').'</h3>';
  167.                                                       $output .= '</div>';
  168.  
  169.  
  170.  
  171.                                                       foreach ($posts as $post){
  172.                                                         setup_postdata( $post );
  173.                                                         $team_1_group    = get_post_meta( get_the_ID(),'team_1_group',true );
  174.                                                         $team_2_group    = get_post_meta( get_the_ID(),'team_2_group',true );
  175.                                                         $home_ground     = get_post_meta( get_the_ID(),'themeum_home_ground',true );
  176.                                                         $datetime      = get_post_meta( get_the_ID(),'themeum_datetime',true );
  177.                                                         $gmt         = get_post_meta( get_the_ID(),'themeum_gmt',true );
  178.  
  179.                                                                
  180.                                                                   $output .= '<div class="row fixture-team-inner clearfix">';
  181.                                                                       $output .= '<div class="col-xs-4 col-sm-4 paddingleft">';
  182.                                                                         if($team_1_group['themeum_club_name1'] != ''){
  183.                                                                             $output .= '<img width="40" class="pull-left" src="'.esc_url(themeum_logo_url_by_id($team_1_group['themeum_club_name1'])).'" alt="'.esc_attr(themeum_get_title_by_id($team_1_group['themeum_club_name1'])).'">';
  184.                                                                           }
  185.                                                                           if($team_1_group['themeum_club_name1'] != ''){
  186.                                                                             $output .= '<h4>'.esc_attr(themeum_get_title_by_id($team_1_group['themeum_club_name1'])).'</h4>';
  187.                                                                           }
  188.                                                                       $output .= '</div>';
  189.                                                                       $output .= '<div class="col-xs-4 col-sm-4 status text-center"> '.date_format(date_create($datetime), 'Y-M-d h:i A');
  190.                                                                         if($home_ground != '' ){
  191.                                                                           $output .= '<span>'.esc_attr(themeum_get_title_by_id($home_ground)).'</span>';
  192.                                                                         }
  193.                                                                       $output .= '</div>';
  194.                                                                       $output .= '<div class="col-xs-4 col-sm-4 text-right">';
  195.                                                                           if($team_2_group['themeum_club_name2'] != ''){
  196.                                                                             $output .= '<img width="40" class="pull-right" src="'.esc_url(themeum_logo_url_by_id($team_2_group['themeum_club_name2'])).'" alt="'.esc_attr(themeum_get_title_by_id($team_2_group['themeum_club_name2'])).'"> ';
  197.                                                                           }
  198.                                                                           if($team_2_group['themeum_club_name2'] != ''){
  199.                                                                             $output .= '<h4>'.esc_attr(themeum_get_title_by_id($team_2_group['themeum_club_name2'])).'</h4>';
  200.                                                                           }
  201.                                                                       $output .= '</div>';
  202.                                                                   $output .= '</div>';
  203.                                                               }
  204.                                                       wp_reset_postdata();
  205.  
  206.  
  207.                                                     $output .= '</div>';
  208.                                                 $output .= '</div>';
  209.  
  210.                                                 echo $output;
  211.  
  212.                                         }
  213.                                     }
  214.  
  215.                                     ?>
  216.                                 </div>
  217.                                 <!-- ********************************** Fixture ************************************ -->
  218.  
  219.  
  220.  
  221.  
  222.                                 <!-- ********************************** Results ************************************ -->
  223.                                 <div role="tabpanel" class="tab-pane fade in" id="results">
  224.                                     <?php
  225.                                         if(is_array($league_id)){
  226.  
  227.                                         if(isset($league_id[0]->slug)){
  228.  
  229.                                           $args = array(
  230.                                                           'post_type'     => 'fixture_reasult',
  231.                                                           'posts_per_page'  => -1,
  232.                                                           'tax_query' => array(
  233.                                                                     array(
  234.                                                                       'taxonomy' => 'league',
  235.                                                                       'field'    => 'slug',
  236.                                                                       'terms'    => $league_id[0]->slug,
  237.                                                                     )
  238.                                                                   ),
  239.                                                           'meta_key'          => 'themeum_datetime',
  240.                                                           'orderby'           => 'meta_value',
  241.                                                           'order'             => 'DESC'
  242.                                                         );
  243.                                         $posts = get_posts($args);
  244.                                         $output = '';
  245.  
  246.  
  247.  
  248.                                         $output .= '<div class="fixture-teams">';
  249.                                           $output .= '<div class="fixture-teams-list result-list">';
  250.  
  251.                                               $output .= '<div class="row">';
  252.                                                   $output .= '<h3 class="fixture-title">'.__('Results','themeum-soccer').'</h3>';
  253.                                               $output .= '</div>';
  254.  
  255.                                               foreach ($posts as $post){
  256.                                                     setup_postdata( $post );
  257.                                                    
  258.                                                     $match_result    = get_post_meta( get_the_ID(),'themeum_goal_count',true);
  259.  
  260.                                                     $team_1    = get_post_meta( get_the_ID(),'team_1_group',true);
  261.                                                     $team_2    = get_post_meta( get_the_ID(),'team_2_group',true);
  262.  
  263.                                                     //$output .= print_r($team_2,true);
  264.  
  265.                                                     if( $match_result != '' ){
  266.                                                     $output .= '<a href='.get_permalink().'><div class="row fixture-team-inner clearfix">';
  267.                                                       $output .= '<div class="col-xs-4 col-sm-4 paddingleft">';
  268.                                                           $output .= '<img width="40" class="pull-left" src="'.esc_url(themeum_logo_url_by_id($team_1["themeum_club_name1"])).'" alt="'.esc_attr(themeum_get_title_by_id($team_1["themeum_club_name1"])).'"> ';
  269.                                                           $output .= '<h4>'.esc_attr(themeum_get_title_by_id($team_1["themeum_club_name1"])).'</h4>';
  270.                                                       $output .= '</div>';
  271.                                                      
  272.                                                       $gmt = get_post_meta( get_the_ID(),'themeum_gmt',true);
  273.                                                       $sports_date = date_format(date_create(get_post_meta( get_the_ID(),"themeum_datetime",true )), 'd M Y h:i A').' '.esc_attr($gmt);
  274.                                                      
  275.                                                       $output .= '<div class="col-xs-4 col-sm-4 status text-center"> '.esc_attr($match_result).' <span class="match-date">'.$sports_date.'</span></div> ';
  276.                                                       $output .= '<div class="col-xs-4 col-sm-4 text-right">';
  277.                                                           $output .= '<img width="40" class="pull-right" src="'.esc_url(themeum_logo_url_by_id($team_2["themeum_club_name2"])).'" alt="'.esc_attr(themeum_get_title_by_id($team_2["themeum_club_name2"])).'">';
  278.                                                           $output .= '<h4>'.esc_attr(themeum_get_title_by_id($team_2["themeum_club_name2"])).'</h4>                                           ';
  279.                                                       $output .= '</div>                                            ';
  280.                                                     $output .= '</div></a>';
  281.                                                     }
  282.                                                 }
  283.                                               wp_reset_postdata();
  284.  
  285.                                           $output .= '</div>';
  286.                                         $output .= '</div>';
  287.  
  288.                                         echo $output;
  289.                                       }
  290.                                     }
  291.                                     ?>
  292.                                 </div>
  293.                                 <!-- ********************************** Results ************************************ -->
  294.  
  295.  
  296.  
  297.                                 <!-- ********************************** Standing ************************************ -->
  298.                                 <div role="tabpanel" class="tab-pane fade in" id="standings">
  299.                                     <?php
  300.                                       if(is_array($league_id)){
  301.                                           if(isset($league_id[0]->slug)){
  302.  
  303.                                                 $args = array(
  304.                                                           'post_type'     => 'point_table',
  305.                                                           'posts_per_page'  => -1,
  306.                                                           'tax_query' => array(
  307.                                                                     array(
  308.                                                                       'taxonomy' => 'league',
  309.                                                                       'field'    => 'slug',
  310.                                                                       'terms'    => $league_id[0]->slug,
  311.                                                                     )
  312.                                                                   )
  313.                                                         );
  314.                                                 $posts = get_posts($args);
  315.                                                 $output = '';
  316.  
  317.  
  318.                                                 $output = '<div class="fixture-teams"><div class="point-table table-responsive">';
  319.                                                 $output .= '<table class="table table-striped">';
  320.                                                
  321.                                                 foreach ($posts as $post){
  322.                                                   setup_postdata( $post );
  323.  
  324.                                                   $point_table    = get_post_meta( get_the_ID(),'point_table_group',true );
  325.                                                   usort($point_table, 'sort_by_points');
  326.                                                   $i=1;
  327.                                                   $output .= '<thead class="point-table-head"><tr><th class="text-left">No</th><th class="text-left">TEAM</th><th>P</th><th>W</th><th>D</th><th>L</th><th>GS</th><th>GA</th><th>+/-</th><th>PTS</th></tr></thead>';
  328.                                                   $output .= '<tbody>';
  329.                                                   foreach ($point_table as  $value) {
  330.                                                     if ( $value['themeum_club_name'] ) {
  331.                                                       $output .= '<tr>';
  332.                                                       $output .= '<td class="text-left">'.$i.'</td>';
  333.                                                       $output .= '<td class="text-left"><img class="point-table-image" src="'.esc_url(themeum_logo_url_by_id($value['themeum_club_name'])).'" alt="'.get_the_title($value['themeum_club_name']).'"><span>'.get_the_title($value['themeum_club_name']).'</span></td>';
  334.                                                       $output .= '<td>'.$value['themeum_games_played'].'</td>';
  335.                                                       $output .= '<td>'.$value['themeum_games_won'].'</td>';
  336.                                                       $output .= '<td>'.$value['themeum_games_drown'].'</td>';
  337.                                                       $output .= '<td>'.$value['themeum_games_lost'].'</td>';
  338.                                                       $output .= '<td>'.$value['themeum_goals_scored'].'</td>';
  339.                                                       $output .= '<td>'.$value['themeum_goals_against'].'</td>';
  340.                                                       $output .= '<td>'.$value['themeum_goals_difference'].'</td>';
  341.                                                       $output .= '<td>'.$value['themeum_points'].'</td>';
  342.                                                       $output .= '</tr>';
  343.  
  344.                                                     $i++;
  345.                                                     }
  346.                                                   }
  347.                                                   $output .= '</tbody>';
  348.                                                 }
  349.                                                 wp_reset_postdata();
  350.                                                 $output .= '</table>';
  351.                                                 $output .= '</div></div>';
  352.  
  353.                                                 echo $output;
  354.                                           }
  355.                                       }
  356.                                     ?>
  357.                                 </div>
  358.                                 <!-- ********************************** Standing ************************************ -->
  359.  
  360.  
  361.  
  362.  
  363.                                 <!-- ********************************** Team Start ********************************** -->
  364.                                 <div role="tabpanel" class="tab-pane fade in" id="teams">
  365.                                     <?php
  366.                                     if(is_array($league_id)){
  367.                                           if(isset($league_id[0]->slug)){
  368.  
  369.                                                   $args = array(
  370.                                                           'post_type'     => 'fixture_reasult',
  371.                                                           'posts_per_page'  => -1,
  372.                                                           'tax_query' => array(
  373.                                                                     array(
  374.                                                                       'taxonomy' => 'league',
  375.                                                                       'field'    => 'slug',
  376.                                                                       'terms'    => $league_id[0]->slug,
  377.                                                                     )
  378.                                                                   )
  379.                                                         );
  380.                                                   $posts = get_posts($args);
  381.  
  382.  
  383.                                                   $team_id_list = array();
  384.                                                   foreach ($posts as $post){
  385.                                                         setup_postdata( $post );
  386.                                                         $team_1    = get_post_meta( get_the_ID(),'team_1_group',true);
  387.                                                         $team_2    = get_post_meta( get_the_ID(),'team_2_group',true);
  388.                                                         $team_id_list[] = $team_1["themeum_club_name1"];
  389.                                                         $team_id_list[] = $team_2["themeum_club_name2"];
  390.                                                   }
  391.                                                   wp_reset_postdata();
  392.                                                   $team_id_list = array_unique($team_id_list);
  393.  
  394.                                                   $args2 = array();
  395.                                                   if(is_array($team_id_list)){
  396.                                                     $args2 = array(
  397.                                                     'post_type'     => 'club',
  398.                                                     'post__in'      => $team_id_list,
  399.                                                     'posts_per_page'  => -1,
  400.                                                   );  
  401.                                                   }
  402.                                                   $posts2 = get_posts($args2);
  403.                                                   $count = count($posts2);
  404.                                                   $output = '';
  405.  
  406.                                                   //print_r($posts2);
  407.  
  408.  
  409.  
  410.                                                   $output .= '<div class="fixture-teams">';
  411.                                                         $output .= '<div class="fixture-teams-list result-list">';
  412.                                                            
  413.                                                             $output .= '<div class="row">';
  414.                                                                 $output .= '<h3 class="fixture-title">'.__('Team List','themeum-soccer').'</h3>';
  415.                                                             $output .= '</div>';
  416.  
  417.                                                             $i=0;
  418.                                                             $count = count($posts2);
  419.  
  420.                                                             foreach ($posts2 as $post){
  421.                                                               setup_postdata( $post );
  422.                                                               $club_logo = get_post_meta( get_the_ID(),'themeum_club_logo',true);
  423.                                                              
  424.                                                               $club_logo = get_post_thumbnail_id( get_the_ID() );
  425.  
  426.                                                                 if($i%2==0){
  427.                                                                     $output .= '<div class="row fixture-team-inner clearfix">';
  428.                                                                   }
  429.  
  430.                                                                 $output .= '<div class="col-sm-6 paddingleft">';
  431.                                                                     $output .= '<img width="40" class="pull-left" src="'.esc_url(wp_get_attachment_image_src($club_logo,'full', true)[0]).'" alt="'.esc_attr(themeum_get_title_by_id($club1)).'"> ';
  432.                                                                     $output .= '<h4>'.get_the_title().'</h4>';
  433.                                                                 $output .= '</div>';
  434.  
  435.                                                                 $i++;
  436.                                                                 if( $i%2==0 || $count == $i ){
  437.                                                                   $output .= '</div>';
  438.                                                                 }
  439.                                                                
  440.                                                             }
  441.                                                             wp_reset_postdata();      
  442.  
  443.                                                         $output .= '</div>';
  444.                                                     $output .= '</div>';
  445.  
  446.  
  447.                                                     echo $output;
  448.                                           }
  449.                                       }
  450.                                     ?>
  451.                                 </div>
  452.                                 <!-- ********************************** Team Start ********************************** -->
  453.  
  454.  
  455.  
  456.                             </div>
  457.  
  458.  
  459.                         </div>
  460.                     </div>
  461.                 </div>
  462.           </div>
  463.         <?php
  464.         endif;
  465.         endif;
  466.         ?>
  467.  
  468.  
  469.   </section> <!--/#main-->
  470. <?php get_footer();
Advertisement
Add Comment
Please, Sign In to add comment