-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-widgets.php
84 lines (70 loc) · 3.4 KB
/
custom-widgets.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
function massively_register_widgets() {
register_widget('massively_address');
}
add_action( 'widgets_init', 'massively_register_widgets' );
class massively_address extends WP_Widget {
public function __construct() {
$des = array(
'description' => __( 'Input your address.', 'massively' )
);
parent::__construct( 'hello', 'Massively Addess Widget', $des );
}
public function widget( $args, $instance ) {
?>
<section class="split contact">
<section class="alt">
<h3>Address</h3>
<p style="line-height: 20px;"><?php echo !empty($instance['addr']) ? $instance['addr'] : ''; ?></p>
</section>
<section>
<h3>Phone</h3>
<p><a href="<?php echo !empty($instance['phn']) ? 'tel:'.$instance['phn'] : '#'; ?>"><?php echo !empty($instance['phn']) ? $instance['phn'] : ''; ?></a></p>
</section>
<section>
<h3>Email</h3>
<p><a href="<?php echo !empty($instance['mail']) ? 'mailto:'.$instance['mail'] : '#'; ?>"><?php echo !empty($instance['mail']) ? $instance['mail'] : ''; ?></a></p>
</section>
<section>
<h3>Social</h3>
<ul class="icons alt">
<?php if ( !empty( get_theme_mod('massively_fb_text') ) ) : ?>
<li><a href="http://<?php echo get_theme_mod('massively_fb_text'); ?>" class="icon alt fa-facebook"><span class="label">Facebook</span></a></li>
<?php endif; ?>
<?php if ( !empty( get_theme_mod('massively_twitter_text') ) ) : ?>
<li><a href="http://<?php echo get_theme_mod('massively_twitter_text'); ?>" class="icon alt fa-twitter"><span class="label">Twitter</span></a></li>
<?php endif; ?>
<?php if ( !empty( get_theme_mod('massively_ins_text') ) ) : ?>
<li><a href="http://<?php echo get_theme_mod('massively_ins_text'); ?>" class="icon alt fa-instagram"><span class="label">Instagram</span></a></li>
<?php endif; ?>
<?php if ( !empty( get_theme_mod('massively_git_text') ) ) : ?>
<li><a href="http://<?php echo get_theme_mod('massively_git_text'); ?>" class="icon alt fa-github"><span class="label">GitHub</span></a></li>
<?php endif; ?>
</ul>
</section>
</section>
<?php
}
public function form( $instance ) {
?>
<p>
<label for="<?php echo $this->get_field_id('title') ?>">Title: </label>
<input type="text" name="<?php echo $this->get_field_name('title') ?>" id="<?php echo $this->get_field_id('title'); ?>" value="<?php echo !empty($instance['title']) ? $instance['title'] : '' ?>" class="widefat">
</p>
<p>
<label for="<?php echo $this->get_field_id('addr') ?>">Address</label>
<!-- <input type="text" name="" id="" value="" class="widefat"> -->
<textarea name="<?php echo $this->get_field_name('addr'); ?>" id="<?php echo $this->get_field_id('addr'); ?>" rows="3" class="widefat"><?php echo !empty($instance['addr']) ? $instance['addr'] : '' ?></textarea>
</p>
<p>
<label for="<?php echo $this->get_field_id('phn'); ?>">Phone: </label>
<input type="text" name="<?php echo $this->get_field_name('phn'); ?>" id="<?php echo $this->get_field_id('phn'); ?>" value="<?php echo !empty($instance['phn']) ? $instance['phn'] : ''; ?>" class="widefat">
</p>
<p>
<label for="<?php echo $this->get_field_id('mail'); ?>">Email: </label>
<input type="text" name="<?php echo $this->get_field_name('mail'); ?>" id="<?php echo $this->get_field_id('mail'); ?>" value="<?php echo !empty($instance['mail']) ? $instance['mail'] : ''; ?>" class="widefat">
</p>
<?php
}
}
?>