add_page( __( 'Theme Options', 'eventbrite-parent' ), __( 'Theme Options', 'eventbrite-parent' ), 'theme-options', 'edit_theme_options', '' )
->add_group( '', Eventbrite_Settings::eventbrite_group_key() )
->add_setting( '
' . __( 'Recommended Page Settings for This Theme', 'eventbrite-venue' ) . '
', 'eventbrite-page-settings', array(
'display_callback' => 'eventbrite_multi_page_settings_description_cb',
) )->group
->add_setting( __( 'Events List', 'eventbrite-venue' ), 'events-page-id', array(
'description' => __( 'This page will be used to show a list of your upcoming Eventbrite events.', 'eventbrite-venue' ),
'display_callback' => 'eventbrite_multi_page_settings_cb',
'sanitize_callbacks' => array( 'absint' ),
) )->group
->add_setting( __( 'Featured Events List', 'eventbrite-venue' ), 'upcoming-events-page-id', array(
'description' => __( 'This page will be used to display a carousel of the selected featured Eventbrite events along with a listing of upcoming Eventbrite events.', 'eventbrite-venue' ),
'display_callback' => 'eventbrite_multi_page_settings_cb',
'sanitize_callbacks' => array( 'absint' ),
) )->group
->add_setting( __( 'Calendar Page', 'eventbrite-venue' ), 'calendar-page-id', array(
'description' => __( 'This page will show a calendar (monthly) view of your Eventbrite events.', 'eventbrite-venue' ),
'display_callback' => 'eventbrite_multi_page_settings_cb',
'sanitize_callbacks' => array( 'absint' ),
) )->group
->add_setting( __( 'Additional Suggested Pages', 'eventbrite-venue' ), 'suggested-pages', array(
'display_callback' => 'eventbrite_multi_page_suggested_cb',
) );
}
}
add_action( 'init', 'eventbrite_multi_page_settings', 99 );
/**
* Callback for Voce_Settings_API for showing the description for pages
*/
function eventbrite_multi_page_settings_description_cb() {
echo '' . sprintf( __( 'To set up the best site with this theme, we recommend adding at
least the following pages to your theme - Events List page, Featured Events page, and
Calendar page. You can use an existing page or create a new one.', 'eventbrite-venue' ) . '
',
esc_url( admin_url( 'post-new.php?post_type=page' ) ) );
}
/**
* Callback for Voce_Settings_API for showing a dropdown of pages
*
* @param type $value value of setting
* @param type $setting setting object
* @param type $setting_args args from setting
*/
function eventbrite_multi_page_settings_cb( $value, $setting, $setting_args ) {
$dropdown = wp_dropdown_pages( array(
'echo' => false,
'name' => esc_attr( $setting->get_field_name() ),
'show_option_none' => __( '— Select —', 'eventbrite-parent' ),
'option_none_value' => '0',
'selected' => eventbrite_services_get_setting( $setting->setting_key, '0' ),
) );
if ( ! $dropdown ) {
echo '' . sprintf( __( "You don't have any published pages. To use this feature create a new page then come back here and update this.", 'eventbrite-parent' ) . '
',
esc_url( admin_url( 'post-new.php?post_type=page' ) ) );
return;
} else {
printf( '%s
', $dropdown );
}
if ( ! empty( $setting_args['description'] ) )
echo sprintf( '%s', wp_kses( $setting_args['description'], wp_kses_allowed_html() ) );
printf ( '%2$s
',
esc_url( admin_url( 'post-new.php?post_type=page' ) ),
__( 'Create new page', 'eventbrite-parent' )
);
}
/**
* Callback for Voce_Settings_API for showing the suggested pages
*/
function eventbrite_multi_page_suggested_cb() {
echo '' . __( 'The following pages are also nice to have for this theme:', 'eventbrite-venue' ) . '
';
echo '
';
echo '- ' . __( 'Contact Us - hours, address, phone number, email and other contact details', 'eventbrite-venue' ) . '
';
echo '- ' . __( 'About - additional information about your venue or events', 'eventbrite-venue' ) . '
';
echo '
';
}
/**
* Flush the rewrite rules if the settings page is updated. used when the Theme
* Options page is loaded to flush the rewrite rules when the page used for
* events may have changed.
*/
function eventbrite_multi_maybe_flush_rewrite_rules() {
if ( isset( $_REQUEST[ 'settings-updated' ] ) )
flush_rewrite_rules( false );
}
add_action( 'load-appearance_page_theme-options-page', 'eventbrite_multi_maybe_flush_rewrite_rules' );