조치를 제거하고 다른 우선 순위로 추가하려고합니다. ,remove_action PHP 클래스
이 필요 프론트 엔드 파일
private function frontend_includes() {
require_once($this->get_plugin_path() . '/includes/wc-memberships-template-functions.php');
require_once($this->get_plugin_path() . '/includes/class-wc-memberships-shortcodes.php');
WC_Memberships_Shortcodes::initialize();
$this->frontend = $this->load_class('/includes/frontend/class-wc-memberships-frontend.php', 'WC_Memberships_Frontend');
$this->checkout = $this->load_class('/includes/frontend/class-wc-memberships-checkout.php', 'WC_Memberships_Checkout');
$this->restrictions = $this->load_class('/includes/frontend/class-wc-memberships-restrictions.php', 'WC_Memberships_Restrictions');
}
포함 제품 구매가 제한하기 메시지
/**
* @param int $post_id Optional. Defaults to current post.
* @return string
*/
public function get_product_purchasing_restricted_message($post_id = null) {
if (! $post_id) {
global $post;
$post_id = $post->ID;
}
$products = $this->get_products_that_grant_access($post_id);
$message = $this->get_restriction_message('product_purchasing_restricted', $post_id, $products);
/**
* Filter the product purchasing restricted message
*
* @since 1.0.0
* @param string $message The restriction message
* @param int $product_id ID of the product being restricted
* @param array $products Array of product IDs that grant access to this product
*/
return apply_filters('wc_memberships_product_purchasing_restricted_message', $message, $post_id, $products);
}
제한 클래스 : 아래 는 메시지를 생성에 도움이 모든 코드 조각입니다 프런트 엔드의 콘텐츠 제한을 처리합니다.
class WC_Memberships_Restrictions {
/** @var array associative array of content conditions for current user **/
private $user_content_access_conditions;
/** @var array of post IDs that content restriction has been applied to **/
private $content_restriction_applied = array();
/** @var string Product content restriction password helper **/
private $product_restriction_password = null;
/** @var bool Product thumbnail removed helper **/
private $product_thumbnail_restricted = false;
public function __construct() {
// Desired action to remove and re-prioritize
add_action('woocommerce_single_product_summary', array($this, 'single_product_purchasing_restricted_message'), 30);
}
}
문자 그대로 WC_Memberships_Restrictions 클래스의 동작에서 우선 순위를 30에서 30으로 변경해야합니다. 문제는 제거를 호출 할 명확한 방법이 없다는 것입니다. 어떤 제안?
아름다운! 정말 고맙습니다! 'wc_memberships() -> restrictions'가 아닌'$ restrictions'를 배열하려고하는 것을 제외하고는 비슷한 해결책을 가졌습니다. – Nalakira