Skip to content

Instantly share code, notes, and snippets.

@Mamaduka
Created August 1, 2011 11:30
Show Gist options
  • Save Mamaduka/1117972 to your computer and use it in GitHub Desktop.
Save Mamaduka/1117972 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Post Meta for Events
* Plugin URI:
* Description: Add meta box to posts for events meta information ( using Kovshenin's Post Options API plugin )
* Version: 0.1
* Author: George Mamadashvili
*/
// Remove test options
remove_action( 'init', 'post_options_test' );
// Hook our options for events meta
add_action( 'init', 'mamaduka_post_meta_events', 11 );
function mamaduka_post_meta_events() {
global $post_options;
// Register one section and add it to 'post' post type
$post_options->register_post_options_section( 'add-event', 'Add Event' );
$post_options->add_section_to_post_type( 'add-event', 'post' );
// Add text field for event title
$post_options->register_post_option( array(
'id' => 'event-title',
'title' => 'What are you planning?',
'section' => 'add-event',
'callback' => Post_Options_Fields::text( array(
'sanitize_callback' => 'sanitize_title'
) )
) );
// Add text field for event location
$post_options->register_post_option( array(
'id' => 'event-location',
'title' => 'Where?',
'section' => 'add-event',
'callback' => Post_Options_Fields::text( array(
'sanitize_callback' => 'sanitize_title'
) )
) );
// Add textare for event description
$post_options->register_post_option( array(
'id' => 'event-info',
'title' => 'More info?',
'section' => 'add-event',
'callback' => Post_Options_Fields::textarea( array(
'decription' => ''
) )
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment