BMI
/*
Plugin Name: Body Mass Index (BMI)
Plugin URI: http://bikinifigur.at/goodies/wp-bmi-rechner
Description: Allows the user to calculate the Body Mass Index (BMI) from body weight and height.
Author: Robert Wetzlmayr
Version: 1.1
Author URI: http://wetzlmayr.at/
License: GPL 2.0, @see http://www.gnu.org/licenses/gpl-2.0.html
*/
function wet_bmicalc_init() {
// check for the required WP functions, die silently for pre-2.2 WP.
if ( !function_exists('wp_register_sidebar_widget') )
return;
function wet_bmicalc($args) {
extract($args);
// get widget options
$options = get_option('wet_bmicalc');
$title = $options['title'];
$buttontext = $options['buttontext'];
// l10n strings
$point = __('.', 'wet_bmicalc'); // decimal point
$lbl_height = __('Altura en cm:', 'wet_bmicalc');
$lbl_weight = __('Peso en kg:', 'wet_bmicalc');
$answer = __('Tu IMC is’, ‘wet_bmicalc’);
$bmi_table = __(’Jump to the BMI table »’, ‘wet_bmicalc’);
$bs = ‘\\’;
// all calculation is done by the client, trying to compensate for common errors like mixing meters with centimeters.
echo <<
JS;
// the widget’s form
echo $before_widget . $before_title . $title . $after_title;
echo ‘
echo ‘‘;
echo <<
FORM;
echo ‘
‘;
echo $after_widget;
}
// back end options dialogue
function wet_bmicalc_control() {
$options = get_option(’wet_bmicalc’);
if ( !is_array($options) )
$options = array(’title’=>__(’Calculate Your Body Mass Index’, ‘wet_bmicalc’), ‘buttontext’=>__(’Calculate’));
if ( $_POST[’wet_bmicalc-submit’] ) {
$options[’title’] = strip_tags(stripslashes($_POST[’wet_bmicalc-title’]));
$options[’buttontext’] = strip_tags(stripslashes($_POST[’wet_bmicalc-buttontext’]));
update_option(’wet_bmicalc’, $options);
}
$title = htmlspecialchars($options[’title’], ENT_QUOTES);
$buttontext = htmlspecialchars($options[’buttontext’], ENT_QUOTES);
echo ‘
‘;
echo ‘
‘;
echo ‘
‘;
}
// load all l10n string upon entry
load_plugin_textdomain(’wet_bmicalc’);
// let WP know of this plugin’s widget view entry
wp_register_sidebar_widget(’wet_bmicalc’, __(’Body Mass Index’, ‘wet_bmicalc’), ‘wet_bmicalc’,
array(
‘classname’ => ‘wet_bmicalc’,
‘description’ => __(’Allows the user to calculate the Body Mass Index (BMI) from body weight and height.’, ‘wet_bmicalc’)
)
);
// let WP know of this widget’s controller entry
wp_register_widget_control(’wet_bmicalc’, __(’Body Mass Index’, ‘wet_bmicalc’), ‘wet_bmicalc_control’,
array(
‘width’ => 300
)
);
}
add_action(’widgets_init’, ‘wet_bmicalc_init’);
?>
Últimos Comentarios