简体   繁体   English

当我知道哪些文件正在产生错误时,修复PHP中的Wordpress插件的HTTPS错误,混合内容错误?

[英]Fixing a Wordpress Plug-in's HTTPS error in PHP, mixed content error when I know which files are creating the error?

I am trying to fix another developer's Wordpress plugin that I would like to utilize but being my wordpress blog is 100% HTTPS (Shared SSL Certificate with CDN) it creates mixed content errors on the admin panel as well as if displayed on the website. 我正在尝试修复我想利用的另一个开发人员的Wordpress插件,但作为我的wordpress博客是100%HTTPS(带有CDN的共享SSL证书),它会在管理面板上以及网站上显示混合内容时出错。 I am not a PHP guy but I have done a lot of coding over the years and code review so I would like to try to work through this. 我不是PHP的人,但是这些年来我做了很多编码和代码审查工作,所以我想尝试一下。

All other plug-ins on my website do not require me to use any forced SSL method, and I have already followed the guides for implementing SSL / HTTPS. 我网站上的所有其他插件都不需要我使用任何强制的SSL方法,并且我已经按照实现SSL / HTTPS的指南进行操作。 I have no other SSL/HTTPS or mixed content errors and I do not want to go back to having to use it as it created other issues. 我没有其他SSL / HTTPS或混合内容错误,并且由于它造成了其他问题, 我不想回到不得不使用它的情况

I have used the Firefox Inspector and know which files generate the issue: http:///wp-content/plugins//resources/scripts/.js http:///wp-content/plugins//resources/css/themes/default/jquery-ui.css As well as it serves up images for the plug-in as HTTP. 我使用了Firefox Inspector,并发现了哪些文件引起了该问题:http:///wp-content/plugins//resources/scripts/.js http:/// wp-content / plugins // resources / css / themes / default / jquery-ui.css以及它以HTTP形式为插件提供图像。

The Plugins.php file that I open in Firefox shows it registered as HTTP vs. HTTPS. 我在Firefox中打开的Plugins.php文件显示它已注册为HTTP vs. HTTPS。

What I have looked at: I have scanned the code for HTTP and not found any HTTP outside of the header docs and confirmed that the plug-in gets its GoogleFonts and Google CoreChart from https://www.google.com/jsapi . 我看过的内容:我扫描了HTTP代码,但未在标头文档中找到任何HTTP,并确认该插件从https://www.google.com/jsapi获得了它的GoogleFonts和Google CoreChart。

I have done some reading and am not clear on "this.url" usage or if this is the source or not but have read others have the problem. 我已经读了一些书,对“ this.url”的用法不清楚,或者这是否是源文件,但读过其他书有问题。

I have scanned the code and did not see any paths that were not ended with a \\ that were not parameters to a specific file themselves. 我已经扫描了代码,没有看到没有以\\结尾的路径,而这些路径本身都不是特定文件的参数。

     * sets up the object with the AJAX url and security nonce, also retrieves language properties
 */
setup: function(url, nonce, pluginUrl, userId, callbackFn, skipLoadGlobals) {
    if(!PI.ajaxSetup) {
        // create custom widgets
        initPICustom();

        PI.globals.pluginUrl = pluginUrl;
        PI.userId = userId;
        this.url = url;
        this.nonce = nonce;

        if(!skipLoadGlobals) {
            this.loadGlobalData(callbackFn);
        }
        else {
            callbackFn();
        }
    }
    else {
        alert('Ajax setup function already called');
    }
},

All of the other references to the URL look something like the following: 该URL的所有其他引用如下所示:

    getUserOldestResultYear: function(userId, callbackFn) {
    jQuery.ajax({
        type: "post",
        url: PI.Ajax.url

At least one of the files being reported is the Datatables plug-in that is about two years old, and JQueryUI 1.6 or 1.7 that is at least 6 years old. 报告的文件中至少有一个是使用了大约两年的Datatables插件 ,以及至少使用了6年的JQueryUI 1.6或1.7

I do not currently use the plugin and would like to. 我目前不使用该插件,但愿意。 This plug-in is still updated is updated about once or twice a year, the developer has their freeware code on GitHub. 该插件仍每年大约更新一次或两次,开发人员将其免费代码保存在GitHub上。 So I would like to take a shot at fixing it or at very minimum give the developer very specific direction on how to fix it if I figure out most of it using my test site. 因此,我想尝试一下修复它,或者,如果我在测试站点上弄清了大部分问题,我将至少给开发人员一个非常具体的指导,说明如何修复它。

I cannot provide a link at this time to the specific site because I only activate the plug-in when I am actively working on it due to it resulting in errors on the rest of my site when I due activate it. 我目前无法提供指向该特定站点的链接,因为我仅在积极从事该插件时才激活该插件,因为该插件在我应激活该插件时会导致其余站点出现错误。 I am looking for guidance on how to further diagnosis the issue and hopefully also how to fix it. 我正在寻找有关如何进一步诊断该问题以及希望如何解决该问题的指南。

So my questions are: 所以我的问题是:

  1. Is there anything else specific thing I should be looking for in the code to possibly identify the source of these HTTP calls that I may be able to fix relatively easily in the code? 我应该在代码中寻找其他特定的东西,以识别可能可以相对容易地在代码中修复的这些HTTP调用的来源吗?
  2. Would simply upgrading JQueryUI and DataTables and likely fix the issue or is this a red herring? 只是升级JQueryUI和DataTables并可能解决该问题还是这是一个麻烦?
  3. IF #2 is in the affirmative, I downloaded DataTables and the latest JQueryUI would attempting to upgrade the app to use it being they are so far behind likely end up in a total rewrite or is it something that is relatively managable? 如果#2是肯定的,我下载了DataTables,而最新的JQueryUI会尝试升级该应用程序以使用它,因为它们可能远远落后于完全重写,还是相对可管理的? (ie I have some time but not a lot of time to try to fix this). (即,我有一些时间但没有很多时间来尝试解决此问题)。
  4. If the AJAX thing is related, how do I fix it? 如果有关AJAX的内容,该如何解决?

The root of my problem was none of the above and it was a change in the way Wordpress internal variables worked. 我的问题的根源不是上述所有问题,而是Wordpress内部变量工作方式的变化。

The plug-in I was attempting to troubleshoot was utilizing the following: 我尝试进行故障排除的插件利用了以下内容:

define('WPA_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . WPA_PLUGIN_NAME);
define('WPA_PLUGIN_URL', WP_PLUGIN_URL . '/' . WPA_PLUGIN_NAME);

New Code which per these two links stating to do not use the internal Wordpress variables and to use these instead took care of it in the primary plugin PHP file. 根据这两个链接,新代码声明不使用内部Wordpress变量而是使用这些 变量在主插件PHP文件中进行处理。

define('WPA_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
define('WPA_PLUGIN_URL', plugin_dir_url( __FILE__ ));

But to recap my questions: 但回顾一下我的问题:

  1. Checking the wordpress codex was what I needed to do to determine depreciated methods were being used. 我需要检查wordpress Codex来确定正在使用的折旧方法。
  2. Yes the old versions were red herrings and had nothing to do with it. 是的,旧版本是红色鲱鱼,与它无关。
  3. N/A 不适用
  4. N/A 不适用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM