Commit bad356f4 authored by lechuck's avatar lechuck Committed by lucha

Upgrade Nextgen Gallery to 2.0.63

parent 6cdf0efa
NextGEN Gallery
by Photocrati Media
= V2.0.63 - 04.29.2014 =
* NEW: Translation ready
* NEW: Including German translation by Roland Stumpp
* NEW: Including Czech translation by Separatista
* NEW: Including Finnish translation by Vesa Tiirikainen
* NEW: WPML / qTranslate support
* NEW: Bundled Browser+ JavaScript library
* NEW: Added NGG_DISABLE_FILTER_THE_CONTENT constant to manage conflicts
* Changed: Moved jquery.nextgen_radio_toggle.js to NextGEN Admin Module
* Changed: Original display settings are passed to secondary display types
* Fixed: Thumbnail dimension calculations are inaccurate by 1px when maintaining aspect ratio
* Fixed: Copy IPTC data from original to new image when creating new sizes / thumbnails
* Fixed: Use correct absolute path when importing images in a multisite environment
* Fixed: Incorrect display of disk space quotas in multisite environments
* Fixed: Removed redundant roles form in multisite environments
* Fixed: Insert Gallery Window support for multisite environments
* Fixed: Incorrect handling of NextGEN Styles in multisite environments
* Fixed: Not honouring NGG_IMPORT_ROOT constant
* Fixed: Fixed inability to edit gallery properties using XMLRPC's edit_gallery method
* Fixed: Alignment issues in Basic Compact Albums caused by subalbums not displaying image 'counter'
* Fixed: Display setting forms compatibility issue with WordPress 3.9
* Fixed; Compability with jQuery Dialogs in WordPress 3.9
* Fixed: Maximum entity code should be a displayed gallery property for recent/random sources only
* Fixed: Problems with zlib compression:
* Fixed: Support for web servers which use a document root of '//'
* Fixed: Compatibility with WPML Translation Management
* Fixed: use 'del' for function name in ngg_store.js, 'delete' is a reserved keyword
* Fixed: Enqueue fontawesome only when necessary
* Fixed: Suhosin compatibility issue when overriding PHP memory limit
* Fixed: Handle images of wrong image type correctly when trying to create cropped thumbnails
* Fixed: Datamapper entities not allowed to have properties with a value of 0
* Fixed: Resource manager is manipulating feeds
* Fixed: Convert absolute urls to relative urls for lightboxes
* Fixed: Start the resource manager as early as we can within the init action
* Fixed: Routing problem for galleries with images named 1.jpg, 2.jpg, 3.jpg, etc.
* Fixed: Added tooltips to basic slideshow settings
* Fixed: Remove CKEditor's NextGEN button, which is incompatible with NextGEN Gallery 2.x
= V2.0.61 - 04.01.2014 =
* Fixed: Compatibility with WP 3.9
* Fixed: Exception thrown when using Reset button
= V2.0.59 - 03.18.2014 =
* Changed: Separated pope_module_list from ngg_options record in options table
* Fixed: Removed code causing jQuery compatibility issues in WP Admin
* Fixed: Allow third-parties to override jQuery with Google's CDN
* Fixed: When resetting the 'jquery' handle, ensure that jquery-migrate is a dependency
* Fixed: Silenced many PHP warnings
* Fixed: Datamapper->count() not returning the correct count
* Fixed: Compatibility with Gravity Forms
= V2.0.58 - 03.10.2014 =
* Fixed: Reset jQuery to WP defaults when modified by a third-party
* Fixed: Compatibility with WP jQuery Lightbox plugin
* Fixed: Compatibility with Peekaboo theme
= V2.0.57 - 03.05.2014 =
* NEW: Re-introduced the Reset button
* NEW: Tooltip added for Page Link to functionality
* NEW: Displayed Gallery Triggers moved from NextGEN Pro to NextGEN Gallery (not in use)
* NEW: Added NGG_Store, a client-side persistence layer (not in use)
* NEW: Added NGG_CRON_SCHEDULE constant. Set to the number of seconds between the execution of NextGEN Gallery cron jobs
* NEW: Added NGG_RENDERING_CACHE_TTL constant. TTL measured in seconds.
* NEW: Added NGG_DISPLAYED_GALLERY_CACHE_TTL constant. TTL measured in seconds.
* NEW: Added NGG_DISABLE_LEGACY_SHORTCODES constant. When TRUE, [slideshow] becomes [nggslideshow].
* NEW: Added Font Awesome, available for NextGEN Gallery extensions
* Changed: Transients are removed every 30 minutes instead of 60 minutes
* Changed: Admin Page & Form components refactored to allow custom POST processing
* Changed: Default path for NEW multisite installations to wp-content/uploads/sites/%BLOG_ID%/nggallery/
* Fixed: Ability to upload ZIP files on Windows hosts
* Fixed: Support for filenames with non-ASCII characters
* Fixed: Dynamic updates in the Attach to Post interface (interframe communication)
* Fixed: Attach to Post interface freezing in IE11
* Fixed: Path issues on Windows Servers
* Fixed: Module installer integrity
* Fixed: Database query performance. No more joins to the WP options table
* Fixed: Lightboxes storing absolute paths for static resources
* Fixed: Displayed gallery cache not regularly flushed
* Fixed: SQL query performance problems. Honor max_packet_allowed variable for MySQL
* Fixed: Multiple database queries generated for determining next available image slug
* Fixed: Corrupted MediaRSS feeds
* Fixed: Padding on Gallery Settings and Other Options pages
* Fixed: Routing issues on subdirectory installs
* Fixed: Importing galleries using the Attach to Post Interface
* Fixed: Gallery path calculations on Windows web servers
* Fixed: Sub-album urls not processed correctly
* Fixed: Apply maximum entity count to existing displayed galleries
* Fixed: NextGEN Gallery Thumbnail Widget shouldn't use ImageBrowser effect
* Fixed: Ability to set shuffle parameter for ImageRotator slideshows
* Fixed: PHP warning about HTMLDocument when displaying a SinglePic
* Fixed: Sanitization of gallery title
* Fixed: Home URL now used instead of Site URL in MediaRSS feed
* Fixed: Attach to Post interface broken when WPML is installed
* Fixed: Attach to Post interface instructing browser to cache the page
* Fixed: Watermarking not working in low-memory environments
* Fixed: Maximum images limit not being applied for galleries already created.
* Fixed: Double forward slashes in static urls
* Fixed: Don't sleep when checking if the installer is running
* Fixed: Don't enforce Pope interface contracts
* Fixed: Remove custom table extra records from wp_options table
* Fixed: Scan folder for new images not working
* Fixed: Incorrect page permalink used for "Page Link To" functionality
* Fixed: Pagination broken when Basic Thumbnail gallery on the same page as Basic Album
* Fixed: parse_url() warnings generated for PHP 5.3.3 and earlier
* Fixed: Compatibility with Headway Themes
* Fixed: Compatibility with web servers which don't provide PHP a document root
* Fixed: Third-party incompatibilities caused by the Photocrati Resource Manager
* Fixed: Compatibility with the Flattr plugin
* Fixed: Compatibility with the Weaver II theme
* Fixed: Interface tweaks for WordPress 3.8
= V2.0.40 - 11.26.2013 =
* NEW: Added the ability to apply lightbox effects to non-NGG images
* NEW: Added NGG_HIDE_STRICT_ERRORS constant. Define and set to TRUE to hide strict errors
* NEW: Added NEXTGEN_GALLERY_IMPORT_ROOT constant. Define and set to TRUE to browse from a custom directory
* NEW: Added NGG_DEBUG constant. Define and set to TRUE to display helpful messages for debugging
* NEW: Each custom table record will have an associated custom post record for expansion
* NEW: Display helpful error messages when there's a problem uploading images
* NEW: Add data-(src|thumbnail|image-id|title|description) attribute to gallery image anchors
* NEW: Variant support for displayed gallery sources. Random images is limited to 5 variations
* Fixed: Excessive creation of transients for random galleries
* Fixed: Many issues prohibiting the ability to upload images
* Fixed: Compatibility with NextGEN Gallery Export Plugin for Adobe Lightroom (thanks Vladimir!)
* Fixed: Sorting in the Attach to Post interface
* Fixed: HTML allowed in gallery/album descriptions
* Fixed: Requests for galleries within albums that have numeric names are broken
* Fixed: Call to a non-member function get() on WP_Query
* Fixed: Ability to sort by Image ID in the Attach to Post interface
* Fixed: Isolate the Attach to Post from implicit third-party script inclusion
* Fixed: Check for the existance of thumbnails when generating urls, and if missing, generate new ones
* Fixed: Compatibility with NextGEN Facebook OpenGraph+ plugin
* Fixed: Various XML-RPC issues
* Fixed: Widgets stylesheet not included
* Fixed: Issue with color not being pre-selected when previewing Watermark
* Fixed: E_NOTICE emitted when cleaning up cached image files
* Fixed: E_NOTICE emitted when viewing display type settings
* Fixed: Typo adjusting pcre.backtrack_limit for shortcodes
* Fixed: Content within the tabs of the Attach to Post interface cut-off
* Fixed: Routing problem which would cause conflicts with different display types on the same page
* Fixed: Broken Dynamic CSS links on GoDaddy
* Fixed: Ability to use HTML in gallery/album descriptions
* Fixed: Sub-album requests conflicting with paginated galleries on the same page
* Merged: Pull request from andreasE (
= V2.0.33 - 10.21.2013 =
* NEW: Requests /ngg_tag/[tagname] will create a displayed gallery
* NEW: Option added to "Import Gallery" tab to use original images
......@@ -3,8 +3,8 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You
* Plugin Name: NextGEN Gallery by Photocrati
* Description: The most popular gallery plugin for WordPress and one of the most popular plugins of all time with over 7 million downloads.
* Version: 2.0.33
* Description: The most popular gallery plugin for WordPress and one of the most popular plugins of all time with over 9 million downloads.
* Version: 2.0.63
* Author: Photocrati Media
* Plugin URI:
* Author URI:
......@@ -12,6 +12,51 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You
if (!class_exists('E_Clean_Exit')) { class E_Clean_Exit extends RuntimeException {} }
if (!class_exists('E_NggErrorException')) { class E_NggErrorException extends RuntimeException {} }
// This is a temporary function to replace the use of WP's esc_url which strips spaces away from URLs
// TODO: Move this to a better place
if (!function_exists('nextgen_esc_url')) {
function nextgen_esc_url( $url, $protocols = null, $_context = 'display' ) {
$original_url = $url;
if ( '' == $url )
return $url;
$url = preg_replace('|[^a-z0-9 \\-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
$strip = array('%0d', '%0a', '%0D', '%0A');
$url = _deep_replace($strip, $url);
$url = str_replace(';//', '://', $url);
/* If the URL doesn't appear to contain a scheme, we
* presume it needs http:// appended (unless a relative
* link starting with /, # or ? or a php file).
if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
! preg_match('/^[a-z0-9-]+?\.php/i', $url) )
$url = 'http://' . $url;
// Replace ampersands and single quotes only when displaying.
if ( 'display' == $_context ) {
$url = wp_kses_normalize_entities( $url );
$url = str_replace( '&', '&', $url );
$url = str_replace( "'", ''', $url );
$url = str_replace( '%', '%25', $url );
$url = str_replace( ' ', '%20', $url );
if ( '/' === $url[0] ) {
$good_protocol_url = $url;
} else {
if ( ! is_array( $protocols ) )
$protocols = wp_allowed_protocols();
$good_protocol_url = wp_kses_bad_protocol( $url, $protocols );
if ( strtolower( $good_protocol_url ) != strtolower( $url ) )
return '';
return apply_filters('clean_url', $good_protocol_url, $original_url, $_context);
* NextGEN Gallery is built on top of the Photocrati Pope Framework:
......@@ -33,7 +78,7 @@ class C_NextGEN_Bootstrap
var $_registry = NULL;
var $_settings_option_name = 'ngg_options';
var $_pope_loaded = FALSE;
static $debug = WP_DEBUG;
static $debug = FALSE;
static function shutdown($exception=NULL)
......@@ -52,7 +97,7 @@ class C_NextGEN_Bootstrap
$klass = get_class($exception);
echo "<h1>{$klass} thrown</h1>";
echo "<p>{$exception->getMessage()}</p>";
if (self::$debug OR (defined('NGG_DEBUG') AND NGG_DEBUG == TRUE)) {
echo "<h3>Where:</h3>";
echo "<p>On line <strong>{$exception->getLine()}</strong> of <strong>{$exception->getFile()}</strong></p>";
echo "<h3>Trace:</h3>";
......@@ -65,16 +110,40 @@ class C_NextGEN_Bootstrap
static function get_backtrace($objects=FALSE, $remove_dynamic_calls=TRUE)
$trace = debug_backtrace($objects);
if ($remove_dynamic_calls) {
$skip_methods = array(
foreach ($trace as $key => &$value) {
if (isset($value['class']) && isset($value['function'])) {
if ($value['class'] == 'ReflectionMethod' && $value['function'] == 'invokeArgs')
else if ($value['class'] == 'ExtensibleObject' && in_array($value['function'], $skip_methods))
return $trace;
function __construct()
// Boostrap
function _load_non_pope()
......@@ -83,11 +152,13 @@ class C_NextGEN_Bootstrap
C_Photocrati_Cache::$enabled = TRUE;
C_Photocrati_Cache::$enabled = PHOTOCRATI_CACHE;
if (isset($_REQUEST['ngg_flush'])) {
$_SERVER['QUERY_STRING'] = str_replace('ngg_flush=1', '', $_SERVER['QUERY_STRING']);
die("Flushed all caches");
elseif (isset($_REQUEST['ngg_force_update'])) {
C_Photocrati_Cache::$do_not_lookup = TRUE;
......@@ -96,7 +167,7 @@ class C_NextGEN_Bootstrap
elseif (isset($_REQUEST['ngg_flush_expired'])) {
C_Photocrati_Cache::flush('all', TRUE);
$_SERVER['QUERY_STRING'] = str_replace('ngg_flush_expired=1', '', $_SERVER['QUERY_STRING']);
die("Flushed all expired items from the cache");
// Load Settings Manager
......@@ -132,9 +203,9 @@ class C_NextGEN_Bootstrap
if ($tmp && (int)$tmp <= 300) @ini_set('xdebug.max_nesting_level', 300);
// Include pope framework
require_once(path_join(NEXTGEN_GALLERY_PLUGIN_DIR, implode(
DIRECTORY_SEPARATOR, array('pope','lib','autoload.php')
DIRECTORY_SEPARATOR, array(NGG_PLUGIN_DIR, 'pope','lib','autoload.php')
// Get the component registry
$this->_registry = C_Component_Registry::get_instance();
......@@ -144,19 +215,16 @@ class C_NextGEN_Bootstrap
// Load embedded products. Each product is expected to load any
// modules required
$this->_registry->add_module_path(NEXTGEN_GALLERY_PRODUCT_DIR, true, false);
$this->_registry->add_module_path(NGG_PRODUCT_DIR, true, false);
// Give third-party plugins that opportunity to include their own products
// and modules
do_action('load_nextgen_gallery_modules', $this->_registry);
// Give third-party plugins that opportunity to include their own products
// and modules
do_action('load_nextgen_gallery_modules', $this->_registry);
// Initializes all loaded modules
// Set the document root
$this->_pope_loaded = TRUE;
......@@ -167,18 +235,11 @@ class C_NextGEN_Bootstrap
function _register_hooks()
// Load text domain
// Register the activation routines
add_action('activate_'.NEXTGEN_GALLERY_PLUGIN_BASENAME, array(get_class(), 'activate'));
add_action('activate_'.NGG_PLUGIN_BASENAME, array(get_class(), 'activate'));
// Register the deactivation routines
add_action('deactivate_'.NEXTGEN_GALLERY_PLUGIN_BASENAME, array(get_class(), 'deactivate'));
add_action('deactivate_'.NGG_PLUGIN_BASENAME, array(get_class(), 'deactivate'));
// Register our test suite
add_filter('simpletest_suites', array(&$this, 'add_testsuite'));
......@@ -188,9 +249,10 @@ class C_NextGEN_Bootstrap
add_filter('pre_update_site_option_'.$this->_settings_option_name, array(&$this, 'persist_settings'));
// This plugin uses jQuery extensively
add_action('init', array(&$this, 'enqueue_jquery'), 1);
add_action('wp_print_scripts', array(&$this, 'fix_jquery'));
add_action('admin_print_scripts', array(&$this, 'fix_jquery'));
add_action('wp_enqueue_scripts', array(&$this, 'fix_jquery'));
add_action('wp_print_scripts', array(&$this, 'fix_jquery'));
// If the selected stylesheet is using an unsafe path, then notify the user
if (C_NextGen_Style_Manager::get_instance()->is_directory_unsafe()) {
......@@ -198,18 +260,43 @@ class C_NextGEN_Bootstrap
// Delete displayed gallery transients periodically
add_filter('cron_schedules', array(&$this, 'add_ngg_schedule'));