示例#1
0
    public function form($instance)
    {
        // title
        // list post type checkbox
        // review checkbox
        // location select
        if (isset($instance['title'])) {
            $title = $instance['title'];
        } else {
            $title = __('Title', ST_TEXTDOMAIN);
        }
        if (isset($instance['post_type'])) {
            $post_type = $instance['post_type'];
        }
        if (isset($instance['count_review'])) {
            $count_review = $instance['count_review'];
        }
        ?>
		<div class='location_widget_item'>
			<p>
				<label ><?php 
        echo balancetags("Title", ST_TEXTDOMAIN);
        ?>
</label>
				<input value='<?php 
        echo esc_attr($title);
        ?>
' type='text' name='<?php 
        echo $this->get_field_name('title');
        ?>
'/>
			</p>
			<p>
				<label><?php 
        echo balancetags("Post type select ", ST_TEXTDOMAIN);
        ?>
</label>
				<?php 
        $get_post_type_list_active = STLocation::get_post_type_list_active();
        if (!empty($get_post_type_list_active) and is_array($get_post_type_list_active)) {
            foreach (STLocation::get_post_type_list_active() as $key => $value) {
                ?>
						<br>
						<input <?php 
                if (!empty($post_type) and $post_type and in_array($value, $post_type)) {
                    echo esc_attr('checked');
                }
                ?>
 
						id ='<?php 
                echo esc_attr("st_w_" . $value);
                ?>
'  
						value = '<?php 
                echo esc_attr($value);
                ?>
' 
						type='checkbox' 
						name='<?php 
                echo balancetags($this->get_field_name('post_type'));
                ?>
[]'/> 
						<label ><?php 
                echo esc_attr(STLocation::get_post_type_name($value, true));
                ?>
</label>
						<?php 
            }
        }
        ?>
			</p>
			<p>
				<label><?php 
        echo balancetags("Count Review", ST_TEXTDOMAIN);
        ?>
</label>
				<input <?php 
        if (!empty($count_review) and $count_review == 'on') {
            echo "checked";
        }
        ?>
 type='checkbox' name='<?php 
        echo balancetags($this->get_field_name('count_review'));
        ?>
'/>
			</p>
			<p>
				<label><?php 
        echo esc_attr("Location select", ST_TEXTDOMAIN);
        ?>
</label>
				<?php 
        $list_location = TravelerObject::get_list_location();
        if (!empty($instance['location'])) {
            $old_location = $instance['location'];
        }
        //$old_location = $instance['location'];
        ?>
				<select name="<?php 
        echo balancetags($this->get_field_name('location'));
        ?>
" class="form-control">
			       <option value=""><?php 
        _e('-- Select --', ST_TEXTDOMAIN);
        ?>
</option>
			       <?php 
        foreach ($list_location as $k => $v) {
            ?>
			            <option <?php 
            if (!empty($old_location) and $old_location == $v['id']) {
                echo 'selected';
            }
            ?>
 value="<?php 
            echo esc_html($v['id']);
            ?>
">
			                <?php 
            echo esc_html($v['title']);
            ?>
			            </option>
			       <?php 
        }
        ?>
			   </select>
		   </p>
		</div>
		<?php 
    }
示例#2
0
<?php

$results = STLocation::location_widget3($instance);
if (!$instance['title']) {
    $title = ucfirst($instance['style']);
    $title .= " " . STLocation::get_post_type_name($instance['post_type']);
    $title .= " " . __("in", ST_TEXTDOMAIN);
    $title .= " <strong>" . ucfirst(get_the_title($instance['location'])) . "</strong>";
} else {
    $title = $instance['title'];
}
echo "<h4> " . $title . " </h4>";
echo "<ul class='booking-list'>";
if (!empty($results) and is_array($results)) {
    foreach ($results as $key => $value) {
        $link = get_permalink($value->ID);
        $post_id = $value->ID;
        $thumbnail = get_the_post_thumbnail($post_id, 'full');
        if (!$thumbnail) {
            $thumbnail = st_get_default_image();
        }
        if (isset($instance['layout']) && !empty($instance['layout'])) {
            $layout = $instance['layout'];
        } else {
            $layout = 'layout1';
        }
        ?>
		<li class='widget_location '>
			<div class="bookinst_save_attributeg-item booking-item booking-item-small">
                <div class="row">
                    <div class="<?php