Plugin Directory

Changeset 3204245


Ignore:
Timestamp:
12/08/2024 02:35:21 AM (15 months ago)
Author:
odude
Message:

Update to version 2.22 from GitHub

Location:
crypto
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • crypto/tags/2.22/README.txt

    r3204035 r3204245  
    66Requires PHP: 5.5
    77Tested up to: 6.6.2
    8 Stable tag: 2.21
     8Stable tag: 2.22
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • crypto/tags/2.22/crypto.php

    r3204035 r3204245  
    1010 *
    1111 * @link              https://odude.com/
    12  * @since             2.21
     12 * @since             2.22
    1313 * @package           Crypto
    1414 *
     
    1717 * Plugin URI:        http://odude.com/
    1818 * Description:       Crypto - Price widget, Metamask Login, Block content.
    19  * Version:           2.21
     19 * Version:           2.22
    2020 * Author:            ODude
    2121 * Author URI:        https://odude.com/
     
    3131}
    3232
    33 define('CRYPTO_VERSION', '2.21');
     33define('CRYPTO_VERSION', '2.22');
    3434define('CRYPTO_FOLDER', dirname(plugin_basename(__FILE__)));
    3535define('CRYPTO_PLUGIN_URL', content_url('/plugins/' . CRYPTO_FOLDER));
  • crypto/tags/2.22/includes/class-crypto-user.php

    r3204035 r3204245  
    99        add_action("wp_ajax_nopriv_crypto_connect_ajax_process", array($this, "crypto_connect_ajax_process"));
    1010    }
    11 
    1211
    1312    /**
     
    5049        // Check if the insertion was successful
    5150        if ($inserted) {
    52             // Start the session if not already started
    53             if (!session_id()) {
    54                 session_start();
    55             }
    56 
    57             // Set session variable for user login
    58             $_SESSION['custom_user'] = $user_login;
     51
     52            // Set transient for user login
     53            set_transient('custom_user', $user_login, HOUR_IN_SECONDS);
    5954
    6055            // Trigger WordPress action for custom user registration
     
    9792        }
    9893
    99         // Start the session if not already started
    100         if (!session_id()) {
    101             session_start();
    102         }
    103 
    104         // Set session variable for user login
    105         $_SESSION['custom_user'] = $user_login;
     94        // Set transient for user login
     95        set_transient('custom_user', $user_login, HOUR_IN_SECONDS);
    10696
    10797        // Trigger WordPress action for custom user login
     
    119109    {
    120110        // Check if the user is logged in
    121         if (!isset($_SESSION['custom_user'])) {
     111        if (!self::if_custom_user_logged_in()) {
    122112            return false; // No user logged in
    123113        }
    124114
    125         // Get the wallet address from the session
    126         $user_login = sanitize_text_field($_SESSION['custom_user']);
    127 
    128         // Clear the session
    129         unset($_SESSION['custom_user']);
     115        // Delete the transient
     116        delete_transient('custom_user');
    130117
    131118        // Trigger WordPress action for custom user logout
    132         do_action('custom_user_logged_out', $user_login);
     119        do_action('custom_user_logged_out');
    133120
    134121        return true; // Successfully logged out
     
    142129    public static function if_custom_user_logged_in()
    143130    {
    144         // Start the session if it's not already started
    145         if (!session_id()) {
    146             session_start();
    147         }
    148 
    149         // Check if the custom user is logged in via session
    150         if (isset($_SESSION['custom_user']) && !empty($_SESSION['custom_user'])) {
     131        // Check if the custom user is logged in via transient
     132        if (get_transient('custom_user')) {
    151133            return true; // User is logged in
    152134        }
    153135
    154136        return false; // User is not logged in
     137    }
     138
     139    /**
     140     * Get the currently logged-in custom user login.
     141     *
     142     * @return string|bool The user login if logged in, false otherwise.
     143     */
     144    public static function get_current_custom_user_login()
     145    {
     146        // Retrieve the user login from the transient
     147        $user_login = get_transient('custom_user');
     148
     149        if ($user_login) {
     150            return sanitize_text_field($user_login);
     151        }
     152
     153        return false; // No custom user is logged in
    155154    }
    156155
     
    180179    }
    181180
    182     // Function to set custom user status (like user_status or user_block)
     181    /**
     182     * Set a custom value for a user (like user_status or user_block).
     183     *
     184     * @param string $user_login The username (wallet address).
     185     * @param string $column The column name to update.
     186     * @param mixed $value The value to set.
     187     * @return bool True on success, false on failure.
     188     */
    183189    public static function set_custom_user_value($user_login, $column, $value)
    184190    {
     
    222228    }
    223229
    224 
    225 
    226     // Function to get custom user status (like user_status or user_block)
     230    /**
     231     * Get a custom value for a user (like user_status or user_block).
     232     *
     233     * @param string $user_login The username (wallet address).
     234     * @param string $column The column name to retrieve.
     235     * @return mixed The value on success, false on failure.
     236     */
    227237    public static function get_custom_user_value($user_login, $column)
    228238    {
     
    255265        return false; // No value found (user doesn't exist or column is invalid)
    256266    }
    257 
    258     public static function get_current_custom_user_login()
    259     {
    260         // Start the session if not already started
    261         if (!session_id()) {
    262             session_start();
    263         }
    264 
    265         // Check if a custom user is logged in
    266         if (isset($_SESSION['custom_user']) && !empty($_SESSION['custom_user'])) {
    267             // Sanitize and return the user_login stored in the session
    268             return sanitize_text_field($_SESSION['custom_user']);
    269         }
    270 
    271         return false; // No custom user is logged in
    272     }
    273267}
  • crypto/tags/2.22/includes/class-crypto_connect_ajax_register.php

    r3204035 r3204245  
    150150    public function add_custom_user_logged_in_class($classes)
    151151    {
    152         // Check if the custom user is logged in
    153         if (isset($_SESSION['custom_user']) && !empty($_SESSION['custom_user'])) {
    154             // Add a class to the body tag
     152        // Check if the custom user is logged in using a transient
     153        if (get_transient('custom_user')) {
     154            // Add a class to the body tag for logged-in users
    155155            $classes[] = 'custom-user-logged-in';
    156156        } else {
    157             // Remove the class from the body tag
     157            // Add a class to the body tag for logged-out users
    158158            $classes[] = 'custom-user-logged-out';
    159159        }
  • crypto/trunk/README.txt

    r3204035 r3204245  
    66Requires PHP: 5.5
    77Tested up to: 6.6.2
    8 Stable tag: 2.21
     8Stable tag: 2.22
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • crypto/trunk/crypto.php

    r3204035 r3204245  
    1010 *
    1111 * @link              https://odude.com/
    12  * @since             2.21
     12 * @since             2.22
    1313 * @package           Crypto
    1414 *
     
    1717 * Plugin URI:        http://odude.com/
    1818 * Description:       Crypto - Price widget, Metamask Login, Block content.
    19  * Version:           2.21
     19 * Version:           2.22
    2020 * Author:            ODude
    2121 * Author URI:        https://odude.com/
     
    3131}
    3232
    33 define('CRYPTO_VERSION', '2.21');
     33define('CRYPTO_VERSION', '2.22');
    3434define('CRYPTO_FOLDER', dirname(plugin_basename(__FILE__)));
    3535define('CRYPTO_PLUGIN_URL', content_url('/plugins/' . CRYPTO_FOLDER));
  • crypto/trunk/includes/class-crypto-user.php

    r3204035 r3204245  
    99        add_action("wp_ajax_nopriv_crypto_connect_ajax_process", array($this, "crypto_connect_ajax_process"));
    1010    }
    11 
    1211
    1312    /**
     
    5049        // Check if the insertion was successful
    5150        if ($inserted) {
    52             // Start the session if not already started
    53             if (!session_id()) {
    54                 session_start();
    55             }
    56 
    57             // Set session variable for user login
    58             $_SESSION['custom_user'] = $user_login;
     51
     52            // Set transient for user login
     53            set_transient('custom_user', $user_login, HOUR_IN_SECONDS);
    5954
    6055            // Trigger WordPress action for custom user registration
     
    9792        }
    9893
    99         // Start the session if not already started
    100         if (!session_id()) {
    101             session_start();
    102         }
    103 
    104         // Set session variable for user login
    105         $_SESSION['custom_user'] = $user_login;
     94        // Set transient for user login
     95        set_transient('custom_user', $user_login, HOUR_IN_SECONDS);
    10696
    10797        // Trigger WordPress action for custom user login
     
    119109    {
    120110        // Check if the user is logged in
    121         if (!isset($_SESSION['custom_user'])) {
     111        if (!self::if_custom_user_logged_in()) {
    122112            return false; // No user logged in
    123113        }
    124114
    125         // Get the wallet address from the session
    126         $user_login = sanitize_text_field($_SESSION['custom_user']);
    127 
    128         // Clear the session
    129         unset($_SESSION['custom_user']);
     115        // Delete the transient
     116        delete_transient('custom_user');
    130117
    131118        // Trigger WordPress action for custom user logout
    132         do_action('custom_user_logged_out', $user_login);
     119        do_action('custom_user_logged_out');
    133120
    134121        return true; // Successfully logged out
     
    142129    public static function if_custom_user_logged_in()
    143130    {
    144         // Start the session if it's not already started
    145         if (!session_id()) {
    146             session_start();
    147         }
    148 
    149         // Check if the custom user is logged in via session
    150         if (isset($_SESSION['custom_user']) && !empty($_SESSION['custom_user'])) {
     131        // Check if the custom user is logged in via transient
     132        if (get_transient('custom_user')) {
    151133            return true; // User is logged in
    152134        }
    153135
    154136        return false; // User is not logged in
     137    }
     138
     139    /**
     140     * Get the currently logged-in custom user login.
     141     *
     142     * @return string|bool The user login if logged in, false otherwise.
     143     */
     144    public static function get_current_custom_user_login()
     145    {
     146        // Retrieve the user login from the transient
     147        $user_login = get_transient('custom_user');
     148
     149        if ($user_login) {
     150            return sanitize_text_field($user_login);
     151        }
     152
     153        return false; // No custom user is logged in
    155154    }
    156155
     
    180179    }
    181180
    182     // Function to set custom user status (like user_status or user_block)
     181    /**
     182     * Set a custom value for a user (like user_status or user_block).
     183     *
     184     * @param string $user_login The username (wallet address).
     185     * @param string $column The column name to update.
     186     * @param mixed $value The value to set.
     187     * @return bool True on success, false on failure.
     188     */
    183189    public static function set_custom_user_value($user_login, $column, $value)
    184190    {
     
    222228    }
    223229
    224 
    225 
    226     // Function to get custom user status (like user_status or user_block)
     230    /**
     231     * Get a custom value for a user (like user_status or user_block).
     232     *
     233     * @param string $user_login The username (wallet address).
     234     * @param string $column The column name to retrieve.
     235     * @return mixed The value on success, false on failure.
     236     */
    227237    public static function get_custom_user_value($user_login, $column)
    228238    {
     
    255265        return false; // No value found (user doesn't exist or column is invalid)
    256266    }
    257 
    258     public static function get_current_custom_user_login()
    259     {
    260         // Start the session if not already started
    261         if (!session_id()) {
    262             session_start();
    263         }
    264 
    265         // Check if a custom user is logged in
    266         if (isset($_SESSION['custom_user']) && !empty($_SESSION['custom_user'])) {
    267             // Sanitize and return the user_login stored in the session
    268             return sanitize_text_field($_SESSION['custom_user']);
    269         }
    270 
    271         return false; // No custom user is logged in
    272     }
    273267}
  • crypto/trunk/includes/class-crypto_connect_ajax_register.php

    r3204035 r3204245  
    150150    public function add_custom_user_logged_in_class($classes)
    151151    {
    152         // Check if the custom user is logged in
    153         if (isset($_SESSION['custom_user']) && !empty($_SESSION['custom_user'])) {
    154             // Add a class to the body tag
     152        // Check if the custom user is logged in using a transient
     153        if (get_transient('custom_user')) {
     154            // Add a class to the body tag for logged-in users
    155155            $classes[] = 'custom-user-logged-in';
    156156        } else {
    157             // Remove the class from the body tag
     157            // Add a class to the body tag for logged-out users
    158158            $classes[] = 'custom-user-logged-out';
    159159        }
Note: See TracChangeset for help on using the changeset viewer.