value[0];
return $result;
}else{
return -2;
}
}
//Action to initialize widget
add_action('widgets_init','alive_init');
//Register alive widget
function alive_init(){
register_widget('Widget_alive');
}
//Widget class to define functions of widget
class Widget_alive extends WP_Widget{
//define how widget looks on widgets page of user
function Widget_alive(){
$widget_ops = array( 'classname' => 'alive', 'description' => 'A widget that displays if the blogger is alive or deseaced.' );
$control_ops = array( 'width' => 200, 'height' => 300, 'id_base' => 'alive-widget' );
$this->WP_Widget( 'alive-widget', 'alive.io', $widget_ops, $control_ops );
}
function widget( $args, $instance ) {
extract( $args );
/* User-selected settings. */
$title = apply_filters('widget_title', $instance['title'] );
$alive_msg = $instance['alive_msg'];
$dead_msg = $instance['dead_msg'];
$show_image = isset( $instance['show_image'] ) ? $instance['show_image'] : false;
/*find out if user is alive or not*/
$status=showResult();
/* Before widget (defined by themes). */
echo $before_widget;
/* Title of widget (before and after defined by themes). */
if ( $title )
echo $before_title . $title . $after_title;
$opt_name = 'mt_alive_username'; //name of option
$username = get_option($opt_name);//get value from wprdpress database
$user_url = "http://".$username.".alive.io";
/* Display alive_msg when alive and dead_msg when deceased from widget settings. */
if($status == 1){
?>
';
echo $alive_msg?>
';
echo $dead_msg ?>
HTML OK FOR ALL FIELDS
id="get_field_id( 'show_image' ); ?>" name="get_field_name( 'show_image' ); ?>" />