?>
][settings][dynamic_flickr_data_type]">
					<?php 
$data_type = sliderpro_get_slide_setting($slide_settings, 'dynamic_flickr_data_type', 'dynamic');
$list = sliderpro_get_settings_list('dynamic_flickr_data_type');
foreach ($list as $entry) {
    $selected = $data_type == $entry ? ' selected="selected"' : '';
    echo '<option' . $selected . ' value="' . $entry . '">' . sliderpro_get_settings_pretty_name($entry) . '</option>';
}
?>
				</select>
			</td>
			
			<td>
				<label title="dynamic_flickr_maximum"><?php 
_e('Maximum', 'slider_pro');
?>
</label>
				<input name="slide[<?php 
echo $counter;
?>
][settings][dynamic_flickr_maximum]" type="text" 
					   value="<?php 
echo sliderpro_get_slide_setting($slide_settings, 'dynamic_flickr_maximum', 'dynamic');
?>
"/>
			</td>
		</tr>
	</table>
	
</div>
"/>
	
	
	<label title="dynamic_gallery_maximum"><?php 
_e('Maximum', 'slider_pro');
?>
</label>
	<input name="slide[<?php 
echo $counter;
?>
][settings][dynamic_gallery_maximum]" type="text" 
		   value="<?php 
echo sliderpro_get_slide_setting($slide_settings, 'dynamic_gallery_maximum', 'dynamic');
?>
"/>
	
	
	<label title="dynamic_gallery_offset"><?php 
_e('Offset', 'slider_pro');
?>
</label>
	<input name="slide[<?php 
echo $counter;
?>
][settings][dynamic_gallery_offset]" type="text" 
		   value="<?php 
echo sliderpro_get_slide_setting($slide_settings, 'dynamic_gallery_offset', 'dynamic');
?>
"/>
	
</div>
_e('Offset', 'slider_pro');
?>
</label>
	<input name="slide[<?php 
echo $counter;
?>
][settings][dynamic_posts_offset]" type="text" 
		   value="<?php 
echo sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_offset', 'dynamic');
?>
"/>
	
	
	<label title="dynamic_posts_featured"><?php 
_e('Featured', 'slider_pro');
?>
</label>
	<input name="slide[<?php 
echo $counter;
?>
][settings][dynamic_posts_featured]" type="hidden" value="0"/>
	<input name="slide[<?php 
echo $counter;
?>
][settings][dynamic_posts_featured]" type="checkbox" value="1" 
		   <?php 
echo sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_featured', 'dynamic') == true ? 'checked="checked"' : '';
?>
 />
	   
