<?php /**
 * Redux Framework is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * any later version.
 *
 * Redux Framework is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.&#13;
 *&#13;
 * @package     ReduxFramework&#13;
 * @subpackage  Field_slides&#13;
 * @author      Luciano "WebCaos" Ubertini&#13;
 * @author      Daniel J Griffiths (Ghost1227)&#13;
 * @author      Dovy Paukstys&#13;
 * @version     3.0.0&#13;
 */&#13;
&#13;
// Exit if accessed directly&#13;
if (!defined('ABSPATH')) exit;&#13;
&#13;
// Don't duplicate me!&#13;
if (!class_exists('ReduxFramework_slides')) {&#13;
&#13;
    /**&#13;
     * Main ReduxFramework_slides class&#13;
     *&#13;
     * @since       1.0.0&#13;
     */&#13;
    class ReduxFramework_slides extends ReduxFramework&#13;
    {&#13;
&#13;
        /**&#13;
         * Field Constructor.&#13;
         *&#13;
         * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function&#13;
         *&#13;
         * @since       1.0.0&#13;
         * @access      public&#13;
         * @return      void&#13;
         */&#13;
        public function __construct($field = array(), $value = '', $parent)&#13;
        {&#13;
&#13;
            parent::__construct($parent-&gt;sections, $parent-&gt;args, $parent-&gt;extra_tabs);&#13;
&#13;
            $this-&gt;field = $field;&#13;
            $this-&gt;value = $value;&#13;
&#13;
        }&#13;
&#13;
        /**&#13;
         * Field Render Function.&#13;
         *&#13;
         * Takes the vars and outputs the HTML for the field in the settings&#13;
         *&#13;
         * @since       1.0.0&#13;
         * @access      public&#13;
         * @return      void&#13;
         */&#13;
        public function render()&#13;
        {&#13;
&#13;
            echo '<div class="redux-slides-accordion">';&#13;
&#13;
            $x = 0;&#13;
&#13;
            if (isset($this-&gt;value) &amp;&amp; is_array($this-&gt;value)) {&#13;
&#13;
                $slides = $this-&gt;value;&#13;
&#13;
                foreach ($slides as $slide) {&#13;
&#13;
                    if (empty($slide['slide_image_url']) &amp;&amp; !empty($slide['slide_image_id'])) {&#13;
                        $img = wp_get_attachment_image_src($slide['slide_image_id'], 'full');&#13;
                        $slide['slide_image_url'] = $img[0];&#13;
                        $slide['slide_image_width'] = $img[1];&#13;
                        $slide['slide_image_height'] = $img[2];&#13;
                    }&#13;
&#13;
                    if (!isset($slide['slide_title'])) $slide['slide_title'] = '';&#13;
                    if (!isset($slide['slide_description'])) $slide['slide_description'] = '';&#13;
                    if (!isset($slide['slide_url'])) $slide['slide_url'] = '';&#13;
                    if (!isset($slide['slide_sort'])) $slide['slide_sort'] = '';&#13;
                    if (!isset($slide['slide_image_id'])) $slide['slide_image_id'] = '';&#13;
                    if (!isset($slide['slide_image_url'])) $slide['slide_image_url'] = '';&#13;
                    if (!isset($slide['slide_image_height'][$x])) $slide['slide_image_height'] = '';&#13;
                    if (!isset($slide['slide_image_width'])) $slide['slide_image_width'] = '';&#13;
					//New Field by Towfiq:&#13;
					if (!isset($slide['slide_content_id'])) $slide['slide_content_id'] = '';&#13;
					//&#13;
&#13;
                    if ($slide['slide_title'] != '' &amp;&amp; isset($slide['slide_title'])) {&#13;
                        echo '<div class="redux-slides-accordion-group ast_slides' . $x . '"><fieldset><h3><span class="redux-slides-header">' . $slide['slide_title'] . '</span></h3><div>';&#13;
&#13;
                        $hide = '';&#13;
                        if (empty($slide['slide_image_url']))&#13;
                            $hide = ' hide';&#13;
&#13;
                        echo '<div class="screenshot' . $hide . '">';&#13;
                        echo '<a class="of-uploaded-image" href="'%20.%20%24slide%5B'slide_image_url'%5D%20.%20'">';&#13;
                        echo '<img class="redux-slides-image" id="image_slide_image_id_' . $x . '" src="'%20.%20%24slide%5B'slide_image_url'%5D%20.%20'" alt="">';&#13;
                        echo '</a>';&#13;
                        echo '</div>';&#13;
&#13;
                        echo '<div class="redux_slides_add_remove">';&#13;
&#13;
                        echo '<span class="button media_upload_button" id="add_slide_' . $x . '">' . __('Upload', 'redux-framework') . '</span>';&#13;
&#13;
                        $hide = '';&#13;
                        if (empty($slide['slide_image_url']) || $slide['slide_image_url'] == '')&#13;
                            $hide = ' hide';&#13;
&#13;
                        echo '<span class="button remove-image' . $hide . '" id="reset_slide_' . $x . '" rel="' . $slide['slide_image_id'] . '">' . __('Remove', 'redux-framework') . '</span>';&#13;
&#13;
                        echo '</div>' . "\n";&#13;
&#13;
                        echo '<ul id="' . $this-&gt;field['id'] . '-ul" class="redux-multi-text">';&#13;
                        echo '<li><input type="text" id="' . $this-&gt;field['id'] . '-slide_title_' . $x . '" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_title]" value="' . esc_attr($slide['slide_title']) . '" class="full-text slide-title"></li>';&#13;
                        echo '<li><textarea name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_description]" id="' . $this-&gt;field['id'] . '-slide_description_' . $x . '" placeholder="'.__('Description', 'redux-framework').'" class="large-text" rows="6">' . esc_attr($slide['slide_description']) . '</textarea></li>';&#13;
                        echo '<li><input type="text" id="' . $this-&gt;field['id'] . '-slide_url_' . $x . '" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_url]" value="' . esc_attr($slide['slide_url']) . '" class="full-text"></li>';&#13;
						//New Field by Towfiq: &#13;
						echo '<li class="ast_trigger"><label>'.__('Slide Text Layout', 'redux-framework').'<br><br><a class="sldcont1 astbtn">layout1</a><a class="sldcont2 astbtn">layout2</a><a class="sldcont3 astbtn">layout3</a><input type="hidden" id="' . $this-&gt;field['id'] . '-slide_content_' . $x . '" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_content_id]" value="' . esc_attr($slide['slide_content_id']) . '" class="full-text ast_content"></label></li>';&#13;
						//echo '<li>';&#13;
							 //&#13;
						echo '</li><li><input type="hidden" class="slide-sort" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_sort]" id="' . $this-&gt;field['id'] . '-slide_sort_' . $x . '" value="' . $slide['slide_sort'] . '">';&#13;
                        echo '</li><li><input type="hidden" class="upload-id" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_image_id]" id="' . $this-&gt;field['id'] . '-slide_image_id_' . $x . '" value="' . $slide['slide_image_id'] . '">';&#13;
                        echo '<input type="hidden" class="upload" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_image_url]" id="' . $this-&gt;field['id'] . '-slide_image_url_' . $x . '" value="' . $slide['slide_image_url'] . '" readonly>';&#13;
                        echo '<input type="hidden" class="upload-height" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_image_height]" id="' . $this-&gt;field['id'] . '-slide_image_height_' . $x . '" value="' . $slide['slide_image_height'] . '">';&#13;
                        echo '<input type="hidden" class="upload-width" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_image_width]" id="' . $this-&gt;field['id'] . '-slide_image_width_' . $x . '" value="' . $slide['slide_image_width'] . '"></li>';&#13;
                        echo '<li><a href="javascript:void(0);" class="button deletion redux-slides-remove">' . __('Delete Slide', 'redux-framework') . '</a></li>';&#13;
                        echo '</ul></div></fieldset></div>';&#13;
                        $x++;&#13;
                    }&#13;
                }&#13;
            }&#13;
&#13;
            if ($x == 0) {&#13;
                echo '<div class="redux-slides-accordion-group"><fieldset><h3><span class="redux-slides-header">New Slide</span></h3><div>';&#13;
&#13;
                $hide = ' hide';&#13;
&#13;
                echo '<div class="screenshot' . $hide . '">';&#13;
                echo '<a class="of-uploaded-image" href="">';&#13;
                echo '<img class="redux-slides-image" id="image_slide_image_id_' . $x . '" src="" alt="">';&#13;
                echo '</a>';&#13;
                echo '</div>';&#13;
&#13;
                //Upload controls DIV&#13;
                echo '<div class="upload_button_div">';&#13;
&#13;
                //If the user has WP3.5+ show upload/remove button&#13;
                echo '<span class="button media_upload_button" id="add_slide_' . $x . '">' . __('Upload', 'redux-framework') . '</span>';&#13;
&#13;
                echo '<span class="button remove-image' . $hide . '" id="reset_slide_' . $x . '" rel="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][slide_image_id]">' . __('Remove', 'redux-framework') . '</span>';&#13;
&#13;
                echo '</div>' . "\n";&#13;
&#13;
                echo '<ul id="' . $this-&gt;field['id'] . '-ul" class="redux-multi-text">';&#13;
                echo '<li><input type="text" id="' . $this-&gt;field['id'] . '-slide_title_' . $x . '" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_title]" value="" placeholder="'.__('Title', 'redux-framework').'" class="full-text slide-title"></li>';&#13;
                echo '<li><textarea name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_description]" id="' . $this-&gt;field['id'] . '-slide_description_' . $x . '" placeholder="'.__('Description', 'redux-framework').'" class="large-text" rows="6"></textarea></li>';&#13;
                echo '<li><input type="text" id="' . $this-&gt;field['id'] . '-slide_url_' . $x . '" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_url]" value="" class="full-text" placeholder="'.__('URL', 'redux-framework').'"></li>';&#13;
				//New Field by Towfiq: &#13;
				echo '<li class="ast_trigger"><label>'.__('Slide Text Layout', 'redux-framework').'<br><br><a class="sldcont1 astbtn">layout1</a><a class="sldcont2 astbtn">layout2</a><a class="sldcont3 astbtn">layout3</a><input type="hidden" id="' . $this-&gt;field['id'] . '-slide_content_' . $x . '" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_content_id]" value="" class="full-text ast_content"></label></li>';&#13;
&#13;
				//&#13;
				echo '<li><input type="hidden" class="slide-sort" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_sort]" id="' . $this-&gt;field['id'] . '-slide_sort_' . $x . '" value="' . $x . '">';&#13;
                echo '</li><li><input type="hidden" class="upload-id" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_image_id]" id="' . $this-&gt;field['id'] . '-slide_image_id_' . $x . '" value="">';&#13;
                echo '<input type="hidden" class="upload" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_image_url]" id="' . $this-&gt;field['id'] . '-slide_image_url_' . $x . '" value="" readonly>';&#13;
                echo '<input type="hidden" class="upload-height" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_image_height]" id="' . $this-&gt;field['id'] . '-slide_image_height_' . $x . '" value="">';&#13;
                echo '<input type="hidden" class="upload-width" name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][' . $x . '][slide_image_width]" id="' . $this-&gt;field['id'] . '-slide_image_width_' . $x . '" value=""></li>';&#13;
                echo '<li><a href="javascript:void(0);" class="button deletion redux-slides-remove">' . __('Delete Slide', 'redux-framework') . '</a></li>';&#13;
                echo '</ul></div></fieldset></div>';&#13;
            }&#13;
            echo '</div><a href="javascript:void(0);" class="button redux-slides-add button-primary" rel-id="' . $this-&gt;field['id'] . '-ul" rel-name="' . $this-&gt;args['opt_name'] . '[' . $this-&gt;field['id'] . '][slide_title][]">' . __('Add Slide', 'redux-framework') . '</a><br>';&#13;
            &#13;
        }&#13;
&#13;
        /**&#13;
         * Enqueue Function.&#13;
         *&#13;
         * If this field requires any scripts, or css define this function and register/enqueue the scripts/css&#13;
         *&#13;
         * @since       1.0.0&#13;
         * @access      public&#13;
         * @return      void&#13;
         */&#13;
&#13;
        public function enqueue() {&#13;
&#13;
&#13;
            wp_enqueue_script(&#13;
                'redux-field-media-js',&#13;
                ReduxFramework::$_url . 'inc/fields/media/field_media.js',&#13;
                array( 'jquery', 'wp-color-picker' ),&#13;
                time(),&#13;
                true&#13;
            );&#13;
&#13;
            wp_enqueue_style(&#13;
                'redux-field-media-css',&#13;
                ReduxFramework::$_url . 'inc/fields/media/field_media.css',&#13;
                time(),&#13;
                true&#13;
            );            &#13;
&#13;
            wp_enqueue_script(&#13;
                'redux-field-slides-js',&#13;
                ReduxFramework::$_url . 'inc/fields/slides/field_slides.js',&#13;
                array('jquery', 'jquery-ui-core', 'jquery-ui-accordion', 'wp-color-picker'),&#13;
                time(),&#13;
                true&#13;
            );&#13;
&#13;
            if (function_exists('wp_enqueue_media')) {&#13;
                wp_enqueue_media();&#13;
            }&#13;
            else {&#13;
                wp_enqueue_script('media-upload');&#13;
                wp_enqueue_script('thickbox');&#13;
                wp_enqueue_style('thickbox');&#13;
            }&#13;
&#13;
            wp_enqueue_style(&#13;
                'redux-field-slides-css',&#13;
                ReduxFramework::$_url . 'inc/fields/slides/field_slides.css',&#13;
                time(),&#13;
                true&#13;
            );&#13;
&#13;
&#13;
        }&#13;
&#13;
    }&#13;
}&#13;
