Configure slider images'; echo '

This theme supports up to ' . MAX_SLIDER_IMAGES . ' slider images. To configure the images, upload the images using the media tool and then enter the url into the text fields below. For best results, images must be the same size. E.g., 1024px wide by 350px high.

E.g. http://campmaine.tamstradingpost.com/wp-content/uploads/2014/10/02_GROUSE_MTN_1024_350.jpg

Optional image captions and onclick urls are configured below.

'; echo '
'; settings_fields('image_slider_theme_options') ; settings_errors('image_slider_url_theme_options'); settings_errors('image_slider_caption_theme_options'); do_settings_sections('image_slider'); echo '

'; echo '

'; } /** * Add Image Slider custom submenu. * */ add_action('admin_menu', 'campmaine_add_image_slider_appearance_menu'); function campmaine_add_image_slider_appearance_menu(){ add_theme_page('Image slider configuration', 'Image Slider', 'manage_options', 'image_slider', 'campmaine_custom_image_slider_submenu_page_callback'); } /** * Register the settings for the Image Slider page */ add_action( 'admin_init', 'campmaine_image_slider_register_settings' ); /** * Function to register the settings */ function campmaine_image_slider_register_settings() { // Register the image url settings with validation callback register_setting( 'image_slider_theme_options', 'image_slider_url_theme_options', 'campmaine_image_slider_url_validate_settings' ); // Add settings section add_settings_section( 'image_slider_url_section', '', 'campmaine_image_slider_url_display_section', 'image_slider' ); // Register the image caption settings. register_setting( 'image_slider_theme_options', 'image_slider_caption_theme_options', 'campmaine_image_slider_caption_validate_settings' ); // Add settings section add_settings_section( 'image_slider_caption_section', '', 'campmaine_image_slider_caption_display_section', 'image_slider' ); // Register the image link settings. register_setting( 'image_slider_theme_options', 'image_slider_link_theme_options', 'campmaine_image_slider_url_validate_settings' ); // Add settings section add_settings_section( 'image_slider_link_section', '', 'campmaine_image_slider_link_display_section', 'image_slider' ); for ($i=0;$i 'text', 'id' => 'image_slider_url_' . (1 + $i) . '_textfield', 'name' => 'image_slider_url', 'desc' => '', 'std' => '', 'label_for' => 'image_slider_url_' . (1 + $i) . '_textfield', 'class' => 'image_slider_url_field' ); add_settings_field( 'image_slider_url_' . (1 + $i) . '_textfield', 'Image #' . (1 + $i), 'campmaine_image_slider_display_setting', 'image_slider', 'image_slider_url_section', $field_args ); // Create image caption textbox field $field_args = array( 'type' => 'text', 'id' => 'image_slider_caption_' . (1 + $i) . '_textfield', 'name' => 'image_slider_caption', 'desc' => '', 'std' => '', 'label_for' => 'image_slider_caption_' . (1 + $i) . '_textfield', 'class' => 'image_slider_caption_field' ); add_settings_field( 'image_slider_caption_' . (1 + $i) . '_textfield', 'Image #' . (1 + $i) . ' caption', 'campmaine_image_slider_display_setting', 'image_slider', 'image_slider_caption_section', $field_args ); // Create image link textbox field $field_args = array( 'type' => 'text', 'id' => 'image_slider_link_' . (1 + $i) . '_textfield', 'name' => 'image_slider_link', 'desc' => '', 'std' => '', 'label_for' => 'image_slider_link_' . (1 + $i) . '_textfield', 'class' => 'image_slider_link_field' ); add_settings_field( 'image_slider_link_' . (1 + $i) . '_textfield', 'Image #' . (1 + $i) . ' link', 'campmaine_image_slider_display_setting', 'image_slider', 'image_slider_link_section', $field_args); } } /** * Function to add extra text to display on each section */ function campmaine_image_slider_url_display_section($section){ echo '

Image URLs.

'; } /** * Function to add extra text to display on each section */ function campmaine_image_slider_caption_display_section($section){ echo '

Image Captions. Limit of ' . MAX_CAPTION_LENGTH . ' characters.

'; } /** * Function to add extra text to display on each section */ function campmaine_image_slider_link_display_section($section){ echo '

Image links.

'; } /** * Function to display the settings on the page * This is setup to be expandable by using a switch on the type variable. * In future you can add multiple types to be display from this function, * Such as checkboxes, select boxes, file upload boxes etc. */ function campmaine_image_slider_display_setting($args) { extract( $args ); $option_name = $name . '_theme_options'; $options = get_option( $option_name ); switch ( $type ) { case 'text': $option_value = empty($options) ? '' : $options[$id]; $option_value = stripslashes($option_value); $option_value = esc_attr( $option_value); echo ""; break; } } function campmaine_image_slider_caption_validate_settings($input) { foreach($input as $k => $v) { $newinput[$k] = trim($v); if (strlen(trim($v)) > MAX_CAPTION_LENGTH) { $newinput[$k] = ''; add_settings_error('image_slider_caption_theme_options', $k, 'Invalid text: ' . $v, 'error'); } else { $newinput[$k] = sanitize_text_field(trim($v)); } } return $newinput; } function campmaine_image_slider_url_validate_settings($input) { foreach($input as $k => $v) { $newinput[$k] = trim($v); // Check the url input. if (!empty($v)) { $url = esc_url_raw(trim($v)); if (empty($url)) { $newinput[$k] = ''; add_settings_error('image_slider_url_theme_options', $k, 'Invalid url: ' . $v, 'error'); } } } return $newinput; }