{$klass} thrown"; echo "
{$exception->getMessage()}
"; if (self::$debug OR (defined('NGG_DEBUG') AND NGG_DEBUG == TRUE)) { echo "On line {$exception->getLine()} of {$exception->getFile()}
"; echo "{$exception->getTraceAsString()}";
if (method_exists($exception, 'getPrevious')) {
if (($previous = $exception->getPrevious())) {
self::print_exception($previous);
}
}
}
}
static function get_backtrace($objects=FALSE, $remove_dynamic_calls=TRUE)
{
$trace = debug_backtrace($objects);
if ($remove_dynamic_calls) {
$skip_methods = array(
'_exec_cached_method',
'__call',
'get_method_property',
'set_method_property',
'call_method'
);
foreach ($trace as $key => &$value) {
if (isset($value['class']) && isset($value['function'])) {
if ($value['class'] == 'ReflectionMethod' && $value['function'] == 'invokeArgs')
unset($trace[$key]);
else if ($value['class'] == 'ExtensibleObject' && in_array($value['function'], $skip_methods))
unset($trace[$key]);
}
}
}
return $trace;
}
function __construct()
{
set_exception_handler(__CLASS__.'::shutdown');
// We only load the plugin if we're outside of the activation request, loaded in an iframe
// by WordPress. Reason being, if WP_DEBUG is enabled, and another Pope-based plugin (such as
// the photocrati theme or NextGEN Pro/Plus), then PHP will output strict warnings
if ($this->is_not_activating()) {
$this->_define_constants();
$this->_load_non_pope();
$this->_register_hooks();
$this->_load_pope();
}
}
function is_not_activating()
{
return !$this->is_activating();
}
function is_activating()
{
$retval = strpos($_SERVER['REQUEST_URI'], 'plugins.php') !== FALSE && isset($_REQUEST['action']) && $_REQUEST['action'] == 'activate';
if (!$retval && strpos($_SERVER['REQUEST_URI'], 'update.php') !== FALSE && isset($_REQUEST['action']) && $_REQUEST['action'] == 'install-plugin' && isset($_REQUEST['plugin']) && strpos($_REQUEST['plugin'], 'nextgen-gallery') === 0) {
$retval = TRUE;
}
if (!$retval && strpos($_SERVER['REQUEST_URI'], 'update.php') !== FALSE && isset($_REQUEST['action']) && $_REQUEST['action'] == 'activate-plugin' && isset($_REQUEST['plugin']) && strpos($_REQUEST['plugin'], 'nextgen-gallery') === 0) {
$retval = TRUE;
}
return $retval;
}
function _load_non_pope()
{
// Load caching component
include_once('non_pope/class.photocrati_transient_manager.php');
if (isset($_REQUEST['ngg_flush']) OR isset($_REQUEST['ngg_flush_expired'])) {
C_Photocrati_Transient_Manager::flush();
die("Flushed all caches");
}
// Load Settings Manager
include_once('non_pope/class.photocrati_settings_manager.php');
include_once('non_pope/class.nextgen_settings.php');
C_Photocrati_Global_Settings_Manager::$option_name = $this->_settings_option_name;
C_Photocrati_Settings_Manager::$option_name = $this->_settings_option_name;
// Load the installer
include_once('non_pope/class.photocrati_installer.php');
// Load the resource manager
include_once('non_pope/class.photocrati_resource_manager.php');
C_Photocrati_Resource_Manager::init();
// Load the style manager
include_once('non_pope/class.nextgen_style_manager.php');
// Load the shortcode manager
include_once('non_pope/class.nextgen_shortcode_manager.php');
}
/**
* Loads the Pope Framework
*/
function _load_pope()
{
// No need to initialize pope again
if ($this->_pope_loaded) return;
// Pope requires a a higher limit
$tmp = ini_get('xdebug.max_nesting_level');
if ($tmp && (int)$tmp <= 300) @ini_set('xdebug.max_nesting_level', 300);
// Include pope framework
require_once(implode(
DIRECTORY_SEPARATOR, array(NGG_PLUGIN_DIR, 'pope','lib','autoload.php')
));
// Enable/disable pope caching. For now, the pope cache will not be used in multisite environments
if (class_exists('C_Pope_Cache')) {
if ((C_Pope_Cache::$enabled = NGG_POPE_CACHE)) {
$blogid = (is_multisite() ? get_current_blog_id() : NULL);
if (isset($_SERVER['SERVER_ADDR']))
$cache_key_prefix = abs(crc32((implode('|', array($blogid, site_url(), AUTH_KEY, $_SERVER['SERVER_ADDR'])))));
else
$cache_key_prefix = abs(crc32(implode('|', array($blogid, site_url(), AUTH_KEY))));
C_Pope_Cache::set_driver('C_Pope_Cache_SingleFile');
C_Pope_Cache::add_key_prefix($cache_key_prefix);
}
}
// Enforce interfaces
if (property_exists('ExtensibleObject', 'enforce_interfaces')) ExtensibleObject::$enforce_interfaces = EXTENSIBLE_OBJECT_ENFORCE_INTERFACES;
// Get the component registry
$this->_registry = C_Component_Registry::get_instance();
// Add the default Pope factory utility, C_Component_Factory
$this->_registry->add_utility('I_Component_Factory', 'C_Component_Factory');
// Blacklist any modules which are known NOT to work with this version of NextGEN Gallery
// We need to check if we have this ability as it's only available with Pope 0.9
if (method_exists($this->_registry, 'blacklist_module_file')) {
$this->_registry->blacklist_module_file('module.nextgen_pro_lightbox_legacy.php');
$this->_registry->blacklist_module_file('module.protect_image.php');
// TODO: Add module id for protect image
}
// If Pro is incompatible, then we need to blacklist all of Pro's modules
// TODO: Pope needs a better way of introspecting into a product's list of provided modules
if ($this->is_pro_incompatible()) {
$pro_modules = array(
'photocrati-comments',
'photocrati-galleria',
'photocrati-nextgen_pro_slideshow',
'photocrati-nextgen_pro_horizontal_filmstrip',
'photocrati-nextgen_pro_thumbnail_grid',
'photocrati-nextgen_pro_blog_gallery',
'photocrati-nextgen_pro_film',
'photocrati-nextgen_pro_masonry',
'photocrati-nextgen_pro_albums',
'photocrati-nextgen_pro_lightbox',
'photocrati-nextgen_pro_lightbox_legacy',
'photocrati-nextgen_pro_ecommerce',
'photocrati-paypal_express_checkout',
'photocrati-paypal_standard',
'photocrati-stripe'
);
foreach ($pro_modules as $mod) $this->_registry->blacklist_module_file($mod);
}
// Load embedded products. Each product is expected to load any
// modules required
$this->_registry->add_module_path(NGG_PRODUCT_DIR, 2, false);
$this->_registry->load_all_products();
// 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
$this->_registry->initialize_all_modules();
$this->_pope_loaded = TRUE;
}
function is_pro_compatible()
{
$retval = TRUE;
if (defined('NEXTGEN_GALLERY_PRO_VERSION')) $retval = FALSE;
if (defined('NEXTGEN_GALLERY_PRO_PLUGIN_BASENAME') && !defined('NGG_PRO_PLUGIN_VERSION')) $retval = FALSE; // 1.0 - 1.0.6
if (defined('NGG_PRO_PLUGIN_VERSION') && version_compare(NGG_PRO_PLUGIN_VERSION, $this->minimum_ngg_pro_version) < 0) $retval = FALSE;
if (defined('NGG_PLUS_PLUGIN_VERSION') && version_compare(NGG_PLUS_PLUGIN_VERSION, $this->minimum_ngg_plus_version) < 0) $retval = FALSE;
return $retval;
}
function is_pro_incompatible()
{
return !$this->is_pro_compatible();
}
function render_incompatibility_warning()
{
echo ''; echo esc_html( sprintf( __("NextGEN Gallery %s is incompatible with this version of NextGEN Pro. Please update NextGEN Pro to version %s or higher to restore NextGEN Pro functionality.", 'nggallery' ), NGG_PLUGIN_VERSION, $this->minimum_ngg_pro_version )); echo '
{$filename} is currently stored in {$abspath}, which isn't upgrade-safe. Please move the stylesheet to {$newpath} to ensure that your customizations persist after updates.