W10x!

Earlier, It's an active one!I uploaded ‘AHCommentCentral’, which is a plug-in that is supposed to help closing/opening comments and ping/trackbacks in your post sections. For now, you’ll find the initial release right over here. That is, for the daring people who experiment. It’s GPL-ed too, which is (only) natural for ‘non-compilable’ sources1.

I left out certain options (you’ll find references to them in the sources): the ‘auto close feature’ (see PrintAutoForm) and the Post Exceptions list (see call to get_options to retrieve data from the ‘ahi_cc_excluded_posts’ options field). In earlier versions, I actually had that ‘auto-close feature’ working, but I decided against adding it to the initial code.

There are couple of things I don’t like about creating WordPress plugins: Designing screens is obnoxious. Here’s a tip for you lazy programmers: grab the ‘wp-admin.css’ file dump it in a directory and then install NVU. Yes, NVU is buggy like crazy, but proofed to be quite the help while racing through all these HTML form elements (A couple of years I was thinking about creating a form-designer). We need XFORMS. Direly.

Another thing that is annoying (when creating these plug-ins) is that the current plug-in structure forces you to start globalizing’ certain variables. I won’t do a rant about globals. There are plenty of them. Global variables kill cats. Somehow, PHP forces programmers to write bad code. You know, poetry is one thing, but comparing PHP code with written literature is a joke. It’s like giving a kid 2 notes (A and B minor) and tell him or her to write 80 melody lines out of those notes. The problem is not in creating 80 of ’em. The problem is that the eighty tunes will always sound alike. But OK, I admit: PHP is not as bad as ASP (which is just a fancy name for Visual Basic for Applications [cough] and servers!).

As for the name: I think I was watching Comedy Central the other day and the name got stuck somehow in the nether regions of my brain. I considered renaming it to something absurd like, ‘W10x’ (which you pronounce as ‘What The Funk’) or better yet, ‘W09y’ (you pronounce that as that typical Eigthties greeting ‘See You Later, Aligator’). I’m actually dreaming of an ‘EP01BF’, which is the abbreviation for Peanut Buster Parfait. OK. Comment Central.

1 What’s the point of releasing ‘closed sourced’ PHP applications? [that’s a joke]

UPDATE: I just updated the plug-in.
UPDATE#2: Older versions of WordPress

This entry was posted in Wordpress and tagged . Bookmark the permalink.

