YOURLS 重复短网址 URL 解决方法

YOURLS(什么是 YOURLS ?请看:YOURLS 短网址系统的详细介绍)会把一篇文章生成 N 个地址,就算系统配置不允许一个网址生成多个短网址。

早就有人发现这些问题(#429#442),不过作者表示:Fixed

FYI it’s because the plugin polls YOURLS to ask for a short URL,
so YOURLS fetches the page to get its title and doing so, the page wants to display
its short url, which doesn’t exist yet, so the plugin polls YOURLS to ask for
a short URL, and so on, till one instance of YOURLS can get the title of the page

简单来说就是,WP插件会不停地跑,直到它拿到文章的标题。

第一次,生成短网址
第二次,还没拿到标题
第三……
第 N 次,拿到标题。

最后,后台生成了 N 个短网址。

临时解决方法:

Continue reading YOURLS 重复短网址 URL 解决方法

替Philna2主题添加版权申明

替Philna2主题添加版权申明

Philna2 主题添加个人代码很简单,例如:版权申明,或者作者栏。

水煮鱼的方法

<?php
/*
Plugin Name: 版权申明
Plugin URI: http://fairyfish.net/m/copyright/
Description: 在日志下面添加版权申明
Version: 0.1
Author: Denis
*/
function post_copyright(){
  if(is_single()){
  global $post,$authordata;
?>
<div id="copyright">
<?php echo get_avatar($authordata->ID,'55');?>
<p>作者:<a href="<?php echo $authordata->user_url; ?>" title="<?php echo $authordata->display_name;?>"><?php echo $authordata->display_name;?></a><br />
原文链接:<a href="<?php echo get_permalink($post->ID);?>" title="<?php echo $post->post_title; ?>"><?php echo $post->post_title; ?></a><br />
<a href="<?php bloginfo('url');?>" title="<?php bloginfo('name');?>"><?php bloginfo('name');?></a>版权所有,请勿转载本博客日志到任何博客或论坛。</p>
</div>
<?php
  }
}

add_filter('the_content','post_copyright_content');
function post_copyright_content($text){
ob_start();
post_copyright();
$post_copyright_content = ob_get_contents();
ob_end_clean();
return $text.$post_copyright_content;
}
?>

复制上面的代码,插到 function.php 的 ?> 之前。

fairyfish-copyright-sample

上面的是水煮鱼的效果图

 

修改代码

1、为了适应 philna2 主题原来的 css 代码,把 div 标签去掉吧,删掉:<div id=”copyright”> 和 </div>

2、作者的头像也不要,删掉:<?php echo get_avatar($authordata->ID,’55’);?>

3、加入自己的代码,我就用短网址(需要安装插件:YOURLS: WordPress to Twitter):

作者也放出一些标签代码:

1、<?php wp_ozh_yourls_url(); ?>
直接生成的链接,例如:
<a href=”http://ozh.in/j5″ rel=”nofollow alternate shorter” title=”short URL”>http://ozh.in/j5</a>

2、<?php wp_ozh_yourls_raw_url( $echo = true)?>
打印出短网址,不是链接;例如:http://ozh.in/j5

3、yourls-wordpress-to-twitter/plugin.php 有更多的标签代码,可以慢慢琢磨一下。

 

提示:本文章的方法只限用于 Philna2 主题,其他的请自行 google

Philna2 的方法

Continue reading 替Philna2主题添加版权申明

YOURLS 短网址系统

Yourls 短网址系统

超短介绍

YOURLS(全称:Your Own URL Shortener) 是一款 PHP 短网址系统,它能把很长的网址变成只有几个字母。域名短缩一般用于microblog,个人状态,个性签名等,作字数限制的地方。

↓↓↓↓↓ 直接看例子吧 ↓↓↓↓↓

例如:
原来长网址:http://code.google.com/p/yourls/downloads/detail?name=yourls-1.5.zip&can=2&q=
缩短后:http://goo.gl/gekjn

例子都不重要,只要明白它的用处就好了。说是没用的,做才是实际。下来玩一回!

注意:上面的例子是用‘随机地址’这个插件生成的,原来的 YOURLS 生成的短地址是跟顺序的:1a,1b,1c 这样

Continue reading YOURLS 短网址系统