is_activating() && ! $this->is_topscorer_request() ) { $this->define_constants(); $this->add_legacy_pro_compat(); $this->register_hooks(); include_once NGG_PLUGIN_DIR . '/src/Functions/deprecated.php'; include_once NGG_PLUGIN_DIR . '/src/Functions/admin.php'; include_once NGG_PLUGIN_DIR . '/src/Functions/compat.php'; // Legacy NGG 1x code was not namespaced and must be loaded manually before POPE. include_once NGG_PLUGIN_DIR . '/src/Legacy/nggallery.php'; $this->notifications = new AMNotifications(); $this->notifications->hooks(); if ( is_admin() ) { ( new About() )->hooks(); ( new MenuNudge() )->hooks(); ( new Ecommerce_Preview() )->hooks(); } $this->load_pope(); do_action( 'ngg_initialized' ); } } /** * @deprecated This class will be removed if there's no complaints made after defaulting to the NGG_ENABLE_SHUTDOWN_EXCEPTION_HANDLER constant * @param Exception $exception */ public static function shutdown( $exception = null ) { if ( is_null( $exception ) ) { $name = php_sapi_name(); if ( false === strpos( $name, 'cgi' ) && version_compare( PHP_VERSION, '5.3.3' ) >= 0 ) { $status = session_status(); if ( in_array( $status, [ PHP_SESSION_DISABLED, PHP_SESSION_NONE ], true ) ) { session_write_close(); } fastcgi_finish_request(); } else { exit(); } } elseif ( ! ( $exception instanceof E_Clean_Exit ) ) { if ( ob_get_level() > 0 ) { ob_end_clean(); } self::print_exception( $exception ); } } public static function print_exception( $exception ) { $klass = get_class( $exception ); 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 );
}
}
}
}
public function autoloader( $class ) {
$prefix = 'Imagely\\NGG\\';
$base_dir = __DIR__ . '/src/';
$len = strlen( $prefix );
if ( strncmp( $prefix, $class, $len ) !== 0 ) {
return;
}
$relative_class = substr( $class, $len );
$file = $base_dir . str_replace( '\\', DIRECTORY_SEPARATOR, $relative_class ) . '.php';
if ( file_exists( $file ) ) {
require $file;
}
}
public function is_topscorer_request() {
// Nonce verification is not necessary here: NextGEN skips loading certain components based on the URL in order
// to maintain compatibility with the Top Scorer plugin.
//
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
return strpos( $_SERVER['REQUEST_URI'], 'topscorer/v1' ) !== false;
}
public function is_activating(): bool {
// Nonce verification is not necessary here: NextGEN will not load various components if the current URL
// indicates that WordPress is in the process of activating a plugin.
//
// phpcs:disable WordPress.Security.NonceVerification.Recommended
$retval = strpos( $_SERVER['REQUEST_URI'], 'plugins.php' ) !== false && isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], [ 'activate-selected' ] );
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;
// phpcs:enable WordPress.Security.NonceVerification.Recommended
}
/**
* These methods will be removed over time once the announcement of their deprecation has been made public. In
* order to allow third party code to remain compatible this is not being placed behind a compatibility level
* check.
*/
public function add_legacy_pro_compat() {
class_alias( '\Imagely\NGG\Admin\FormManager', 'C_Form_Manager' );
class_alias( '\Imagely\NGG\Admin\Notifications\Manager', 'C_Admin_Notification_Manager' );
class_alias( '\Imagely\NGG\Admin\RequirementsManager', 'C_Admin_Requirements_Manager' );
class_alias( '\Imagely\NGG\DataMappers\Album', 'C_Album_Mapper' );
class_alias( '\Imagely\NGG\DataMappers\Gallery', 'C_Gallery_Mapper' );
class_alias( '\Imagely\NGG\DataMappers\Image', 'C_Image_Mapper' );
class_alias( '\Imagely\NGG\DataStorage\MetaData', 'C_NextGen_Metadata' );
class_alias( '\Imagely\NGG\DataTypes\LegacyImage', 'C_Image_Wrapper' );
class_alias( '\Imagely\NGG\DataTypes\Lightbox', 'C_NGG_Lightbox' );
class_alias( '\Imagely\NGG\DisplayType\Installer', 'C_Display_Type_Installer' );
class_alias( '\Imagely\NGG\DisplayType\InstallerProxy', 'C_Gallery_Display_Installer' );
class_alias( '\Imagely\NGG\DisplayTypes\Taxonomy', 'C_Taxonomy_Controller' );
class_alias( '\Imagely\NGG\Display\I18N', 'M_I18N' );
class_alias( '\Imagely\NGG\Display\Shortcodes', 'C_NextGen_Shortcode_Manager' );
class_alias( '\Imagely\NGG\DisplayedGallery\Renderer', 'C_Displayed_Gallery_Renderer' );
class_alias( '\Imagely\NGG\DisplayedGallery\TriggerManager', 'C_Displayed_Gallery_Trigger_Manager' );
class_alias( '\Imagely\NGG\DynamicStylesheets\Manager', 'C_Dynamic_Stylesheet_Controller' );
class_alias( '\Imagely\NGG\DynamicThumbnails\Manager', 'C_Dynamic_Thumbnails_Manager' );
class_alias( '\Imagely\NGG\IGW\ATPManager', 'M_Attach_To_Post' );
class_alias( '\Imagely\NGG\IGW\Controller', 'C_Attach_Controller' );
class_alias( '\Imagely\NGG\Settings\Settings', 'C_NextGen_Settings' );
class_alias( '\Imagely\NGG\Settings\Settings', 'C_Photocrati_Settings_Manager' );
class_alias( '\Imagely\NGG\Util\Filesystem', 'C_Fs' );
class_alias( '\Imagely\NGG\Util\Installer', 'C_Photocrati_Installer' );
class_alias( '\Imagely\NGG\Util\Router', 'C_Router' );
class_alias( '\Imagely\NGG\Util\RoutingApp', 'C_Routing_App' );
class_alias( '\Imagely\NGG\Util\Serializable', 'C_NextGen_Serializable' );
class_alias( '\Imagely\NGG\Util\Transient', 'C_Photocrati_Transient_Manager' );
}
public function fix_loading_order() {
// If a plugin wasn't activated/deactivated siliently, we can listen for these things.
if ( did_action( 'activate_plugin' ) || did_action( 'deactivate_plugin' ) ) {
return;
} elseif ( strpos( $_SERVER['REQUEST_URI'], 'plugins' ) !== false ) {
return;
} elseif ( ! $this->is_page_request() ) {
return;
}
$plugins = get_option( 'active_plugins' );
// Remove NGG from the list.
$ngg = basename( __DIR__ ) . '/' . basename( __FILE__ );
$order = [];
foreach ( $plugins as $plugin ) {
if ( $plugin != $ngg ) {
$order[] = $plugin;
}
}
// Get the position of either NGG Pro or NGG Plus.
$insert_at = false;
for ( $i = 0; $i < count( $order ); $i++ ) {
$plugin = $order[ $i ];
if ( strpos( $plugin, 'nggallery-pro' ) !== false ) {
$insert_at = $i + 1;
} elseif ( strpos( $plugin, 'ngg-plus' ) !== false ) {
$insert_at = $i + 1;
}
}
// Re-insert NGG after Pro or Plus.
if ( $insert_at === false || $insert_at === count( $order ) ) {
$order[] = $ngg;
} elseif ( $insert_at === 0 ) {
array_unshift( $order, $ngg );
} else {
array_splice( $order, $insert_at, 0, [ $ngg ] );
}
if ( $order != $plugins ) {
$order = array_filter( $order );
update_option( 'active_plugins', $order );
}
}
public static function get_legacy_module_directory( $module_id ) {
// POPE is not loaded; return the result from a manual mapping of id -> directory name.
$module_dir = null;
if ( $module_id === 'photocrati-nextgen_pagination' ) {
$module_dir = 'nextgen_pagination';
}
if ( $module_id === 'photocrati-attach_to_post' ) {
$module_dir = 'attach_to_post';
}
if ( $module_id === 'photocrati-cache' ) {
$module_dir = 'cache';
}
if ( $module_id === 'photocrati-dynamic_stylesheet' ) {
$module_dir = 'dynamic_stylesheet';
}
if ( $module_id === 'photocrati-dynamic_thumbnails' ) {
$module_dir = 'dynamic_thumbnails';
}
if ( $module_id === 'photocrati-frame_communication' ) {
$module_dir = 'frame_communication';
}
if ( $module_id === 'photocrati-fs' ) {
$module_dir = 'fs';
}
if ( $module_id === 'photocrati-i18n' ) {
$module_dir = 'i18n';
}
if ( $module_id === 'photocrati-lightbox' ) {
$module_dir = 'lightbox';
}
if ( $module_id === 'photocrati-nextgen-data' ) {
$module_dir = 'nextgen_data';
}
if ( $module_id === 'photocrati-nextgen-legacy' ) {
$module_dir = 'ngglegacy';
}
if ( $module_id === 'photocrati-nextgen_basic_gallery' ) {
$module_dir = 'nextgen_basic_gallery';
}
if ( $module_id === 'photocrati-nextgen_basic_thumbnails' ) {
$module_dir = 'nextgen_basic_gallery';
}
if ( $module_id === 'photocrati-nextgen_basic_slideshow' ) {
$module_dir = 'nextgen_basic_gallery';
}
if ( $module_id === 'photocrati-nextgen_basic_imagebrowser' ) {
$module_dir = 'nextgen_basic_imagebrowser';
}
if ( $module_id === 'photocrati-nextgen_basic_singlepic' ) {
$module_dir = 'nextgen_basic_singlepic';
}
if ( $module_id === 'photocrati-nextgen_basic_tagcloud' ) {
$module_dir = 'nextgen_basic_tagcloud';
}
if ( $module_id === 'photocrati-nextgen_basic_templates' ) {
$module_dir = 'nextgen_basic_templates';
}
if ( $module_id === 'photocrati-nextgen_block' ) {
$module_dir = 'nextgen_block';
}
if ( $module_id === 'photocrati-nextgen_gallery_display' ) {
$module_dir = 'nextgen_gallery_display';
}
if ( $module_id === 'photocrati-ajax' ) {
$module_dir = 'ajax';
}
if ( $module_dir ) {
return NGG_MODULE_DIR . DIRECTORY_SEPARATOR . $module_dir;
}
if ( defined( 'NGG_PRO_MODULES_DIR' ) ) {
// This is a bit of a hack, but it's easiest to just dump all of these here in one place.
// The following are all Starter/Plus/Pro modules.
if ( $module_id === 'photocrati-nextgen_pro_captions' ) {
$module_dir = 'nextgen_pro_captions';
}
if ( $module_id === 'photocrati-nextgen_pro_ecommerce' ) {
$module_dir = 'ecommerce';
}
if ( $module_id === 'photocrati-auto_update' ) {
$module_dir = 'autoupdate';
}
if ( $module_id === 'photocrati-auto_update-admin' ) {
$module_dir = 'autoupdate_admin';
}
if ( $module_id === 'imagely-braintree' ) {
$module_dir = 'braintree';
}
if ( $module_id === 'photocrati-cheque' ) {
$module_dir = 'cheque';
}
if ( $module_id === 'photocrati-comments' ) {
$module_dir = 'comments';
}
if ( $module_id === 'photocrati-coupons' ) {
$module_dir = 'coupons';
}
if ( $module_id === 'photocrati-free_gateway' ) {
$module_dir = 'free_gateway';
}
if ( $module_id === 'photocrati-galleria' ) {
$module_dir = 'galleria';
}
if ( $module_id === 'photocrati-image_protection' ) {
$module_dir = 'image_protection';
}
if ( $module_id === 'imagely-licensing' ) {
$module_dir = 'licensing';
}
if ( $module_id === 'photocrati-nextgen_pro_albums' ) {
$module_dir = 'nextgen_pro_albums';
}
if ( $module_id === 'photocrati-nextgen_pro_blog_gallery' ) {
$module_dir = 'nextgen_pro_blog_gallery';
}
if ( $module_id === 'photocrati-nextgen_pro_film' ) {
$module_dir = 'nextgen_pro_film';
}
if ( $module_id === 'photocrati-nextgen_pro_horizontal_filmstrip' ) {
$module_dir = 'nextgen_pro_horizontal_filmstrip';
}
if ( $module_id === 'photocrati-nextgen_pro_i18n' ) {
$module_dir = 'nextgen_pro_i18n';
}
if ( $module_id === 'photocrati-nextgen_pro_imagebrowser' ) {
$module_dir = 'nextgen_pro_imagebrowser';
}
if ( $module_id === 'photocrati-nextgen_pro_lightbox' ) {
$module_dir = 'nextgen_pro_lightbox';
}
if ( $module_id === 'photocrati-nextgen_pro_marketing' ) {
$module_dir = 'nextgen_pro_marketing';
}
if ( $module_id === 'photocrati-nextgen_pro_masonry' ) {
$module_dir = 'nextgen_pro_masonry';
}
if ( $module_id === 'photocrati-nextgen_pro_mosaic' ) {
$module_dir = 'nextgen_pro_mosaic';
}
if ( $module_id === 'photocrati-nextgen_pro_proofing' ) {
$module_dir = 'nextgen_pro_proofing';
}
if ( $module_id === 'photocrati-nextgen_pro_settings' ) {
$module_dir = 'nextgen_pro_settings';
}
if ( $module_id === 'photocrati-nextgen_pro_sidescroll' ) {
$module_dir = 'nextgen_pro_sidescroll';
}
if ( $module_id === 'photocrati-nextgen_pro_slideshow' ) {
$module_dir = 'nextgen_pro_slideshow';
}
if ( $module_id === 'photocrati-nextgen_pro_thumbnail_grid' ) {
$module_dir = 'nextgen_pro_thumbnail_grid';
}
if ( $module_id === 'photocrati-nextgen_pro_tile' ) {
$module_dir = 'nextgen_pro_tile';
}
if ( $module_id === 'photocrati-pro-wpcli' ) {
$module_dir = 'nextgen_pro_wpcli';
}
if ( $module_id === 'photocrati-paypal_checkout' ) {
$module_dir = 'paypal_checkout';
}
if ( $module_id === 'photocrati-paypal_express_checkout' ) {
$module_dir = 'paypal_express_checkout';
}
if ( $module_id === 'photocrati-paypal_standard' ) {
$module_dir = 'paypal_standard';
}
if ( $module_id === 'photocrati-nextgen_picturefill' ) {
$module_dir = 'picturefill';
}
if ( $module_id === 'imagely-pro-search' ) {
$module_dir = 'search';
}
if ( $module_id === 'photocrati-stripe' ) {
$module_dir = 'stripe';
}
if ( $module_id === 'photocrati-test_gateway' ) {
$module_dir = 'test_gateway';
}
if ( $module_dir ) {
return NGG_PRO_MODULES_DIR . DIRECTORY_SEPARATOR . $module_dir;
}
}
// The module was not in the list above, consult POPE if possible.
if ( self::$pope_loaded ) {
return \C_Component_Registry::get_instance()->get_module_dir( $module_id );
}
return $module_dir;
}
public function load_pope( $force = false ) {
// We allow POPE to load if the requested URL/POST includes photocrati_ajax as it is still used by a few NextGEN
// modules for XHR such as uploading images.
//
// Nonce verification is not necessary here.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! $force
&& empty( $_REQUEST['photocrati_ajax'] )
&& ( self::get_pro_api_version() >= 4.0 && ! is_admin() )
&& ! defined( 'EWWW_IMAGE_OPTIMIZER_VERSION' ) // EWWW uses I_Gallery_Storage.
&& ! defined( 'WP_SMUSH_VERSION' ) // WP_SMUSH_VERSION uses I_Gallery_Storage.
&& ! defined( 'IMAGIFY_VERSION' ) // Imagify adds their own mixin to C_Gallery_Storage.
|| self::$pope_loaded ) {
return;
}
// Pope requires a higher limit.
$tmp = ini_get( 'xdebug.max_nesting_level' );
if ( $tmp && (int) $tmp <= 300 ) {
@ini_set( 'xdebug.max_nesting_level', 300 );
}
// Enforce interfaces.
if ( property_exists( 'ExtensibleObject', 'enforce_interfaces' ) ) {
ExtensibleObject::$enforce_interfaces = EXTENSIBLE_OBJECT_ENFORCE_INTERFACES;
}
// Get the component registry.
$registry = C_Component_Registry::get_instance();
// Add the default Pope factory utility, C_Component_Factory.
$registry->add_utility( 'I_Component_Factory', 'C_Component_Factory' );
// Load embedded products. Each product is expected to load any modules required.
$registry->add_module_path( NGG_PRODUCT_DIR, 2 );
$registry->load_all_products();
// Give third-party plugins that opportunity to include their own products and modules.
do_action( 'load_nextgen_gallery_modules', $registry );
// Initializes all loaded modules.
$registry->initialize_all_modules();
self::$pope_loaded = true;
}
public 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;
}
public function render_incompatibility_warning() {
echo ''; echo esc_html( sprintf( __( 'NextGEN Gallery %1$s is incompatible with this version of NextGEN Pro. Please update NextGEN Pro to version %2$s or higher to restore NextGEN Pro functionality.', 'nggallery' ), NGG_PLUGIN_VERSION, $this->minimum_ngg_pro_version ) ); echo '
'; print $message; print ' '; print $account_msg; if ( version_compare( $wp_version, '5.5', '>=' ) && version_compare( $wp_version, '5.5.9', '<=' ) ) { $note = __( "NOTE: The autoupdater doesn't work on the version of WordPress you have installed.", 'ngallery' ); print "