Example #1
0
 public function at_ajax_get_tournaments()
 {
     if (!is_admin()) {
         exit('Get oouuuttaaa heeeere.');
     }
     check_ajax_referer(ajax_nonce_string, 'security');
     global $at_tournament;
     $at_tournament = new at_tournament();
     $tournaments = $at_tournament->at_get_tournament_data();
     if (!empty($tournaments)) {
         $tournaments_array = array();
         foreach ($tournaments as $tournament) {
             $tournaments_array[] = array('post_id' => $tournament->ID, 'title' => $tournament->post_title);
         }
         wp_send_json($tournaments_array);
     }
     exit;
 }
Example #2
0
 public function at_filter_the_content($content)
 {
     global $post, $at_config, $at_functions, $at_entry, $at_tournament;
     $at_tournament = new at_tournament();
     $published = $post->post_status == 'publish' || 'future' ? true : false;
     $new_content = $content;
     $status = '';
     // Get AT Post Type
     $meta_post_type = get_post_meta($post->ID, at_post_type, true);
     // Get AT Post End DateTime
     $at_post_expires = get_post_meta($post->ID, at_post_expires, true);
     if (!empty($at_post_expires)) {
         $post_end = date_create_from_format('Y-m-d H:i:s', $at_post_expires, $at_config->wp_timezone);
         $post_end_date = $post_end->format('F jS, Y');
         $post_end_time = $post_end->format('g:i A');
     }
     // If Post is Tournament
     if ($post->post_type === at_post_type_tournament) {
         if (!empty($post->post_parent)) {
             $tournament_id = $post->post_parent;
         } else {
             $tournament_id = $post->ID;
         }
         $status = $at_tournament->at_insert_tournament_status($tournament_id);
         if ($meta_post_type === at_post_type_sample_pack_page && !is_user_logged_in()) {
             $new_content = '<div class="alert alert-success"><p><a href="' . wp_registration_url() . '">Register</a> now to download this Sample Pack!</p>';
             $new_content .= '<p>Already a member? <a href="' . wp_login_url() . '">Login</a> to continue.</p></div>';
         }
         $new_content = $status . $new_content;
     }
     if ($post->post_type === at_post_type_tournament && !empty($at_post_expires) && $published) {
         // Post has not expired
         if ($this->at_ts_pending($at_post_expires)) {
             switch ($meta_post_type) {
                 case at_post_type_sample_pack_page:
                     $at_config->at_javascript_globals['samplepackEnd'] = $post_end->format('U');
                     $new_content = '<div class="alert alert-warning"><p>Sample Pack access ends <span class="samplepackEnd"></span></p></div>' . $new_content;
                     break;
             }
         } else {
             if ($this->at_ts_expired($at_post_expires)) {
                 switch ($meta_post_type) {
                     case at_post_type_sample_pack_page:
                         $at_config->at_javascript_globals['samplepackEnd'] = $post_end->format('U');
                         $expired_content = '<div class="alert alert-danger"><p>Sample Pack ended <span class="samplepackEnd"></span></p></div>';
                         break;
                     case at_post_type_submit_page:
                         $at_config->at_javascript_globals['submitEnd'] = $post_end->format('U');
                         $expired_content = '<div class="alert alert-danger"><p>Submissions ended <span class="submitEnd"></span></p></div>';
                         break;
                     case at_post_type_voting_page:
                         $at_config->at_javascript_globals['votingEnd'] = $post_end->format('U');
                         $expired_content = '<div class="alert alert-danger"><p>Voting ended <span class="votingEnd"></span></p></div>';
                         break;
                 }
                 $new_content = $status . $expired_content;
             }
         }
     }
     return $new_content;
 }