-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpressenza-plugin.php
More file actions
146 lines (123 loc) · 6.28 KB
/
pressenza-plugin.php
File metadata and controls
146 lines (123 loc) · 6.28 KB
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
<?php
/*
Plugin Name: Pressenza
Plugin URI: https://github.com/Pressenza/pressenza-plugin
Version: 0.2.5
Description: collection of widgets and setup for pressenza.com
Author: Stefano Cecere & Tom Butikofer
Author URI: https://github.com/Pressenza
GitHub Plugin URI: https://github.com/Pressenza/pressenza-plugin
GitHub Branch: master
*/
// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
}
function pressenza_register_widgets()
{
register_widget('MultilanguageHtmlWidget');
}
add_action('widgets_init', 'pressenza_register_widgets');
class MultilanguageHtmlWidget extends WP_Widget
{
function __construct()
{
$widget_ops = array('classname' => 'MultilanguageHtmlWidget', 'description' => 'widget description');
parent::__construct('MultilanguageHtmlWidget', 'Pressenza: Multilanguage HTML', $widget_ops);
}
function form($instance)
{
$instance = wp_parse_args((array)$instance, array(
'html_default' => '',
'html_it' => '',
'html_es' => '',
'html_fr' => '',
'html_pt' => '',
'html_de' => '',
'html_el' => '',
'html_hu' => '',
'html_ca' => ''
)
);
$html_default = esc_textarea($instance['html_default']);
$html_it = esc_textarea($instance['html_it']);
$html_es = esc_textarea($instance['html_es']);
$html_fr = esc_textarea($instance['html_fr']);
$html_pt = esc_textarea($instance['html_pt']);
$html_de = esc_textarea($instance['html_de']);
$html_el = esc_textarea($instance['html_el']);
$html_hu = esc_textarea($instance['html_hu']);
$html_ca = esc_textarea($instance['html_ca']);
?>
<label for="<?php echo $this->get_field_id('html_default'); ?>">HTML (default):</label>
<textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('html_default'); ?>" name="<?php echo $this->get_field_name('html_default'); ?>"><?php echo $html_default; ?></textarea>
<label for="<?php echo $this->get_field_id('html_it'); ?>">HTML (italian):</label>
<textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('html_it'); ?>" name="<?php echo $this->get_field_name('html_it'); ?>"><?php echo $html_it; ?></textarea>
<label for="<?php echo $this->get_field_id('html_es'); ?>">HTML (espanol):</label>
<textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('html_es'); ?>" name="<?php echo $this->get_field_name('html_es'); ?>"><?php echo $html_es; ?></textarea>
<label for="<?php echo $this->get_field_id('html_fr'); ?>">HTML (francais):</label>
<textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('html_fr'); ?>" name="<?php echo $this->get_field_name('html_fr'); ?>"><?php echo $html_fr; ?></textarea>
<label for="<?php echo $this->get_field_id('html_pt'); ?>">HTML (portoguese):</label>
<textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('html_pt'); ?>" name="<?php echo $this->get_field_name('html_pt'); ?>"><?php echo $html_pt; ?></textarea>
<label for="<?php echo $this->get_field_id('html_de'); ?>">HTML (german):</label>
<textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('html_de'); ?>" name="<?php echo $this->get_field_name('html_de'); ?>"><?php echo $html_de; ?></textarea>
<label for="<?php echo $this->get_field_id('html_el'); ?>">HTML (Greek):</label>
<textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('html_el'); ?>" name="<?php echo $this->get_field_name('html_el'); ?>"><?php echo $html_el; ?></textarea>
<label for="<?php echo $this->get_field_id('html_hu'); ?>">HTML (Hungarian):</label>
<textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('html_hu'); ?>" name="<?php echo $this->get_field_name('html_hu'); ?>"><?php echo $html_hu; ?></textarea>
<label for="<?php echo $this->get_field_id('html_ca'); ?>">HTML (Catalan):</label>
<textarea class="widefat" rows="5" cols="20" id="<?php echo $this->get_field_id('html_ca'); ?>" name="<?php echo $this->get_field_name('html_ca'); ?>"><?php echo $html_ca; ?></textarea>
<?php
}
function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['html_default'] = $new_instance['html_default'];
$instance['html_it'] = $new_instance['html_it'];
$instance['html_es'] = $new_instance['html_es'];
$instance['html_fr'] = $new_instance['html_fr'];
$instance['html_pt'] = $new_instance['html_pt'];
$instance['html_de'] = $new_instance['html_de'];
$instance['html_el'] = $new_instance['html_el'];
$instance['html_hu'] = $new_instance['html_hu'];
$instance['html_ca'] = $new_instance['html_ca'];
return $instance;
}
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
//echo $before_widget;
switch (ICL_LANGUAGE_CODE) {
case 'it':
$html = $instance['html_it'];
break;
case 'es':
$html = $instance['html_es'];
break;
case 'fr':
$html = $instance['html_fr'];
break;
case 'pt-pt':
$html = $instance['html_pt'];
break;
case 'de':
$html = $instance['html_de'];
break;
case 'el':
$html = $instance['html_el'];
break;
case 'hu':
$html = $instance['html_hu'];
break;
case 'ca':
$html = $instance['html_ca'];
break;
default:
$html = $instance['html_default'];
break;
}
echo $html;
//echo $after_widget;
}
}
add_action('widgets_init', create_function('', 'return register_widget("MultilanguageHtmlWidget");'));