'dribbble-widget', 'description' => 'A widget that show images dribbble' ); /* Create the widget. */ parent::__construct( 'rst-dribbble-widget', 'Angilla - Dribbble', $widget_ops); } function widget($args, $instance) { $html = ''; $html .= $args['before_widget']; if( !empty($instance['title']) ) { $html .= $args['before_title']; $html .= $instance['title']; $html .= $args['after_title']; } $html .= '
'; $user_id = isset($instance['user_id']) ? $instance['user_id'] : ''; $count = isset($instance['count']) ? absint($instance['count']) : '6'; $access_token = isset($instance['api_key']) ? $instance['api_key'] : ''; if( !empty($user_id) || !empty($access_token) ) { $dribbble_data = wp_remote_retrieve_body(wp_remote_get("https://api.dribbble.com/v1/users/$user_id/shots?access_token=$access_token&per_page=$count")); if( $dribbble_data ) { $dribbble = json_decode($dribbble_data, true); if( is_array($dribbble) ) { foreach($dribbble as $shot) : $html .= '
'; $html .= ''. $shot['title'] .''; $html .= '
'; endforeach; } } } $html .= '
'; $html .= '
'; $html .= $args['after_widget']; echo force_balance_tags($html); } function update($new_instance, $old_instance) { return $new_instance; } function form($instance) { ?>