';
}
/**
* combineURL
* 拼接url
* @param string $baseURL 基于的url
* @param array $keysArr 参数列表数组
* @return string 返回拼接的url
*/
function combineURL($baseURL, $keysArr)
{
$combined = $baseURL . "?";
$valueArr = array();
foreach ($keysArr as $key => $val) {
$valueArr[] = "$key=$val";
}
$keyStr = implode("&", $valueArr);
$combined .= ($keyStr);
return $combined;
}
function load_js_parameter($name, $arr)
{
echo '';
}
function file_load_img($path)
{
echo "";
}
function file_get_img_url($path)
{
return THEME_IMG_PATH . "/" . $path;
}
function file_echo_svg($path)
{
global $wp_filesystem;
$svg = $wp_filesystem->get_contents(THEME_PATH . '/static/img/' . $path);
print_r($svg);
//readfile(THEME_PATH . '/static/img/' . $path);
}
function file_get_svg($path)
{
global $wp_filesystem;
$svg = $wp_filesystem->get_contents(THEME_PATH . '/static/img/' . $path);
return $svg;
//readfile(THEME_PATH . '/static/img/' . $path);
}
function file_load_face()
{
$files = scandir(THEME_PATH . "/static/img/face");
$html = null;
foreach ($files as $v) {
/* if(is_file($v)){
$fileItem[] = $v;
}*/
if (pathinfo($v, PATHINFO_EXTENSION) == 'gif') {
$html = '
' . $html;
}
}
return $html;
}
function file_load_css($path)
{
echo '';
}
function file_load_lib($path, $type)
{
if ($type == 'css') {
echo '';
} elseif ($type == 'js') {
echo '';
}
}
function file_load_component($name)
{
require_once(THEME_PATH . "/component/{$name}");
}
function islogin()
{
return is_user_logged_in();
}
function loginAndBack($url = null)
{
if ($url == null) {
return wp_login_url('//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
} else {
return wp_login_url($url);
}
}
function corepress_get_user_nickname($user_id = null)
{
if ($user_id == null) {
$currentUser = wp_get_current_user();
$name = $currentUser->display_name;
} else {
$user = get_userdata($user_id);
$name = $user->display_name;
}
return $name;
}
function corepress_get_avatar_url($email = null, $size = 60)
{
if ($email == null) {
$currentUser = wp_get_current_user();
$avatarurl = get_avatar_url($currentUser->user_email, array('size' => $size));
} else {
$avatarurl = get_avatar_url($email, array('size' => $size));
}
return $avatarurl;
}
function isadmin($user_id = null)
{
if ($user_id == null) {
$currentUser = wp_get_current_user();
$roles = $currentUser->roles;
} else {
$user = get_userdata($user_id);
$roles = $user->roles;
}
if (!empty($roles) && in_array('administrator', $roles)) {
return true;
} else {
return false; // 非管理员
}
}
function diffBetweenTwoDay($time)
{
$time = strtotime($time);
$NowTime = time();
if($time > $NowTime){ return false; }
$TimePoor = $NowTime - $time;
if ($TimePoor == 0) {
$str = '一眨眼之间';
} else if ($TimePoor < 60 && $TimePoor > 0) {
$str = $TimePoor . '秒之前';
} else if ($TimePoor >= 60 && $TimePoor <= 60 * 60) {
$str = floor($TimePoor / 60) . '分钟前';
} else if ($TimePoor > 60 * 60 && $TimePoor <= 3600 * 24) {
$str = floor($TimePoor / 3600) . '小时前';
} else if ($TimePoor > 3600 * 24 && $TimePoor <= 3600 * 24 * 7) {
if (floor($TimePoor / (3600 * 24)) == 1) {
$str = "昨天";
} else if (floor($TimePoor / (3600 * 24)) == 2) {
$str = "前天";
} else {
$str = floor($TimePoor / (3600 * 24)) . '天前';
}
} else if ($TimePoor > 3600 * 24 * 7) {
$str = date("Y-m-d", $time);
}
return $str;
}
if (!function_exists('utf8_excerpt')) :
function utf8_excerpt($str, $len)
{
$str = strip_tags(str_replace(array("\n", "\r"), ' ', $str));
if (function_exists('mb_substr')) {
$excerpt = mb_substr($str, 0, $len, 'utf-8');
} else {
preg_match_all("/[x01-x7f]|[xc2-xdf][x80-xbf]|xe0[xa0-xbf][x80-xbf]|[xe1-xef][x80-xbf][x80-xbf]|xf0[x90-xbf][x80-xbf][x80-xbf]|[xf1-xf7][x80-xbf][x80-xbf][x80-xbf]/", $str, $ar);
$excerpt = join('', array_slice($ar[0], 0, $len));
}
if (trim($str) != trim($excerpt)) {
$excerpt .= '...';
}
return $excerpt;
}
endif;
function format_date($time)
{
global $options, $post;
$p_id = isset($post->ID) ? $post->ID : 0;
$q_id = get_queried_object_id();
$single = $p_id == $q_id && is_single();
if (isset($options['time_format']) && $options['time_format'] == '0') {
return date(get_option('date_format') . ($single ? ' ' . get_option('time_format') : ''), $time);
}
$t = current_time('timestamp') - $time;
$f = array(
'86400' => '天',
'3600' => '小时',
'60' => '分钟',
'1' => '秒'
);
if ($t == 0) {
return '1秒前';
} else if ($t >= 604800 || $t < 0) {
return date(get_option('date_format') . ($single ? ' ' . get_option('time_format') : ''), $time);
} else {
foreach ($f as $k => $v) {
if (0 != $c = floor($t / (int)$k)) {
return $c . $v . '前';
}
}
}
}
function get_share_url($type, $title, $summary)
{
global $set;
if ($set['seo']['description'] != null) {
$description = $set['seo']['description'];
} else {
$description = get_bloginfo('description');
}
$url = urlencode(get_the_permalink());
if ($type == 'qq') {
return 'https://connect.qq.com/widget/shareqq/index.html?url=' . $url . '&title=' . urlencode($title) . '&source=' . urlencode(get_bloginfo('name')) . '&desc=' . urlencode($description) . '&pics=&summary=' . urlencode($summary);
} else if ($type == 'weibo') {
return 'https://service.weibo.com/share/share.php?url=' . $url . '&title=' . urlencode($summary) . '&pic=&appkey=&searchPic=true';
} else if ($type = 'qzone') {
return 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' . $url . '&title=' . urlencode($title) . '&pics=&summary=' . urlencode($summary);
}
}
function corepress_replace_copyright($str)
{
global $post;
$author_name = get_the_author();
$author_url = get_the_author_link();
$post_url = get_permalink();
$post_name = get_the_title();
$str = str_replace('<#username#>', $author_name, $str);
$str = str_replace('<#url#>', $post_url, $str);
$str = str_replace('<#authorurl#>', $author_url, $str);
$str = str_replace('<#postname#>', $post_name, $str);
return $str;
}
function corepress_jmp_message($message, $jumpUrl)
{
global $set;
?>