Title: WP SoftLinks
Author: SwiftWeb
Published: <strong>2014 年 6 月 13 日</strong>
Last modified: 2014 年 6 月 13 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://s.w.org/plugins/geopattern-icon/wp-softlinks.svg)

# WP SoftLinks

 作者：[SwiftWeb](https://profiles.wordpress.org/swiftweb/)

[下载](https://downloads.wordpress.org/plugin/wp-softlinks.1.0.1.zip)

 * [详情](https://cn.wordpress.org/plugins/wp-softlinks/#description)
 * [评价](https://cn.wordpress.org/plugins/wp-softlinks/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/wp-softlinks/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/wp-softlinks/#developers)

 [支持](https://wordpress.org/support/plugin/wp-softlinks/)

## 描述

We were tired to alter every link and image in posts, pages or widgets when switching
from development to live environments.

e.g. when you insert an image in TinyMCE on your development environment (`http://
dev.example.com`), the image has a hard URL: `http://dev.example.com/media/2014/
06/example.jpg`
 When switching to your live environment (`http://live.example.com`),
you change your WordPress Site URL, but the image in the content is still `http://
dev.example.com/media/2014/06/example.jpg`. This is very frustrating, you have to
alter each page, post, widget etcetera…

This plugin solves that problem. It automatically adds a data-wp-id tag when you
insert an image or link in your TinyMCE.
 The data-wp-id tag contains a unique ID
from the wp-post table in WordPress.

When displaying the content on the front-end this plugin automatically recognizes
the data-wp-id tag and replaces the `src=""` and `href=""` with the correct permalink.

You can use the tag anywhere you want, simply add the `data-wp-id="123"` (where `
123` is the ID).

#### So, how does it work?

The plugin automatically adds the data-wp-id when inserting an image or link in 
the WordPress editor.

**Normally, when you insert an image into the WP editor, WordPress would generate
image tags like this:**

> `<img src="http://dev.example.com/media/2014/05/example-150x150.jpg" class="size-
> thumbnail" width="150" height="150" />`

**But this Plugin will generate a link like this:**

> `<img data-wp-id="123" src="#" class="size-thumbnail" width="150" height="150"/
> >`

**… And finally on the Front-End, the Plugin will output is as:**

> `<img src="http://live.example.com/media/2014/05/example-150x150.jpg" class="size-
> thumbnail" width="150" height="150" />`

Another example, adding a link:

**Normally WordPress will generate a link like this:**

> `<a href="http://dev.example.com/example-page" target="_blank" />`

**But this Plugin will generate it like this:**

> `<a data-wp-id="100" href="#" target="_blank" />`

**…And finally on the Front-End, the Plugin will output it as:**

> `<a href="http://live.example.com/example-page" target="_blank" />`

## 屏幕截图

 * [[
 * An example how a link works with the data-wp-id
 * [[
 * An example how an image works with the data-wp-id
 * [[
 * The image remains intact in the editor
 * [[
 * The link modal contains an ID field

## 安装

 1. Upload the `wp-softlinks` folder to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. Place `data-wp-id="1234"` in any HTML tag of your choice.

## 常见问题

  How does it work?

The plugin has a hook on the_content that parses the content. Every HTML tag that
contains a data-wp-id, will be converted in a perfect link or source.

  How does it work under the hood?

The plugin uses the DOMDocument Class in PHP to parse the HTML. Tags will be replaced
and removed, and clean HTML will be outputted. So no Javascript or whatsoever.

  Do I have to add the data-wp-id tag manually?

You can, but it will be inserted automatically by the Plugin, when inserting an 
Image or Link in the WordPress editor.

  Can you give me an example?

Sure, you add a data-wp-id to an image: `<img src="#" data-wp-id="24" class="size-
thumbnail" />`, it will be converted to a clean URL: `<img src="http://www.example.
com/media/2014/05/example-150x150.jpg" class="size-thumbnail" />`

  Can I use this with HTTPS?

Yes, because the plugin uses the WordPress Site URL to generate a link.

  Can I use it with any HTML tag?

Sure, you can use any HTML tag, and it recognizes automatically if the tag needs
a `src=""` or `href=""`

  How does it work with image sizes?

WordPress adds a class to any image size (e.g. size-thumbnail). The plugin recognizes
this class and will return the correct link.

  Can I use it in my plugins and themes?

Currently not, but we are working on that.

## 评价

此插件暂无评价。

## 贡献者及开发者

「WP SoftLinks」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ SwiftWeb ](https://profiles.wordpress.org/swiftweb/)

[帮助将「WP SoftLinks」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/wp-softlinks)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/wp-softlinks/)，查看
[SVN仓库](https://plugins.svn.wordpress.org/wp-softlinks/)，或通过[RSS](https://plugins.trac.wordpress.org/log/wp-softlinks/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/wp-softlinks/)。

## 更新日志

#### 1.0.1

Fixed screenshots, improved readme.txt

#### 1.0

Fixed data-wp-id tag in stead of shortcode.

## 额外信息

 *  版本 **1.0.1**
 *  最后更新：**12 年前**
 *  活跃安装数量 **10+**
 *  WordPress 版本 ** 3.6 或更高版本 **
 *  已测试的最高版本为 **3.9.40**
 *  语言
 * [English (US)](https://wordpress.org/plugins/wp-softlinks/)
 * 标签
 * [tinyMCE](https://cn.wordpress.org/plugins/tags/tinymce/)
 *  [高级视图](https://cn.wordpress.org/plugins/wp-softlinks/advanced/)

## 评级

 5 星（最高 5 星）。

 *  [  2 条 5 星评价     ](https://wordpress.org/support/plugin/wp-softlinks/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/wp-softlinks/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/wp-softlinks/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/wp-softlinks/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/wp-softlinks/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/wp-softlinks/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/wp-softlinks/reviews/)

## 贡献者

 *   [ SwiftWeb ](https://profiles.wordpress.org/swiftweb/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/wp-softlinks/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](http://www.swiftweb.nl/)