?> </option> </select> </label> </td> </tr> <tr> <th valign="top"><?php _e('Which pages?', 'adrotate'); ?> </th> <td> <label for="adrotate_pages"> <div class="adrotate-select"> <?php echo adrotate_select_pages($edit_group->page, 0, 0, 0); ?> </div><em><?php _e('Click the pages you want the adverts to show in.', 'adrotate'); ?> </em> </label> </td> </tr> </tbody> </table> <h3><?php _e('Usage', 'adrotate'); ?> </h3>
function adrotate_select_pages($savedpages, $count = 2, $child_of = 0, $parent = 0) { if (!is_array($savedpages)) { $savedpages = explode(',', $savedpages); } $pages = get_pages(array('child_of' => $parent, 'parent' => $parent, 'sort_column' => 'ID', 'sort_order' => 'asc')); if (!empty($pages)) { $output = ''; if ($parent == 0) { $output = '<table width="100%">'; if (count($pages) > 5) { $output .= '<thead><tr><td scope="col" class="manage-column check-column" style="padding: 0px;"><input type="checkbox" /></td><td style="padding: 0px;">Select All</td></tr></thead>'; } $output .= '<tbody>'; } foreach ($pages as $page) { if ($page->post_parent > 0) { if ($page->post_parent != $child_of) { $count = $count + 1; } $indent = ' ' . str_repeat('-', $count * 2) . ' '; } else { $indent = ''; } $output .= '<tr>'; $output .= '<th class="check-column" style="padding: 0px;"><input type="checkbox" name="adrotate_pages[]" value="' . $page->ID . '"'; if (in_array($page->ID, $savedpages)) { $output .= ' checked'; } $output .= '></th><td style="padding: 0px;">' . $indent . $page->post_title . '</td>'; $output .= '</tr>'; $output .= adrotate_select_pages($savedpages, $count, $page->post_parent, $page->ID); $child_of = $parent; } if ($parent == 0) { $output .= '</tbody></table>'; } return $output; } }