• Good Morning!

    I plan to add a modified JWT to my WordPress for cross domain user id verification. Part of the SDK codes are below. Does anyone know which php files in my theme folder can add those codes? I’m newbie in the WP development.

    Thanks
    iam

    <?php
    namespace sdk;
    
    class bJwt
    {
    	const TYPE_RESERVED = 0;
    	const TYPE_JSON = 1;
    	const TYPE_SYS = 2;
    	
    	public static $enableLog = true;
    	protected static $logger = null;
    	
    	public static $appName = '';
    	public static $issuerId = 0;
    	public static $secretKey = '';
    	public static $aesKey = '';
    	
    	public static function getJwt($body)
    	{
    		$body = json_encode($body, JSON_UNESCAPED_UNICODE);	//JSON_UNESCAPED_UNICODE 必须
    		
    		$header = self::packHeader();
    		$body = self::encrypt($body);
    		
    		$base64Header = base64_encode($header);
    		$base64Payload = base64_encode($body);
    		$base64Signature = base64_encode(self::sign($base64Header, $base64Payload));
    		
    		return "{$base64Header}.{$base64Payload}.{$base64Signature}";
    	}
    	
    	protected static function packHeader()
    	{
    		$header = '';
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    If your theme gets updated once in a while, you don’t want to alter theme files because your changes will be overwritten during the update. Instead, create a child theme or custom plugin to contain your code. You can add your code to the child’s functions.php, or keep it on a separate file which is included into functions.php.

    Similar for plugins, you can place code in the main plugin file or include a separate page. For more information on child themes, plugins, and WP development in general, start at https://developer.wordpress.org/

Viewing 1 replies (of 1 total)
  • The topic ‘which php files for jwt integration?’ is closed to new replies.