WordPress.org

Ready to get started?Download WordPress

Forums

WP MtG-Helper
Link to card names with text not matching card name (1 post)

  1. spekkionu
    Member
    Posted 11 months ago #

    I have added the ability to use different text for the card links than the card name itself.

    Usage Examples

    [card Akroma, Angel of Wrath]Akroma[/card]
    [card Nevinyrral's Disk]Disk[/card]

    Patch with changes

    Index: mtg_helper_card.php
    ===================================================================
    --- mtg_helper_card.php	(revision 785690)
    +++ mtg_helper_card.php	(working copy)
    @@ -4,24 +4,32 @@
     function mtgh_card($content){
    
     	//preload all image-files
    -	preg_match_all('/(\[CARD\])(.*)(\[\/CARD\])/iU',$content,$result);
    +	preg_match_all('/(\[CARD([^\]]*)\])(.*)(\[\/CARD\])/iU',$content,$result);
    +
    +	$result[2] = trim($result[2][0]);
    +	if (strlen($result[2]) == 0)
    +		$result[2] = $result[3];
     	$preload = cache_cards($result[2]);
    
     	//replace the [card]-tags with the referer for the card images
     	$content = preg_replace_callback(
    -	'/(\[CARD\])(.*)(\[\/CARD\])/iU',
    +	'/(\[CARD([^\]]*)\])(.*)(\[\/CARD\])/iU',
     	'parse_card_url',
     	$content);
    
     	return $content.$preload;
    -
    +
     }
    
     function parse_card_url ($card_names){
    
    -	return '<a href="' . get_bloginfo('wpurl') . MTGH_DIR
    -	.'/mtg_helper_cardfinder.php?find=' . urlencode($card_names[2]) . '&width=223&height=310" class="jTip" name="">'
    -	. $card_names[2] . '</a>';
    +	$card_names[2] = trim($card_names[2]);
    +	if (strlen($card_names[2]) == 0)
    +		$card_names[2] = $card_names[3];
    +  $card_names[2] = str_replace(array("'",'ΓÇÖ',"’"),"’",$card_names[2]);
    +	return '<a href="' . get_bloginfo('wpurl') . MTGH_DIR
    +	.'/mtg_helper_cardfinder.php?find=' . rawurlencode($card_names[2]) . '&width=223&height=310" class="jTip" name="">'
    +	. $card_names[3] . '</a>';
     }
    
    -?>
    \ No newline at end of file
    +?>

    http://wordpress.org/plugins/wp-mtg-helper/

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.