Skip to content

Commit 3ca08d4

Browse files
authored
Merge pull request #705 from humanmade/pr-383
Add url_fopen option checking to requirements
2 parents aa6897c + 7656d70 commit 3ca08d4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

inc/namespace.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ function check_requirements() : bool {
6969
return false;
7070
}
7171

72+
if ( ! ini_get( 'allow_url_fopen' ) ) {
73+
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
74+
add_action( 'admin_notices', __NAMESPACE__ . '\\url_fopen_disabled_notice' );
75+
}
76+
77+
return false;
78+
}
79+
7280
return true;
7381
}
7482

@@ -84,6 +92,17 @@ function outdated_php_version_notice() {
8492
);
8593
}
8694

95+
/**
96+
* Print an admin notice when the PHP version is not high enough.
97+
*
98+
* This has to be a named function for compatibility with PHP 5.2.
99+
*/
100+
function url_fopen_disabled_notice() {
101+
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>',
102+
'https://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen'
103+
);
104+
}
105+
87106
/**
88107
* Print an admin notice when the WP version is not high enough.
89108
*

0 commit comments

Comments
 (0)