You know the drill, Updates

This commit is contained in:
2023-05-01 19:51:20 -07:00
parent af6f76fbcb
commit 006e3d3314
105 changed files with 1725 additions and 1430 deletions

View File

@ -595,7 +595,7 @@ function yourls_load_plugins() {
$plugins = [];
foreach ( $active_plugins as $key => $plugin ) {
$file = YOURLS_PLUGINDIR . '/' . $plugin;
if ( yourls_is_a_plugin_file($file) && yourls_activate_plugin_sandbox( $file ) === true ) {
if ( yourls_is_a_plugin_file($file) && yourls_include_file_sandbox( $file ) === true ) {
$plugins[] = $plugin;
unset( $active_plugins[ $key ] );
}
@ -659,7 +659,7 @@ function yourls_activate_plugin( $plugin ) {
}
// attempt activation.
$attempt = yourls_activate_plugin_sandbox( $plugindir.'/'.$plugin );
$attempt = yourls_include_file_sandbox( $plugindir.'/'.$plugin );
if( $attempt !== true ) {
return yourls_s( 'Plugin generated unexpected output. Error was: <br/><pre>%s</pre>', $attempt );
}
@ -673,22 +673,6 @@ function yourls_activate_plugin( $plugin ) {
return true;
}
/**
* Plugin activation sandbox
*
* @since 1.8.3
* @param string $pluginfile Plugin filename (full path)
* @return string|true string if error or true if success
*/
function yourls_activate_plugin_sandbox( $pluginfile ) {
try {
include_once $pluginfile;
return true;
} catch ( \Throwable $e ) {
return $e->getMessage();
}
}
/**
* Deactivate a plugin
*
@ -706,12 +690,16 @@ function yourls_deactivate_plugin( $plugin ) {
// Check if we have an uninstall file - load if so
$uninst_file = YOURLS_PLUGINDIR . '/' . dirname($plugin) . '/uninstall.php';
if ( file_exists($uninst_file) ) {
$attempt = yourls_include_file_sandbox( $uninst_file );
// Check if we have an error to display
if ( is_string( $attempt ) ) {
$message = yourls_s( 'Loading %s generated unexpected output. Error was: <br/><pre>%s</pre>', $uninst_file, $attempt );
return( $message );
}
if ( $attempt === true ) {
define('YOURLS_UNINSTALL_PLUGIN', true);
$attempt = yourls_activate_plugin_sandbox( $uninst_file );
if( $attempt !== true ) {
return yourls_s( 'Plugin generated unexpected output. Error was: <br/><pre>%s</pre>', $attempt );
}
}
// Deactivate the plugin