简体   繁体   English

在子主题中覆盖父主题功能? 怎么样?

[英]Override Parent Theme Function in Child Theme? How?

I want to change the output in this function. 我想在此函数中更改输出。

function ph_mailchimp($action){
    $msg = get_theme_mod('pic_mailchimp', 'text');
    $output = '
    <div class="newsletter-box well">
      <p>' . $msg  . '</p>
      <form accept-charset="UTF-8" action="'.$action.'" class="new_subscriber" data-remote="true" id="mc-embedded-subscribe-form" method="post">
        <div style="display:none">
          <input name="utf8" type="hidden" value="">
        </div>
        <input class="inputfield" id="mce-EMAIL" name="EMAIL" placeholder="Your email" type="email">
        <input name="subscribe" type="submit" value="Subscribe">
      </form>
    </div>';
    return $output;
}

Basically I want to add a code in my Child theme's functions.php file to override the Output in the function above. 基本上,我想在我的Child主题的functions.php文件中添加代码,以覆盖上述函数中的Output。

Can anyone help? 有人可以帮忙吗? Thanks. 谢谢。

You can, if you have the proper setup. 如果设置正确,则可以。 Install APD from PECL, or runkit from the same. 从PECL安装APD或从相同的Runkit安装。 If you have runkit, this should do the trick: 如果您有Runkit,这应该可以解决问题:

runkit_function_remove ( "ph_mailchimp" );

function ph_mailchimp() {
    echo "Foobar";//do stuff here
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM