/**
     * Widget form
     *
     * @since SG Window 1.0.0
     *
     * @param array $instance Array of widget options.
     */
    function form($instance)
    {
        // Output admin widget options form
        // Set up some default widget settings.
        $instance = wp_parse_args((array) $instance, $this->defaults($instance));
        sgwindow_echo_input_text($this, 'title', $instance, __('Title: ', 'sg-window'), 0);
        $tax = 'product_cat';
        $terms = get_terms($tax);
        if ($terms && !is_wp_error($terms)) {
            esc_html_e('Category:', 'sg-window');
            ?>
			<select id="<?php 
            echo esc_attr($this->get_field_id('product_cat'));
            ?>
" name="<?php 
            echo esc_attr($this->get_field_name('product_cat'));
            ?>
" style="width:100%;">
				<option value="0"><?php 
            esc_html_e('Any', 'sg-window');
            ?>
</option>
			<?php 
            foreach ($terms as $term) {
                echo '<option value="' . esc_attr($term->term_id) . '" ';
                selected($instance['product_cat'], $term->term_id);
                echo '>' . esc_html($term->name) . '</option>';
            }
            ?>
			</select>
			
		<?php 
        }
        ?>
					
		<?php 
        esc_html_e('Columns:', 'sg-window');
        ?>
		<select id="<?php 
        echo esc_attr($this->get_field_id('columns'));
        ?>
" name="<?php 
        echo esc_attr($this->get_field_name('columns'));
        ?>
" style="width:100%;">
		<?php 
        $styles = array(__('1', 'sg-window'), __('2', 'sg-window'), __('3', 'sg-window'), __('4', 'sg-window'));
        $styles_ids = array('column-1', 'column-2', 'column-3', 'column-4');
        for ($i = 0; $i < 4; $i++) {
            echo '<option value="' . esc_attr($styles_ids[$i]) . '" ';
            selected($instance['columns'], $styles_ids[$i]);
            echo '>' . esc_html($styles[$i]) . '</option>';
        }
        ?>
		</select>
		
		<?php 
        esc_html_e('Image Size:', 'sg-window');
        ?>
		<select id="<?php 
        echo esc_attr($this->get_field_id('image_size'));
        ?>
" name="<?php 
        echo esc_attr($this->get_field_name('image_size'));
        ?>
" style="width:100%;">
		<?php 
        $styles = array(__('Post Thumbnail', 'sg-window'), __('Thumbnail', 'sg-window'), __('Large', 'sg-window'), __('Full', 'sg-window'));
        $styles_ids = array('post-thumbnail', 'thumbnail', 'large', 'full');
        foreach ($styles as $i => $type) {
            echo '<option value="' . esc_attr($styles_ids[$i]) . '" ';
            selected($instance['image_size'], $styles_ids[$i]);
            echo '>' . esc_html($styles[$i]) . '</option>';
        }
        ?>
		</select>
		
		<?php 
        sgwindow_echo_input_hover_style($this, 'effect_id', $instance);
        sgwindow_echo_input_text($this, 'count', $instance, __('Count: ', 'sg-window'), 0);
        ?>
		
		<hr>
		
		<?php 
        sgwindow_echo_section_start(__('More options', 'sg-window'), $this->get_field_id('is_link'));
        sgwindow_echo_input_checkbox($this, 'is_margin_0', $instance, __('No Margins', 'sg-window'));
        sgwindow_echo_input_checkbox($this, 'is_has_description', $instance, __('Display description block', 'sg-window'));
        if ($instance['is_has_description'] != 0) {
            sgwindow_echo_input_checkbox($this, 'is_right', $instance, __('Right', 'sg-window'));
        }
        sgwindow_echo_section_end();
    }
