我正在使用WooCommerce Print Invoice 用于打印发票的插件。现在我正在为我的网站开发Cordova应用程序,我需要能够从wordpress查看发票。
插件具有隐藏或重定向页面的功能,如果您未登录。
public function print_document_action() {
// listen for \'print\' action query string
if (isset($_GET[\'wc_pip_document\'], $_GET[\'wc_pip_action\']) && \'print\' === $_GET[\'wc_pip_action\']) {
// sanity check, if user is not logged in, prompt to log in
if (!is_user_logged_in()) {
wp_redirect(wc_get_page_permalink(\'myaccount\'));
exit;
}
$nonce = isset($_REQUEST[\'_wpnonce\']) ? $_REQUEST[\'_wpnonce\'] : \'\';
// security admin/frontend checks
if (!$nonce || !wp_verify_nonce($nonce, \'wc_pip_document\')) {
die(__(\'You are not allowed to view this page.\', \'woocommerce-pip\'));
}
是否可以从函数中覆盖此内容。php?
尝试再次使用整个函数,但没有以下行:
add_filter(\'print_document_action\', \'showInvoices\', $priority = 9999, $args = 1);
function showInvoices() {
// same function without sanity check and security admin/frontend checks
}
还尝试使用JSON API插件生成nounce,并按如下方式运行页面:
site.com/orders/?wc_pip_action=print&wc_pip_document=invoice&order_id=\'+id+\'&_wpnonce=\'+nonce;
这也不起作用。有什么想法吗?
SO网友:Ash0ur
尝试从过滤器中删除插件函数。
您确定插件函数和过滤器的名称相同吗!
*您需要知道插件函数在remove\\u filter中使用它的优先级,我假设它是默认值(10)。
remove_filter( \'print_document_action\', \'print_document_action\', 10 );
然后将函数添加到过滤器。
add_filter(\'print_document_action\', \'showInvoices\', $priority = 9999, $args = 1);