'alexaRankdigcms_Widget', 'description' => __('This Widget will show the Alexa website ranking as your choice', 'Alexa_Rank_Widget') ); /* Widget control settings. */ $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'alexa-rank-widget' ); /* Create the widget. */ $this->WP_Widget( 'alexa-rank-widget', __('Alexa Rank Widget', 'alexa_rank_widget'), $widget_ops, $control_ops ); } /** * How to display the widget on the screen. */ function widget( $args, $instance ) { extract( $args ); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title'] ); $website_name = $instance['website_name']; $button_size = $instance['button_size']; /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) echo $before_title . $title . $after_title; if( $button_size == 'squre') { echo ''; } else { echo ''; } /* After widget (defined by themes). */ echo $after_widget; } /** * Update the widget settings. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags for title and name to remove HTML (important for text inputs). */ $instance['title'] = strip_tags( $new_instance['title'] ); $instance['website_name'] = $new_instance['website_name']; $instance['button_size'] = $new_instance['button_size']; return $instance; } /** * Displays the widget settings controls on the widget panel. * Make use of the get_field_id() and get_field_name() function * when creating your form elements. This handles the confusing stuff. */ function form( $instance ) { /* Set up some default widget settings. */ $defaults = array( 'title' => __('Alexa Rank', 'Alexa Rank'), 'website_name' => 'digcms.com', 'button_size' => '120x95' ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>