页面载入中...
首页 » WordPress

如意盒de免费PHP空间,免费分享优质国外空间

如意盒de免费PHP空间,免费分享优质国外空间
# 无需备案+超强中文控制面板cpanel+域名邮箱+多个域名绑定+不限容量的mysql数据库

# 可自行绑定 2个一级域名, N个二级域名,随意开通 N 个共享磁盘空间容量的企业邮箱(如:admin@你的域名)
# ? M 的空间,每个网站月流量限制 ? G(?=随机)
# 可建立 N 个MYSQL数据库(共享磁盘容量),支持PhpMyAdmin在线管理
# 支持文件
在线压缩、解压缩,支持web在线文件管理
# N 个FTP账号,并支持SSH
# 支持
SSL, FTP, Stats ,手机wap浏览,支持泛域名解析,.htaccess
#mod_rewrite组件支持,可直接设置各类程序的伪静态

# 支持CGI,Perl,PHP,MySQL,不支持ASP
#空间支持国内、国外各种PHP程序,如discuz、phpwind、DEDECMS、PHPCMS、Supesite、帝国cms、ecshop、shopex、wordpress、zen-cart、Joomla、淘宝客站,168整站系统等(不支持ASP和ASP.NET)

术语解析:cpanel–虚拟主机控制系统。在cPanel主机上,您可以自如控制一切,无需联系服务商开通或调整任何功能,所有你想得到的功能都可以在控制界面自助完成。在cPanel做不到的功能,99%的可能性是根本不适合在虚拟主机环境(来自百度百科)。

本空间不允许放置仿牌外贸站,下载站、发布垃圾邮件、带有涉及版权的内容、在服务器上大量采集站、电影、游戏、私服、成人站点、国内禁止的某类图片站、擦边站、美女聊天室,并且本站禁止存放任何与中国和美国法律相抵触的内容

