/** * Start the week with a table row * * @since 0.1.0 */ protected function get_row_cell($iterator = 1, $start_day = 1) { // Calculate the day of the month $day_of_month = (int) ($iterator - (int) $start_day + 1); // Calculate link to day view $link_to_day = add_query_arg(array('mode' => 'day', 'year' => $this->year, 'month' => $this->month, 'day' => $day_of_month), $this->get_base_url()); // Link to add new event on this day $add_event_for_day = add_query_arg(array('post_type' => wp_event_calendar_get_admin_post_type(), 'start_day' => strtotime("{$this->month}/{$day_of_month}/{$this->year}")), admin_url('post-new.php')); ?> <td class="<?php echo $this->get_day_classes($iterator, $start_day); ?> "> <a href="<?php echo esc_url($link_to_day); ?> " class="day-number"> <?php echo (int) $day_of_month; ?> </a> <a href="<?php echo esc_url($add_event_for_day); ?> " class="add-event-for-day"> <i class="dashicons dashicons-plus"></i> </a> <div class="events-for-cell"> <?php echo $this->get_posts_for_cell($day_of_month); ?> </div> </td> <?php }
/** * Output the admin calendar * * @since 0.1.0 */ function wp_event_calendar_show_admin_calendar() { // Get the post type for easy caps checking $post_type = wp_event_calendar_get_admin_post_type(); $post_type_object = get_post_type_object($post_type); $user_id = get_current_user_id(); // Check for new mode if (!empty($_REQUEST['mode'])) { if (in_array($_REQUEST['mode'], array('month', 'week', 'day'))) { $mode = $_REQUEST['mode']; } update_user_option($user_id, 'event_calendar_mode', $mode); // Use existing mode } else { $mode = get_user_option('event_calendar_mode', $user_id); } // Load the list table based on the mode switch ($mode) { case 'day': $wp_list_table = new WP_Event_Calendar_Day_Table(); break; case 'week': $wp_list_table = new WP_Event_Calendar_Week_Table(); break; case 'month': default: $wp_list_table = new WP_Event_Calendar_Month_Table(); break; } // Query for calendar content $wp_list_table->prepare_items(); // Set the help tabs $wp_list_table->set_help_tabs(); ?> <div class="wrap"> <h1><?php esc_html_e('Events', 'wp-event-calendar'); ?> <?php if (current_user_can($post_type_object->cap->create_posts)) { ?> <a href="<?php echo esc_url(add_query_arg(array('post_type' => $post_type), admin_url('post-new.php'))); ?> " class="page-title-action"><?php esc_html_e('Add New', 'wp-event-calendar'); ?> </a> <?php } ?> </h1> <?php $wp_list_table->views(); ?> <form id="posts-filter" method="get"> <?php $wp_list_table->search_box($post_type_object->labels->search_items, $post_type); ?> <input type="hidden" name="post_type" class="post_type_page" value="<?php echo esc_attr($post_type); ?> " /> <input type="hidden" name="page" class="post_type_page" value="<?php echo esc_attr($post_type); ?> -calendar" /> <?php $wp_list_table->display(); ?> </form> <div id="ajax-response"></div> <br class="clear" /> </div> <?php }