\x20\40\x20\40 HEX
HEX
Server: Apache
System: Linux web1.jenscom.net 4.18.0-553.111.1.el8_10.x86_64 #1 SMP Sun Mar 8 20:06:07 EDT 2026 x86_64
User: sps (1059)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/sps/public_html/wp-content/plugins/nextgen-gallery/src/Settings/Settings.php
<?php

namespace Imagely\NGG\Settings;

// phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound
use Imagely\NGG\Util\Serializable;

/**
 * Settings manager for blog-level settings.
 */
class Settings extends ManagerBase {

	/**
	 * Singleton instance.
	 *
	 * @var Settings|null
	 */
	protected static $instance = null;

	/**
	 * Get the singleton instance.
	 *
	 * @return Settings
	 */
	public static function get_instance() {
		if ( is_null( self::$instance ) ) {
			self::$instance = new Settings();

			// This setting must be an option handler as it cannot be static.
			self::$instance->add_option_handler( '\Imagely\NGG\Settings\Ajax_URL_Option_Handler', [ 'ajax_url' ] );
		}
		return self::$instance;
	}

	/**
	 * Save settings.
	 *
	 * @return bool Whether the save was successful.
	 */
	public function save() {
		return \update_option( self::$option_name, $this->to_array() );
	}

	/**
	 * Load settings from database.
	 */
	public function load() {
		$this->_options = \get_option( self::$option_name, [] );

		if ( ! $this->_options ) {
			$this->_options = [];
		} elseif ( is_string( $this->_options ) ) {
			try {

				$this->_options = Serializable::unserialize( $this->_options );
			} catch ( \Exception $exception ) {
				$this->_options = [];
			}
		}
	}

	/**
	 * Delete settings from database.
	 */
	public function destroy() {
		\delete_option( self::$option_name );
	}
}

/**
 * Option handler for AJAX URL settings.
 *
 * Provides dynamic AJAX URL handling for the settings system.
 */
class Ajax_URL_Option_Handler {
 // phpcs:ignore Generic.Files.OneObjectStructurePerFile.MultipleFound

	/**
	 * Get the AJAX URL.
	 *
	 * @param string $key The option key.
	 * @param mixed  $default_value The default value.
	 * @return mixed The option value.
	 */
	public function get( $key, $default_value = null ) {
		$retval = $default_value;

		if ( 'ajax_url' == $key ) {
			$retval = site_url( '/index.php?' . NGG_AJAX_SLUG . '=1' );
			if ( is_ssl() && strpos( $retval, 'https' ) === false ) {
				$retval = str_replace( 'http', 'https', $retval );
			}
		}

		return $retval;
	}
}