'', 'video'=> 'http://www.youtube.com/watch?v=AYxu_MQSTTY', 'videoid' => 'AYxu_MQSTTY', 'width' => '200', 'height' => '165', ); if ( $_POST['a2zvideoapi-submit'] ) { // Remember to sanitize and format use input appropriately. $options['video'] = strip_tags(stripslashes($_POST['a2zvideoapi-video'])); $options['width'] = strip_tags(stripslashes($_POST['a2zvideoapi-width'])); $options['height'] = strip_tags(stripslashes($_POST['a2zvideoapi-height'])); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); /* Video API Server */ curl_setopt($ch, CURLOPT_URL, 'http://www.svnlabs.com/a2zvideoapi/server.php'); curl_setopt($ch, CURLOPT_POST, true); /* Request variables URL & Format for API server */ $post = array( 'url' => $options['video'], 'format' => "json" ); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $result = curl_exec($ch); $response = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); /* Output from a2zVideoAPI */ if($response==200) { $vid = json_decode($result); $options['title'] = $vid->video_title; $options['embed'] = $vid->video_embed; } // echo $result; update_option('widget_a2zvideoapi', $options); } // Be sure you format your options to be valid HTML attributes. $video = htmlspecialchars($options['video'], ENT_QUOTES); $width = htmlspecialchars($options['width'], ENT_QUOTES); $height = htmlspecialchars($options['height'], ENT_QUOTES); // Here is our little form segment. Notice that we don't need a // complete form. This will be embedded into the existing form. echo '

'; echo '

'; echo '

'; echo ''; } // This registers our widget so it appears with the other available // widgets and can be dragged and dropped into any active sidebars. register_sidebar_widget(array('a2zVideoAPI', 'widgets'), 'widget_a2zvideoapi'); // This registers our optional widget control form. Because of this // our widget will have a button that reveals a 300x100 pixel form. register_widget_control(array('a2zVideoAPI', 'widgets'), 'widget_a2zvideoapi_control', 300, 200); } // Run our code later in case this loads prior to any required plugins. add_action('widgets_init', 'widget_a2zvideoapi_init'); ?>