Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter innerlooping

    (@innerlooping)

    Is this more difficult than it seems? The reason I’d like to do this, is so that every page opens with greybox.

    When asking for help in modifying an existing plugin, some good steps to take are:

    1. Contact the plugin’s developer to see if he or she will provide the mod. Speaking as one of those plugin devs, I often provide updates to mine based on requests (that make sense to me).

    2. If [1] leads nowhere, a link to the plugin would be nice for those who *might* be able to help but have no knowledge of the plugin.

    3. Better yet, if you know where in the plugin’s code the change you want to make needs to occur, you could post a fragment of the plugin’s source code on a pastebin site like:

    https://wordpress.pastebin.ca

    and link to that in your request.

    4. Keep in mind that not everyone here knows PHP or can write (or rewrite) a WordPress plugin. And for those who can, some may be reticent to play around with another developer’s code.

    Thread Starter innerlooping

    (@innerlooping)

    My apologies for an ill-formed post.

    1. I have not received a response from the plugin developer yet, though I have submitted the request.

    2. The plugin page can be found here: https://www.coffee2code.com/archives/2004/07/08/plugin-auto-hyperlink-urls/

    3. I’m not familiar with PHP so I can’t pinpoint the location that should be altered, though a link to the code snippet can be found here: https://wordpress.pastebin.ca/316585

    4. Understood. Any help would be greatly appreciated.

    Ah, one of Scott’s plugins. I’ve got no problem flipping his stuff. ;)

    You don’t mention what the “specific ‘rel=’ attribute” is, but if you just want to make a static change to all links, you only need slip it into the <a> tag that appears in each of the preg_replace() lines. For example, you’ll find this in the first preg_replace():

    '$1<a href=\"https://$2.$3$4\" title=\"https://$2.$3$4\"$new_win_txt>'

    Just modify it like so:

    '$1<a href=\"https://$2.$3$4\" rel=\"value\" title=\"https://$2.$3$4\"$new_win_txt>'

    Change ‘value’ to the rel attribute value you want to use. Then do the same for the other two instances of preg_replace(), inserting the rel between the href and title attributes that already exist in them.

    Take note of how the double-quote marks both in the addition of the rel and other attributes are escaped out. It’s a PHP thing which allows the use of quotes within similarly quoted string values (double in double, or single in single). So you want to insert:

    rel=\"value\"

    and not:

    rel="value"

    Thread Starter innerlooping

    (@innerlooping)

    works great! thanks very much for the help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding a rel= Attribute to Auto-hyperlink URLs’ is closed to new replies.