$class_name, 'description' => $calc_desc ) ); // wp_register_sidebar_widget wp_register_widget_control( $class_name, $calc_title, array($class_name, 'bodycomp_calculator_control'), array('width' => '100%') ); // wp_register_widget_congrol add_shortcode( $class_name, array($class_name, 'bodycomp_calculator_shortcode') ); // add_shortcode } // function bodycomp_calc_init function display($is_widget, $args=array()) { if ($is_widget) { extract($args); $options = get_option('eatregularlydotcom_bodycomp_calculator'); $title = $options['title']; $output[] = $before_widget . $before_title . $title . $after_title; } // if $is_widget $output[] = '
Body Composition Change Calculator
Starting Composition
Ending Composition
'; $output[] = $after_widget; return join($output, "\n"); } // function display function bodycomp_calculator_control() { $class_name = 'eatregularlydotcom_bodycomp_calculator'; $calc_title = 'Body Compostiton Calculator'; $options = get_option($class_name); if (!is_array($options)) $options = array('title'=>$calc_title); if ($_POST[$class_name.'_submit']) { $options['title'] = strip_tags(stripslashes($_POST[$class_name.'_title'])); update_option($class_name, $options); } // if $title = htmlspecialchars($options['title'], ENT_QUOTES); echo '

Title:

'; echo ''; } // function bodycomp_calculator_control function bodycomp_calculator_shortcode($args, $content=null) { wp_enqueue_script('bodycomp-script', plugins_url('bodycomp.js', __FILE__), false, false, false); return eatregularlydotcom_bodycomp_calculator::display(false, $args); } // function bodycomp_calculator_shortcode function bodycomp_calculator_widget($args) { wp_enqueue_script('bodycomp-script', plugins_url('bodycomp.js', __FILE__), false, false, false); echo eatregularlydotcom_bodycomp_calculator::display(true, $args); } // function bodycomp_calculator_widget } // class eatregularlydotcom_bodycomp_calculator add_action('widgets_init', array('eatregularlydotcom_bodycomp_calculator', 'bodycomp_calculator_init')); ?>