11 Responses to W10x!

  1. alfons says:

    Hi there, I work with a slightly older WordPress version, and I get this error:

    WordPress database error: [Unknown column ‘comment_count’ in ‘field list’]
    select count(*) as number, post_status, comment_status, ping_status, sum(comment_count) as comment_count from wp_posts group by post_status, comment_status, ping_status order by post_status

    ED: slightly edited

  2. alfons says:

    If look at the database, there are two tables:

    1)

    CREATE TABLE `wp_posts` (
    `ID` bigint(20) unsigned NOT NULL auto_increment,
    `post_author` int(4) NOT NULL default ‘0’,
    `post_date` datetime NOT NULL default ‘0000-00-00 00:00:00’,
    `post_date_gmt` datetime NOT NULL default ‘0000-00-00 00:00:00’,
    `post_content` longtext NOT NULL,
    `post_title` text NOT NULL,
    `post_category` int(4) NOT NULL default ‘0’,
    `post_excerpt` text NOT NULL,
    `post_lat` float default NULL,
    `post_lon` float default NULL,
    `post_status` enum(‘publish’,’draft’,’private’,’static’,’object’) NOT NULL default ‘publish’,
    `comment_status` enum(‘open’,’closed’,’registered_only’) NOT NULL default ‘open’,
    `ping_status` enum(‘open’,’closed’) NOT NULL default ‘open’,
    `post_password` varchar(20) NOT NULL default ”,
    `post_name` varchar(200) NOT NULL default ”,
    `to_ping` text NOT NULL,
    `pinged` text NOT NULL,
    `post_modified` datetime NOT NULL default ‘0000-00-00 00:00:00’,
    `post_modified_gmt` datetime NOT NULL default ‘0000-00-00 00:00:00’,
    `post_content_filtered` text NOT NULL,
    `post_parent` int(11) NOT NULL default ‘0’,
    `guid` varchar(255) NOT NULL default ”,
    `menu_order` int(11) NOT NULL default ‘0’,
    PRIMARY KEY (`ID`),
    KEY `post_date` (`post_date`),
    KEY `post_date_gmt` (`post_date_gmt`),
    KEY `post_name` (`post_name`),
    KEY `post_status` (`post_status`)
    ) TYPE=MyISAM

  3. alfons says:

    And:

    2)

    CREATE TABLE `wp_comments` (
    `comment_ID` bigint(20) unsigned NOT NULL auto_increment,
    `comment_post_ID` int(11) NOT NULL default ‘0’,
    `comment_author` tinytext NOT NULL,
    `comment_author_email` varchar(100) NOT NULL default ”,
    `comment_author_url` varchar(200) NOT NULL default ”,
    `comment_author_IP` varchar(100) NOT NULL default ”,
    `comment_date` datetime NOT NULL default ‘0000-00-00 00:00:00’,
    `comment_date_gmt` datetime NOT NULL default ‘0000-00-00 00:00:00’,
    `comment_content` text NOT NULL,
    `comment_karma` int(11) NOT NULL default ‘0’,
    `comment_approved` enum(‘0′,’1′,’spam’) NOT NULL default ‘1’,
    `user_id` int(11) NOT NULL default ‘0’,
    `comment_agent` varchar(255) NOT NULL default ”,
    `comment_type` varchar(20) NOT NULL default ”,
    `comment_parent` int(11) NOT NULL default ‘0’,
    PRIMARY KEY (`comment_ID`),
    KEY `comment_approved` (`comment_approved`),
    KEY `comment_post_ID` (`comment_post_ID`)
    ) TYPE=MyISAM

  4. alfons says:

    To get the number of comments for a posting you should link “wp_comments.comment_post_ID” with the “wp_posts.post_parent”.
    My SQL knowledge is okayish, but my PHP skills are just n00b.

  5. alfons says:

    Commenting out everything related to comment_count made it work.

  6. Arthur says:

    Comment count is part of the 2.0 series I think.

  7. Arthur says:

    To get the number of comments for a posting you should link “wp_comments.comment_post_ID” with the “wp_posts.post_parent”.

    You mean, group them together.

  8. Arthur says:

    (see also here). The same idea was applied to the wp_posts (so it has an extra field that is filled each time ‘with the comment count’), which is in fact not really necessary (and there’s no speed gain either, since it requires an extra update statement whenever somebody adds a new comment).

  9. Arthur says:

    Interestingly, to get the actual data the way I did it originally requires a grouping via a left outer join (to include postings that do not have comments, after all a normal join is *EXCLUSIVE* [kids are you reading?]). The query I’m after for you is:


    select count(p.ID), p.post_status,
    p.comment_status, p.ping_status,
    count(c.comment_post_id)
    from wp_posts p
    left outer join wp_comments c on
    (c.comment_post_ID = p.ID)
    group by p.post_status,
    p.comment_status, p.ping_status
    order by p.post_status

    Now, I can’t vy if your MYSQL version supports left outer joins. Could you test it?

  10. alfons says:

    The following as an sql string makes it work:

    $sql = “select count(p.ID) as number, p.post_status as post_status,
    p.comment_status as comment_status, p.ping_status as ping_status,
    count(c.comment_post_id) as comment_count
    from wp_posts p
    left outer join wp_comments c on
    (c.comment_post_ID = p.ID)
    group by p.post_status,
    p.comment_status, p.ping_status
    order by p.post_status”;

  11. Arthur says:

    You mean your WordPress doesn’t understand the $wpdb->posts macros? (Unless the routine didn’t manage to find your WordPress version number. Maybe that was included NEW too).

    OK. I tested it on a lower version but wasn’t able to find the issue you were talking about: it must have been a MySQL issue with aliases (which have now been added to that specific query for lower WP versions). Also minor fix-ups for your version. Hope this helps!

Comments are closed.