'Pages', 'headpage'=>'0'); if ( $_POST['subpagehierarchy-submit'] ) { // Remember to sanitize and format use input appropriately. $options['title'] = strip_tags(stripslashes($_POST['subpagehierarchy-title'])); $options['headpage'] = strip_tags(stripslashes($_POST['subpagehierarchy-headpage'])); update_option('widget_subpagehierarchy', $options); } // Be sure you format your options to be valid HTML attributes. $title = htmlspecialchars($options['title'], ENT_QUOTES); $headpage = intval($options['headpage']); // Here is our little form segment. Notice that we don't need a // complete form. This will be embedded into the existing form. echo '
'; // Get the details for the drop down box $dropargs = array( 'selected' => $headpage, 'name' => "subpagehierarchy-headpage", 'id' => "subpagehierarchy-headpage" ); $pages = get_pages(); if(!empty($pages)): echo ''; else: echo 'To use this widget, please add some pages to your site.
'; endif; 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('Sub page hierarchy', 'widget_subpagehierarchy'); // 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('Sub page hierarchy', 'widget_subpagehierarchy_control', 400, 200); } // Run our code later in case this loads prior to any required plugins. add_action('plugins_loaded', 'widget_subpagehierarchy_init'); ?>