settings = $settings; $this->appearance = $appearance; $this->access_manager = $access_manager; $this->stripe_manager = $stripe_manager; } public function protect( string $content ): string { if ( ! $this->settings->is_enabled() ) { return $content; } if ( $this->has_access() ) { return $content; } return $this->render_locked_content( $content ); } private function has_access(): bool { $article_id = get_the_ID(); if ( ! $article_id ) { return false; } return $this->access_manager->user_has_access( $article_id ); } private function render_locked_content( string $content ): string { $article_id = get_the_ID(); $price = $this->settings->get_default_price(); wp_enqueue_style( 'articlevault-frontend', plugins_url( '../../assets/css/frontend.css', __FILE__ ), array(), Constants::VERSION ); wp_enqueue_script( 'articlevault-frontend', plugins_url( '../../assets/js/frontend.js', __FILE__ ), array(), Constants::VERSION, true ); $logo_url = $this->appearance->get_logo_url(); $heading = $this->appearance->get_heading(); $message = $this->appearance->get_message(); $button_text = $this->appearance->get_button_text(); $button_colour = $this->appearance->get_button_colour(); $background_colour = '#FFFFFF'; $heading_colour = $this->appearance->get_heading_colour(); $message_colour = $this->appearance->get_message_colour(); $blur_enabled = $this->appearance->is_blur_enabled(); $heading_style = $this->build_typography_style( $this->appearance->get_heading_typography_mode(), $this->appearance->get_heading_font(), $this->appearance->get_heading_font_size(), $this->appearance->get_heading_font_weight(), $heading_colour ); $message_style = $this->build_typography_style( $this->appearance->get_message_typography_mode(), $this->appearance->get_message_font(), $this->appearance->get_message_font_size(), $this->appearance->get_message_font_weight(), $message_colour ); $price_font = 'custom' === $this->appearance->get_heading_typography_mode() ? $this->appearance->get_heading_font() : 'inherit'; $price_style = sprintf( 'color:%s;', $heading_colour ); $locked_content_class = $blur_enabled ? 'articlevault-locked-content articlevault-locked-content--blur' : 'articlevault-locked-content'; $paywall_class = $blur_enabled ? 'articlevault-paywall articlevault-paywall--blur' : 'articlevault-paywall'; $custom_properties = sprintf( '--articlevault-paywall-background:%1$s;--articlevault-button-colour:%2$s;--articlevault-heading-colour:%3$s;--articlevault-message-colour:%4$s;', $background_colour, $button_colour, $heading_colour, $message_colour ); $display_price = sprintf( '$%s USD', number_format( (float) $price, 2, '.', '' ) ); ob_start(); ?>
stripe_manager->is_configured() && $article_id ) : ?>