function admin_print_styles()
 {
     wp_enqueue_style('wp-jquery-ui-dialog');
     wp_enqueue_style('rs-codemirror');
     wp_enqueue_style('rs-codemirror-theme');
     wp_enqueue_style('rs-codemirror-theme-elegant');
     wp_enqueue_style('jquery-rs-qtip-css');
     wp_enqueue_style('new-rs-jquery-ui');
     wp_enqueue_style('thickbox');
     wp_enqueue_style("new-royalslider-admin");
     $skins = NewRoyalSliderOptions::getRsSkins();
     foreach ($skins as $key => $value) {
         wp_enqueue_style('new-rs-skin-' . $key);
     }
     $templates = NewRoyalSliderOptions::getRsTemplates();
     foreach ($templates as $key => $value) {
         if (isset($value['template-css'])) {
             wp_enqueue_style('new-rs-template-' . $key);
         }
     }
     wp_enqueue_style('new-royalslider-default-skin-css');
 }
    static function generateSlides($fetch_data, $refresh_cache, $id, $type, $markup = null, $slides = null, $options = null, $template = null, $skin = null, $disable_cache = false)
    {
        $arr = false;
        $refresh_hours = NewRoyalSliderMain::$refresh_hours;
        if (!$disable_cache) {
            if ($refresh_hours > 0) {
                $disable_cache = false;
            } else {
                $disable_cache = true;
            }
        }
        if (!$disable_cache) {
            $transient_key = NewRoyalSliderMain::get_transient_key($id, $type);
            if (!$id) {
                $refresh_cache = true;
            }
            if ($refresh_cache) {
                // delete cached version
                delete_transient($transient_key);
            } else {
                $arr = get_transient($transient_key);
            }
        }
        if ($arr === false) {
            if ($fetch_data) {
                if ($type != 'nextgen') {
                    $rsdata = NewRoyalSliderMain::query_slider_data($id);
                } else {
                    $rsdata = NewRoyalSliderMain::query_nextgen_slider_config();
                }
                if (!$rsdata || !$rsdata[0]) {
                    if ($type == 'nextgen') {
                        return NewRoyalSliderMain::frontend_error(__('NextGEN configuration not found. Likely you just haven\'t created it yet, please go to "RoyalSlider admin page > Create New Slider > NextGEN config" and create it.', 'new_royalslider'));
                    } else {
                        return NewRoyalSliderMain::frontend_error(__('Incorrect RoyalSlider ID or problem with query.', 'new_royalslider'));
                    }
                }
                $rsdata = $rsdata[0];
                $rsdata = apply_filters('new_rs_slider_data', $rsdata);
                $type = $rsdata['type'];
                $markup = $rsdata['template_html'];
                if (!$slides) {
                    $slides = $rsdata['slides'];
                }
                $options = $rsdata['options'];
                $template = $rsdata['template'];
                $skin = $rsdata['skin'];
            }
            if (!is_array($slides)) {
                $slides = json_decode($slides, ARRAY_A);
            }
            if (!class_exists('Mustache_Autoloader')) {
                require_once NEW_ROYALSLIDER_PLUGIN_PATH . 'lib/Mustache/Autoloader.php';
            }
            require_once NEW_ROYALSLIDER_PLUGIN_PATH . 'classes/NewRoyalSliderOptions.php';
            Mustache_Autoloader::register();
            $m = new Mustache_Engine(array('escape' => array('NewRoyalSliderGenerator', 'escapeMustache')));
            $css_id = 'new-royalslider-' . $id;
            $t = NewRoyalSliderOptions::getRsTemplates();
            $add_js = '';
            $curr_template;
            $selector = '';
            if (!isset($t[$template])) {
                $template = ' noTemplate';
            } else {
                $curr_template = $t[$template];
                if (isset($curr_template['add_js'])) {
                    $add_js = $curr_template['add_js'];
                    $add_js = str_replace('{{selector}}', '.' . $css_id, $add_js);
                }
                $template = ' ' . $curr_template['template-css-class'];
            }
            if ($options) {
                if (!is_array($options)) {
                    $options = json_decode($options, ARRAY_A);
                } else {
                }
                $gen_opts = self::preParseOpts($options);
                if (isset($options['sopts'])) {
                    $o = array_merge($options, $options['sopts']);
                    $to_unset = array('sopts', 'posts', 'rs_500px', 'flickr', 'rs_instagram');
                    foreach ($to_unset as $key => $value) {
                        if (isset($o[$value])) {
                            unset($o[$value]);
                        }
                    }
                    foreach ($o as $key => $option) {
                        if (is_array($option)) {
                            foreach ($option as $subkey => $suboption) {
                                if (is_numeric($suboption)) {
                                    $o[$key][$subkey] = (double) $suboption;
                                }
                            }
                        } else {
                            if (is_numeric($option)) {
                                $o[$key] = (double) $option;
                            }
                        }
                    }
                    //return;
                    $init_opts = json_encode($o);
                    $init_opts = str_replace(':"true"', ':!0', $init_opts);
                    $init_opts = str_replace(':"false"', ':!1', $init_opts);
                    $init_opts = str_replace('"', '\'', $init_opts);
                    $init_opts = str_replace(',\'', ',', $init_opts);
                    $init_opts = str_replace('\':', ':', $init_opts);
                    $init_opts = str_replace('{\'', '{', $init_opts);
                } else {
                    $init_opts = $options;
                }
            } else {
                $options = array();
                $gen_opts = self::preParseOpts(null);
                $init_opts = '';
            }
            $js_init_code = "\t\$('." . $css_id . "').royalSlider(" . $init_opts . ");\n" . $add_js;
            if (!isset($skin)) {
                $skin = 'rsDefault';
            }
            $skin = ' ' . $skin;
            $out = '';
            if (NewRoyalSliderMain::$include_style_tag) {
                if ($gen_opts['thumb_width'] != 96 || $gen_opts['thumb_height'] != 72) {
                    $out .= "\n<style type=\"text/css\">\n";
                    $out .= '.' . $css_id . ' .rsThumbsHor { height:' . $gen_opts['thumb_height'] . 'px; }' . "\n";
                    $out .= '.' . $css_id . ' .rsThumbsVer { width:' . $gen_opts['thumb_width'] . 'px; } 
			.' . $css_id . ' .rsThumb { width: ' . $gen_opts['thumb_width'] . 'px; height: ' . $gen_opts['thumb_height'] . 'px; }';
                    $out .= "\n</style>\n";
                }
            }
            if (isset($curr_template) && isset($curr_template['wrapHTML'])) {
                $out .= str_replace('%width%', $gen_opts['width'], $curr_template['wrapHTML']['before']);
            }
            $options['id'] = $id;
            $slides = apply_filters('new_rs_slides_filter', $slides, $options, $type);
            if ($type === 'custom') {
                require_once 'renderers/DefaultRenderer.php';
            } else {
                if ($type === 'gallery') {
                    require_once 'renderers/PostGalleryRenderer.php';
                } else {
                    if ($type === 'flickr' || $type === '500px') {
                        require_once 'renderers/CustomSourceRenderer.php';
                    } else {
                        if ($type === 'posts') {
                            require_once 'renderers/PostsListRenderer.php';
                        } else {
                            if ($type === 'nextgen') {
                                require_once 'renderers/NextGenRenderer.php';
                            } else {
                                if ($type === 'instagram') {
                                    require_once 'renderers/InstagramRenderer.php';
                                }
                            }
                        }
                    }
                }
            }
            if (is_array($slides) && count($slides) > 0) {
                $width = $gen_opts['width'];
                if (is_numeric($width)) {
                    $width .= 'px';
                }
                if ($width) {
                    $width = 'width:' . $width . ';';
                } else {
                    $width = '';
                }
                $height = $gen_opts['height'];
                if (is_numeric($height)) {
                    $height .= 'px';
                }
                if ($height) {
                    $height = 'height:' . $height . ';';
                } else {
                    $height = '';
                }
                $out .= '<div id="' . $css_id . '" class="royalSlider ' . $css_id . $skin . $template . '" style="' . $width . $height . ';">' . "\n";
                foreach ($slides as $key => $slide) {
                    if ($type === 'custom') {
                        $renderer = new NewRoyalSliderDefaultRenderer($slide, $gen_opts, $options);
                    } else {
                        if ($type === 'gallery') {
                            $renderer = new NewRoyalSliderPostGalleryRenderer($key, $slide, $gen_opts, $options);
                        } else {
                            if ($type === 'flickr' || $type === '500px') {
                                $renderer = new NewRoyalSliderCustomSourceRenderer($slide, $gen_opts, $options);
                            } else {
                                if ($type === 'posts') {
                                    $renderer = new NewRoyalSliderPostsRenderer($slide, $gen_opts, $options);
                                } else {
                                    if ($type === 'nextgen') {
                                        $renderer = new NewRoyalSliderNextGenRenderer($slide, $gen_opts, $options);
                                    } else {
                                        if ($type === 'instagram') {
                                            $renderer = new NewRoyalSliderInstagramRenderer($slide, $gen_opts, $options);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    $m->getHelpers()->clear();
                    apply_filters('new_rs_slides_renderer_helper', $m, $slide, $options);
                    $out .= $m->render($markup, $renderer) . "\n";
                }
                $out = apply_filters('new_rs_slides_output_before_end', $out, $id, $type);
                $out .= "\n" . '</div>' . "\n";
            } else {
                if ($type !== 'posts') {
                    $error_message = print_r($slides, true);
                    if (strlen($error_message) > 5) {
                        $out .= NewRoyalSliderMain::frontend_error(print_r($slides, true));
                    } else {
                        $out .= NewRoyalSliderMain::frontend_error(__('Slides are missing. ', 'new_royalslider') . print_r($slides, true));
                    }
                } else {
                    $out .= NewRoyalSliderMain::frontend_error(__('No posts found matching your criteria.', 'new_royalslider'));
                }
            }
            if (isset($curr_template) && isset($curr_template['wrapHTML'])) {
                $out .= $curr_template['wrapHTML']['after'];
            }
            if ($type != '500px' && $type != 'flickr' && $type != 'instagram') {
                $pattern = '\\[(\\[?)(gallery|new_royalslider)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
                preg_match_all('/' . $pattern . '/s', $out, $matches);
                $out = preg_replace_callback("/{$pattern}/s", array('NewRoyalSliderGenerator', 'strip_shortcode_tag'), $out);
                $out = do_shortcode($out);
            }
            $arr = array('out' => $out, 'js_init' => $js_init_code);
            if (!$disable_cache) {
                set_transient($transient_key, $arr, 60 * 60 * $refresh_hours);
            }
        }
        NewRoyalSliderMain::register_slider($id, $arr['js_init']);
        return $arr['out'];
    }
 function frontend_styles()
 {
     global $wpdb;
     $table = self::get_sliders_table_name();
     if (count($this->sliders_to_enqueue) > 0 || $this->load_all) {
         $this->has_slider_on_page = true;
         $qstr = " \r\n\t\t\t\tSELECT id, skin, template FROM {$table} WHERE active=1\r\n\t\t\t";
         if (!$this->load_all) {
             $ids = '(';
             foreach ($this->sliders_to_enqueue as $key => $value) {
                 if ($key != 0) {
                     $ids .= ',';
                 }
                 $ids .= (int) $value;
             }
             $ids .= ')';
             $qstr .= " AND id IN {$ids} ";
         }
         $res = $wpdb->get_results($qstr, ARRAY_A);
         require_once 'NewRoyalSliderOptions.php';
         $templates = NewRoyalSliderOptions::getRsTemplates();
         $skins = NewRoyalSliderOptions::getRsSkins();
         foreach ($res as $key => $slider_data) {
             // skins
             if (isset($slider_data['skin']) && isset($skins[$slider_data['skin']])) {
                 $this->push_style($slider_data['skin'], $skins[$slider_data['skin']]['path']);
             }
             // templates
             if (isset($slider_data['template']) && isset($templates[$slider_data['template']])) {
                 $template = $templates[$slider_data['template']];
                 if (isset($template['template-css'])) {
                     $this->push_style($slider_data['template'], $template['template-css']);
                 }
             }
         }
     }
     if (count($this->styles) > 0) {
         wp_register_style('new-royalslider-core-css', NEW_ROYALSLIDER_PLUGIN_URL . 'lib/royalslider/royalslider.css', false, NEW_ROYALSLIDER_WP_VERSION, 'all');
         wp_enqueue_style('new-royalslider-core-css');
     }
     foreach ($this->styles as $key => $style) {
         wp_register_style($key . '-css', $style, array('new-royalslider-core-css'), NEW_ROYALSLIDER_WP_VERSION, 'all');
         wp_enqueue_style($key . '-css');
     }
 }
        function build_view()
        {
            ?>

<div id="new-royalslider-edit-page" class="wrap">
    <h2 id="edit-slider-text"><span>

    <?php 
            if ($this->slider_type != 'nextgen') {
                ?>
        <?php 
                if (!$this->is_add_new) {
                    if ($this->slider_id) {
                        echo sprintf(__('Editing %s RoyalSlider #', 'new_royalslider'), ucfirst($this->slider_type));
                        echo '<span>';
                        echo $this->slider_id;
                        echo '</span>';
                    }
                    ?>
        <?php 
                } else {
                    ?>
                <?php 
                    echo sprintf(__('New %s RoyalSlider', 'new_royalslider'), ucfirst($this->slider_type));
                    ?>
        <?php 
                }
                ?>
    <?php 
            } else {
                ?>
        <?php 
                _e('NextGEN template configuration', 'new_royalslider');
                if ($this->slider_id) {
                    echo ' #<span>';
                    echo $this->slider_id;
                    echo '</span>';
                }
                ?>
    <?php 
            }
            ?>
       </span>
       <a href="#" class="add-new-h2 rs-embed-to-site <?php 
            echo $this->slider_id ? '' : 'rs-hidden';
            ?>
"><?php 
            _e('Embed this slider to site', 'new_royalslider');
            ?>
</a>
       <a href="admin.php?page=new_royalslider" class="add-new-h2"><?php 
            _e('Back to list', 'new_royalslider');
            ?>
</a>
       
    </h2>
    <?php 
            echo NewRoyalSliderMain::get_embed_help_block($this->slider_id ? $this->slider_id : 123);
            ?>
    <div id="poststuff" class="metabox-holder has-right-sidebar">

        <div id="side-info-column" class="options-sidebar">
            <div id="slider-actions" class="postbox action actions-holder"> 
                <?php 
            if ($this->slider_type != 'gallery' && $this->slider_type != 'nextgen') {
                ?>
                            
                    <a class="alignleft button-secondary button80" id="preview-slider" href="#"><?php 
                _e('Preview slider', 'new_royalslider');
                ?>
</a>
                <?php 
            }
            ?>

                    <div id="save-progress" class="waiting ajax-saved" >
                        <?php 
            _e('Saved!', 'new_royalslider');
            ?>
                    </div>
                    <a class="alignright button-primary button80" id="save-slider" data-slider-id="<?php 
            echo $this->slider_id;
            ?>
" data-create="<?php 
            echo $this->slider_id ? 'false' : 'true';
            ?>
" data href="#"><?php 
            if ($this->slider_id) {
                _e('Save slider', 'new_royalslider');
            } else {
                _e('Create slider', 'new_royalslider');
            }
            ?>
</a>   
                <br class="clear">              
            </div>
                        
            <div id="new-royalslider-options">
                <div class="postbox open">    
                    <div class="handlediv" title="Toggle view"></div>           
                    <h3 class="hndle"><?php 
            _e('General options', 'new_royalslider');
            ?>
</h3> 
                    <div class="inside slider-opts-group">
                                             <div class="rs-opt">
                                                <div data-help="<?php 
            _e('Template resets all slider settings to create specific type of slideshow. After you set it you may (optionally) modify other options to fit your requirements.<br/><br/> Please note that most templates (except first one) add additional CSS file and change slide HTML markup, so some options might requre minor CSS modifications.', 'new_royalslider');
            ?>
" class="rs-template-title rs-help-el"><span id="rs-template-title-text"><?php 
            _e('Templates', 'new_royalslider');
            ?>
</span><i class="help-ico"></i></div>
                                                <div id="template-select" class="templates-grid">
                                                    <?php 
            require_once 'NewRoyalSliderOptions.php';
            $newrs_templates = NewRoyalSliderOptions::getRsTemplates();
            $value = isset($this->res['template']) ? $this->res['template'] : 'default';
            $template_obj = $newrs_templates[$value];
            $template_html = isset($template_obj['template-html']) ? $template_obj['template-html'] : $newrs_templates['default']['template-html'];
            $col = 0;
            $row = 0;
            foreach ($newrs_templates as $key => $args) {
                $label = $args['label'];
                //$label
                echo sprintf('<div class="rs-template"><input id="%s" type="radio" name="template" value="%s" %s><label style="background-position: %s ;" for="%s">%s</label></div>', $key, $key, checked($value, $key, false), '-' . $col * 89 . 'px -' . ($row * 65 + 100) . 'px', $key, '');
                $col++;
                if ($col > 1) {
                    $col = 0;
                    $row++;
                }
            }
            ?>
                                                </div>
                                            </div>
                                            <hr>
                                            <div class="rs-opt">
                                                <div data-help="<?php 
            _e('Skin is a set of CSS styled UI controls.', 'new_royalslider');
            ?>
" class="rs-template-title rs-skin-title rs-help-el"><?php 
            _e('Skin', 'new_royalslider');
            ?>
<i class="help-ico"></i></div>
                                                <select id="skin-select">
                                                    <?php 
            require_once 'NewRoyalSliderOptions.php';
            $newrs_skins = NewRoyalSliderOptions::getRsSkins();
            $value = isset($this->res['skin']) ? $this->res['skin'] : 'rsUni';
            foreach ($newrs_skins as $key => $args) {
                $label = $args['label'];
                echo sprintf('<option value="%s"%s>%s</option>', $key, selected($value, $key, false), $label);
            }
            ?>
                                                </select>
                                                <a href="http://help.dimsemenov.com/kb/wordpress-royalslider-advanced/wp-adding-custom-skin-without-modifying-core-of-slider" target="_blank" style="color: #888; display:block; margin-top: 5px;"><?php 
            _e('how to add custom skin');
            ?>
</a>
                                            </div>
                                            <hr>
                                            <a id="edit-slide-markup" class="in-page-action" href="#"><?php 
            _e('Edit slide markup', 'new_royalslider');
            ?>
</a>

                    </div>
                </div>
                <div class="other-options">
                     <?php 
            $this->get_slider_options();
            ?>
                </div>
            </div>        
        </div>

       
        <div class="sortable-slides-body">                              
            <div class="sortable-slides-container">
                <div id="titlediv">
                    <div id="titlewrap">           
                        <input type="text" name="title" size="40" maxlength="255" placeholder="<?php 
            _e('Slider name', 'new_royalslider');
            ?>
" id="title" value="<?php 
            echo isset($this->res) ? $this->res['name'] : '';
            ?>
" />
                    </div>
                </div>
                <div id="template-editor" style="display:none;">
                    <textarea style="width: 80%; height: 200px;"><?php 
            echo isset($this->res['template_html']) ? esc_html($this->res['template_html']) : esc_html($template_html);
            ?>
</textarea>
                </div>
                <input id="admin-slider-type" type="hidden" value="<?php 
            echo isset($_REQUEST['rstype']) ? $_REQUEST['rstype'] : '';
            ?>
" />
                <?php 
            if ($this->slider_type == 'custom') {
                ?>
                    <div class="rs-add-slides-wrap">
                        <a class="button" id="create-new-slide" href="#"><?php 
                _e('Create New Slide', 'new_royalslider');
                ?>
</a> or 
                        <a class="button" id="add-images" href="#"><?php 
                _e('Add Images', 'new_royalslider');
                ?>
</a>
                    </div>

                    <div id="rs-be" style="display:none;" class="with-animation-options">
                        <div id="rs-be-buttons">
                            <button class="button button-primary rs-be-add-html-block"><?php 
                _e('Add HTML block', 'new_royalslider');
                ?>
</button>or
                            <button class="button rs-be-add-image-block"><?php 
                _e('Add image', 'new_royalslider');
                ?>
</button>
                        </div>

                        <div class="rs-ab-props">
                            <label for="block-classes-select" class="rs-help-el" data-align="top" data-help="<?php 
                _e('CSS class that is applied to selected block.', 'new_royalslider');
                ?>
"><?php 
                _e('Block CSS class:', 'new_royalslider');
                ?>
</label>
                            <select id="block-classes-select">
                                <option value=''><?php 
                _e('No class', 'new_royalslider');
                ?>
</option>
                            <?php 
                $anim_block_classes = array('abBlackBox', 'abWhiteBox', 'abTextAlignCenter');
                //$anim_block_classes = array('testClass1', 'testClass2');
                $saved_items = get_option("new_royalslider_anim_block_classes");
                if (is_array($saved_items)) {
                    $anim_block_classes = array_merge($anim_block_classes, $saved_items);
                }
                $anim_block_classes = apply_filters('new_royalslider_animated_block_classes', $anim_block_classes);
                foreach ($anim_block_classes as $key => $value) {
                    ?>
                                    <option value='<?php 
                    echo $value;
                    ?>
'><?php 
                    echo $value;
                    ?>
</option>
                                    <?php 
                }
                ?>
                                <option value='rs_add_user_class'><?php 
                _e('>> Add new class <<', 'new_royalslider');
                ?>
</option>
                                <option value='rs_remove_user_class'><?php 
                _e('>> Remove class <<', 'new_royalslider');
                ?>
</option>
                            </select>
                            <label for="rs-a-b-animEnabled" class=" animation-cb">
                                <input id="rs-a-b-animEnabled" type="checkbox" value="true" checked="checked" />
                                <?php 
                _e('Use block animation', 'new_royalslider');
                ?>
                            </label>
                            <i class="help-ico rs-help-el"  class="rs-help-el" data-align="top" data-help="<?php 
                echo esc_attr(__('Leave animation fields empty to use default settings that are defined in right sidebar options.<br/>Please don\'t overuse animation. Use it wisely and only when it
                            \'s really required.', 'new_royalslider'));
                ?>
"></i>
                        </div>
                        <div class="clear"></div>
                        <div class="rs-be-blocks-list"></div>
                        <div class="rs-anim-blocks-inputs">
                            
                            <div class="rs-be-editorarea"><textarea></textarea></div>
                            <div class="size-fields">
                                <div>
                                    <label for="rs-a-b-width" class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Width in pixels, percents or auto.<br/> e.g. \'123px\', \'50%\' or \'auto\'. ', 'new_royalslider'));
                ?>
"><?php 
                _e('Width', 'new_royalslider');
                ?>
</label>
                                    <input id="rs-a-b-width" value="" />
                                </div>
                                <div>
                                    <label for="rs-a-b-height" class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Height in pixels, percents or auto.<br/> e.g. \'123px\', \'50%\' or \'auto\'. ', 'new_royalslider'));
                ?>
"><?php 
                _e('Height', 'new_royalslider');
                ?>
</label>
                                    <input id="rs-a-b-height" value="" />
                                </div>

                                <div>
                                    <label for="rs-a-b-left" class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Distance from left in pixels, percents or auto.<br/> e.g. \'123px\', \'50%\' or \'auto\'. ', 'new_royalslider'));
                ?>
"><?php 
                _e('Left', 'new_royalslider');
                ?>
</label>
                                    <input id="rs-a-b-left" value="" />
                                </div>
                                <div>
                                    <label for="rs-a-b-right" class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Distance from right in pixels, percents or auto.<br/> e.g. \'123px\', \'50%\' or \'auto\'. ', 'new_royalslider'));
                ?>
