Skip to content

Commit

Permalink
Gave Theatre admin menu it’s own icon.
Browse files Browse the repository at this point in the history
Events can be sold out.
Event can have custom text on tickets button.
  • Loading branch information
slimndap committed Jan 9, 2014
1 parent 8b51cd6 commit 3bff720
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 11 deletions.
49 changes: 42 additions & 7 deletions functions/wpt_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@ function admin_init() {
}

function admin_menu() {
add_menu_page( __('Theatre'), __('Theatre'), 'edit_posts', 'theatre', array($this, 'hallo'), '', 30);
add_menu_page( __('Theatre'), __('Theatre'), 'edit_posts', 'theatre', array(), 'dashicons-calendar', 30);
add_submenu_page( 'theatre', 'Theatre '.__('Settings'), __('Settings'), 'manage_options', 'theatre-admin', array( $this, 'admin_page' ));
}

function hallo() {
echo 'hallo';
}

function add_meta_boxes() {
add_meta_box(
'wp_theatre_events',
Expand Down Expand Up @@ -223,6 +219,42 @@ function meta_box_tickets($event) {
echo '</td>';
echo '</tr>';

echo '<tr>';
echo '<th><label>'.__('Status','wp_theatre').'</label></th>';
echo '<td>';

$status = get_post_meta($event->ID,'tickets_status',true);

echo '<label>';
echo '<input type="radio" name="tickets_status" value=""';
if ($status=='') {
echo ' checked="checked"';
}
echo '> ';
echo '<span>'.__('on sale','wp_theatre').'</span>';
echo '</label><br />';

echo '<label>';
echo '<input type="radio" name="tickets_status" value="soldout"';
if ($status=='soldout') {
echo ' checked="checked"';
}
echo '> ';
echo '<span>'.__('sold out','wp_theatre').'</span>';
echo '</label><br />';

echo '</td>';
echo '</tr>';

echo '<tr>';
echo '<th><label>'.__('Text on button','wp_theatre').'</label></th>';
echo '<td>';

echo '<input type="text" name="tickets_button"';
echo ' value="' . get_post_meta($event->ID,'tickets_button',true) . '" />';
echo '</td>';
echo '</tr>';

echo '</tbody>';
echo '</table>';
}
Expand Down Expand Up @@ -300,14 +332,17 @@ function save_post( $post_id ) {
$venue = sanitize_text_field( $_POST['venue'] );
$city = sanitize_text_field( $_POST['city'] );
$tickets_url = sanitize_text_field( $_POST['tickets_url'] );

$tickets_button = sanitize_text_field( $_POST['tickets_button'] );
$tickets_status = $_POST['tickets_status'];

// Update the meta field.
update_post_meta( $post_id, WPT_Production::post_type_name, $production );
update_post_meta( $post_id, 'event_date', $event_date );
update_post_meta( $post_id, 'venue', $venue );
update_post_meta( $post_id, 'city', $city );
update_post_meta( $post_id, 'tickets_url', $tickets_url );

update_post_meta( $post_id, 'tickets_status', $tickets_status );
update_post_meta( $post_id, 'tickets_button', $tickets_button );

/*
* We need to verify this came from the our screen and with proper authorization,
Expand Down
3 changes: 3 additions & 0 deletions functions/wpt_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ function time() {
}
return $this->time;
}

function post_class() {
}
}

?>
21 changes: 18 additions & 3 deletions functions/wpt_production.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,24 @@ function render_events() {
$html.= '</span>';

$html.= '<br />';
$html.= '<a href="'.get_post_meta($event->ID,'tickets_url',true).'">';
$html.= __('Tickets','wp_theatre');
$html.= '</a>';

if (get_post_meta($event->ID,'tickets_status',true) == 'soldout') {
$html.= __('Sold out', 'wp_theatre');
} else {
$url = get_post_meta($event->ID,'tickets_url',true);
if ($url!='') {
$html.= '<a href="'.get_post_meta($event->ID,'tickets_url',true).'">';
$button_text = get_post_meta($event->ID,'tickets_button',true);
if ($button_text!='') {
$html.= $button_text;
} else {
$html.= __('Tickets','wp_theatre');
}
$html.= '</a>';

}
}

$html.= '</li>';
}
$html.= '</ul>';
Expand Down
6 changes: 5 additions & 1 deletion functions/wpt_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ function init() {
array(
'labels' => array(
'name' => __( 'Productions','wp_theatre'),
'singular_name' => __( 'Production','wp_theatre')
'singular_name' => __( 'Production','wp_theatre'),
'add_new' => _x('Add New', 'product','wp_theatre'),
'new_item' => __('New'),' '.__('production','wp_theatre'),
'add_new_item' => __('Add new').' '.__('production','wp_theatre'),
'edit_item' => __('Edit production','wp_theatre')
),
'public' => true,
'has_archive' => true,
Expand Down

0 comments on commit 3bff720

Please sign in to comment.