%PDF- %PDF-
Mini Shell

Mini Shell

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

<?php
namespace Tribe\Utils;

/**
 * Class Element_Attributes to handle HTML attributes for elements.
 *
 * @since 4.12.3
 *
 * @package Tribe\Utils
 */
class Element_Attributes {
	/**
	 * Store the results of parsing the attributes.
	 *
	 * @since 4.12.3
	 *
	 * @var array<string,string>
	 */
	protected $results = [];

	/**
	 * Stores the arguments passed.
	 *
	 * @since 4.12.3
	 *
	 * @var array
	 */
	protected $arguments = [];

	/**
	 * Setups an instance of Element Attributes.
	 *
	 * @since 4.12.3
	 *
	 * @return void
	 */
	public function __construct() {
		$this->arguments = func_get_args();
	}

	/**
	 * When invoked this class will return the full HTML attributes.
	 *
	 * @since 4.12.3
	 *
	 * @return string In the format ` attribute1="value1" attribute2="value2" `
	 */
	public function __invoke() {
		$this->arguments = func_get_args();
		return $this->get_attributes();
	}


	/**
	 * When cast to string an instance will return the full HTML attributes.
	 *
	 * @since 4.12.3
	 *
	 * @return string In the format ` attribute1="value1" attribute2="value2" `
	 */
	public function __toString() {
		return $this->get_attributes();
	}

	/**
	 * Gets the full HTML attributes for this instance of Element Attributes.
	 * It will contain a space on each end of the attribute.
	 *
	 * @since 4.12.3
	 *
	 * @return string In the format ` attribute1="value1" attribute2="value2" `
	 */
	public function get_attributes() {
		$attributes = $this->get_attributes_as_string();

		// Bail with empty string when no attributes are present
		if ( ! $attributes ) {
			return '';
		}

		return " {$attributes} ";
	}

	/**
	 * Gets a space separated string of all attributes to be printed.
	 *
	 * @since 4.12.3
	 *
	 * @return string
	 */
	public function get_attributes_as_string() {
		return implode( ' ', $this->get_attributes_array() );
	}

	/**
	 * Get the array of attributes to be printed.
	 *
	 * @since 4.12.3
	 * @since 6.14.0.1 Event handler attributes (names starting with `on`) are never printed.
	 *
	 * @return array
	 */
	public function get_attributes_array() {
		$this->results = [];
		$attributes    = [];

		$this->parse_array( $this->arguments );

		foreach ( $this->results as $key => $val ) {

			if ( ! $val && '0' !== $val ) {
				continue;
			}

			$name = tag_escape( $key );

			/*
			 * Attribute names can come from template data. A name that escaping had to change could
			 * hide a second attribute, and an `on*` name would print a working event handler.
			 */
			if ( strtolower( $key ) !== $name || str_starts_with( $name, 'on' ) ) {
				continue;
			}

			if ( is_bool( $val ) ) {
				$attributes[] = $name;
			} else {
				// Remove double quotes that might be surrounding the value.
				$attributes[] = $name . '="' . esc_attr( trim( $val, '"' ) ) . '"';
			}
		}

		return $attributes;
	}

	/**
	 * Parse arguments or argument for this instance, and store values on results.
	 *
	 * @since 4.12.3
	 *
	 * @param mixed  $arguments  Any possible set of arguments that this class supports.
	 *
	 * @return void
	 */
	protected function parse( $arguments ): void {
		if ( ! $arguments ) {
			return;
		}

		if ( is_numeric( $arguments ) ) { // phpcs:ignore
			// Bail on any numeric values.
		} elseif ( is_array( $arguments ) ) {
			// ['foo', 'bar', ...] || ['foo' => TRUE, 'bar' => FALSE, 'baz' => 'foo', ...]
			$this->parse_array( $arguments );
		} elseif ( is_string( $arguments ) ) {
			// 'foo bar'
			$this->parse_string( $arguments );
		} elseif ( $arguments instanceof \Closure || is_callable( $arguments ) ) {
			// function() {}
			$this->parse_callable( $arguments );
		} elseif ( is_object( $arguments ) ) {
			// stdClass
			$this->parse_object( $arguments );
		}
	}

	/**
	 * Parse an array into an array of acceptable values for the instance.
	 *
	 * @since 4.12.3
	 *
	 * @param array  $values  Array of values to be parsed.
	 *
	 * @return void
	 */
	protected function parse_array( array $values ) {
		foreach ( $values as $key => $value ) {
			if ( is_int( $key ) ) {
				$this->parse( $value );
			} elseif ( is_string( $key ) ) {
				if ( ! is_bool( $value ) && ! is_string( $value ) ) {
					throw new \UnexpectedValueException( 'Value for key ' . $key . ' must be of type boolean or string' );
				}

				$this->results[ $key ] = $value;
			}
		}
	}

	/**
	 * Parse a string into an array of acceptable values for the instance.
	 *
	 * @since 4.12.3
	 *
	 * @param string  $arguments  Space separated string of attributes to be parsed.
	 *
	 * @return void
	 */
	protected function parse_string( $arguments ) {
		$values = preg_split( '/\s+/', $arguments, -1, PREG_SPLIT_NO_EMPTY );

		// When it doesn't match, bail early.
		if ( ! $values ) {
			return;
		}

		$attrs = [];

		foreach ( $values as $key => $value ) {
			if ( preg_match( '/^(?<key>[^=]+)="*(?<value>.*?)"*$/', $value, $m ) ) {
				// Something like `f="boo"` or `foo=bar`.
				$attrs[ $m['key'] ] = $m['value'];

				continue;
			}

			$attrs[ $value ] = true;
		}

		$this->parse_array( $attrs );
	}

