Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • @froman118

    Two things:

    1. I havn’t yet noticed any notes of “oops we messed up” or other noises of contrition over this from those who have more responsibility to keep track of these things. I haven’t been looking that hard, however. Have the appropriate people acknowledged these problems with the incomplete release notes:
    • $wpdb->linkcategories is gone
    • the behavior of wp_list_cats has been broken
    • the behavior of list_cats has been broken

    all of this would have been good to mention to folks who were looking at upgrading. The fact that the “suddenly deprecated” (broken) methods cited above didn’t have links to their new replacement methods at time of release makes the 2.1 launch look rushed.

    • You probably know this but for completeness I wanted to add that the query fix you provided above is incomplete for front-end usage. The link_count column keeps track of how many ‘bookmarks’ (aka links) exist in a category. It does nothing to track which links are (in)visible. The new wp_list_bookmarks tag you reference supports this by using ‘hide_invisible=true’.
    • I hope these comments can be taken in a constructive and instructive way.

    Forum: Developing with WordPress
    In reply to: Bad API

    Why does darage presume that the template tags ought to behave in an object oriented fashion?

    Examine that assumption.

    Have hammer -> see nail. 😛

    What follows is a solution tested in WordPress 1.5

    1. this change will print the category name before the post title.
    2. this replaces the ‘get_archives’ function in the file: ‘wp-templates/template-functions-general.php’
    3. two new optional parameters are added to the function: before_cat and after_cat
    4. before_cat defaults to ” and will be displayed before the category name
    5. after_cat defaults to ‘ ‘ and will be displayed after the category name. Note that this provides a separator between the post title and the category name
    6. MAKE A BACKUP BEFORE YOU CLOBBER YOUR OLD FILES.

    function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false, $before_cat = '', $after_cat = ' ') {
    global $month, $wpdb;

    if ('' == $type) {
    $type = 'monthly';
    }

    if ('' != $limit) {
    $limit = (int) $limit;
    $limit = ' LIMIT '.$limit;
    }
    // this is what will separate dates on weekly archive links
    $archive_week_separator = '–';

    // archive link url
    $archive_link_m = get_settings('siteurl') . '/?m='; # monthly archive;
    $archive_link_w = get_settings('siteurl') . '/?w='; # weekly archive;
    $archive_link_p = get_settings('siteurl') . '/?p='; # post-by-post archive;

    // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
    $archive_date_format_over_ride = 0;

    // options for daily archive (only if you over-ride the general date format)
    $archive_day_date_format = 'Y/m/d';

    // options for weekly archive (only if you over-ride the general date format)
    $archive_week_start_date_format = 'Y/m/d';
    $archive_week_end_date_format = 'Y/m/d';

    if (!$archive_date_format_over_ride) {
    $archive_day_date_format = get_settings('date_format');
    $archive_week_start_date_format = get_settings('date_format');
    $archive_week_end_date_format = get_settings('date_format');
    }

    $add_hours = intval(get_settings('gmt_offset'));
    $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));

    $now = current_time('mysql');

    if ('monthly' == $type) {
    $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
    if ($arcresults) {
    $afterafter = $after;
    foreach ($arcresults as $arcresult) {
    $url = get_month_link($arcresult->year, $arcresult->month);
    if ($show_post_count) {
    $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
    $after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
    } else {
    $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
    }
    echo get_archives_link($url, $text, $format, $before, $after);
    }
    }
    } elseif ('daily' == $type) {
    $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS
    year, MONTH(post_date) AS month, DAYOFMONTH(post_date) AS dayofmonth FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    if ($arcresults) {
    foreach ($arcresults as $arcresult) {
    $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
    $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
    $text = mysql2date($archive_day_date_format, $date);
    echo get_archives_link($url, $text, $format, $before, $after);
    }
    }
    } elseif ('weekly' == $type) {
    $start_of_week = get_settings('start_of_week');
    $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS
    week, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    $arc_w_last = '';
    if ($arcresults) {
    foreach ($arcresults as $arcresult) {
    if ($arcresult->week != $arc_w_last) {
    $arc_year = $arcresult->yr;
    $arc_w_last = $arcresult->week;
    $arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week'));
    $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
    $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
    $url = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), '', '?',
    '=', $arc_year, '&amp;',
    '=', $arcresult->week);
    $text = $arc_week_start . $archive_week_separator . $arc_week_end;
    echo get_archives_link($url, $text, $format, $before, $after);
    }
    }
    }
    } elseif (strpos('postbypost', $type) == 0) { //
    $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    if ($arcresults) {
    foreach ($arcresults as $arcresult) {
    if ($arcresult->post_date != '0000-00-00 00:00:00') {
    $url = get_permalink($arcresult->ID);
    $arc_title = $arcresult->post_title;
    if ($arc_title) {
    $text = strip_tags($arc_title);
    } else {
    $text = $arcresult->ID;
    }
    if ('postbypostwithcat' == $type ) {
    $post_cat = $wpdb->get_var("Select cat_name FROM $wpdb->categories, $wpdb->post2cat WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$arcresult->ID' LIMIT 1");
    $text = $before_cat . strip_tags($post_cat) . $after_cat . $text;
    }
    echo get_archives_link($url, $text, $format, $before, $after);
    }
    }
    }
    }
    }

    Bump: I will second a request for help on this issue.

Viewing 5 replies - 1 through 5 (of 5 total)