Ejemplo n.º 2
0
    /**
     * Widget form
     *
     * @since SG Window 1.1.0
     *
     * @param array $instance Array of widget options.
     */
    function form($instance)
    {
        // Output admin widget options form
        // Set up some default widget settings.
        $instance = wp_parse_args((array) $instance, $this->defaults($instance));
        sgwindow_echo_input_text($this, 'title', $instance, __('Title: ', 'sg-window'), 0);
        sgwindow_echo_input_text($this, 'count', $instance, __('Number of Slides', 'sg-window'));
        /* What to display */
        _e('What you wish to display? (<span style="color:red;">Press "Apply" button to see new fields</span>):', 'sg-window');
        ?>
		<select id="<?php 
        echo $this->get_field_id('content_type');
        ?>
" name="<?php 
        echo $this->get_field_name('content_type');
        ?>
" style="width:100%;">
			<option value="0" <?php 
        selected($instance['content_type'], '0');
        ?>
><?php 
        esc_html_e('Custom Slides', 'sg-window');
        ?>
</option>
			<option value="1" <?php 
        selected($instance['content_type'], '1');
        ?>
><?php 
        esc_html_e('Posts from the Category', 'sg-window');
        ?>
</option>
			
			<?php 
        if (class_exists('Jetpack')) {
            ?>
			<option value="2" <?php 
            selected($instance['content_type'], '2');
            ?>
><?php 
            esc_html_e('Portfolio Projects', 'sg-window');
            ?>
</option>
			<?php 
        }
        ?>
			
			<option value="3" <?php 
        selected($instance['content_type'], '3');
        ?>
><?php 
        esc_html_e('Posts from the Current Query ( from Blog )', 'sg-window');
        ?>
</option>
			<option value="4" <?php 
        selected($instance['content_type'], '4');
        ?>
><?php 
        esc_html_e('Sticky Posts', 'sg-window');
        ?>
</option>
			<option value="5" <?php 
        selected($instance['content_type'], '5');
        ?>
><?php 
        esc_html_e('Related Posts', 'sg-window');
        ?>
</option>
			<option value="6" <?php 
        selected($instance['content_type'], '6');
        ?>
><?php 
        esc_html_e('Popular Posts (Jetpack)', 'sg-window');
        ?>
</option>
		</select>
		
		<?php 
        if ('1' == $instance['content_type'] || '2' == $instance['content_type'] || '4' == $instance['content_type'] || '5' == $instance['content_type']) {
            esc_html_e('Sort Order:', 'sg-window');
            ?>
			<select id="<?php 
            echo $this->get_field_id('order');
            ?>
" name="<?php 
            echo $this->get_field_name('order');
            ?>
" style="width:100%;">
				<option value="date" <?php 
            selected($instance['order'], 'date');
            ?>
><?php 
            esc_html_e('Date', 'sg-window');
            ?>
</option>
				<option value="rand" <?php 
            selected($instance['order'], 'rand');
            ?>
><?php 
            esc_html_e('Random', 'sg-window');
            ?>
</option>
				<option value="comment_count" <?php 
            selected($instance['order'], 'comment_count');
            ?>
><?php 
            esc_html_e('Number of Comments', 'sg-window');
            ?>
</option>
			</select>
		
		<?php 
        }
        /* Category */
        if ('1' == $instance['content_type'] || '3' == $instance['content_type'] || '4' == $instance['content_type'] || '5' == $instance['content_type'] || '6' == $instance['content_type']) {
            sgwindow_echo_input_checkbox($this, 'is_cat', $instance, __('Display Category', 'sg-window'));
        }
        /* Is Pages  */
        if ('6' == $instance['content_type']) {
            sgwindow_echo_input_checkbox($this, 'is_popular_pages', $instance, __('Display Popular Pages', 'sg-window'));
        }
        if ('1' == $instance['content_type'] || '4' == $instance['content_type']) {
            $tax = 'category';
            $terms = get_terms($tax);
            if ($terms && !is_wp_error($terms)) {
                esc_html_e('Category:', 'sg-window');
                ?>
				<select id="<?php 
                echo $this->get_field_id('category');
                ?>
" name="<?php 
                echo $this->get_field_name('category');
                ?>
" style="width:100%;">
					<option value="0"><?php 
                esc_html_e('Any', 'sg-window');
                ?>
</option>
				<?php 
                foreach ($terms as $term) {
                    echo '<option value="' . esc_attr($term->term_id) . '" ';
                    selected($instance['category'], $term->term_id);
                    echo '>' . esc_html($term->name) . '</option>';
                }
                ?>
				</select>
							
			<?php 
            }
        }
        /* Project */
        if ('2' == $instance['content_type']) {
            $tax = 'jetpack-portfolio-type';
            $terms = get_terms($tax);
            if ($terms && !is_wp_error($terms)) {
                esc_html_e('Project:', 'sg-window');
                ?>
				<select id="<?php 
                echo $this->get_field_id($tax);
                ?>
" name="<?php 
                echo $this->get_field_name($tax);
                ?>
" style="width:100%;">
					<option value="0"><?php 
                esc_html_e('Any', 'sg-window');
                ?>
</option>
				<?php 
                foreach ($terms as $term) {
                    echo '<option value="' . esc_attr($term->term_id) . '" ';
                    selected($instance[$tax], $term->term_id);
                    echo '>' . esc_html($term->name) . '</option>';
                }
                ?>
				</select>
							
			<?php 
            }
        }
        if ('0' == $instance['content_type']) {
            for ($i = 0; $i < $instance['count']; $i++) {
                if (!isset($instance['link_' . $i]) || empty($instance['link_' . $i])) {
                    $instance['link_' . $i] = '#';
                }
                if (!isset($instance['img_' . $i]) || empty($instance['img_' . $i]) || '' == $instance['img_' . $i]) {
                    $instance['img_' . $i] = $instance['img_0'];
                }
                if (!isset($instance['title_' . $i]) || empty($instance['title_' . $i])) {
                    $instance['title_' . $i] = __('Slide Title', 'sg-window') . ' ' . ($i + 1);
                }
                if (!isset($instance['descr_' . $i]) || empty($instance['descr_' . $i])) {
                    $instance['descr_' . $i] = __('description', 'sg-window');
                }
                if (!isset($instance['is_link_' . $i]) || empty($instance['is_link_' . $i])) {
                    $instance['is_link_' . $i] = $instance['is_link'];
                }
                sgwindow_echo_section_main_start(__('Edit Image ', 'sg-window') . ($i + 1), $this->get_field_id('title_' . $i) . $i);
                sgwindow_echo_input_upload_id($this, 'img_' . $i, $instance, __('Image: ', 'sg-window'));
                sgwindow_echo_input_text($this, 'title_' . $i, $instance, __('Title: ', 'sg-window'));
                sgwindow_echo_input_text($this, 'descr_' . $i, $instance, __('Description: ', 'sg-window'));
                sgwindow_echo_input_checkbox($this, 'is_link_' . $i, $instance, __('Display Link? ', 'sg-window'));
                sgwindow_echo_input_text($this, 'link_' . $i, $instance, __('Link: ', 'sg-window'));
                sgwindow_echo_section_main_end();
            }
        }
        sgwindow_echo_section_start(__('Slider options', 'sg-window'), $this->get_field_id('speed'));
        sgwindow_echo_input_text($this, 'speed', $instance, __('Movement Speed (ms): ', 'sg-window'));
        sgwindow_echo_input_text($this, 'delay', $instance, __('Delay (ms): ', 'sg-window'));
        sgwindow_echo_input_checkbox($this, 'is_play', $instance, __('Auto play slides', 'sg-window'));
        sgwindow_echo_input_text($this, 'height', $instance, __('Height of slides (number between 10-100, % of width): ', 'sg-window'));
        sgwindow_echo_input_text($this, 'margin', $instance, __('Visible part of the next and previous slide ( number between 0-34, %): ', 'sg-window'));
        sgwindow_echo_input_color($this, 'text_color', $instance, __('Text color: ', 'sg-window'), '#ffffff');
        sgwindow_echo_input_checkbox($this, 'is_background', $instance, __('Display Image as background ', 'sg-window'));
        sgwindow_echo_section_end();
    }
