Title: Text Modules
Author: Thorsten Frommen
Published: <strong>2015 年 7 月 24 日</strong>
Last modified: 2015 年 8 月 20 日

---

搜尋外掛

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

![](https://ps.w.org/text-modules/assets/icon-256x256.png?rev=1205728)

# Text Modules

 由 [Thorsten Frommen](https://profiles.wordpress.org/tfrommen/) 開發

[下載](https://downloads.wordpress.org/plugin/text-modules.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/text-modules/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/text-modules/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/text-modules/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/text-modules/#developers)

 [技術支援](https://wordpress.org/support/plugin/text-modules/)

## 外掛說明

**Use the new Text Modules custom post type and display a text module by either 
shortcode or widget.**

Have you ever wanted to use some pieces of text information more than once? For 
instance, contact information such as a postal address? Or some slogan, motto or
claim?

This is exactly when _Text Modules_ kicks in.

#### Usage

This plugin registers a simple post type for text modules. A text module can be 
accessed either via shortcode (by means of the text module’s ID or slug) or via 
a new Tex Modules widget.

**Filters**

In order to customize certain aspects of the plugin, it provides you with several
filters. For each of these, a short description as well as a code example on how
to alter the default behavior is given below. Just put the according code snippet
in your theme’s `functions.php` file or your _customization_ plugin, or to some 
other appropriate place.

**`text_modules_after_widget_content`**

This filter lets you alter the HTML after the widget content.

    ```
    /**
     * Filter the HTML after the widget content.
     *
     * @param string $after_widget_content Some HTML after the widget content.
     */
    add_filter( 'text_modules_after_widget_content', function() {

        return '<!-- End of Text Modules widget content -->';
    } );
    ```

**`text_modules_before_widget_content`**

This filter lets you alter the HTML before the widget content.

    ```
    /**
     * Filter the HTML before the widget content.
     *
     * @param string $before_widget_content Some HTML before the widget content.
     */
    add_filter( 'text_modules_before_widget_content', function() {

        return '<!-- Start of Text Modules widget content -->';
    } );
    ```

**`text_modules_post_type`**

Yes, you can alter the post type (slug).

    ```
    /**
     * Filter the post type.
     *
     * @param string $post_type Post type.
     */
    add_filter( 'text_modules_post_type', function() {

        return 'exotic_stuff';
    } );
    ```

**`text_modules_post_type_args`**

If you want to alter a specific post type argument but you can’t find a fitting 
filter, there’s `text_modules_post_type_args`, which provides you with the complete
args array.

    ```
    /**
     * Filter the post type args.
     *
     * @param array $args Post type args.
     */
    add_filter( 'text_modules_post_type_args', function( $args ) {

        // Use hierarchical external content
        $args[ 'hierarchical' ] = TRUE;

        return $args;
    } );
    ```

**`text_modules_post_type_description`**

The post type description can be customized by using the `text_modules_post_type_description`
filter.

    ```
    /**
     * Filter the post type description.
     *
     * @param string $description Post type description.
     */
    add_filter( 'text_modules_post_type_description', function() {

        // Provide a description
        return 'Simple post type for text modules.';
    } );
    ```

**`text_modules_post_type_labels`**

In case you don’t like the labels, easily adapt them to your liking.

    ```
    /**
     * Filter the post type labels.
     *
     * @param array $labels Post type labels.
     */
    add_filter( 'text_modules_post_type_labels', function( $labels ) {

        // A little more horror, please...
        $labels[ 'not_found' ] = 'ZOMG, no text module found!!1!!1!!oneone!!!1!eleven!1!';

        return $labels;
    } );
    ```

**`text_modules_post_type_supports`**

This filter provides you with the post type supports.

    ```
    /**
     * Filter the post type supports.
     *
     * @param array $supports Post type supports.
     */
    add_filter( 'text_modules_post_type_supports', function( $supports ) {

        // Let's add revisions for our post type
        if ( ! in_array( 'revisions', $supports ) ) {
            $supports[] = 'revisions';
        }

        return $supports;
    } );
    ```

**`text_modules_shortcode_apply_do_shortcode`**

By default, do_shortcode() will be called on the shortcode output. Of course, you
can change that.

    ```
    /**
     * Filter if the shortcode should apply do_shortcode() to the output.
     *
     * @param bool $do_shortcode Should the shortcode apply do_shortcode()?
     */
    add_filter( 'text_modules_shortcode_apply_do_shortcode', '__return_false' );
    ```

**`text_modules_shortcode_callback`**

In case you would like to adapt how the shortcode data is handled, you can provide
your own shortcode callback. This can either be a string holding the function name,
or an array with either a class name or an object, and the according method.

    ```
    /**
     * Filter the shortcode callback.
     *
     * @param array|string $callback Shortcode callback.
     */
    add_filter( 'text_modules_shortcode_callback', function() {

        return 'my_text_modules_shortcode_callback';
    } );
    ```

**`text_modules_shortcode_id_attribute_name`**

This filter lets you alter the shortcode’s ‘id’ attribute name.

    ```
    /**
     * Filter the 'id' shortcode attribute name.
     *
     * @param string $name Attribute name.
     */
    add_filter( 'text_modules_shortcode_id_attribute_name', function() {

        return 'post_id';
    } );
    ```

**`text_modules_shortcode_output`**

This filter lets you alter the shortcode output. The second parameter holds the 
shortcode attributes array.

    ```
    /**
     * Filter the shortcode output.
     *
     * @param string $output Shortcode output.
     * @param array  $atts   Shortcode attributes array.
     */
    add_filter( 'text_modules_shortcode_output', function( $output ) {

        return $output . ' Over and out.';
    } );
    ```

**`text_modules_shortcode_query_args`**

Also, there’s `text_modules_shortcode_query_args`, which provides you with the complete
args array for the shortcode’s query.

    ```
    /**
     * Filter the shortcode query args.
     *
     * @param array $args Shortcode query args.
     */
    add_filter( 'text_modules_shortcode_query_args', function( $args ) {

        // Exclude some text modules by ID
        $args[ 'post__not_in' ] = array( 4, 8, 15, 16, 23, 42 );

        return $args;
    } );
    ```

**`text_modules_shortcode_slug_attribute_name`**

This filter lets you alter the shortcode’s ‘slug’ attribute name.

    ```
    /**
     * Filter the 'slug' shortcode attribute name.
     *
     * @param string $name Attribute name.
     */
    add_filter( 'text_modules_shortcode_slug_attribute_name', function() {

        return 'post_slug';
    } );
    ```

**`text_modules_shortcode_tag`**

This filter lets you alter the shortcode’s tag.

    ```
    /**
     * Filter the shortcode tag.
     *
     * @param string $shortcode_tag Shortcode tag.
     */
    add_filter( 'text_modules_shortcode_tag', function() {

        return 'text_block';
    } );
    ```

**`text_modules_shortcode_use_slug`**

By default, text modules are being queried by their post ID first. Of course, you
can change that and use the post slug instead.

    ```
    /**
     * Filter if the shortcode (query) should use the post slug instead of the post ID.
     *
     * @param bool $use_slug Use slug instead of ID?
     */
    add_filter( 'text_modules_shortcode_use_slug', '__return_true' );
    ```

**`text_modules_widget_form_query_args`**

Also, there’s `text_modules_widget_form_query_args`, which provides you with the
complete args array for the widget form’s query.

    ```
    /**
     * Filter the widget form query args.
     *
     * @param array $args Query args.
     */
    add_filter( 'text_modules_widget_form_query_args', function( $args ) {

        // Exclude some text modules by ID
        $args[ 'post__not_in' ] = array( 4, 8, 15, 16, 23, 42 );

        return $args;
    } );
    ```

#### Contribution

To **contribute** to this plugin, please see its [**GitHub repository**](https://github.com/tfrommen/text-modules).

If you have a feature request, or if you have developed the feature already, please
feel free to use the Issues and/or Pull Requests section.

Of course, you can also provide me with translations if you would like to use the
plugin in another not yet included language.

## 螢幕擷圖

 * [[
 * **List table** – Here you can see all text modules together with their individual
   slug and shortcode.
 * [[
 * **Meta box** – Here you can see the currently edited text module’s shortcode.
 * [[
 * **Widget** – Use any text module in a Text Module widget.

## 安裝方式

This plugin requires PHP 5.3.

 1. Upload the `text-modules` folder to the `/wp-content/plugins/` directory on your
    web server.
 2. Activate the plugin through the _Plugins_ menu in WordPress.
 3. Find the new _Text Modules_ menu in your WordPress backend.

## 使用者評論

![](https://secure.gravatar.com/avatar/4af1edbc8af2cf14762254c2c563926006141c3ab513681fe86b0bfb42a8b830?
s=60&d=retro&r=g)

### 󠀁[Perfect for content organization!](https://wordpress.org/support/topic/perfect-for-content-organization/)󠁿

 [vynnus](https://profiles.wordpress.org/vynnus/) 2016 年 10 月 4 日 1 則留言

I was used to other CMS which had similar module. Having found this plugin made 
the transition from the old CMS less painful 🙂 Thank you for this one!

 [ 閱讀全部 1 則使用者評論 ](https://wordpress.org/support/plugin/text-modules/reviews/)

## 參與者及開發者

以下人員參與了開源軟體〈Text Modules〉的開發相關工作。

參與者

 *   [ Thorsten Frommen ](https://profiles.wordpress.org/tfrommen/)
 *   [ Thorsten Frommen ](https://profiles.wordpress.org/ipm-frommen/)

[將〈Text Modules〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/text-modules)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/text-modules/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/text-modules/)，或透過 [RSS](https://plugins.trac.wordpress.org/log/text-modules/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/text-modules/)。

## 變更記錄

#### 1.0.1

 * Escape translated strings.
 * Improve namespace imports.
 * Compatible up to WordPress 4.2.4.

#### 1.0.0

 * Initial release.
 * wordpress.org release.
 * Compatible up to WordPress 4.2.3.

## 中繼資料

 *  版本 **1.0.1**
 *  最後更新 **11 年前**
 *  啟用安裝數 **40+**
 *  WordPress 版本需求 ** 3.0.0 或更新版本 **
 *  已測試相容的 WordPress 版本 **4.3.34**
 *  語言
 * [English (US)](https://wordpress.org/plugins/text-modules/)
 * 標籤:
 * [custom post type](https://tw.wordpress.org/plugins/tags/custom-post-type/)[module](https://tw.wordpress.org/plugins/tags/module/)
   [modules](https://tw.wordpress.org/plugins/tags/modules/)[post](https://tw.wordpress.org/plugins/tags/post/)
   [text](https://tw.wordpress.org/plugins/tags/text/)
 *  [進階檢視](https://tw.wordpress.org/plugins/text-modules/advanced/)

## 評分

 5 星，滿分為 5 星

 *  [  1 個 5 星使用者評論     ](https://wordpress.org/support/plugin/text-modules/reviews/?filter=5)
 *  [  0 個 4 星使用者評論     ](https://wordpress.org/support/plugin/text-modules/reviews/?filter=4)
 *  [  0 個 3 星使用者評論     ](https://wordpress.org/support/plugin/text-modules/reviews/?filter=3)
 *  [  0 個 2 星使用者評論     ](https://wordpress.org/support/plugin/text-modules/reviews/?filter=2)
 *  [  0 個 1 星使用者評論     ](https://wordpress.org/support/plugin/text-modules/reviews/?filter=1)

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

[查看全部使用者評論](https://wordpress.org/support/plugin/text-modules/reviews/)

## 參與者

 *   [ Thorsten Frommen ](https://profiles.wordpress.org/tfrommen/)
 *   [ Thorsten Frommen ](https://profiles.wordpress.org/ipm-frommen/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/text-modules/)

## 贊助

想要支援這個外掛的發展嗎？

 [ 贊助這個外掛 ](http://ipm-frommen.de/wordpress)