Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
New theme option for making an event active
  • Loading branch information
danielbachhuber committed May 9, 2011
1 parent 16da0fa commit 786856e
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion functions.php
Expand Up @@ -235,8 +235,8 @@ function register_settings() {

// Global options
add_settings_section( 'cngnyc_global', 'Global', array(&$this, 'settings_global_section'), $this->settings_page );
// Top homepage announcement
add_settings_field( 'project_description', 'Project Description', array(&$this, 'settings_project_description_option'), $this->settings_page, 'cngnyc_global' );
add_settings_field( 'active_event', 'Active Live Coverage', array(&$this, 'settings_active_event_option'), $this->settings_page, 'cngnyc_global' );


} // END register_settings()
Expand All @@ -258,6 +258,35 @@ function settings_project_description_option() {

} // END settings_project_description_option()

/**
* settings_active_event_option()
* Choose whether there's currently an active event
*/
function settings_active_event_option() {

$options = $this->options;
$args = array(
'posts_per_page' => '-1',
'post_type' => 'cngnyc_event',
);
$all_events = new WP_Query( $args );
echo '<select id="active_event" name="' . $this->options_group_name . '[active_event]">';
echo '<option value="0">-- No active event --</option>';
if ( $all_events->have_posts() ) {
while ( $all_events->have_posts() ) {
$all_events->the_post();
echo '<option value="' . get_the_id() . '"';
if ( get_the_id() == $options['active_event'] ) {
echo ' selected="selected"';
}
echo '>' . get_the_title() . '</option>';
}
}
echo '</select>';
echo '<p class="description">Making an event active will add the event to the homepage and an alert message elsewhere</p>';

} // END settings_active_event_option()

/**
* settings_validate()
* Validation and sanitization on the settings field
Expand Down

0 comments on commit 786856e

Please sign in to comment.