Ejemplo n.º 3
0
    function form($instance)
    {
        // Output admin widget options form
        // Set up some default widget settings.
        $instance = wp_parse_args((array) $instance, $this->defaults($instance));
        $instance = wp_parse_args((array) $instance, $this->defaults_for_count($instance, $instance['count']));
        sgwindow_echo_input_text($this, 'title', $instance, __('Title: ', 'sg-window'), 0);
        sgwindow_echo_section_start(__('Main options', 'sg-window'), $this->get_field_id('is_background'));
        esc_html_e('Image Size:', 'sg-window');
        ?>
		<select id="<?php 
        echo esc_attr($this->get_field_id('image_size'));
        ?>
" name="<?php 
        echo esc_attr($this->get_field_name('image_size'));
        ?>
" style="width:100%;">
		<?php 
        $styles = array(__('Post Thumbnail', 'sg-window'), __('Thumbnail', 'sg-window'), __('Large', 'sg-window'), __('Full', 'sg-window'));
        $styles_ids = array('post-thumbnail', 'thumbnail', 'large', 'full');
        foreach ($styles as $i => $type) {
            echo '<option value="' . esc_attr($styles_ids[$i]) . '" ';
            selected($instance['image_size'], $styles_ids[$i]);
            echo '>' . esc_html($styles[$i]) . '</option>';
        }
        ?>
		</select>
		
		<?php 
        sgwindow_echo_input_checkbox($this, 'is_background', $instance, __('Background Image', 'sg-window'));
        sgwindow_echo_input_checkbox($this, 'is_step', $instance, __('Step Animation', 'sg-window'));
        sgwindow_echo_input_checkbox($this, 'is_margin_0', $instance, __('No Margins', 'sg-window'));
        sgwindow_echo_section_end();
        if ($instance['is_has_description'] != 0) {
            sgwindow_echo_input_checkbox($this, 'is_right', $instance, __('Right', 'sg-window'));
            sgwindow_echo_input_text($this, 'main_title', $instance, __('Main Title: ', 'sg-window'));
            sgwindow_echo_input_textarea($this, 'main_description', $instance, __('Main Description: ', 'sg-window'));
        }
        ?>
		<hr>
		<?php 
        for ($i = 0; $i < $instance['count']; $i++) {
            sgwindow_echo_section_main_start(__('Press to edit Image ', 'sg-window') . ($i + 1), $this->get_field_id('image_' . $i) . $i);
            ?>
 
			<hr>
			<hr>
			<p style="font-size: 20px; color: red; "> 
				<?php 
            esc_html_e('Image ', 'sg-window');
            echo $i + 1;
            ?>
			</p>
			<hr>
			<hr>

			<?php 
            sgwindow_echo_input_upload_id($this, 'image_' . $i, $instance, __('Image: ', 'sg-window'));
            sgwindow_echo_input_hover_style($this, 'effect_id_' . $i, $instance);
            sgwindow_echo_input_text($this, 'title_' . $i, $instance, __('Header: ', 'sg-window'));
            sgwindow_echo_section_start(__('More options', 'sg-window'), $this->get_field_id('text_' . $i) . $i);
            sgwindow_echo_input_textarea($this, 'text_' . $i, $instance, __('Text: ', 'sg-window'));
            sgwindow_echo_input_text($this, 'link_' . $i, $instance, __('Link: ', 'sg-window'));
            sgwindow_echo_input_checkbox($this, 'is_animate_' . $i, $instance, __('Animate', 'sg-window'));
            sgwindow_echo_input_checkbox($this, 'is_animate_once_' . $i, $instance, __('Once', 'sg-window'));
            sgwindow_echo_input_checkbox($this, 'is_zoom_' . $i, $instance, __('Transparent', 'sg-window'));
            sgwindow_echo_input_checkbox($this, 'is_link_' . $i, $instance, __('Display Link', 'sg-window'));
            sgwindow_echo_input_text($this, 'link_caption_' . $i, $instance, __('Button caption: ', 'sg-window'), 0);
            sgwindow_echo_section_end();
            sgwindow_echo_section_main_end();
        }
        ?>
		
		<hr>
		
		<?php 
        esc_html_e('Columns:', 'sg-window');
        ?>
		<select id="<?php 
        echo esc_attr($this->get_field_id('columns'));
        ?>
" name="<?php 
        echo esc_attr($this->get_field_name('columns'));
        ?>
" style="width:100%;">
		<?php 
        $styles = array(__('1', 'sg-window'), __('2', 'sg-window'), __('3', 'sg-window'), __('4', 'sg-window'));
        $styles_ids = array('column-1', 'column-2', 'column-3', 'column-4');
        for ($i = 0; $i < 4; $i++) {
            echo '<option value="' . esc_attr($styles_ids[$i]) . '" ';
            selected($instance['columns'], $styles_ids[$i]);
            echo '>' . esc_html($styles[$i]) . '</option>';
        }
        ?>
		</select>
		
		<?php 
        sgwindow_echo_input_text($this, 'count', $instance, __('Number of images (press Apply): ', 'sg-window'), 0);
    }