"><?php 
                _e('Right', 'new_royalslider');
                ?>
</label>
                                    <input id="rs-a-b-right" value="" />
                                </div>
                                <div >
                                    <label for="rs-a-b-top" class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Distance from top in pixels, percents or auto.<br/> e.g. \'123px\', \'50%\' or \'auto\'. ', 'new_royalslider'));
                ?>
"><?php 
                _e('Top', 'new_royalslider');
                ?>
</label>
                                    <input id="rs-a-b-top" value="" />
                                </div>
                                <div>
                                    <label  class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Distance from bottom in pixels, percents or auto.<br/> e.g. \'123px\', \'50%\' or \'auto\'. ', 'new_royalslider'));
                ?>
" for="rs-a-b-bottom"><?php 
                _e('Bottom', 'new_royalslider');
                ?>
</label>
                                    <input id="rs-a-b-bottom" value="" />
                                </div>
                            </div>
                        </div>
                        <div class="transition-fields rs-anim-blocks-inputs">
                            <div>
                                <label for="rs-a-b-speed" class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Animation speed of block.', 'new_royalslider'));
                ?>
"><?php 
                _e('Speed', 'new_royalslider');
                ?>
</label>
                                <input id="rs-a-b-speed" value="300" />
                            </div>
                            <div class="rs-be-fade-effect">
                                <label for="rs-a-b-fade-effect">
                                <input id="rs-a-b-fade-effect" type="checkbox" checked="checked" value="true" />
                                <?php 
                _e('Fade in', 'new_royalslider');
                ?>
