| 1 |
<?php |
| 2 |
/** |
| 3 |
* Container column class for Smart Post Show Blocks. |
| 4 |
* |
| 5 |
* @package Smart_Post_Show_Pro |
| 6 |
* @subpackage Smart_Post_Show_Pro/blocks/includes |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace SmartPostShow\Blocks; |
| 10 |
|
| 11 |
use SmartPostShow\Blocks\Helper; |
| 12 |
|
| 13 |
use SmartPostShow\Blocks\Block_Base; |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Column |
| 21 |
*/ |
| 22 |
class Column extends Block_Base { |
| 23 |
/** |
| 24 |
* Set block properties |
| 25 |
* |
| 26 |
* @return void |
| 27 |
*/ |
| 28 |
protected function set_block_properties() { |
| 29 |
$this->block_name = 'column'; |
| 30 |
$this->styles = array( |
| 31 |
'sp_smart_post_blocks_css', |
| 32 |
); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Render Column block. |
| 37 |
* |
| 38 |
* @param array $attributes attributes. |
| 39 |
* @param mixed $content Content to be rendered. |
| 40 |
* @param array $blocks Blocks to be rendered. |
| 41 |
* @return string Rendered HTML content. |
| 42 |
*/ |
| 43 |
public function render_block( $attributes, $content = '', $blocks = array() ) { |
| 44 |
if ( Helper::is_editor_page() ) { |
| 45 |
return $content; |
| 46 |
} |
| 47 |
$attributes['page_id'] = get_the_ID(); |
| 48 |
|
| 49 |
unset( |
| 50 |
$attributes['dynamicCss'], |
| 51 |
$attributes['fontListsEditPage'], |
| 52 |
$attributes['fontLists'] |
| 53 |
); |
| 54 |
$unique_id = $attributes['uniqueId'] ?? ''; |
| 55 |
$column_additional_class = $attributes['columnAdditionalClass'] ?? ''; |
| 56 |
$column_additional_id = $attributes['columnAdditionalID'] ?? ''; |
| 57 |
$column_wrapper_link_enable = isset( $attributes['columnWrapperLink'] ) ? $attributes['columnWrapperLink'] : false; |
| 58 |
$column_wrapper_link_url = $attributes['columnWrapperLinkUrl'] ?? ''; |
| 59 |
$column_wrapper_link_newtab = isset( $attributes['columnWrapperLinkNewTab'] ) && $attributes['columnWrapperLinkNewTab'] ? '_blank' : '_self'; |
| 60 |
// Video Background Attributes. |
| 61 |
$background_style = isset( $attributes['columnBg']['color']['style'] ) ? $attributes['columnBg']['color']['style'] : ''; |
| 62 |
$background_video = $attributes['columnBgVideo'] ?? ''; |
| 63 |
$background_video_url = isset( $background_video['url'] ) ? $background_video['url'] : ''; |
| 64 |
|
| 65 |
// Column Class. |
| 66 |
$column_class = array( $unique_id, 'sp-smart-post-container-column' ); |
| 67 |
if ( ! empty( $column_additional_class ) ) { |
| 68 |
$column_class[] = $column_additional_class; |
| 69 |
} |
| 70 |
$column_class_output = implode( ' ', $column_class ); |
| 71 |
|
| 72 |
ob_start(); |
| 73 |
?> |
| 74 |
<div class="<?php echo esc_attr( $column_class_output ); ?>" id="<?php echo esc_attr( $unique_id ); ?>"> |
| 75 |
<div class="sp-smart-post-column-wrapper" id="<?php echo esc_attr( $column_additional_id ); ?>"> |
| 76 |
<?php if ( 'video' === $background_style && ! empty( $background_video ) ) : ?> |
| 77 |
<!-- Container Video Background Start --> |
| 78 |
<div class="sp-smart-post-column__video-wrap"> |
| 79 |
<video muted loop autoplay> |
| 80 |
<source src="<?php echo esc_url( $background_video_url ); ?>" type="video/mp4"> |
| 81 |
Your browser does not support the html5 video tag. |
| 82 |
</video> |
| 83 |
</div> |
| 84 |
<!-- Container Video Background Ends --> |
| 85 |
<?php endif; ?> |
| 86 |
<div class="sp-smart-post-show-column"> |
| 87 |
<!-- Container Content div start --> |
| 88 |
<?php |
| 89 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- The HTML output is already properly escaped at the time of generation, so additional escaping is not required here. |
| 90 |
echo $content; |
| 91 |
?> |
| 92 |
<!-- Container Content div ends --> |
| 93 |
<?php if ( $column_wrapper_link_enable && ! empty( $column_wrapper_link_url ) ) : ?> |
| 94 |
<a class="sp-smart-post-column-block-wrapper-link" rel="noopener" href="<?php echo esc_url( $column_wrapper_link_url ); ?>" target="<?php echo esc_attr( $column_wrapper_link_newtab ); ?>"></a> |
| 95 |
<?php endif; ?> |
| 96 |
</div> |
| 97 |
</div> |
| 98 |
</div> |
| 99 |
<?php |
| 100 |
return ob_get_clean(); |
| 101 |
} |
| 102 |
} |
| 103 |
|