Linux 软件免费装
Banner图

Linkify Text

开发者 coffee2code
更新时间 2018年7月20日 14:06
捐献地址: 去捐款
PHP版本: 4.7 及以上
WordPress版本: 4.9
版权: GPLv2 or later
版权网址: 版权信息

标签

post link text shortcut shortcuts post content coffee2code replace autolink hyperlink

下载

1.0 1.5 1.6 1.7 1.8 1.9 1.9.1

详情介绍:

This plugin allows you to define words or phrases that, whenever they appear in your posts or pages, get automatically linked to the URLs of your choosing. For instance, wherever you may mention the word "WordPress", that can get automatically linked as "WordPress". Additional features of the plugin controlled via settings and filters: You can also link multiple terms to the same link and only define that link once in the settings via use of a special link syntax. A number of filters exist to programmatically customize the behavior of the plugin, all of which are documented. Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage

安装:

  1. Install via the built-in WordPress plugin installer. Or download and unzip linkify-text.zip inside the plugins directory for your site (typically wp-content/plugins/)
  2. Activate the plugin through the 'Plugins' admin menu in WordPress
  3. (optional) Go to the Settings -> Linkify Text admin options page and define text and the URLs they should point to

屏幕截图:

  • A screenshot of the admin options page for the plugin, where you define the text and their related links, as well as customize various settings.

升级注意事项:

1.9.1 Minor bugfix release: prevented multibyte functions from being used if not available; prevented conflicts with oembeds. 1.9 Recommended update: added setting to open links in new window; added filter for customizing link attributes; improved performance; allow for linkable text to contain any number of whitespace; updated plugin framework to v048; compatibility is now WP 4.7-4.9; added README.md; more. 1.8 Recommended update: fixed to honor 'replace once' setting, including for multibyte strings; preserved capitalization of linkified text; matched longer strings before shorter strings; added support for language packs; compatibility is now WP 4.1-4.5+ 1.7 Enhancement update: improved support for '&' in text to be linkified; no longer create a link when the link look anything like a URL or filename; minor refactoring; added more unit tests 1.6 Recommended update: prevented linkification of text within shortcodes; added support for linkifying multibyte text; updated plugin framework to version 039; noted compatibility through WP 4.1+; added plugin icon. 1.5 Recommended update: added ability to reference another term's link; added setting to allow limiting linkification to once per term per post; improved validation of data received; added unit tests; noted compatibility through WP 3.8+ 1.0.1 Trivial update: noted compatibility through WP 3.4+; explicitly stated license

常见问题:

Does this plugin modify the post content in the database?

No. The plugin filters post content on-the-fly.

Will this work for posts I wrote prior to installing this plugin?

Yes, if they include terms that you have defined to be linkified.

What post fields get handled by this plugin?

By default, the plugin filters the post content, post excerpt fields, widget text, and optionally comments and comment excerpts. You can use the 'c2c_linkify_text_filters' filter to modify that behavior (see Filters section). There is a setting you can change to make text linkifications apply to comments as well.

Is the plugin case sensitive?

By default, yes. There is a setting you can change to make it case insensitive. Or if you are a coder, you can use the 'c2c_linkify_text_case_sensitive' filter (see Filters section).

What if the word or phrase is already linked in a post?

Already linked text will not get linked again by this plugin (regardless of what the link may be).

Will all instances of a given term be linked in a single post?

By default, yes. There is a setting you can change so that only the first occurrence of the term in the post gets linked. Or if you are a coder, you can use the 'c2c_linkify_text_replace_once' filter (see Filters section).

Is there an efficient way to link multiple terms to the same link without repeating the link in the settings field (which can be tedious and prone to errors)?

Yes. You can reference another term by specifying its link as another term in the list prepended with a colon (':'). For instance: WP => https://wordpress.org, WordPress => :WP dotorg => :WP Given the above terms to link, all terms would link to 'https://wordpress.org'. The latter two all reference the link used for the term "WP". NOTE: The referenced term must have an actual link defined and not be a reference to another term. (Basically, nested references are not currently supported.)

How can I get text linkification to apply for custom fields (or something not linkified by default)?

You can add to the list of filters that get text linkified using something like this (added to your theme's functions.php file, for instance): ` /**

  • Enable text linkification for custom fields.
  • @param array $filters Array of filters that the plugin should hook.
  • @return array */ function more_text_replacements( $filters ) { $filters[] = 'the_meta'; // Here you could put in the name of any filter you want return $filters; } add_filter( 'c2c_linkify_text_filters', 'more_text_replacements' ); `

Can I only have text linkification take place for only a part of a post (such as text inside certain tags, or except for text in certain tags)?

No. The plugin applies fully to the post content. With some non-trivial coding the plugin could be utilized to affect only targeted parts of a post's content, but it's not something that will be built into the plugin.

Can I change how the link gets created because I want to add a 'title' attribute to the link?

Yes, with a bit of code. You can define the title attribute text in your replacement string, like so: WP => https://wordpress.org || This is the link title Now the code: ` /**

  • Force links created by Linkify Text plugin to open in a new tab.
  • @param array $attrs The associative array of attributes to be used for the link.
  • @param string $old_text The text being replaced/linkified.
  • @param string $link_for_text The URL that $old_text is to be linked to.
  • @return array */ function add_title_attribute_to_linkified_text( $attrs, $old_text, $link_for_text ) { // The string that you chose to separate the link URL and the title attribute text. $separator = ' || ';
// Only change the linked text if a title has been defined if ( false !== strpos( $link_for_text, $separator ) ) { // Get the link and title that was defined for the text to be linked. list( $url, $title ) = explode( $separator, $link_for_text, 2 ); // Set the attributes ('href' must be overridden to be a proper URL). $attrs['href'] = $url; $attrs['title'] = $title; } return $attrs; } add_filter( 'c2c_linkify_text_link_attrs', 'add_title_attribute_to_linkified_text', 10, 3 ); `

Can I selectively disable text linkification?

Yes, with some custom code making use of the 'c2c_linkify_text_linked_text' filter. The code should determine if the given text linkification should be disabled, and if so, return the second argument sent via the filter. See the docs for the 'c2c_linkify_text_linked_text' filter for an example of how a custom field could be used to disable all text linkifications on a per-post basis. No doubt your particular situation will require custom logic to determine when to disable linkification.

Does this plugin include unit tests?

Yes.

更新日志:

1.9.1 (2018-07-19) 1.9 (2018-07-05) Highlights: Details: 1.8 (2016-05-16) 1.7 (2015-02-20) 1.6 (2015-02-12) 1.5 (2014-01-04) 1.0.1 (unreleased) 1.0