Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author DZ

    (@dzaikos)

    Here’s the problem, if a WordPress admin is using either the jQuery or Basic embed methods, all the rendering is done on the client/visitor browser. While jQuery could manipulate the HTML to force opening links in a new window, the Basic method could not (because that code is literally controlled by Bible Gateway’s service).

    In the end, this creates an inconsistent user experience for the WordPress admin. One embed method (Cache) would support forcing new tabs/windows, one (jQuery) might, and one (Basic) definitely would not. I’m pretty sure it would create more support inquiries for me and I don’t want that. ??

    You could resolve this by using something like jQuery to intercept all links within the appropriate class (all embed methods wrap the HTML in a class for this type of thing). This would work with all methods but requires JavaScript (shouldn’t be a problem for most users).

    Alternatively, the plugin is filterable. If you’re using the Cache embed method you can just add some code to your theme’s functions.php file and it would add it on the server-side. Something like:

    add_filter( 'dz_biblegateway_json_parsed', function ( $parsed, $json, $filtered ) {
    	$parsed['verse'] = str_replace( '<a href=', '<a target="_blank" href=', $parsed['verse'] );
    
    	return $parsed;
    }, 10, 3 );

    This won’t take effect until the cache is updated (it can be forced to refresh in settings or will update itself in a day). Note the sample code is very basic. It does the job but be aware that future plugin updates might break this… Though you should generally be okay.

    Thread Starter OldClicker

    (@oldclicker)

    dzaikos
    Wow, that’s a comprehensive explanation of the options. Thanks for taking the time to put that together!

    I’d assumed it would be a reasonably easy change – I can see that it’s not. I don’t want to introduce any extra complexity to the site at the moment, so will bear your resolutions in mind for the time that I get significant user feedback on it.

    Incidently, is there any copyright reason for having the three separate links at the end of the verse? They seem to pretty much duplicate themselves, with the “BibleGateway.com” one displaying the verse of the day anyway (albeit not necessarily in the bible version in use). Having all three looks cluttered, particularly if the verse is a short one.
    Thanks – Clicker

    Plugin Author DZ

    (@dzaikos)

    You’re welcome.

    I honestly can’t tell you about the links basically going to the same place (more or less). I just wrote the plugin to make it easier to embed Bible Gateway’s verse; they actually present it that way and I just replicate it.

    As for opening links in new windows, if you put that code in your theme’s file you should be good. It won’t really add any overhead and while I cannot imagine any situation in which it would cause problems you can alway remove it if you find some conflicts.

    I’ll keep your suggestions in mind for a future update; maybe I’ll find a way to add it without confusion.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Open Links in New Tab/Page’ is closed to new replies.