'agentrank_client', 'description' => __('A Widget to get Agent Client Reviews from RealtyBaron\'s AgentRank API ', 'agentrank_client') ); $control_ops = array( 'width' => 200, 'height' => 350, 'id_base' => 'agentrank_client' ); $this->WP_Widget( 'agentrank_client', __('AgentRank Client Reviews', 'agentrank_client'), $widget_ops, $control_ops ); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', $instance['title'] ); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; //check options API Key $check_key = get_option('agent_apikey'); //if api key not empty, proceed to do api call //else display error message if(!empty($check_key)){ //use agentrank rest api class to request xml response global $agapi; $xml = $agapi->sidebar_client_reviews(0); if(!empty($xml)){ //start display widget $html = "
"; //get status code 400 error 200 ok $status_code = $xml->status['code']; if($status_code = "400"){ //catch error message for status 400 foreach ($xml->status->messages as $mess){ $errormessage = $mess->message; echo ""; } }//end if($status_code = "400") //check status code 200 is ok 400 is error if($status_code = "200"){ if(!empty($xml->reviews->review)){ $html .= ""; }else{ $html .= ""; } }//end if($status_code = "200") $review_url = get_bloginfo('url')."/agentrank/reviews"; if(!empty($xml->reviews->review)){ $html .= ""; } $html .= ""; echo $html; }//end if(!empty($xml)) }else{ echo ""; echo ""; $plugin_admin_url_structure = get_bloginfo('url')."/wp-admin/options-general.php?page=agentrank_option.php"; echo "AgentRank Admin Settings"; }//end if(!empty($check_key)) //lastly check if empty xml return from rest api class will indicate service unavailable //return Service is Unavailable message! if(empty($xml)&&!empty($check_key)){ echo ""; } echo $after_widget; }//end of function widget function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); return $instance; } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '') ); $instance['title'] = strip_tags( $instance['title'] ); ?>