MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/public_html/wp-content/plugins/imageseo/src/Services/ImageSocial.php
<?php

namespace ImageSeoWP\Services;

if (!defined('ABSPATH')) {
    exit;
}

use ImageSeoWP\Helpers\SocialMedia;

class ImageSocial
{
    protected $transientProcess = null;

    public function __construct()
    {
        $this->optionService = imageseo_get_service('Option');
    }

    public function getPreviewImageIdSocialMedia($postId)
    {
        $id = get_post_meta($postId, sprintf('_imageseo_social_media_image_%s', SocialMedia::OPEN_GRAPH['name']), true);
        if (!$id) {
            return null;
        }

        return $id;
    }

    /**
     * @param int    $postId
     * @param string $size
     */
    public function getPreviewImageUrlSocialMedia($postId, $size = 'medium')
    {
        $medias = [
            SocialMedia::OPEN_GRAPH['name'],
        ];
        foreach ($medias as $media) {
            $id = get_post_meta($postId, sprintf('_imageseo_social_media_image_%s', $media), true);
            if (!$id) {
                continue;
            }

            return wp_get_attachment_image_url($id, $size);
        }

        return false;
    }

    public function getTransientProcess()
    {
        if (null !== $this->transientProcess) {
            return $this->transientProcess;
        }

        $this->transientProcess = get_transient('_imageseo_filename_social_process');

        return $this->transientProcess;
    }

    public function setCurrentProcess($postId)
    {
        $transient = $this->getTransientProcess();
        if (!$transient) {
            $transient = [];
        }
        $transient[$postId] = 1;

        set_transient('_imageseo_filename_social_process', $transient, 60);
    }

    /**
     * @param int $postId
     *
     * @return bool
     */
    public function isCurrentProcess($postId)
    {
        $transient = $this->getTransientProcess();
        if (!$transient) {
            return false;
        }

        return array_key_exists($postId, $transient);
    }
}