Plugin Directory

Changeset 2921182


Ignore:
Timestamp:
06/04/2023 09:10:30 AM (22 months ago)
Author:
iqbalrony
Message:

Releasing version 1.0.3

Location:
wp-user-switch
Files:
1 added
1 deleted
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-user-switch/trunk/inc/enqueue_scripts.php

    r2476880 r2921182  
    2323function wpus_scripts() {
    2424    wp_enqueue_style('wpus-main-css', wpus_plugin_url('/assets/css/main.css'), '', '');
    25     wp_enqueue_script('wpus-main-js', wpus_plugin_url('/assets/js/main.js'), ['jquery'], '', true);
     25    wp_enqueue_script('wpus-main-js', wpus_plugin_url('/assets/js/main.js'), array('jquery'), '', true);
    2626}
  • wp-user-switch/trunk/inc/functions.php

    r2237142 r2921182  
    3030        $allow = true;
    3131    } else {
    32         if ( isset( $_COOKIE['wpus_who_switch'] ) ) {
    33             $allowed_user_cookie = sanitize_user($_COOKIE['wpus_who_switch']);
     32        $set_option = get_option(WP_USERSWITCH_LOGGED_IN_COOKIE, false);
     33        if ( $set_option ) {
     34            $allowed_user_cookie = sanitize_user(wpus_decrypt($set_option));
    3435        }
    3536        $user = get_user_by( 'login', $allowed_user_cookie );
     
    4950function wpus_is_switcher_admin () {
    5051    $allowed_user_cookie = '';
    51     if ( isset( $_COOKIE['wpus_who_switch'] ) ) {
    52         $allowed_user_cookie = sanitize_user($_COOKIE['wpus_who_switch']);
     52    $set_option = get_option(WP_USERSWITCH_LOGGED_IN_COOKIE, false);
     53    if ( $set_option ) {
     54        $allowed_user_cookie = sanitize_user(wpus_decrypt($set_option));
    5355    }
    5456    $user = get_user_by( 'login', $allowed_user_cookie );
     
    98100    <?php
    99101}
     102
     103function wpus_encrypt($string){
     104    $current_date = current_datetime()->format('Y-m-d');
     105    $new_string = $string . '____' . $current_date;
     106    $encoded64 = base64_encode($new_string);
     107    return $encoded64;
     108}
     109
     110function wpus_decrypt($string){
     111    $decoded64 = base64_decode($string);
     112    $current_date = current_datetime()->format('Y-m-d');
     113    $replaceable_str = '____' . $current_date;
     114    $decoded_string = str_replace($replaceable_str, "", $decoded64);
     115    return $decoded_string;
     116}
  • wp-user-switch/trunk/readme.txt

    r2826294 r2921182  
    22Plugin Name: WP User Switch
    33Contributors: iqbalrony
    4 Version: 1.0.2
     4Version: 1.0.3
    55License: GPLv2 or later
    66License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • wp-user-switch/trunk/wp-user-switch.php

    r2826292 r2921182  
    55 * Author: IqbalRony
    66 * Author URI: http://www.iqbalrony.com
    7  * Version: 1.0.2
     7 * Version: 1.0.3
    88 * License: GPLv2 or later
    99 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4545}
    4646/**
     47 * Define cookiesHASH page slug
     48 */
     49if ( ! defined( 'WP_USERSWITCH_COOKIEHASH' ) ) {
     50    $siteurl = get_site_option( 'siteurl' );
     51    if ( $siteurl ) {
     52        define( 'WP_USERSWITCH_COOKIEHASH', md5( $siteurl ) );
     53    } else {
     54        define( 'WP_USERSWITCH_COOKIEHASH', '' );
     55    }
     56}
     57
     58if ( ! defined( 'WP_USERSWITCH_LOGGED_IN_COOKIE' ) ) {
     59    define( 'WP_USERSWITCH_LOGGED_IN_COOKIE', 'wpus_switch_' . WP_USERSWITCH_COOKIEHASH );
     60}
     61
     62/**
    4763 * Hooks
    4864 */
     
    5066function wpus_element_load() {
    5167    load_plugin_textdomain('wp-user-switch', false, plugin_basename(dirname(__FILE__)) . '/languages/');
    52     require_once wpus_get_plugin_path( 'inc/wp-user-switch.php' );
    53     $WP_User_Switch = 'IqbalRony\WP_User_Switch\WP_User_Switch';
    54     $WP_User_Switch::instance();
     68    require_once wpus_get_plugin_path( 'inc/user-switch.php' );
     69    $User_Switch = 'IqbalRony\WP_User_Switch\User_Switch';
     70    $User_Switch::instance();
    5571}
Note: See TracChangeset for help on using the changeset viewer.