标记档案: WordPress的

高性能博客和网站

你有一个网站或一个博客,觉得这是陷入困境交通繁忙? 首先, 祝贺 - 这是这些问题一个网站管理员和博客很想有. 但你会如何解决呢? 要做的第一件事是让PHP加速, 如果你的网站/博客是一个基于PHP的. 尽管它应该是直接的 (在理论上), 它可能需要一段时间来得到它的权利. 你知道他们说什么 - 在理论上, 理论和实践都一样. 在实践中, 它们不是. 促进, 然而,, 是低挂的果实, 并会很长的路要走解决你的问题.

一旦你已经提取的所有里程出来的加速器解决方案, 现在是时候把内容分发网络CDN或. 什么是CDN确实是为所有的静态文件 (图片, 样式表, javascript文件, 甚至缓存的博客网页) 从服务器而不是您​​自己的网络. 这些服务器进行战略性部署在非洲大陆 (和世界各地的) 让你的读者从地理上位置靠近他接收内容. 除了减少了等待时间,由于距离, CDN还可以帮助您减少服务器上的负载.

继续阅读

如何将字符串保存到一个PHP本地文件?

这篇文章是第二个在我的怪胎系列.

虽然我的节目主题调教, 我碰到这个问题,. 我在我的PHP程序有我的服务器上的字符串 (在调整了样式表, 事实上), 我想给用户保存到一个文件中他的计算机的选项. 我一直认为这是一个常见的​​问题, 和所有常见的问题都可以通过谷歌搜索来解决. 但, 你瞧, 我只是找不到一个满意的解决方案. 我发现我自己, 并以为我会在这里分享, 所有未来谷歌的利益还没有来去.

在我们进入解决方案, 让我们明白问题是什么. 问题是在劳动两台计算机之间的分工 — 一个是服务器, 在那里你的WordPress和PHP运行; 另一种是在客户的计算机,其中所述的观看正在发生. 我们正在谈论的字符串是在服务器上. 我们希望将其保存在一个文件中的客户端的计算机上. 做到这一点的唯一方法是通过服务的字符串作为HTML回复.

乍一看, 这看起来并不像一个大问题. 毕竟, 服务器定期发送的字符串和数据客户 — 这就是我们看到的在任何浏览器, 包括你正在阅读. 如果这只是任何PHP程序,要保存字符串, 这将不会是一个问题. 你可以只转储字符串到服务器上的文件和服务文件.

但是,你会怎么做,如果你不想让整个世界倾倒字符串的文件服务器上的方式? 好, 你可以做这样的事情:

<?php
header('Content-Disposition: attachment; filename="style.css"');
header("Content-Transfer-Encoding: ascii");
header('Expires: 0');
header('Pragma: no-cache');
print $stylestr ;
?>

所以, 只是把这个代码在您foo.php,计算字符串$ stylestr和你做. 但我们的问题是,我们正在努力在WordPress的插件框架, 而不能使用的标头() 电话. 当您尝试这样做,, 你会得到错误信息说,头已经完成花花公子. 针对此问题, 我找到了巧妙的解决方案,我用的插件之一. 忘记了哪一个, 但我想这是一种常见的技术. 该解决方案是定义一个空的iFrame并设置其源PHP函数会写什么. 由于预计的iFrame一个完整的HTML源代码, 你被允许 (事实上, 有责任) 以得到标题() 指令. 该代码片段看起来像:

<iframe id="saveCSS" src="about:blank" style="visibility:hidden;border:none;height:1em;width:1px;"></iframe>
<script type="text/javascript">
var fram = document.getElementById("saveCSS");
<?php echo 'fram.src = "' . $styleurl .'"' ;
?>

现在的问题是, 又该源是? 换句话说, 什么是$ styleurl? 明确地, 它不会是你的服务器上的静态文件. 与这个主题的目的是要表明,它不必须是在服务器上的文件中,在所有. 它是由两部分组成的答案. 你要记住,你是WordPress的框架内工作, 你不能让独立的PHP文件. 你能做的唯一一件事就是参数添加到现有的PHP文件, 或者您所创建的插件. 所以,你首先做一个提交按钮如下:

<form method="post" action="<?php echo $_SERVER["REQUEST_URI"]?>">
<div class="submit">
<input type="submit" name="saveCSS" title="Download the tweaked stylesheet to your computer" value="Download Stylesheet" />
</div>

请注意,按钮的名称属性 “saveCSS。” 现在, 在代码的部分,处理的顺服, 你做这样的事情:

<?php
if (isset($_POST['saveCSS']))
$styleurl = get_option('siteurl') . '/' . "/wp-admin/themes.php?page=theme-tweaker.php&save" ;

?>

这是$ styleurl,你会给你的iframe的源, 前锋. 请注意,这是一样的你pluging页面网址, 除非你设法添加 “?保存” 在它的结束. 接下来的关键是要抓住这样的说法和处理它. 对于, 使用WordPress的API函数, add_action作为:

<?php
if (isset($_GET['save'] ))
add_action('init', array(&$thmTwk, 'saveCSS'));
else
remove_action('init', array(&$thmTwk, 'saveCSS'));
?>

这增加了一个功能,saveCSS到你的插件的初始化部分. 现在,你必须定义这个功能:

<?php
function saveCSS() {
header('Content-Disposition: attachment; filename="style.css"');
header("Content-Transfer-Encoding: ascii");
header('Expires: 0');
header('Pragma: no-cache');
$stylestr = "Whatever string you want to save";
ob_start() ;
print $stylestr ;
ob_end_flush() ;
die() ;
}
?>

现在,我们几乎无家. 要了解的唯一的事情就是你 需要模具(). 如果你的函数不会死, 它会喷涌出来的WordPress的东西产生,其余为你保存文件, 其追加到您的字符串$ stylestr.

它可能看起来复杂. 好, 我想这是一个有点复杂, 但一旦你实现它,并让它运行, 您可以 (做) 忘掉它. 至少, 我做的. 这就是为什么我张贴在这里, 因此,在未来的时间,我需要做的, 我可以看看它.

Geeks

I have been doing a bit of geeky stuff lately — writing WordPress插件. 好, it is because I’m suffering from a terrible writer’s block.

你看, I’m supposed to be working on my next book. I foolishly promised a couple of chapters of 定量发展的原则 to my commissioning editor at John Wiley & Sons within a month; now I find myself writing everything other than those darned chapters! Including plugins. 未来想起来, writing those chapters wouldn’t be any less geeky, 它会?

That made me wonder… We all started off as geeks, didn’t we? No use denying it. Remember how our teachers loved us, and the sexy cheerleaders, 好, didn’t? Later in life, due to exigencies of circumstances, we may have tried to lose our techie halo and simulate a managerial posture. 但, in our moments of panic, we go back to our geek roots. 至少, 我做的.

You think you don’t? 好, check out these geek jokes. If you find them funny, chances are your roots are not too different from mine.

Heisenberg was driving down the highway when he was pulled over for speeding. The officer says, “Do you know how fast you were going?” Heisenberg says, “别, but I do know where I am!”

Two Hydrogen atoms walk into a bar. One says, “I’ve lost my electron!” The other says, “Are you sure?” The first replies, “是的, I’m positive…”

Geek Pickup Lines:

  • Tell me of this thing you humans call [dramatic pause] love.
  • If you turn me down now, I will become more drunk than you can possibly imagine.
  • They don’t call me Bones because I’m a doctor.
  • Your name is Leslie? 看, I can spell your name on my calculator!
  • What’s a nice girl like you doing in a wretched hive of scum and villainy like this?
  • You must be Windows 95 because you got me so unstable.
  • My ‘up-time’ is better than BSD.
  • I can tell by your emoticons that you’re looking for some company.
  • Is that an iPod mini in your pocket or are you just happy to see me.
  • Want to see my Red Hat?
  • If you won’t let me buy you a drink, at least let me fix your laptop.
  • You had me at “Hello World.”
  • Mind if I run a sniffer to see if your ports are open?
  • You make me want to upgrade my Tivo.
  • By looking at you I can tell you’re 36-25-36, which by the way are all perfect squares.
  • Jedi Mind Trick: “This is the geek you’re looking for.” [Waves hand]
  • You can put a Trojan on my Hard Drive anytime.
  • Have you ever Googled yourself?
  • How about we do a little peer-to-peer saliva swapping?
  • With my IQ and your body we could begin a race of genetic superchildren to conquer the earth.
  • What’s a girl like you doing in a place like this when there’s a Farscape marathon on right now on the Sci Fi channel.
  • I’m attracted to you so strongly, scientists will have to develop a fifth fundamental force.

What Makes 100%?

What does it mean to give MORE than 100%? Ever wonder about those people who say they are giving more than 100%? We have all been to those meetings where someone wants you to give over 100%. How about achieving 103%? What makes up 100% in life? Here’s a little mathematical formula that might help you answer these questions:

如果:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z are represented as:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

then H-A-R-D-W-O-R-K = 8+1+18+4+23+15+18+11 = 98%

and K-N-O-W-L-E-D-G-E = 11+14+15+23+12+5+4+7+5 = 96%

but A-T-T-I-T-U-D-E = 1+20+20+9+20+21+4+5 = 100%

and B-U-L-L-S-H-I-T = 2+21+12+12+19+8+9+20 = 103%

but look how far ass kissing will take you.

A-S-S-K-I-S-S-I-N-G = 1+19+19+11+9+19+19+9+14+7 = 118%

所以, one can conclude with mathematical certainty that While Hard work and Knowledge will get you close, and Attitude will get you there, it’s the Bullshit and Ass kissing that will put you over the top.