| 1 |
<?php |
| 2 |
|
| 3 |
namespace Beyondwords\Wordpress\Core\Player\Renderer; |
| 4 |
|
| 5 |
use Beyondwords\Wordpress\Component\Post\PostMetaUtils; |
| 6 |
use Beyondwords\Wordpress\Component\Settings\Fields\IntegrationMethod\IntegrationMethod; |
| 7 |
use Beyondwords\Wordpress\Core\CoreUtils; |
| 8 |
|
| 9 |
/** |
| 10 |
* Class Base. |
| 11 |
* |
| 12 |
* Base class for player renderers. |
| 13 |
*/ |
| 14 |
class Base |
| 15 |
{ |
| 16 |
/** |
| 17 |
* Check whether a player should be rendered. |
| 18 |
* |
| 19 |
* @param \WP_Post $post WordPress post object. |
| 20 |
* |
| 21 |
* @return bool True if a player should be rendered. |
| 22 |
*/ |
| 23 |
public static function check(\WP_Post $post): bool |
| 24 |
{ |
| 25 |
if (function_exists('is_preview') && is_preview()) { |
| 26 |
return false; |
| 27 |
} |
| 28 |
|
| 29 |
if (CoreUtils::isGutenbergPage() || CoreUtils::isEditScreen()) { |
| 30 |
return false; |
| 31 |
} |
| 32 |
|
| 33 |
$projectId = PostMetaUtils::getProjectId($post->ID); |
| 34 |
|
| 35 |
if (! $projectId) { |
| 36 |
return false; |
| 37 |
} |
| 38 |
|
| 39 |
$contentId = PostMetaUtils::getContentId($post->ID); |
| 40 |
$method = IntegrationMethod::getIntegrationMethod($post); |
| 41 |
|
| 42 |
return $method === IntegrationMethod::CLIENT_SIDE || |
| 43 |
($method === IntegrationMethod::REST_API && $contentId); |
| 44 |
} |
| 45 |
} |
| 46 |
|