WordPress.org

Support

Support » Plugins and Hacks » [Resolved] having links open in new / blank window

[Resolved] having links open in new / blank window

Viewing 5 replies - 1 through 5 (of 5 total)
  • I need it too.

    ellbristow
    WPMU DEV Support Staff

    @ellbristow

    To have shared links open in a new window, you need to edit the file at

    /plugins/buddypress-activity-plus/lib/forms/link_tag_template.php

    There are two places where the tags are used, if you add target=”_blank” to each you’ll be good to go.

    stevenpreece
    Member

    @stevenpreece

    I’m having the same problem. I looked at the file above and noticed that there is already one instance of target=”_blank” but have no idea where a second should be?

    <?php
    $target = in_array(BPFB_LINKS_TARGET, array('all', 'external')) ? 'target="_blank"' : '';
    ?><div class="bpfb_final_link">
    	<?php if ($image) { ?>
    	<div class="bpfb_link_preview_container">
    		<a>" <?php echo $target; ?> ><img src="<?php echo $image; ?>" /></a>
    	</div>
    	<?php } ?>
    	<div class="bpfb_link_contents">
    		<div class="bpfb_link_preview_title"><?php echo $title;?></div>
    		<div class="bpfb_link_preview_url">
    			<a>" <?php echo $target; ?> ><?php echo $url;?></a>
    		</div>
    		<div class="bpfb_link_preview_body"><?php echo $body;?></div>
    	</div>
    </div>

    [Please post code & markup between backticks or use the code button. Your posted code has now have been permanently damaged by the forum’s parser.]

    ellbristow
    WPMU DEV Support Staff

    @ellbristow

    Hi @stevenpreece,

    Your code was modified by wordpress when you posted it… but the two locations you are looknig at are the lines that contain <a href=" etc

    you need to add target="_blank" between the a and the href. That should get it working for you.

    Have a look at the code below and where the target="_blank" needs to go. Works for me:

    <?php
    $target = in_array(BPFB_LINKS_TARGET, array('all', 'external')) ? 'target="_blank"' : '';
    ?><div class="bpfb_final_link">
    	<?php if ($image) { ?>
    	<div class="bpfb_link_preview_container">
    		<a href="<?php echo $url;?>" <?php echo $target; ?> target="_blank"><img src="<?php echo $image; ?>" /></a>
    	</div>
    	<?php } ?>
    	<div class="bpfb_link_contents">
    		<div class="bpfb_link_preview_title"><?php echo $title;?></div>
    		<div class="bpfb_link_preview_url">
    			<a href="<?php echo $url;?>" <?php echo $target; ?> target="_blank"><?php echo $url;?></a>
    		</div>
    		<div class="bpfb_link_preview_body"><?php echo $body;?></div>
    	</div>
    </div>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] having links open in new / blank window’ is closed to new replies.