• Resolved joleksow

    (@joleksow)


    Mat,

    This is related to the following question I asked earlier: https://www.ads-software.com/support/topic/default-to-link-target-_blank?replies=4

    I noticed one small issue with using this filter. If you select the target=”_none” option, it actually sets the target to be an empty string (see line 903 of meta-boxes.php). On line 300 of Simple_Link.php, it’s checking to see if $target is empty, and if so it applies the simple-links-default-target filter.

    function target_meta_box_output( $post ){
            $target = get_post_meta( $post->ID, 'target', true );
    	if( empty( $target ) ){
    		$target = apply_filters( 'simple-links-default-target', "" );
    	}
    	require( SIMPLE_LINKS_DIR . 'admin-views/link-target.php' );
    	}

    However, this means that this filter will apply even if the user has selected target=”_none” because it makes $target an empty string. Since I’ve changed the default to return “_blank”, links that were previously set to target=”_none” will have to be reset every single time the link is edited.

    Thanks,
    John

    https://www.ads-software.com/plugins/simple-links/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mat Lipe

    (@mat-lipe)

    Hello,

    Thanks for the heads up.
    I have committed a fix to the repo which will go out during the next release cycle.

    For you you can change the function to this:

    function target_meta_box_output( $post ){
    		$target = get_post_meta( $post->ID, 'target', true );
    		if( $post->post_status == "auto-draft" ){
    			$target = apply_filters( 'simple-links-default-target', "" );
    		}
    
    		require( SIMPLE_LINKS_DIR . 'admin-views/link-target.php' );
    
    	}

    It should fix the issue and matches what will change on the next update.

    Thread Starter joleksow

    (@joleksow)

    Boy you’re fast. Thanks so much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Issue with simple-links-default-target filter’ is closed to new replies.