1
我爲我們可以在我們的WordPress網站上使用的工具提示創建了一個簡碼。簡碼只是一個鏈接,當你將鼠標懸停在鏈接上時,它會顯示一個工具提示,但由於某些原因,當使用簡碼時,它會在鏈接的末尾添加額外的空間,我無法弄清楚如何擺脫它。您可以在我們的網站上看到問題WordPress的短代碼鏈接在結尾添加了額外的空間
http://stormable.com/hero-lore-tyrande-whisperwind/如果您查看內容中的任何鏈接,您將在鏈接後看到額外的空間。
add_shortcode('tyrande', 'tyrande');
function tyrande($atts, $content = null) {
// Hero Meta Data
$HeroID = 337;
$Hero = Tyrande;
$hero = tyrande;
$franchise = warcraft;
$heroSubname = get_post_meta($HeroID, 'hero-sub-name', true);
$health_gain = get_post_meta($HeroID, 'health-gain', true);
$heroHealth = $health_gain*24+get_post_meta($HeroID, "health-lvl1", true);
$healthRegenGain = get_post_meta($HeroID, 'health-regen-gain', true);
$heroHealthRegen = $healthRegenGain*24+get_post_meta($HeroID, "health-regen-lvl1", true);
$manaGain = get_post_meta($HeroID, 'mana-gain', true);
$heroMana = $manaGain*24+get_post_meta($HeroID, "mana-lvl1", true);
$manaRegenGain = get_post_meta($HeroID, 'mana-regen-gain', true);
$heroManaRegen = $manaRegenGain*24+get_post_meta($HeroID, "mana-regen-lvl1", true);
$attackSpeedGain = get_post_meta($HeroID, 'attack-speed-gain', true);
$heroAttackSpeed = $attackSpeedGain*24+get_post_meta($HeroID, "attack-speed-lvl1", true);
$attackDamageGain = get_post_meta($HeroID, 'attack-damage-gain', true);
$heroAttackDamage = $attackDamageGain*24+get_post_meta($HeroID, "attack-damage-lvl1", true);
extract(shortcode_atts(array('icon' => 'false'), $atts));
if($icon == 'true'){
$output = '<img class="hero-tt-icon" src="http://stormable.com/img/heroes/' . $hero . '/' . $hero . '-tt-icon.png" alt="' . $hero . ' Heroes of the Storm">';
}
$output .= '
<a class="tooltip"
href="http://stormable.com/heroes/' . $hero . '/">' . $Hero . '
<span class="hero-tooltip">
<span class="hero-tt-image"><img src="http://stormable.com/img/heroes/' . $hero . '/' . $hero . '-tt.png" alt="Heroes of the Storm ' . $Hero . '" /></span>
<span class="hero-tt-info">
<span class="hero-tt-name-info">
<span class="hero-tt-fran"><img src="http://stormable.com/img/icons/' . $franchise . '.png" alt="Heroes of the Storm ' . $franchise . ' Franchise" /></span>
<span class="hero-tt-name">' . $Hero . '</span>
<span class="hero-tt-subname">' . $heroSubname . '</span>
</span>
<span class="HeroStats">
<span class="HeroStats-title">Hero Stats at Level 25</span>
<span class="HeroStats-row">
<span class="HeroStat-left">Health</span>
<span class="HeroStat-right">' . $heroHealth . ' (' . $health_gain . '/level)</span>
</span>
<span class="HeroStats-row">
<span class="HeroStat-left">Health Regen</span>
<span class="HeroStat-right">' . $heroHealthRegen . ' (' . $healthRegenGain . '/level)</span>
</span>
<span class="HeroStats-row">
<span class="HeroStat-left">Mana</span>
<span class="HeroStat-right">' . $heroMana . ' (' . $manaGain . '/level)</span>
</span>
<span class="HeroStats-row">
<span class="HeroStat-left">Mana Regen</span>
<span class="HeroStat-right">' . $heroManaRegen . ' (' . $manaRegenGain . '/level)</span>
</span>
<span class="HeroStats-row">
<span class="HeroStat-left">Attack Speed</span>
<span class="HeroStat-right">' . $heroAttackSpeed . ' (' . $attackSpeedGain . '/level)</span>
</span>
<span class="HeroStats-row">
<span class="HeroStat-left">Attack Damage</span>
<span class="HeroStat-right">' . $heroAttackDamage . ' (' . $attackDamageGain . '/level)</span>
</span>
</span>
<span class="clear"></span>
</span>
</a>
';
return $output;
}
謝謝你,那個作品你能夠向我解釋那是什麼,爲什麼我有多餘的線路與?我只是學習PHP,所以我真的不明白你給我的那一行。 – Greenhoe
所有輸入您在'$ output'變量中輸入的內容都將被視爲HTML的新鏈接。 – Rikesh
你在我的$輸出中的「all enter」是什麼意思?我的輸出中只顯示正常的HTML,沒有間隔,所以鏈接末尾的額外空間究竟是從哪裏來的? – Greenhoe