Global, network-wide shortcodes or text replace functions

What I’m trying to achieve is a simple textreplace functions, that would be available to any site in my WordPress Network. Basically I want to:

  1. Change [--] into — (—),

  2. Be able to link to my own posts using only their titles — [internallink post=title] or anything similar.

I found simple example of solving this using shortcodes. But I don’t know, where to put my custom shortcodes definition, so it would be available to any site in my WordPress Network.

I’m always looking into solutions as simple as possible, so I would like to know, if I have to use shortcodes to solve these two tasks or:

  1. Is there an easy way to define global search & replace mechanism, so any occurence of just -- would be changed to — in any post or page on any site in the network?

  2. Is there anyway to define global shortcode function, that would convert any [post title] into link poiting to post titled “Post Title”?

Thank you in advance for any help here?

Solutions Collecting From Web of "Global, network-wide shortcodes or text replace functions"

To have a Network enabled shortcode, you only need a Must Use plugin. Just create the folder /wp-content/mu-plugins and drop your code there. From the Codex:

  • Always-on, no need to enable via admin and users cannot disable by accident.
  • Can be enabled simply by uploading file to the mu-plugins directory, without having to log-in.
  • Loaded by PHP, in alphabetical order, before normal plugins, meaning API hooks added in an mu-plugin apply to all other plugins
    even if they run hooked-functions in the global namespace.

The search and replace issue seems a bit more sensitive and maybe this plugin can be of use: Search and Replace and do it only in the post_content field. You can also use the filter the_content, search this site for various examples on how to deal with it.