0

需要一些编码建议,我想结合 2 个不同的wordpress 函数,它们以 $string 开头并返回代码。

返回码是

return '<div> some html </div>';

$sting代码是

$string .= '<div>';
if else
$string .= '</div>';

谢谢

4

1 回答 1

0

Well I dont have experience in coding and html..

1st function

<?php function _bit_header_inside(){ /* HEADER WITH LOGO + BANNER */

global $wpdb,$PPT;

return '<div id="header" class="full"><div class="w_960">

    <div class="f_half left" id="logo">

        <a href="'.$GLOBALS['bloginfo_url'].'/" title="'.get_bloginfo('name').'">

            <img src="'.$PPT->Logo(true).'" alt="'.get_bloginfo('name').'" />

        </a>

    </div>

    <div class="left" id="banner">

        '.test_banner("top",true).'

    </div>

    </div> <!-- end header w_960 -->

    <div class="clearfix"></div>

    </div> <!-- end header -->';

    } ?>

<?php echo test_header_inside(_bit_header_inside()); /* HOOK  / FILTER  */ ?>

2nd function

<?php function custom_login_logout(){ /* Custom LOGIN-LOGOUT BAR */

global $wpdb,$PPT, $userdata; get_currentuserinfo(); $string='';  

$string .= '<div id="submenubar"><div class="w_960">';

    if(isset($GLOBALS['ppt_layout_styles']['header']) && isset($GLOBALS['ppt_layout_styles']['header']['loginlogout']) && $GLOBALS['ppt_layout_styles']['header']['loginlogout'] == 1){ }else{

$string .= '<ul class="submenu_account">';

    if ( isset($userdata) && $userdata->ID ){ 

$string .= '<li id="submenu_li_logout"><a href="'.wp_logout_url().'">'.$PPT->_e(array('head','4')).'</a></li>
<li id="submenu_li_account"><a href="'.$GLOBALS['test']['dashboard_url'].'">'.$PPT->_e(array('head','5')).'</a></li>
<li id="submenu_li_username"><b>'.$userdata->display_name.'</b></li>';

    }else{

$string .= '<li><a href="'.$GLOBALS['bloginfo_url'].'/wp-login.php" rel="nofollow" id="submenu_li_login">'. $PPT->_e(array('head','6')).'</a>

<a href="'.$GLOBALS['bloginfo_url'].'/wp-login.php?action=register" rel="nofollow" id="submenu_li_register">'.$PPT->_e(array('head','7')).'</a></li>';

    }

$string .= '</ul> ';

}

$string .= '</div> <!-- end w_960 --> </div><!-- end submenubar --> ';

return $string;

} ?>

<?php echo test_submenu_inside(custom_login_logout()); /* HOOK / FILTER */  ?>

How to insert "custom_login_logout" inside "test_header_inside" below

<div class="left" id="banner">

    '.test_banner("top",true).'

</div>

Can I combine them this way

<?php
return '<div> some html';

$string .= '<div>';
if else
$string .= '</div>';

return '</div>';
?>
<?php echo test_header_inside(_bit_header_inside()); /* HOOK  / FILTER  */ ?>

Thanks

于 2013-02-21T06:03:09.167 回答