Changeset 3204245
- Timestamp:
- 12/08/2024 02:35:21 AM (15 months ago)
- Location:
- crypto
- Files:
-
- 8 edited
- 1 copied
-
tags/2.22 (copied) (copied from crypto/trunk)
-
tags/2.22/README.txt (modified) (1 diff)
-
tags/2.22/crypto.php (modified) (3 diffs)
-
tags/2.22/includes/class-crypto-user.php (modified) (8 diffs)
-
tags/2.22/includes/class-crypto_connect_ajax_register.php (modified) (1 diff)
-
trunk/README.txt (modified) (1 diff)
-
trunk/crypto.php (modified) (3 diffs)
-
trunk/includes/class-crypto-user.php (modified) (8 diffs)
-
trunk/includes/class-crypto_connect_ajax_register.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
crypto/tags/2.22/README.txt
r3204035 r3204245 6 6 Requires PHP: 5.5 7 7 Tested up to: 6.6.2 8 Stable tag: 2.2 18 Stable tag: 2.22 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
crypto/tags/2.22/crypto.php
r3204035 r3204245 10 10 * 11 11 * @link https://odude.com/ 12 * @since 2.2 112 * @since 2.22 13 13 * @package Crypto 14 14 * … … 17 17 * Plugin URI: http://odude.com/ 18 18 * Description: Crypto - Price widget, Metamask Login, Block content. 19 * Version: 2.2 119 * Version: 2.22 20 20 * Author: ODude 21 21 * Author URI: https://odude.com/ … … 31 31 } 32 32 33 define('CRYPTO_VERSION', '2.2 1');33 define('CRYPTO_VERSION', '2.22'); 34 34 define('CRYPTO_FOLDER', dirname(plugin_basename(__FILE__))); 35 35 define('CRYPTO_PLUGIN_URL', content_url('/plugins/' . CRYPTO_FOLDER)); -
crypto/tags/2.22/includes/class-crypto-user.php
r3204035 r3204245 9 9 add_action("wp_ajax_nopriv_crypto_connect_ajax_process", array($this, "crypto_connect_ajax_process")); 10 10 } 11 12 11 13 12 /** … … 50 49 // Check if the insertion was successful 51 50 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); 59 54 60 55 // Trigger WordPress action for custom user registration … … 97 92 } 98 93 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); 106 96 107 97 // Trigger WordPress action for custom user login … … 119 109 { 120 110 // Check if the user is logged in 121 if (! isset($_SESSION['custom_user'])) {111 if (!self::if_custom_user_logged_in()) { 122 112 return false; // No user logged in 123 113 } 124 114 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'); 130 117 131 118 // Trigger WordPress action for custom user logout 132 do_action('custom_user_logged_out' , $user_login);119 do_action('custom_user_logged_out'); 133 120 134 121 return true; // Successfully logged out … … 142 129 public static function if_custom_user_logged_in() 143 130 { 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')) { 151 133 return true; // User is logged in 152 134 } 153 135 154 136 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 155 154 } 156 155 … … 180 179 } 181 180 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 */ 183 189 public static function set_custom_user_value($user_login, $column, $value) 184 190 { … … 222 228 } 223 229 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 */ 227 237 public static function get_custom_user_value($user_login, $column) 228 238 { … … 255 265 return false; // No value found (user doesn't exist or column is invalid) 256 266 } 257 258 public static function get_current_custom_user_login()259 {260 // Start the session if not already started261 if (!session_id()) {262 session_start();263 }264 265 // Check if a custom user is logged in266 if (isset($_SESSION['custom_user']) && !empty($_SESSION['custom_user'])) {267 // Sanitize and return the user_login stored in the session268 return sanitize_text_field($_SESSION['custom_user']);269 }270 271 return false; // No custom user is logged in272 }273 267 } -
crypto/tags/2.22/includes/class-crypto_connect_ajax_register.php
r3204035 r3204245 150 150 public function add_custom_user_logged_in_class($classes) 151 151 { 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 155 155 $classes[] = 'custom-user-logged-in'; 156 156 } else { 157 // Remove the class from the body tag157 // Add a class to the body tag for logged-out users 158 158 $classes[] = 'custom-user-logged-out'; 159 159 } -
crypto/trunk/README.txt
r3204035 r3204245 6 6 Requires PHP: 5.5 7 7 Tested up to: 6.6.2 8 Stable tag: 2.2 18 Stable tag: 2.22 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
crypto/trunk/crypto.php
r3204035 r3204245 10 10 * 11 11 * @link https://odude.com/ 12 * @since 2.2 112 * @since 2.22 13 13 * @package Crypto 14 14 * … … 17 17 * Plugin URI: http://odude.com/ 18 18 * Description: Crypto - Price widget, Metamask Login, Block content. 19 * Version: 2.2 119 * Version: 2.22 20 20 * Author: ODude 21 21 * Author URI: https://odude.com/ … … 31 31 } 32 32 33 define('CRYPTO_VERSION', '2.2 1');33 define('CRYPTO_VERSION', '2.22'); 34 34 define('CRYPTO_FOLDER', dirname(plugin_basename(__FILE__))); 35 35 define('CRYPTO_PLUGIN_URL', content_url('/plugins/' . CRYPTO_FOLDER)); -
crypto/trunk/includes/class-crypto-user.php
r3204035 r3204245 9 9 add_action("wp_ajax_nopriv_crypto_connect_ajax_process", array($this, "crypto_connect_ajax_process")); 10 10 } 11 12 11 13 12 /** … … 50 49 // Check if the insertion was successful 51 50 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); 59 54 60 55 // Trigger WordPress action for custom user registration … … 97 92 } 98 93 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); 106 96 107 97 // Trigger WordPress action for custom user login … … 119 109 { 120 110 // Check if the user is logged in 121 if (! isset($_SESSION['custom_user'])) {111 if (!self::if_custom_user_logged_in()) { 122 112 return false; // No user logged in 123 113 } 124 114 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'); 130 117 131 118 // Trigger WordPress action for custom user logout 132 do_action('custom_user_logged_out' , $user_login);119 do_action('custom_user_logged_out'); 133 120 134 121 return true; // Successfully logged out … … 142 129 public static function if_custom_user_logged_in() 143 130 { 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')) { 151 133 return true; // User is logged in 152 134 } 153 135 154 136 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 155 154 } 156 155 … … 180 179 } 181 180 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 */ 183 189 public static function set_custom_user_value($user_login, $column, $value) 184 190 { … … 222 228 } 223 229 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 */ 227 237 public static function get_custom_user_value($user_login, $column) 228 238 { … … 255 265 return false; // No value found (user doesn't exist or column is invalid) 256 266 } 257 258 public static function get_current_custom_user_login()259 {260 // Start the session if not already started261 if (!session_id()) {262 session_start();263 }264 265 // Check if a custom user is logged in266 if (isset($_SESSION['custom_user']) && !empty($_SESSION['custom_user'])) {267 // Sanitize and return the user_login stored in the session268 return sanitize_text_field($_SESSION['custom_user']);269 }270 271 return false; // No custom user is logged in272 }273 267 } -
crypto/trunk/includes/class-crypto_connect_ajax_register.php
r3204035 r3204245 150 150 public function add_custom_user_logged_in_class($classes) 151 151 { 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 155 155 $classes[] = 'custom-user-logged-in'; 156 156 } else { 157 // Remove the class from the body tag157 // Add a class to the body tag for logged-out users 158 158 $classes[] = 'custom-user-logged-out'; 159 159 }
Note: See TracChangeset
for help on using the changeset viewer.