Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add url_fopen option checking to requirements #383

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions s3-uploads.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ function s3_uploads_check_requirements() {

return false;
}

if ( ! ini_get( 'allow_url_fopen' ) ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action( 'admin_notices', 's3_uploads_url_fopen_disabled_notice' );
}

return false;
}

return true;
}
Expand All @@ -89,6 +97,18 @@ function s3_uploads_outdated_php_version_notice() {
PHP_VERSION
);
}

/**
* Print an admin notice when the PHP version is not high enough.
*
* This has to be a named function for compatibility with PHP 5.2.
*/
function s3_uploads_url_fopen_disabled_notice() {
printf( '<div class="error"><p>The S3 Uploads plugin requires PHP option allow_url_fopen to be enabled. <a href="%s" target="_blank" rel="noopener noreferrer">Learn more</a>.</p></div>',
'https://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen'
);
}

/**
* Check if URL rewriting is enabled.
*
Expand Down