-
Notifications
You must be signed in to change notification settings - Fork 0
/
widgets_old.php
234 lines (198 loc) · 7.26 KB
/
widgets_old.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
/**
* Register sidebars and widgets
*/
function roots_widgets_init() {
// Sidebars
register_sidebar(array(
'name' => 'Főoldal jobbsáv',
'id' => 'sidebar-primary',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'Előfizetés oldal jobbsáv',
'id' => 'sidebar-elofizetes',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'Aloldal jobbsáv',
'id' => 'sidebar-secondary',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'Támogatás jobbsáv',
'id' => 'sidebar-support',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'Kategóriák doboz',
'id' => 'sidebar-footer',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'Lábléc figyelő + kereső',
'id' => 'sidebar-footer-2',
'before_widget' => '<section class="widget %1$s %2$s col-md-4">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'Naptár, facebook',
'id' => 'sidebar-footer-3',
'before_widget' => '<section class="widget %1$s %2$s col-md-4">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'Főoldal lábléc listák',
'id' => 'sidebar-front-bottom',
'before_widget' => '<section class="widget %1$s %2$s col-md-4">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'Főoldal lábléc listák 2',
'id' => 'sidebar-front-bottom-2',
'before_widget' => '<section class="widget %1$s %2$s col-md-4">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => __('adblock 1', 'roots'),
'id' => 'adblock-1',
'before_widget' => '<section class="widget adblock %1$s %2$s col-md-12">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => __('adblock 2', 'roots'),
'id' => 'adblock-2',
'before_widget' => '<section class="widget adblock %1$s %2$s col-md-12">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => __('header-primary', 'roots'),
'id' => 'header-1',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => __('header-secondary', 'roots'),
'id' => 'header-2',
'before_widget' => '<section class="widget %1$s %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
// Widgets
register_widget('Roots_Vcard_Widget');
}
add_action('widgets_init', 'roots_widgets_init');
/**
* Example vCard widget
*/
class Roots_Vcard_Widget extends WP_Widget {
private $fields = array(
'title' => 'Title (optional)',
'street_address' => 'Street Address',
'locality' => 'City/Locality',
'region' => 'State/Region',
'postal_code' => 'Zipcode/Postal Code',
'tel' => 'Telephone',
'email' => 'Email'
);
function __construct() {
$widget_ops = array('classname' => 'widget_roots_vcard', 'description' => __('Use this widget to add a vCard', 'roots'));
$this->WP_Widget('widget_roots_vcard', __('Roots: vCard', 'roots'), $widget_ops);
$this->alt_option_name = 'widget_roots_vcard';
add_action('save_post', array(&$this, 'flush_widget_cache'));
add_action('deleted_post', array(&$this, 'flush_widget_cache'));
add_action('switch_theme', array(&$this, 'flush_widget_cache'));
}
function widget($args, $instance) {
$cache = wp_cache_get('widget_roots_vcard', 'widget');
if (!is_array($cache)) {
$cache = array();
}
if (!isset($args['widget_id'])) {
$args['widget_id'] = null;
}
if (isset($cache[$args['widget_id']])) {
echo $cache[$args['widget_id']];
return;
}
ob_start();
extract($args, EXTR_SKIP);
$title = apply_filters('widget_title', empty($instance['title']) ? __('vCard', 'roots') : $instance['title'], $instance, $this->id_base);
foreach($this->fields as $name => $label) {
if (!isset($instance[$name])) { $instance[$name] = ''; }
}
echo $before_widget;
if ($title) {
echo $before_title, $title, $after_title;
}
?>
<p class="vcard">
<a class="fn org url" href="<?php echo home_url('/'); ?>"><?php bloginfo('name'); ?></a><br>
<span class="adr">
<span class="street-address"><?php echo $instance['street_address']; ?></span><br>
<span class="locality"><?php echo $instance['locality']; ?></span>,
<span class="region"><?php echo $instance['region']; ?></span>
<span class="postal-code"><?php echo $instance['postal_code']; ?></span><br>
</span>
<span class="tel"><span class="value"><?php echo $instance['tel']; ?></span></span><br>
<a class="email" href="mailto:<?php echo $instance['email']; ?>"><?php echo $instance['email']; ?></a>
</p>
<?php
echo $after_widget;
$cache[$args['widget_id']] = ob_get_flush();
wp_cache_set('widget_roots_vcard', $cache, 'widget');
}
function update($new_instance, $old_instance) {
$instance = array_map('strip_tags', $new_instance);
$this->flush_widget_cache();
$alloptions = wp_cache_get('alloptions', 'options');
if (isset($alloptions['widget_roots_vcard'])) {
delete_option('widget_roots_vcard');
}
return $instance;
}
function flush_widget_cache() {
wp_cache_delete('widget_roots_vcard', 'widget');
}
function form($instance) {
foreach($this->fields as $name => $label) {
${$name} = isset($instance[$name]) ? esc_attr($instance[$name]) : '';
?>
<p>
<label for="<?php echo esc_attr($this->get_field_id($name)); ?>"><?php _e("{$label}:", 'roots'); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id($name)); ?>" name="<?php echo esc_attr($this->get_field_name($name)); ?>" type="text" value="<?php echo ${$name}; ?>">
</p>
<?php
}
}
}