PHP探针(http://ruyice.com/tanzhen.php
PHP详细信息(http://ruyice.com/phpinfo.php
支持手机wap访问,测试地址(http://ruyice.com/wap.php
cpanel使用教程(http://ruyice.com/cp
后台管理登陆(http://ruyice.com/cpanel
企业(域名)邮箱登陆(http://ruyice.com/webmail

方便实用的 Wordpress 小技巧

两列显示WordPress的分类:

<?php
$cats = explode("<br />",wp_list_categories('title_li=&echo=0&depth=1&style=none'));
$cat_n = count($cats) - 1;
$cat_col = round($cat_n / 2);
for ($i=0;$i<$cat_n;$i++){
if ($i<$cat_col){
$cat_left = $cat_left.'<li>'.$cats[$i].'</li>';
}
elseif ($i>=$cat_col){
$cat_right = $cat_right.'<li>'.$cats[$i].'</li>';
}
}
?>
<ul>
<?php echo $cat_left;?>
</ul>
<ul>
<?php echo $cat_right;?>
</ul>

CSS代码

.right {float:left; width:200px;}
.left {float:left; width:200px;}

两列显示WordPress的页面:

<?php
$page_s = explode("</li>",wp_list_pages('title_li=&echo=0&depth=1&style=none'));
$page_n = count($page_s) - 1;
$page_col = round($page_n / 2);
for ($i=0;$i<$page_n;$i++){
if ($i<$page_col){
$page_left = $page_left.''.$page_s[$i].'</li>';
}
elseif ($i>=$page_col){
$page_right = $page_right.''.$page_s[$i].'</li>';
}
}
?>
<ul>
<?php echo $page_left; ?>
</ul>
<ul>
<?php echo $page_right; ?>
</ul>

CSS代码:

.right {float:left; width:200px;}
.left {float:left; width:200px;}

版权年限:

手动地输入版权信息

Copyright &copy; < ?php echo date("Y");?>

全自动式只需打开主题中的functions.php文件,添加如下代码

function copyrightDate() {
global $wpdb;
$copyright_dates = $wpdb->get_results("
SELECT
YEAR(min(post_date_gmt)) AS firstdate,
YEAR(max(post_date_gmt)) AS lastdate
FROM
$wpdb->posts
");
if($copyright_dates) {
$copyright = "Copyright &copy; " . $copyright_dates[0]->firstdate;
if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
$copyright .= '-' . $copyright_dates[0]->lastdate;
}
echo $copyright . "&nbsp;" . get_bloginfo('name');
}
}
add_filter('wp_footer', 'copyrightDate');

自动读取文章中的第一个图片,打开functions.php文件,添加如下的php代码:

function get_first_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "/images/default.jpg";
}
return $first_img;
}

调用该函数

<?php echo get_first_image() ?>

手动定义显示文章完整或摘录的函数,在您的index.php文件,取代您的循环函数:

<?php if (have_posts()) :
while (have_posts()) : the_post();
$customField = get_post_custom_values("full");
if (isset($customField[0])) {
//Custom field is set, display a full post
the_title();
the_content();
} else {
// No custom field set, let’s display an excerpt
the_title();
the_excerpt();
endwhile;
endif;
?>

禁用评论超过30天WordPress的帖子,打开functions.php文件,添加如下的php代码:

function close_comments( $posts ) {
if ( !is_single() ) { return $posts; }
if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( 30 * 24 * 60 * 60 ) ) {
$posts[0]->comment_status = 'closed';
$posts[0]->ping_status = 'closed';
}
return $posts;
}
add_filter( 'the_posts', 'close_comments' );

对你的WordPress的访客,显示一个欢迎回来的信息:

<?php
if(isset($_COOKIE['comment_author_'.COOKIEHASH])) {
$lastCommenter = $_COOKIE['comment_author_'.COOKIEHASH];
echo "Welcome Back ". $lastCommenter ."!";
} else {
echo "Welcome, Guest!";
}
?>

WordPress中显示一个下拉菜单的标签,打开functions.php文件,添加如下的php代码:

function dropdown_tag_cloud( $args = '' ) {
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
'exclude' => '', 'include' => ''
);
$args = wp_parse_args( $args, $defaults );
$tags = get_tags( array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags
if ( empty($tags) )
return;
$return = dropdown_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
if ( is_wp_error( $return ) )
return false;
else
echo apply_filters( 'dropdown_tag_cloud', $return, $args );
}
function dropdown_generate_tag_cloud( $tags, $args = '' ) {
global $wp_rewrite;
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
);
$args = wp_parse_args( $args, $defaults );
extract($args);
if ( !$tags )
return;
$counts = $tag_links = array();
foreach ( (array) $tags as $tag ) {
$counts[$tag->name] = $tag->count;
$tag_links[$tag->name] = get_tag_link( $tag->term_id );
if ( is_wp_error( $tag_links[$tag->name] ) )
return $tag_links[$tag->name];
$tag_ids[$tag->name] = $tag->term_id;
}
$min_count = min($counts);
$spread = max($counts) - $min_count;
if ( $spread <= 0 )
$spread = 1;
$font_spread = $largest - $smallest;
if ( $font_spread <= 0 )
$font_spread = 1;
$font_step = $font_spread / $spread;
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
if ( 'name' == $orderby )
uksort($counts, 'strnatcasecmp');
else
asort($counts);
if ( 'DESC' == $order )
$counts = array_reverse( $counts, true );
$a = array();
$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';
foreach ( $counts as $tag => $count ) {
$tag_id = $tag_ids[$tag];
$tag_link = clean_url($tag_links[$tag]);
$tag = str_replace(' ', '&nbsp;', wp_specialchars( $tag ));
$a[] = "\t<option value='$tag_link'>$tag ($count)</option>";
}
switch ( $format ) :
case 'array' :
$return =& $a;
break;
case 'list' :
$return = "<ul class='wp-tag-cloud'>\n\t<li>";
$return .= join("</li>\n\t<li>", $a);
$return .= "</li>\n</ul>\n";
break;
default :
$return = join("\n", $a);
break;
endswitch;
return apply_filters( ‘dropdown_generate_tag_cloud’, $return, $tags, $args );
}

调用该函数

<select name="tag-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="#">Liste dauteurs</option>
<?php dropdown_tag_cloud('number=0&order=asc'); ?>
</select>

添加一个电子邮件这个按钮:

<script type="text/javascript">
<!-- Begin
function isPPC() {
if (navigator.appVersion.indexOf("PPC") != -1) return true;
else return false;
}
if(isPPC()) {
document.write('<a HREF=\"mailto:\?subject\=Take a look at this page I found, ' + document.title + '?body=You can see this page at: ' + window.location + '\" onMouseOver="window.status=\'Send your friends e-mail about this page\'; return true" TITLE="Send your friends e-mail about this page">Email to a Friend<\/a>');
}
else { document.write('<a HREF=\"mailto:\?body\=Take a look at this page I found titled ' + document.title + '. You can see this page at: ' + window.location + '\" onMouseOver="window.status=\'Send your friends e-mail about this page\'; return true" TITLE="Send your friends e-mail about this page" rel="nofollow">Email This!<\/a>');
}
// End –>
</script>

使用PHP的preg_replace函数,显示我们要显示的东西:

<ul id="nav">
<li><a href="<?php echo get_option('home'); ?>/"><span>Home</span></a></li>
<?php echo preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<li$1><a$2><span>$3</span></a>', wp_list_pages('echo=0&orderby=name&exlude=181&title_li=&depth=1')); ?>
</ul>

<ul id="nav">
<li><a href="<?php echo get_option('home'); ?>/"><span>Home</span></a></li>
<?php echo preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<li$1><a$2><span>$3</span></a>', wp_list_categories('echo=0&orderby=name&exlude=181&title_li=&depth=1')); ?>
</ul>

一个下拉框显示档案:

<select name=\"archive-dropdown\" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=\"\"><?php echo attribute_escape(__('Select Month')); ?></option>
<?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>

在下拉框显示分类:

<form action="<?php bloginfo('url'); ?>/" method="get">
<?php
$select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0');
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select); echo $select; ?>
<noscript><input type="submit" value="View" /></noscript>
</form>

强大的 Wordpress 自定义域

wordpress高级应用,的确感觉wordpress是越来越强大了,利用它不仅仅可以做出博客,而且更可以成为内容管理系统。在本文中,收藏一些Wordpress 自定义域的技巧和应用。

优化wordpress SEO

<?php if ( is_home() ) { ?>
<meta name="description" content="。。。" />
<meta name="keywords" content="。。。" />
<?php } ?>
<?php if ( is_single() ) { ?>
<meta name="description" content="<?php $key="description"; echo get_post_meta($post->ID, $key, true); ?>" />
<?php } ?>
<?php if ( is_category() ) { ?>
<meta name="description" content="<?php echo category_description(); ?>" />
<?php } ?>

单篇日志和PAGE页面的TITlE优化

<?php if (is_home() ) { ?>首页标题<?php }?>
<?php if( get_post_meta($post->ID, "title_single", true) ): ?>
<?php echo get_post_meta($post->ID, "title_single", true); ?>|站点名称
<?php else: ?>
<?php wp_title(''); ?>|站点名称
<?php endif; ?>

给某一日记添加js或者CSS

假设我们给日志单独加载JS、CSS的自定义域名称是 head_JS_CSS。那么你首先需要把下面这段代码复制到你主题根目录下的 functions.php 文件中:

function head_JS_CSS(){
if (is_single() || is_page()) {
global $post;
$head_JS_CSS = get_post_meta($post->ID, 'head_JS_CSS', true);
echo $head_JS_CSS;
}
}
add_action("wp_head","head_JS_CSS");

现在你在添加日志的时候,在WordPress自定义域区域,创建一个新的名称为:”head_JS_CSS”自定义域,在“值”输入你要单独为这篇日志 加载的 Javascript 代码或者 CSS 即可。

给加密的日志添加密码提示信息

假设我们给日志添加密码提示的自定义域名称是password_hint。那么你首先需要把下面这段代码复制到你主题根目录下的 functions.php 文件中:

function password_hint( $c ){
global $post, $user_ID, $user_identity;
if ( empty($post->post_password) )
return $c;
if ( isset($_COOKIE['wp-postpass_'.COOKIEHASH]) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) == $post->post_password )
return $c;
//替换
if($hint = get_post_meta($post->ID, 'password_hint', true)){
$url = get_option('siteurl').'/wp-pass.php';
if($hint)
$hint = '密码提示:'.$hint;
else
$hint = "请输入您的密码";
if($user_ID)
$hint .= sprintf('欢迎进入,您的密码是:', $user_identity, $post->post_password);
$out = <<<END
<form method="post" action="$url">
<p>这篇文章是受保护的文章,请输入密码继续阅读:</p>
<div>
<label>$hint<br/>
<input type="password" name="post_password"/></label>
<input type="submit" value="Submit" name="Submit"/>
</div>
</form>
END;
return $out;
}else{
return $c;
}
}
add_filter('the_content', 'password_hint');

然后在你添加日志的时候,在WordPress自定义域区域,创建一个新的名称为:”password_hint”的自定义域,在“值”输入你密码提示: 如xx的生日是几号?

显示日志缩略图

<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<img src="<?php $values = get_post_custom_values("image_thumb"); echo $values[0]; ?>" alt="<?php the_title(); ?>" />
</a>

然后在你添加日志的时候,在WordPress自定义域区域,创建一个新的名称为:”image_thumb”自定义域,在“值”输入你要为本篇日志上传 的图片的 URL。

WordPress添加自定义域提示

我们只需要找到主题文件夹的根目录下的functions.php文件,添加以下代码即可:

function custom_fields_tip(){
$h3 = "欢迎使用自定义域";
$html=<<<END
<div>
<h3>$h3</h3>
<div>
<p>如果你正在发布或编辑一篇受密码保护的文章,建议您添加一个名称为'password_hint'的自定义域.用来提示访客.<br/>使用'head_JS_CSS'可以添加css、js到头部.<br/>使用'image_thumb'可以给文章添加缩略图</p>
</div>
</div>
END;
echo $html;
}
add_action('submitpost_box', 'custom_fields_tip');
add_action('submitpage_box', 'custom_fields_tip');

一个自定义字段中存放多个值

function article_source() {
global $post;
$article_source = get_post_meta($post->ID, article_source,false);
if($article_source) {
foreach ($article_source as $article_sources){
$fullValue = explode ("|", $article_sources);
$name = $fullValue[0];
$address = $fullValue[1];
}
echo '翻译来源:<a href="'.$address.'" target="_blank">'.$name.'</a>,';
}
else {
echo '本文为本站原创,';
}
}

将上面的代码复制到 WordPress 主题目录的 functions.php 中,然后在合适的地方调用这个函数即可。对于翻译的文章,需要给文章添加一个名称为 article_source 的自定义域,里面存放两个值,方式为“网站名|文章地址”。原创的文章则不添加这个自定义域。

下面简单解释一下这段代码。get_post_meta() 这个函数会调用指定自定义域中的值,通过其参数我们可以控制是作为一个字符串 调用还是作为一个数组调用以便接下来的处理,详细的用法请参见函数的说明。我这里使用 false 参数将函数设定为作为数组提取。接下来使用 foreach 语句遍历数组,讲结果存放到一个新的变量中,再用 explode 语句以“|” 符号为标记对其进行切割。最后就是把切割开的值分别存放到两个新的变量中以供提取使用。

有了这个例子,你就可以很方便的修改上面给出的代码来实现自己需要的功能了。