我创建了一个按预期显示结果的短代码,但它位于div或table单元格之外,我将短代码放置在我的站点中。是否有一种更简洁的方法来编写此代码,从而在预期的位置生成代码?
<?php
function minisocialvar( $atts )
{
$s = shortcode_atts( array(
\'id\' => \'\',
\'fb\' => \'\',
\'tw\' => \'\',
\'ig\' => \'\',
\'yt\' => \'\',
\'in\' => \'\',
\'fk\' => \'\',
\'align\' => \'left\',
\'size\' => \'\',
), $atts ); ?>
<div id="<?php echo $s[\'id\']; ?>" style="text-align: <?php echo $s[\'align\']; ?>;">
<?php if (!empty($s[\'fb\'])) { ?>
<a href="<?php echo $s[\'fb\']; ?>" title="Follow Us On Facebook" target="_blank" class="fb-socialicon">
<span class="fa-stack <?php echo $s[\'size\']; ?>">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
</span>
</a>
<?php } ?>
<?php if (!empty($s[\'tw\'])) { ?>
<a href="<?php echo $s[\'tw\']; ?>" title="Follow Us On Twitter" target="_blank" class="tw-socialicon">
<span class="fa-stack <?php echo $s[\'size\']; ?>">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
</span>
</a>
<?php } ?>
<?php if (!empty($s[\'ig\'])) { ?>
<a href="<?php echo $s[\'ig\']; ?>" title="Follow Us On Instagram" target="_blank" class="ig-socialicon">
<span class="fa-stack <?php echo $s[\'size\']; ?>">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-instagram fa-stack-1x fa-inverse"></i>
</span>
</a>
<?php } ?>
<?php if (!empty($s[\'yt\'])) { ?>
<a href="<?php echo $s[\'yt\']; ?>" title="Watch Us On YouTube" target="_blank" class="yt-socialicon">
<span class="fa-stack <?php echo $s[\'size\']; ?>">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-youtube fa-stack-1x fa-inverse"></i>
</span>
</a>
<?php } ?>
<?php if (!empty($s[\'in\'])) { ?>
<a href="<?php echo $s[\'in\']; ?>" title="Join Us On LinkedIn" target="_blank" class="in-socialicon">
<span class="fa-stack <?php echo $s[\'size\']; ?>">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-linkedin fa-stack-1x fa-inverse"></i>
</span>
</a>
<?php } ?>
<?php if (!empty($s[\'fk\'])) { ?>
<a href="<?php echo $s[\'fk\']; ?>" title="View Us On Flickr" target="_blank" class="fk-socialicon">
<span class="fa-stack <?php echo $s[\'size\']; ?>">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-flickr fa-stack-1x fa-inverse"></i>
</span>
</a>
<?php } ?>
</div>
<?php } ?>
<?php add_shortcode( \'minisocial\', \'minisocialvar\' );