' .
'Please create the folder manually, or change the file permissions of your wp-content folder.'
);
return false;
} else {
if (!Paths::createConfigDirIfMissing()) {
Messenger::printMessage(
'error',
'For migration to 0.5.0, WebP Express needs to create a directory "webp-express/config" under your wp-content folder, but does not have permission to do so.
' .
'Please create the folder manually, or change the file permissions.'
);
return false;
}
if (!Paths::createCacheDirIfMissing()) {
Messenger::printMessage(
'error',
'For migration to 0.5.0, WebP Express needs to create a directory "webp-express/webp-images" under your wp-content folder, but does not have permission to do so.
' .
'Please create the folder manually, or change the file permissions.'
);
return false;
}
}
return true;
}
function webp_express_migrate1_createDummyConfigFiles()
{
// TODO...
return true;
}
function webpexpress_migrate1_migrateOptions()
{
$converters = json_decode(Option::getOption('webp_express_converters', '[]'), true);
foreach ($converters as &$converter) {
unset ($converter['id']);
}
$options = [
'image-types' => intval(Option::getOption('webp_express_image_types_to_convert', 1)),
'max-quality' => intval(Option::getOption('webp_express_max_quality', 80)),
'fail' => Option::getOption('webp_express_failure_response', 'original'),
'converters' => $converters,
'forward-query-string' => true
];
if ($options['max-quality'] == 0) {
$options['max-quality'] = 80;
if ($options['image-types'] == 0) {
$options['image-types'] = 1;
}
}
if ($options['converters'] == null) {
$options['converters'] = [];
}
// TODO: Save
//Messenger::addMessage('info', 'Options:
' . print_r($options, true) . ''); // $htaccessExists = Config::doesHTAccessExists(); $config = $options; //$htaccessExists = Config::doesHTAccessExists(); //$rules = HTAccess::generateHTAccessRulesFromConfigObj($config); if (Config::saveConfigurationFile($config)) { $options = Config::generateWodOptionsFromConfigObj($config); if (Config::saveWodOptionsFile($options)) { Messenger::addMessage( 'success', 'WebP Express has successfully migrated its configuration to 0.5.0' ); //Config::saveConfigurationAndHTAccessFilesWithMessages($config, 'migrate'); //$rulesResult = HTAccess::saveRules($config); // Commented out because rules are going to be saved in migrate12 /* 'mainResult' // 'index', 'wp-content' or 'failed' 'minRequired' // 'index' or 'wp-content' 'pluginToo' // 'yes', 'no' or 'depends' 'pluginFailed' // true if failed to write to plugin folder (it only tries that, if pluginToo == 'yes') 'pluginFailedBadly' // true if plugin failed AND it seems we have rewrite rules there 'overidingRulesInWpContentWarning' // true if main result is 'index' but we cannot remove those in wp-content 'rules' // the rules that were generated */ /* $mainResult = $rulesResult['mainResult']; $rules = $rulesResult['rules']; if ($mainResult != 'failed') { Messenger::addMessage( 'success', 'WebP Express has successfully migrated its configuration and updated the rewrite rules to 0.5.0' ); } else { Messenger::addMessage( 'warning', 'WebP Express has successfully migrated its configuration.' . 'However, WebP Express could not update the rewrite rules