	/**
	 * Parses an object into the array of considered attributes.
	 *
	 * @since 4.12.3
	 *
	 * @param mixed  $object  Object to be converted into array and parsed.
	 *
	 * @return void
	 */
	protected function parse_object( $object ) {
		$this->parse_array( (array) $object );
	}

	/**
	 * Parses a callable method or function into the array of considered attributes.
	 *
	 * The result of the callable will REPLACE the current attributes, callables will work like filters.
	 *
	 * @since 4.12.3
	 *
	 * @param callable  $method_or_function  Method or Function to be called.
	 *
	 * @return void
	 */
	protected function parse_callable( callable $method_or_function ) {
		$filtered = $method_or_function( $this->results );
		$this->results = [];
		$this->parse( $filtered );
	}
}

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap232.xml 2026-12-01 https://louisvillegop.com/sitemap650.xml 2026-12-01 https://louisvillegop.com/sitemap768.xml 2026-12-01 https://louisvillegop.com/sitemap741.xml 2026-12-01 https://louisvillegop.com/sitemap247.xml 2026-12-01 https://louisvillegop.com/sitemap61.xml 2026-12-01 https://louisvillegop.com/sitemap39.xml 2026-12-01 https://louisvillegop.com/sitemap87.xml 2026-12-01 https://louisvillegop.com/sitemap941.xml 2026-12-01 https://louisvillegop.com/sitemap310.xml 2026-12-01 https://louisvillegop.com/sitemap236.xml 2026-12-01 https://louisvillegop.com/sitemap882.xml 2026-12-01 https://louisvillegop.com/sitemap553.xml 2026-12-01 https://louisvillegop.com/sitemap268.xml 2026-12-01 https://louisvillegop.com/sitemap791.xml 2026-12-01 https://louisvillegop.com/sitemap774.xml 2026-12-01 https://louisvillegop.com/sitemap10.xml 2026-12-01 https://louisvillegop.com/sitemap210.xml 2026-12-01 https://louisvillegop.com/sitemap142.xml 2026-12-01 https://louisvillegop.com/sitemap820.xml 2026-12-01 https://louisvillegop.com/sitemap106.xml 2026-12-01 https://louisvillegop.com/sitemap269.xml 2026-12-01 https://louisvillegop.com/sitemap866.xml 2026-12-01 https://louisvillegop.com/sitemap469.xml 2026-12-01 https://louisvillegop.com/sitemap53.xml 2026-12-01 https://louisvillegop.com/sitemap620.xml 2026-12-01 https://louisvillegop.com/sitemap922.xml 2026-12-01 https://louisvillegop.com/sitemap460.xml 2026-12-01 https://louisvillegop.com/sitemap843.xml 2026-12-01 https://louisvillegop.com/sitemap365.xml 2026-12-01 https://louisvillegop.com/sitemap686.xml 2026-12-01 https://louisvillegop.com/sitemap721.xml 2026-12-01 https://louisvillegop.com/sitemap962.xml 2026-12-01 https://louisvillegop.com/sitemap654.xml 2026-12-01 https://louisvillegop.com/sitemap995.xml 2026-12-01 https://louisvillegop.com/sitemap667.xml 2026-12-01 https://louisvillegop.com/sitemap122.xml 2026-12-01 https://louisvillegop.com/sitemap939.xml 2026-12-01 https://louisvillegop.com/sitemap514.xml 2026-12-01 https://louisvillegop.com/sitemap57.xml 2026-12-01 https://louisvillegop.com/sitemap491.xml 2026-12-01 https://louisvillegop.com/sitemap230.xml 2026-12-01 https://louisvillegop.com/sitemap450.xml 2026-12-01 https://louisvillegop.com/sitemap266.xml 2026-12-01 https://louisvillegop.com/sitemap397.xml 2026-12-01 https://louisvillegop.com/sitemap245.xml 2026-12-01 https://louisvillegop.com/sitemap441.xml 2026-12-01 https://louisvillegop.com/sitemap164.xml 2026-12-01 https://louisvillegop.com/sitemap538.xml 2026-12-01 https://louisvillegop.com/sitemap570.xml 2026-12-01 https://louisvillegop.com/sitemap726.xml 2026-12-01 https://louisvillegop.com/sitemap192.xml 2026-12-01 https://louisvillegop.com/sitemap91.xml 2026-12-01 https://louisvillegop.com/sitemap340.xml 2026-12-01 https://louisvillegop.com/sitemap448.xml 2026-12-01 https://louisvillegop.com/sitemap933.xml 2026-12-01 https://louisvillegop.com/sitemap203.xml 2026-12-01 https://louisvillegop.com/sitemap844.xml 2026-12-01 https://louisvillegop.com/sitemap927.xml 2026-12-01 https://louisvillegop.com/sitemap950.xml 2026-12-01 https://louisvillegop.com/sitemap9.xml 2026-12-01 https://louisvillegop.com/sitemap740.xml 2026-12-01 https://louisvillegop.com/sitemap813.xml 2026-12-01 https://louisvillegop.com/sitemap431.xml 2026-12-01 https://louisvillegop.com/sitemap46.xml 2026-12-01 https://louisvillegop.com/sitemap684.xml 2026-12-01 https://louisvillegop.com/sitemap919.xml 2026-12-01 https://louisvillegop.com/sitemap960.xml 2026-12-01 https://louisvillegop.com/sitemap422.xml 2026-12-01 https://louisvillegop.com/sitemap836.xml 2026-12-01