Example #1
0
?>
</option>
		        </select>
			</label>
	        </td>
      	</tr>
      	<tr>
	        <th valign="top"><?php 
_e('Which categories?', 'adrotate');
?>
</th>
	        <td>
	        <label for="adrotate_categories">
				<div class="adrotate-select">
		        <?php 
echo adrotate_select_categories($edit_group->cat, 0, 0, 0);
?>
				</div><em><?php 
_e('Click the categories posts you want the adverts to show in.', 'adrotate');
?>
</em>
	        </label>
	        </td>
      	</tr>
      	<tr>
	        <th valign="top"><?php 
_e('In pages?', 'adrotate');
?>
</th>
	        <td>
	        <label for="adrotate_page_location">
Example #2
0
function adrotate_select_categories($savedcats, $count = 2, $child_of = 0, $parent = 0)
{
    if (!is_array($savedcats)) {
        $savedcats = explode(',', $savedcats);
    }
    $categories = get_categories(array('child_of' => $parent, 'parent' => $parent, 'orderby' => 'id', 'order' => 'asc', 'hide_empty' => 0));
    if (!empty($categories)) {
        $output = '';
        if ($parent == 0) {
            $output = '<table width="100%">';
            if (count($categories) > 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 ($categories as $category) {
            if ($category->parent > 0) {
                if ($category->parent != $child_of) {
                    $count = $count + 1;
                }
                $indent = '&nbsp;' . str_repeat('-', $count * 2) . '&nbsp;';
            } else {
                $indent = '';
            }
            $output .= '<tr>';
            $output .= '<th class="check-column" style="padding: 0px;"><input type="checkbox" name="adrotate_categories[]" value="' . $category->cat_ID . '"';
            if (in_array($category->cat_ID, $savedcats)) {
                $output .= ' checked';
            }
            $output .= '></th><td style="padding: 0px;">' . $indent . $category->name . ' (' . $category->category_count . ')</td>';
            $output .= '</tr>';
            $output .= adrotate_select_categories($savedcats, $count, $category->parent, $category->cat_ID);
            $child_of = $parent;
        }
        if ($parent == 0) {
            $output .= '</tbody></table>';
        }
        return $output;
    }
}