HEX
HEX
Server: Apache
System: Linux localhost.localdomain 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64
User: www (1001)
PHP: 8.1.32
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/ahmsolaiman.com/wp-content/plugins/types/application/models/media/mapper.php
<?php

/**
 * @since 2.3
 */
class Types_Media_Mapper implements Types_Media_Mapper_Interface {

	/**
	 * @var Types_Wordpress_Media_Interface
	 */
	private $attachment;


	/**
	 * Types_Media_Mapper constructor.
	 *
	 * @param Types_Wordpress_Media_Interface $attachment
	 */
	public function __construct( Types_Wordpress_Media_Interface $attachment ) {
		$this->attachment = $attachment;
	}


	/**
	 * @param string $url
	 *
	 * @return false|Types_Media
	 */
	public function find_by_url( $url ) {
		if ( ! $id = $this->attachment->get_attachment_id_by_url( $url ) ) {
			return new Types_Media( array( 'url' => $url ) );
		}

		return $this->find_by_id( $id );
	}


	/**
	 * @param int $id
	 *
	 * @return false|Types_Media
	 */
	public function find_by_id( $id ) {
		if ( ! $attachment = $this->attachment->get_attachment_by_id( $id ) ) {
			return false;
		}

		if ( ! $url = wp_get_attachment_url( $id ) ) {
			return false;
		}

		return new Types_Media(
			array(
				'id' => $id,
				'url' => $url,
				'title' => $attachment['post_title'],
				'description' => $attachment['post_content'],
				'caption' => $attachment['post_excerpt'],
				'alt' => $attachment['alt'],
			)
		);
	}


	/**
	 * Not used yet.
	 *
	 * @param Types_Interface_Media $media
	 */
	public function store( Types_Interface_Media $media ) {
		// TODO implement when it's used.
	}
}