-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmortgagecalc.php
100 lines (56 loc) · 2 KB
/
mortgagecalc.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
<?php
/**
*
*/
class MortgageCalc extends WP_Widget
{
public function __construct() {
parent::WP_Widget(
'calculator',
//title of the widget in the WP dashboard
__('Mortgage'),
array('description'=>'Wraps whatever you type in with code.', 'class'=>'register_calculator_widget')
);
}
/**
*
* @param type $instance
*/
public function form($instance)
{
// these are the default widget values
$default = array(
'title' => __(''),
"testing" =>__("")
);
$instance = wp_parse_args( (array)$instance, $default );
//this is the html for the fields in the wp dashboard
echo "\r\n";
echo "<p>";
echo "<label for='".$this->get_field_id('title')."'>" . __('Title') . ":</label> " ;
echo "<input type='text' class='widefat' id='".$this->get_field_id('title')."' name='".$this->get_field_name('title')."' value='" . esc_attr($instance['title'] ) . "' />" ;
echo "</p>";
echo "<p>";
echo "<label for='".$this->get_field_id('testing')."'>" . __('What do you want wrapped?') . ":</label> " ;
echo "<input type='text' class='widefat' id='".$this->get_field_id('testing')."' name='".$this->get_field_name('testing')."' value='" . esc_attr( $instance['testing'] ) . "' placeholder='This shows up as a watermark in the field.' />" ;
echo "</p>";
}
public function update($new_instance, $old_instance){
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['testing'] = $new_instance['testing'];
return $instance;
}
public function widget($args, $instance){
extract($args, EXTR_SKIP);
//global WP theme-driven "before widget" code
echo $before_widget;
// code before your user input
echo '<div class="your-class"><!--Your custom html code goes here!-->';
echo $instance['testing'];
// code after your user input
echo '</div>';
//global WP theme-driven "after widget" code
echo $after_widget;
}
}