403Webshell
Server IP : 104.21.14.103  /  Your IP : 3.12.74.189
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/self/cwd/wp-content/plugins/wordpress-seo/frontend/schema/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/self/cwd/wp-content/plugins/wordpress-seo/frontend/schema/class-schema-image.php
<?php
/**
 * WPSEO plugin file.
 *
 * @package WPSEO\Frontend\Schema
 */

/**
 * Returns schema image data.
 *
 * @since 11.1
 *
 * @property string $schema_id      The `@id` to use for the returned image.
 * @property array  $data           The ImageObject Schema array.
 * @property int    $attachment_id  The ID of the attachment used to generate the object.
 */
class WPSEO_Schema_Image {

	/**
	 * The `@id` to use for the returned image.
	 *
	 * @var string
	 */
	private $schema_id;

	/**
	 * The ImageObject Schema array.
	 *
	 * @var array
	 */
	private $data;

	/**
	 * The ID of the attachment used to generate the object.
	 *
	 * @var int
	 */
	private $attachment_id;

	/**
	 * WPSEO_Schema_Image constructor.
	 *
	 * @param string $schema_id The string to use in an image's `@id`.
	 */
	public function __construct( $schema_id ) {
		$this->schema_id = $schema_id;
		$this->generate_object();
	}

	/**
	 * Find an image based on its URL and generate a Schema object for it.
	 *
	 * @param string $url     The image URL to base our object on.
	 * @param string $caption An optional caption.
	 *
	 * @return array Schema ImageObject array.
	 */
	public function generate_from_url( $url, $caption = '' ) {
		$attachment_id = WPSEO_Image_Utils::get_attachment_by_url( $url );
		if ( $attachment_id > 0 ) {
			return $this->generate_from_attachment_id( $attachment_id, $caption );
		}

		return $this->simple_image_object( $url, $caption );
	}

	/**
	 * Retrieve data about an image from the database and use it to generate a Schema object.
	 *
	 * @param int    $attachment_id The attachment to retrieve data from.
	 * @param string $caption       The caption string, if there is one.
	 *
	 * @return array Schema ImageObject array.
	 */
	public function generate_from_attachment_id( $attachment_id, $caption = '' ) {
		$this->attachment_id = $attachment_id;
		$this->data['url']   = wp_get_attachment_image_url( $this->attachment_id, 'full' );
		$this->add_image_size();
		$this->add_caption( $caption );

		return $this->data;
	}

	/**
	 * If we can't find $url in our database, we output a simple ImageObject.
	 *
	 * @param string $url     The image URL.
	 * @param string $caption A caption, if set.
	 *
	 * @return array $data Schema ImageObject array.
	 */
	public function simple_image_object( $url, $caption = '' ) {
		$this->data['url'] = $url;

		if ( ! empty( $caption ) ) {
			$this->data['caption'] = $caption;
		}

		return $this->data;
	}

	/**
	 * Retrieves an image's caption if set, or uses the alt tag if that's set.
	 *
	 * @param string $caption The caption string, if there is one.
	 *
	 * @return void
	 */
	private function add_caption( $caption = '' ) {
		if ( ! empty( $caption ) ) {
			$this->data['caption'] = $caption;

			return;
		}

		$caption = wp_get_attachment_caption();
		if ( ! empty( $caption ) ) {
			$this->data['caption'] = $caption;

			return;
		}

		$caption = get_post_meta( $this->attachment_id, '_wp_attachment_image_alt', true );
		if ( ! empty( $caption ) ) {
			$this->data['caption'] = $caption;
		}
	}

	/**
	 * Generates our bare bone ImageObject.
	 *
	 * @return void
	 */
	private function generate_object() {
		$this->data = [
			'@type' => 'ImageObject',
			'@id'   => $this->schema_id,
		];

		$this->data = WPSEO_Schema_Utils::add_piece_language( $this->data );
	}

	/**
	 * Adds image's width and height.
	 *
	 * @return void
	 */
	private function add_image_size() {
		$image_meta = wp_get_attachment_metadata( $this->attachment_id );
		if ( empty( $image_meta['width'] ) || empty( $image_meta['height'] ) ) {
			return;
		}
		$this->data['width']  = $image_meta['width'];
		$this->data['height'] = $image_meta['height'];
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit