SILENT KILLERPanel

Current Path: > home > codekrsu > > ameliagraphics.com > wp-content > plugins > content-control > > inc > functions


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/codekrsu//ameliagraphics.com/wp-content/plugins/content-control//inc/functions

NameTypeSizeLast ModifiedActions
back-compat.php File 4300 bytes October 01 2023 13:39:02.
compatibility.php File 6294 bytes June 21 2024 13:00:36.
content.php File 3218 bytes October 26 2023 13:40:28.
developers.php File 10976 bytes June 21 2024 13:00:36.
globals.php File 1889 bytes June 21 2024 13:00:36.
install.php File 2216 bytes March 11 2025 14:19:36.
options.php File 4105 bytes August 18 2024 09:36:48.
post-restrictions.php File 900 bytes June 21 2024 13:00:36.
protections.php File 2250 bytes September 18 2023 05:47:10.
query.php File 13898 bytes March 15 2025 12:03:42.
restrictions.php File 6168 bytes June 21 2024 13:00:36.
rule-callbacks.php File 20563 bytes May 09 2025 02:30:24.
rules.php File 2539 bytes May 09 2025 02:30:24.
term-restrictions.php File 905 bytes June 21 2024 13:00:36.
upgrades.php File 4835 bytes December 08 2023 15:26:30.
utils.php File 584 bytes March 18 2024 03:33:26.
widgets.php File 1454 bytes December 08 2023 15:26:30.

Reading File: /home/codekrsu//ameliagraphics.com/wp-content/plugins/content-control//inc/functions/upgrades.php

<?php
/**
 * Backward compatibility functions.
 *
 * @package ContentControl
 */

namespace ContentControl;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use function wp_parse_args;
use function apply_filters;

/**
 * Get the current data versions.
 *
 * @return int[]
 */
function current_data_versions() {
	return apply_filters( 'content_control/current_data_versions', [
		'backup'       => 2,
		'settings'     => 2,
		'restrictions' => 2,
		'plugin_meta'  => 2,
		'user_meta'    => 2,
	] );
}

/**
 * Get all data versions.
 *
 * @return int[]
 */
function get_data_versions() {
	$versioning = \get_option( 'content_control_data_versioning', [] );

	return wp_parse_args( $versioning, current_data_versions() );
}

/**
 * Set the data version.
 *
 * @param string $key    Data key.
 * @param int    $version Data version.
 *
 * @return bool
 */
function set_data_version( $key, $version ) {
	$versioning = get_data_versions();

	$versioning[ $key ] = $version;

	return set_data_versions( $versioning );
}

/**
 * Set the data version.
 *
 * @param int[] $versioning Data versions.
 *
 * @return bool
 */
function set_data_versions( $versioning ) {
	$versioning = wp_parse_args( $versioning, get_data_versions() );

	return \update_option( 'content_control_data_versioning', $versioning );
}

/**
 * Get the current data version.
 *
 * @param string $key Type of data to get version for.
 *
 * @return int|bool
 */
function get_data_version( $key ) {
	$versioning = get_data_versions();

	switch ( $key ) {
		// Fallthrough.
		case 'restrictions':
			// If set to v1 and there are no v1 restrictions, set to v2.
			if ( 1 === $versioning[ $key ] ) {
				$v1_restrictions = get_v1_restrictions();

				if ( false === $v1_restrictions ) {
					$versioning[ $key ] = 2;
					set_data_versions( $versioning );
					return 2;
				}
			}

			break;

		case 'settings':
			// If set to v1 and there are no v1 settings, set to v2.
			if ( 1 === $versioning[ $key ] ) {
				$v1_settings = \get_option( 'jp_cc_settings', [] );

				if ( empty( $v1_settings ) ) {
					$versioning[ $key ]   = 2;
					$versioning['backup'] = 2; // Backup is always the same as settings.
					set_data_versions( $versioning );
					return 2;
				}
			}

			break;
	}

	return isset( $versioning[ $key ] ) ? $versioning[ $key ] : false;
}

/**
 * Checks if user is upgrading from < 2.0.0.
 *
 * Sets data versioning to 1 as they didn't exist before.
 *
 * @param string $old_version Old version.
 *
 * @return void
 */
function maybe_force_v2_migrations( $old_version ) {
	if ( version_compare( $old_version, '2.0.0', '<' ) ) {
		$versioning = get_data_versions();

		// Forces updates for all data types to v2.
		$versioning = wp_parse_args( [
			'backup'       => 1,
			'settings'     => 1,
			'restrictions' => 1,
			'plugin_meta'  => 1,
			'user_meta'    => 1,
		], $versioning );

		\update_option( 'content_control_data_versioning', $versioning );
	}
}

/**
 * Get the name of an upgrade.
 *
 * @param string|\ContentControl\Base\Upgrade $upgrade Upgrade to get name for.
 *
 * @return string
 */
function get_upgrade_name( $upgrade ) {
	if ( is_object( $upgrade ) ) {
		$upgrade = $upgrade::TYPE . '-' . $upgrade::VERSION;
	}

	return $upgrade;
}

/**
 * Get the completed upgrades.
 *
 * @return string[]
 */
function get_completed_upgrades() {
	return \get_option( 'content_control_completed_upgrades', [] );
}

/**
 * Set the completed upgrades.
 *
 * @param string[] $upgrades Completed upgrades.
 *
 * @return bool
 */
function set_completed_upgrades( $upgrades ) {
	return \update_option( 'content_control_completed_upgrades', $upgrades );
}

/**
 * Mark an upgrade as complete.
 *
 * @param \ContentControl\Base\Upgrade $upgrade Upgrade to mark as complete.
 *
 * @return void
 */
function mark_upgrade_complete( $upgrade ) {
	$upgrade_name = get_upgrade_name( $upgrade );

	$upgrades = get_completed_upgrades();

	if ( ! in_array( $upgrade_name, $upgrades, true ) ) {
		$upgrades[] = $upgrade_name;
	}

	set_completed_upgrades( $upgrades );

	// Update the data version.
	set_data_version( $upgrade::TYPE, $upgrade::VERSION );

	/**
	 * Fires when an upgrade is marked as complete.
	 *
	 * @param \ContentControl\Base\Upgrade $upgrade Upgrade type.
	 */
	do_action( 'content_control/upgrade_complete', $upgrade );

	/**
	 * Fires when a specific upgrade is marked as complete.
	 *
	 * @param \ContentControl\Base\Upgrade $upgrade Upgrade type.
	 */
	do_action( "content_control/upgrade_complete/{$upgrade_name}", $upgrade );
}

/**
 * Check if an upgrade has been completed.
 *
 * @param string|\ContentControl\Base\Upgrade $upgrade Upgrade to check.
 *
 * @return bool
 */
function is_upgrade_complete( $upgrade ) {
	$upgrade = get_upgrade_name( $upgrade );

	$upgrades = get_completed_upgrades();

	return in_array( $upgrade, $upgrades, true );
}

SILENT KILLER Tool