// you’re reading...

WordPress 翻译

把WordPress变成Twitter

本文转载自:WordPress啦!

Twitter日益流行,越来越多的人想给自己的家人、朋友、同事建立一个像Twitter这样的微博客,其实这并没有想象中的难。在这里我给大家介绍下如何在WordPress中轻松创建微博客

前言

Twitter的成功是大家有目共睹的,微博客无疑是非常实用和高效的。它可以让我们随时跟家人、朋友、同事保持联系。 尽管Twitter已经很出色了,但是作为私人空间,比如与同事分享工作体验或是向家人汇报近况,Twitter却不是最佳的选择。

为此,之前我用开源程序laconi.ca创建自己的微博客网站,它可以让用户创建类似于Twitter 的微博客网站。说实话,它不怎么让我满意,应该说挺后悔安装它的。
在这次不愉快的体验后,我觉得应该让WordPress来实现这一功能。

动手吧!

说了这么多,让我们行动起来用WordPress创建自己的私人微博客吧!

1. 安装WordPress

首先要做的当然是在服务器上安装WordPress。安装WordPress非常简单,你可以在网上找到安装教程,这里就不再讲述。需要帮助的话,你可以阅读相关文档

2.使用P2 主题

Automattic公司出品的适合微博客应用的一个非常酷的主题,叫做P2,你可以 免费下载

下载完后,将它上传到WordPress的the wp-content/ themes 目录下。然后,登陆到WordPress后台的外观/主题,选择P2主题并激活。 这样你就成功安装P2主题,一切准备就绪了。

3.关于登录面板

尽管P2主题已经不错了,你还可以通过一些方法完善它。由于P2允许用户不通过WordPress后台直接从frontpage发布内容。在主题的侧边栏添加个登录控制面板是个不错的主意。 登录控制面板可以帮你实现:

  • 如果用户尚未登录或还没有账户,系统将会显示登录表单及注册链接,访问者可以自己创建账户。
  • 如果用户已经登录,系统会显示一个退出和账户选项的链接,因此就算是不懂WordPress的用户也可以轻松更新他的资料。

在主题的侧边栏添加登录面板,只要打开主题中sidebar.php文件,粘贴下面的代码就行:

<li>
<?php global $user_ID, $user_identity, $user_level ?>
<?php if ( $user_ID ) : ?>

<h2>Control panel</h2>
<ul>
<li>Identified as <strong><?php echo $user_identity ?></strong>.
<ul>
<li><a href=”<?php bloginfo(‘url’) ?>/wp-admin/”>Dashboard</a></li>

<li><a href=”<?php bloginfo(‘url’) ?>/wp-admin/profile.php”>Profile and personal options</a></li>
<li><a href=”<?php bloginfo(‘url’) ?>/wp-login.php?action=logout&amp;redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>”>Logout</a></li>

<?php
if (is_single()) {?>
<li><a href=”<?php bloginfo(‘wpurl’);?>/wp-admin/edit.php?p=<?php the_ID(); ?>”>Edit Post</a>
</li>
<?php } ?>

</ul>
</li>
</ul>

<?php elseif ( get_option(‘users_can_register’) ) : ?>
<h2>Identification</h2>
<ul>
<li>

<form action=”<?php bloginfo(‘url’) ?>/wp-login.php” method=”post”>
<p>
<label for=”log”><input type=”text” name=”log” id=”log” value=”<?php echo wp_specialchars(stripslashes($user_login), 1) ?>” size=”22″ /> User</label><br />
<label for=”pwd”><input type=”password” name=”pwd” id=”pwd” size=”22″ /> Password</label><br />
<input type=”submit” name=”submit” value=”Login” />
<label for=”rememberme”><input name=”rememberme” id=”rememberme” type=”checkbox” checked=”checked” value=”forever” /> Remember me</label><br />
</p>
<input type=”hidden” name=”redirect_to” value=”<?php echo $_SERVER['REQUEST_URI']; ?>”/>
</form>

</li>
<li><a href=”<?php bloginfo(‘url’) ?>/wp-register.php”>Register</a></li>
<li><a href=”<?php bloginfo(‘url’) ?>/wp-login.php?action=lostpassword”>Recover password</a></li>
</ul>

<?php endif; ?>
</li>

4. 微博客保密化
登录/注册表单在某些情况下是挺完美了,但是别人还是可以通过搜索引擎引用你的内容。如果你想要让你的网站完全保密,也是没有问题的。 这就需要使用到WordPress插件Private WP,(下载)。下载完后,将它上传到wp-content/plugins 目录下。然后登陆WordPress后台,激活该插件。

这样,你的网站就可以自动检测登录用户,只有登录用户才可阅读和发布文章。对于未知访问者,系统将会自动转向到WordPress登录面板。

结论

这再次验证了WordPress的可扩展性以及功能的强大。如果你对WP比较熟悉,不用半个小时就可以用P2主题创建一个类似于Twitter的站点。够神奇吧!

这里只是简单介绍创建微博客网站的一些基本技巧,如果有兴趣,还有很多有意思的功能可以用来加强你的微博网站。比如,创建一个页面显示所有的会员列表或者过滤文章(只有特定的会员才可以发布文章)等等。

