Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Issue of locking and unlocking content based on access level #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: sesamy, paywall
Requires at least: 5.0.1
Requires PHP: 7.4
Tested up to: 6.4.2
Stable tag: 1.0.10
Stable tag: 2.0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -102,8 +102,11 @@ The following filters can be used to modify the default output from the plugin:

== Changelog ==

= 1.0.10 =
* Removed unnecessary scripts and tags
= 2.0.1 =
* Fixed Issue of locking and unlocking content based on access level.

= 2.0 =
* Remove unnecessary scripts and tags

= 1.0.9 =
* Fixed Sesamy Attribute count issue
Expand Down
17 changes: 16 additions & 1 deletion src/public/class-sesamy-content-container.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,25 @@ public function show_paywall( $post, $post_settings ) {

ob_start();

$post_settings = sesamy_get_post_settings( $post_id );
if ( $post_settings['access_level'] != -1 && !empty( $post_settings['access_level'] ) ) {
$access_level = $post_settings['access_level'];
} else {
$access_level = 'entitlement';
}

$html_attributes_l = array(
"access-level" => $access_level,
);

echo '<sesamy-locked-content-container ';
Sesamy_Utils::html_attributes( $html_attributes_l );
Copy link
Contributor

@julianidiart julianidiart Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're missing some attributes here, the <sesamy-locked-content-container> should also include:

  • required-attributes: for the case that the access-level is logged-in, we need to know if there are some attributes required as well.
  • item-src: for the case that the access-level is entitlement, we need to know which entitlement should be in charge of locking/unlocking the content.
  • pass: idem item-src.
  • publisher-content-id: to get the item-src, pass, and public from the <sesamy-content-data> component or meta tags in the case that these are not set as attributes.

These valules should be the same the we pass to the <sesamy-content-container> component.

echo ' >';

?>
<div class="sesamy-paywall" data-sesamy-paywall data-sesamy-item-src="<?php the_permalink( $post->ID ); ?>" data-sesamy-passes="<?php sesamy_get_passes_urls( $post->ID ); ?>">

<?php sesamy_login(); ?>
<?php sesamy_login(); echo '</sesamy-locked-content-container>'; ?>
<?php

if ( $post_settings['enable_single_purchase'] ) {
Expand Down
10 changes: 10 additions & 0 deletions src/public/sesamy-global-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ function ( $key ) use ( $non_display_atts ) {
ARRAY_FILTER_USE_KEY
);

if($access_level == "logged-in") {
$html_attributes = array(
"access-url" => $atts['access_url'],
"pass" => $atts['pass'],
"access-level" => $atts['access-level'],
"gradient" => $atts['gradient'],
'is_locked' => Sesamy_Post_Properties::is_locked( $post_id ) ? "true" : "false",
);
}

echo '<sesamy-content-container ';
Sesamy_Utils::html_attributes( $html_attributes );
echo '/>';
Expand Down
4 changes: 2 additions & 2 deletions src/sesamy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Plugin Name: Sesamy
* Plugin URI: https://sesamy.com
* Description: Add paywall functionality with Sesamy (sesamy.com) to your WordPress website.
* Version: 1.0.10 // Downgrade version number
* Version: 2.0.1
* Author: Sesamy AB
* Author URI: https://sesamy.com
* License: GPL-2.0+
Expand All @@ -34,7 +34,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'SESAMY_VERSION', '1.0.10' );
define( 'SESAMY_VERSION', '2.0.1' );

/**
* The code that runs during plugin activation.
Expand Down
2 changes: 1 addition & 1 deletion src/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
* @package Sesamy
*/

define( 'SESAMY_VERSION', '1.0.10' );
define( 'SESAMY_VERSION', '2.0.1' );