Plugin Directory

Changeset 3494567


Ignore:
Timestamp:
03/30/2026 12:02:21 PM (7 months ago)
Author:
aimansaeedsh
Message:

tagging 4.0.9

Location:
zlick-paywall
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • zlick-paywall/tags/4.0.9/public/js/zlick-widget.js

    r3415349 r3494567  
    1616    if (match) return match[2];
    1717}
     18
     19// Store sync flag from onAuthenticated for use in onPaymentComplete
     20var _zp_sync_wp_users = false;
    1821
    1922function passSupportedParamsToWidget(zlickWidgetPurpose){
    … …  
    4245            }
    4346        vuePaywallElement.onAuthenticated = function (params) {
    44             console.log("access_info_signed: ", params);
    45             console.log(params.access_info_signed);
     47            console.log("onAuthenticated - params: ", params);
     48           
     49            // Store the sync flag for onPaymentComplete to use
     50            _zp_sync_wp_users = params.sync_wp_users_with_subscribers === true;
    4651            var post_data = {
    4752                'action': 'zp_authenticate_article',
    … …  
    7681                } else {
    7782                    return "something went wrong.";
    78             }
     83                }
    7984            }
    8085            xhr.send(xwwwfurlenc(post_data));
    … …  
    116121            xhr.send(xwwwfurlenc(post_data));
    117122        }
    118         vuePaywallElement.onPaymentComplete = function ({ data }) {
    119             // window._zp_delayed_reload = true;
     123        vuePaywallElement.onPaymentComplete = function (paymentData) {
     124            console.log("onPaymentComplete - paymentData: ", paymentData);
     125            console.log("onPaymentComplete - _zp_sync_wp_users: ", _zp_sync_wp_users);
     126           
     127            // Only sync if sync_wp_users_with_subscribers is enabled (set from onAuthenticated)
     128            if (!_zp_sync_wp_users) {
     129                console.log("onPaymentComplete - sync_wp_users_with_subscribers is false, skipping user creation");
     130                return;
     131            }
     132           
     133            // SDK passes { signed_payment_info: 'JWT', unsigned_payment_info: 'JSON' }
     134            var signedPaymentInfo = paymentData && paymentData.signed_payment_info ? paymentData.signed_payment_info : '';
     135            console.log("onPaymentComplete - signed_payment_info: ", signedPaymentInfo);
     136           
     137            if (!signedPaymentInfo) {
     138                console.log("onPaymentComplete - no signed_payment_info, skipping sync");
     139                return;
     140            }
     141           
     142            // Send the signed JWT to PHP for user creation
     143            var post_data = {
     144                'action': 'zp_sync_subscriber',
     145                'zp_nonce': zlick_payments_ajax.zp_ajax_nonce,
     146                'zp_signed_payment_info': signedPaymentInfo
     147            };
     148           
     149            var xhr = new XMLHttpRequest();
     150            var cacheBuster = 'zp_' + Math.random().toString(20).substr(2, 8);
     151            var url = zlick_payments_ajax.ajax_url + '?action=zp_sync_subscriber&' + cacheBuster + '=1';
     152            console.log("onPaymentComplete - sending to: ", url);
     153            xhr.withCredentials = true;
     154            xhr.open('POST', url, true);
     155            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
     156            xhr.onreadystatechange = function() {
     157                if (xhr.readyState === 4) {
     158                    console.log("onPaymentComplete - response: ", xhr.responseText);
     159                }
     160            }
     161            xhr.send(xwwwfurlenc(post_data));
    120162        }
    121163        vuePaywallElement.onFailure = (data)=>{
  • zlick-paywall/tags/4.0.9/public/shortcodes/zlick-widget.php

    r3417615 r3494567  
    142142add_action('wp_ajax_nopriv_zp_access_expired', 'zlickpay_access_expired');
    143143
    144 
     144/**
     145 * Register Ajax callback for syncing Zlick subscribers to WordPress users
     146 */
     147add_action('wp_ajax_zp_sync_subscriber', 'zlickpay_sync_subscriber');
     148add_action('wp_ajax_nopriv_zp_sync_subscriber', 'zlickpay_sync_subscriber');
     149
     150/**
     151 * Create/sync WordPress user from Zlick subscriber data (called from onPaymentComplete)
     152 */
     153if (!function_exists('zlickpay_sync_subscriber')) {
     154        function zlickpay_sync_subscriber() {
     155                // Check for nonce security
     156                if (!isset($_POST['zp_nonce']) || !wp_verify_nonce($_POST['zp_nonce'], 'zp-ajax-nonce')) {
     157                        write_log('zlickpay_sync_subscriber: Nonce verification failed');
     158                        wp_die('Nonce verification failed');
     159                }
     160               
     161                $zp_signed_payment_info = sanitize_text_field($_POST['zp_signed_payment_info']);
     162               
     163                if (empty($zp_signed_payment_info)) {
     164                        write_log('zlickpay_sync_subscriber: No signed payment info received');
     165                        wp_die('No payment info');
     166                }
     167               
     168                // Decode the JWT using existing function
     169                $payload = json_decode(zlickpay_get_jwt_payload($zp_signed_payment_info), true);
     170                write_log('zlickpay_sync_subscriber: Decoded payload: ' . json_encode($payload));
     171               
     172                if (empty($payload) || !isset($payload['userId']) || !isset($payload['subscriptionId']) || !isset($payload['subscribedPricePlan'])) {
     173                        write_log('zlickpay_sync_subscriber: Missing required fields in payload');
     174                        wp_die('Missing required fields');
     175                }
     176               
     177                // Extract contact field (can be email or other identifier like phone)
     178                $contact = isset($payload['contact']) ? sanitize_text_field($payload['contact']) : '';
     179                $user_email = '';
     180                $display_name = '';
     181               
     182                // Check if contact is an email
     183                if (!empty($contact) && is_email($contact)) {
     184                        // Contact is an email - use email as username and display name
     185                        $username = sanitize_user($contact, true); // sanitize for use as username
     186                        $user_email = $contact;
     187                        $display_name = $contact;
     188                        write_log('zlickpay_sync_subscriber: Contact is email, using as username: ' . $username);
     189                } elseif (!empty($contact)) {
     190                        // Contact is not an email (e.g., phone) - use as username directly
     191                        $username = sanitize_user($contact);
     192                        $display_name = $contact;
     193                        write_log('zlickpay_sync_subscriber: Contact (phone) used as username: ' . $username);
     194                } else {
     195                        // No contact - use userId as before
     196                        $username = $payload['userId'] . '_' . $payload['subscribedPricePlan'];
     197                        write_log('zlickpay_sync_subscriber: No contact, using userId: ' . $username);
     198                }
     199               
     200                $password = $payload['subscriptionId'];
     201               
     202                write_log('zlickpay_sync_subscriber: Creating user with username: ' . $username . ', email: ' . $user_email);
     203               
     204                // Clear any existing logged in user
     205                if (is_user_logged_in()) {
     206                        wp_logout();
     207                }
     208               
     209                $user = get_user_by('login', $username);
     210                if ($user) {
     211                        write_log('zlickpay_sync_subscriber: User already exists, updating: ' . $username);
     212                        $wp_user_id = $user->ID;
     213                        wp_set_password($password, $wp_user_id);
     214                        // Update email and display name if provided
     215                        $update_data = array('ID' => $wp_user_id);
     216                        if (!empty($user_email)) {
     217                                $update_data['user_email'] = $user_email;
     218                        }
     219                        if (!empty($display_name)) {
     220                                $update_data['display_name'] = $display_name;
     221                                $update_data['nickname'] = $display_name;
     222                        }
     223                        if (count($update_data) > 1) {
     224                                wp_update_user($update_data);
     225                        }
     226                } else {
     227                        write_log('zlickpay_sync_subscriber: Creating new user: ' . $username);
     228                        // wp_create_user(username, password, email)
     229                        $wp_user_id = wp_create_user($username, $password, $user_email);
     230                        if (is_wp_error($wp_user_id)) {
     231                                write_log('zlickpay_sync_subscriber: User creation failed: ' . $wp_user_id->get_error_message());
     232                                wp_die('User creation failed');
     233                        }
     234                        write_log('zlickpay_sync_subscriber: User created with ID: ' . $wp_user_id);
     235                       
     236                        // Set display name if provided
     237                        if (!empty($display_name)) {
     238                                wp_update_user(array(
     239                                        'ID' => $wp_user_id,
     240                                        'display_name' => $display_name,
     241                                        'nickname' => $display_name
     242                                ));
     243                        }
     244                }
     245               
     246                // Set role to subscriber
     247                if ($wp_user_id && !is_wp_error($wp_user_id)) {
     248                        $u = new WP_User($wp_user_id);
     249                        $u->set_role('subscriber');
     250                        write_log('zlickpay_sync_subscriber: Role set to subscriber');
     251                       
     252                        // Sign the user in
     253                        wp_signon(array('user_login' => $username, 'user_password' => $password), is_ssl());
     254                        write_log('zlickpay_sync_subscriber: User signed in');
     255                }
     256               
     257                wp_die('success');
     258        }
     259}
    145260
    146261function zlickpay_shortcode_resource()
    … …  
    737852    if (in_array(get_post_type(), $all_post_types)) {
    738853        if (!zlickpay_cookie_is_valid_subscription() && !zlickpay_cookie_is_purchased_article($post_id)) {
     854            $post_content = '';
    739855            if ($content_length === false) {
    740856                if ($other_content_length === false) {
    … …  
    744860                                                $pre_content = substr($content, 0, $content_length + strlen($needle_end));
    745861                                        }
     862                    $post_content = zlickpay_post_content($content, $is_block_editor);
    746863                } else {
    747864                    $pre_content = substr($content, 0, $other_content_length);
     865                    $post_content = substr($content, $other_content_length + strlen($other_needle));
    748866                }
    749867            } else {
    … …  
    751869                    $pre_content = substr($content, 0, $content_length);
    752870                }
     871                $post_content = substr($content, $content_length + strlen($needle));
    753872            }
    754             $post_content = zlickpay_post_content($content, $is_block_editor);
     873            $post_content = str_replace($needle, '', $post_content);
     874            $post_content = str_replace($other_needle, '', $post_content);
    755875            $content = $pre_content . do_shortcode("[zlick_payment_widget post_id=" . $post_id . "]") . $post_content;
    756876        }
    … …  
    763883add_filter("the_content", "zlickpay_limit_content", 12);
    764884add_action('wp_head', 'zlickpay_add_noarchive_meta');
     885
     886if (!function_exists('zlickpay_block_wprm_shortcodes')) {
     887        /**
     888         * Block WP Recipe Maker shortcodes outside the_content for unpaid users.
     889         *
     890         * @param string $output Shortcode output.
     891         * @param string $tag Shortcode tag.
     892         * @param array $attr Shortcode attributes.
     893         * @param array $m Regex matches.
     894         * @return string
     895         */
     896        function zlickpay_block_wprm_shortcodes($output, $tag, $attr, $m) {
     897                if ($tag !== 'wprm-recipe') {
     898                        return $output;
     899                }
     900
     901                // Let the_content handle paywall placement when marker is used.
     902                if (doing_filter('the_content')) {
     903                        return $output;
     904                }
     905
     906                $post_id = get_the_ID();
     907                if (empty($post_id)) {
     908                        return $output;
     909                }
     910
     911                $zp_custom_fields = get_post_custom($post_id);
     912                $is_monetized_via_category = is_monetized_with_article_pricing($post_id);
     913                if (((!isset($zp_custom_fields['zp_is_paid']) || $zp_custom_fields['zp_is_paid'][0] != 'paid') && !$is_monetized_via_category)) {
     914                        return $output;
     915                }
     916
     917                if (empty(zlickpay_get_options_data('zp_client_token'))) {
     918                        return $output;
     919                }
     920
     921                if (zlickpay_get_options_data('zp_search_engine_bypass') && zlickpay_is_search_engine()) {
     922                        return $output;
     923                }
     924
     925                if (zlickpay_cookie_is_valid_subscription() || zlickpay_cookie_is_purchased_article($post_id)) {
     926                        return $output;
     927                }
     928
     929                static $widget_rendered = false;
     930                if ($widget_rendered) {
     931                        return '';
     932                }
     933                $widget_rendered = true;
     934
     935                return do_shortcode("[zlick_payment_widget post_id=" . $post_id . "]");
     936        }
     937}
     938
     939add_filter('do_shortcode_tag', 'zlickpay_block_wprm_shortcodes', 10, 4);
    765940
    766941if (!function_exists('zlickpay_limit_feed_content')) {
    … …  
    814989
    815990                if (in_array(get_post_type(), $all_post_types)) {
     991                        $post_content = '';
    816992                        if ($content_length === false) {
    817993                                $para_count = zlickpay_get_options_data('zp_previewable_paras');
    … …  
    821997                                        $pre_content = substr($content, 0, $content_length + strlen($needle_end) );
    822998                                }
     999                                $post_content = zlickpay_post_content($content, $is_block_editor);
    8231000                        } else {
    8241001                                if (!zlickpay_show_zero_previewable_paras()) {
    8251002                                        $pre_content = substr($content, 0, $content_length );
    8261003                                }
    827                         }
    828                         $post_content = zlickpay_post_content($content, $is_block_editor);
     1004                                $post_content = substr($content, $content_length + strlen($needle));
     1005                        }
     1006                        $post_content = str_replace($needle, '', $post_content);
    8291007                        $content = $pre_content . do_shortcode("[zlick_payment_widget post_id=" . $post_id . "]") . $post_content;
    8301008                }
  • zlick-paywall/tags/4.0.9/zlick-payments.php

    r3417615 r3494567  
    1313 * Plugin URI:  https://zlick.it
    1414 * Description: Sell subscriptions and one-off access to your content with industry-leading conversion rates, a simple platform to operate, and no upfront costs.
    15  * Version:     4.0.8
     15 * Version:     4.0.9
    1616 * Author:      Zlick
    1717 * Author URI:  info@zlick.it
  • zlick-paywall/trunk/public/js/zlick-widget.js

    r3415349 r3494567  
    1616    if (match) return match[2];
    1717}
     18
     19// Store sync flag from onAuthenticated for use in onPaymentComplete
     20var _zp_sync_wp_users = false;
    1821
    1922function passSupportedParamsToWidget(zlickWidgetPurpose){
    … …  
    4245            }
    4346        vuePaywallElement.onAuthenticated = function (params) {
    44             console.log("access_info_signed: ", params);
    45             console.log(params.access_info_signed);
     47            console.log("onAuthenticated - params: ", params);
     48           
     49            // Store the sync flag for onPaymentComplete to use
     50            _zp_sync_wp_users = params.sync_wp_users_with_subscribers === true;
    4651            var post_data = {
    4752                'action': 'zp_authenticate_article',
    … …  
    7681                } else {
    7782                    return "something went wrong.";
    78             }
     83                }
    7984            }
    8085            xhr.send(xwwwfurlenc(post_data));
    … …  
    116121            xhr.send(xwwwfurlenc(post_data));
    117122        }
    118         vuePaywallElement.onPaymentComplete = function ({ data }) {
    119             // window._zp_delayed_reload = true;
     123        vuePaywallElement.onPaymentComplete = function (paymentData) {
     124            console.log("onPaymentComplete - paymentData: ", paymentData);
     125            console.log("onPaymentComplete - _zp_sync_wp_users: ", _zp_sync_wp_users);
     126           
     127            // Only sync if sync_wp_users_with_subscribers is enabled (set from onAuthenticated)
     128            if (!_zp_sync_wp_users) {
     129                console.log("onPaymentComplete - sync_wp_users_with_subscribers is false, skipping user creation");
     130                return;
     131            }
     132           
     133            // SDK passes { signed_payment_info: 'JWT', unsigned_payment_info: 'JSON' }
     134            var signedPaymentInfo = paymentData && paymentData.signed_payment_info ? paymentData.signed_payment_info : '';
     135            console.log("onPaymentComplete - signed_payment_info: ", signedPaymentInfo);
     136           
     137            if (!signedPaymentInfo) {
     138                console.log("onPaymentComplete - no signed_payment_info, skipping sync");
     139                return;
     140            }
     141           
     142            // Send the signed JWT to PHP for user creation
     143            var post_data = {
     144                'action': 'zp_sync_subscriber',
     145                'zp_nonce': zlick_payments_ajax.zp_ajax_nonce,
     146                'zp_signed_payment_info': signedPaymentInfo
     147            };
     148           
     149            var xhr = new XMLHttpRequest();
     150            var cacheBuster = 'zp_' + Math.random().toString(20).substr(2, 8);
     151            var url = zlick_payments_ajax.ajax_url + '?action=zp_sync_subscriber&' + cacheBuster + '=1';
     152            console.log("onPaymentComplete - sending to: ", url);
     153            xhr.withCredentials = true;
     154            xhr.open('POST', url, true);
     155            xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
     156            xhr.onreadystatechange = function() {
     157                if (xhr.readyState === 4) {
     158                    console.log("onPaymentComplete - response: ", xhr.responseText);
     159                }
     160            }
     161            xhr.send(xwwwfurlenc(post_data));
    120162        }
    121163        vuePaywallElement.onFailure = (data)=>{
  • zlick-paywall/trunk/public/shortcodes/zlick-widget.php

    r3417615 r3494567  
    142142add_action('wp_ajax_nopriv_zp_access_expired', 'zlickpay_access_expired');
    143143
    144 
     144/**
     145 * Register Ajax callback for syncing Zlick subscribers to WordPress users
     146 */
     147add_action('wp_ajax_zp_sync_subscriber', 'zlickpay_sync_subscriber');
     148add_action('wp_ajax_nopriv_zp_sync_subscriber', 'zlickpay_sync_subscriber');
     149
     150/**
     151 * Create/sync WordPress user from Zlick subscriber data (called from onPaymentComplete)
     152 */
     153if (!function_exists('zlickpay_sync_subscriber')) {
     154        function zlickpay_sync_subscriber() {
     155                // Check for nonce security
     156                if (!isset($_POST['zp_nonce']) || !wp_verify_nonce($_POST['zp_nonce'], 'zp-ajax-nonce')) {
     157                        write_log('zlickpay_sync_subscriber: Nonce verification failed');
     158                        wp_die('Nonce verification failed');
     159                }
     160               
     161                $zp_signed_payment_info = sanitize_text_field($_POST['zp_signed_payment_info']);
     162               
     163                if (empty($zp_signed_payment_info)) {
     164                        write_log('zlickpay_sync_subscriber: No signed payment info received');
     165                        wp_die('No payment info');
     166                }
     167               
     168                // Decode the JWT using existing function
     169                $payload = json_decode(zlickpay_get_jwt_payload($zp_signed_payment_info), true);
     170                write_log('zlickpay_sync_subscriber: Decoded payload: ' . json_encode($payload));
     171               
     172                if (empty($payload) || !isset($payload['userId']) || !isset($payload['subscriptionId']) || !isset($payload['subscribedPricePlan'])) {
     173                        write_log('zlickpay_sync_subscriber: Missing required fields in payload');
     174                        wp_die('Missing required fields');
     175                }
     176               
     177                // Extract contact field (can be email or other identifier like phone)
     178                $contact = isset($payload['contact']) ? sanitize_text_field($payload['contact']) : '';
     179                $user_email = '';
     180                $display_name = '';
     181               
     182                // Check if contact is an email
     183                if (!empty($contact) && is_email($contact)) {
     184                        // Contact is an email - use email as username and display name
     185                        $username = sanitize_user($contact, true); // sanitize for use as username
     186                        $user_email = $contact;
     187                        $display_name = $contact;
     188                        write_log('zlickpay_sync_subscriber: Contact is email, using as username: ' . $username);
     189                } elseif (!empty($contact)) {
     190                        // Contact is not an email (e.g., phone) - use as username directly
     191                        $username = sanitize_user($contact);
     192                        $display_name = $contact;
     193                        write_log('zlickpay_sync_subscriber: Contact (phone) used as username: ' . $username);
     194                } else {
     195                        // No contact - use userId as before
     196                        $username = $payload['userId'] . '_' . $payload['subscribedPricePlan'];
     197                        write_log('zlickpay_sync_subscriber: No contact, using userId: ' . $username);
     198                }
     199               
     200                $password = $payload['subscriptionId'];
     201               
     202                write_log('zlickpay_sync_subscriber: Creating user with username: ' . $username . ', email: ' . $user_email);
     203               
     204                // Clear any existing logged in user
     205                if (is_user_logged_in()) {
     206                        wp_logout();
     207                }
     208               
     209                $user = get_user_by('login', $username);
     210                if ($user) {
     211                        write_log('zlickpay_sync_subscriber: User already exists, updating: ' . $username);
     212                        $wp_user_id = $user->ID;
     213                        wp_set_password($password, $wp_user_id);
     214                        // Update email and display name if provided
     215                        $update_data = array('ID' => $wp_user_id);
     216                        if (!empty($user_email)) {
     217                                $update_data['user_email'] = $user_email;
     218                        }
     219                        if (!empty($display_name)) {
     220                                $update_data['display_name'] = $display_name;
     221                                $update_data['nickname'] = $display_name;
     222                        }
     223                        if (count($update_data) > 1) {
     224                                wp_update_user($update_data);
     225                        }
     226                } else {
     227                        write_log('zlickpay_sync_subscriber: Creating new user: ' . $username);
     228                        // wp_create_user(username, password, email)
     229                        $wp_user_id = wp_create_user($username, $password, $user_email);
     230                        if (is_wp_error($wp_user_id)) {
     231                                write_log('zlickpay_sync_subscriber: User creation failed: ' . $wp_user_id->get_error_message());
     232                                wp_die('User creation failed');
     233                        }
     234                        write_log('zlickpay_sync_subscriber: User created with ID: ' . $wp_user_id);
     235                       
     236                        // Set display name if provided
     237                        if (!empty($display_name)) {
     238                                wp_update_user(array(
     239                                        'ID' => $wp_user_id,
     240                                        'display_name' => $display_name,
     241                                        'nickname' => $display_name
     242                                ));
     243                        }
     244                }
     245               
     246                // Set role to subscriber
     247                if ($wp_user_id && !is_wp_error($wp_user_id)) {
     248                        $u = new WP_User($wp_user_id);
     249                        $u->set_role('subscriber');
     250                        write_log('zlickpay_sync_subscriber: Role set to subscriber');
     251                       
     252                        // Sign the user in
     253                        wp_signon(array('user_login' => $username, 'user_password' => $password), is_ssl());
     254                        write_log('zlickpay_sync_subscriber: User signed in');
     255                }
     256               
     257                wp_die('success');
     258        }
     259}
    145260
    146261function zlickpay_shortcode_resource()
    … …  
    737852    if (in_array(get_post_type(), $all_post_types)) {
    738853        if (!zlickpay_cookie_is_valid_subscription() && !zlickpay_cookie_is_purchased_article($post_id)) {
     854            $post_content = '';
    739855            if ($content_length === false) {
    740856                if ($other_content_length === false) {
    … …  
    744860                                                $pre_content = substr($content, 0, $content_length + strlen($needle_end));
    745861                                        }
     862                    $post_content = zlickpay_post_content($content, $is_block_editor);
    746863                } else {
    747864                    $pre_content = substr($content, 0, $other_content_length);
     865                    $post_content = substr($content, $other_content_length + strlen($other_needle));
    748866                }
    749867            } else {
    … …  
    751869                    $pre_content = substr($content, 0, $content_length);
    752870                }
     871                $post_content = substr($content, $content_length + strlen($needle));
    753872            }
    754             $post_content = zlickpay_post_content($content, $is_block_editor);
     873            $post_content = str_replace($needle, '', $post_content);
     874            $post_content = str_replace($other_needle, '', $post_content);
    755875            $content = $pre_content . do_shortcode("[zlick_payment_widget post_id=" . $post_id . "]") . $post_content;
    756876        }
    … …  
    763883add_filter("the_content", "zlickpay_limit_content", 12);
    764884add_action('wp_head', 'zlickpay_add_noarchive_meta');
     885
     886if (!function_exists('zlickpay_block_wprm_shortcodes')) {
     887        /**
     888         * Block WP Recipe Maker shortcodes outside the_content for unpaid users.
     889         *
     890         * @param string $output Shortcode output.
     891         * @param string $tag Shortcode tag.
     892         * @param array $attr Shortcode attributes.
     893         * @param array $m Regex matches.
     894         * @return string
     895         */
     896        function zlickpay_block_wprm_shortcodes($output, $tag, $attr, $m) {
     897                if ($tag !== 'wprm-recipe') {
     898                        return $output;
     899                }
     900
     901                // Let the_content handle paywall placement when marker is used.
     902                if (doing_filter('the_content')) {
     903                        return $output;
     904                }
     905
     906                $post_id = get_the_ID();
     907                if (empty($post_id)) {
     908                        return $output;
     909                }
     910
     911                $zp_custom_fields = get_post_custom($post_id);
     912                $is_monetized_via_category = is_monetized_with_article_pricing($post_id);
     913                if (((!isset($zp_custom_fields['zp_is_paid']) || $zp_custom_fields['zp_is_paid'][0] != 'paid') && !$is_monetized_via_category)) {
     914                        return $output;
     915                }
     916
     917                if (empty(zlickpay_get_options_data('zp_client_token'))) {
     918                        return $output;
     919                }
     920
     921                if (zlickpay_get_options_data('zp_search_engine_bypass') && zlickpay_is_search_engine()) {
     922                        return $output;
     923                }
     924
     925                if (zlickpay_cookie_is_valid_subscription() || zlickpay_cookie_is_purchased_article($post_id)) {
     926                        return $output;
     927                }
     928
     929                static $widget_rendered = false;
     930                if ($widget_rendered) {
     931                        return '';
     932                }
     933                $widget_rendered = true;
     934
     935                return do_shortcode("[zlick_payment_widget post_id=" . $post_id . "]");
     936        }
     937}
     938
     939add_filter('do_shortcode_tag', 'zlickpay_block_wprm_shortcodes', 10, 4);
    765940
    766941if (!function_exists('zlickpay_limit_feed_content')) {
    … …  
    814989
    815990                if (in_array(get_post_type(), $all_post_types)) {
     991                        $post_content = '';
    816992                        if ($content_length === false) {
    817993                                $para_count = zlickpay_get_options_data('zp_previewable_paras');
    … …  
    821997                                        $pre_content = substr($content, 0, $content_length + strlen($needle_end) );
    822998                                }
     999                                $post_content = zlickpay_post_content($content, $is_block_editor);
    8231000                        } else {
    8241001                                if (!zlickpay_show_zero_previewable_paras()) {
    8251002                                        $pre_content = substr($content, 0, $content_length );
    8261003                                }
    827                         }
    828                         $post_content = zlickpay_post_content($content, $is_block_editor);
     1004                                $post_content = substr($content, $content_length + strlen($needle));
     1005                        }
     1006                        $post_content = str_replace($needle, '', $post_content);
    8291007                        $content = $pre_content . do_shortcode("[zlick_payment_widget post_id=" . $post_id . "]") . $post_content;
    8301008                }
  • zlick-paywall/trunk/zlick-payments.php

    r3417615 r3494567  
    1313 * Plugin URI:  https://zlick.it
    1414 * Description: Sell subscriptions and one-off access to your content with industry-leading conversion rates, a simple platform to operate, and no upfront costs.
    15  * Version:     4.0.8
     15 * Version:     4.0.9
    1616 * Author:      Zlick
    1717 * Author URI:  info@zlick.it
Note: See TracChangeset for help on using the changeset viewer.