本文整理匯總了PHP中TimberHelper::start_timer方法的典型用法代碼示例。如果您正苦於以下問題:PHP TimberHelper::start_timer方法的具體用法?PHP TimberHelper::start_timer怎麽用?PHP TimberHelper::start_timer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TimberHelper
的用法示例。
在下文中一共展示了TimberHelper::start_timer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testTimers
function testTimers()
{
$start = TimberHelper::start_timer();
sleep(1);
$end = TimberHelper::stop_timer($start);
$this->assertContains(' seconds.', $end);
$time = str_replace(' seconds.', '', $end);
$this->assertGreaterThan(1, $time);
}
示例2: TimberPost
<?php
/**
* The main template file.
*/
// set up page data
$template = false;
$start = TimberHelper::start_timer();
$data = Timber::get_context();
$data['latest_news'] = get_fg_latest_posts();
if (is_singular()) {
$data['post'] = new TimberPost();
} else {
$data['posts'] = Timber::get_posts();
}
$data['config'] = $get_config();
$data['menu'] = new TimberMenu('main-menu');
if (is_single()) {
$template = 'single';
$data['slideshow'] = $get_slideshow();
} elseif (is_page()) {
$matches = null;
$template = 'page';
// for custom templates
$returnValue = preg_match('/.*\\/(.*?)\\./', get_page_template(), $matches);
if ($returnValue) {
$template = 'page-' . $matches[1];
}
$data['slideshow'] = $get_slideshow();
} elseif (is_home()) {
$template = 'index';
示例3: handle_post_results
public static function handle_post_results($results, $PostClass = 'TimberPost')
{
$start = TimberHelper::start_timer();
$posts = array();
foreach ($results as $rid) {
$PostClassUse = $PostClass;
if (is_array($PostClass)) {
$post_type = get_post_type($rid);
$PostClassUse = 'TimberPost';
if (isset($PostClass[$post_type])) {
$PostClassUse = $PostClass[$post_type];
} else {
if (is_array($PostClass)) {
TimberHelper::error_log($post_type . ' of ' . $rid . ' not found in ' . print_r($PostClass, true));
} else {
TimberHelper::error_log($post_type . ' not found in ' . $PostClass);
}
}
}
$post = new $PostClassUse($rid);
if (isset($post->ID)) {
$posts[] = $post;
}
}
return $posts;
}