<tr> <th scope="row"><?php _e('Albums Page'); ?> </th> <td> <select name="fb_albums_page"> <?php if (!fb_albums_page_is_set()) { ?> <option value="0" selected>Please select...</option> <?php } ?> <?php fb_parent_dropdown($fb_albums_page); ?> </select><br /> <small>Select the page you want to use to display the photo albums.</small> </td> </tr> <tr> <th scope="row"><?php _e('Albums Per Page'); ?> </th> <td> <input name="fb_albums_per_page" type="text" value="<?php echo $fb_albums_per_page; ?> " size="3" />
function fb_parent_dropdown($default = 0, $parent = 0, $level = 0) { global $wpdb; $albums_page = get_option('fb_albums_page'); $items = $wpdb->get_results("SELECT `ID`, `post_parent`, `post_title` FROM `{$wpdb->posts}` WHERE `post_parent` = '{$parent}' AND `post_type` = 'page' AND `post_parent` != '{$albums_page}' ORDER BY `menu_order`"); if ($items) { foreach ($items as $item) { $pad = str_repeat(' ', $level * 3); if ($item->ID == $default) { $current = ' selected="selected"'; } else { $current = ''; } echo "\n\t<option value='{$item->ID}'{$current}>{$pad} " . wp_specialchars($item->post_title) . "</option>"; fb_parent_dropdown($default, $item->ID, $level + 1); } } else { return false; } }