| 1 |
<?php |
| 2 |
/** |
| 3 |
* Base class for player renderers. |
| 4 |
* |
| 5 |
* @package BeyondWords\Player\Renderer |
| 6 |
* @since 6.0.0 |
| 7 |
* @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. |
| 8 |
*/ |
| 9 |
|
| 10 |
declare( strict_types = 1 ); |
| 11 |
|
| 12 |
namespace BeyondWords\Player\Renderer; |
| 13 |
|
| 14 |
defined( 'ABSPATH' ) || exit; |
| 15 |
|
| 16 |
/** |
| 17 |
* Common eligibility checks for every renderer. |
| 18 |
* |
| 19 |
* @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. |
| 20 |
*/ |
| 21 |
class Base { |
| 22 |
|
| 23 |
/** |
| 24 |
* Whether a player should be rendered for this post in this request. |
| 25 |
* |
| 26 |
* @param \WP_Post $post WordPress post object. |
| 27 |
*/ |
| 28 |
public static function check( \WP_Post $post ): bool { |
| 29 |
if ( function_exists( 'is_preview' ) && is_preview() ) { |
| 30 |
return false; |
| 31 |
} |
| 32 |
|
| 33 |
if ( \BeyondWords\Core\Utils::is_gutenberg_page() || \BeyondWords\Core\Utils::is_edit_screen() ) { |
| 34 |
return false; |
| 35 |
} |
| 36 |
|
| 37 |
$project_id = \BeyondWords\Post\Meta::get_project_id( $post->ID ); |
| 38 |
|
| 39 |
if ( ! $project_id ) { |
| 40 |
return false; |
| 41 |
} |
| 42 |
|
| 43 |
$content_id = \BeyondWords\Post\Meta::get_content_id( $post->ID ); |
| 44 |
$method = \BeyondWords\Settings\Fields::get_integration_method( $post ); |
| 45 |
|
| 46 |
return \BeyondWords\Settings\Fields::INTEGRATION_CLIENT_SIDE === $method |
| 47 |
|| ( \BeyondWords\Settings\Fields::INTEGRATION_REST_API === $method && $content_id ); |
| 48 |
} |
| 49 |
} |
| 50 |
|