function mf_get_scheduled_item($the_ID) { $query = wp_cache_get($the_ID . '_saturday_schedule'); if ($query == false) { $args = array('post_type' => 'event-items', 'orderby' => 'meta_value', 'meta_key' => 'mfei_start', 'order' => 'asc', 'posts_per_page' => '30', 'meta_query' => array(array('key' => 'mfei_record', 'value' => $the_ID), array('key' => 'mfei_day', 'value' => 'Saturday'))); $query = new WP_Query($args); wp_cache_set($the_ID . '_saturday_schedule', $query, '', 300); } $output = '<table class="hide schedule table table-striped table-bordered">'; if ($query->found_posts >= 1) { // Set a variable we can use to see if Saturday events were found for the Sunday query $has_saturday_events = true; $output .= '<thead><tr class="info"><td><strong>Day</strong></td><td><strong>Start Time</strong></td><td><strong>End Time</strong></td><td><strong>Locations</strong></td><td class="no-video"><strong>Video Coverage</strong></td></tr></thead><tbody>'; while ($query->have_posts()) { $query->the_post(); $meta = get_post_meta(get_the_ID()); $sched_post = get_post($meta['mfei_record'][0]); $json = json_decode(str_replace("\\'", "'", $sched_post->post_content)); $day = $meta['mfei_day'][0] ? $meta['mfei_day'][0] : ''; $start = $meta['mfei_start'][0] ? $meta['mfei_start'][0] : ''; $stop = $meta['mfei_stop'][0] ? $meta['mfei_stop'][0] : ''; $location = mf_get_locations(get_the_id()); $coverage = !empty($meta['mfei_coverage'][0]) ? $meta['mfei_coverage'][0] : ''; $output .= '<tr>'; $output .= '<td>' . esc_html($day) . '</td>'; $output .= '<td>' . esc_html($start) . '</td>'; $output .= '<td>' . esc_html($stop) . '</td>'; if (!empty($location)) { $output .= '<td>' . esc_html($location) . '</td>'; } else { $output .= '<td>' . get_the_term_list(get_the_ID(), 'location') . '</td>'; } if (!empty($coverage)) { $output .= '<td class="has-video"><a href="' . esc_url($coverage) . '" class="btn btn-xs btn-primary">Watch Video</a></td>'; } else { $output .= '<td class="no-video"></td>'; } $output .= '</tr>'; } } wp_reset_postdata(); $query = wp_cache_get($the_ID . '_sunday_schedule'); if ($query == false) { $args = array('post_type' => 'event-items', 'orderby' => 'meta_value', 'meta_key' => 'mfei_start', 'order' => 'asc', 'posts_per_page' => '30', 'meta_query' => array(array('key' => 'mfei_record', 'value' => $the_ID), array('key' => 'mfei_day', 'value' => 'Sunday'))); $query = new WP_Query($args); wp_cache_set($the_ID . '_sunday_schedule', $query, '', 300); } if ($query->found_posts >= 1) { if (!isset($has_saturday_events)) { $output .= '<thead><tr class="info"><td><strong>Day</strong></td><td><strong>Start Time</strong></td><td><strong>End Time</strong></td><td><strong>Locations</strong></td><td class="no-video"><strong>Video Coverage</strong></td></tr></thead><tbody>'; } while ($query->have_posts()) { $query->the_post(); $meta = get_post_meta(get_the_ID()); $sched_post = get_post($meta['mfei_record'][0]); $json = json_decode(str_replace("\\'", "'", $sched_post->post_content)); $day = $meta['mfei_day'][0] ? $meta['mfei_day'][0] : ''; $start = $meta['mfei_start'][0] ? $meta['mfei_start'][0] : ''; $stop = $meta['mfei_stop'][0] ? $meta['mfei_stop'][0] : ''; $location = mf_get_locations(get_the_id()); $coverage = !empty($meta['mfei_coverage'][0]) ? $meta['mfei_coverage'][0] : ''; $output .= '<tr>'; $output .= '<td>' . esc_html($day) . '</td>'; $output .= '<td>' . esc_html($start) . '</td>'; $output .= '<td>' . esc_html($stop) . '</td>'; if (!empty($location)) { $output .= '<td>' . esc_html($location) . '</td>'; } else { $output .= '<td>' . get_the_term_list(get_the_ID(), 'location') . '</td>'; } if (!empty($coverage)) { $output .= '<td class="has-video"><a href="' . esc_url($coverage) . '" class="btn btn-xs btn-primary">Watch Video</a></td>'; } else { $output .= '<td class="no-video">No Video Available</td>'; } $output .= '</tr>'; } } $output .= '<tbody></table>'; return $output; wp_reset_postdata(); }
function makerfaire_add_name_to_column($column_name, $post_ID) { switch ($column_name) { case 'event_id': edit_post_link('Event ID : ' . $post_ID, '', '', $post_ID); break; case 'project_id': echo intval(get_post_meta($post_ID, 'mfei_record', true)); break; case 'day': echo esc_html(get_post_meta($post_ID, 'mfei_day', true)); break; case 'project_name': $id = get_post_meta($post_ID, 'mfei_record', true); edit_post_link(get_the_title($id), '', '', $id); break; case 'start_time': echo esc_html(get_post_meta($post_ID, 'mfei_start', true)); break; case 'stop_time': echo esc_html(get_post_meta($post_ID, 'mfei_stop', true)); break; case 'location': echo mf_get_locations($post_ID); break; } }
private function build_presentation_exports($type = 'manager') { // NONCE CHECK if (isset($_GET['_wpnonce']) && !wp_verify_nonce($_GET['_wpnonce'], 'mf_export_check')) { return false; } // CAP CHECK if (!current_user_can('edit_others_posts')) { return false; } // EXPORT TYPES if ($type == 'manager') { $output = "Start Time\tEnd Time\tDate\tLocation\tProject ID\tProject Name\tType\tFirst Name\tLast Name\tEmail\tPhone\tTwitter\tSpecial Requests\r\n"; $title = 'MANAGER_REPORT_'; } elseif ($type == 'signage') { $output = "Location\tStart Time\tEnd Time\tDay\tProject Title\tPresenter Name(s)\r\n"; $title = 'STAGE_SIGNAGE_'; } elseif ($type == 'checkin') { $output = "Presenter ID\tPresenter Last name\tPresenter First name\tProject Title\tLocation\tDate\tStart Time\tEnd Time\r\n"; $title = 'PRESENTER_CHECKIN_'; } else { return false; } // GET PRESENTER FORMS $args = array('posts_per_page' => 1999, 'post_type' => 'mf_form', 'post_status' => array('accepted'), 'faire' => MF_CURRENT_FAIRE, 'type' => 'presenter'); $ps = new WP_Query($args); $forms = array(); foreach ($ps->posts as $post) { $forms[$post->ID] = $post; } // GET EVENT ITEMS $mfeis = get_posts(array('post_type' => 'event-items', 'numberposts' => 1999)); // BUILD THE 3 FORMS foreach ($mfeis as $mfei) { $data = get_post_custom($mfei->ID); if (!isset($forms[$data['mfei_record'][0]])) { continue; } $form = (array) json_decode(str_replace("\\'", "'", $forms[$data['mfei_record'][0]]->post_content)); $loc = mf_get_locations($mfei->ID); $fname = substr($form['name'], 0, strpos($form['name'], ' ')); $lname = substr($form['name'], strpos($form['name'], ' ') + 1); if ($type == 'manager') { if (!is_array($form['presenter_name'])) { $form['presenter_name'] = array($form['presenter_name']); } $line = ''; foreach ($form['presenter_name'] as $name) { $fname = substr($name, 0, strpos($name, ' ')); $lname = substr($name, strpos($name, ' ') + 1); $line .= $data['mfei_start'][0] . "\t"; $line .= $data['mfei_stop'][0] . "\t"; $line .= $data['mfei_day'][0] . "\t"; $line .= $loc . "\t"; $line .= intval($data['mfei_record'][0]) . "\t"; $line .= $form['presentation_name'] . "\t"; $line .= "Presentation\t"; $line .= $fname . "\t"; $line .= $lname . "\t"; $line .= $form['email'] . "\t"; $line .= $form['phone1'] . "\t"; $line .= isset($form['presenter_twitter']) && is_array($form['presenter_twitter']) ? implode(", ", $form['presenter_twitter']) . "\t" : $form['presenter_twitter'] . "\t"; $line .= $form['special_requests'] . "\t\r\n"; } $line = substr($line, 0, -4); } elseif ($type == 'signage') { $line = $loc . "\t"; $line .= $data['mfei_start'][0] . "\t"; $line .= $data['mfei_stop'][0] . "\t"; $line .= $data['mfei_day'][0] . "\t"; $line .= $form['presentation_name'] . "\t"; $line .= (is_array($form['presenter_name']) ? implode(', ', $form['presenter_name']) . "\t" : $form['presenter_name']) . "\t"; } elseif ($type == 'checkin') { if (!is_array($form['presenter_name'])) { $form['presenter_name'] = array($form['presenter_name']); } $line = ''; foreach ($form['presenter_name'] as $name) { $fname = substr($name, 0, strpos($name, ' ')); $lname = substr($name, strpos($name, ' ') + 1); $line .= intval($data['mfei_record'][0]) . "\t"; $line .= $fname . "\t"; $line .= $lname . "\t"; $line .= $form['presentation_name'] . "\t"; $line .= $loc . "\t"; $line .= $data['mfei_day'][0] . "\t"; $line .= $data['mfei_start'][0] . "\t"; $line .= $data['mfei_stop'][0] . "\r\n"; } $line = substr($line, 0, -4); } else { return false; } $output .= $line . "\r\n"; } $time_offset = time() - 3600 * 7; $this->output_csv($title . date('M-d-Y', $time_offset) . '_' . date('G-i', $time_offset), $output); }
/** * Current Faire Page */ function display_current_faire_page() { //must check that the user has the required capability if (!current_user_can($this->user_capabilities)) { wp_die(__('You do not have sufficient permissions to access this page.', 'make')); } // Get any query variables if set $query_vars = $this->get_query_vars(); // Check if we are filtering our results by post type. if (empty($query_vars['post_status']) || $query_vars['post_status'] == 'all') { $post_status = array_slice($this->post_status, 1); } else { $post_status = $query_vars['post_status']; } $args = array('faire' => $this->current_faire, 'post_type' => $this->post_type, 'post_status' => $post_status, 'posts_per_page' => $query_vars['posts_per_page'], 'paged' => $query_vars['paged'], 'cat' => $query_vars['category'], 'tag' => $query_vars['tag'], 'type' => $query_vars['app_type'], 'meta_key' => $query_vars['edu_day'], 'orderby' => $query_vars['order_by'], 's' => $query_vars['search'], 'p' => $query_vars['post_id']); $query = new WP_Query($args); ?> <div class="wrap"> <h1><?php echo $this->submenu_data['page_title']; ?> </h1> <ul class="subsubsub"> <?php echo $this->count_post_status(); ?> </ul> <form method="get" class="posts-filter"> <input type="hidden" name="post_type" value="<?php echo esc_attr($_REQUEST['post_type']); ?> " /> <input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?> " /> <?php wp_nonce_field('overview-form-save', $this->nonce_name, false); ?> <p class="search-box"> <label for="post-search-input" class="screen-reader-text">Search All Applications</label> <input type="search" id="post-search-input" name="s" value="<?php echo isset($query_vars['search']) ? esc_attr($query_vars['search']) : ''; ?> "> <input type="submit" name="" id="search-submit" class="button" value="Search All Applications"> </p> <div class="tablenav top"> <?php echo $this->application_type_dropdown(); ?> <?php echo $this->categories_dropdown(); ?> <?php echo $this->tags_dropdown(); ?> <?php echo $this->orderby_dropdown(); ?> <?php echo $this->posts_per_page_dropdown(array(20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 1000)); ?> <label for="post-search-id" class="screen-reader-text">Search by Project ID</label> <input type="search" id="post-search-id" name="p" placeholder="Project ID" value="<?php echo isset($_GET['p']) && !empty($_GET['p']) ? esc_attr($_GET['p']) : ''; ?> "> <input type="submit" name="" id="filter-submit" class="button" value="Filter All Content"> <button class="button"><a href="<?php echo esc_url(admin_url($this->submenu_data['page_url'])); ?> ">Reset Filters</a></button> <div class="tablenav-pages"> <span class="displaying-num"><?php echo absint($query->found_posts); ?> Items</span> <?php echo $this->get_pagination_link($query->max_num_pages, $query_vars['paged']); ?> </div> </div> <table id="current-faire" class="wp-list-table widefat fixed pages"> <thead> <tr> <?php foreach ($this->columns as $column => $details) { ?> <th scope="col" id="<?php echo $column; ?> " class="manage-column column-<?php echo $column; echo $details['sortable'] ? ' table-sortable' : ''; ?> "<?php echo $this->check_screen_options($column, false, $details['default']); ?> ><?php echo $details['label']; ?> </th> <?php } ?> </tr> </thead> <tfoot> <tr> <?php foreach ($this->columns as $column => $details) { ?> <th scope="col" id="<?php echo $column; ?> " class="manage-column column-<?php echo $column; echo $details['sortable'] ? ' table-sortable' : ''; ?> "<?php echo $this->check_screen_options($column, false, $details['default']); ?> ><?php echo $details['label']; ?> </th> <?php } ?> </tr> </tfoot> <tbody id="the-list"> <?php global $post, $wp_post_statuses; if (!empty($query->posts)) { foreach ($query->posts as $post) { setup_postdata($post); // Set just a couple of variables.... :/ $json = json_decode(str_replace('\\', '\\\\', $post->post_content)); $post_id = absint($post->ID); $app_image = mf_get_the_maker_image($json); $post_status = $wp_post_statuses[get_post_status()]->label; $maker_name = !empty($json->name) ? $json->name : ''; $app_type = get_the_term_list($post_id, 'type', '', ', ', ''); $description = !empty($json->public_description) ? mf_clean_content($json->public_description) : ''; $cats = get_the_category_list(', ', '', $post_id); $tags = get_the_term_list($post_id, 'post_tag', null, ', '); $location = mf_get_locations($post_id); $featured = get_post_meta($post_id, '_ef_editorial_meta_checkbox_featured', true); $commercial = !empty($json->sales) ? sanitize_text_field($this->convert_boolean($json->sales)) : ''; $edu_day = get_post_meta($post_id, '_ef_editorial_meta_checkbox_education-day', true); echo '<tr id="post-' . absint($post->ID) . '" valign="top">'; echo '<td class="post_photo column-post_photo"' . $this->check_screen_options('post_photo', false, true) . '>'; if (!empty($app_image)) { echo '<img src="' . legacy_get_resized_remote_image_url(esc_url($app_image), 130, 130, true) . '" width="130" height="130">'; } echo '</td>'; echo '<td class="post_id column-post_id"' . $this->check_screen_options('post_id', false, true) . '>' . $post_id . '</td>'; echo '<td class="post_status column-post_status"' . $this->check_screen_options('post_status', false, true) . '>' . $post_status . '</td>'; echo '<td class="post_title column-post_title"' . $this->check_screen_options('post_title', false, true) . '><strong><a href="' . get_edit_post_link(absint($post->ID)) . '">' . esc_html(get_the_title()) . '</a></strong> <div class="row-actions"> <span class="inline hide-if-no-js"><a href="' . get_edit_post_link(absint($post->ID)) . '">Edit</a> | </span> <span class="view"><a href="' . get_permalink() . '">View</a></span> </div> </td>'; echo '<td class="post_author column-post_author"' . $this->check_screen_options('post_author', false, true) . '>' . esc_html($maker_name) . '</td>'; echo '<td class="post_type column-post_type"' . $this->check_screen_options('post_type', false, true) . '>' . $app_type . '</td>'; echo '<td class="post_description column-post_description"' . $this->check_screen_options('post_description', false, true) . '>' . wp_trim_words(Markdown(wp_kses_post($description)), 15) . '</td>'; echo '<td class="cats column-cats"' . $this->check_screen_options('cats', false, true) . '>' . $cats . '</td>'; echo '<td class="tags column-tags"' . $this->check_screen_options('tags', false, true) . '>' . $tags . '</td>'; echo '<td class="location column-location"' . $this->check_screen_options('location', false, true) . '>' . esc_html($location) . '</td>'; echo '<td class="featured_maker column-featured_maker"' . $this->check_screen_options('featured_maker', false, true) . '>' . $this->convert_boolean($featured) . '</td>'; echo '<td class="post_date column-post_date"' . $this->check_screen_options('post_date', false, true) . '>' . $this->process_dates($post->post_date, $post->post_modified) . '</td>'; echo '<td class="commercial column-commercial"' . $this->check_screen_options('commercial', false, true) . '>' . $commercial . '</td>'; echo '<td class="education_day column-education_day"' . $this->check_screen_options('education_day', false, true) . '>' . $this->convert_boolean($edu_day) . '</td>'; echo '</tr>'; } } else { echo '<tr class="no-items"><td class="colspanchange" colspan="3">No content found.</td></tr>'; } ?> </tbody> </table> <div class="tablenav bottom"> <div class="tablenav-pages"> <span class="displaying-num"><?php echo absint($query->found_posts); ?> Items</span> <?php echo $this->get_pagination_link($query->max_num_pages, $query_vars['paged']); ?> </div> </div> </form> </div> <?php }