Tag Archives: WordPress

Allow WordPress Embedded Posts with Global X-Frame-Options for Nginx Servers

The problem: when you enables X-Frame-Options globally. You won’t be able to embed your posts with latest WordPress embed posts method.

The solution: you can simply exclude it in your Nginx configuration. I’ll use Nginx map for better performance:

map $request_uri $x_frame_options_headers {
  default                 SAMEORIGIN;
  # Matching WordPress embed page, ie. https://example.com/my-post/embed#?secret=vLi4CQcWkH
  ~/embed                 "";

# Don't allow the browser to render the page inside an frame or iframe
add_header X-Frame-Options $x_frame_options_headers;
Embedding Demo

Using git-svn to Update WordPress Plugin from GitHub, Syncing to WordPress.org Repository

# Get earliest commit on WordPress repo
svn log -r 1:HEAD –limit 1 https://plugins.trac.wordpress.org/log/plugin-name
# Clone a git repo from WordPress
git svn clone -s -r599654 –no-minimize-url –prefix=origin/ http://plugins.svn.wordpress.org/plugin-name/
cd plugin-name
git svn fetch
git svn rebase
# Add GitHub remote repo
git remote add origin [email protected]:user/plugin-name.git
git push origin master
# After editing files
git add –all
git commit -am "Edited files"
git tag v2.0.0
git push -u origin master –tags
# Push to WordPress repo, it may take long
git svn rebase
git svn dcommit
# Tagging new release if necessary
git svn tag "2.0.0"
# Need to edit files again on git repo? rebase first
git rebase


禁用 global_terms_enabled 以允许 WordPress Mutisite 用户编辑 category slug 与 tag slug

方法一,编辑数据库 wp_sitemeta 表中的 global_terms_enabled,将值设置为 0


// disable global terms to make category, link_category, and tag slugs editable
// you can also set global_terms_enabled value to 0 on wp_sitemeta table
function disable_global_terms($enablefalse) {
   return 0;
add_filter( 'global_terms_enabled', 'disable_global_terms' );

Postfix 发送邮件至本地报错 status=bounced (unknown user: “***”) 的解决办法

有时候如果你需要发送的邮件与本机 hostname 相同时(例如 WordPress 帐号需要重置密码),但发现无法收到邮件,那么你打开 log 可能会发现这样的问题

postfix/local[19499]: B2E312E701: to=, relay=local, delay=0.05, delays=0.03/0.01/0/0.01, dsn=5.1.1, status=bounced (unknown user: "usr")

一个简单的办法是修改 Postfix 的 main.cf 配置文件,将 mydestination 设置为空

mydestination = 


postfix/smtp[19838]: 68C072E701: to=, relay=aspmx.l.google.com[]:25, delay=1.4, delays=0.03/0.01/0.29/1.1, dsn=2.0.0, status=sent (250 2.0.0 OK 1335520194 t9si6294951pbj.252)

让 SyntaxHighlighter Evolved 变好看的 CSS

凡是用 WordPress 贴代码的基本都会用 SyntaxHighlighter Evolved 插件,因为 wordpress.com 就在用,但凡是用了 SyntaxHighlighter Evolved 的样子都奇丑无比,让人恶心,下面提供一下本站使用的 CSS 样式,让你的代码可以瞬间从无数没有审美的程序猿中脱颖而出

.code .container {
  font-size: 14px !important;
  padding: 15px !important;

.code .container code {
  font-family: "Lucida Console", Monaco, monospace !important;

.syntaxhighlighter table td.code .line {
  padding: 2px 1em !important;