-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-bmi.php
63 lines (57 loc) · 1.85 KB
/
wp-bmi.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
<?php
/*
Plugin Name: WP BMI
Plugin URI: http://nabtron.com/wp-bmi/
Description: Body Mass Index calculator as a widget on sidebar
Author: nabtron
Version: 1.0.1
Author URI: http://nabtron.com/
*/
function wp_bmi_scripts() {
wp_register_style( 'wp-bmi-styles', plugin_dir_url( __FILE__ ) . 'assets/wp-bmi-styles.css' );
wp_enqueue_style( 'wp-bmi-styles' );
wp_register_script( 'wp-bmi-js', plugin_dir_url( __FILE__ ) . 'assets/wp-bmi-js.js' );
wp_enqueue_script( 'wp-bmi-js' );
}
add_action( 'wp_enqueue_scripts', 'wp_bmi_scripts' );
function wp_bmi_front()
{
?>
<div id="bmi_div">
<form>
<p> <span>height</span> <br />
<span class="bmi_input">
<input type="text" id="bmi_height" value="0" onKeyUp="AnEventHasOccurred()">
</span> <span class="bmi_radio">
<input type="radio" id="bmi_cms" name="bmi_cmsinches" value="cms" checked="checked" onClick="AnEventHasOccurred()">
cm
<input type="radio" id="bmi_inches" name="bmi_cmsinches" value="inches" onClick="AnEventHasOccurred()">
in </span> </p>
<p> <span>weight</span> <br />
<span class="bmi_input">
<input type="text" id="bmi_weight" value="0" onKeyUp="AnEventHasOccurred()">
</span> <span class="bmi_radio">
<input type="radio" id="bmi_kg" name="bmi_kglb" value="kgs" checked="checked" onClick="AnEventHasOccurred()">
kg
<input type="radio" id="bmi_lb" name="bmi_kglb" value="lbs" onClick="AnEventHasOccurred()">
lb </span> </p>
<p>Your BMI is : <span id="bmi_result">0</span></p>
</form>
<script type="text/javascript">
</script>
</div>
<?php
}
function wp_bmi_widget($args)
{
extract($args);
echo $before_widget;
echo $before_title;?>BMI Calculator<?php echo $after_title;
wp_bmi_front();
echo $after_widget;
}
function wp_bmi_init()
{
register_sidebar_widget('BMI Widget', 'wp_bmi_widget');
}
add_action("plugins_loaded", "wp_bmi_init");