</label>
                            </div>
                            <div>
                                <label for="rs-a-b-move-offset"  class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Distance for move animation.', 'new_royalslider'));
                ?>
"><?php 
                _e('Move offset', 'new_royalslider');
                ?>
</label>
                                <input id="rs-a-b-move-offset" value="300" />
                            </div>
                            <div>
                                <label for="rs-a-b-move-effect" class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Move/slide animation', 'new_royalslider'));
                ?>
"><?php 
                _e('Move effect', 'new_royalslider');
                ?>
</label>
                                <select id="rs-a-b-move-effect">
                                    <option value="left"><?php 
                _e('From left', 'new_royalslider');
                ?>
</option>
                                    <option value="right"><?php 
                _e('From right', 'new_royalslider');
                ?>
</option>
                                    <option value="top"><?php 
                _e('From top', 'new_royalslider');
                ?>
</option>
                                    <option value="bottom"><?php 
                _e('From bottom', 'new_royalslider');
                ?>
</option>
                                    <option value="none"><?php 
                _e('None', 'new_royalslider');
                ?>
</option>
                                </select>
                            </div>
                            <div>
                                <label for="rs-a-b-delay" class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Delay before block shows up. Leave field empty or set to AUTO to use default sequential delay.', 'new_royalslider'));
                ?>
