예제 #1
0
    function widget($args, $instance)
    {
        $cache = array();
        if (!$this->is_preview()) {
            $cache = wp_cache_get('perth_employees', 'widget');
        }
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $title = !empty($instance['title']) ? $instance['title'] : '';
        $title = apply_filters('widget_title', $title, $instance, $this->id_base);
        $see_all = isset($instance['see_all']) ? esc_url($instance['see_all']) : '';
        $see_all_text = isset($instance['see_all_text']) ? esc_html($instance['see_all_text']) : '';
        $number = !empty($instance['number']) ? intval($instance['number']) : -1;
        if (!$number) {
            $number = -1;
        }
        $category = isset($instance['category']) ? esc_attr($instance['category']) : '';
        $r = new WP_Query(array('no_found_rows' => true, 'post_status' => 'publish', 'post_type' => 'employees', 'posts_per_page' => $number, 'category_name' => $category));
        echo $args['before_widget'];
        if ($r->have_posts()) {
            ?>

		<?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>

		<div class="employee-area clearfix">
			<?php 
            while ($r->have_posts()) {
                $r->the_post();
                ?>
				<?php 
                //Get the custom field values
                $position = get_post_meta(get_the_ID(), 'wpcf-position', true);
                $facebook = get_post_meta(get_the_ID(), 'wpcf-facebook', true);
                $twitter = get_post_meta(get_the_ID(), 'wpcf-twitter', true);
                $google = get_post_meta(get_the_ID(), 'wpcf-google-plus', true);
                $link = get_post_meta(get_the_ID(), 'wpcf-custom-link', true);
                ?>
			<div class="employee">
				<?php 
                if (has_post_thumbnail()) {
                    ?>
				<div class="employee-photo">
					<?php 
                    the_post_thumbnail('perth-medium-thumb');
                    ?>
				</div>
				<?php 
                }
                ?>
				<h4 class="employee-name">
			        <?php 
                if ($link == '') {
                    ?>
			        	<?php 
                    the_title();
                    ?>
			        <?php 
                } else {
                    ?>
			        	<a href="<?php 
                    echo esc_url($link);
                    ?>
"><?php 
                    the_title();
                    ?>
</a>
			        <?php 
                }
                ?>
					
				</h4>
				<div class="employee-position"><?php 
                echo esc_html($position);
                ?>
</div>								
				<div class="employee-social">
					<?php 
                if ($facebook != '') {
                    ?>
					<div class="svg-container employee-svg">
						<?php 
                    perth_svg_1();
                    ?>
						<a class="facebook" href="<?php 
                    echo esc_url($facebook);
                    ?>
" target="_blank"><i class="fa fa-facebook"></i></a>
					</div>	
					<?php 
                }
                ?>
					<?php 
                if ($twitter != '') {
                    ?>
					<div class="svg-container employee-svg">
						<?php 
                    perth_svg_1();
                    ?>
						<a class="twitter" href="<?php 
                    echo esc_url($twitter);
                    ?>
" target="_blank"><i class="fa fa-twitter"></i></a>
					</div>	
					<?php 
                }
                ?>
					<?php 
                if ($google != '') {
                    ?>
					<div class="svg-container employee-svg">
						<?php 
                    perth_svg_1();
                    ?>
			
						<a href="<?php 
                    echo esc_url($google);
                    ?>
"><i class="fa fa-google-plus"></i></a>
					</div>
					<?php 
                }
                ?>
				</div>
			</div>

			<?php 
            }
            ?>
		</div>

		<?php 
            if ($see_all != '') {
                ?>
			<a href="<?php 
                echo esc_url($see_all);
                ?>
" class="button more-button">
				<?php 
                if ($see_all_text) {
                    ?>
					<?php 
                    echo $see_all_text;
                    ?>
				<?php 
                } else {
                    ?>
					<?php 
                    echo __('See all our employees', 'perth');
                    ?>
				<?php 
                }
                ?>
			</a>
		<?php 
            }
            ?>
	
	
	<?php 
            wp_reset_postdata();
        }
        echo $args['after_widget'];
        if (!$this->is_preview()) {
            $cache[$args['widget_id']] = ob_get_flush();
            wp_cache_set('perth_employees', $cache, 'widget');
        } else {
            ob_end_flush();
        }
    }
