Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 52.86 KB | None | 0 0
  1.  
  2.     <?php
  3.     /**
  4.     * Public pages
  5.     */
  6.     if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  7.    
  8.     class PTA_SUS_Public {
  9.    
  10.     private $data;
  11.         private $table;
  12.         private $plugin_path;
  13.         private $plugin_prefix = 'pta-sus';
  14.         private $request_uri;
  15.         private $all_sheets_uri;
  16.         public $main_options;
  17.         public $email_options;
  18.         public $integration_options;
  19.         public $member_directory_active;
  20.         public $submitted;
  21.         public $err;
  22.         public $success;
  23.         public $errors;
  24.         public $messages;
  25.         private $task_item_header;
  26.         private $start_time_header;
  27.         private $end_time_header;
  28.         private $item_details_header;
  29.         private $item_qty_header;
  30.         private $na_text;
  31.        
  32.         public function __construct() {
  33.             $this->data = new PTA_SUS_Data();
  34.            
  35.             $plugin = plugin_basename(__FILE__);
  36.            
  37.             $this->plugin_path = dirname(__FILE__).'/';
  38.    
  39.             $this->all_sheets_uri = add_query_arg(array('sheet_id' => false, 'date' => false, 'signup_id' => false, 'task_id' => false));
  40.    
  41.             add_shortcode('pta_sign_up_sheet', array($this, 'display_sheet'));
  42.            
  43.             add_action('wp_enqueue_scripts', array($this, 'add_css_and_js_to_frontend'));
  44.    
  45.             add_action('wp_loaded', array($this, 'process_signup_form'));
  46.             add_action('wp_loaded', array($this, 'set_up_filters'));
  47.    
  48.             $this->main_options = get_option( 'pta_volunteer_sus_main_options' );
  49.             $this->email_options = get_option( 'pta_volunteer_sus_email_options' );
  50.             $this->integration_options = get_option( 'pta_volunteer_sus_integration_options' );
  51.    
  52.            
  53.         } // Construct
  54.    
  55.         public function set_up_filters() {
  56.             // Set up some public output strings used by multiple functions
  57.             $this->task_item_header = apply_filters( 'pta_sus_public_output', __('Task/Item', 'pta_volunteer_sus'), 'task_item_header' );
  58.             $this->start_time_header = apply_filters( 'pta_sus_public_output', __('Start Time', 'pta_volunteer_sus'), 'start_time_header' );
  59.             $this->end_time_header = apply_filters( 'pta_sus_public_output', __('End Time', 'pta_volunteer_sus'), 'end_time_header' );
  60.             $this->item_details_header = apply_filters( 'pta_sus_public_output', __('Item Details', 'pta_volunteer_sus'), 'item_details_header' );
  61.             $this->item_qty_header = apply_filters( 'pta_sus_public_output', __('Item Qty', 'pta_volunteer_sus'), 'item_qty_header' );
  62.             $this->na_text = apply_filters( 'pta_sus_public_output', __('N/A', 'pta_volunteer_sus'), 'not_applicable_text' );
  63.         }
  64.    
  65.         public function process_signup_form() {
  66.            
  67.             $this->submitted = (isset($_POST['pta_sus_form_mode']) && $_POST['pta_sus_form_mode'] == 'submitted');
  68.             $this->err = 0;
  69.             $this->success = false;
  70.             $this->errors = '';
  71.             $this->messages = '';
  72.            
  73.             // Process Sign-up Form
  74.             if ($this->submitted) {
  75.                 // NONCE check
  76.                 if ( ! isset( $_POST['pta_sus_signup_nonce'] ) || ! wp_verify_nonce( $_POST['pta_sus_signup_nonce'], 'pta_sus_signup' ) ) {
  77.                     $this->err++;
  78.                     $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Sorry! Your security nonce did not verify!', 'pta_volunteer_sus').'</p>', 'nonce_error_message' );
  79.                     return;
  80.                 }
  81.                 // Check for spambots
  82.                 if (!empty($_POST['website'])) {
  83.                     $this->err++;
  84.                     $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Oops! You filled in the spambot field. Please leave it blank and try again.', 'pta_volunteer_sus').'</p>', 'spambot_error_message' );
  85.                     return;
  86.                 }
  87.                 //Error Handling
  88.                 if (
  89.                     empty($_POST['signup_firstname'])
  90.                     || empty($_POST['signup_lastname'])
  91.                     || empty($_POST['signup_email'])
  92.                     || (false == $this->main_options['no_phone'] && empty($_POST['signup_phone']))
  93.                     || ("YES" == $_POST['need_details'] && '' == $_POST['signup_item'])
  94.                     || ("YES" == $_POST['enable_quantities'] && '' == $_POST['signup_item_qty'])
  95.                 ) {
  96.                     $this->err++;
  97.                     $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Please complete all required fields.', 'pta_volunteer_sus').'</p>', 'required_fields_error_message' );
  98.                 }
  99.    
  100.                 // Check for non-allowed characters
  101.                 elseif (! $this->data->check_allowed_text(stripslashes($_POST['signup_firstname'])))
  102.                     {
  103.                         $this->err++;
  104.                         $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Invalid Characters in First Name!  Please try again.', 'pta_volunteer_sus').'</p>', 'firstname_error_message' );
  105.                     }
  106.                 elseif (! $this->data->check_allowed_text(stripslashes($_POST['signup_lastname'])))
  107.                     {
  108.                         $this->err++;
  109.                         $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Invalid Characters in Last Name!  Please try again.', 'pta_volunteer_sus').'</p>', 'lastname_error_message' );
  110.                     }
  111.                 elseif ( !is_email( $_POST['signup_email'] ) )
  112.                     {
  113.                         $this->err++;
  114.                         $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Invalid Email!  Please try again.', 'pta_volunteer_sus').'</p>', 'email_error_message' );
  115.                     }
  116.                 elseif (false == $this->main_options['no_phone'] && preg_match("/[^0-9\-\.\(\)\ ]/", $_POST['signup_phone']))
  117.                     {
  118.                         $this->err++;
  119.                         $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Invalid Characters in Phone Number!  Please try again.', 'pta_volunteer_sus').'</p>', 'phone_error_message' );
  120.                     }
  121.                 elseif ( "YES" == $_POST['need_details'] && ! $this->data->check_allowed_text(stripslashes($_POST['signup_item'])))
  122.                     {
  123.                         $this->err++;
  124.                         $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Invalid Characters in Signup Item!  Please try again.', 'pta_volunteer_sus').'</p>', 'item_details_error_message' );
  125.                     }
  126.                 elseif ( "YES" == $_POST['enable_quantities'] && (! $this->data->check_numbers($_POST['signup_item_qty']) || (int)$_POST['signup_item_qty'] < 1 || (int)$_POST['available_qty'] < (int)$_POST['signup_item_qty']))
  127.                     {
  128.                         $this->err++;
  129.                         $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.sprintf(__('Please enter a number between 1 and %d for Item QTY!', 'pta_volunteer_sus'), (int)$_POST['available_qty']).'</p>', 'item_quantity_error_message' );
  130.                     }
  131.                 elseif (!$this->data->check_date($_POST['signup_date']))
  132.                     {
  133.                         $this->err++;
  134.                         $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Hidden signup date field is invalid!  Please try again.', 'pta_volunteer_sus').'</p>', 'signup_date_error_message' );
  135.                     }
  136.                 // If no errors so far, Check for duplicate signups if not allowed
  137.                 if (!$this->err && (!isset($_POST['allow_duplicates']) || 'NO' == $_POST['allow_duplicates'])) {
  138.                     if( $this->data->check_duplicate_signup( $_GET['task_id'], $_POST['signup_date'], $_POST['signup_firstname'], $_POST['signup_lastname']) ) {
  139.                         $this->err++;
  140.                         $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('You are already signed up for this task!', 'pta_volunteer_sus').'</p>', 'signup_duplicate_error_message' );
  141.                     }
  142.                 }
  143.                 // Add Signup
  144.                 if (!$this->err) {
  145.                     do_action( 'pta_sus_before_add_signup', $_POST, $_GET['task_id'] );
  146.                     if ( $this->data->add_signup($_POST, $_GET['task_id']) === false) {
  147.                         $this->err++;
  148.                         $this->errors .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Error adding signup record.  Please try again.', 'pta_volunteer_sus').'</p>', 'add_signup_database_error_message' );
  149.                     } else {
  150.                         global $wpdb;
  151.                         if(!class_exists('PTA_SUS_Emails')) {
  152.                             include_once(dirname(__FILE__).'/class-pta_sus_emails.php');
  153.                         }
  154.                         $emails = new PTA_SUS_Emails();
  155.                         $this->success = true;
  156.                         $this->messages .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus updated">'.__('You have been signed up!', 'pta_volunteer_sus').'</p>', 'signup_success_message' );
  157.                         if ($emails->send_mail($wpdb->insert_id) === false) {
  158.                             $this->messages .= apply_filters( 'pta_sus_public_output', __('ERROR SENDING EMAIL', 'pta_volunteer_sus'), 'email_send_error_message' );
  159.                         }
  160.                     }
  161.                 }
  162.                
  163.             }
  164.         }
  165.    
  166.     /**
  167.          * Output the volunteer signup form
  168.          *
  169.          * @param   array   attributes from shortcode call
  170.          */
  171.         public function display_sheet($atts) {
  172.             // Set up some common strings for translation and customizing by customizer extension
  173.             $title_header = apply_filters( 'pta_sus_public_output', __('Title', 'pta_volunteer_sus'), 'title_header' );
  174.             $start_date_header = apply_filters( 'pta_sus_public_output', __('Start Date', 'pta_volunteer_sus'), 'start_date_header' );
  175.             $end_date_header = apply_filters( 'pta_sus_public_output', __('End Date', 'pta_volunteer_sus'), 'end_date_header' );
  176.             $open_spots_header = apply_filters( 'pta_sus_public_output', __('Open Spots', 'pta_volunteer_sus'), 'open_spots_header' );
  177.             $date_header = apply_filters( 'pta_sus_public_output', __('Date', 'pta_volunteer_sus'), 'date_header' );
  178.             $no_contact_message = apply_filters( 'pta_sus_public_output', __('No Event Chair contact info provided', 'pta_volunteer_sus'), 'no_contact_message' );
  179.             $contact_label = apply_filters( 'pta_sus_public_output', __('Contact:', 'pta_volunteer_sus'), 'contact_label' );
  180.    
  181.    
  182.             do_action( 'pta_sus_before_process_shortcode', $atts );
  183.             $return = '';
  184.             if(isset($this->main_options['enable_test_mode']) && true === $this->main_options['enable_test_mode'] ) {
  185.                 if (current_user_can( 'manage_options' ) || current_user_can( 'manage_signup_sheets' )) {
  186.                     $return .= apply_filters( 'pta_sus_public_output', '<p class="pta-sus error">'.__('Volunteer Sign-Up Sheets are in TEST MODE', 'pta_volunteer_sus').'</p>', 'admin_test_mode_message' );
  187.                 } elseif (is_page( $this->main_options['volunteer_page_id'] )) {
  188.                     $message = esc_html($this->main_options['test_mode_message']);
  189.                     return $message;
  190.                 } else {
  191.                     return;
  192.                 }
  193.             }
  194.             if(isset($this->main_options['login_required']) && true === $this->main_options['login_required'] ) {
  195.                 if (!is_user_logged_in()) {
  196.                     $message = '<p class="pta-sus error">' . esc_html($this->main_options['login_required_message']) . '</p>';
  197.                     return $message;
  198.                 }
  199.             }
  200.             extract( shortcode_atts( array(
  201.                 'id' => false,
  202.                 'date' => false,
  203.                 'list_title' => __('Current Volunteer Sign-up Sheets', 'pta_volunteer_sus'),
  204.             ), $atts, 'pta_sign_up_sheet' ) );
  205.    
  206.             // Allow plugins or themes to modify shortcode parameters
  207.             $id = apply_filters( 'pta_sus_shortcode_id', $id );
  208.             if('' == $id) $id = false;
  209.             $date = apply_filters( 'pta_sus_shortcode_date', $date );
  210.             if('' == $date) $date = false;
  211.             if('' == $list_title) $list_title = __('Current Volunteer Sign-up Sheets', 'pta_volunteer_sus');
  212.             $list_title = apply_filters( 'pta_sus_shortcode_list_title', $list_title );
  213.    
  214.            
  215.             if ($id === false && !empty($_GET['sheet_id'])) $id = (int)$_GET['sheet_id'];
  216.    
  217.             if ($date === false && !empty($_GET['date'])) {
  218.                 // Make sure it's a valid date in our format first - Security check
  219.                 if ($this->data->check_date($_GET['date'])) {
  220.                     $date = $_GET['date'];
  221.                 }
  222.             }
  223.    
  224.             $return = apply_filters( 'pta_sus_before_display_sheets', $return, $id, $date );
  225.             do_action( 'pta_sus_begin_display_sheets', $id, $date );
  226.            
  227.             if ($id === false) {
  228.                 $show_hidden = false;
  229.                 $hidden = '';
  230.                 // Allow admin or volunteer managers to view hidden sign up sheets
  231.                 if (current_user_can( 'manage_options' ) || current_user_can( 'manage_signup_sheets' )) {
  232.                     $show_hidden = true;
  233.                     $hidden = '<br/><span class="pta-sus-hidden">'.apply_filters( 'pta_sus_public_output', '(--'.__('Hidden!', 'pta_volunteer_sus').'--)', 'hidden_notice' ).'</span>';
  234.                 }
  235.                
  236.                 // Display all active
  237.                 $return .= '<h2 class="pta-sus-list-title">'.apply_filters( 'pta_sus_public_output', esc_html($list_title), 'sheet_list_title' ).'</h2>';
  238.                 $sheets = $this->data->get_sheets(false, true, $show_hidden);
  239.                 $sheets = array_reverse($sheets);
  240.    
  241.                 // Move ongoing sheets to bottom of list if that setting is checked
  242.                 if ($this->main_options['show_ongoing_last']) {
  243.                     // Move ongoing events to end of our sheets array
  244.                     foreach ($sheets as $key => $sheet) {
  245.                         if ('Ongoing' == $sheet->type) {
  246.                             $move_me = $sheet;
  247.                             unset($sheets[$key]);
  248.                             $sheets[] = $move_me;
  249.                         }
  250.                     }
  251.                 }
  252.    
  253.                 // Allow plugins or themes to modify retrieved sheets
  254.                 $sheets = apply_filters( 'pta_sus_display_active_sheets', $sheets, $atts );
  255.    
  256.                 if (empty($sheets)) {
  257.                     $return .= '<p>'.apply_filters( 'pta_sus_public_output', __('No sheets currently available at this time.', 'pta_volunteer_sus'), 'no_sheets_message' ).'</p>';
  258.                 } else {
  259.                     $return .= apply_filters( 'pta_sus_before_sheet_list_table', '' );
  260.                     $return .= '<div class="pta-sus-sheets main">
  261.                        <table class="pta-sus-sheets" cellspacing="0">
  262.                            <thead>
  263.                                <tr>
  264.                                    <th class="column-title">'.esc_html( $title_header ).'</th>';
  265.                     $return .= apply_filters( 'pta_sus_sheet_list_table_header_after_title', '', $atts );
  266.                     $return .=     '<th class="column-date">'.esc_html( $start_date_header ).'</th>
  267.                                    <th class="column-date">'.esc_html( $end_date_header ).'</th>
  268.                                    <th class="column-open_spots">'.esc_html( $open_spots_header ).'</th>
  269.                                    <th class="column-view_link">&nbsp;</th>
  270.                                </tr>
  271.                            </thead>
  272.                            <tbody>
  273.                            ';
  274.                             foreach ($sheets AS $sheet) {
  275.                                 if ( 'Single' == $sheet->type ) {
  276.                                     // if a date was passed in, skip any sheets not on that date
  277.                                     if($date && $date != $sheet->first_date) continue;
  278.                                 } else {
  279.                                     // Recurring or Multi-day sheets
  280.                                     $dates = $this->data->get_all_task_dates($sheet->id);
  281.                                     if($date && !in_array($date, $dates)) continue;
  282.                                 }
  283.                                 if ( '1' == $sheet->visible) {
  284.                                     $is_hidden = '';
  285.                                 } else {
  286.                                     $is_hidden = $hidden;
  287.                                 }
  288.                                 $open_spots = ($this->data->get_sheet_total_spots($sheet->id) - $this->data->get_sheet_signup_count($sheet->id));
  289.                                 $sheet_args = array('sheet_id' => $sheet->id, 'date' => false, 'signup_id' => false, 'task_id' => false);
  290.                                 $sheet_url = apply_filters('pta_sus_view_sheet_url', add_query_arg($sheet_args), $sheet);
  291.                                 $ongoing_label = apply_filters( 'pta_sus_public_output', __('Ongoing', 'pta_volunteer_sus'), 'ongoing_event_type_start_end_label' );
  292.                                 $view_signup_text = apply_filters( 'pta_sus_public_output', __('View &amp; sign-up', 'pta_volunteer_sus'), 'view_and_signup_link_text' );
  293.                                 $sheet_filled_text = apply_filters( 'pta_sus_public_output', __('Filled', 'pta_volunteer_sus'), 'sheet_filled_text' );
  294.                                 $return .= '
  295.                                    <tr'.(($open_spots === 0) ? ' class="filled"' : '').'>
  296.                                        <td class="column-title"><a href="'.esc_url($sheet_url).'">'.esc_html($sheet->title).'</a>'.$is_hidden.'</td>';
  297.                                 $return .= apply_filters( 'pta_sus_sheet_list_table_content_after_title', '', $sheet, $atts );
  298.                                 $return .= '<td class="column-date">'.(($sheet->first_date == '0000-00-00') ? esc_html( $ongoing_label ) : date_i18n(get_option('date_format'), strtotime($sheet->first_date))).'</td>
  299.                                        <td class="column-date">'.(($sheet->last_date == '0000-00-00') ? esc_html( $ongoing_label ) : date_i18n(get_option('date_format'), strtotime($sheet->last_date))).'</td>
  300.                                        <td class="column-open_spots">'.(int)$open_spots.'</td>
  301.                                        <td class="column-view_link">'.(($open_spots > 0) ? '<a href="'.esc_url($sheet_url).'">'.esc_html( $view_signup_text ).' &raquo;</a>' : '&#10004; '.esc_html( $sheet_filled_text )).'</td>
  302.                                    </tr>
  303.                                ';                          
  304.                             }
  305.                             $return .= '
  306.                            </tbody>
  307.                        </table>
  308.                        </div>
  309.                    ';
  310.                     $return .= apply_filters( 'pta_sus_after_sheet_list_table', '' );
  311.                 }
  312.                
  313.                 // If current user has signed up for anything, list their signups and allow them to edit/clear them
  314.                 // If they aren't logged in, prompt them to login to see their signup info
  315.                 if ( !is_user_logged_in() ) {
  316.                     if (!$this->main_options['disable_signup_login_notice']) {
  317.                         $return .= '<p>'. apply_filters( 'pta_sus_public_output', __('Please login to view and edit your volunteer sign ups.', 'pta_volunteer_sus'), 'user_not_loggedin_signups_list_message' ).'</p>';
  318.                     }
  319.                 } else {
  320.                     $current_user = wp_get_current_user();
  321.                     if ( !($current_user instanceof WP_User) )
  322.                     return;
  323.    
  324.                     // Check if they clicked on a CLEAR link
  325.                     // Perhaps add some sort of confirmation, maybe with jQuery?
  326.                     if (isset($_GET['signup_id'])) {
  327.                         // Make sure the signup exists first
  328.                         if (null == $this->data->get_signup((int)$_GET['signup_id'])) {
  329.                             $return .= '<p class="pta-sus error">'.apply_filters( 'pta_sus_public_output', __('Not a valid signup!', 'pta_volunteer_sus'), 'clear_invalid_signup_error_message' ).'</p>';
  330.                         } else {
  331.                             // Send cleared emails
  332.                             if(!class_exists('PTA_SUS_Emails')) {
  333.                                 include_once(dirname(__FILE__).'/class-pta_sus_emails.php');
  334.                             }
  335.                             $emails = new PTA_SUS_Emails();
  336.                             $emails->send_mail((int)$_GET['signup_id'], $reminder=false, $clear=true);
  337.                             $cleared = $this->data->delete_signup((int)$_GET['signup_id']);
  338.                             if ($cleared) {
  339.                                 $return .= '<p class="pta-sus updated">'.apply_filters( 'pta_sus_public_output', __('Signup Cleared', 'pta_volunteer_sus'), 'signup_cleared_message' ).'</p>';
  340.                             } else {
  341.                                 $return .= '<p class="pta-sus error">'.apply_filters( 'pta_sus_public_output', __('ERROR clearing signup!', 'pta_volunteer_sus'), 'error_clearing_signup_message' ).'</p>';
  342.                             }
  343.                         }
  344.                     }
  345.    
  346.                     $signups = apply_filters( 'pta_sus_user_signups', $this->data->get_user_signups($current_user->ID) );
  347.                     if ($signups) {
  348.                         $return .= apply_filters( 'pta_sus_before_user_signups_list_headers', '' );
  349.                         $return .= '<h3>'.apply_filters( 'pta_sus_public_output', __('You have signed up for the following', 'pta_volunteer_sus'), 'user_signups_list_headers_h3' ).'</h3>';
  350.                         $return .= '<h4>'.apply_filters( 'pta_sus_public_output', __('Click on Clear to remove yourself from a signup.', 'pta_volunteer_sus'), 'user_signups_list_headers_h4' ).'</h4>';
  351.                         $return .= apply_filters( 'pta_sus_before_user_signups_list_table', '' );
  352.                         $return .= '<div class="pta-sus-sheets user">
  353.                            <table class="pta-sus-sheets" cellspacing="0">
  354.                            <thead>
  355.                                <tr>
  356.                                    <th class="column-title">'.esc_html($title_header).'</th>
  357.                                    <th class="column-date">'.esc_html($date_header).'</th>
  358.                                    <th class="column-task">'.esc_html($this->task_item_header).'</th>
  359.                                    <th class="column-time" style="text-align:right;">'.esc_html($this->start_time_header).'</th>
  360.                                    <th class="column-time" style="text-align:right;">'.esc_html($this->end_time_header).'</th>
  361.                                    <th class="column-details" style="text-align:center;">'.esc_html($this->item_details_header).'</th>
  362.                                    <th class="column-qty" style="text-align:center;">'.esc_html($this->item_qty_header).'</th>
  363.                                    <th class="column-clear_link">&nbsp;</th>
  364.                                </tr>
  365.                            </thead>
  366.                            <tbody>';
  367.                         foreach ($signups as $signup) {
  368.                                
  369.                             if ( true == $signup->clear && ( 0 == $signup->clear_days || $signup->signup_date == "0000-00-00"
  370.                                 || ( strtotime( $signup->signup_date ) - current_time( 'timestamp' ) > ((int)$signup->clear_days * 60 * 60 * 24) ) ) ) {
  371.                                 $clear_args = array('sheet_id' => false, 'task_id' => false, 'signup_id' => (int)$signup->id);
  372.                                 $clear_url = add_query_arg($clear_args);
  373.                                 $clear_text = apply_filters( 'pta_sus_public_output', __('Clear', 'pta_volunteer_sus'), 'clear_signup_link_text');
  374.                             } else {
  375.                                 $clear_url = '';
  376.                                 $clear_text = '';
  377.                             }
  378.                            
  379.                             $return .= '<tr>
  380.                                <td>'.esc_html($signup->title).'</td>
  381.                                <td>'.(($signup->signup_date == "0000-00-00") ? esc_html($this->na_text) : date_i18n(get_option("date_format"), strtotime($signup->signup_date))).'</td>
  382.                                <td>'.esc_html($signup->task_title).'</td>
  383.                                <td style="text-align:right;">'.(("" == $signup->time_start) ? esc_html($this->na_text) : date_i18n(get_option("time_format"), strtotime($signup->time_start)) ).'</td>
  384.                                <td style="text-align:right;">'.(("" == $signup->time_end) ? esc_html($this->na_text) : date_i18n(get_option("time_format"), strtotime($signup->time_end)) ).'</td>
  385.                                <td style="text-align:center;">'.((" " !== $signup->item) ? esc_html($signup->item) : esc_html($this->na_text) ).'</td>
  386.                                <td style="text-align:center;">'.(("" !== $signup->item_qty) ? (int)$signup->item_qty : esc_html($this->na_text) ).'</td>
  387.                                <td style="text-align:right;"><a href="'.esc_url($clear_url).'">'.esc_html($clear_text).'</a></td>
  388.                            </tr>';
  389.                         }
  390.                         $return .= '</tbody></table></div>';
  391.                         $return .= apply_filters( 'pta_sus_after_user_signups_list_table', '' );
  392.                     }
  393.                 }
  394.    
  395.             } else {
  396.                 $return .= $this->messages;
  397.                 // Display Individual Sheet
  398.                 $sheet = apply_filters( 'pta_sus_display_individual_sheet', $this->data->get_sheet($id), $id );
  399.                 if ($sheet === false) {
  400.                     $return .= '<p class="pta-sus error">'.apply_filters( 'pta_sus_public_output', __("Sign-up sheet not found.", 'pta_volunteer_sus'), 'sheet_not_found_error_message' ).'</p>';
  401.                     return $return;
  402.                 } else {
  403.                     // Check is the sheet is visible and don't show unless it's an admin user
  404.                     if ( false == $sheet->visible && !current_user_can( 'manage_signup_sheets' ) ) return;
  405.                     // Allow extensions to choose if they want to show header info if not on the main volunteer page
  406.                     $show_headers = apply_filters( 'pta_sus_show_sheet_headers', $show = false, $sheet );
  407.                     $return .= apply_filters( 'pta_sus_before_display_single_sheet', '', $sheet );
  408.                     // *****************************************************************************
  409.                     // If it's not the main
  410.                     // volunteer page, then change the header info -- don't show "view all..." and
  411.                     // don't show title and chair... instead just make a simple heading
  412.                     if ( is_page( $this->main_options['volunteer_page_id'] ) || $show_headers ) {
  413.                         // TODO
  414.                         // USE THE ANTISPAMBOT WP FEATURE TO OBFUSCATE THE EMAIL ADDRESSES AND EITHER PUT THEM BACK TOGETHER
  415.                         // SEPARATED BY COMMAS, OR USE A BCC FOR OTHER EMAIL ADDRESSES AFTER THE FIRST
  416.                         //
  417.                         // AFTER MAKING PTA MEMBER DIRECTORY A CLASS, WE CAN ALSO CHECK IF IT EXISTS
  418.                         if( isset($this->integration_options['enable_member_directory']) && true === $this->integration_options['enable_member_directory'] && function_exists('pta_member_directory_init') && '' != $sheet->position ) {
  419.                             // Create Contact Form link
  420.                             if($position = get_term_by( 'slug', $sheet->position, 'member_category' )) {
  421.                                 if ( isset($this->integration_options['contact_page_id']) && 0 < $this->integration_options['contact_page_id']) {              
  422.                                     $contact_url = get_permalink( $this->integration_options['contact_page_id'] ) . '?id=' . esc_html($sheet->position);
  423.                                     $display_chair = esc_html($contact_label) . ' <a href="' . esc_url($contact_url) .'">'. esc_html($position->name) .'</a>';
  424.                                 } elseif ( isset($this->integration_options['directory_page_id']) && 0 < $this->integration_options['directory_page_id']) {              
  425.                                     $contact_url = get_permalink( $this->integration_options['directory_page_id'] ) . '?id=' . $sheet->position;
  426.                                     $display_chair = esc_html($contact_label)  . ' <a href="' . esc_url($contact_url) .'">'. esc_html($position->name) .'</a>';
  427.                                 } else {
  428.                                     $display_chair = esc_html( $no_contact_message );
  429.                                 }
  430.                             } else {
  431.                                 $display_chair = esc_html( $no_contact_message );
  432.                             }
  433.                            
  434.                         } else {
  435.                             $chair_names = $this->data->get_chair_names_html($sheet->chair_name);
  436.                             // Check if there is more than one chair name to display either Chair or Chairs
  437.                             $names = str_getcsv($sheet->chair_name);
  438.                             $count = count($names);
  439.                             if ( $count > 1) {
  440.                                 $display_chair = apply_filters( 'pta_sus_public_output', __('Event Chairs:', 'pta_volunteer_sus'), 'event_chairs_label_plural') .' <a href="mailto:'.esc_attr($sheet->chair_email).'">'.esc_html($chair_names).'</a>';
  441.                             } elseif ( 1 == $count && '' != $sheet->chair_name && '' != $sheet->chair_email ) {
  442.                                 $display_chair = apply_filters( 'pta_sus_public_output', __('Event Chair:', 'pta_volunteer_sus'), 'event_chair_label_singular') .' <a href="mailto:'.esc_attr($sheet->chair_email).'">'.esc_html($chair_names).'</a>';
  443.                             } else {
  444.                                 $display_chair = esc_html( $no_contact_message );
  445.                             }
  446.                         }
  447.    
  448.                         $display_chair = apply_filters( 'pta_sus_display_chair_contact', $display_chair, $sheet );
  449.                         $view_all_text = apply_filters('pta_sus_public_output', __('View all Sign-up Sheets', 'pta_volunteer_sus'), 'view_all_sheets_link_text');
  450.                         $return .= '
  451.                            <p><a href="'.esc_url($this->all_sheets_uri).'">&laquo; '.esc_html( $view_all_text ).'</a></p>
  452.                            <div class="pta-sus-sheet">
  453.                                <h2>'.esc_html($sheet->title).'</h2>
  454.                        ';
  455.                         if ( false == $this->main_options['hide_contact_info'] ) {
  456.                             $return .= '<h2>'.$display_chair.'</h2>';
  457.                         }
  458.                     } else {
  459.                         $return .= '<div class="pta-sus-sheet">';
  460.                     }
  461.                     if ( false == $sheet->visible && current_user_can( 'manage_signup_sheets' ) ) {
  462.                         $return .= '<p class="pta-sus-hidden">'.apply_filters( 'pta_sus_public_output', __('This sheet is currently hidden from the public.', 'pta_volunteer_sus'), 'sheet_hidden_message' ).'</p>';
  463.                     }
  464.                    
  465.                     // Display Sign-up Form
  466.        if (!$this->submitted || $this->err) {
  467.        if (isset($_GET['task_id']) && $date) {
  468.                             do_action('pta_sus_before_display_signup_form', $_GET['task_id'], $date );
  469.        return $this->errors . $this->display_signup_form($_GET['task_id'], $date);
  470.        }
  471.        }
  472.        
  473.        // Sheet Details
  474.                     // Need to escape/sanitize all output to screen
  475.        if (!$this->submitted || $this->success || $this->err) {
  476.                         $future_dates = false;
  477.                         $task_dates = $this->data->get_all_task_dates($sheet->id);
  478.                         foreach ($task_dates as $tdate) {
  479.                             if($tdate >= date('Y-m-d') || "0000-00-00" == $tdate) {
  480.                                 $future_dates = true;
  481.                                 break;
  482.                             }
  483.                         }
  484.                        
  485.                         // Make sure there are some future dates before showing anything
  486.                         if($future_dates) {
  487.                             // Only show details if there is something to show
  488.                             if('' != $sheet->details) {
  489.                                 $return .= '<h3>'.apply_filters( 'pta_sus_public_output', __('DETAILS:', 'pta_volunteer_sus'), 'sheet_details_heading' ).'</h3>';
  490.                                 $return .= wp_kses_post($sheet->details);
  491.                             }
  492.                             $open_spots = ($this->data->get_sheet_total_spots($sheet->id) - $this->data->get_sheet_signup_count($sheet->id));
  493.                             if ($open_spots > 0) {
  494.                                 $return .= '<h3>'.apply_filters( 'pta_sus_public_output', __('Sign up below...', 'pta_volunteer_sus'), 'sign_up_below' ).'</h3>';              
  495.                             } else {
  496.                                 $return .= '<h3>'.apply_filters( 'pta_sus_public_output', __('All spots have been filled.', 'pta_volunteer_sus'), 'sheet_all_spots_filled' ).'</h3>';
  497.                             }
  498.                            
  499.                             $task_dates = apply_filters( 'pta_sus_sheet_task_dates', $task_dates, $sheet->id );
  500.                             foreach ($task_dates as $tdate) {
  501.                                 if( "0000-00-00" != $tdate && $tdate < date('Y-m-d')) continue; // Skip dates that have passed already
  502.                                 if( "0000-00-00" != $tdate ) {
  503.                                     $return .= '<h4><strong>'.mysql2date( get_option('date_format'), $tdate, $translate = true ).'</strong></h4>';
  504.                                 }                          
  505.                                 $return .= $this->display_task_list($sheet->id, $tdate);
  506.                             }
  507.                         }
  508.    
  509.                         $return .= '</div>';
  510.                }
  511.                 }
  512.             }
  513.             $return .= apply_filters( 'pta_sus_after_display_sheets', '', $id, $date );
  514.             return $return;
  515.         } // Display Sheet
  516.    
  517.         public function display_task_list($sheet_id, $date) {
  518.             // Tasks
  519.             $return = '';
  520.             if (!($tasks = apply_filters('pta_sus_public_sheet_get_tasks', $this->data->get_tasks($sheet_id, $date), $sheet_id, $date) ) ) {
  521.                 $return .= '<p>'.apply_filters( 'pta_sus_public_output', __('No tasks were found for ', 'pta_volunteer_sus'), 'no_tasks_found_for_date' ) . mysql2date( get_option('date_format'), $tdate, $translate = true ).'</p>';
  522.             } else {
  523.                 $show_details = false;
  524.                 $show_qty = false;
  525.                 foreach ($tasks as $task) {
  526.                     if ( 'YES' == $task->need_details ) {
  527.                         $show_details = true;
  528.                     }
  529.                     if ( 'YES' == $task->enable_quantities ) {
  530.                         $show_qty = true;
  531.                     }
  532.                 }
  533.                 $return .= apply_filters( 'pta_sus_before_task_list', '', $tasks );
  534.                 $return .= '<div class="pta-sus-sheets tasks">
  535.                    <table class="pta-sus-tasks" cellspacing="0">
  536.                        <thead>
  537.                            <tr>
  538.                                <th>'.esc_html($this->task_item_header).'</th>
  539.                                <th>'.esc_html($this->start_time_header).'</th>
  540.                                <th>'.esc_html($this->end_time_header).'</th>
  541.                                <th>'.esc_html( apply_filters( 'pta_sus_public_output', __('Available Spots', 'pta_volunteer_sus'), 'task_available_spots_header' ) ).'</th>';
  542.                 if ($show_details) {
  543.                     $return .= '<th>'.esc_html($this->item_details_header).'</th>';
  544.                 }
  545.                 if ($show_qty) {
  546.                     $return .= '<th>'.esc_html($this->item_qty_header).'</th>';
  547.                 }
  548.                 $return .= '                
  549.                            </tr>
  550.                        </thead>
  551.                        <tbody>
  552.                        ';
  553.                         foreach ($tasks AS $task) {
  554.                             $task_dates = explode(',', $task->dates);
  555.                             // Don't show tasks that don't include our date, if one was passed in
  556.                             if ($date && !in_array($date, $task_dates)) continue;
  557.    
  558.                             $task_args = array('sheet_id' => $sheet_id, 'task_id' => $task->id, 'date' => $date, 'signup_id' => false);
  559.                             if (is_page($this->main_options['volunteer_page_id'])) {        
  560.                                 $task_url = add_query_arg($task_args);
  561.                             } else {
  562.                                 $task_query = http_build_query($task_args);
  563.                                 $task_url = get_permalink( $this->main_options['volunteer_page_id'] ) . '?' . $task_query;
  564.                             }
  565.                             $task_url = apply_filters( 'pta_sus_task_signup_url', $task_url, $task, $sheet_id, $date );
  566.                            
  567.                             $i=1;
  568.                             $signups = apply_filters( 'pta_sus_task_get_signups', $this->data->get_signups($task->id, $date), $task->id, $date);
  569.                            
  570.                             foreach ($signups AS $signup) {
  571.                                 if ($i == $task->qty) {
  572.                                     $return .= '<tr class="pta-sus-tasks-bb">';
  573.                                 } else {
  574.                                     $return .= '<tr>';
  575.                                 }
  576.                                 if (1 == $i) {
  577.                                     $return .= '
  578.                                    <td>'.esc_html($task->title).'</td>
  579.                                    <td>'.(("" == $task->time_start) ? esc_html($this->na_text) : date_i18n(get_option("time_format"), strtotime($task->time_start)) ).'</td>
  580.                                    <td>'.(("" == $task->time_end) ? esc_html($this->na_text) : date_i18n(get_option("time_format"), strtotime($task->time_end)) ).'</td>';
  581.                                 } else {
  582.                                     $return .= '
  583.                                    <td></td>
  584.                                    <td></td>
  585.                                    <td></td>';
  586.                                 }
  587.                                 if($this->main_options['hide_volunteer_names']) {
  588.                                     $display_signup = apply_filters( 'pta_sus_public_output', __('Filled', 'pta_volunteer_sus'), 'task_spot_filled_message' );
  589.                                 } else {
  590.                                     $display_signup = esc_html($signup->firstname).' '.esc_html(substr($signup->lastname, 0, 1)) . '.';
  591.                                 }
  592.                                 // hook to allow others to modify how the signed up names are displayed
  593.                                 $display_signup = apply_filters( 'pta_sus_display_signup_name', $display_signup, $signup );
  594.                                 $return .= '<td class="pta-sus-em">#'.$i.': '.$display_signup.'</td>';
  595.                                 if ($show_details) {
  596.                                         $return .= '<td class="pta-sus-em">'.esc_html($signup->item).'</td>';
  597.                                 }
  598.                                 if ($show_qty) {
  599.                                         $return .= '<td>'.("YES" === $task->enable_quantities ? (int)($signup->item_qty) : "").'</td>';
  600.                                 }
  601.                                 if ('YES' === $task->enable_quantities) {
  602.                                     $i += $signup->item_qty;
  603.                                 } else {
  604.                                     $i++;
  605.                                 }                          
  606.                                 $return .= '</tr>';
  607.                             }
  608.                             for ($i=$i; $i<=$task->qty; $i++) {
  609.                                 if ($i == $task->qty) {
  610.                                     $return .= '<tr class="pta-sus-tasks-bb">';
  611.                                 } else {
  612.                                     $return .= '<tr>';
  613.                                 }
  614.                                 if (1 == $i) {
  615.                                     $return .= '
  616.                                    <td>'.esc_html($task->title).'</td>
  617.                                    <td>'.(("" == $task->time_start) ? esc_html($this->na_text) : date_i18n(get_option("time_format"), strtotime($task->time_start)) ).'</td>
  618.                                    <td>'.(("" == $task->time_end) ? esc_html($this->na_text) : date_i18n(get_option("time_format"), strtotime($task->time_end)) ).'</td>';
  619.                                 } else {
  620.                                     $return .= '
  621.                                    <td></td>
  622.                                    <td></td>
  623.                                    <td></td>';
  624.                                 }
  625.                                 $return .= '<td>#'.$i.': <a href="'.esc_url($task_url).'">'.apply_filters( 'pta_sus_public_output', __('Sign up ', 'pta_volunteer_sus'), 'task_sign_up_link_text' ) . '&raquo;</a></td>';
  626.                                 if($show_details) {
  627.                                 $return .= '<td></td>';
  628.                                 }
  629.                                 if($show_qty) {
  630.                                     $return .= '<td></td>';
  631.                                 }
  632.                             $return .= '</tr>';
  633.                             }
  634.                         }
  635.                         $return .= '
  636.                        </tbody>
  637.                    </table></div>';
  638.                 $return .= apply_filters( 'pta_sus_after_task_list', '', $tasks );
  639.                 return $return;
  640.             }
  641.         } // Display task list
  642.    
  643.     public function display_signup_form($task_id, $date) {
  644.             $task = apply_filters( 'pta_sus_public_signup_get_task', $this->data->get_task($task_id), $task_id);
  645.             do_action( 'pta_sus_before_signup_form', $task, $date );
  646.             if ("0000-00-00" == $date) {
  647.                 $show_date = false;
  648.             } else {
  649.                 $show_date = date_i18n(get_option('date_format'), strtotime($date));
  650.             }
  651.             $form = '<div class="pta-sus-sheets signup-form">';
  652.             $form .= apply_filters( 'pta_sus_signup_page_before_form_title', '', $task, $date );
  653.             $form .= '<h3>'.apply_filters( 'pta_sus_public_output', __('Sign Up', 'pta_volunteer_sus'), 'sign_up_form_heading' ).'</h3>';
  654.             $form .= '<h4>'. apply_filters( 'pta_sus_public_output', __('You are signing up for... ', 'pta_volunteer_sus'), 'you_are_signing_up_for' ).'<br/><strong>'.esc_html($task->title).'</strong> ';
  655.             if ($show_date) {
  656.                 $form .= sprintf(__('on %s', 'pta_volunteer_sus'), $show_date);
  657.             }
  658.             $form .= '</h4>';
  659.             if ('' != $task->time_start) {
  660.                 $form .= '<span class="time_start">'.esc_html($this->start_time_header) . ': '. date_i18n(get_option("time_format"), strtotime($task->time_start)) . '</span><br/>';
  661.             }
  662.             if ('' != $task->time_end) {
  663.                 $form .= '<span class="time_end">'.esc_html($this->end_time_header) . ': '. date_i18n(get_option("time_format"), strtotime($task->time_end)) . '</span><br/>';
  664.             }
  665.             $firstname_label = apply_filters( 'pta_sus_public_output', __('First Name', 'pta_volunteer_sus'), 'firstname_label' );
  666.             $lastname_label = apply_filters( 'pta_sus_public_output', __('Last Name', 'pta_volunteer_sus'), 'lastname_label' );
  667.             $email_label = apply_filters( 'pta_sus_public_output', __('E-mail', 'pta_volunteer_sus'), 'email_label' );
  668.             $phone_label = apply_filters( 'pta_sus_public_output', __('Phone', 'pta_volunteer_sus'), 'phone_label' );
  669.    
  670.             $form .= apply_filters( 'pta_sus_signup_form_before_form_fields', '<br/>', $task, $date );
  671.             if ( is_user_logged_in() ) {
  672.                 $current_user = wp_get_current_user();
  673.                 if ( !($current_user instanceof WP_User) )
  674.                 return;          
  675.                 // Prefill user data if they are signed in
  676.                 $form .= '
  677.    <form name="pta_sus_signup_form" method="post" action="">
  678.                    <input type="hidden" name="signup_user_id" value="'.$current_user->ID.'" />
  679.    <p>
  680.    <label for="signup_firstname">'.$firstname_label.'</label>
  681.    <input type="text" id="signup_firstname" name="signup_firstname" value="'. esc_attr($current_user->user_firstname) .'" />
  682.    </p>
  683.    <p>
  684.    <label for="signup_lastname">'.$lastname_label.'</label>
  685.    <input type="text" id="signup_lastname" name="signup_lastname" value="'. esc_attr($current_user->user_lastname) .'" />
  686.    </p>
  687.    <p>
  688.    <label for="signup_email">'.$email_label.'</label>
  689.    <input type="text" id="signup_email" name="signup_email" value="'. esc_attr($current_user->user_email) .'" />
  690.    </p>';
  691.                 if( false == $this->main_options['no_phone'] ) {
  692.                     // Using Woocommerce to handle site registrations stores a "billing_phone" user meta field
  693.                     // since we set single to "true", this will return an empty string if the field doesn't exist
  694.                     $phone = apply_filters('pta_sus_user_phone', get_user_meta( $current_user->ID, 'billing_phone', true ), $current_user );
  695.                     $form .= '
  696.                    <p>
  697.                        <label for="signup_phone">'.$phone_label.'</label>
  698.                        <input type="text" id="signup_phone" name="signup_phone" value="'. esc_attr($phone).'" />
  699.                    </p>';
  700.                 }
  701.             } else {
  702.             // If not signed in, get the user data
  703.                 if (false == $this->main_options['disable_signup_login_notice']) {
  704.                     $form .= '<p>'.apply_filters( 'pta_sus_public_output', __('If you have an account, it is strongly recommended that you <strong>login before you sign up</strong> so that you can view and edit all your signups.', 'pta_volunteer_sus'), 'signup_login_notice' ).'</p>';
  705.                 }
  706.                 $form .= '
  707.    <form name="pta_sus_signup_form" method="post" action="">
  708.    <p>
  709.    <label for="signup_firstname">'.$firstname_label.'</label>
  710.    <input type="text" id="signup_firstname" name="signup_firstname" value="'.((isset($_POST['signup_firstname'])) ? esc_attr($_POST['signup_firstname']) : '').'" />
  711.    </p>
  712.    <p>
  713.    <label for="signup_lastname">'.$lastname_label.'</label>
  714.    <input type="text" id="signup_lastname" name="signup_lastname" value="'.((isset($_POST['signup_lastname'])) ? esc_attr($_POST['signup_lastname']) : '').'" />
  715.    </p>
  716.    <p>
  717.    <label for="signup_email">'.$email_label.'</label>
  718.    <input type="text" id="signup_email" name="signup_email" value="'.((isset($_POST['signup_email'])) ? esc_attr($_POST['signup_email']) : '').'" />
  719.    </p>';
  720.                 if( false == $this->main_options['no_phone'] ) {
  721.                     $form .= '
  722.                    <p>
  723.                        <label for="signup_phone">'.$phone_label.'</label>
  724.                        <input type="text" id="signup_phone" name="signup_phone" value="'.((isset($_POST['signup_phone'])) ? esc_attr($_POST['signup_phone']) : '').'" />
  725.                    </p>';
  726.                 }
  727.             }
  728.    
  729.             $form .= apply_filters( 'pta_sus_signup_form_before_details_field', '', $task, $date );
  730.    
  731.             // Get the remaining fields, whether or not they are signed in
  732.    
  733.             // If details are needed for the task, show the field to fill in details.
  734.             // Otherwise don't show the field, but fill it with a blank space
  735.             if ($task->need_details == "YES") {
  736.                 $form .= '
  737.                <p>
  738.       <label for="signup_item">'.esc_html($task->details_text).'</label>
  739.       <input type="text" id="signup_item" name="signup_item" value="'.((isset($_POST['signup_item'])) ? esc_attr($_POST['signup_item']) : '').'" />
  740.                    <input type="hidden" name="need_details" value="YES" />
  741.       </p>';
  742.             } else {
  743.                 $form .= '<input type="hidden" name="signup_item" value=" " />
  744.                <input type="hidden" name="need_details" value="NO" />';
  745.             }
  746.             if ($task->enable_quantities == "YES") {
  747.                 $form .= '<p>';
  748.                 $available = $this->data->get_available_qty($task_id, $date, $task->qty);
  749.                 if ($available > 1) {
  750.                     $form .= '<label for="signup_item_qty">'.esc_html( apply_filters( 'pta_sus_public_output', sprintf(__('Item QTY (1 - %d): ', 'pta_volunteer_sus'), (int)$available), 'item_quantity_input_label', (int)$available ) ).'</label>
  751.                    <input type="text" id="signup_item_qty" name="signup_item_qty" value="'.((isset($_POST['signup_item_qty'])) ? (int)($_POST['signup_item_qty']) : '').'" />';
  752.                 } elseif ( 1 == $available) {
  753.                     $form .= '<strong>'.apply_filters( 'pta_sus_public_output', __('Only 1 remaining! Your quantity will be set to 1.', 'pta_volunteer_sus'), 'only_1_remaining' ).'</strong>';
  754.                     $form .= '<input type="hidden" name="signup_item_qty" value="1" />';
  755.                 }
  756.                 $form .= '<input type="hidden" name="enable_quantities" value="YES" />
  757.                        <input type="hidden" name="available_qty" value="'.esc_attr($available).'" />
  758.                </p>';
  759.             } else {
  760.                 $form .= '<input type="hidden" name="signup_item_qty" value="1" />
  761.                <input type="hidden" name="enable_quantities" value="NO" />';
  762.             }
  763.    
  764.             $form .= apply_filters( 'pta_sus_signup_form_after_details_field', '', $task, $date );
  765.    
  766.             // Spam check and form submission
  767.             $go_back_args = array('task_id' => false, 'date' => $date, 'sheet_id' => $_GET['sheet_id']);
  768.             $go_back_url = apply_filters( 'pta_sus_signup_goback_url', add_query_arg($go_back_args) );
  769.             $form .= '
  770.    <div style="visibility:hidden">
  771.               <input name="website" type="text" size="20" />
  772.           </div>
  773.           <p class="submit">
  774.               <input type="hidden" name="signup_date" value="'.esc_attr($date).'" />
  775.                    <input type="hidden" name="allow_duplicates" value="'.$task->allow_duplicates.'" />
  776.               <input type="hidden" name="signup_task_id" value="'.esc_attr($_GET['task_id']).'" />
  777.             <input type="hidden" name="pta_sus_form_mode" value="submitted" />
  778.             <input type="submit" name="Submit" class="button-primary" value="'.esc_attr( apply_filters( 'pta_sus_public_output', __('Sign me up!', 'pta_volunteer_sus'), 'signup_button_text' ) ).'" />
  779.               <a href="'.esc_url($go_back_url).'">'.esc_html( apply_filters( 'pta_sus_public_output', __('&laquo; go back to the Sign-Up Sheet', 'pta_volunteer_sus'), 'go_back_to_signup_sheet_text' ) ).'</a>
  780.           </p>
  781.                ' . wp_nonce_field('pta_sus_signup','pta_sus_signup_nonce') . '
  782.    </form>
  783.    ';
  784.             $form .= '</div>';
  785.             return $form;      
  786.     } // Display Sign up form
  787.    
  788.     /**
  789.         * Enqueue plugin css and js files
  790.         */
  791.         public function add_css_and_js_to_frontend() {
  792.             wp_register_style('pta-sus-style', plugins_url('../assets/css/style.css', __FILE__));
  793.             wp_enqueue_style('pta-sus-style');
  794.         }
  795.    
  796.     } // End of class
  797.     /* EOF */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement