class VultrStorage_VideoMediaExtension {
private static $instance = null;
public static function get_instance() {
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
private function __construct() {
add_filter('plupload_init', array($this, 'modify_uploader_config'));
add_filter('wp_handle_upload_prefilter', array($this, 'pre_upload'));
add_filter('attachment_fields_to_edit', array($this, 'add_video_fields'), 10, 2);
add_filter('attachment_fields_to_save', array($this, 'save_video_fields'), 10, 2);
add_action('add_attachment', array($this, 'process_video_upload'));
add_action('delete_attachment', array($this, 'handle_video_deletion'));
}
public function modify_uploader_config($config) {
if (isset($_REQUEST['video_upload']) && $_REQUEST['video_upload'] === 'true') {
$config['filters']['mime_types'][0]['extensions'] = 'mp4,m4v,mov,wmv,avi,mpg,ogv,3gp,3g2';
}
return $config;
}
public function add_video_fields($form_fields, $post) {
if (!wp_attachment_is_video($post->ID)) {
return $form_fields;
}
$storage_type = get_post_meta($post->ID, '_video_storage_type', true);
if ($storage_type === 'youtube') {
$youtube_id = get_post_meta($post->ID, '_youtube_video_id', true);
$privacy = get_post_meta($post->ID, '_youtube_privacy', true);
$form_fields['youtube_privacy'] = array(
'label' => 'YouTube Gizlilik',
'input' => 'select',
'value' => $privacy,
'choices' => array(
'private' => 'Özel',
'unlisted' => 'Liste Dışı',
'public' => 'Herkese Açık'
)
);
}
return $form_fields;
}
public function save_video_fields($post, $attachment) {
if (!wp_attachment_is_video($post['ID'])) {
return $post;
}
if (isset($attachment['youtube_privacy'])) {
update_post_meta($post['ID'], '_youtube_privacy', $attachment['youtube_privacy']);
// YouTube API üzerinden gizlilik ayarını güncelle
$youtube = VultrStorage_YouTubeIntegration::get_instance();
$youtube->update_video_privacy($post['ID'], $attachment['youtube_privacy']);
}
return $post;
}
}
Depremzedeler Ağrı’da evlerde misafir ediliyor – Haber Değer