</div>
/**
* Create the Slider PRO
*/
function slider_pro($id, $atts = null, $content = null)
{
    global $sliderpro_slider_settings, $sliderpro_unique_id, $sliderpro_used_ids, $sliderpro_scripts_to_load, $sliderpro_custom_scripts_to_load, $sliderpro_styles_to_load, $sliderpro_sliders_js, $sliderpro_lightbox_loaded, $sliderpro_videojs_loaded, $sliderpro_js_properties, $sliderpro_flickr_sizes;
    // assign an ID for this slider
    // it will either be the based on the ID that the slider has in the database
    // or, if that ID is already used in the same page, another unique ID will be assign
    $current_id = in_array($id, $sliderpro_used_ids) || $id == -1 ? $sliderpro_unique_id-- : $id;
    array_push($sliderpro_used_ids, $current_id);
    // if id is -1, it means that an id was not specified and the slider will be created
    // based on shortcode data
    if ($id == -1) {
        $slides = array();
        $available_settings = array();
        foreach ($sliderpro_slider_settings as $key => $value) {
            $available_settings[$key] = $value['default_value'];
        }
        // merge the values specified in the shortcode with the default ones
        $slider_settings = $atts ? array_merge($available_settings, $atts) : $available_settings;
    } else {
        // if an id was specified, load the slider
        $slider = sliderpro_get_slider($id);
        // if the slider does not exist, display a message
        if (!$slider) {
            return "A slider with the ID of {$id} was not found.";
        }
        // merge the values specified in the shortcode with the values specified for the slider in the admin area
        $slider_settings = $atts ? array_merge($slider['settings'], $atts) : $slider['settings'];
        // load the slider's slides
        $slides = sliderpro_get_slides($id);
    }
    // analyze the shortcode's content, if any
    if ($content) {
        // create an array that will hold extra slides
        $slides_extra = array();
        // counter for the slides for which an index was not specified and will be added at the end of the other slides
        $end_counter = 1;
        // get all the added slides
        $slides_sc = do_shortcode($content);
        $slides_sc = str_replace('<br />', '', $slides_sc);
        $slides_sc = explode('%sp_sep%', $slides_sc);
        // loop through all the slides added within the shortcode
        // and add the slide to the slides_extra array
        foreach ($slides_sc as $slide_sc) {
            $slide_sc = unserialize(trim($slide_sc));
            if ($slide_sc) {
                $index = $slide_sc['settings']['index'];
                if (!is_numeric($index)) {
                    $index .= "_{$end_counter}";
                    $end_counter++;
                }
                $slides_extra[$index] = $slide_sc;
            }
        }
        // loop through all the existing slides and override the settings and/or the content
        // if it's the case
        foreach ($slides as &$slide_r) {
            $slide_settings = unserialize($slide_r['settings']);
            $slide_content = unserialize($slide_r['content']);
            if (isset($slides_extra[$slide_r['position']])) {
                $slide_extra = $slides_extra[$slide_r['position']];
                if ($slide_extra['settings']) {
                    $slide_settings = array_merge($slide_settings, $slide_extra['settings']);
                }
                if ($slide_extra['content']) {
                    $slide_content = array_merge($slide_content, $slide_extra['content']);
                }
                unset($slides_extra[$slide_r['position']]);
            }
            $slide_r['settings'] = $slide_settings;
            $slide_r['content'] = $slide_content;
        }
        // add the extra slides at the end of the initial slides
        $extra_slides_counter = count($slides);
        foreach ($slides_extra as $slide_end) {
            $extra_slides_counter++;
            $slide_end['visibility'] = isset($slide_end['settings']['visibility']) ? $slide_end['settings']['visibility'] : 'enabled';
            $slide_end['position'] = $extra_slides_counter;
            array_push($slides, $slide_end);
        }
    } else {
        foreach ($slides as &$slide_s) {
            $slide_settings = unserialize($slide_s['settings']);
            $slide_content = unserialize($slide_s['content']);
            $slide_s['settings'] = $slide_settings;
            $slide_s['content'] = $slide_content;
        }
    }
    $dynamic_slides = array();
    $posts_terms_pattern = sliderpro_regex(array('sp_image', 'sp_image_alt', 'sp_image_title', 'sp_image_caption', 'sp_image_description', 'sp_comments_number', 'sp_comments_link', 'sp_title', 'sp_content', 'sp_excerpt', 'sp_author_name', 'sp_author_posts', 'sp_date', 'sp_link', 'sp_custom'));
    $gallery_terms_pattern = sliderpro_regex(array('sp_image', 'sp_image_alt', 'sp_image_title', 'sp_image_caption', 'sp_image_description'));
    $flickr_terms_pattern = sliderpro_regex(array('sp_image', 'sp_image_title', 'sp_image_description', 'sp_image_link', 'sp_image_set', 'sp_date', 'sp_user', 'sp_user_link', 'sp_user_photos', 'sp_user_sets'));
    foreach ($slides as $slide) {
        // check if the slide is set to automatically fetch post dara
        if (sliderpro_get_slide_setting($slide['settings'], 'slide_type', 'dynamic') == 'posts') {
            if (isset($slide['visibility']) && $slide['visibility'] == 'disabled') {
                continue;
            }
            $slide_settings = $slide['settings'];
            $slide_content = $slide['content'];
            foreach ($slide_content as $key => $value) {
                $slide_content[$key] = sliderpro_decode($value, true, true);
            }
            // construct the argument of the Query object
            $dynamic_slide_args = array();
            $dynamic_posts_types_raw = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_types', 'dynamic');
            if ($dynamic_posts_types_raw != '') {
                $dynamic_post_types = explode(';', $dynamic_posts_types_raw);
                $dynamic_slide_args['post_type'] = $dynamic_post_types;
            }
            $dynamic_posts_taxonomies_raw = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_taxonomies', 'dynamic');
            if ($dynamic_posts_taxonomies_raw != '') {
                $tax_query = array();
                $dynamic_taxonomies = explode(';', $dynamic_posts_taxonomies_raw);
                foreach ($dynamic_taxonomies as $item_raw) {
                    $item = explode('|', $item_raw);
                    $tax_item['taxonomy'] = $item[0];
                    $tax_item['terms'] = $item[1];
                    $tax_item['field'] = 'slug';
                    array_push($tax_query, $tax_item);
                }
                $tax_query['relation'] = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_relation', 'dynamic');
                $dynamic_slide_args['tax_query'] = $tax_query;
            }
            $dynamic_posts_featured = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_featured', 'dynamic');
            if ($dynamic_posts_featured) {
                $dynamic_slide_args['meta_query'] = array(array('key' => '_sliderpro-featured', 'value' => true));
            }
            $dynamic_slide_args['posts_per_page'] = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_maximum', 'dynamic');
            $dynamic_slide_args['offset'] = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_offset', 'dynamic');
            $dynamic_slide_args['orderby'] = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_orderby', 'dynamic');
            $dynamic_slide_args['order'] = sliderpro_get_slide_setting($slide_settings, 'dynamic_posts_order', 'dynamic');
            $slide_dynamic_terms = array();
            $has_image = false;
            // get all the dynamic terms used in the content fields
            foreach ($slide_content as $key => $value) {
                if ($value != '') {
                    $matches = array();
                    preg_match_all('/' . $posts_terms_pattern . '/s', $value, $matches);
                    // check if a match is found
                    if (!empty($matches)) {
                        // loop through all terms found in the field
                        foreach ($matches[0] as $counter => $match_item) {
                            // check if the exact term is not already added to the collection
                            if (!isset($slide_dynamic_terms[$match_item])) {
                                // get the array of arguments specified for the term/tag
                                $args = explode('|', trim($matches[3][$counter]));
                                // create an array of argument pairs (name => value)
                                $arg_pair = array('term_name' => $matches[2][$counter]);
                                // check if an image exists in the content fields
                                if ($matches[2][$counter] == 'sp_image') {
                                    $has_image = true;
                                }
                                foreach ($args as $arg) {
                                    if ($arg != '') {
                                        $arg_item = explode('=', $arg);
                                        $arg_pair[trim($arg_item[0])] = substr(trim($arg_item[1]), 1, -1);
                                    }
                                }
                                // associate the term found with its array of argument pairs
                                $slide_dynamic_terms[$match_item] = $arg_pair;
                            }
                        }
                    }
                }
            }
            // start the Query
            $query = new WP_Query($dynamic_slide_args);
            while ($query->have_posts()) {
                $query->the_post();
                $dynamic_slide = array();
                // each dynamic slide will initially contain the main slide's content and settings
                $dynamic_slide['settings'] = $slide_settings;
                $dynamic_slide['content'] = $slide_content;
                $dynamic_slide['position'] = $slide['position'];
                $dynamic_slide['visibility'] = $slide['visibility'];
                // the image id will be used for multiple terms
                $image_id;
                // contains data like image alt, image title, image caption and image description
                $image_data;
                // if an image exists, get the ID and meta data of the image
                if ($has_image) {
                    if (has_post_thumbnail()) {
                        $image_id = get_post_thumbnail_id();
                    } else {
                        $children_args = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => get_the_ID(), 'numberposts' => 1, 'orderby' => 'menu_order', 'order' => 'ASC');
                        $image_item = get_children($children_args, ARRAY_A);
                        if ($image_item) {
                            $image_item = array_values($image_item);
                        }
                        $image_id = $image_item[0]['ID'];
                    }
                    $image_data = get_post($image_id, ARRAY_A);
                    $image_alt_data = get_post_meta($image_id, '_wp_attachment_image_alt');
                    $image_data['alt'] = !empty($image_alt_data) ? $image_alt_data[0] : '';
                }
                // loop through all content fields
                foreach ($dynamic_slide['content'] as $field_name => &$field_content) {
                    if ($field_content != '') {
                        // loop through all terms that were find in the content fields
                        foreach ($slide_dynamic_terms as $term => $term_data) {
                            // check if the term is in the current field
                            if (strpos($field_content, $term) !== false) {
                                // check the type of the term
                                $replace = '';
                                if ($term_data['term_name'] == 'sp_image') {
                                    $image_size = isset($term_data['size']) ? $term_data['size'] : 'full';
                                    $image_src = wp_get_attachment_image_src($image_id, $image_size);
                                    $replace = sliderpro_get_real_path($image_src[0]);
                                } else {
                                    if ($term_data['term_name'] == 'sp_image_alt') {
                                        $replace = $image_data['alt'];
                                    } else {
                                        if ($term_data['term_name'] == 'sp_image_title') {
                                            $replace = $image_data['post_title'];
                                        } else {
                                            if ($term_data['term_name'] == 'sp_image_caption') {
                                                $replace = $image_data['post_excerpt'];
                                            } else {
                                                if ($term_data['term_name'] == 'sp_image_description') {
                                                    $replace = $image_data['post_content'];
                                                } else {
                                                    if ($term_data['term_name'] == 'sp_title') {
                                                        $replace = get_the_title();
                                                    } else {
                                                        if ($term_data['term_name'] == 'sp_link') {
                                                            $replace = get_post_permalink(get_the_ID());
                                                        } else {
                                                            if ($term_data['term_name'] == 'sp_date') {
                                                                $date_format = isset($term_data['format']) ? $term_data['format'] : get_option('date_format');
                                                                $replace = get_the_date($date_format);
                                                            } else {
                                                                if ($term_data['term_name'] == 'sp_author_name') {
                                                                    $replace = get_the_author();
                                                                } else {
                                                                    if ($term_data['term_name'] == 'sp_author_posts') {
                                                                        $replace = get_author_posts_url(get_the_author_meta('ID'));
                                                                    } else {
                                                                        if ($term_data['term_name'] == 'sp_comments_number') {
                                                                            $more = isset($term_data['more']) ? $term_data['more'] : false;
                                                                            $one = isset($term_data['one']) ? $term_data['one'] : false;
                                                                            $zero = isset($term_data['zero']) ? $term_data['zero'] : false;
                                                                            $number = get_comments_number();
                                                                            if ($number > 1) {
                                                                                $replace = str_replace('%', $number, $more === false ? __('% Comments') : $more);
                                                                            } else {
                                                                                if ($number == 0) {
                                                                                    $replace = $zero === false ? __('No Comments') : $zero;
                                                                                } else {
                                                                                    $replace = $one === false ? __('1 Comment') : $one;
                                                                                }
                                                                            }
                                                                        } else {
                                                                            if ($term_data['term_name'] == 'sp_comments_link') {
                                                                                $replace = get_comments_link();
                                                                            } else {
                                                                                if ($term_data['term_name'] == 'sp_excerpt') {
                                                                                    $excerpt = isset($term_data['limit']) ? substr(get_the_excerpt(), 0, $term_data['limit']) : get_the_excerpt();
                                                                                    if (isset($term_data['more_text'])) {
                                                                                        $more_text = $term_data['more_text'];
                                                                                        $more_link = isset($term_data['more_link']) ? $term_data['more_link'] : get_post_permalink(get_the_ID());
                                                                                        $excerpt .= '<a href="' . $more_link . '">' . $more_text . '</a>';
                                                                                    }
                                                                                    $replace = $excerpt;
                                                                                } else {
                                                                                    if ($term_data['term_name'] == 'sp_content') {
                                                                                        global $more;
                                                                                        $more = 0;
                                                                                        $content = isset($term_data['more_text']) ? get_the_content($term_data['more_text']) : get_the_content();
                                                                                        if (isset($term_data['filters'])) {
                                                                                            $content = apply_filters('the_content', $content);
                                                                                            $content = str_replace(']]>', ']]&gt;', $content);
                                                                                        }
                                                                                        $replace = $content;
                                                                                    } else {
                                                                                        if ($term_data['term_name'] == 'sp_custom') {
                                                                                            $replace = '';
                                                                                            if (isset($term_data['name'])) {
                                                                                                $values = get_post_meta(get_the_ID(), $term_data['name']);
                                                                                                $index = isset($term_data['index']) ? $term_data['index'] : 0;
                                                                                                $replace = isset($values[$index]) ? $values[$index] : '';
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                // replace all the current terms in the field with the corresponding content
                                $field_content = str_replace($term, $replace, $field_content);
                            }
                        }
                        // end terms loop
                    }
                }
                // end fields loop
                array_push($dynamic_slides, $dynamic_slide);
                unset($dynamic_slide);
            }
            // end while
            wp_reset_postdata();
            unset($slide_dynamic_terms);
        } else {
            if (sliderpro_get_slide_setting($slide['settings'], 'slide_type', 'dynamic') == 'gallery') {
                if (isset($slide['visibility']) && $slide['visibility'] == 'disabled') {
                    continue;
                }
                $slide_settings = $slide['settings'];
                $slide_content = $slide['content'];
                foreach ($slide_content as $key => $value) {
                    $slide_content[$key] = sliderpro_decode($value, true, true);
                }
                $gallery_post_id;
                $dynamic_gallery_post = sliderpro_get_slide_setting($slide_settings, 'dynamic_gallery_post', 'dynamic');
                $dynamic_gallery_maximum = sliderpro_get_slide_setting($slide_settings, 'dynamic_gallery_maximum', 'dynamic');
                $dynamic_gallery_offset = sliderpro_get_slide_setting($slide_settings, 'dynamic_gallery_offset', 'dynamic');
                global $post;
                // if the post is set to '-1' only display the content if it's inside a post
                // don't diplay it if it's in the Preview window
                if ($dynamic_gallery_post == -1 && !isset($post)) {
                    continue;
                } else {
                    $gallery_post_id = $dynamic_gallery_post == -1 ? get_the_ID() : $dynamic_gallery_post;
                }
                // get the images from the post's gallery
                $children_args = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $gallery_post_id, 'numberposts' => $dynamic_gallery_maximum, 'orderby' => 'menu_order', 'order' => 'ASC');
                $gallery_images = array_splice(array_values(get_children($children_args, ARRAY_A)), $dynamic_gallery_offset);
                $slide_dynamic_terms = array();
                // get all the dynamic terms used in the content fields
                foreach ($slide_content as $key => $value) {
                    if ($value != '') {
                        $matches = array();
                        preg_match_all('/' . $gallery_terms_pattern . '/s', $value, $matches);
                        // check if a match is found
                        if (!empty($matches)) {
                            // loop through all terms found in the field
                            foreach ($matches[0] as $counter => $match_item) {
                                // check if the exact term is not already added to the collection
                                if (!isset($slide_dynamic_terms[$match_item])) {
                                    // get the array of arguments specified for the term/tag
                                    $args = explode('|', trim($matches[3][$counter]));
                                    // create an array of argument pairs (name => value)
                                    $arg_pair = array('term_name' => $matches[2][$counter]);
                                    foreach ($args as $arg) {
                                        if ($arg != '') {
                                            $arg_item = explode('=', $arg);
                                            $arg_pair[trim($arg_item[0])] = substr(trim($arg_item[1]), 1, -1);
                                        }
                                    }
                                    // associate the term found with its array of argument pairs
                                    $slide_dynamic_terms[$match_item] = $arg_pair;
                                }
                            }
                        }
                    }
                }
                foreach ($gallery_images as $image) {
                    $dynamic_slide = array();
                    // each dynamic slide will initially contain the main slide's content and settings
                    $dynamic_slide['settings'] = $slide_settings;
                    $dynamic_slide['content'] = $slide_content;
                    $dynamic_slide['position'] = $slide['position'];
                    $dynamic_slide['visibility'] = $slide['visibility'];
                    // loop through all content fields
                    foreach ($dynamic_slide['content'] as $field_name => &$field_content) {
                        if ($field_content != '') {
                            // loop through all terms that were find in the content fields
                            foreach ($slide_dynamic_terms as $term => $term_data) {
                                // check if the term is in the current field
                                if (strpos($field_content, $term) !== false) {
                                    // check the type of the term
                                    $replace = '';
                                    if ($term_data['term_name'] == 'sp_image') {
                                        $image_size = isset($term_data['size']) ? $term_data['size'] : 'full';
                                        $image_src = wp_get_attachment_image_src($image['ID'], $image_size);
                                        $replace = sliderpro_get_real_path($image_src[0]);
                                    } else {
                                        if ($term_data['term_name'] == 'sp_image_alt') {
                                            $image_alt = get_post_meta($image['ID'], '_wp_attachment_image_alt');
                                            $replace = !empty($image_alt) ? $image_alt[0] : '';
                                        } else {
                                            if ($term_data['term_name'] == 'sp_image_title') {
                                                $replace = $image['post_title'];
                                            } else {
                                                if ($term_data['term_name'] == 'sp_image_caption') {
                                                    $replace = $image['post_excerpt'];
                                                } else {
                                                    if ($term_data['term_name'] == 'sp_image_description') {
                                                        $replace = $image['post_content'];
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    // replace all the current terms in the field with the corresponding content
                                    $field_content = str_replace($term, $replace, $field_content);
                                }
                            }
                            // end terms loop
                        }
                    }
                    // end fields loop
                    array_push($dynamic_slides, $dynamic_slide);
                    unset($dynamic_slide);
                }
                unset($slide_dynamic_terms);
            } else {
                if (sliderpro_get_slide_setting($slide['settings'], 'slide_type', 'dynamic') == 'flickr') {
                    if (isset($slide['visibility']) && $slide['visibility'] == 'disabled') {
                        continue;
                    }
                    $slide_settings = $slide['settings'];
                    $slide_content = $slide['content'];
                    foreach ($slide_content as $key => $value) {
                        $slide_content[$key] = sliderpro_decode($value, true, true);
                    }
                    // instantiate the Flickr object
                    global $sliderpro_flickr;
                    if (!isset($sliderpro_flickr)) {
                        include_once 'includes/flickr/phpFlickr.php';
                        $sliderpro_flickr = new phpFlickr(sliderpro_get_slide_setting($slide_settings, 'dynamic_flickr_api_key', 'dynamic'));
                        $sliderpro_flickr->enableCache("fs", WP_PLUGIN_DIR . '/slider-pro/includes/flickr/cache');
                    }
                    $dynamic_flickr_data_type = sliderpro_get_slide_setting($slide_settings, 'dynamic_flickr_data_type', 'dynamic');
                    $dynamic_flickr_data_id = sliderpro_get_slide_setting($slide_settings, 'dynamic_flickr_data_id', 'dynamic');
                    $dynamic_flickr_maximum = sliderpro_get_slide_setting($slide_settings, 'dynamic_flickr_maximum', 'dynamic');
                    $flickr_response;
                    $flickr_array_name;
                    if ($dynamic_flickr_data_type == 'set') {
                        $flickr_response = $sliderpro_flickr->photosets_getPhotos($dynamic_flickr_data_id, 'description,date_upload,owner_name');
                        $flickr_array_name = 'photoset';
                    } else {
                        if ($dynamic_flickr_data_type == 'username') {
                            $flickr_response = $sliderpro_flickr->people_getPublicPhotos($dynamic_flickr_data_id, NULL, 'description,date_upload,owner_name');
                            $flickr_array_name = 'photos';
                        }
                    }
                    $slide_dynamic_terms = array();
                    // get all the dynamic terms used in the content fields
                    foreach ($slide_content as $key => $value) {
                        if ($value != '') {
                            $matches = array();
                            preg_match_all('/' . $flickr_terms_pattern . '/s', $value, $matches);
                            // check if a match is found
                            if (!empty($matches)) {
                                // loop through all terms found in the field
                                foreach ($matches[0] as $counter => $match_item) {
                                    // check if the exact term is not already added to the collection
                                    if (!isset($slide_dynamic_terms[$match_item])) {
                                        // get the array of arguments specified for the term/tag
                                        $args = explode('|', trim($matches[3][$counter]));
                                        // create an array of argument pairs (name => value)
                                        $arg_pair = array('term_name' => $matches[2][$counter]);
                                        foreach ($args as $arg) {
                                            if ($arg != '') {
                                                $arg_item = explode('=', $arg);
                                                $arg_pair[trim($arg_item[0])] = substr(trim($arg_item[1]), 1, -1);
                                            }
                                        }
                                        // associate the term found with its array of argument pairs
                                        $slide_dynamic_terms[$match_item] = $arg_pair;
                                    }
                                }
                            }
                        }
                    }
                    foreach ($flickr_response[$flickr_array_name]['photo'] as $image) {
                        $dynamic_slide = array();
                        // each dynamic slide will initially contain the main slide's content and settings
                        $dynamic_slide['settings'] = $slide_settings;
                        $dynamic_slide['content'] = $slide_content;
                        $dynamic_slide['position'] = $slide['position'];
                        $dynamic_slide['visibility'] = $slide['visibility'];
                        $image_owner = $dynamic_flickr_data_type == 'set' ? $flickr_response['photoset']['owner'] : $image['owner'];
                        // loop through all content fields
                        foreach ($dynamic_slide['content'] as $field_name => &$field_content) {
                            if ($field_content != '') {
                                // loop through all terms that were find in the content fields
                                foreach ($slide_dynamic_terms as $term => $term_data) {
                                    // check if the term is in the current field
                                    if (strpos($field_content, $term) !== false) {
                                        // check the type of the term
                                        $replace = '';
                                        if ($term_data['term_name'] == 'sp_image') {
                                            $image_size = isset($term_data['size']) ? $term_data['size'] : '';
                                            if ($image_size != '') {
                                                $image_size = isset($sliderpro_flickr_sizes[$image_size]) ? '_' . $sliderpro_flickr_sizes[$image_size] : '';
                                            }
                                            $replace = 'http://farm' . $image['farm'] . '.staticflickr.com/' . $image['server'] . '/' . $image['id'] . '_' . $image['secret'] . $image_size . '.jpg';
                                        } else {
                                            if ($term_data['term_name'] == 'sp_image_title') {
                                                $replace = $image['title'];
                                            } else {
                                                if ($term_data['term_name'] == 'sp_image_description') {
                                                    $replace = $image['description'];
                                                } else {
                                                    if ($term_data['term_name'] == 'sp_image_link') {
                                                        $replace = 'http://www.flickr.com/photos/' . $image_owner . '/' . $image['id'];
                                                    } else {
                                                        if ($term_data['term_name'] == 'sp_image_set' && $dynamic_flickr_data_type == 'set') {
                                                            $replace = 'http://www.flickr.com/photos/' . $image_owner . '/sets/' . $flickr_response['photoset']['id'];
                                                        } else {
                                                            if ($term_data['term_name'] == 'sp_date') {
                                                                $replace = date('F j Y', $image['dateupload']);
                                                            } else {
                                                                if ($term_data['term_name'] == 'sp_user') {
                                                                    $replace = $image['ownername'];
                                                                } else {
                                                                    if ($term_data['term_name'] == 'sp_user_link') {
                                                                        $replace = 'http://www.flickr.com/people/' . $image_owner . '/';
                                                                    } else {
                                                                        if ($term_data['term_name'] == 'sp_user_photos') {
                                                                            $replace = 'http://www.flickr.com/photos/' . $image_owner . '/';
                                                                        } else {
                                                                            if ($term_data['term_name'] == 'sp_user_sets') {
                                                                                $replace = 'http://www.flickr.com/photos/' . $image_owner . '/sets/';
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        // replace all the current terms in the field with the corresponding content
                                        $field_content = str_replace($term, $replace, $field_content);
                                    }
                                }
                                // end terms loop
                            }
                        }
                        // end fields loop
                        array_push($dynamic_slides, $dynamic_slide);
                        unset($dynamic_slide);
                    }
                    unset($slide_dynamic_terms);
                }
            }
        }
        // end if
    }
    // end foreach
    // insert the dynamic slides
    if (!empty($dynamic_slides)) {
        $dynamic_slides = array_reverse($dynamic_slides);
        $position_to_remove = -1;
        foreach ($dynamic_slides as $dynamic_slide) {
            // remove the 'static' slides that were set to be dynamic
            if ($dynamic_slide['position'] != $position_to_remove) {
                $position_to_remove = $dynamic_slide['position'];
                array_splice($slides, $position_to_remove - 1, 1);
            }
            // add the dynamic slides
            array_splice($slides, $position_to_remove - 1, 0, array($dynamic_slide));
        }
    }
    // string that will contain the javascript properties of the slider
    $slider_js_properties = "";
    // if a value is different from the default value, add it to the string
    foreach ($sliderpro_slider_settings as $name => $value) {
        if (isset($slider_settings[$name]) && isset($sliderpro_js_properties[$name])) {
            if ($slider_settings[$name] != $value['default_value']) {
                if ($slider_js_properties != "") {
                    $slider_js_properties .= ", " . PHP_EOL;
                }
                $slider_js_properties .= SP_IND_3 . sliderpro_get_js_property_name($name) . ": " . sliderpro_get_js_property_value($slider_settings[$name]);
            }
        }
    }
    // decide what javascript files will need to be included in public view
    // based on the sliders' settings
    if (!in_array('slider', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'slider');
    }
    if (sliderpro_get_setting($slider_settings, 'enable_custom_js') && !in_array($current_id, $sliderpro_custom_scripts_to_load)) {
        array_push($sliderpro_custom_scripts_to_load, $current_id);
    }
    if (sliderpro_get_setting($slider_settings, 'timer_animation') && !in_array('excanvas', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'excanvas');
    }
    if (sliderpro_get_setting($slider_settings, 'thumbnail_mouse_wheel') && !in_array('mousewheel', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'mousewheel');
    }
    if (sliderpro_get_setting($slider_settings, 'lightbox') && !in_array('lightbox', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'lightbox');
    }
    if (sliderpro_get_setting($slider_settings, 'css3_transitions') && !in_array('css3_transitions', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'css3_transitions');
    }
    if (sliderpro_get_setting($slider_settings, 'youtube_controller') && !in_array('youtube_controller', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'youtube_controller');
    }
    if (sliderpro_get_setting($slider_settings, 'vimeo_controller') && !in_array('vimeo_controller', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'vimeo_controller');
    }
    if (sliderpro_get_setting($slider_settings, 'html5_controller') && !in_array('html5_controller', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'html5_controller');
    }
    if (sliderpro_get_setting($slider_settings, 'videojs_controller') && !in_array('videojs_controller', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'videojs_controller');
    }
    if (sliderpro_get_setting($slider_settings, 'jwplayer_controller') && !in_array('jwplayer_controller', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'jwplayer_controller');
        $sliderpro_scripts_to_load['jwplayer_path'] = sliderpro_get_setting($slider_settings, 'jwplayer_path');
    }
    if (sliderpro_get_setting($slider_settings, 'effect_type') == 'swipe' && !in_array('touch_swipe', $sliderpro_scripts_to_load)) {
        array_push($sliderpro_scripts_to_load, 'touch_swipe');
    }
    // string that will contain the javascript properties of the slides
    $slides_js_properties = "";
    $index = 0;
    // loop through all the slides
    foreach ($slides as $slide) {
        $slide_settings = $slide['settings'];
        $slide_js_properties = "";
        // if a setting was marked to override the global setting, add that property to the string
        foreach ($slide_settings as $name => $value) {
            if (isset($sliderpro_js_properties[$name])) {
                if ($slide_js_properties != "") {
                    $slide_js_properties .= ", ";
                }
                $slide_js_properties .= sliderpro_get_js_property_name($name) . ": " . sliderpro_get_js_property_value($slide_settings[$name]);
            }
        }
        if ($slide_js_properties != "") {
            if ($slides_js_properties != "") {
                $slides_js_properties .= ", " . PHP_EOL;
            }
            $slides_js_properties .= SP_IND_4 . $index . ': {' . $slide_js_properties . '}';
        }
        $index++;
    }
    // create the Javascript output
    $js_string = '';
    $js_string .= PHP_EOL . '<script type="text/javascript">' . PHP_EOL;
    // append the lightbox css to the header if it's going to be used
    if (sliderpro_get_setting($slider_settings, 'lightbox') && !$sliderpro_lightbox_loaded) {
        $sliderpro_lightbox_loaded = true;
        $js_string .= SP_IND_1 . 'jQuery("<link>").attr({rel: "stylesheet", type: "text/css", media: "all", href: "' . plugins_url('/slider-pro/css/slider/prettyPhoto.css') . '"}).appendTo(jQuery("head"));' . PHP_EOL . PHP_EOL;
    }
    // append the VideoJS css to the header if it's going to be used
    if (sliderpro_get_setting($slider_settings, 'videojs_controller') && !$sliderpro_videojs_loaded) {
        $sliderpro_lightbox_loaded = true;
        $js_string .= SP_IND_1 . 'jQuery("<link>").attr({rel: "stylesheet", type: "text/css", media: "all", href: "' . plugins_url('/slider-pro/css/slider/video-js.min.css') . '"}).appendTo(jQuery("head"));' . PHP_EOL . PHP_EOL;
    }
    $js_string .= SP_IND_1 . 'jQuery(document).ready(function() {' . PHP_EOL;
    $js_string .= SP_IND_2 . 'jQuery("#slider-pro-' . $current_id . '").advancedSlider({' . PHP_EOL;
    $js_string .= $slider_js_properties;
    if ($slides_js_properties != '') {
        if ($slider_js_properties != '') {
            $js_string .= ', ' . PHP_EOL;
        }
        $js_string .= SP_IND_3 . 'slideProperties: {' . PHP_EOL . $slides_js_properties . PHP_EOL . SP_IND_3 . '}' . PHP_EOL;
    } else {
        $js_string .= PHP_EOL;
    }
    $js_string .= SP_IND_2 . '});' . PHP_EOL;
    $js_string .= SP_IND_1 . '});' . PHP_EOL;
    $js_string .= '</script>' . PHP_EOL;
    // to be printed in foother
    $sliderpro_sliders_js .= $js_string;
    $slider_classes = sliderpro_get_setting($slider_settings, 'custom_class') != '' ? 'advanced-slider ' . sliderpro_get_setting($slider_settings, 'custom_class') : 'advanced-slider';
    // create the HTML output
    $html_string = '';
    $html_string .= '<div class="' . $slider_classes . '" id="slider-pro-' . $current_id . '" tabindex="0">' . PHP_EOL;
    $html_string .= SP_IND_1 . '<ul class="slides">' . PHP_EOL;
    $slider_width = sliderpro_get_setting($slider_settings, 'width');
    $slider_height = sliderpro_get_setting($slider_settings, 'height');
    foreach ($slides as $slide) {
        if (isset($slide['visibility']) && $slide['visibility'] == 'disabled') {
            continue;
        }
        $slide_content = $slide['content'];
        $slide_settings = $slide['settings'];
        $slide_width = sliderpro_get_setting($slider_settings, 'slide_resizing_width') == 'auto' ? strpos($slider_width, '%') ? 500 : $slider_width : sliderpro_get_setting($slider_settings, 'slide_resizing_width');
        $slide_height = sliderpro_get_setting($slider_settings, 'slide_resizing_height') == 'auto' ? strpos($slider_height, '%') ? 300 : $slider_height : sliderpro_get_setting($slider_settings, 'slide_resizing_height');
        $timthumb_image_path = get_option('slider_pro_enable_timthumb') && sliderpro_get_setting($slider_settings, 'slide_resizing_resize') ? esc_attr(plugins_url('/slider-pro/includes/timthumb/timthumb.php') . '?q=' . sliderpro_get_setting($slider_settings, 'slide_resizing_quality') . '&w=' . $slide_width . '&h=' . $slide_height . '&a=' . sliderpro_get_setting($slider_settings, 'slide_resizing_align') . '&zc=' . sliderpro_get_setting($slider_settings, 'slide_resizing_crop') . '&src=') : '';
        $timthumb_thumbnails_path = get_option('slider_pro_enable_timthumb') && sliderpro_get_setting($slider_settings, 'thumbnail_resizing_resize') ? esc_attr(plugins_url('/slider-pro/includes/timthumb/timthumb.php') . '?q=' . sliderpro_get_setting($slider_settings, 'thumbnail_resizing_quality') . '&w=' . sliderpro_get_setting($slider_settings, 'thumbnail_width') . '&h=' . sliderpro_get_setting($slider_settings, 'thumbnail_height') . '&a=' . sliderpro_get_setting($slider_settings, 'thumbnail_resizing_align') . '&zc=' . sliderpro_get_setting($slider_settings, 'thumbnail_resizing_crop') . '&src=') : '';
        $lazy_loaded_image = $slide_content['image'] != '' && sliderpro_get_setting($slider_settings, 'lazy_loading') ? 'data-image="' . $timthumb_image_path . $slide_content['image'] . '"' : '';
        $html_string .= SP_IND_2 . '<li class="slide" ' . $lazy_loaded_image . '>' . PHP_EOL;
        // get the link specified for the slide
        $slide_link_path = sliderpro_get_slide_content($slide_content, 'slide_link_path');
        if ($slide_link_path != '') {
            $slide_link_target = sliderpro_get_slide_setting($slide_settings, 'slide_link_target', 'extra');
            $slide_link_title = sliderpro_get_slide_content($slide_content, 'slide_link_title', true);
            $slide_link_title = $slide_link_title != '' ? ' title="' . $slide_link_title . '"' : '';
            $slide_lightbox_content = sliderpro_get_slide_setting($slide_settings, 'slide_link_lightbox', 'extra') ? sliderpro_get_setting($slider_settings, 'lightbox_gallery') ? ' rel="slider-lightbox[slider-pro-slide-' . $current_id . ']"' : ' rel="slider-lightbox"' : '';
            $html_string .= SP_IND_3 . '<a' . $slide_lightbox_content . ' href="' . $slide_link_path . '" target="' . $slide_link_target . '"' . $slide_link_title . ' tabindex="-1">' . PHP_EOL;
        }
        // get the slide image
        $slide_image = sliderpro_get_slide_content($slide_content, 'image');
        if ($slide_image != '') {
            $slide_image = $lazy_loaded_image == '' ? $timthumb_image_path . $slide_image : '';
            $slide_title = sliderpro_get_slide_content($slide_content, 'title', true);
            $slide_title = $slide_title != '' ? ' title="' . $slide_title . '"' : '';
            $image_indentation = $slide_link_path != '' ? SP_IND_4 : SP_IND_3;
            $slide_alt = sliderpro_get_slide_content($slide_content, 'alt', true);
            $html_string .= $image_indentation . '<img class="image" src="' . $slide_image . '" alt="' . $slide_alt . '"' . $slide_title . '/>' . PHP_EOL;
        }
        // end the slide link
        if ($slide_link_path != '') {
            $html_string .= SP_IND_3 . '</a>' . PHP_EOL;
        }
        // get the slide caption
        $slide_caption = sliderpro_get_slide_content($slide_content, 'caption');
        if ($slide_caption != '') {
            $html_string .= SP_IND_3 . '<div class="caption">' . do_shortcode(sliderpro_decode($slide_caption, true, true)) . '</div>' . PHP_EOL;
        }
        // get the slide inline HTML content
        $slide_html = sliderpro_get_slide_content($slide_content, 'html');
        if ($slide_html != '') {
            $html_string .= SP_IND_3 . '<div class="html">' . do_shortcode(sliderpro_decode($slide_html, true, true)) . '</div>' . PHP_EOL;
        }
        // get the thumbnail type
        $thumbnail_type = sliderpro_get_setting($slider_settings, 'thumbnail_type');
        if ($thumbnail_type != 'none') {
            // get the thumbnail image
            $thumbnail_path = sliderpro_get_slide_content($slide_content, 'thumbnail_image') != '' ? $slide_content['thumbnail_image'] : $slide_content['image'];
            if ($thumbnail_path != '') {
                $thumbnail_title = sliderpro_get_slide_content($slide_content, 'thumbnail_title', true);
                $thumbnail_title = $thumbnail_title != '' ? ' title="' . $thumbnail_title . '"' : '';
                $thumbnail_link_path = sliderpro_get_slide_content($slide_content, 'thumbnail_link_path');
                $thumbnail_indentation = $thumbnail_link_path != '' ? SP_IND_4 : SP_IND_3;
                // get the thumbnail link
                if ($thumbnail_link_path != '') {
                    $thumbnail_link_target = sliderpro_get_slide_setting($slide_settings, 'thumbnail_link_target');
                    $thumbnail_link_title = sliderpro_get_slide_content($slide_content, 'thumbnail_link_title', true);
                    $thumbnail_link_title = $thumbnail_link_title != '' ? ' title="' . $thumbnail_link_title . '"' : '';
                    $thumbnail_lightbox_content = sliderpro_get_slide_setting($slide_settings, 'thumbnail_link_lightbox', 'extra') ? sliderpro_get_setting($slider_settings, 'lightbox_gallery') ? ' rel="slider-lightbox[slider-pro-thumbnail-' . $current_id . ']"' : ' rel="slider-lightbox"' : '';
                    $html_string .= SP_IND_3 . '<a' . $thumbnail_lightbox_content . ' href="' . $thumbnail_link_path . '" target="' . $thumbnail_link_target . '"' . $thumbnail_link_title . ' tabindex="-1">' . PHP_EOL;
                }
                $thumbnail_alt = sliderpro_get_slide_content($slide_content, 'thumbnail_alt', true);
                $html_string .= $thumbnail_indentation . '<img class="thumbnail" src="' . $timthumb_thumbnails_path . $thumbnail_path . '" alt="' . $thumbnail_alt . '"' . $thumbnail_title . '/>' . PHP_EOL;
                // end the thumbnail link
                if ($thumbnail_link_path != '') {
                    $html_string .= SP_IND_3 . '</a>' . PHP_EOL;
                }
            }
        }
        $html_string .= SP_IND_2 . '</li>' . PHP_EOL;
    }
    $html_string .= SP_IND_1 . '</ul>' . PHP_EOL;
    $html_string .= '</div>';
    return PHP_EOL . PHP_EOL . $html_string . PHP_EOL . PHP_EOL;
}
}
unset($set_settings);
?>
				</table>
				
            </div>
			
			
			<div id="slide-type-<?php 
echo $counter;
?>
">
				
				<div class="slide-type-indicator">
					<?php 
$slide_type = sliderpro_get_slide_setting($slide_settings, 'slide_type', 'dynamic');
?>
					
					<label title="slide_type"><?php 
_e('Slide Type', 'slider_pro');
?>
</label>
				
					<select name="slide[<?php 
echo $counter;
?>
][settings][slide_type]" class="slide-type">
						<?php 
$list = sliderpro_get_settings_list('slide_types');
foreach ($list as $entry) {
    $selected = $slide_type == $entry ? ' selected="selected"' : '';