受密码保护的页面添加过滤器更改文本不起作用

时间:2016-03-17 作者:cgee

我搜索解决方案以更改受保护页面上的文本:

此帖子受密码保护。要查看它,请在下面输入您的密码:

我找到了这个过滤器挂钩,并将其包含到我的函数中。php在我的主题中。

https://codex.wordpress.org/Using_Password_Protection#Protected_Excerpt_Text

但这个代码对我不起作用。

我找不到任何其他解决方案,也不想编辑我的页面模板。

有什么办法可以解决这个问题吗?

非常感谢。

@编辑:

这篇文章来自我的主题。采购订单文件。

1 个回复
SO网友:cgee

我使用wordpress主题wpcasa,主题更改wordpress的标准文本。

所以我加入了一个主题的过滤器挂钩:

add_filter( \'the_password_form\', \'wpsight_password_form_dmd\' );

function wpsight_password_form_dmd($output){
    global $post;
    $output = \'\';
    $aktuelleseite = $_SERVER[\'REQUEST_URI\'];
    $sprache = explode(\'/\',$aktuelleseite);  


    $label = \'pwbox-\'.( empty( $post->ID ) ? rand() : $post->ID );

    $output = \'<form action="\' . get_option( \'siteurl\' ) . \'/wp-login.php?action=postpass" method="post" class="form-password form-inline">\';
    switch($sprache[1]){
        case \'en\':
            $output .= \'<p>Please include your password which we sent you.<br><br>You do not have a password? Than make a request <a href="/en/top-ten-request-form/"><u>here</u></a>.</p>\';
            break;
        case \'de\':
            $output .= \'<p>Bitte geben Sie hier Ihr Passwort ein, welches wir Ihnen gesendet haben.<br><br>Sie haben kein Passwort? Dann fordern Sie <a href="/de/top-ten-zugangsformular/"><u>hier</u></a> eins an.</p>\';
            break;
    }
    $output .= \'    <label for="\' . $label . \'">\' . __( \'Password\', \'wpsight\' ) . \'<input name="post_password" id="\' . $label . \'" type="password" size="20" class="password span3" /></label><button type="submit" name="Submit" class="btn">\' . esc_attr__( \'Submit\', \'wpsight\' ) . \'</button></form>\';

    return $output;    
}
现在一切正常。

相关推荐

Apply_Filters()对所需的参数进行切片

我正在尝试向WooCommerce订单中的每个退款行添加一个按钮(其功能超出了这个问题的范围,足以说明它需要退款id作为参数)。我发现这些行是在woocommerce\\includes\\admin\\meta Box\\views\\html订单退款中创建的。无法重写的php。然而,有一项行动:do_action( \'woocommerce_admin_order_item_values\', null, $refund, $refund->get_id() ); 这似乎非常适合我的