/** * Runs when update is needed, updating the given blog. If $blog is null, * active blog is updated. * * @param int $blog Blog to update or null if updating current blog. */ private static function _update($blog) { $options = DocumentGallery::getOptions($blog); if (is_null($options)) { return; } // version-specific updates self::twoPointTwo($options); self::twoPointThree($options); self::threePointZeroBeta($options); self::threePointOne($options); self::threePointTwo($options); self::threePointThree($options); self::threePointFour($options); self::threePointFive($options); self::fourPointZero($options); self::fourPointOne($options); self::fourPointOnePointFive($options); // update plugin meta data $options['meta']['version'] = DG_VERSION; $options['meta']['donate_link'] = self::getDonateLink(); // remove previously-failed thumbs DG_Thumb::purgeFailedThumbs(); DocumentGallery::setOptions($options, $blog); }
/** * Validate settings for the tab. */ function dg_validate_settings($values) { global $dg_options; $ret = $dg_options; include_once DG_PATH . 'inc/class-gallery.php'; $thumbs_cleared = false; // handle gallery shortcode defaults $errs = array(); $ret['gallery'] = DG_Gallery::sanitizeDefaults(null, $values['gallery_defaults'], $errs); foreach ($errs as $k => $v) { add_settings_error(DG_OPTION_NAME, str_replace('_', '-', $k), $v); } // handle setting width if (isset($values['thumbnail_generation']['width'])) { $width = (int) $values['thumbnail_generation']['width']; if ($width > 0) { $ret['thumber']['width'] = $width; } else { add_settings_error(DG_OPTION_NAME, 'thumber-width', __('Invalid width given: ', 'document-gallery') . $values['thumbnail_generation']['width']); } unset($values['thumbnail_generation']['width']); } // handle setting height if (isset($values['thumbnail_generation']['height'])) { $height = (int) $values['thumbnail_generation']['height']; if ($height > 0) { $ret['thumber']['height'] = $height; } else { add_settings_error(DG_OPTION_NAME, 'thumber-height', __('Invalid height given: ', 'document-gallery') . $values['thumbnail_generation']['height']); } unset($values['thumbnail_generation']['width']); } // delete thumb cache to force regeneration if max dimensions changed if ($ret['thumber']['width'] !== $dg_options['thumber']['width'] || $ret['thumber']['height'] !== $dg_options['thumber']['height']) { DG_Thumb::purgeThumbs(); } // handle setting the active thumbers foreach (array_keys($ret['thumber']['active']) as $k) { $ret['thumber']['active'][$k] = isset($values['thumbnail_generation'][$k]); } // if new thumbers available, clear failed thumbnails for retry if (!$thumbs_cleared) { DG_Thumb::purgeFailedThumbs(); } // handle modified CSS if (trim($ret['css']['text']) !== trim($values['css'])) { $ret['css']['text'] = trim($values['css']); } return $ret; }