예제 #2
0
            perth_svg_1();
            ?>
							<a class="twitter" href="<?php 
            echo esc_url($twitter);
            ?>
" target="_blank"><i class="fa fa-twitter"></i></a>
						</div>	
						<?php 
        }
        ?>
						<?php 
        if ($google != '') {
            ?>
						<div class="svg-container employee-svg">
							<?php 
            perth_svg_1();
            ?>
			
							<a href="<?php 
            echo esc_url($google);
            ?>
"><i class="fa fa-google-plus"></i></a>
						</div>
						<?php 
        }
        ?>
					</div>
				</div>
			<?php 
    }
    ?>
예제 #3
0
    function widget($args, $instance)
    {
        $cache = array();
        if (!$this->is_preview()) {
            $cache = wp_cache_get('perth_services', 'widget');
        }
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $title = !empty($instance['title']) ? $instance['title'] : '';
        $title = apply_filters('widget_title', $title, $instance, $this->id_base);
        $see_all = isset($instance['see_all']) ? esc_url($instance['see_all']) : '';
        $see_all_text = isset($instance['see_all_text']) ? esc_html($instance['see_all_text']) : '';
        $number = !empty($instance['number']) ? intval($instance['number']) : -1;
        if (!$number) {
            $number = -1;
        }
        $category = isset($instance['category']) ? esc_attr($instance['category']) : '';
        $cols = isset($instance['cols']) ? esc_attr($instance['cols']) : '';
        $services = new WP_Query(array('no_found_rows' => true, 'post_status' => 'publish', 'post_type' => 'services', 'posts_per_page' => $number, 'category_name' => $category));
        if ($cols == '1') {
            $cols_no = '';
        } elseif ($cols == '3') {
            $cols_no = 'columns3';
        } elseif ($cols == '2') {
            $cols_no = 'columns2';
        }
        echo $args['before_widget'];
        if ($services->have_posts()) {
            ?>
			<?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>

				<div class="service-area type-b">
					<?php 
            while ($services->have_posts()) {
                $services->the_post();
                ?>
						<?php 
                $icon = get_post_meta(get_the_ID(), 'wpcf-service-icon', true);
                ?>
						<?php 
                $link = get_post_meta(get_the_ID(), 'wpcf-service-link', true);
                ?>
						<div class="service clearfix <?php 
                echo $cols_no;
                ?>
">
							<?php 
                if (has_post_thumbnail()) {
                    ?>
							<div class="service-thumb">
								<?php 
                    the_post_thumbnail('perth-client-thumb');
                    ?>
							</div>
							<?php 
                } elseif ($icon) {
                    ?>
	
							<div class="svg-container service-icon-svg">
								<?php 
                    perth_svg_1();
                    ?>
								<span class="service-icon">
									<?php 
                    echo '<i class="fa ' . esc_html($icon) . '"></i>';
                    ?>
								</span>								
							</div>										
							<?php 
                }
                ?>
						
							<div class="content">
								<h4 class="service-title">
									<?php 
                if ($link) {
                    ?>
										<a href="<?php 
                    echo esc_url($link);
                    ?>
"><?php 
                    the_title();
                    ?>
</a>
									<?php 
                } else {
                    ?>
										<?php 
                    the_title();
                    ?>
									<?php 
                }
                ?>
								</h4>
								<?php 
                the_content();
                ?>
							</div>
						</div>
					<?php 
            }
            ?>
				</div>	

				<?php 
            if ($see_all != '') {
                ?>
					<a href="<?php 
                echo esc_url($see_all);
                ?>
" class="button more-button">
						<?php 
                if ($see_all_text) {
                    ?>
							<?php 
                    echo $see_all_text;
                    ?>
						<?php 
                } else {
                    ?>
							<?php 
                    echo __('See all our services', 'perth');
                    ?>
						<?php 
                }
                ?>
					</a>
				<?php 
            }
            ?>
				
	<?php 
            wp_reset_postdata();
        }
        echo $args['after_widget'];
        if (!$this->is_preview()) {
            $cache[$args['widget_id']] = ob_get_flush();
            wp_cache_set('perth_services', $cache, 'widget');
        } else {
            ob_end_flush();
        }
    }