"><?php 
                _e('Delay', 'new_royalslider');
                ?>
</label>
                                <input id="rs-a-b-delay" value="400" />
                            </div>
                            <div>
                                <label for="rs-a-b-easing"  class="rs-help-el" data-help="<?php 
                echo esc_attr(__('Easing function for animation', 'new_royalslider'));
                ?>
"><?php 
                _e('Easing', 'new_royalslider');
                ?>
</label>
                                <select id="rs-a-b-easing">
                                    <option value="easeOutSine"><?php 
                _e('easeOutSine', 'new_royalslider');
                ?>
</option>
                                    <option value="easeInOutSine"><?php 
                _e('easeInOutSine', 'new_royalslider');
                ?>
</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div id="rs-no-slides-block">
                        <h2><?php 
                _e("You don't have any slides", 'new_royalslider');
                ?>
</h2>
                        <p><?php 
                _e("Get started by adding slides via buttons above or watch <a target=\"_blank\" href=\"http://help.dimsemenov.com/kb/wordpress-royalslider-tutorials/wp-creating-custom-slider\">introductory video</a>.", 'new_royalslider');
                ?>
</p>
                    </div>
                    <div id="new-rs-slides">
                         <?php 
                $this->get_slider_items();
                ?>
                    </div> 
                <?php 
            } else {
                if ($this->slider_type === 'gallery') {
                    ?>
                    <div class="rs-info">
                        <p class="rs-awesome-paragraph"><?php 
                    _e('Here you can create configuration of RoyalSlider that will override default WordPress gallery, and can be added only inside post.', 'new_royalslider');
                    ?>
</p>

                        <div class="help-video"><a class="in-page-action" target="_blank" href="http://help.dimsemenov.com/kb/wordpress-royalslider-tutorials/wp-creating-royalslider-from-images-attached-to-post"><?php 
                    _e('View help video about how to create such slider', 'new_royalslider');
                    ?>
</a></div><br/>
                        <p>Or follow these steps:</p>
                        <ol>
                            <li><?php 
                    _e('Enter name for slider.', 'new_royalslider');
                    ?>
</li>
                            <li><?php 
                    _e('Configure slider options at right side, most of time you just need to change "Template" and "Skin" options.', 'new_royalslider');
                    ?>
</li>
                            <li><?php 
                    _e('Click create(save) slider button.', 'new_royalslider');
                    ?>
</li>
                            <li><?php 
                    _e('Go to any post and insert default WordPress gallery as usually.', 'new_royalslider');
                    ?>
</li>
                            <li><?php 
                    _e('Switch to Text(HTML) tab in post content editor and add <code>royalslider="SLIDER_ID"</code> attribute to gallery shortcode, where <code>SLIDER_ID</code> is id of slider that you\'re editing now.<br/>For example if ID of your slider is 3: <code>[gallery ids="24,22"]</code> should be changed to <code>[gallery royalslider="3"  ids="24,22"]</code>.', 'new_royalslider');
                    ?>
</li>
                            <li><?php 
                    _e('Optionally change configuration of the slider or change Slide HTML markup.', 'new_royalslider');
                    ?>
</li>
                        </ol>
                        <p><?php 
                    _e('You may also override all default WordPress galleries in posts (without adding royalslider attribute to [gallery] shortcode), visit RoyalSlider global settings page to learn more.', 'new_royalslider');
                    ?>
</p>
                    </div>
                <?php 
                } else {
                    if ($this->slider_type === '500px') {
                        NewRoyalSlider500pxSource::show_admin_options($this->parsed_options);
                    } else {
                        if ($this->slider_type === 'posts') {
                            NewRoyalSliderPostsSource::show_admin_options($this->parsed_options);
                        } else {
                            if ($this->slider_type === 'nextgen') {
                                NewRoyalSliderNextGenSource::show_admin_options($this->parsed_options);
                            } else {
                                if ($this->slider_type === 'flickr') {
                                    NewRoyalSliderFlickrSource::show_admin_options($this->parsed_options);
                                } else {
                                    if ($this->slider_type === 'instagram') {
                                        NewRoyalSliderInstagramSource::show_admin_options($this->parsed_options);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            ?>
            </div>
        </div>
        

    </div>
</div>
            <?php 
        }
    static function generateSlides($refresh_cache, $id, $type, $markup, $slides, $options, $template, $skin)
    {
        $transient_key = NewRoyalSliderMain::get_transient_key($id, $type);
        if (!$id) {
            $refresh_cache = true;
        }
        if ($refresh_cache) {
            // delete cached version
            delete_transient($transient_key);
            $arr = false;
        } else {
            $arr = get_transient($transient_key);
        }
        if ($arr === false) {
            if (!is_array($slides)) {
                $slides = json_decode($slides, ARRAY_A);
            }
            require_once NEW_ROYALSLIDER_PLUGIN_PATH . 'lib/Mustache/Autoloader.php';
            require_once 'renderers/DefaultRenderer.php';
            require_once 'renderers/PostGalleryRenderer.php';
            require_once 'renderers/CustomSourceRenderer.php';
            require_once 'renderers/PostsListRenderer.php';
            require_once NEW_ROYALSLIDER_PLUGIN_PATH . 'classes/NewRoyalSliderOptions.php';
            Mustache_Autoloader::register();
            $m = new Mustache_Engine(array('escape' => array('NewRoyalSliderGenerator', 'escapeMustache')));
            $css_id = 'new-royalslider-' . $id;
            $t = NewRoyalSliderOptions::getRsTemplates();
            $add_js = '';
            $curr_template;
            $selector = '';
            if (!isset($t[$template])) {
                $template = ' noTemplate';
            } else {
                $curr_template = $t[$template];
                if (isset($curr_template['add_js'])) {
                    $add_js = $curr_template['add_js'];
                    $add_js = str_replace('{{selector}}', '.' . $css_id, $add_js);
                }
                $template = ' ' . $curr_template['template-css-class'];
            }
            if ($options) {
                if (!is_array($options)) {
                    $options = json_decode($options, ARRAY_A);
                } else {
                }
                $gen_opts = self::preParseOpts($options);
                if (isset($options['sopts'])) {
                    $o = array_merge($options, $options['sopts']);
                    $to_unset = array('sopts', 'posts', 'rs_500px', 'flickr');
                    foreach ($to_unset as $key => $value) {
                        if (isset($o[$value])) {
                            unset($o[$value]);
                        }
                    }
                    foreach ($o as $key => $option) {
                        if (is_array($option)) {
                            foreach ($option as $subkey => $suboption) {
                                if (is_numeric($suboption)) {
                                    $o[$key][$subkey] = (double) $suboption;
                                }
                            }
                        } else {
                            if (is_numeric($option)) {
                                $o[$key] = (double) $option;
                            }
                        }
                    }
                    //return;
                    $init_opts = json_encode($o);
                    $init_opts = str_replace(':"true"', ':!0', $init_opts);
                    $init_opts = str_replace(':"false"', ':!1', $init_opts);
                    $init_opts = str_replace('"', '\'', $init_opts);
                    $init_opts = str_replace(',\'', ',', $init_opts);
                    $init_opts = str_replace('\':', ':', $init_opts);
                    $init_opts = str_replace('{\'', '{', $init_opts);
                } else {
                    $init_opts = $options;
                }
            } else {
                $options = array();
                $gen_opts = self::preParseOpts(null);
                $init_opts = '';
            }
            $js_init_code = "\t\$('." . $css_id . "').royalSlider(" . $init_opts . ");\n" . $add_js;
            if (!isset($skin)) {
                $skin = 'rsDefault';
            }
            $skin = ' ' . $skin;
            $out = '';
            if ($gen_opts['thumb_width'] != 96 || $gen_opts['thumb_height'] != 72) {
                $out .= "\n<style type=\"text/css\">\n";
                $out .= '.' . $css_id . ' .rsThumbsVer { width:' . $gen_opts['thumb_width'] . 'px; } 
		.' . $css_id . ' .rsThumb { width: ' . $gen_opts['thumb_width'] . 'px; height: ' . $gen_opts['thumb_height'] . 'px; }';
                $out .= "\n</style>\n";
            }
            if (isset($curr_template) && isset($curr_template['wrapHTML'])) {
                $out .= str_replace('%width%', $gen_opts['width'], $curr_template['wrapHTML']['before']);
            }
            $options['id'] = $id;
            $slides = apply_filters('new_rs_slides_filter', $slides, $options, $type);
            if (is_array($slides)) {
                $out .= '<div id="' . $css_id . '" class="royalSlider ' . $css_id . $skin . $template . '" style="width:' . $gen_opts['width'] . '; height:' . $gen_opts['height'] . ';">';
                foreach ($slides as $key => $slide) {
                    if ($type === 'custom') {
                        $renderer = new NewRoyalSliderDefaultRenderer($slide, $gen_opts, $options);
                    } else {
                        if ($type === 'gallery') {
                            $renderer = new NewRoyalSliderPostGalleryRenderer($key, $slide, $gen_opts, $options);
                        } else {
                            if ($type === 'flickr' || $type === '500px') {
                                $renderer = new NewRoyalSliderCustomSourceRenderer($slide, $gen_opts, $options);
                            } else {
                                if ($type === 'posts') {
                                    $renderer = new NewRoyalSliderPostsRenderer($slide, $gen_opts, $options);
                                }
                            }
                        }
                    }
                    $m->getHelpers()->clear();
                    apply_filters('new_rs_slides_renderer_helper', $m, $slide, $options);
                    $out .= $m->render($markup, $renderer);
                }
                $out .= '</div>';
            } else {
                $out .= NewRoyalSliderMain::frontend_error(__('Slides are missing: ', 'new_royalslider') . print_r($slides, true));
            }
            if (isset($curr_template) && isset($curr_template['wrapHTML'])) {
                $out .= $curr_template['wrapHTML']['after'];
            }
            if ($type != '500px' && $type != 'flickr') {
                $pattern = '\\[(\\[?)(gallery|new_royalslider)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)';
                preg_match_all('/' . $pattern . '/s', $out, $matches);
                $out = preg_replace_callback("/{$pattern}/s", array('NewRoyalSliderGenerator', 'strip_shortcode_tag'), $out);
                $out = do_shortcode($out);
            }
            $arr = array('out' => $out, 'js_init' => $js_init_code);
            $refresh_hours = NewRoyalSliderMain::$refresh_hours;
            if ($refresh_hours > 0) {
                set_transient($transient_key, $arr, 60 * 60 * $refresh_hours);
            }
        }
        NewRoyalSliderMain::register_slider($id, $arr['js_init']);
        return $arr['out'];
    }