简码 API 参数像国会分支中的逻辑一样被拒绝

Shortcode API parameters rejected like logic in the Congressional Branch

我已经看过这个问题的次数多得我都数不过来了,但我终究无法弄清楚我做错了什么。我过去写过很多次短代码函数,而且次数多得我数不过来。无论出于何种原因,这个都拒绝正常工作。经过一个小时的反复尝试,我没有找到成功。请帮助。

默认值出现在html就好了,但不会反映短代码中设置的参数。

我的理智现在正在接受超出合理措施的测试,我正在幻想对 Matt Mullenweg 的智能手机进行 DDOS 攻击

请治愈我的疯狂,并指出我明显忽略的微小细节这样我就可以继续我的一天。

简码

[subscription ID="1" referrer="overlay-promotion" buttonText="Send it to me" buttonBGHex="#000c49"]

函数

function subscription_form($atts){
    //Yes, I tried extract to, and yes, I changed the variables in the html below to reflect this change.
    $a = shortcode_atts( array(
        "ID" => "1",
        "referrer" => "not-what-you-think-this-should-be",
        "buttonText" => "Subscribe",
        "buttonBGHex" => "#78C138"
    ), $atts, "subscription" );

    $html = '<form id="subscribe" name="email_signup" class="form-inline validate" action="http://www.example.com/subscribe" method="post">';
    $html .= '<input type="hidden" name="referrer" value="'.$a["referrer"].'">';
    $html .= '<input type="hidden" name="success_url" value="http://www.example.com/subscribe/success">';
    $html .= '<input type="hidden" name="error_url" value="http://www.example.com/subscribe/error">';
    $html .= '<input type="hidden" name="list_id" value="'.$a["ID"].'">';
    $html .= '<input type="text" placeholder="Enter your email address" class="input-large" name="email">';
    $html .= '<input type="submit" class="btn btn-primary" style="background-color:'.$a["buttonBGHex"].';" name="submit" value="'.$a["buttonText"].'">';
    $html .= '</form>';

    return $html;
}
add_shortcode( 'subscription', 'subscription_form' );

输出

<form id="subscribe" name="email_signup" class="form-inline validate" action="https://www.example.com/subscribe" method="post">
<input type="hidden" name="referrer" value="HP-overlay-2015">
<input type="hidden" name="success_url" value="https://www.example.com/subscribe/success">
<input type="hidden" name="error_url" value="https://www.example.com/subscribe/error">
<input type="hidden" name="list_id" value="1"><input type="text" placeholder="Enter your email address" class="input-large" name="email">
<input type="submit" class="btn btn-primary" style="background-color:#78C138;" name="submit" value="Subscribe">
</form>

根据 add_shortcode 的法典,短代码的属性名称被转换为小写。

Shortcode attribute names are always converted to lowercase before they are passed into the handler function. Values are untouched.

这意味着您需要使用小写版本访问数组键以获得正确的输出。