Plugin Directory

Changeset 3208372


Ignore:
Timestamp:
12/16/2024 07:53:22 AM (15 months ago)
Author:
lehelm
Message:

Update to 2.0.2

Location:
terms-popup-on-user-login
Files:
339 added
15 edited

Legend:

Unmodified
Added
Removed
  • terms-popup-on-user-login/trunk/README.txt

    r3204527 r3208372  
    66Tested up to: 6.7.1
    77Requires PHP: 7.4
    8 Stable tag: 2.0.1
     8Stable tag: 2.0.2
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    233233== Changelog ==
    234234
     235= 2.0.2 =
     236Fix always show popup bug.
     237
    235238= 2.0.1 =
    236239Redo UUID generation, revert dependencies to php 7.x
  • terms-popup-on-user-login/trunk/admin/class-terms-popup-on-user-login-plugin-settings.php

    r3199813 r3208372  
    157157        );
    158158
     159        add_settings_field(
     160            'tplu_license_key',
     161            __('Enter License Key', 'terms-popup-on-user-login'),
     162            array($this, 'tplu_license_key_render'),
     163            'tpul_settings_general_options',
     164            'tpul_general_section'
     165        );
     166
    159167        /**
    160168         * Add option to Section
     
    176184        //     'tpul_general_section'
    177185        // );
    178 
    179         add_settings_field(
    180             'tplu_license_key',
    181             __('Enter License Key', 'terms-popup-on-user-login'),
    182             array($this, 'tplu_license_key_render'),
    183             'tpul_settings_general_options',
    184             'tpul_general_section'
    185         );
    186186
    187187        /**
     
    832832        );
    833833
    834         add_settings_field(
    835             'terms_modal_woo_log_out_user',
    836             __('Decline button redirect', 'terms-popup-on-user-login'),
    837             array($this, 'terms_modal_woo_log_out_user_render'),
    838             'tpul_settings_term_modal_woo_options',
    839             'tpul_term_modal_woo_section'
    840         );
    841834
    842835        add_settings_field(
     
    12541247                                </tr>
    12551248                                <tr>
     1249                                    <th scope="row"><?php echo __('Your Settings Export'); ?></th>
     1250                                    <td>
     1251                                        <?php
     1252                                        // JSON format export of all plugin settings
     1253                                        $modal_option = new TPUL_Modal_Options();
     1254                                        $display_option = new TPUL_Display_Options();
     1255                                        $woo_option = new TPUL_Woo_Options();
     1256                                        $email_option = new TPUL_Email_Options();
     1257                                        $license_option = new TPUL_License_Options();
     1258
     1259                                        $modal_options = $modal_option->export_all_settings();
     1260                                        $display_options = $display_option->export_all_settings();
     1261                                        $woo_options = $woo_option->export_all_settings();
     1262                                        $email_options = $email_option->export_all_settings();
     1263
     1264                                        $all_options = json_encode(array(
     1265                                            'php_version' => phpversion(),
     1266                                            'wp_version' => get_bloginfo('version'),
     1267                                            'curl_version' => function_exists('curl_version') ? curl_version()["version"] : 'cURL is not installed',
     1268                                            'TPUL_License_Options' => $license_option->get_options(),
     1269                                            'TPUL_Modal_Options' => $modal_options,
     1270                                            'TPUL_Display_Options' => $display_options,
     1271                                            'TPUL_Woo_Options' => $woo_options,
     1272                                            'TPUL_Email_Options' => $email_options
     1273                                        ), JSON_PRETTY_PRINT);
     1274
     1275                                        // preformat modal options
     1276                                        echo __('Copy and paste the following JSON in your support request email to share your settings.', 'terms-popup-on-user-login');
     1277                                        echo "<br><br>";
     1278                                        echo "<textarea style='width: 100%; height: 400px;'>";
     1279                                        echo  $all_options;
     1280                                        echo "</textarea>";
     1281
     1282                                        ?>
     1283                                        <p class="description">
     1284                                        </p>
     1285                                    </td>
     1286                                </tr>
     1287                                <tr>
    12561288                                    <th scope="row"><?php echo __('Propose a feature'); ?></th>
    12571289                                    <td>
     
    14961528                                    </td>
    14971529                                </tr>
     1530
    14981531
    14991532                            </tbody>
     
    23952428                                            $select_options_array = [
    23962429                                                'none' => [
    2397                                                     'value' => '',
     2430                                                    'value' => 'keep_user_logged_in',
    23982431                                                    'label' => __('Redirect and keep user logged in', 'terms-popup-on-user-login'),
    23992432                                                    'with_license_key_only' => false
  • terms-popup-on-user-login/trunk/includes/class-terms-popup-on-user-login-modal-visibility-manger.php

    r3199813 r3208372  
    223223
    224224            error_log("terms_and_conditions_modal_test -- Reason: TEST mode is on.");
    225             error_log("returningtrue!");
    226225            return true;
    227226        }
  • terms-popup-on-user-login/trunk/includes/class-terms-popup-on-user-login.php

    r3199813 r3208372  
    115115        require_once plugin_dir_path(dirname(__FILE__)) . 'service/terms-reset-service.php';
    116116        require_once plugin_dir_path(dirname(__FILE__)) . 'service/terms-apisettings-service.php';
     117        require_once plugin_dir_path(dirname(__FILE__)) . 'service/terms-userstate-migrate-service.php';
    117118
    118119
  • terms-popup-on-user-login/trunk/includes/db/class-terms-user-state-model.php

    r3202934 r3208372  
    6161
    6262        $this->user_id = (isset($userstate['user_id'])) ? $userstate['user_id'] : get_current_user_id();
    63         $this->user_name = (isset($userstate['user_name'])) ? $userstate['user_name'] : get_user_by('id', $this->user_id)->user_login;
    64         $this->user_displayname = (isset($userstate['user_displayname'])) ? $userstate['user_displayname'] : get_user_by('id', $this->user_id)->display_name;
    65         $this->user_first_name = (isset($userstate['user_first_name'])) ? $userstate['user_first_name'] : get_user_meta($this->user_id, 'first_name', true);;
    66         $this->user_last_name = (isset($userstate['user_last_name'])) ? $userstate['user_last_name'] : get_user_meta($this->user_id, 'last_name', true);;
     63        $user = get_user_by('id', $this->user_id);
     64        $this->user_name = (isset($userstate['user_name'])) ? $userstate['user_name'] : ($user ? $user->user_login : '');
     65        $this->user_displayname = (isset($userstate['user_displayname'])) ? $userstate['user_displayname'] : ($user ? $user->display_name : '');
     66        $this->user_first_name = (isset($userstate['user_first_name'])) ? $userstate['user_first_name'] : get_user_meta($this->user_id, 'first_name', true);
     67        $this->user_last_name = (isset($userstate['user_last_name'])) ? $userstate['user_last_name'] : get_user_meta($this->user_id, 'last_name', true);
    6768        $this->user_action = (isset($userstate['user_action'])) ? $userstate['user_action'] : '';
    6869        $this->user_action_code = (isset($userstate['user_action_code'])) ? $userstate['user_action_code'] : 0;
     
    205206
    206207    public function setUserActionCodeForSession($user_action_code_for_session) {
    207         $accepted_values = array(2, -2, 0, 1, -1);
     208        $accepted_values = array(1, 0, -1);
    208209        if (!in_array($user_action_code_for_session, $accepted_values)) {
    209210            throw new Exception('Invalid user action code for session');
     
    364365    public function setActionAcceptedTermsForSession() {
    365366        $this->user_action_for_session = 'Accepted Terms';
    366         $this->setUserActionCodeForSession(2);
     367        $this->setUserActionCodeForSession(1);
    367368    }
    368369
     
    376377    public function setActionDeclinedTermsForSession() {
    377378        $this->user_action_for_session = 'Declined Terms';
    378         $this->setUserActionCodeForSession(-2);
     379        $this->setUserActionCodeForSession(-1);
    379380    }
    380381
  • terms-popup-on-user-login/trunk/includes/lhl-admin-ui/class-lhl-admin-ui.php

    r3036610 r3208372  
    107107
    108108        echo "<select name='{$selectbox_name}'{$disabled_attribute}>";
     109
     110        // Check if the key exists in the options array
     111        $selected_value = isset($options[$options_id]) ? $options[$options_id] : '';
     112
    109113        foreach ($select_options_array as $option_item) {
    110114
     
    114118            }
    115119
    116             echo '<option value="' . $option_item['value'] . '" ' . selected($option_item['value'], $options[$options_id]) . " {$is_disabled_sub_option}>" . $option_item['label'] . '</option>';
     120            echo '<option value="' . $option_item['value'] . '" ' . selected($option_item['value'], $selected_value, false) . " {$is_disabled_sub_option}>" . $option_item['label'] . '</option>';
    117121        }
    118122        echo "</select>";
  • terms-popup-on-user-login/trunk/includes/models/class-display-options.php

    r2781131 r3208372  
    11<?php
    22
    3 class TPUL_Display_Options{
     3class TPUL_Display_Options {
    44
    55    private $options = false;
     
    88    private $defaults = array(
    99
    10         'terms_modal_width'                    =>   '',
    11         'terms_modal_height'                   =>   '',
     10        'terms_modal_width'                    =>    '',
     11        'terms_modal_height'                    =>    '',
    1212
    13         'terms_modal_border_rnd'               =>   '',
    14         'terms_modal_btn_border_rnd'           =>   '',
     13        'terms_modal_border_rnd'               =>    '',
     14        'terms_modal_btn_border_rnd'           =>    '',
    1515
    16         'terms_modal_acc_btn_size'             =>   '',
    17         'terms_modal_acc_btn_color'            =>   '',
    18         'terms_modal_acc_btn_txt_color'        =>   '',
     16        'terms_modal_acc_btn_size'               =>    '',
     17        'terms_modal_acc_btn_color'               =>    '',
     18        'terms_modal_acc_btn_txt_color'           =>    '',
    1919
    20         'terms_modal_dec_btn_size'             =>   '',
    21         'terms_modal_dec_btn_color'            =>   '',
    22         'terms_modal_dec_btn_txt_color'        =>   '',
     20        'terms_modal_dec_btn_size'               =>    '',
     21        'terms_modal_dec_btn_color'            =>    '',
     22        'terms_modal_dec_btn_txt_color'           =>    '',
    2323
    2424    );
    2525
    26     public function __construct() {     
    27         $this->options = get_option( $this->options_name );
     26    public function __construct() {
     27        $this->options = get_option($this->options_name);
    2828    }
    2929
     
    3232    }
    3333
    34     public function get_options(){
    35         if( false ==  $this->options) {           
     34    public function get_options() {
     35        if (false ==  $this->options) {
    3636            return $this->default_options();
    3737        }
     
    3939    }
    4040
    41 
     41    public function export_all_settings() {
     42        // return all the atributes
     43        $export = $this->options;
     44        return $export;
     45    }
    4246}
  • terms-popup-on-user-login/trunk/includes/models/class-email-options.php

    r3140681 r3208372  
    6868        return $this->defaults[$option];
    6969    }
     70
     71    public function export_all_settings() {
     72        // return all the atributes
     73        $export = $this->options;
     74        return $export;
     75    }
    7076}
  • terms-popup-on-user-login/trunk/includes/models/class-modal-options.php

    r3199813 r3208372  
    131131    }
    132132
     133    public function is_show_on_every_login() {
     134        if (!empty($this->options['terms_modal_show_every_login'])) {
     135            return true;
     136        }
     137        return false;
     138    }
     139
    133140    public function get_options() {
    134141        if (false ==  $this->options) {
     
    136143        }
    137144        return $this->options;
     145    }
     146
     147    public function export_all_settings() {
     148        // return all the atributes
     149        $export = $this->options;
     150        return $export;
    138151    }
    139152
  • terms-popup-on-user-login/trunk/includes/models/class-user-action-handler.php

    r3199813 r3208372  
    136136            return 0;
    137137        }
    138         return $this->user_state_model->getUserActionCode();
    139     }
     138        return $this->user_state_model->getUserActionCodeForSession();
     139    }
     140    public function did_user_acc_for_this_session() {
     141        $this_session_action = $this->get_user_acc_for_this_session();
     142
     143        if (empty($this_session_action)) {
     144            return 0;
     145        }
     146
     147        if ($this_session_action == 1) {
     148            return 1;
     149        }
     150        return 0;
     151    }
     152
    140153    public function did_user_take_action_this_session() {
    141154        $this_session_action = $this->get_user_acc_for_this_session();
     
    349362    }
    350363
     364    public function get_terms_accepted_timestamp() {
     365        if (empty($this->user_state_model)) {
     366            return -1;
     367        }
     368        if ($this->user_state_model->getUserActionCode() == 2) {
     369            return $this->user_state_model->getTimestampLastAction();
     370        }
     371        return 0;
     372    }
    351373
    352374    /**
  • terms-popup-on-user-login/trunk/includes/models/class-woo-options.php

    r3163261 r3208372  
    6060    }
    6161
     62    public function export_all_settings() {
     63        // return all the atributes
     64        $export = $this->options;
     65        return $export;
     66    }
     67
    6268    public function get_user_type() {
    6369        return $this->options['terms_modal_woo_display_user_type'];
  • terms-popup-on-user-login/trunk/public/js/terms-popup-on-user-login-framework.js

    r3199813 r3208372  
    245245    }
    246246
     247    function __getUserAccepted() {
     248        if (
     249            typeof tpulApiSettings !== "undefined" &&
     250            typeof tpulApiSettings.user_accepted !== "undefined"
     251        ) {
     252            return tpulApiSettings.user_accepted;
     253        }
     254        return 0;
     255    }
     256
     257    function __getUserSessionAccepted() {
     258        if (
     259            typeof tpulApiSettings !== "undefined" &&
     260            typeof tpulApiSettings.user_session_accepted !== "undefined"
     261        ) {
     262            return tpulApiSettings.user_session_accepted;
     263        }
     264        return 0;
     265    }
     266
     267    function __getUserTermsAcceptedTimestamp() {
     268        if (
     269            typeof tpulApiSettings !== "undefined" &&
     270            typeof tpulApiSettings.user_terms_accepted_timestamp !== "undefined"
     271        ) {
     272            return tpulApiSettings.user_terms_accepted_timestamp;
     273        }
     274        return 0;
     275    }
     276
    247277    function __getGeolocation() {
    248278        if (window.tpul_GeoLocationResult) {
     
    312342    window.TPUL.__isTestMode = __isTestMode;
    313343    window.TPUL.__isLoginPage = __isLoginPage;
    314     window.TPUL.__isUserLoggedIn = __isUserLoggedIn;
    315344    window.TPUL.__isPopupSavesCookie = __isPopupSavesCookie;
    316345    window.TPUL.__shouldPopupCheckCookie = __shouldPopupCheckCookie;
     346    // User
     347    window.TPUL.__isUserLoggedIn = __isUserLoggedIn;
     348    window.TPUL.__getUserAccepted = __getUserAccepted;
     349    window.TPUL.__getUserSessionAccepted = __getUserSessionAccepted;
     350    window.TPUL.__getUserTermsAcceptedTimestamp = __getUserTermsAcceptedTimestamp;
    317351    // GeoLocation
    318352    window.TPUL.__isGeoLocationTrackingEnabled = __isGeoLocationTrackingEnabled;
  • terms-popup-on-user-login/trunk/service/class-terms-popup-userstate-serivce.php

    r3199813 r3208372  
    7070     * Fetch user record for current content hash and version
    7171     */
    72 
    7372    public static function fetch_user_record_for_current_content_hash_and_version($user_id) {
    7473        $current_terms_content_hash = TPUL_Terms_Content_Service::get_default_terms_content_hash();
    7574        $current_version = TPUL_Terms_Content_Service::get_default_terms_content_version();
     75
    7676        $user_record = self::fetch_user_record_for_content_hashand_and_version($user_id, $current_terms_content_hash, $current_version);
    7777        return $user_record;
     
    218218            return false;
    219219        }
    220 
     220        // Go into every record found and clear their session
    221221        foreach ($user_records as $key => $record) {
    222222            $user_state_model = TPUL_Terms_User_State_Model::from_object($record);
    223223            $user_state_model->clearSession();
    224224            $user_state_DB->update($user_state_model->to_array(), array('userstate_primary_key' => $user_state_model->userstate_primary_key));
     225            // error_log('Clearing session for record: ' . print_r($record, true));
    225226        }
    226227        return null;
  • terms-popup-on-user-login/trunk/service/terms-apisettings-service.php

    r3199813 r3208372  
    6565        }
    6666
     67        /**
     68         * Get user state
     69         */
     70        $user_id = get_current_user_id();
     71        $userState = new TPUL_User_State($user_id);
     72
     73        /**
     74         * Did user accept for this session
     75         */
     76        $did_user_accept = 0;
     77
     78
    6779        return array(
    6880            'root' => esc_url_raw(rest_url()),
     81            'tpul_time' => time(),
    6982            'tpul_geolocation' => ($this->gen_options->get_track_location()) ? 1 : '',
    7083            'tpul_last_reset_ran' => $this->last_reset_ran,
    7184            'user_is_logged_in' => (is_user_logged_in()) ? 1 : 0,
     85            'user_accepted' => ($userState->did_accept_latest_terms()) ? 1 : 0,
     86            'user_session_accepted' => $userState->did_user_acc_for_this_session(),
     87            'user_terms_accepted_timestamp' => $userState->get_terms_accepted_timestamp(),
    7288            'popup_saves_cookie' => $this->should_save_cookie,
    7389            'popup_check_cookie' => $should_check_cookie,
  • terms-popup-on-user-login/trunk/terms-popup-on-user-login.php

    r3202934 r3208372  
    1717 * Plugin URI:        https://www.lehelmatyus.com/wp-plugins/terms-popup-on-user-login
    1818 * Description:       Creates a popup with a scrollable window that will show your own custom Terms and Conditions when users logs in to your website
    19  * Version:           2.0.1
     19 * Version:           2.0.2
    2020 * Author:            Lehel Matyus
    2121 * Author URI:        https://www.lehelmatyus.com
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define('TERMS_POPUP_ON_USER_LOGIN_VERSION', '2.0.1');
     38define('TERMS_POPUP_ON_USER_LOGIN_VERSION', '2.0.2');
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.