force-https icon indicating copy to clipboard operation
force-https copied to clipboard

Plugin exits php when run in script mode

Open apinstein opened this issue 6 years ago • 3 comments

When using a php script to manipulate a WP install, the force-https plugin will still try to load itself, and the start function will die(), thus making it impossible for the main script to ever execute.

I see a related issue #6 but that seems to be a fix that just detects WP_CLI. In my situation I have a custom CLI script.

My suggestion is that the script should only load itself when not in CLI mode.

apinstein avatar Jan 24 '19 14:01 apinstein

I should add I tried updating my plugin to 1.3.0 but WP thinks that 1.2.0 is the most current version...

apinstein avatar Jan 24 '19 14:01 apinstein

Thanks for the feedback. I'm not sure the entire process you are using, but if you are using a custom script to install WordPress (etc) then you can consider the upcoming defined constants.

These are planned for the next release 1.4.0:

/* Force HTTPS Functions */
define('FORCE_HTTPS', true);
define('FORCE_HTTPS_EXTERNAL_LINKS', false);
define('FORCE_HTTPS_EXTERNAL_RESOURCES', true);
define('FORCE_HTTPS_INTERNAL_LINKS', true);
define('FORCE_HTTPS_INTERNAL_RESOURCES', true);

As the plugin is now hosted on GitHub, the old versions do not detect updates. This will be fixed in future versions that auto-update from this GitHub repo (not WordPress.org).

But I'll have our team take a look at your suggestion re: further support of CLI.

jessuppi avatar Jan 24 '19 16:01 jessuppi

I don't think that helps. since you cannot redefine a define constant. A script couldn't leverage those settings to make a difference.

My thinking was that the plugin should basically "skip initializing itself" if the current execution environment isn't a web server.

apinstein avatar Jan 24 '19 16:01 apinstein