当前位置: 首页>>代码示例>>PHP>>正文


PHP backslashit函数代码示例

本文整理汇总了PHP中backslashit函数的典型用法代码示例。如果您正苦于以下问题:PHP backslashit函数的具体用法?PHP backslashit怎么用?PHP backslashit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了backslashit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: eo_format_datetime

/**
 * Formats a datetime object into a specified format and handles translations.
 * Used by 
 *
 * * {@see `eo_get_the_start()`} 
 * * {@see `eo_get_the_end()`}
 * * {@see `eo_get_schedule_start()`}
 * * {@see `eo_get_schedule_last()`}
 *
 * The constant DATETIMEOBJ can be passed to them to get datetime objects 
 * Applies {@see `eventorganiser_format_datetime`} filter
 *
 * @since 1.2.0
 * @link http://php.net/manual/en/function.date.php PHP Date
 *
 * @param dateTime $datetime The datetime to format
 * @param string|constant $format How to format the date, see http://php.net/manual/en/function.date.php  or DATETIMEOBJ constant to return the datetime object.
 * @return string|dateTime The formatted date
*/
function eo_format_datetime($datetime, $format = 'd-m-Y')
{
    global $wp_locale;
    if (DATETIMEOBJ == $format) {
        return $datetime;
    }
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        //Translate
        $datemonth = $wp_locale->get_month($datetime->format('m'));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday($datetime->format('w'));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = trim($wp_locale->get_meridiem($datetime->format('a')));
        $datemeridiem_capital = $wp_locale->get_meridiem($datetime->format('A'));
        $datemeridiem = empty($datemeridiem) ? $datetime->format('a') : $datemeridiem;
        $dateformatstring = ' ' . $format;
        $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);
    }
    $formatted_datetime = $datetime->format($dateformatstring);
    return apply_filters('eventorganiser_format_datetime', $formatted_datetime, $format, $datetime);
}
开发者ID:windyjonas,项目名称:fredrika,代码行数:46,代码来源:event-organiser-utility-functions.php

示例2: amr_date_i18n

 function amr_date_i18n($dateformatstring, $dateobj = null)
 {
     global $wp_locale;
     // store original value for language with untypical grammars
     // see http://core.trac.wordpress.org/ticket/9396
     $req_format = $dateformatstring;
     //$datefunc = 'date';
     if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
         $datemonth = $wp_locale->get_month($dateobj->format('m'));
         $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
         $w = $dateobj->format('w');
         if ($w == '-1') {
             $w = get_oldweekdays($dateobj);
         }
         /* php seems to break around 1760 and google passed a zero year date */
         $dateweekday = $wp_locale->get_weekday($w);
         $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
         $datemeridiem = $wp_locale->get_meridiem($dateobj->format('a'));
         $datemeridiem_capital = $wp_locale->get_meridiem($dateobj->format('A'));
         $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);
     }
     $j = $dateobj->format($dateformatstring);
     // allow plugins to redo this entirely for languages with untypical grammars
     $j = apply_filters('amr_date_i18n', $j, $req_format, $dateobj);
     return $j;
 }
开发者ID:greg3560,项目名称:plailly,代码行数:33,代码来源:amr_date_i18n.php

示例3: date_i18n

function date_i18n($dateformatstring, $unixtimestamp) {
	global $month, $weekday;
	$i = $unixtimestamp; 
	if ((!empty($month)) && (!empty($weekday))) {
		$datemonth = $month[date('m', $i)];
		$dateweekday = $weekday[date('w', $i)];
		$dateformatstring = ' '.$dateformatstring;
		$dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit(substr($dateweekday, 0, 3)), $dateformatstring);
		$dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring);
		$dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
		$dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit(substr($datemonth, 0, 3)), $dateformatstring);
		$dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
	}
	$j = @date($dateformatstring, $i);
	return $j;
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:16,代码来源:functions.php

示例4: date_i18n

function date_i18n($dateformatstring, $unixtimestamp)
{
    $i = $unixtimestamp;
    $month = get_month_names('long');
    $month_abbrev = get_month_names('short');
    $weekday = get_day_names('long');
    $weekday_abbrev = get_day_names('short');
    if (!empty($month) && !empty($weekday)) {
        $datemonth = $month[intVal(date('m', $i))];
        $datemonth_abbrev = $month_abbrev[intVal(date('m', $i))];
        $dateweekday = $weekday[intVal(date('w', $i))];
        $dateweekday_abbrev = $weekday_abbrev[intVal(date('m', $i))];
        $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 = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
    }
    $j = @date($dateformatstring, $i);
    return $j;
}
开发者ID:qlixes,项目名称:springphp,代码行数:22,代码来源:dates.php

示例5: action_latex

function action_latex()
{
    global $page, $pagestore, $ParseEngine, $DisplayEngine, $HTTP_IF_MODIFIED_SINCE;
    global $version;
    $pg = $pagestore->page($page);
    if ($version != '') {
        $pg->version = $version;
    }
    $pg->read();
    //  if(!empty($HTTP_IF_MODIFIED_SINCE))
    //    { if_modified($pg->time); }
    //  gen_headers($pg->time);
    // $pg->text is the raw stuff from the database
    //  print $pg->text;
    // $DisplayEngine indicates what functions will be used to translate wiki
    //   markup elements into actual HTML.  See parse/html.php
    $DisplayEngine = array('bold_start' => 'latex_bold_start', 'bold_end' => 'latex_bold_end', 'italic_start' => 'latex_italic_start', 'italic_end' => 'latex_italic_end', 'tt_start' => 'latex_tt_start', 'tt_end' => 'latex_tt_end', 'head_start' => 'latex_head_start', 'head_end' => 'latex_head_end', 'newline' => 'latex_newline', 'ref' => 'latex_ref', 'url' => 'latex_url', 'interwiki' => 'latex_interwiki', 'raw' => 'latex_raw', 'code' => 'latex_code', 'hr' => 'latex_hr', 'nowiki' => 'latex_nowiki', 'bullet_list_start' => 'latex_ul_start', 'bullet_list_end' => 'latex_ul_end', 'bullet_item_start' => 'latex_li_start', 'bullet_item_end' => 'latex_li_end', 'indent_list_start' => 'latex_dl_start', 'indent_list_end' => 'latex_dl_end', 'indent_item_start' => 'latex_dd_start', 'indent_item_end' => 'latex_dd_end', 'numbered_list_start' => 'latex_ol_start', 'numbered_list_end' => 'latex_ol_end', 'numbered_item_start' => 'latex_li_start', 'numbered_item_end' => 'latex_li_end', 'diff_old_start' => 'latex_diff_old_start', 'diff_old_end' => 'latex_diff_end', 'diff_new_start' => 'latex_diff_new_start', 'diff_new_end' => 'latex_diff_end', 'diff_change' => 'latex_diff_change', 'diff_add' => 'latex_diff_add', 'diff_delete' => 'latex_diff_delete');
    $rawtext = $pg->text;
    $parseText = parseText($rawtext, $ParseEngine, "OBJECTNAMEHERE");
    $newtext = backslashit($parseText);
    template_view($page, $newtext);
}
开发者ID:BackupTheBerlios,项目名称:hpt-obm-svn,代码行数:22,代码来源:latex.php

示例6: date_i18n

function date_i18n($dateformatstring, $unixtimestamp)
{
    global $wp_locale;
    $i = $unixtimestamp;
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month(date('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday(date('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
        $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);
    }
    $j = @date($dateformatstring, $i);
    return $j;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:23,代码来源:functions.php

示例7: date_i18n

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @param string $dateformatstring Format to display the date
 * @param int $unixtimestamp Unix timestamp
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false)
{
    global $wp_locale;
    $i = $unixtimestamp;
    // Sanity check for PHP 5.1.0-
    if (false === $i || intval($i) < 0) {
        if (!$gmt) {
            $i = current_time('timestamp');
        } else {
            $i = time();
        }
        // we should not let date() interfere with our
        // specially computed timestamp
        $gmt = true;
    }
    $datefunc = $gmt ? 'gmdate' : 'date';
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month($datefunc('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday($datefunc('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem($datefunc('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem($datefunc('A', $i));
        $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);
    }
    $j = @$datefunc($dateformatstring, $i);
    return $j;
}
开发者ID:joelglennwright,项目名称:agencypress,代码行数:48,代码来源:functions.php

示例8: date_i18n

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @global WP_Locale $wp_locale
 *
 * @param string   $dateformatstring Format to display the date.
 * @param bool|int $unixtimestamp    Optional. Unix timestamp. Default false.
 * @param bool     $gmt              Optional. Whether to use GMT timezone. Default false.
 *
 * @return string The date, translated if locale specifies it.
 */
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 https://core.trac.wordpress.org/ticket/9396
     */
    $req_format = $dateformatstring;
    $datefunc = $gmt ? 'gmdate' : 'date';
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month($datefunc('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday($datefunc('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem($datefunc('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem($datefunc('A', $i));
        $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);
    }
    $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
    $timezone_formats_re = implode('|', $timezone_formats);
    if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
        $timezone_string = get_option('timezone_string');
        if ($timezone_string) {
            $timezone_object = timezone_open($timezone_string);
            $date_object = date_create(null, $timezone_object);
            foreach ($timezone_formats as $timezone_format) {
                if (false !== strpos($dateformatstring, $timezone_format)) {
                    $formatted = date_format($date_object, $timezone_format);
                    $dateformatstring = ' ' . $dateformatstring;
                    $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                    $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
                }
            }
        }
    }
    $j = @$datefunc($dateformatstring, $i);
    /**
     * Filter the date formatted based on the locale.
     *
     * @since 2.8.0
     *
     * @param string $j          Formatted date string.
     * @param string $req_format Format to display the date.
     * @param int    $i          Unix timestamp.
     * @param bool   $gmt        Whether to convert to GMT for time. Default false.
     */
    $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    return $j;
}
开发者ID:hpilevar,项目名称:WordPress,代码行数:84,代码来源:functions.php

示例9: date_i18n

 function date_i18n($dateformatstring, $unixtimestamp, $charset = "")
 {
     if (!empty($GLOBALS['month']) && !empty($GLOBALS['weekday'])) {
         $datemonth = $GLOBALS['month'][date('m', $unixtimestamp)];
         $dateweekday = $GLOBALS['weekday'][date('w', $unixtimestamp)];
         $dateformatstring = ' ' . $dateformatstring;
         $dateformatstring = preg_replace("/([^\\\\])D/", "\\1" . backslashit(mb_substring($dateweekday, 0, $GLOBALS['s_weekday_length'], $charset)), $dateformatstring);
         $dateformatstring = preg_replace("/([^\\\\])F/", "\\1" . backslashit($datemonth), $dateformatstring);
         $dateformatstring = preg_replace("/([^\\\\])l/", "\\1" . backslashit($dateweekday), $dateformatstring);
         $dateformatstring = preg_replace("/([^\\\\])M/", "\\1" . backslashit(mb_substring($datemonth, 0, $GLOBALS['s_month_length'], $charset)), $dateformatstring);
         $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
     }
     $j = @date($dateformatstring, $unixtimestamp);
     return $j;
 }
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:15,代码来源:functions-formatting.php

示例10: date_i18n

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @param string $dateformatstring Format to display the date.
 * @param int $unixtimestamp Optional. Unix timestamp.
 * @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false)
{
    global $wp_locale;
    $i = $unixtimestamp;
    // Sanity check for PHP 5.1.0-
    if (false === $i || intval($i) < 0) {
        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://core.trac.wordpress.org/ticket/9396
    $req_format = $dateformatstring;
    $datefunc = $gmt ? 'gmdate' : 'date';
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month($datefunc('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday($datefunc('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem($datefunc('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem($datefunc('A', $i));
        $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);
    }
    $j = @$datefunc($dateformatstring, $i);
    // allow plugins to redo this entirely for languages with untypical grammars
    $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    return $j;
}
开发者ID:Ogwang,项目名称:sainp,代码行数:54,代码来源:functions.php

示例11: post_notification_date_i18n_tz

function post_notification_date_i18n_tz($dateformatstring, $unixtimestamp)
{
    // In case the Time Zone plugin is installed, date() is working correctly.
    // Let it do its work.
    //
    if (class_exists('TimeZone')) {
        return date_i18n($dateformatstring, $unixtimestamp);
    }
    // Else, we cannot rely on date() and must revert to gmdate(). We assume
    // that no daylight saving takes part. Else, install the plugin from
    // http://kimmo.suominen.com/sw/timezone/ using (or not) the patches from
    // http://www.philippusdo.de/technische-informationen/ .
    //
    global $wp_locale;
    $i = $unixtimestamp + get_option('gmt_offset') * 3600;
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month(gmdate('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday(gmdate('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem(gmdate('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem(gmdate('A', $i));
        $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);
    }
    $j = @gmdate($dateformatstring, $i);
    return $j;
}
开发者ID:jrep20,项目名称:samcozen,代码行数:34,代码来源:functions.php

示例12: date_i18n

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @param string $dateformatstring Format to display the date.
 * @param int $unixtimestamp Optional. Unix timestamp.
 * @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
 * @return string The date, translated if locale specifies it.
 */
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://core.trac.wordpress.org/ticket/9396
	$req_format = $dateformatstring;

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

	if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {
		$datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) );
		$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
		$dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) );
		$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
		$datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) );
		$datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) );
		$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 );
	}
	$timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );
	$timezone_formats_re = implode( '|', $timezone_formats );
	if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) {
		$timezone_string = get_option( 'timezone_string' );
		if ( $timezone_string ) {
			$timezone_object = timezone_open( $timezone_string );
			$date_object = date_create( null, $timezone_object );
			foreach( $timezone_formats as $timezone_format ) {
				if ( false !== strpos( $dateformatstring, $timezone_format ) ) {
					$formatted = date_format( $date_object, $timezone_format );
					$dateformatstring = ' '.$dateformatstring;
					$dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring );
					$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
				}
			}
		}
	}
	$j = @$datefunc( $dateformatstring, $i );
	// allow plugins to redo this entirely for languages with untypical grammars
	$j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
	return $j;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:73,代码来源:functions.php