原文:

Create your own private Twitter site using WordPress

With the incredible popularity of Twitter theses days, many people are asking themselves how can they create their own Twitter-like network for their family, friends or company. This may be a lot easier than you think. In this tutorial, I’m going to show you how to do it easily, using WordPress.

Getting ready

Twitter success is the proof, microblogging is definitely something useful and efficient. It can help you staying tuned with friends, family or coworkers.

While Twitter is great, it may not be the best choice if you’re looking for a private network, for example for sharing work tips with colleagues, or notice your familly about what’s up.
As I was searching for an easy and quick way to create a private microblogging website, I stumbled upon an open source app called laconi.ca, which was created to allow people to launch their own private “Twitter like” microblogging sites. I didn’t really liked it and it was a total pain to install.

After this not so good experience, I decided that WordPress should do that job, and do it good as always.
P2 Theme

Let’s doing it

Well, enought talk for now! Let’s create our own, private microblogging website using our beloved WordPress.

1. Installing WordPress

The first thing to do is obviously to install WordPress on your server. Installing WordPress is definitely easy and and I’ll not explain it here due to the incredible amount of tutorials you can find on the internet.
If you need help for installing WordPress, you should read the documentation. Or even better, you can register at WpWebHost, the WordPress hosting experts, and use Fantastico to get your WordPress installed automatically in a minute. Just click here if you want to know more.

2. Get your copy of the P2 theme

The guys from Automattic (The company behing WordPress) released, some time ago, a very cool WordPress theme for social microblogging. The theme is called P2 and you can get it for free here.

After you downloaded P2, simply uncompress the archive and upload it to the wp-content/themes directory of your WordPress install. Once done, login to your WordPress dashboard and go to “Appearance”, “Themes”. Slect the P2 theme and activate it.

P2 Theme
That’s easy as that, you have sucessfully installed P2 and you’re ready for social microblogging.

3. What about a login form?

Althought the P2 theme itself is very good, it is possible to enhance it even more. As P2 allow users to post directly from the frontpage, without visiting WordPress dashboard, a good idea should be to integrate a control panel in the theme sidebar.
Our control panel will do the following:
If the user isn’t logged in or have no account yet: We’ll display a login form as well as a link to register, so the visitor can create his account.
If the user is already logged in: We’ll display a link to logout as well as a link to account options, so the user (Even if (s)he doesn’t know much about WordPress) can easily update his/her profile.

To integrate a login form in your theme sidebar, simply open the sidebar.php file and paste the following code:

<li>
  <?php global $user_ID, $user_identity, $user_level ?>
  <?php if ( $user_ID ) : ?>

    <h2>Control panel</h2>
	 <ul>
	   <li>Identified as <strong><?php echo $user_identity ?></strong>.
	   <ul>
		  <li><a href="<?php bloginfo('url') ?>/wp-admin/">Dashboard</a></li>

			<li><a href="<?php bloginfo('url') ?>/wp-admin/profile.php">Profile and personal options</a></li>
			<li><a href="<?php bloginfo('url') ?>/wp-login.php?action=logout&amp;redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>">Logout</a></li>

         <?php
         if (is_single()) {?>
           <li><a href="<?php bloginfo('wpurl');?>/wp-admin/edit.php?p=<?php the_ID(); ?>">Edit Post</a>
           </li>
         <?php } ?>

	</ul>
	</li>
	</ul>

  <?php elseif ( get_option('users_can_register') ) : ?>
    <h2>Identification</h2>
    <ul>
      <li>

      <form action="<?php bloginfo('url') ?>/wp-login.php" method="post">
      <p>
        <label for="log"><input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="22" /> User</label><br />
        <label for="pwd"><input type="password" name="pwd" id="pwd" size="22" /> Password</label><br />
<input type="submit" name="submit" value="Login" />
        <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label><br />
</p>
        <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
      </form>

      </li>
      <li><a href="<?php bloginfo('url') ?>/wp-register.php">Register</a></li>
      <li><a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Recover password</a></li>
    </ul>

<?php endif; ?>
</li>

4. Making your network private

While the login/register form option can be good in some case, it will still allow people to read your discussions and search engines to index your content. If your need is a 100% private website, don’t worry. This is far from being a problem.
To do so, we’ll use a WordPress plugin, named Private WP. Get your copy here. Once you have it, extract the archive on your hard drive and upload the private-wp to the wp-content/plugins directory of your WordPress install. Then, simply login to WordPress, go to the dashboard, then to “Plugins” and activate the plugin.

That’s all you have to do. Now, your website will automatically detect logged in users, who’ll be able to read and post content, and unknown visitors, who’ll be automatically redirected to WordPress loggin panel.

Conclusion

The first thing which have to be said is that, one more time, WordPress show how extensible and powerful it is. If you’re familiar with WP, creating this “Twitter-like” site using the P2 theme should not take you more than 30 minutes. Isn’t that great? I’ll not say that I love WordPress, because all of you already know ;)

This tutorial was focused on making a private microblogging site and used only basic techniques, but there’s a lot of other interresting things that can be done in order to enhance this “Twitter-like” site. For example, you may want to create a page template listing all members, or even better, filtering posts to see only those posted by a selection of members?