: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ($this->has_woocommerce()) {
remove_action('wp_loaded', array('WC_Form_Handler', 'process_registration'), 20);
wc_add_notice($message, 'error');
public function _handle_woocommerce_registration() {
if ($this->has_woocommerce() && isset($_POST['register'], $_POST['email']) && (isset($_POST['_wpnonce']) || isset($_POST['woocommerce-register-nonce']))) {
$captchaResult = $this->process_registration_captcha_with_hooks();
if ($captchaResult !== true) {
$this->disable_woocommerce_registration($captchaResult['message']);
public function _user_new_form() {
if (Controller_Settings::shared()->get_user_2fa_grace_period())
echo Model_View::create('user/grace-period-toggle', array())->render();
public function _user_register($newUserId) {
$creator = wp_get_current_user();
if (!Controller_Permissions::shared()->can_manage_settings($creator) || $creator->ID == $newUserId)
if (isset($_POST['wfls-grace-period-toggle']))
Controller_Users::shared()->allow_grace_period($newUserId);
public function _woocommerce_account_menu_items($items) {
if ($this->can_user_activate_2fa_self()) {
$endpointId = self::WOOCOMMERCE_ENDPOINT;
$label = __('Wordfence 2FA', 'wordfence');
if (!Utility_Array::insertAfter($items, 'edit-account', $endpointId, $label)) {
$items[$endpointId] = $label;
public function _woocommerce_get_query_vars($query_vars) {
$query_vars[self::WOOCOMMERCE_ENDPOINT] = self::WOOCOMMERCE_ENDPOINT;
private function can_user_activate_2fa_self($user = null) {
$user = wp_get_current_user();
return user_can($user, Controller_Permissions::CAP_ACTIVATE_2FA_SELF);
private function render_embedded_user_2fa_management_interface($stacked = null) {
$user = wp_get_current_user();
$stacked = $stacked === null ? Controller_Settings::shared()->should_stack_ui_columns() : $stacked;
if ($this->can_user_activate_2fa_self($user)) {
$assets = $this->management_assets_enqueued ? array() : $this->get_2fa_management_assets(true);
$scriptData = $this->management_assets_enqueued ? array() : $this->get_2fa_management_script_data();
return Model_View::create(
'scriptData' => $scriptData
return Model_View::create('page/permission-denied')->render();
public function _woocommerce_account_menu_content() {
echo $this->render_embedded_user_2fa_management_interface();
private function does_current_page_include_shortcode($shortcode) {
return $post instanceof \WP_Post && has_shortcode($post->post_content, $shortcode);
public function _woocommerce_account_enqueue_assets() {
if (!$this->has_woocommerce())
if ($this->does_current_page_include_shortcode('woocommerce_my_account')) {
wp_enqueue_style('wordfence-ls-woocommerce-account-styles', Model_Asset::css('woocommerce-account.css'), array(), WORDFENCE_LS_VERSION);
$this->enqueue_2fa_management_assets(true);
public function _handle_user_2fa_management_shortcode($attributes, $content = null, $shortcode = null) {
$shortcode = $shortcode === null ? self::SHORTCODE_2FA_MANAGEMENT : $shortcode;
$attributes = shortcode_atts(
'stacked' => Controller_Settings::shared()->should_stack_ui_columns() ? 'true' : 'false'
$stacked = filter_var($attributes['stacked'], FILTER_VALIDATE_BOOLEAN);
return $this->render_embedded_user_2fa_management_interface($stacked);
public function _handle_shortcode_prerequisites() {
if ($this->does_current_page_include_shortcode(self::SHORTCODE_2FA_MANAGEMENT)) {
if (!is_user_logged_in())
$this->enqueue_2fa_management_assets(true);