public static function form_fields($project = 0, $required = false) { $fields = array(); $associated_client = $project ? $project->get_associated_clients() : array(0); $client_id = array_pop($associated_client); $fields['name'] = array('weight' => 1, 'label' => self::__('Project Name'), 'type' => 'text', 'required' => true, 'default' => $project ? $project->get_title() : ''); $client_options = array(); $client_options[0] = ''; $client_options += SI_Client::get_all_clients(); $description = $client_id ? sprintf(self::__('Edit <a href="%s">%s</a>, select another client or <a href="%s">create a new client</a>.'), get_edit_post_link($client_id), get_the_title($client_id), '#TB_inline?width=600&height=450&inlineId=client_creation_modal" id="client_creation_modal_link" class="thickbox') : sprintf(self::__('Select an existing client or <a href="%s">create a new client</a>.'), '#TB_inline?width=600&height=420&inlineId=client_creation_modal" id="client_creation_modal_link" class="thickbox'); $fields['client'] = array('weight' => 3, 'label' => self::__('Client'), 'type' => 'select', 'options' => $client_options, 'required' => true, 'default' => $client_id, 'attributes' => array('class' => 'select2'), 'description' => $description); $fields['start_date'] = array('weight' => 100, 'label' => self::__('Start Date'), 'type' => 'date', 'required' => $required, 'default' => $project && $project->get_start_date() ? date('Y-m-d', $project->get_start_date()) : '', 'placeholder' => ''); $fields['end_date'] = array('weight' => 100, 'label' => self::__('End Date'), 'type' => 'date', 'required' => $required, 'default' => $project && $project->get_end_date() ? date('Y-m-d', $project->get_end_date()) : '', 'placeholder' => ''); $fields['website'] = array('weight' => 120, 'label' => self::__('Website'), 'type' => 'text', 'required' => $required, 'default' => $project ? $project->get_website() : '', 'placeholder' => 'http://'); $fields['nonce'] = array('type' => 'hidden', 'value' => wp_create_nonce(self::SUBMISSION_NONCE), 'weight' => 10000); $fields = apply_filters('si_project_form_fields', $fields); uasort($fields, array(__CLASS__, 'sort_by_weight')); return $fields; }