1. WP 2.6.2 posts revisions & Twitter Updater

    October 5, 2008 by jerome

    * Tlktlk is using the Twitter Updater plugins. It’s quite a nice plugin, really usefull to do automated posting to a twitter account.
    But for a reason I didn’t quite grok, the twitter account was updated even when editing (save post) and/or (maybe) trough the autosave function of the new 2.6. On a few other blogs I decided to desactivate it since it was creating twits based on revision not accessible to general plugin and resulting in a 404.

    This afternoon I had a look in the WP Codex page for Actions’ Hook and I tried to replace the hook from the plugin (line 108: twitter_updater.php) and posted a new event on the blog; so far it seems it worked like a charm:


    add_action ( 'publish_post', 'vc_twit');
    //add_action ( 'save_post', 'vc_twit');


  2. (can’t) insert uploaded images in WP 2.5+

    July 3, 2008 by jerome

    With Wordpress 2.5 came a new way of handling files upload: the image gallery. Very neat and simple to use. One single issue made it so far a pain in the bum for me: for some reason, some times, it was impossible to use the button ‘Insert into Post’.

    Firebug was indicating that the AJAX call was left with no answer - it is apparently related with server configuration - this happen all the time and it’s a real problem when developing on a shared hosting machine; I had these issues on a shared hosted account at IX web hosting and I still have to test on a DreamHost account to see if it solves this issue there too.

    I finally found out a solution for my WP 2.5.1 installation:
    Thanks to Otto42 on the WP forum, after following the whole discussion - i had to edit my .htaccess and add the following lines.

    <IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </IfModule>

    The ‘.htaccess’ file provides additional configuration instruction to the Apache server, specific for the files accessed in the same directory where it is located - in this case it should be the root directory of your WP installation, if you have no .htaccess file you can just create one and call it this way, with the dot in front of the name: it means the file will be hidden using http, but you still can see it trough ftp - when downloading this file, if your are on a Mac OS X, the file will not be listed in the directory, but it still is there, it is just hidden.

    * Please note that disabling mod_security apparently opens wide door to comment and referrer spam, and possibly nastier attack of other forms.


  3. (re) Enabling the past

    May 26, 2008 by jerome

    sangbleu.png

    A few days ago, I had to modify the SangBleu WordPress theme for Maxime. Maxime finally wanted to give access to the recent archives pages. The SangBleu theme has been built on top of Naked Wordpress Theme; Naked is a drastically simplified theme with just the strict minimum DOM architecture. As such it is very easy to develop your own CSS - which is not the case with the standard Kubricks theme: too many intricated elements in the DOM structure, producing a super huge and complex stylesheet.

    You can download the Naked theme from http://bealers.com/wordpress-naked/; it is definitely a must-have if you’re going to develop some small project and need flexibility as well as simplicity.

    The problem I faced was a bit silly: the posts_nav_link was not behaving correctly - I changed at some point the MySql bits form the origianl theme: the Loop was not a standard one, but a simple MySql request on the database.

    $querystr = "	SELECT wposts.*
        FROM $wpdb->posts AS wposts
        WHERE wposts.post_status = 'publish'
        AND wposts.post_type='post'
        ORDER BY wposts.post_date DESC LIMIT 0,20
     ";
    
    $pageposts = $wpdb->get_results($querystr, OBJECT);
    
    if ($pageposts): ?>
    <ol id="posts">
    				setup_postdata($post);
    [...]
    			endforeach;
    [...]
    endif;</ol>

    This MySql bit does not query any paged items. To manage to get the paging back, I had to re-modify the way the theme is requesting the posts from the database. In order to have the pagination for past posts enabled, I simply did a copy/paste from the Kubricks theme. So, I replaced the above by the following:


    if (have_posts()) :
    while (have_posts()) : the_post();
    [...]
    endwhile;
    endif;

    In Wordpress you can control the pagination on a page with multiple posts (like index.php) using the template tag: posts_nav_link. This tag takes 3 parameters, the first one being the string inserted at the beginning, the last two parameters being quite obvious…
    posts_nav_link(’ · ‘, ‘previous page’, ‘next page’)
    In order for it to work, you need to have a Loop on the page which is going to query the posts using a paged information.

    On a single post page, you can also use the next_post_link() and previous_post_link() to display links to the individual next/previous post.

    * http://codex.wordpress.org/Template_Tags/posts_nav_link


  4. Mime Type of Attachments

    April 1, 2008 by jerome

    Today, during one of the soft redesign of Assembling I found myself in need to know whether an attachment was an image or not; the wordpress documentation did not give me any clue about how to do this - so I started to create myself the function I needed: get_the_attachment_type

    It sits in my theme functions.php - and might be of any use to someone else:
    <?php
    function get_the_attachment_type($id = 0) {
    $id = (int) $id;
    $_post = & get_post($id);
    $mime = $_post->post_mime_type;
    return $mime;
    }
    ?>

    I use the function in the attachment.php file in the following manner:


    <?php switch (get_the_attachment_type($post->ID)) {
    case "image/jpeg":
    case "image/gif":
    case "image/png":
    break;
    default:?>
    <p><b>Download</b>:
    <?php } ?>
    <?php echo $attachment_link; ?> <?php the_content(); ?>

    This will then output a bold Download prompt in front of the file’s name in case, the attachment file is not an image (pdf, zip, etc.); if the attachment is an image, then nothing will be displayed.


  5. Auto Social - a patch for delicious description

    March 22, 2008 by jerome

    Auto Social is a very neat plug-in for WordPress which lets your blog publish automatically its new or updated content on various services; at the moment it works only with del.icio.us, but the plugin structure is open enough to send in the future to any service with a descent API or url construct.

    We decided to start using Auto Social with R-Echos. It worked great - out of the box, straight to the WordPress plugin folder on the server but we wanted to have a brief description of the content in the field Notes. With the del.icio.us API it has been a snap to introduce this in the code; note that the field Notes (extended.api) is limited to 255 characters.

    Mainly, it’s this line which does the job:

    $params .= "&extended=".urlencode($cleaned_content);

    You can find more details about the del.icio.us api post:
    https://api.del.icio.us/v1/posts/add? Add a post to del.icio.us
    &extended (optional) - notes for the item.

    Here is the patch for the file delicious.php: delicious_patch.txt.

    To apply a patch, you can use:
    patch -p 0 < patch_name

    To create a patch, you can use the unix command: diff
    diff -Naur oldfile newfile &rt; patch_name


  6. returning wordpress tags as an array

    March 20, 2008 by jerome

    Maybe useful for someone else: this is a patch of wp-includes/category-template.php to return an array of the tags instead of printing it when using the “format=array” option in wp_tag_cloud().

    This seems to have been fixed in version 2.5, let’s see that soon! In the meantime…

    tag_array-patch


  7. pipeline frontend development

    March 14, 2008 by jerome

    ‘lo, update before uploading the site, finished coding main views.

    pipeline

    pipeline2.jpg