Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
requests-topic
Adding hyperlinks to Profanity Filter replacement words
Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Nov 23, 2012 - 8:09 pm

Just tested the Profanity Filter plugin and it works like a charm, thanks! Just have a special request...

It would be just dandy if we could replace specific keywords or phrases with hyperlinked text. I tried doing this and the filter stripped out the href tag I added to the replacement word. I understand this may be difficult, or perhaps impossible, but consider this scenario, in our canine amputation support forums:

Member A posts about a helpful "ruffware harness" they found on our site.

Member B wants more info about product, but member A provided no link, and spelled the item name wrong making searching difficult.

We create Profanity filter to replace "ruffware harness" with Ruff Wear harness, link and all.

Any thoughts? Thank you for your consideration.

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Nov 23, 2012 - 9:18 pm

hmmm... sounds like a different plugin to me... though I can understand why you are trying to use the existing one... ;)

but still think an auto hyperlinking plugin might not be a bad idea... can open a ticket to make note of this...

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Nov 23, 2012 - 9:26 pm

Thumb's up for auto-hyperlinking plugin! Just thought I'd give the filter a try to see if it passed tags since correcting spelling at the same time would be a big plus.

Thanks!

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Nov 23, 2012 - 11:32 pm

If you want, you could try editing the plugin...  sp-profantiy-filter-admin-options-save.php... around line 12 change

    $filter['replacementwords'] = sp_esc_regex(sp_filter_title_save(trim($_POST['replacementwords']), false));

to

    $filter['replacementwords'] = sp_esc_regex(sp_filter_save_kses(trim($_POST['replacementwords']), false));

and then in sp-profanity-filter-components.php around line 36 change

    $content = sp_filter_display_stripslashes($content);

to

    $content = esc_html($content);

that is completely untested and possible the html will throw off the regex, but worth a try...

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Nov 24, 2012 - 10:51 am

Thanks for the valiant attempt!

Filter content settings on admin pane saved without issue when including hyperlink tag, but interesting behavior when loading topic or adding new post...

Loading topic with existing keywords replaced by filter resulted in "Invalid Database Query", and testing filter resulted in various issues:

  • odd slash-stripping behavior for URLs.
  • <p> tags being added to all posts in topic
  • and Polls conflict with shortcodes rendering as "Poll ID invalid"

FYI Only, happy to wait for and help test any new plugin development.

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Nov 24, 2012 - 11:09 am

yeah was afraid the regex might not like that...  okay, yeah, will need to wait until I can dig into... will be post 5.2 which is couple weeks away...

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Nov 24, 2012 - 4:42 pm

Hey, Jim...  why not give this early, pre-release plugin in a shot and see if it does what you want... ;)

 

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Nov 25, 2012 - 12:31 pm

Sweet! Thought you were busy with 5.2?

Anyway... seems to work like a charm so far. Still trying to find fault.

Been testing it in conjunction with the Profanity Filter to correct spellings and add links at same time. Only identified one issue so far:

The Profanity Filter is replacing words on the Auto-Link admin pane. But while the keyword on the left does get replaced, the link still gets added to the original word in posts. So, for example, by adding links to various spellings of the same keywords, the words get replaced but the link gets added. In this case, words in a post get replaced (is also added to PF) and a link added, so it's mainly a visual thing.

Thanks for working on this! Will report back with any other issues I might find.

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Nov 25, 2012 - 12:54 pm

not sure I understand the interaction with profanity filter you are referring to...  can you explain further?  are you replacing the same word with both plugins?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Nov 25, 2012 - 1:10 pm

which do you want to run first?

find this line in the auto link plugin main file:

add_filter('sph_display_post_content_filter',     'sp_autolink_filter');

and change it to

add_filter('sph_display_post_content_filter',     'sp_autolink_filter', xx);

replace xx with 20 if you want profanity to run first... or replace xx with 7 if you want autolink to run first...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626