Your IP : 216.73.216.162


Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/
Upload File :
Current File : /home/x/b/o/xbodynamge/namtation/wp-content/NetworkOptions.php.tar

xbodynamge/namtation/wp-content/plugins/all-in-one-seo-pack/app/Common/Traits/NetworkOptions.php000064400000003700151137705440027761 0ustar00home<?php
namespace AIOSEO\Plugin\Common\Traits;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Options trait.
 *
 * @since 4.2.5
 */
trait NetworkOptions {
	/**
	 * Initializes the options.
	 *
	 * @since 4.2.5
	 *
	 * @return void
	 */
	protected function init() {
		if ( ! is_multisite() ) {
			return;
		}

		aioseo()->helpers->switchToBlog( $this->helpers->getNetworkId() );

		$dbOptions = json_decode( get_option( $this->optionsName ), true );
		if ( empty( $dbOptions ) ) {
			$dbOptions = [];
		}

		$this->defaultsMerged = aioseo()->helpers->arrayReplaceRecursive( $this->defaults, $this->defaultsMerged );

		$options = aioseo()->helpers->arrayReplaceRecursive(
			$this->defaultsMerged,
			$this->addValueToValuesArray( $this->defaultsMerged, $dbOptions )
		);

		aioseo()->core->optionsCache->setOptions( $this->optionsName, $options );

		aioseo()->helpers->restoreCurrentBlog();
	}

	/**
	 * Sanitizes, then saves the options to the database.
	 *
	 * @since 4.2.5
	 *
	 * @param  array $newOptions The new options to sanitize, then save.
	 * @return void
	 */
	public function sanitizeAndSave( $newOptions ) {
		if ( ! is_multisite() ) {
			return;
		}

		if ( ! is_array( $newOptions ) ) {
			return;
		}

		$this->init();

		aioseo()->helpers->switchToBlog( $this->helpers->getNetworkId() );

		$cachedOptions = aioseo()->core->optionsCache->getOptions( $this->optionsName );
		$dbOptions     = aioseo()->helpers->arrayReplaceRecursive(
			$cachedOptions,
			$this->addValueToValuesArray( $cachedOptions, $newOptions, [], true )
		);

		// Tools.
		if ( ! empty( $newOptions['tools'] ) ) {
			if ( isset( $newOptions['tools']['robots']['rules'] ) ) {
				$dbOptions['tools']['robots']['rules']['value'] = $this->sanitizeField( $newOptions['tools']['robots']['rules'], 'array' );
			}
		}

		aioseo()->core->optionsCache->setOptions( $this->optionsName, $dbOptions );
		$this->save( true );

		aioseo()->helpers->restoreCurrentBlog();
	}
}home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Traits/NetworkOptions.php000064400000003700151143276300026617 0ustar00<?php
namespace AIOSEO\Plugin\Common\Traits;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Options trait.
 *
 * @since 4.2.5
 */
trait NetworkOptions {
	/**
	 * Initializes the options.
	 *
	 * @since 4.2.5
	 *
	 * @return void
	 */
	protected function init() {
		if ( ! is_multisite() ) {
			return;
		}

		aioseo()->helpers->switchToBlog( $this->helpers->getNetworkId() );

		$dbOptions = json_decode( get_option( $this->optionsName ), true );
		if ( empty( $dbOptions ) ) {
			$dbOptions = [];
		}

		$this->defaultsMerged = aioseo()->helpers->arrayReplaceRecursive( $this->defaults, $this->defaultsMerged );

		$options = aioseo()->helpers->arrayReplaceRecursive(
			$this->defaultsMerged,
			$this->addValueToValuesArray( $this->defaultsMerged, $dbOptions )
		);

		aioseo()->core->optionsCache->setOptions( $this->optionsName, $options );

		aioseo()->helpers->restoreCurrentBlog();
	}

	/**
	 * Sanitizes, then saves the options to the database.
	 *
	 * @since 4.2.5
	 *
	 * @param  array $newOptions The new options to sanitize, then save.
	 * @return void
	 */
	public function sanitizeAndSave( $newOptions ) {
		if ( ! is_multisite() ) {
			return;
		}

		if ( ! is_array( $newOptions ) ) {
			return;
		}

		$this->init();

		aioseo()->helpers->switchToBlog( $this->helpers->getNetworkId() );

		$cachedOptions = aioseo()->core->optionsCache->getOptions( $this->optionsName );
		$dbOptions     = aioseo()->helpers->arrayReplaceRecursive(
			$cachedOptions,
			$this->addValueToValuesArray( $cachedOptions, $newOptions, [], true )
		);

		// Tools.
		if ( ! empty( $newOptions['tools'] ) ) {
			if ( isset( $newOptions['tools']['robots']['rules'] ) ) {
				$dbOptions['tools']['robots']['rules']['value'] = $this->sanitizeField( $newOptions['tools']['robots']['rules'], 'array' );
			}
		}

		aioseo()->core->optionsCache->setOptions( $this->optionsName, $dbOptions );
		$this->save( true );

		aioseo()->helpers->restoreCurrentBlog();
	}
}home/xbodynamge/dev/wp-content/plugins/all-in-one-seo-pack/app/Common/Options/NetworkOptions.php000064400000003622151150436760027015 0ustar00<?php
namespace AIOSEO\Plugin\Common\Options;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use AIOSEO\Plugin\Common\Traits;
use AIOSEO\Plugin\Common\Utils;

/**
 * Class that holds all network options for AIOSEO.
 *
 * @since 4.2.5
 */
class NetworkOptions {
	use Traits\Options;
	use Traits\NetworkOptions;

	/**
	 * Holds the helpers class.
	 *
	 * @since 4.2.5
	 *
	 * @var Utils\Helpers
	 */
	protected $helpers;

	/**
	 * All the default options.
	 *
	 * @since 4.2.5
	 *
	 * @var array
	 */
	protected $defaults = [
		// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
		'searchAppearance' => [
			'advanced' => [
				'unwantedBots'  => [
					'all'      => [ 'type' => 'boolean', 'default' => false ],
					'settings' => [
						'googleAdsBot'             => [ 'type' => 'boolean', 'default' => false ],
						'openAiGptBot'             => [ 'type' => 'boolean', 'default' => false ],
						'commonCrawlCcBot'         => [ 'type' => 'boolean', 'default' => false ],
						'googleGeminiVertexAiBots' => [ 'type' => 'boolean', 'default' => false ]
					]
				],
				'searchCleanup' => [
					'settings' => [
						'preventCrawling' => [ 'type' => 'boolean', 'default' => false ]
					]
				]
			]
		],
		'tools'            => [
			'robots' => [
				'enable'         => [ 'type' => 'boolean', 'default' => false ],
				'rules'          => [ 'type' => 'array', 'default' => [] ],
				'robotsDetected' => [ 'type' => 'boolean', 'default' => true ],
			]
		]
		// phpcs:enable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound
	];

	/**
	 * The Construct method.
	 *
	 * @since 4.2.5
	 *
	 * @param string $optionsName The options name.
	 */
	public function __construct( $optionsName = 'aioseo_options_network' ) {
		$this->helpers     = new Utils\Helpers();
		$this->optionsName = $optionsName;

		$this->init();

		add_action( 'shutdown', [ $this, 'save' ] );
	}
}