Exemplo n.º 1
0
 /**
  * Exports all accepted exhibits so we can create printed signs for each
  * 
  * @return void
  */
 private function build_exhibit_signage_export()
 {
     // Check our nonce
     if (isset($_GET['export_nonce']) && !wp_verify_nonce($_GET['export_nonce'], 'mf_export_check')) {
         return false;
     }
     // Make sure the user requesting this has the privileges...
     if (!current_user_can('edit_others_posts')) {
         return false;
     }
     /**
      * $options = array(
      * 'filters' => array(
      * 'type' => 'exhibit',
      * 'post_status' => 'accepted',
      * ),
      * );
      */
     $options = array('filters' => array('post_status' => 'accepted', 'tax_query' => array(array('taxonomy' => 'type', 'field' => 'slug', 'terms' => 'exhibit'), array('taxonomy' => 'faire', 'field' => 'slug', 'terms' => MF_CURRENT_FAIRE)), 'meta_query' => array()));
     // Setup the headers we want.
     $headers = array('ID', 'Exhibit', 'Photo', '@Photo_Slug', 'Description', 'Name', 'Bio');
     // Process our headers
     $header_titles = '';
     foreach ($headers as $header) {
         $header_titles .= "{$header}\t";
     }
     $header_titles .= "\r\n";
     // As we get closer to the faire we need to reprint signs for some applications. Let's customize the application retrival to do just that.
     if (isset($_GET['reprint'])) {
         $options['filters']['meta_query'][] = array('key' => '_ef_editorial_meta_checkbox_reprint-sign', 'value' => '1');
     }
     // Get our applications
     $exhibits = $this->get_all_forms(null, $options['filters']['post_status'], $options['filters'], MF_CURRENT_FAIRE);
     $results = array();
     $body = '';
     foreach ($exhibits as $exhibit) {
         $form = (array) json_decode(str_replace('\\', '\\\\', $exhibit->post_content));
         // Loop through all the content and clean it up
         foreach ($form as $key => $value) {
             if (is_array($value)) {
                 $i = 0;
                 foreach ($value as $v) {
                     $form[sanitize_key($key)][intval($i)] = mf_clean_content($v, true);
                     $i++;
                 }
             } else {
                 $form[sanitize_key($key)] = mf_clean_content($value, true);
             }
         }
         // Process our name field. We'll want to handle exhibit maker types differently.
         if (array_key_exists('form_type', $form) && $form['form_type'] == 'exhibit') {
             switch ($form['maker']) {
                 case 'One maker':
                     $maker_name = (!empty($form['maker_name']) ? $form['maker_name'] : '') . "\t";
                     $maker_bio = (!empty($form[$this->merge_fields('user_bio', $form['form_type'])]) ? $form[$this->merge_fields('user_bio', $form['form_type'])] : '') . "\t";
                     break;
                 case 'A list of makers':
                     $count = 1;
                     if (is_array($form['m_maker_name'])) {
                         $maker_name = '';
                         foreach ($form['m_maker_name'] as $m_name) {
                             $separator = $count == 1 ? '' : ', ';
                             $maker_name .= !empty($m_name) ? $separator . $m_name : $separator;
                             $count++;
                         }
                         $maker_name .= "\t";
                         $maker_bio = '';
                     } else {
                         $maker_name = (!empty($form['m_maker_name']) ? $form['m_maker_name'] : '') . "\t";
                         $maker_bio = (!empty($form['m_maker_bio']) ? $form['m_maker_bio'] : '') . "\t";
                     }
                     break;
                 case 'A group or association':
                     $maker_name = (!empty($form['group_name']) ? $form['group_name'] : '') . "\t";
                     $maker_bio = (!empty($form['group_bio']) ? $form['group_bio'] : '') . "\t";
                     break;
             }
         } else {
             $maker_name = (!empty($form['name']) ? $form['name'] : '') . "\t";
             $maker_bio = (!is_array($form[$this->merge_fields('user_bio', $form['form_type'])]) ? $form[$this->merge_fields('user_bio', $form['form_type'])] : $form[$this->merge_fields('user_bio', $form['form_type'])][0]) . "\t";
         }
         $photo = $form[$this->merge_fields('form_photo', $form['form_type'])];
         $row = $exhibit->ID . "\t";
         $row .= $form[$this->merge_fields('project_name', $form['form_type'])] . "\t";
         $row .= $photo . "\t";
         $row .= basename($photo) . "\t";
         $row .= $form['form_type'] != 'presenter' ? $form['public_description'] . "\t" : $form['short_description'] . "\t";
         $row .= $maker_name;
         $row .= $maker_bio;
         // Contain our entire row into the $body variable
         $body .= $row . "\r\n";
     }
     // Get the time this export was ran. This is used in the file name of the CSV
     $time_offset = time() - 3600 * 7;
     // Process the list makers CSV
     $this->output_csv('EXHIBIT_SIGNAGE_' . date('M-d-Y', $time_offset), $header_titles . $body);
 }
Exemplo n.º 2
0
    /**
     * 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 
    }