wordpress语言切换
One aspect of WordPress I dislike is that trackbacks display as a comment with the rest of a post's comments. Trackbacks are a nuisance when there's a great conversation going within the post's comments. Some users, however, love trackbacks so I can't simply get rid of them. I know there are plugins available to separate trackbacks from post comments, but I've chosen a different approach.
我不喜欢的WordPress的一方面是引用引用与帖子的其余评论一起显示为评论。 当帖子的评论中进行大量对话时,引用引用是很麻烦的。 但是,有些用户喜欢引用,所以我不能简单地摆脱它们。 我知道有一些插件可用于将引用引用与帖子注释分开,但是我选择了另一种方法。
Using PHP, MooTools JavaScript, and simple CSS, I've added functionality to my website to toggle trackback display at the click of a link. Want to do the same? Follow these steps.
使用PHP,MooTools JavaScript和简单CSS,我在网站上添加了功能,以在单击链接时切换引用显示。 想要做同样的事情吗? 跟着这些步骤。
步骤1:PHP / XHTML (Step 1: The PHP/XHTML)
You'll need to add a CSS class, trackback, to the comment's wrapper DIV if the comment type is trackback.
如果注释类型为引用 ,则需要将CSS类trackback添加到注释的包装器 DIV中。
<div id="comment-<?php comment_ID() ?>" class="comment <?php if(get_comment_type() != 'comment') { echo 'trackback'; } ?>">
步骤2:CSS (Step 2: The CSS)
Declare the trackback class in your stylesheet. Also, define the toggle link as an ID(#).
在样式表中声明引用类。 另外,将切换链接定义为ID(#)。
.trackback { display:none; }
#toggle-tb-link { display:block; float:right; font-size:11px; font-family:arial; font-weight:normal; margin:0 10px 0 0; color:#090; }
步骤3:Moo (Step 3: The Moo)
Using MooTools, we create a JavaScript function that sets the wrapper DIV's CSS display property and link message depending on whether the trackbacks should show or hide.
使用MooTools,我们创建了一个JavaScript函数,该函数根据应显示或隐藏引用来设置包装器DIVCSS显示属性和链接消息。
//trackback toggle
function toggle_trackbacks()
{
//for every trackback div...
$$('.trackback').each(function(el) {
//show or hide the trackbacks
el.setStyle('display',(el.getStyle('display') == 'block' ? 'none' : 'block'));
});
//set the link text
$('toggle-tb-link').setText(($('toggle-tb-link').getText() == 'Hide Trackbacks' ? 'Show' : 'Hide') + ' Trackbacks');
}
步骤4:建立连结 (Step 4: Create the Link)
Now that all of the functionality in place, we can add the link anywhere on our page.
现在所有功能都已就绪,我们可以在页面上的任何位置添加链接。
<a href="javascript:toggle_trackbacks();" class="no-print" id="toggle-tb-link">Show Trackbacks</a>
You don't need to use MooTools for this project, but like MooTools does for every other part of my blog, I can create a lot of functionality with a little bit of code.
您无需在该项目中使用MooTools,但就像MooTools在我的博客的每个其他部分一样,我可以用一些代码来创建很多功能。
没有引用引用? 没问题! (No Trackbacks? No Problem!)
I've also added the following snippet of code to hide the toggle link if there are no trackbacks:
我还添加了以下代码片段,以在没有引用的情况下隐藏切换链接:
//manage trackback link
window.addEvent('domready',function() {
if(!$$('.trackback').length) { $('toggle-tb-link').setStyle('display','none'); }
});
Have any suggestions for this system?
对这个系统有什么建议吗?
翻译自: https://davidwalsh.name/set-wordpress-blog-trackback-toggling
wordpress语言切换