<?php /*-----------------------------------------------------------------------*/ // Match Custom Post /*-----------------------------------------------------------------------*/ $match = PostType::make('slhb_match', 'Les matchs', 'match')->set(array('public' => true, 'menu_position' => 20, 'supports' => false, 'rewrite' => false, 'query_var' => false, 'labels' => ['add_new' => 'Ajouter un nouveau match', 'add_item' => 'Ajouter un match', 'all_items' => 'Tous les matchs', 'edit_item' => 'Modifier un match'])); /*-----------------------------------------------------------------------*/ // Match informations /*-----------------------------------------------------------------------*/ $infos = Metabox::make('Informations du match', $match->get('name'))->set(array(Field::date('match_date', ['title' => 'Date du match']), Field::select('match_team_dom', TeamModel::getTeamsArray()), Field::text('match_team_ext', ['title' => 'Equipe à l\'exterieur']), Field::number('score_dom', ['title' => 'Score de l\'équipe à domicile']), Field::number('score_ext', ['title' => 'Score de l\'équipe extérieur']))); /*-----------------------------------------------------------------------*/ // Match Defaults Values /*-----------------------------------------------------------------------*/ function slhb_set_title($post_id, $post, $update) { $dateStr = Meta::get($post_id, 'match_date'); $title = $dateStr . ' - ' . Meta::get($post_id, 'match_team_dom') . ' - ' . Meta::get($post_id, 'match_team_ext'); $date = date($dateStr); //This temporarily removes filter to prevent infinite loops remove_action('save_post_slhb_match', __FUNCTION__); wp_update_post(array('ID' => $post_id, 'post_title' => $title, 'match_date' => $date)); //redo filter add_action('save_post_slhb_match', __FUNCTION__, 10, 3); } add_action('save_post_slhb_match', 'slhb_set_title', 10, 3);
/** * Set up timeslot custom post type * * @private */ private static function _set_up_timeslot() { PostType::make('timeslot', 'Time Slots', 'Time Slot')->set(); $fields = array(Field::select('timeslot_venue', array(array('none' => __('- None -')) + VenueModel::venueSelection()), array('title' => __('Venue'))), Field::select('timeslot_user', array(array('none' => __('- None -')) + UserModel::userSelection()), array('title' => __('User'))), Field::date('date', array('title' => 'Date')), Field::select('time_from', array(Config::get('application.timeslots')), array('title' => __('Start at'))), Field::select('time_to', array(Config::get('application.timeslots')), array('title' => __('Finish at')))); Metabox::make('Options', 'timeslot')->set($fields); }