示例13: test_double_backslashes_leading_numbers

	function test_double_backslashes_leading_numbers() {
		$this->assertEquals("\\\\95", backslashit("95"));
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:3,代码来源:Slashit.php

示例14: preg_replace

         $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);
     }
     $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
     $timezone_formats_re = implode('|', $timezone_formats);
     if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
         $timezone_object = $ns->get_wp_timezone();
         $date_object = date_create(null, $timezone_object);
         foreach ($timezone_formats as $timezone_format) {
             if (false !== strpos($dateformatstring, $timezone_format)) {
                 $formatted = date_format($date_object, $timezone_format);
                 $dateformatstring = ' ' . $dateformatstring;
                 $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                 $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
             }
         }
     }
     return $datetime->format($dateformatstring);
 });
 birch_defn($ns, 'get_day_minutes', function ($datetime) use($ns) {
     $time = $datetime->format('H') * 60 + $datetime->format('i');
     return $time;
 });
 birch_defn($ns, 'has_shortcode', function ($shortcode = NULL) use($ns) {
     $post_to_check = get_post(get_the_ID());
     // false because we have to search through the post content first
     $found = false;
     // if no short code was provided, return false
开发者ID:JonathanAJ,项目名称:Seara-da-Ciencia-UFC,代码行数:31,代码来源:package.php

示例15: fix_date_i18n

 /** https://core.trac.wordpress.org/ticket/25768
  *
  * Modified from the original patch to use the currently set
  * timezone from PHP, like PHP's date(), and to make the code
  * more readable.
  *
  * @param      $j
  * @param      $req_format
  * @param bool $i
  * @param bool $gmt
  * @return bool|string
  */
 function fix_date_i18n($j, $req_format, $i = false, $gmt = false)
 {
     /* @var $wp_locale WP_Locale */
     global $wp_locale;
     $timestamp = $i;
     // get current timestamp if $i is false
     if (false === $timestamp) {
         if ($gmt) {
             $timestamp = time();
         } else {
             $timestamp = current_time('timestamp');
         }
     }
     // get components of the date (timestamp) as array
     $date_components = getdate($timestamp);
     // numeric representation of a month, with leading zeros
     $date_month = $wp_locale->get_month($date_components['mon']);
     $date_month_abbrev = $wp_locale->get_month_abbrev($date_month);
     // numeric representation of the day of the week
     $date_weekday = $wp_locale->get_weekday($date_components['wday']);
     $date_weekday_abbrev = $wp_locale->get_weekday_abbrev($date_weekday);
     // get if hour is Ante meridiem or Post meridiem
     $meridiem = $date_components['hours'] >= 12 ? 'pm' : 'am';
     // lowercase Ante meridiem and Post meridiem hours
     $date_meridiem = $wp_locale->get_meridiem($meridiem);
     // uppercase Ante meridiem and Post meridiem
     $date_meridiem_capital = $wp_locale->get_meridiem(strtoupper($meridiem));
     // escape literals
     $date_weekday_abbrev = backslashit($date_weekday_abbrev);
     $date_month = backslashit($date_month);
     $date_weekday = backslashit($date_weekday);
     $date_month_abbrev = backslashit($date_month_abbrev);
     $date_meridiem = backslashit($date_meridiem);
     $date_meridiem_capital = backslashit($date_meridiem_capital);
     // the translated format string
     $translated_date_format_string = '';
     // the 2 arrays map a format literal to its translation (e. g. 'F' to the escaped month translation)
     $translate_formats = array('D', 'F', 'l', 'M', 'a', 'A', 'c', 'r');
     $translations = array($date_weekday_abbrev, $date_month, $date_weekday, $date_month_abbrev, $date_meridiem, $date_meridiem_capital, 'Y-m-d\\TH:i:sP', sprintf('%s, d %s Y H:i:s O', $date_weekday_abbrev, $date_month_abbrev));
     // find each format literal that needs translation and replace it by its translation
     // respects the escaping
     // iterate $req_format from ending to beginning
     for ($i = strlen($req_format) - 1; $i > -1; $i--) {
         // test if current char is format literal that needs translation
         $translate_formats_index = array_search($req_format[$i], $translate_formats);
         if ($translate_formats_index !== false) {
             // counts the slashes (the escape char) in front of the current char
             $slashes_counter = 0;
             // count all slashes left-hand side of the current char
             for ($j = $i - 1; $j > -1; $j--) {
                 if ($req_format[$j] == '\\') {
                     $slashes_counter++;
                 } else {
                     break;
                 }
             }
             // number of slashes is even
             if ($slashes_counter % 2 == 0) {
                 // current char is not escaped, therefore it is a format literal
                 $translated_date_format_string = $translations[$translate_formats_index] . $translated_date_format_string;
             } else {
                 // current char is escaped, therefore it is not a format literal, just add it unchanged
                 $translated_date_format_string = $req_format[$i] . $translated_date_format_string;
             }
         } else {
             // current char is no a format literal, just add it unchanged
             $translated_date_format_string = $req_format[$i] . $translated_date_format_string;
         }
     }
     $req_format = $translated_date_format_string;
     if ($gmt) {
         // get GMT date string
         $date_formatted = gmdate($req_format, $timestamp);
     } else {
         // get Wordpress time zone
         // $timezone_string = get_option('timezone_string');
         // Haha, just kidding. Let's get the currently set timezone, as God and Rasmus intended
         $timezone_string = date_default_timezone_get();
         if ($timezone_string) {
             // create time zone object
             $timezone_object = timezone_open($timezone_string);
             // create date object from time zone object
             $local_date_object = date_create(null, $timezone_object);
             // set time and date of $local_date_object to $timestamp
             $date_components = isset($date_components) ? $date_components : getdate($timestamp);
             date_date_set($local_date_object, $date_components['year'], $date_components['mon'], $date_components['mday']);
             date_time_set($local_date_object, $date_components['hours'], $date_components['minutes'], $date_components['seconds']);
             // format date according to the Wordpress time zone
//.........这里部分代码省略.........
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:101,代码来源:timed-content.php


注:本文中的backslashit函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。