Beispiel #1
0
/**
 * Return specific Bootstrap icon
 *
 * @since 1.0
 */
function wpsight_get_bootstrap_icon($bootstrap_icon)
{
    if (empty($bootstrap_icon)) {
        return;
    }
    $bootstrap_icons = wpsight_bootstrap_icons();
    return $bootstrap_icons[$bootstrap_icon];
}
Beispiel #2
0
    function form($instance)
    {
        $defaults = array('remove' => false, 'center' => false, 'link' => false, 'position' => false);
        $instance = wp_parse_args((array) $instance, $defaults);
        $icon = isset($instance['icon']) ? strip_tags($instance['icon']) : false;
        $title = isset($instance['title']) ? strip_tags($instance['title']) : false;
        $image = isset($instance['image']) ? $instance['image'] : false;
        $imageurl = isset($instance['imageurl']) ? $instance['imageurl'] : false;
        $imagewidth = isset($instance['imagewidth']) ? $instance['imagewidth'] : false;
        $title_icon = isset($instance['title_icon']) ? strip_tags($instance['title_icon']) : false;
        $image_link = !empty($instance['image']) ? __('Change image', 'wpsight') : __('Add image', 'wpsight');
        $size = isset($instance['size']) ? $instance['size'] : 'post-thumbnail';
        $align = isset($instance['align']) ? $instance['align'] : 'none';
        $text = isset($instance['text']) ? wp_kses_post($instance['text']) : false;
        $link_space = isset($instance['link_space']) ? strip_tags($instance['link_space']) : false;
        $width = isset($instance['width']) ? $instance['width'] : 'full';
        ?>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('icon');
        ?>
"><?php 
        _e('Icon', 'wpsight');
        ?>
:</label><br />
			<select class="widefat" id="<?php 
        echo $this->get_field_id('icon');
        ?>
" name="<?php 
        echo $this->get_field_name('icon');
        ?>
">
			    <option value=""<?php 
        selected('icon', $icon);
        ?>
><?php 
        _e('none', 'wpsight');
        ?>
</option>
			    <?php 
        foreach (wpsight_bootstrap_icons() as $k) {
            echo '<option value="' . $k . '"' . selected($k, $icon) . '>' . $k . '</option>';
        }
        ?>
			</select>
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title', 'wpsight');
        ?>
:</label><br />
			<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" />	
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('title_icon');
        ?>
"><?php 
        _e('Title Icon', 'wpsight');
        ?>
:</label><br />
			<select class="widefat" id="<?php 
        echo $this->get_field_id('title_icon');
        ?>
" name="<?php 
        echo $this->get_field_name('title_icon');
        ?>
">
			    <option value=""<?php 
        selected('title_icon', $title_icon);
        ?>
><?php 
        _e('none', 'wpsight');
        ?>
</option>
			    <?php 
        foreach (wpsight_bootstrap_icons() as $k) {
            echo '<option value="' . $k . '"' . selected($k, $title_icon) . '>' . $k . '</option>';
        }
        ?>
			</select>
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('image');
        ?>
"><?php 
        _e('Image', 'wpsight');
        ?>
:</label>
		</p>
		<p>
			<?php 
        $media_upload_iframe_src = 'media-upload.php?type=image&widget_id=' . $this->id;
        $image_upload_iframe_src = apply_filters('image_upload_iframe_src', $media_upload_iframe_src);
        ?>
			<a href="<?php 
        echo $image_upload_iframe_src;
        ?>
&TB_iframe=true" id="add_image-<?php 
        echo $this->get_field_id('image');
        ?>
" class="thickbox-image-widget" onClick="set_active_widget('<?php 
        echo $this->id;
        ?>
');return false;"><?php 
        echo $image_link;
        ?>
</a>

			<div id="display-<?php 
        echo $this->get_field_id('image');
        ?>
" class="wpsight-spaces-image<?php 
        if (empty($instance['imageurl'])) {
            echo ' no-image';
        }
        ?>
">
				<?php 
        if ($imageurl) {
            if ($instance['size'] == 'custom') {
                echo "<img src=\"{$imageurl}\" alt=\"{$title}\" />";
            } else {
                echo wp_get_attachment_image($image, 'post-thumbnail');
            }
        }
        ?>
			</div>
			
			<input id="<?php 
        echo $this->get_field_id('image');
        ?>
" name="<?php 
        echo $this->get_field_name('image');
        ?>
" type="hidden" value="<?php 
        echo $image;
        ?>
" />
		</p>
		
		<div id="settings-<?php 
        echo $this->get_field_id('image');
        ?>
" class="<?php 
        if (empty($imageurl)) {
            echo 'no-image';
        }
        ?>
">
		
			<p>
				<input type="checkbox" class="checkbox" id="<?php 
        echo $this->get_field_id('remove');
        ?>
" name="<?php 
        echo $this->get_field_name('remove');
        ?>
" <?php 
        checked($instance['remove'], true);
        ?>
 />
				<label for="<?php 
        echo $this->get_field_id('remove');
        ?>
"><?php 
        _e('Remove image', 'wpsight');
        ?>
</label>		
			</p>	
		
			<p>
				<label for="<?php 
        echo $this->get_field_id('size');
        ?>
"><?php 
        _e('Image size', 'wpsight');
        ?>
:</label>
				<select class="widefat" id="<?php 
        echo $this->get_field_id('size');
        ?>
" name="<?php 
        echo $this->get_field_name('size');
        ?>
">
					<option value="custom"<?php 
        selected('custom', $size);
        ?>
><?php 
        _e('custom', 'wpsight');
        ?>
</option>
					<?php 
        foreach (wpsight_image_sizes() as $k => $v) {
            echo '<option value="' . $k . '"' . selected($k, $size) . '>' . $v['label'] . ' (' . $v['size']['w'] . 'x' . $v['size']['h'] . ')</option>';
        }
        ?>
				</select><br />
				<span class="description"<?php 
        if ($size == 'custom') {
            echo ' style="display:none"';
        }
        ?>
><?php 
        _e('Image size is also limited by the box width you select below', 'wpsight');
        ?>
</span>
			</p>
			
			<div <?php 
        if ($size != 'custom') {
            echo ' style="display:none"';
        }
        ?>
>
			
				<p>
					<label for="<?php 
        echo $this->get_field_id('imagewidth');
        ?>
"><?php 
        _e('Image width', 'wpsight');
        ?>
:</label><br />
					<input class="widefat" id="<?php 
        echo $this->get_field_id('imagewidth');
        ?>
" name="<?php 
        echo $this->get_field_name('imagewidth');
        ?>
" type="text" value="<?php 
        echo esc_attr(strip_tags($imagewidth));
        ?>
" onchange="changeImgWidth('<?php 
        echo $this->id;
        ?>
')" />
					<input id="<?php 
        echo $this->get_field_id('height');
        ?>
" name="<?php 
        echo $this->get_field_name('height');
        ?>
" type="hidden" value="<?php 
        echo esc_attr(strip_tags($imagewidth));
        ?>
" onchange="changeImgHeight('<?php 
        echo $this->id;
        ?>
')" />
				</p>
			
			</div>
		
			<p>
				<label for="<?php 
        echo $this->get_field_id('align');
        ?>
"><?php 
        _e('Image align', 'wpsight');
        ?>
:</label>
				<select class="widefat" id="<?php 
        echo $this->get_field_id('align');
        ?>
" name="<?php 
        echo $this->get_field_name('align');
        ?>
">
					<option value="none"<?php 
        selected('none', $align);
        ?>
><?php 
        _e('none', 'wpsight');
        ?>
</option>
					<option value="left"<?php 
        selected('left', $align);
        ?>
><?php 
        _e('left', 'wpsight');
        ?>
</option>
					<option value="right"<?php 
        selected('right', $align);
        ?>
><?php 
        _e('right', 'wpsight');
        ?>
</option>
					<option value="center"<?php 
        selected('center', $align);
        ?>
><?php 
        _e('center', 'wpsight');
        ?>
</option>
				</select>
			</p>
			
			<p>
				<input type="checkbox" class="checkbox" id="<?php 
        echo $this->get_field_id('link');
        ?>
" name="<?php 
        echo $this->get_field_name('link');
        ?>
" <?php 
        checked($instance['link'], true);
        ?>
 />
				<label for="<?php 
        echo $this->get_field_id('link');
        ?>
"><?php 
        _e('Link image', 'wpsight');
        ?>
</label><br />
				<span class="description"><?php 
        _e('Click on image opens lightbox', 'wpsight');
        ?>
</span>
			</p>
		
		</div>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('text');
        ?>
"><?php 
        _e('Text', 'wpsight');
        ?>
:</label>
			<textarea class="widefat" rows="10" cols="10" id="<?php 
        echo $this->get_field_id('text');
        ?>
" name="<?php 
        echo $this->get_field_name('text');
        ?>
"><?php 
        echo esc_textarea($text);
        ?>
</textarea><br />
		</p>
		
		<p>
		    <input type="checkbox" class="checkbox" id="<?php 
        echo $this->get_field_id('center');
        ?>
" name="<?php 
        echo $this->get_field_name('center');
        ?>
" <?php 
        checked($instance['center'], true);
        ?>
 />
		    <label for="<?php 
        echo $this->get_field_id('center');
        ?>
"><?php 
        _e('Center widget content', 'wpsight');
        ?>
</label>
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('link_space');
        ?>
"><?php 
        _e('Link', 'wpsight');
        ?>
:</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id('link_space');
        ?>
" name="<?php 
        echo $this->get_field_name('link_space');
        ?>
" type="text" value="<?php 
        echo esc_attr($link_space);
        ?>
" /><br />
			<span class="description"><?php 
        _e('Adds links to title and image (enter a URL or post/page ID)', 'wpsight');
        ?>
</span>
		</p>
		
		<p>
			<label for="<?php 
        echo $this->get_field_id('width');
        ?>
"><?php 
        _e('Width', 'wpsight');
        ?>
:</label>
			<select class="widefat" id="<?php 
        echo $this->get_field_id('width');
        ?>
" name="<?php 
        echo $this->get_field_name('width');
        ?>
">
				<?php 
        foreach (wpsight_widget_widths() as $k => $v) {
            echo '<option value="' . $k . '"' . selected($k, $width, false) . '>' . $v . '</option>';
        }
        ?>
			</select>
		</p>
		
		<p>
		    <input type="checkbox" class="checkbox" id="<?php 
        echo $this->get_field_id('position');
        ?>
" name="<?php 
        echo $this->get_field_name('position');
        ?>
" <?php 
        checked($instance['position'], true);
        ?>
 />
		    <label for="<?php 
        echo $this->get_field_id('position');
        ?>
"><?php 
        _e('First widget', 'wpsight');
        ?>
</label><br />
		    <span class="description"><?php 
        _e('Position of the widget in the row.', 'wpsight');
        ?>
</span>
		</p><?php 
    }