| Server IP : 121.121.20.254 / Your IP : 216.73.217.51 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/KnowledgeBase/wp-content/plugins/real-media-library/inc/metadata/ |
Upload File : |
<?php
namespace MatthiasWeb\RealMediaLibrary\metadata;
use MatthiasWeb\RealMediaLibrary\api\IMetadata;
// @codeCoverageIgnoreStart
\defined('ABSPATH') or die('No script kiddies please!');
// Avoid direct file request
// @codeCoverageIgnoreEnd
/**
* Implements a description field.
*/
class Description implements IMetadata
{
/**
* Get description if set.
*
* @param int $folder_id
* @return string
*/
public function getDescription($folder_id)
{
return \get_media_folder_meta($folder_id, 'description', \true);
}
/**
* Generate content for meta box.
*
* @param string $content
* @param IFolder $folder
*/
public function content($content, $folder)
{
$description = $this->getDescription($folder->getId());
$content .= '<label>' . \__('Description') . '</label><textarea name="description" class="regular-text">' . \esc_textarea($description) . '</textarea>';
return $content;
}
/**
* Save content in meta box.
*
* @param string[] $response
* @param IFolder $folder
* @param WP_REST_Request $request
* @return string[]
*/
public function save($response, $folder, $request)
{
$fid = $folder->getId();
$description = $this->getDescription($fid);
$new = $request->get_param('description');
if (isset($new) && $new !== $description) {
if (\strlen($new) > 0) {
\update_media_folder_meta($fid, 'description', $new);
} else {
// Delete it
\delete_media_folder_meta($fid, 'description');
}
}
return $response;
}
/**
* Enqueue scripts.
*
* @param Assets $assets
*/
public function scripts($assets)
{
// Silence is golden.
}
}