Risolto bug in xmlrpc di WordPress

Ho risolto, almeno parzialmente, il baco annunciato nel post bug in wordpress xmlrpc (createDate)
 
Come gia indicato nel bug report le righe incriminate fanno parte della function mw_newPost che sono state riscritte in questo modo
        // Do some timestamp voodoo
        $dateCreatedd = $content_struct['dateCreated'];
        if (!empty($dateCreatedd)) {
            //$dateCreated = $dateCreatedd->getIso();
            //$post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
            //$post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
            $post_date=$dateCreatedd;
            $post_date_gmt = $dateCreatedd;
        } else {
            $post_date = current_time('mysql');
            $post_date_gmt = current_time('mysql', 1);
        }

Allego i file xmlrpc.php per la versione 2.6.2 e la versione 2.3.2 di WordPress

Nella versione 2.6.2 di WordPress, per attivare il supporto xmlrpc si deve spuntare l'apposita checkbox in  /wp-admin/options-writing.php

Con i file xmlrpc modificati, si può inviare un array dati strutturato cosi (attenzione al formato data in uso):

$date = '2008-10-11 17:22:15'; $content=array(  'title' => $title,
                 'description' => $body,
                 'mt_allow_comments' => 0,
                 'mt_keywords' => $tags,
                 'mt_allow_pings' => 1,
                 'categories' => array("squadra_informatica"),
                 'dateCreated' => $date                       
                     );

esempio di utilizzo tratto dal modulo post_also di Drupal (che io ho opportunamente modificato per soddisfare le mie esigenze)

    if($endpoint=='http://dventurin.wordpress.com/xmlrpc.php')
    {
      //bogus xmlrpc
      $content=array(  'title' => $title,
                        'description' => $body,
                        'mt_allow_comments' => 0,
                        'mt_keywords' => $tags,
                        'mt_allow_pings' => 1,
                        'categories' => array("squadra_informatica")
                     );
    }
    else
    {
      $content=array(  'title' => $title,
                        'description' => $body,
                        'mt_allow_comments' => 0,
                        'mt_keywords' => $tags,
                        'mt_allow_pings' => 1,
                        'categories' => array("squadra_informatica"),
                        'dateCreated' => $date                       
                     );
    }

    return xmlrpc($endpoint,'metaWeblog.newPost', $id, $username, $password, $content, !!$publish); 

In questo modo la data di creazione del post sarà reale e potrà anche non coincidere con la data di invio del post.
 

Invia nuovo commento

Il contenuto di questo campo è privato e non verrà mostrato pubblicamente.
  • Indirizzi web o e-mail vengono trasformati in link automaticamente
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Linee e paragrafi vanno a capo automaticamente.

Maggiori informazioni sulle opzioni di formattazione.

CAPTCHA
Questa domanda serve per verificare che tu sia un visitatore umano (non un computer) e per prevenire lo spam
1 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.