WordPress相关的base64编码问题
Base64 encode questions related to WordPress
我在 WordPress 中有 2 个变量,我正在连接然后 "trying" 转换为 Base64。
我把它作为一个更大的脚本的一部分作为插件移植到 WordPress 并且一切正常,但是,该版本不符合 WP 标准,也没有添加新功能,我已经创建。在添加新功能时,我不得不放弃原来的 JS。现在我需要重现最后一个 JS 函数 (btoa)。
Before going further - var1 and var2 are pre-encrypted codes used for a remote OAuth server - not for WordPress.
That server needs these codes to be Base64 Encoded to connect.
我将它们连接起来,但无法将结果变量转换为 Base64。我已经尝试了以下两行代码:
$concatenated = $var1 . ":" . $var2; //This works fine - only here for reference
base64_encode($concatenated); //I figured this would not work in WordPress
echo '<script type="text/javascript">$concatenated = btoa($concatenated);</script>'; //I thought this would work, but it does nothing
任何片段或示例都非常适合这一行。
我研究并发现了许多需要大量阅读但最终没有有效解决方案的解决方案。这(如我所见)应该是一个简单的工作班轮。
对于那些正在寻找 WP 兼容 Base64_encode 解决方案的人,我通过反复试验找到了它...
$concatenated = base64_encode(htmlentities($concatenated, ENT_QUOTES));
我在 WordPress 中有 2 个变量,我正在连接然后 "trying" 转换为 Base64。
我把它作为一个更大的脚本的一部分作为插件移植到 WordPress 并且一切正常,但是,该版本不符合 WP 标准,也没有添加新功能,我已经创建。在添加新功能时,我不得不放弃原来的 JS。现在我需要重现最后一个 JS 函数 (btoa)。
Before going further - var1 and var2 are pre-encrypted codes used for a remote OAuth server - not for WordPress.
That server needs these codes to be Base64 Encoded to connect.
我将它们连接起来,但无法将结果变量转换为 Base64。我已经尝试了以下两行代码:
$concatenated = $var1 . ":" . $var2; //This works fine - only here for reference
base64_encode($concatenated); //I figured this would not work in WordPress
echo '<script type="text/javascript">$concatenated = btoa($concatenated);</script>'; //I thought this would work, but it does nothing
任何片段或示例都非常适合这一行。 我研究并发现了许多需要大量阅读但最终没有有效解决方案的解决方案。这(如我所见)应该是一个简单的工作班轮。
对于那些正在寻找 WP 兼容 Base64_encode 解决方案的人,我通过反复试验找到了它...
$concatenated = base64_encode(htmlentities($concatenated, ENT_QUOTES));