samedi 26 décembre 2015

Warning: date() expects parameter 2 to be long, string error

I use the theme as an affiliate deals aggregator. I am using WP all import plugin to import deals from xml files. On import, I face a major problem concerning the expire date as in every xml, it is in the format: “2015-04-23 00:00:00”, while your theme requires UNIX timestamp and can not convert. I used strtotime() in wp all import to convert date to timestamp in real time. But im getting this error : Warning: date() expects parameter 2 to be long, string given in /home/xxxx/http://ift.tt/1mH0pXM on line 112/114/116 and 117

A part of functions.php file :

function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
global $wp_locale;
$i = $unixtimestamp;

if ( false === $i ) {
    if ( ! $gmt )
        $i = current_time( 'timestamp' );
    else
        $i = time();
    // we should not let date() interfere with our
    // specially computed timestamp
    $gmt = true;
}

/*
 * Store original value for language with untypical grammars.
 * See http://ift.tt/1PpL47u
 */
$req_format = $dateformatstring;

$datefunc = $gmt? 'gmdate' : 'date';

if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {
    $datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) );-----------LINE 112
    $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
    $dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) );------LINE 114
    $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
    $datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) );----LINE 116
    $datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i) );------LINE 117
    $dateformatstring = ' '.$dateformatstring;
    $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );
    $dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring );
    $dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring );
    $dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring );
    $dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring );
    $dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring );

    $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire