个人工具
名字空间
变换
操作

WordPress:How WordPress Processes Post Content

来自站长百科
跳转到: 导航, 搜索

WordPress processes text entered in the Write Post Panel multiple times before the text is finally displayed on a web page within your WordPress blog. The processing of the text filters out the unwanted code and conforms the text to a form that the browser can interpret. Without attention to detail and familiarity with WordPress's post content filtering, this can cause unwanted changes.

WordPress多次处理写文章面板中输入的文本,然后文本才会显示在你的WordPress博客网页上。处理文本,过滤了不必要的代码并且将文本转变为浏览器能够阅读的形式。不注意WordPress文章内容过滤的详细信息,可能导致不必要的变化。

The majority of the conversion and filters are found in the wp-includes/formatting.php file. See the file source code for specific code functions and features.

可以在wp-includes/formatting.php文件中找到大多数conversion 和filters。请看看文件源代码上特别的代码函数和功能。

Come typical problems some users have with these filtering and processing functions are:

WordPress使用这些filtering和processing函数时候,遇到的典型问题是:

  1. Empty paragraphs, closing span tags, and line break (BR) elements are removed upon saving.
  1. 在保存的时候,空段落,关闭span标签,和行分隔符(BR)elements得到移除。
  1. Classes are removed from elements.
  1. Classes从elements中移除。
  1. DIV elements are converted to P elements.
  1. DIV elements转变为P elements。
  1. Javascripts and code are converted to displayable code rather than actionable code. See WordPress:Using Javascript for information on how to incorporate Javascript into a blog post.
  1. Javascript和代码转变为可显示的代码而不是可运行的代码。请看看使用Javascript,关于怎样将Javascript合并到博客文章的信息。

The following is step-by-step list of how WordPress processing post content text before the final publish.

下面是WordPress最后发表文章之前,怎样处理文章文本的一步步的介绍。

目录

TinyMCE

TinyMCE

WordPress:TinyMCE is the editor used by WordPress, known as the Rich Text Editor. Not all WordPress bloggers use it, but if you do, it will change various codes upon saving an entry to prepare it for publishing.

WordPress:TinyMCE是WordPress使用的编辑器,又名为多功能文本编辑器。并不是所有的WordPress博客用户都使用这个编辑器,但是如果你使用这个编辑器,保存文章等待发表的时候,这个编辑器能够更改不同的代码。

wpautop() WordPress Function

wpautop() WordPress 函数

wpautop() is a core WordPress function that automatically processes, fixes, and modifies the text of a post.

wpautop()是核心的WordPress[WordPress:Function_Reference|函数]]能够自动地处理,更改文章文本。

It puts in line breaks, paragraph tags, opens and closes tags that aren't opened and closed, and cleans up duplicate HTML tags.

这个函数放入行分隔符,段落标签,并没有打开或者关闭的,打开和关闭的标签,并且整理了复制的HTML标签。

Texturize

Texturize

Texturize (wptexturize()) is a text filter enabled by default that modifies posted text or comments to present a more readable and visually attractive output.

Texturize (wptexturize())是默认运行的文本编辑器,能够更改已发表的文本或者评论,呈现更易读的并且视觉上更吸引人的文本。

While it creates aesthetically pleasant text, it might create difficulties when posting code examples in a programming language. In such situations modification of the text is not desirable because it might create syntactically incorrect code.

虽然这个编辑器能够创建美观的文本,但是在程序语言中发表代表的时候,可能会出现问题。在这种情况下,更改文本并不必要,因为这样可能会产生语法上错误的代码。

A few examples include: 一些例子包括:

"quoted text" becomes “quoted text”
'quoted text' becomes ’quoted text’
          --- becomes —
           -- becomes –
          ... becomes …
          (c) becomes ©
          (r) becomes ®
         (tm) becomes ™
           '' becomes ”
           `` becomes “
  president's becomes president’s
  presidents' becomes presidents’
          12' becomes 12′
          12" becomes 12″
          2x4 becomes 2×4











"quoted text" becomes “quoted text”
'quoted text' becomes ’quoted text’
          --- becomes —
           -- becomes –
          ... becomes …
          (c) becomes ©
          (r) becomes ®
         (tm) becomes ™
           '' becomes ”
           `` becomes “
  president's becomes president’s
  presidents' becomes presidents’
          12' becomes 12′
          12" becomes 12″
          2x4 becomes 2×4



Convert Smilies

转变 Smilies

The convert_smilies() function converts combinations of characters into smilies or emoticons within the post, page, and comment text. For example, if smilies are enabled, WordPress will recognize :D and turn it into a smiling face.

convert_smilies()函数将字符集转变为文章,网页,或者评论文本中的smilies 或者emoticons。例如,如果激活了smilies,WordPress就能够读懂:D,并且将这个字符,转变为笑脸。

The key to making smilies work is to create a space before and after the keystroke combination. If place up against the text, it will not convert.

使得smilies运行的关键在于,在一次按多个键之前之后,创建空格。如果放置在文本旁边,之间没有空格,字符就不能够转变为smilies。 If conversion of smilies is not desired, turn it off through the Options > Writing panel.

如果不需要转变smilies,可以通过选项 > 写面板,关闭smilies。

Convert Characters

转变字符

The formatting.php code file contains numerous functions which help publish character entities, accents, and non-English characters to a form recognizable by the web browser.

formatting.php代码文件包含许多函数,能够帮助发表字符实体,重音符,非英语字符,形成网络浏览器能够识别的格式。

Generally, these work excellently, however, your browser may not recognize various language characters unless that language is activated in your web browser. See your browser's documentation for more information on adding language character recognition to your browser.

一般来说,这些能够很好地运行,但是除非你的网络浏览器中激活了不同的语言,否则,浏览器可能不能够识别不同的语言字符。更多关于向浏览器添加语言字符的信息,请看看你的浏览器的文档。

Methods to Prevent Processing

阻止处理过程的方法

There are a variety of Plugins to change the filtering process WordPress uses by default. It is highly recommended that you do not change the core programming but use WordPress Plugins to change all or some of the content processing. See the WordPress Plugins Directory for various Plugins that change the post content filtering process.

有许多插件,可以更改WordPress默认使用的filtering 处理过程。强烈建议你不要更改核心程序,而是使用WordPress插件,更改所有的或者一些内容处理过程。请看看WordPress 插件目录更改文章内容过滤过程的不同的插件。

More Information

更多的信息



留言