I added a shortcode for preg_replace to my SHORTcURL Plugin

Now, with a shortcode for the single most powerful PHP function there is (preg_replace), I dare to imagine that there is nothing that this simple plugin cannot do.

If you know what this amazing function, preg_replace, is capable of then put it to the test.

Here is an example of the syntax for the new new shortcode that calls preg_replace:

[preg_replace replace=”/to be searched/” with=”I replaced”]<li>The content to be searched</li>[/preg_replace]

and this is what you get:

  • The content I replaced
  • 15 thoughts on “I added a shortcode for preg_replace to my SHORTcURL Plugin

    1. Hello,

      How do I replace html tags?

      e.g. [preg_replace replace="" with=""][/preg_replace] doesn’t work. I know my syntax is probably not correct. Could you tell me how to “escape” the syntax so that I obtain the correct function? Thanks!

    2. Love the plugin, it fits my needs almost perfectly. I’m trying to retrieve an image from sharefiles like this.

      [remote_get url="http://www.shareimages.com/image.php?75704-pJOhl5SglpynlpyYng-il_spectroman.jpg"] it works, but it brings in the full page, with adverts, is there a way just to get the image?

        • Thanks so much, I tried that and it worked, well it still left a little underneath, but far better than it was, so thanks again :)

          • No, I don’t think so, because the featured images are set in the database not in the dynamic code. But maybe you could hack you theme to call the shortcurl function in place of displaying the featured image, that would depend on your theme and your PHP skills ;-)

    3. Hi,

      I constantly ge the following error messages for all (4) durles sites, shown in WP Dashboard:

      11-24 21:18: /wp-admin/post.php
      SHORTCURL ERROR: wp_remote_get returned Array ( [ERROR] => WP_Error Object ( [errors] => Array ( [http_request_failed] => Array ( [0] => cURL error 28: Connection timed out after 10000 milliseconds ) ) [error_data] => Array ( ) ) )

      any idea whats wrong or what I’m doing wrong?

      Regards
      Fiaskogaul

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.