function b_wp_categories_show($options) { $block_style = $options[0] ? $options[0] : 0; $with_count = $options[1] ? $options[1] : 0; $sorting_key = $options[2] ? $options[2] : 'name'; $sorting_order = $options[3] ? $options[3] : 'asc'; $id = 1; global $dateformat, $time_difference, $siteurl, $blogfilename; global $tablelinks, $tablelinkcategories; global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week; global $tableposts, $tablepost2cat, $tablecomments, $tablecategories; global $smilies_directory, $use_smilies, $wp_smiliessearch, $wp_smiliesreplace; global $wp_bbcode, $use_bbcode, $wp_gmcode, $use_gmcode, $use_htmltrans, $wp_htmltrans, $wp_htmltranswinuni; require_once dirname(__FILE__) . '/../wp-blog-header.php'; if ($block_style == 0) { // Simple Listing ob_start(); list_cats(0, 'All', $sorting_key, $sorting_order, '', true, 0, $with_count); $block['content'] = ob_get_contents(); ob_end_clean(); } else { // Dropdown Listing $file = "{$siteurl}/{$blogfilename}"; $link = $file . $querystring_start . 'cat' . $querystring_equal; ob_start(); echo '<form name="listcatform" action="">'; $select_str = '<select name="cat" onchange="window.location = (\'' . $link . '\'+document.forms.listcatform.cat[document.forms.listcatform.cat.selectedIndex].value);"> '; dropdown_cats(1, _WP_LIST_CAT_ALL, $sorting_key, $sorting_order, 0, $with_count); echo '</form>'; $block_str = ob_get_contents(); ob_end_clean(); $block['content'] = ereg_replace('\\<select name\\=[^\\>]*\\>', $select_str, $block_str); } return $block; }
function b_wp_recent_posts_edit($options, $wp_num = "") { global $wpdb, $siteurl, $wp_id, $wp_inblock, $use_cache; $form = "<table width='100%'>"; $form .= "<tr><td width='40%'>Number of Posts in this block:</td>"; $form .= "<td><input type='text' name='options[]' value='" . $options[0] . "' /></td></tr>"; $form .= "<tr><td>Display Posted Date:</td>"; $chk = $options[1] == 1 ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[1]' value='1'" . $chk . " /> " . _YES . " "; $chk = $options[1] == 0 ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[1]' value='0'" . $chk . " /> " . _NO . "</td></tr>"; $form .= "<tr><td>Display RSS Icon:</td>"; $chk = $options[2] == 1 ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[2]' value='1'" . $chk . " /> " . _YES . " "; $chk = $options[2] == 0 ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[2]' value='0'" . $chk . " /> " . _NO . "</td></tr>"; $form .= "<tr><td>Display RDF Icon:</td>"; $chk = $options[3] == 1 ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[3]' value='1'" . $chk . " /> " . _YES . " "; $chk = $options[3] == 0 ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[3]' value='0'" . $chk . " /> " . _NO . "</td></tr>"; $form .= "<tr><td>Display RSS2 Icon:</td>"; $chk = $options[4] == 1 ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[4]' value='1'" . $chk . " /> " . _YES . " "; $chk = $options[4] == 0 ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[4]' value='0'" . $chk . " /> " . _NO . "</td></tr>"; $form .= "<tr><td>Display ATOM Icon:</td>"; $chk = $options[5] == 1 ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[5]' value='1'" . $chk . " /> " . _YES . " "; $chk = $options[5] == 0 ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[5]' value='0'" . $chk . " /> " . _NO . "</td></tr>"; $form .= "<tr><td>Number of Posts in Meta Feed(RSS,RDF,ATOM):</td>"; $form .= "<td><input type='text' name='options[6]' value='" . $options[6] . "' /></td></tr>"; $form .= "<tr><td>Listing only in a following categoty:</td><td>"; if ($wp_num == "") { $wp_id = $wp_num; $wp_inblock = 1; require dirname(__FILE__) . '/../wp-config.php'; $wp_inblock = 0; } $cat = $options[7]; ob_start(); dropdown_cats(1, _WP_LIST_CAT_ALL, 'ID', 'asc', 0, 0, 0, FALSE, $options[7]); $list_str = ob_get_contents(); ob_end_clean(); $select_str = '<select name="options[7]">'; $form .= ereg_replace('\\<select name\\=[^\\>]*\\>', $select_str, $list_str); $form .= "</td></tr>"; $form .= "<tr><td>Display New Flag:</td>"; $chk = $options[8] == 1 ? " checked='checked'" : ""; $form .= "<td><input type='radio' name='options[8]' value='1'" . $chk . " /> " . _YES . " "; $chk = $options[8] == 0 ? " checked='checked'" : ""; $form .= "<input type='radio' name='options[8]' value='0'" . $chk . " /> " . _NO . "</td></tr>"; $form .= "</table>"; return $form; }
function b_wp_categories_show($options, $wp_num = "") { $block_style = $options[0] ? $options[0] : 0; $with_count = $options[1] ? $options[1] : 0; $sorting_key = $options[2] ? $options[2] : 'name'; $sorting_order = $options[3] ? $options[3] : 'asc'; global $wpdb, $siteurl, $wp_id, $wp_inblock, $user_cache, $category_name, $cat; $id = 1; $use_cache = 1; $cat = intval($_GET['cat']); $category_name = $_GET['category_name']; if ($wp_num == "") { $wp_id = $wp_num; $wp_inblock = 1; require dirname(__FILE__) . '/../wp-config.php'; $wp_inblock = 0; } if ($block_style == 0) { // Simple Listing ob_start(); list_cats(0, 'All', $sorting_key, $sorting_order, '', true, 0, $with_count); $block['content'] = ob_get_contents(); ob_end_clean(); } else { // Dropdown Listing $file = "{$siteurl}/index.php"; $link = $file . '?cat='; ob_start(); echo '<form name="listcatform' . $wp_num . '" action="">'; $select_str = '<select name="cat" onchange="window.location = (\'' . $link . '\'+document.forms.listcatform' . $wp_num . '.cat[document.forms.listcatform' . $wp_num . '.cat.selectedIndex].value);"> '; dropdown_cats(1, _WP_LIST_CAT_ALL, $sorting_key, $sorting_order, 0, $with_count); echo '</form>'; $block_str = ob_get_contents(); ob_end_clean(); $block['content'] = ereg_replace('\\<select name\\=[^\\>]*\\>', $select_str, $block_str); } return $block; }
function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $optiondates = 0, $optioncount = 0, $hide_empty = 0, $optionnone = false, $selected = 0, $hide = 0, $hierarchical = true, $child_of = 0, $link = false, $level = 0, $echo = true, $categoryObjects = null) { $dropdown_cats = ""; if (!$selected) { $selected = empty($GLOBALS['cat']) ? 0 : $GLOBALS['cat']; } if (!isset($categoryObjects)) { $criteria =& new CriteriaCompo(new Criteria('cat_ID', 0, '>')); if ($hide) { $criteria->add(new Criteria('cat_ID', $hide, '!=')); $catc = trim(get_category_children($hide, '', ' ')); $catc_array = explode(' ', $catc); for ($i = 0; $i < count($catc_array); $i++) { $criteria->add(new Criteria('category_id', intval($catc_array[$i]), '!=')); } } $criteria->setGroupBy('cat_ID'); $criteria->setSort('cat_' . $sort_column); $criteria->setOrder($sort_order); $joinCriteria =& new XoopsJoinCriteria(wp_table('post2cat'), 'cat_ID', 'category_id'); $joinCriteria->cascade(new XoopsJoinCriteria(wp_table('posts'), 'post_id', 'ID')); $categoryHandler =& wp_handler('Category'); $categoryObjects =& $categoryHandler->getObjects($criteria, false, 'cat_ID, cat_name, category_nicename,category_parent, category_description cat_description, COUNT(' . wp_table('post2cat') . '.post_id) AS cat_count,DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth', false, $joinCriteria); } if ($level == 0) { $dropdown_cats .= "<select name='cat' class='postform'>\n"; } if (intval($optionall) == 1) { $all = apply_filters('list_cats', $all); if ($link) { $dropdown_cats .= "\t<option value='" . wp_siteurl() . "'>{$all}</option>\n"; } else { $dropdown_cats .= "\t<option value='all'>{$all}</option>\n"; } } if (intval($optionnone) == 1) { $dropdown_cats .= "\t<option value='0'>None</option>\n"; } if ($categoryObjects) { foreach ($categoryObjects as $categoryObject) { if (!$hierarchical || $child_of == $categoryObject->getVar('category_parent')) { if (intval($hide_empty) != 1 || $categoryObject->getVar('cat_count') > 0) { $pad = str_repeat('– ', $level); $cat_name = apply_filters('list_cats', $pad . $categoryObject->getVar('cat_name')); if ($link) { $dropdown_cats .= "\t<option value=\"" . get_category_link(false, $categoryObject->getVar('cat_ID'), $categoryObject->getVar('category_nicename')) . "\""; } else { $dropdown_cats .= "\t<option value=\"" . $categoryObject->getVar('cat_ID') . "\""; } if ($categoryObject->getVar('cat_ID') == $selected) { $dropdown_cats .= ' selected="selected"'; } $dropdown_cats .= '>'; $dropdown_cats .= $cat_name; if (intval($optioncount) == 1) { $dropdown_cats .= ' (' . $categoryObject->getExtraVar('cat_count') . ')'; } if (intval($optiondates) == 1) { $dropdown_cats .= ' ' . $categoryObject->getExtraVar('lastday') . '/' . $categoryObject->getExtraVar('lastmonth'); } $dropdown_cats .= "</option>\n"; } $dropdown_cats .= dropdown_cats(0, '', $sort_column, $sort_order, $optiondates, $optioncount, $hide_empty, $optionnone, $selected, $hide, $hierarchical = true, $categoryObject->getVar('cat_ID'), $link, $level + 1, false, $categoryObjects); } } } if ($level == 0) { $dropdown_cats .= "</select>\n"; } return _echo($dropdown_cats, $echo); }
/** * @desc Output of plugin composing the list_cats function call * @author Georg Leciejewski */ function widget_king_search($args, $number = 1) { global $s; # $args is an array of strings that help widgets to conform to # the active theme: before_widget, before_title, after_widget, # and after_title are the array keys. Default tags: li and h2. extract($args, EXTR_PREFIX_ALL, "default"); $options = get_option('widget_king_search'); $title = $options[$number]['title']; $use_suggestion = $options[$number]['use_suggestion'] ? 1 : 0; $use_catsearch = $options[$number]['use_catsearch'] ? 1 : 0; $show_category = $options[$number]['show_category'] ? 1 : 0; $category_id = $options[$number]['category_id']; $show_on_site_area = $options[$number]['show_on_site_area'] ? 1 : 0; $site_area_id = $options[$number]['site_area_id']; $site_area = $options[$number]['site_area']; $before_widget = empty($options[$number]['before_widget']) ? $default_before_widget : stripslashes($options[$number]['before_widget']); $before_widget_title = empty($options[$number]['before_widget_title']) ? $default_before_title : stripslashes($options[$number]['before_widget_title']); $after_widget_title = empty($options[$number]['after_widget_title']) ? $default_after_title : stripslashes($options[$number]['after_widget_title']); $after_widget = empty($options[$number]['after_widget']) ? $default_after_widget : stripslashes($options[$number]['after_widget']); # These lines generate our output. #if events search mode if (!empty($category_id)) { #if specific category is selected $post = $wp_query->post; if (in_category($category_id)) { echo $before_widget . "\n"; echo $before_widget_title . "\n"; echo $title . "\n"; echo $after_widget_title . "\n"; ?> <form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <p> <input type="text" name="s" id="s" size="15" value="<?php echo wp_specialchars($s, 1); ?> " /><br /> <?php if (!empty($use_catsearch)) { _e('Search only category:', 'widgetKing'); dropdown_cats(); } ?> <br /> <input type="submit" value="<?php _e('Search'); ?> " /> </p> </form> <?php if (!empty($use_suggestion)) { if (!empty($s)) { king_search_suggest(wp_specialchars($s, 1)); } } echo $after_widget . "\n"; } #else{} } elseif (!empty($show_on_site_area)) { #if sitearea is selected if ($site_area($site_area_id)) { echo $before_widget . "\n"; echo $before_widget_title . "\n"; echo $title . "\n"; echo $after_widget_title . "\n"; ?> <form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <p> <input type="text" name="s" id="s" size="15" value="<?php echo wp_specialchars($s, 1); ?> " /><br /> <?php if (!empty($use_catsearch)) { _e('Search only category:', 'widgetKing'); dropdown_cats(); } ?> <br /> <input type="submit" value="<?php _e('Search'); ?> " /> </p> </form> <?php if (!empty($use_suggestion)) { if (!empty($s)) { king_search_suggest(wp_specialchars($s, 1)); } } echo $after_widget . "\n"; } #else{} } else { #no category id selected echo $before_widget . "\n"; echo $before_widget_title . "\n"; echo $title . "\n"; echo $after_widget_title . "\n"; ?> <form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <p> <input type="text" name="s" id="s" size="15" value="<?php echo wp_specialchars($s, 1); ?> " /><br /> <?php if (!empty($use_catsearch)) { _e('Search only in category:', 'widgetKing'); echo '<br />'; dropdown_cats(); } ?> <br /> <input type="submit" value="<?php _e('Search'); ?> " /> </p> </form> <?php if (!empty($use_suggestion)) { if (!empty($s)) { king_search_suggest(wp_specialchars($s, 1)); } } echo $after_widget . "\n"; } }
function _b_wp_categories_show($options, $wp_num = "") { $block_style = $options[0] ? $options[0] : 0; $with_count = $options[1] ? $options[1] : 0; $sorting_key = $options[2] ? $options[2] : 'name'; $sorting_order = $options[3] ? $options[3] : 'asc'; if (current_wp()) { if (!empty($_SERVER['PATH_INFO'])) { permlink_to_param(); } init_param('GET', 'cat', 'string', ''); init_param('GET', 'category_name', 'string', ''); if (!empty($GLOBALS['category_name']) && empty($GLOBALS['cat'])) { if (stristr($GLOBALS['category_name'], '/')) { $GLOBALS['category_name'] = explode('/', $GLOBALS['category_name']); if ($GLOBALS['category_name'][count($GLOBALS['category_name']) - 1]) { $GLOBALS['category_name'] = $GLOBALS['category_name'][count($GLOBALS['category_name']) - 1]; // no trailing slash } else { $GLOBALS['category_name'] = $GLOBALS['category_name'][count($GLOBALS['category_name']) - 2]; // there was a trailling slash } } $categoryHandler =& wp_handler('Category'); $categoryObject =& $categoryHandler->getByNiceName($GLOBALS['category_name']); $GLOBALS['cat'] = $categoryObject->getVar('cat_ID'); } } if ($block_style == 0) { // Simple Listing ob_start(); block_style_get($wp_num); echo '<ul class="wpBlockList">' . "\n"; wp_list_cats("hide_empty=0&sort_column={$sorting_key}&sorting_order={$sorting_order}&optioncount={$with_count}"); echo '</ul>' . "\n"; $block['content'] = ob_get_contents(); ob_end_clean(); } else { // Dropdown Listing $file = wp_siteurl() . '/index.php'; $link = $file . '?cat='; ob_start(); block_style_get($wp_num); echo '<form name="listcatform' . $wp_num . '" id="listcatform' . $wp_num . '" action="#">'; $select_str = '<select name="cat" onchange="window.location = (document.forms.listcatform' . $wp_num . '.cat[document.forms.listcatform' . $wp_num . '.cat.selectedIndex].value);"> '; dropdown_cats(1, _WP_LIST_CAT_ALL, $sorting_key, $sorting_order, 0, $with_count, 0, false, 0, 0, true, 0, true, 0); echo '</form>'; $block_str = ob_get_contents(); ob_end_clean(); $block['content'] = ereg_replace('\\<select name\\=[^\\>]*\\>', $select_str, $block_str); } return $block; }
<li><h2><?php _e('Categories'); ?> </h2> <ul> <?php list_cats(0, '', 'name', 'asc', '', 1, 0, 1, 1, 1, 1, 0, '', '', '', '', ''); ?> </ul> --> <form action="<?php echo $PHP_SELF; ?> " method="get"> <?php dropdown_cats(1, 'All Categories', 'name', '', 0, 1, 1); ?> <input type="submit" name="submit" value="view"></input> </form> </li> <?php include TEMPLATEPATH . '/searchform.php'; ?> <?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>'); ?> <?php
/** * display the options page * @param string Which update message to show. Either 'updated' or 'delete'. * @since version 2.0 */ function display_options_page($updated = false) { if ($updated) { echo '<div id="message" class="updated fade"><p><strong>' . __('Options saved.', 'cqs') . '</strong></p></div>'; } ob_start(); ?> <form name="cqsoptions" method="post"> <?php if ($this->options) { ?> <div class="wrap" onmouseover="window.status='Customize My Queries Please!'; return true;"><h2>Custom Query String <?php echo k_CQS_VER; ?> </h2> <h3><?php _e('Current Conditions', 'cqs'); ?> </h3> <table cellspacing="2" cellpadding="5" width="100%"> <tr class="alternate"> <th></th> <th><?php _e('Condition', 'cqs'); ?> </th> <th><?php _e('Result', 'cqs'); ?> </th> </tr> <?php $i = 0; foreach ($this->options as $condition => $cqs_option) { # get the name of cat for display. if (strpos($condition, 'cat_') !== false) { $cat_id = str_replace('cat_', '', $condition); $cat_name = $this->get_category_nicename(intval($cat_id)); $display_condition = 'cat_' . $cat_name; } else { $display_condition = $condition; } ?> <tr valign="top" <?php if ($i % 2 != 0) { echo 'class="alternate"'; } ?> > <td><input type="checkbox" name="cqs[delete][]" value="<?php echo $condition; ?> " /></td> <td><strong><?php echo $display_condition; ?> </strong></td> <td><?php $string = __('Show <strong>%posts_per_page% %what_to_show%</strong> per page, ordered by %orderby% %order%', 'cqs'); echo str_replace(array('%posts_per_page%', '%what_to_show%', '%orderby%', '%order%'), array($cqs_option['posts_per_page'], $cqs_option['what_to_show'], $cqs_option['orderby'], $cqs_option['order']), $string); ?> </td> </tr> <?php $i++; } ?> </table> <p class="submit"> <input type="submit" class="button" name="cqs[deleteChecked]" value="<?php _e('Delete Checked', 'cqs'); ?> " /> <?php $this->check_all_js(); ?> </p> <?php } ?> <h3 style="margin-top:4em;"><?php _e('Add New Condition', 'cqs'); ?> </h3> <p><?php _e('To update current conditions replace them with new ones here. Use \'-1\' to show all posts.', 'cqs'); ?> </p> <table cellspacing="2" cellpadding="5" width="100%"> <tr class="alternate"> <th> </th> <th><?php _e('Condition', 'cqs'); ?> </th> <th><?php _e('Show', 'cqs'); ?> </th> <th><?php _e('Order By', 'cqs'); ?> </th> <th> </th> </tr> <tr> <th scope="row"><?php _e('Query', 'cqs'); ?> </th> <td> <select name="cqs[condition]"> <?php foreach ($this->conditions as $condition) { echo "<option>{$condition}</option>"; } ?> </select> </td> <td> <input type="text" name="cqs[posts_per_page]" size="3" /> <select name="cqs[what_to_show]"> <?php foreach ($this->what_to_shows as $what_to_show) { echo "<option>{$what_to_show}</option>"; } ?> </select> </td> <td> <select name="cqs[orderby]"> <?php foreach ($this->orderbys as $orderby) { echo "<option>{$orderby}</option>"; } ?> </select> <select name="cqs[order]"> <?php foreach ($this->orders as $order) { echo "<option>{$order}</option>"; } ?> </select> </td> <td><input type="submit" class="button" name="cqs[add]" value="<?php _e('Add', 'cqs'); ?> " /></td> </tr> <tr class="alternate"> <th scope="row"><?php _e('Category', 'cqs'); ?> </th> <td> <?php dropdown_cats(0, 'All', 'ID', 'asc', 0, 0, 0, FALSE, 0, 0); ?> </td> <td> <input type="text" name="cqs[category][posts_per_page]" size="3" /> <select name="cqs[category][what_to_show]"> <?php foreach ($this->what_to_shows as $what_to_show) { echo "<option>{$what_to_show}</option>"; } ?> </select> </td> <td> <select name="cqs[category][orderby]"> <?php foreach ($this->orderbys as $orderby) { echo "<option>{$orderby}</option>"; } ?> </select> <select name="cqs[category][order]"> <?php foreach ($this->orders as $order) { echo "<option>{$order}</option>"; } ?> </select> </td> <td><input type="submit" class="button" name="cqs[addCategory]" value="<?php _e('Add', 'cqs'); ?> " /></td> </tr> </table> <?php $this->footer(); ?> </div> </form> <?php ob_end_flush(); }
function b_wp_categories_show($options, $wp_num = "") { $block_style = $options[0] ? $options[0] : 0; $with_count = $options[1] ? $options[1] : 0; $sorting_key = $options[2] ? $options[2] : 'name'; $sorting_order = $options[3] ? $options[3] : 'asc'; global $wpdb, $siteurl, $wp_id, $wp_inblock, $user_cache, $cache_categories, $category_name, $cat; $id = 1; $use_cache = 1; if ($wp_num == "") { $wp_id = $wp_num; $wp_inblock = 1; require dirname(__FILE__) . '/../wp-config.php'; $wp_inblock = 0; } $cur_PATH = $_SERVER['SCRIPT_FILENAME']; if (preg_match("/^" . preg_quote(XOOPS_ROOT_PATH . "/modules/wordpress" . $wp_num . "/", "/") . "/i", $cur_PATH)) { $cat = array_key_exists('cat', $_GET) ? intval($_GET['cat']) : null; $category_name = array_key_exists('category_name', $_GET) ? $_GET['category_name'] : ''; if ($category_name and $cat == 0) { $category_name = preg_replace('|/+$|', '', $category_name); $cat = $wpdb->get_var("SELECT cat_ID FROM {$wpdb->categories[$wp_id]} WHERE category_nicename='{$category_name}'"); } } if ($block_style == 0) { // Simple Listing ob_start(); echo "<ul>\n"; wp_list_cats("sort_column={$sorting_key}&sorting_order={$sorting_order}&optioncount={$with_count}"); echo "</ul>\n"; $block['content'] = ob_get_contents(); ob_end_clean(); } else { // Dropdown Listing $file = "{$siteurl}/index.php"; $link = $file . '?cat='; ob_start(); echo '<form name="listcatform' . $wp_num . '" action="">'; $select_str = '<select name="cat" onchange="window.location = (\'' . $link . '\'+document.forms.listcatform' . $wp_num . '.cat[document.forms.listcatform' . $wp_num . '.cat.selectedIndex].value);"> '; dropdown_cats(1, _WP_LIST_CAT_ALL, $sorting_key, $sorting_order, 0, $with_count); echo '</form>'; $block_str = ob_get_contents(); ob_end_clean(); $block['content'] = ereg_replace('\\<select name\\=[^\\>]*\\>', $select_str, $block_str); } return $block; }
function b_wp_categories_show($options, $wp_num = "") { $block_style = $options[0] ? $options[0] : 0; $with_count = $options[1] ? $options[1] : 0; $sorting_key = $options[2] ? $options[2] : 'name'; $sorting_order = $options[3] ? $options[3] : 'asc'; global $wpdb, $siteurl, $wp_id, $wp_inblock, $user_cache, $cache_categories, $category_name, $cat, $wp_mod, $wp_base; $id = 1; $use_cache = 1; if ($wp_num == "") { $wp_id = $wp_num; $wp_inblock = 1; require dirname(__FILE__) . '/../wp-config.php'; $wp_inblock = 0; } if (current_wp()) { param('cat', 'string', ''); param('category_name', 'string', ''); if ($category_name && !$cat) { if (stristr($category_name, '/')) { $category_name = explode('/', $category_name); if ($category_name[count($category_name) - 1]) { $category_name = $category_name[count($category_name) - 1]; // no trailing slash } else { $category_name = $category_name[count($category_name) - 2]; // there was a trailling slash } } $cat = $wpdb->get_var("SELECT cat_ID FROM {$wpdb->categories[$wp_id]} WHERE category_nicename='{$category_name}'"); } } if ($block_style == 0) { // Simple Listing ob_start(); block_style_get($wp_num); echo "<ul class='wpBlockList'>\n"; wp_list_cats("sort_column={$sorting_key}&sorting_order={$sorting_order}&optioncount={$with_count}"); echo "</ul>\n"; $block['content'] = ob_get_contents(); ob_end_clean(); } else { // Dropdown Listing $file = "{$siteurl}/index.php"; $link = $file . '?cat='; ob_start(); block_style_get($wp_num); echo '<form name="listcatform' . $wp_num . '" action="">'; $select_str = '<select name="cat" onchange="window.location = (document.forms.listcatform' . $wp_num . '.cat[document.forms.listcatform' . $wp_num . '.cat.selectedIndex].value);"> '; dropdown_cats(1, _WP_LIST_CAT_ALL, $sorting_key, $sorting_order, 0, $with_count, 0, false, 0, 0, true, 0, true, 0); echo '</form>'; $block_str = ob_get_contents(); ob_end_clean(); $block['content'] = ereg_replace('\\<select name\\=[^\\>]*\\>', $select_str, $block_str); } return $block; }
function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $optiondates = 0, $optioncount = 0, $hide_empty = 0, $optionnone = false, $selected = 0, $hide = 0, $hierarchical = true, $child_of = 0, $link = false, $level = 0) { global $wpdb, $wp_id, $siteurl, $cat; if (!$selected) { $selected = $cat; } $query = "\n SELECT cat_ID, cat_name, category_nicename,category_parent, category_description cat_description,\n COUNT({$wpdb->post2cat[$wp_id]}.post_id) AS cat_count,\n DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth\n FROM {$wpdb->categories[$wp_id]} LEFT JOIN {$wpdb->post2cat[$wp_id]} ON (cat_ID = category_id)\n LEFT JOIN {$wpdb->posts[$wp_id]} ON (ID = post_id)\n WHERE cat_ID > 0\n "; if ($hide) { $query .= " AND cat_ID != {$hide}"; $query .= get_category_children($hide, " AND cat_ID != "); } $query .= " GROUP BY cat_ID"; $query .= " ORDER BY cat_{$sort_column} {$sort_order}, post_date DESC"; $categories = $wpdb->get_results($query); if ($level == 0) { echo "<select name='cat' class='postform'>\n"; } if (intval($optionall) == 1) { $all = apply_filters('list_cats', $all); echo "\t<option value='all'>{$all}</option>\n"; } if (intval($optionnone) == 1) { echo "\t<option value='0'>None</option>\n"; } if ($categories) { foreach ($categories as $category) { if (!$hierarchical || $child_of == $category->category_parent) { if (intval($hide_empty) != 1 || $category->cat_count > 0) { $pad = str_repeat('– ', $level); $cat_name = apply_filters('list_cats', $pad . $category->cat_name); if ($link) { echo "\t<option value=\"" . get_category_link(false, $category->cat_ID, $category->category_nicename) . "\""; } else { echo "\t<option value=\"" . $category->cat_ID . "\""; } if ($category->cat_ID == $selected) { echo ' selected="selected"'; } echo '>'; echo $cat_name; if (intval($optioncount) == 1) { echo ' (' . $category->cat_count . ')'; } if (intval($optiondates) == 1) { echo ' ' . $category->lastday . '/' . $category->lastmonth; } echo "</option>\n"; } dropdown_cats(0, '', $sort_column, $sort_order, $optiondates, $optioncount, $hide_empty, $optionnone, $selected, $hide, $hierarchical = true, $category->cat_ID, $link, $level + 1); } } } if ($level == 0) { echo "</select>\n"; } }