static function update($reset = FALSE) { $global_settings = C_NextGen_Global_Settings::get_instance(); $local_settings = C_NextGen_Settings::get_instance(); $last_module_list = $reset ? array() : $global_settings->get('pope_module_list', array()); $current_module_list = self::_generate_module_info(); if (count($modules = array_diff($current_module_list, $last_module_list)) > 0) { // The cache should be flushed C_Photocrati_Cache::flush(); // Delete auto-update cache update_option('photocrati_auto_update_admin_update_list', null); update_option('photocrati_auto_update_admin_check_date', ''); foreach ($modules as $module_name) { if ($handler = self::get_handler_instance(array_shift(explode('|', $module_name)))) { if (method_exists($handler, 'install')) { $handler->install($reset); } } } // Update the module list $global_settings->set('pope_module_list', $current_module_list); // Save any changes settings $global_settings->save(); $local_settings->save(); } }
function define($context = FALSE) { parent::define('photocrati-frame_communication', 'Frame/iFrame Inter-Communication', 'Provides a means for HTML frames to share server-side events with each other', '0.4', 'http://www.nextgen-gallery.com', 'Photocrati Media', 'http://www.photocrati.com', $context); include_once 'class.frame_communication_option_handler.php'; C_NextGen_Settings::get_instance()->add_option_handler('C_Frame_Communication_Option_Handler', array('frame_event_cookie_name')); C_NextGen_Global_Settings::get_instance()->add_option_handler('C_Frame_Communication_Option_Handler', array('frame_event_cookie_name')); }
function enqueue_backend_resources() { $this->call_parent('enqueue_backend_resources'); // Enqueue frame event publishing wp_enqueue_script('frame_event_publisher'); // Enqueue JQuery UI libraries wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script('jquery-ui-tooltip'); wp_enqueue_script('ngg_tabs', $this->get_static_url('photocrati-attach_to_post#ngg_tabs.js')); // Ensure select2 wp_enqueue_style('select2'); wp_enqueue_script('select2'); // Ensure that the Photocrati AJAX library is loaded wp_enqueue_script('photocrati_ajax'); // Enqueue logic for the Attach to Post interface as a whole wp_enqueue_script('ngg_attach_to_post', $this->get_static_url('photocrati-attach_to_post#attach_to_post.js')); wp_enqueue_style('ngg_attach_to_post', $this->get_static_url('photocrati-attach_to_post#attach_to_post.css')); // Enqueue backbone.js library, required by the Attach to Post display tab wp_enqueue_script('backbone'); // provided by WP // Ensure underscore sting, a helper utility wp_enqueue_script('underscore.string', $this->get_static_url('photocrati-attach_to_post#underscore.string.js'), array('underscore'), '2.3.0'); // Enqueue the backbone app for the display tab $settings = C_NextGen_Global_Settings::get_instance(); $preview_url = $settings->gallery_preview_url; $display_tab_js_url = $settings->attach_to_post_display_tab_js_url; if ($this->object->_displayed_gallery->id()) { $display_tab_js_url .= '/id--' . $this->object->_displayed_gallery->id(); } wp_enqueue_script('ngg_display_tab', $display_tab_js_url, array('backbone', 'underscore.string')); wp_localize_script('ngg_display_tab', 'ngg_displayed_gallery_preview_url', $settings->gallery_preview_url); }
function __construct() { $this->blog_settings = C_NextGen_Settings::get_instance(); $this->site_settings = C_NextGen_Global_Settings::get_instance(); $this->_global_settings = array('gallerypath' => implode(DIRECTORY_SEPARATOR, array('wp-content', 'uploads', 'sites', '%BLOG_ID%', 'nggallery')) . DIRECTORY_SEPARATOR, 'wpmuCSSfile' => 'nggallery.css', 'wpmuStyle' => FALSE, 'wpmuRoles' => FALSE, 'wpmuImportFolder' => FALSE, 'wpmuZipUpload' => FALSE, 'wpmuQuotaCheck' => FALSE, 'datamapper_driver' => 'custom_table_datamapper', 'gallerystorage_driver' => 'ngglegacy_gallery_storage', 'maximum_entity_count' => 500, 'router_param_slug' => 'nggallery'); $this->_local_settings = array('gallerypath' => 'wp-content' . DIRECTORY_SEPARATOR . 'gallery' . DIRECTORY_SEPARATOR, 'deleteImg' => TRUE, 'swfUpload' => TRUE, 'usePermalinks' => FALSE, 'permalinkSlug' => 'nggallery', 'graphicLibrary' => 'gd', 'imageMagickDir' => '/usr/local/bin/', 'useMediaRSS' => FALSE, 'galleries_in_feeds' => FALSE, 'activateTags' => 0, 'appendType' => 'tags', 'maxImages' => 7, 'relatedHeading' => '<h3>' . __('Related Images', 'nggallery') . ':</h3>', 'thumbwidth' => 240, 'thumbheight' => 160, 'thumbfix' => True, 'thumbquality' => 100, 'imgWidth' => 800, 'imgHeight' => 600, 'imgQuality' => 100, 'imgBackup' => True, 'imgAutoResize' => False, 'galImages' => '20', 'galPagedGalleries' => 0, 'galColumns' => 0, 'galShowSlide' => True, 'galTextSlide' => __('[Show slideshow]', 'nggallery'), 'galTextGallery' => __('[Show thumbnails]', 'nggallery'), 'galShowOrder' => 'gallery', 'galSort' => 'sortorder', 'galSortDir' => 'ASC', 'galNoPages' => True, 'galImgBrowser' => 0, 'galHiddenImg' => 0, 'galAjaxNav' => 0, 'thumbEffect' => 'fancybox', 'thumbCode' => 'class="ngg-fancybox" rel="%GALLERY_NAME%"', 'thumbEffectContext' => 'nextgen_images', 'wmPos' => 'botRight', 'wmXpos' => 5, 'wmYpos' => 5, 'wmType' => 'image', 'wmPath' => '', 'wmFont' => 'arial.ttf', 'wmSize' => 10, 'wmText' => get_option('blogname'), 'wmColor' => '000000', 'wmOpaque' => '100', 'slideFX' => 'fade', 'irWidth' => 600, 'irHeight' => 400, 'irRotatetime' => 10, 'activateCSS' => 1, 'CSSfile' => 'nggallery.css', 'always_enable_frontend_logic' => FALSE); }
function __construct() { $this->blog_settings = C_NextGen_Settings::get_instance(); $this->site_settings = C_NextGen_Global_Settings::get_instance(); $this->_global_settings = array('gallerypath' => 'wp-content/blogs.dir/%BLOG_ID%/files/', 'wpmuCSSfile' => 'nggallery.css', 'wpmuStyle' => FALSE, 'wpmuRoles' => FALSE, 'wpmuImportFolder' => FALSE, 'wpmuZipUpload' => FALSE, 'datamapper_driver' => 'custom_table_datamapper', 'gallerystorage_driver' => 'ngglegacy_gallery_storage', 'maximum_entity_count' => 500, 'router_param_slug' => 'nggallery'); $this->_local_settings = array('gallerypath' => 'wp-content/gallery/', 'deleteImg' => True, 'swfUpload' => True, 'usePermalinks' => False, 'permalinkSlug' => 'nggallery', 'graphicLibrary' => 'gd', 'imageMagickDir' => '/usr/local/bin/', 'useMediaRSS' => False, 'usePicLens' => False, 'activateTags' => 0, 'appendType' => 'tags', 'maxImages' => 7, 'relatedHeading' => __('<h3>Related Images:</h3>', 'nggallery'), 'thumbwidth' => 120, 'thumbheight' => 90, 'thumbfix' => True, 'thumbquality' => 100, 'imgWidth' => 800, 'imgHeight' => 600, 'imgQuality' => 100, 'imgBackup' => True, 'imgAutoResize' => False, 'galImages' => '20', 'galPagedGalleries' => 0, 'galColumns' => 0, 'galShowSlide' => True, 'galTextSlide' => __('[Show as slideshow]', 'nggallery'), 'galTextGallery' => __('[Show picture list]', 'nggallery'), 'galShowOrder' => 'gallery', 'galSort' => 'sortorder', 'galSortDir' => 'ASC', 'galNoPages' => True, 'galImgBrowser' => 0, 'galHiddenImg' => 0, 'galAjaxNav' => 0, 'thumbEffect' => 'fancybox', 'thumbCode' => 'class="ngg-fancybox" rel="%GALLERY_NAME%"', 'wmPos' => 'botRight', 'wmXpos' => 5, 'wmYpos' => 5, 'wmType' => 0, 'wmPath' => '', 'wmFont' => 'arial.ttf', 'wmSize' => 10, 'wmText' => get_option('blogname'), 'wmColor' => '000000', 'wmOpaque' => '100', 'enableIR' => 0, 'slideFx' => 'fade', 'irURL' => '', 'irXHTMLvalid' => 0, 'irAudio' => '', 'irWidth' => 600, 'irHeight' => 400, 'irShuffle' => True, 'irLinkfromdisplay' => True, 'irShownavigation' => 0, 'irShowicons' => 0, 'irWatermark' => 0, 'irOverstretch' => 'True', 'irRotatetime' => 10, 'irTransition' => 'random', 'irKenburns' => 0, 'irBackcolor' => '000000', 'irFrontcolor' => 'FFFFFF', 'irLightcolor' => 'CC0000', 'irScreencolor' => '000000', 'activateCSS' => 1, 'CSSfile' => 'nggallery.css'); }
function install() { $settings = C_NextGen_Global_Settings::get_instance(); $settings->set_default_value('router_param_separator', '--'); $settings->set_default_value('router_param_prefix', ''); $settings->set_default_value('router_param_slug', 'params'); }
function _nextgen_basic_album_rewrite_rules($displayed_gallery) { // Get display types $original_display_type = isset($displayed_gallery->display_settings['original_display_type']) ? $displayed_gallery->display_settings['original_display_type'] : ''; $display_type = $displayed_gallery->display_type; // Get router $router = $this->get_registry()->get_utility('I_Router'); $app = $router->get_routed_app(); $slug = C_NextGen_Global_Settings::get_instance()->router_param_slug; // If we're viewing an album, rewrite the urls $regex = "/photocrati-nextgen_basic_\\w+_album/"; if (preg_match($regex, $display_type)) { $app->rewrite("{$slug}/pid--{*}", "{$slug}/pid--{1}", FALSE, TRUE); // avoid conflicts with imagebrowser $app->rewrite("{$slug}/{\\w}", "{$slug}/album--{1}"); $app->rewrite("{$slug}/{\\w}/{\\w}", "{$slug}/album--{1}/gallery--{2}"); $app->rewrite("{$slug}/{\\w}/{\\w}/{\\w}{*}", "{$slug}/album--{1}/gallery--{2}/{3}{4}"); } elseif (preg_match($regex, $original_display_type)) { $app->rewrite("{$slug}/album--{\\w}", "{$slug}/{1}"); $app->rewrite("{$slug}/album--{\\w}/gallery--{\\w}", "{$slug}/{1}/{2}"); $app->rewrite("{$slug}/album--{\\w}/gallery--{\\w}/{*}", "{$slug}/{1}/{2}/{3}"); } // Perform rewrites $app->do_rewrites(); }
function define() { parent::define("photocrati-mvc", "MVC Framework", "Provides an MVC architecture for the plugin to use", "0.4", "http://www.photocrati.com", "Photocrati Media", "http://www.photocrati.com"); include_once 'class.mvc_installer.php'; C_Photocrati_Installer::add_handler($this->module_id, 'C_Mvc_Installer'); include_once 'class.mvc_option_handler.php'; C_NextGen_Global_Settings::add_option_handler('C_Mvc_Option_Handler', array('mvc_template_dir')); }
function install() { // Delete cached values. Needed for 2.0.7 and less $settings = C_NextGen_Global_Settings::get_instance(); $settings->delete('attach_to_post_url'); $settings->delete('gallery_preview_url'); $settings->delete('attach_to_post_display_tab_js_url'); }
function define() { parent::define('photocrati-ajax', 'AJAX', 'Provides AJAX functionality', '0.8', 'http://www.photocrati.com', 'Photocrati Media', 'http://www.photocrati.com'); C_NextGen_Settings::get_instance()->add_option_handler('C_Ajax_Option_Handler', array('ajax_slug', 'ajax_url', 'ajax_js_url')); if (is_multisite()) { C_NextGen_Global_Settings::get_instance()->add_option_handler('C_Ajax_Option_Handler', array('ajax_slug', 'ajax_url', 'ajax_js_url')); } }
function install() { // Delete cached values. Needed for 2.0.7 and less $settings = C_NextGen_Global_Settings::get_instance(); $settings->delete('ajax_url'); $settings->delete('ajax_slug'); $settings->delete('ajax_js_url'); }
/** * Defines the module */ function define() { parent::define('photocrati-nextgen_admin', 'NextGEN Administration', 'Provides a framework for adding Administration pages', '0.4', 'http://www.nextgen-gallery.com', 'Photocrati Media', 'http://www.photocrati.com'); include_once 'class.nextgen_admin_installer.php'; C_Photocrati_Installer::add_handler($this->module_id, 'C_NextGen_Admin_Installer'); include_once 'class.nextgen_admin_option_handler.php'; C_NextGen_Global_Settings::add_option_handler('C_NextGen_Admin_Option_Handler', array('jquery_ui_theme', 'jquery_ui_theme_version', 'jquery_ui_theme_url')); }
function define() { parent::define("photocrati-mvc", "MVC Framework", "Provides an MVC architecture for the plugin to use", "0.8", "https://www.imagely.com", "Photocrati Media", "https://www.imagely.com"); C_NextGen_Settings::get_instance()->add_option_handler('C_Mvc_Option_Handler', array('mvc_template_dir', 'mvc_template_dirname', 'mvc_static_dir', 'mvc_static_dirname')); if (is_multisite()) { C_NextGen_Global_Settings::get_instance()->add_option_handler('C_Mvc_Option_Handler', array('mvc_template_dir', 'mvc_template_dirname', 'mvc_static_dir', 'mvc_static_dirname')); } }
/** * Defines the module */ function define() { parent::define('photocrati-nextgen_admin', 'NextGEN Administration', 'Provides a framework for adding Administration pages', '0.10', 'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/', 'Photocrati Media', 'https://www.imagely.com'); C_Photocrati_Installer::add_handler($this->module_id, 'C_NextGen_Admin_Installer'); C_NextGen_Settings::get_instance()->add_option_handler('C_NextGen_Admin_Option_Handler', array('jquery_ui_theme', 'jquery_ui_theme_version', 'jquery_ui_theme_url')); if (is_multisite()) { C_NextGen_Global_Settings::get_instance()->add_option_handler('C_NextGen_Admin_Option_Handler', array('jquery_ui_theme', 'jquery_ui_theme_version', 'jquery_ui_theme_url')); } }
/** * Defines the module * @param string|bool $context */ function define($context = FALSE) { parent::define('photocrati-attach_to_post', 'Attach To Post', 'Provides the "Attach to Post" interface for displaying galleries and albums', '0.11', 'http://www.nextgen-gallery.com', 'Photocrati Media', 'http://www.photocrati.com', $context); C_NextGen_Settings::get_instance()->add_option_handler('C_Attach_To_Post_Option_Handler', array('attach_to_post_url', 'gallery_preview_url', 'attach_to_post_display_tab_js_url')); if (is_multisite()) { C_NextGen_Global_Settings::get_instance()->add_option_handler('C_Attach_To_Post_Option_Handler', array('attach_to_post_url', 'gallery_preview_url', 'attach_to_post_display_tab_js_url')); } C_Photocrati_Installer::add_handler($this->module_id, 'C_Attach_To_Post_Installer'); }
function add_nextgen_basic_gallery_routes() { $slug = C_NextGen_Global_Settings::get_instance()->router_param_slug; $this->object->rewrite("{$slug}{*}/image/{*}", "{$slug}{1}/pid--{2}"); $this->object->rewrite("{$slug}{*}/slideshow/{*}", "{$slug}{1}/show--" . NEXTGEN_GALLERY_BASIC_SLIDESHOW . "{2}"); $this->object->rewrite("{$slug}{*}/thumbnails/{*}", "{$slug}{1}/show--" . NEXTGEN_GALLERY_BASIC_THUMBNAILS . "{2}"); $this->object->rewrite("{$slug}{*}/show--slide/{*}", "{$slug}{1}/show--" . NEXTGEN_GALLERY_BASIC_SLIDESHOW . "/{2}"); $this->object->rewrite("{$slug}{*}/show--gallery/{*}", "{$slug}{1}/show--" . NEXTGEN_GALLERY_BASIC_THUMBNAILS . "/{2}"); $this->object->rewrite("{$slug}{*}/page/{\\d}{*}", "{$slug}{1}/page--{2}{3}"); }
function define($context = FALSE) { parent::define($context); $this->add_mixin('Mixin_Validation'); if ($this->has_context('global') or $this->has_context('site')) { $this->wrapper = C_NextGen_Global_Settings::get_instance(); } else { $this->wrapper = C_NextGen_Settings::get_instance(); } }
/** * Loads a single script to provide the photocrati_ajax settings to the web browser */ function enqueue_scripts() { $settings = C_NextGen_Global_Settings::get_instance(); $router = $this->get_registry()->get_utility('I_Router'); $site_url = $router->get_base_url(TRUE); $home_url = $router->get_base_url(); wp_register_script('photocrati_ajax', $settings->ajax_js_url); wp_enqueue_script('photocrati_ajax'); $vars = array('url' => $router->get_url($settings->ajax_slug, FALSE), 'wp_site_url' => $home_url, 'wp_site_static_url' => str_replace('/index.php', '', $site_url)); wp_localize_script('photocrati_ajax', 'photocrati_ajax', $vars); }
function define() { parent::define('photocrati-ajax', 'AJAX', 'Provides AJAX functionality', '0.7', 'http://www.photocrati.com', 'Photocrati Media', 'http://www.photocrati.com'); include_once 'class.ajax_option_handler.php'; C_NextGen_Settings::get_instance()->add_option_handler('C_Ajax_Option_Handler', array('ajax_slug', 'ajax_url', 'ajax_js_url')); if (is_multisite()) { C_NextGen_Global_Settings::get_instance()->add_option_handler('C_Ajax_Option_Handler', array('ajax_slug', 'ajax_url', 'ajax_js_url')); } include_once 'class.ajax_installer.php'; C_Photocrati_Installer::add_handler($this->module_id, 'C_Ajax_Installer'); }
/** * Defines the module * @param string|bool $context */ function define($context = FALSE) { parent::define('photocrati-attach_to_post', 'Attach To Post', 'Provides the "Attach to Post" interface for displaying galleries and albums', '0.10', 'http://www.nextgen-gallery.com', 'Photocrati Media', 'http://www.photocrati.com', $context); include_once 'class.attach_to_post_option_handler.php'; C_NextGen_Settings::get_instance()->add_option_handler('C_Attach_To_Post_Option_Handler', array('attach_to_post_url', 'gallery_preview_url', 'attach_to_post_display_tab_js_url')); if (is_multisite()) { C_NextGen_Global_Settings::get_instance()->add_option_handler('C_Attach_To_Post_Option_Handler', array('attach_to_post_url', 'gallery_preview_url', 'attach_to_post_display_tab_js_url')); } include_once 'class.attach_to_post_installer.php'; C_Photocrati_Installer::add_handler($this->module_id, 'C_Attach_To_Post_Installer'); // Set WP_ADMIN=true for better compatibility with certain themes & plugins. // Unfortunately as of 3.9 in a multisite environment this causes problems. if (self::is_atp_url() && (!defined('MULTISITE') || defined('MULTISITE') && !MULTISITE)) { define('WP_ADMIN', true); } }
/** * Gets the absolute path to a static resource. If it doesn't exist, then NULL is returned * * @param string $path * @param string $module * @param string $relative * @return string|NULL */ function find_static_abspath($path, $module = FALSE, $relative = FALSE) { // Find the module directory $fs = $this->object->get_registry()->get_utility('I_Fs'); if (!$module) { list($path, $module) = $fs->parse_formatted_path($path); } $mod_dir = $this->object->get_registry()->get_module_dir($module); // Create the absolute path to the file $path = $fs->join_paths($mod_dir, C_NextGen_Global_Settings::get_instance()->get('mvc_static_dirname'), $path); // Get the relative path, if asked if ($relative) { $path = str_replace($fs->get_document_root(), '', $path); } return $path; }
/** * Returns the name of the class which provides the gallerystorage * implementation * @return string */ function _get_driver_factory_method($context = FALSE) { $factory_method = ''; // No constant has been defined to establish a global gallerystorage driver if (!defined('GALLERYSTORAGE_DRIVER')) { // Get the datamapper configured in the database $factory_method = C_NextGen_Global_Settings::get_instance()->gallerystorage_driver; // Define a constant and use this as the global gallerystorage driver, // unless running in a SimpleTest Environment if (!isset($GLOBALS['SIMPLE_TEST_RUNNING'])) { define('GALLERYSTORAGE_DRIVER', $factory_method); } } else { $factory_method = GALLERYSTORAGE_DRIVER; } return $factory_method; }
function _set_tag_cloud_parameters($key, $id = NULL) { // Get the returned url $retval = $this->object->get_method_property($this->method_called, ExtensibleObject::METHOD_PROPERTY_RETURN_VALUE); // Get the settings manager $settings = C_NextGen_Global_Settings::get_instance(); // Create the regex pattern $sep = preg_quote($settings->router_param_separator, '#'); if ($id) { $id = preg_quote($id, '#') . $sep; } $prefix = preg_quote($settings->router_param_prefix, '#'); $regex = implode('', array('#//?', $id ? "({$id})?" : "(\\w+{$sep})?", "({$prefix})?gallerytag{$sep}([\\w-_]+)/?#")); // Replace any page parameters with the ngglegacy equivalent if (preg_match($regex, $retval, $matches)) { $retval = str_replace($matches[0], "/tags/{$matches[3]}/", $retval); $this->object->set_method_property($this->method_called, ExtensibleObject::METHOD_PROPERTY_RETURN_VALUE, $retval); } return $retval; }
function install() { // In version 0.2 of this module and earlier, the following values // were statically set rather than dynamically using a handler. Therefore, we need // to delete those static values $module_name = 'photocrati-nextgen_admin'; $settings = C_NextGen_Global_Settings::get_instance(); $modules = $settings->pope_module_list; $cleanup = FALSE; if (!isset($modules[$module_name])) { $cleanup = FALSE; } elseif (floatval(str_replace($module_name, '|', $modules[$module_name])) < '0.3') { $cleanup = TRUE; } if ($cleanup) { $keys = array('jquery_ui_theme', 'jquery_ui_theme_version', 'jquery_ui_theme_url'); foreach ($keys as $key) { $settings->delete($key); } } }
function _add_nextgen_basic_imagebrowser_routes() { $slug = C_NextGen_Global_Settings::get_instance()->router_param_slug; $this->object->rewrite("{$slug}{*}/image/{\\w}", "{$slug}{1}/pid--{2}"); }
<?php $settings = C_NextGen_Global_Settings::get_instance(); $obj = method_exists($this, 'get_class_definition_dir') ? $this : $this->object; $template_dir = path_join($obj->get_class_definition_dir(), 'templates'); $default_template_dir = $settings->mvc_template_dir; ?> <h1>Welcome to Pope MVC!</h1> <p> You have not yet created a index.php file in:<br/><strong><?php echo $template_dir; ?> </strong> </p> <p> So, you're being served the index.php from the default directory:<br/> <strong><?php echo $default_template_dir; ?> </strong> </p>
function prettify_pagelink($pagelink) { $param_separator = C_NextGen_Global_Settings::get_instance()->get('router_param_separator'); $regex = implode('', array('#', '/(gallery|album)', preg_quote($param_separator), '([^/?]+)', '#')); return preg_replace($regex, '/\\2', $pagelink); }
function __construct() { $this->settings = C_NextGen_Global_Settings::get_instance(); }
function initialize() { parent::initialize(); $this->_app = C_NextGen_Global_Settings::get_instance()->dynamic_stylesheet_slug; }
static function update($reset = FALSE) { $local_settings = C_NextGen_Settings::get_instance(); $global_settings = C_NextGen_Global_Settings::get_instance(); // Somehow some installations are missing several default settings // Because gallerystorage_driver is essential to know we do a 'soft' reset here // by filling in any missing options from the default settings if (is_null($local_settings->gallerystorage_driver)) { $settings_installer = new C_NextGen_Settings_Installer(); $local_settings->reset(); $settings_installer->install_local_settings(); $local_settings->save(); $global_settings->reset(); $settings_installer->install_global_settings(); $global_settings->save(); } // This is a specific hack/work-around/fix and can probably be removed sometime after 2.0.20's release // // NextGen 2x was not multisite compatible until 2.0.18. Users that upgraded before this // will have nearly all of their settings stored globally (network wide) in wp_sitemeta. If // pope_module_list (which should always be a local setting) exists site-wide we wipe the current // global ngg_options and restore from defaults. This should only ever run once. if (is_multisite() && isset($global_settings->pope_module_list)) { // Setting this to TRUE will wipe current settings for display types, but also // allows the display type installer to run correctly $reset = TRUE; $settings_installer = new C_NextGen_Settings_Installer(); $global_defaults = $settings_installer->get_global_defaults(); // Preserve the network options we honor by restoring them after calling $global_settings->reset() $global_settings_to_keep = array(); foreach ($global_defaults as $key => $val) { $global_settings_to_keep[$key] = $global_settings->{$key}; } // Resets internal options to an empty array $global_settings->reset(); // Restore the defaults, then our saved values. This must be done again later because // we've set $reset to TRUE. $settings_installer->install_global_settings(); foreach ($global_settings_to_keep as $key => $val) { $global_settings->{$key} = $val; } } // Get last module list and current module list. Compare... $last_module_list = self::_get_last_module_list($reset); $current_module_list = self::_generate_module_info(); $diff = array_diff($current_module_list, $last_module_list); $do_upgrade = count($diff) > 0 || count($last_module_list) != count($current_module_list); $can_upgrade = $do_upgrade ? self::can_do_upgrade() : FALSE; if ($can_upgrade && !$diff) { $diff = $current_module_list; } if ($can_upgrade && $do_upgrade) { // Clear APC cache if (function_exists('apc_clear_cache')) { @apc_clear_cache('opcode'); apc_clear_cache(); } // We flush ALL transients wp_cache_flush(); global $wpdb; $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient%'"); // Remove all NGG created cron jobs self::refresh_cron(); // Delete auto-update cache update_option('photocrati_auto_update_admin_update_list', null); update_option('photocrati_auto_update_admin_check_date', ''); // Other Pope applications might be loaded, and therefore // all singletons should be destroyed, so that they can be // adapted as necessary. For now, we'll just assume that the factory // is the only singleton that will be used by other Pope applications C_Component_Factory::$_instances = array(); foreach ($diff as $module_name) { $parts = explode('|', $module_name); if ($handler = self::get_handler_instance(array_shift($parts))) { if (method_exists($handler, 'install')) { $handler->install($reset); } } } // NOTE & TODO: if the above section that declares $global_settings_to_keep is removed this should also // Since a hard-reset of the settings was forced we must again re-apply our previously saved values if (isset($global_settings_to_keep)) { foreach ($global_settings_to_keep as $key => $val) { $global_settings->{$key} = $val; } } // Save any changes settings $global_settings->save(); $local_settings->save(); } // Another workaround to an issue caused by NextGen's lack of multisite compatibility. It's possible // the string substitation wasn't performed, so if a '%' symbol exists in gallerypath we reset it. It's // another db call, but again this should only ever run once. // // Remove this when removing the above reset-global-settings code if (strpos($local_settings->gallerypath, '%')) { $settings_installer = new C_NextGen_Settings_Installer(); $local_settings->gallerypath = $settings_installer->gallerypath_replace($global_settings->gallerypath); $local_settings->save(); } // Update the module list, and remove the update flag if ($can_upgrade) { update_option('pope_module_list', $current_module_list); self::done_upgrade(); } }