__( 'Display quote of the day on your website/blog automatically updated everyday!', 'themeidol-all-widget' ), ) // Args ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { $qtype = apply_filters('widget_title', esc_attr($instance['qtype'])); $qdisplay = apply_filters('widget_title', esc_attr($instance['qdisplay'])); $title_hash = array( "none" => "Select Category", "any" => "All", "love" => "Love Quotes (Popular)", "inspirational" => "Inspirational Quotes (Popular)", "funny" => "Funny Quotes", "friendship" => "Friendship Quotes", "life" => "Life Quotes", "motivational" => "Motivational Quotes", "birthday" => "Birthday Quotes", "famous" => "Famous Quotes", "relationship" => "Relationship Quotes", "positive" => "Positive Quotes", "sad" => "Sad Quotes", "happiness" => "Happiness Quotes", "family" => "Family Quotes", "smile" => "Smile Quotes", "best" => "Best Quotes", "success" => "Success Quotes", "romantic" => "Romantic Quotes", "good" => "Good Quotes", "anniversary" => "Anniversary Quotes", "attitude" => "Attitude Quotes", "trust" => "Trust Quotes", ); echo $args['before_widget']; if ( ! empty( $qtype) ) $webpageurl=$_SERVER['REQUEST_URI']; $website=$_SERVER['SERVER_NAME']; $visitorip=$_SERVER['REMOTE_ADDR']; $resp = wp_remote_get('http://api.site2quotes.com/wp/quotations.aspx?category=' .$qtype. '&qdisplay=' .$qdisplay. '&visitorip=' .$visitorip. '&domain=' .$website. '&webpage=' .$webpageurl. '' ); if ( 200 == $resp['response']['code'] ) { $body = $resp['body']; echo __($body,'text_domain'); // perform action with the content. } echo $args['after_widget']; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form( $instance ) { if ( isset( $instance[ 'qtype' ] ) ) { $qtype = esc_attr($instance[ 'qtype' ]); } else { $qtype = "day"; } if ( isset( $instance[ 'qdisplay' ] ) ) { $qdisplay = esc_attr($instance[ 'qdisplay' ]); } else { $qdisplay = "image"; } ?>