| 1 |
<?php |
| 2 |
/** |
| 3 |
* Social profiles 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 |
* Social Profile Item Block Class. |
| 21 |
*/ |
| 22 |
class Social_Profiles extends Block_Base { |
| 23 |
|
| 24 |
|
| 25 |
/** |
| 26 |
* Set_block_properties |
| 27 |
* |
| 28 |
* @return void |
| 29 |
*/ |
| 30 |
protected function set_block_properties() { |
| 31 |
$this->block_name = 'social-profiles'; |
| 32 |
$this->styles = array( 'sp_smart_post_blocks_google_fonts' ); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Render Social Profile Item block. |
| 37 |
* |
| 38 |
* @param array $attributes Block attributes. |
| 39 |
* @param string $content Block content. |
| 40 |
* @param array $blocks Inner blocks. |
| 41 |
* @return $content. |
| 42 |
*/ |
| 43 |
public function render_block( $attributes, $content = '', $blocks = array() ) { |
| 44 |
if ( Helper::is_editor_page() ) { |
| 45 |
return $content; |
| 46 |
} |
| 47 |
|
| 48 |
$attributes['page_id'] = get_the_ID(); |
| 49 |
$sp_block_name = $attributes['blockName'] ?? ''; |
| 50 |
$sp_unique_id = $attributes['uniqueId'] ?? ''; |
| 51 |
$sp_layout = $attributes['layout'] ?? ''; |
| 52 |
$sp_social_alignment = $attributes['socialAlignment'] ?? ''; |
| 53 |
$sp_social_hover_effect = $attributes['socialHoverEffect'] ?? ''; |
| 54 |
$additional_css_class = $attributes['additionalCssClass'] ?? ''; |
| 55 |
$show_divider_icon = ! empty( $attributes['socialIconDivider'] ) ? $attributes['socialIconDivider'] : false; |
| 56 |
|
| 57 |
unset( |
| 58 |
$attributes['dynamicCss'], |
| 59 |
$attributes['fontListsEditPage'], |
| 60 |
$attributes['fontLists'] |
| 61 |
); |
| 62 |
|
| 63 |
// const dividerClass = |
| 64 |
// layout === "social-profiles-layout-three" && socialIconDivider ? "sp-icon-divider" : "sp-icon-divider-none"; |
| 65 |
$divider_class = ( 'social-profiles-layout-three' === $sp_layout && $show_divider_icon ) ? 'sp-icon-divider' : 'sp-icon-divider-none'; |
| 66 |
|
| 67 |
$sp_profiles_wrapper_class = 'sp-social-profile-wrapper ' . $sp_layout . ' sp-align-' . $sp_social_alignment . ' sp-icon-hover-effect-' . $sp_social_hover_effect . ' ' . $divider_class; |
| 68 |
$align_class = isset( $attributes['align'] ) ? 'align' . $attributes['align'] : ''; |
| 69 |
$container_class = 'sp-smart-post-wrapper' . $align_class . ( $additional_css_class === '' ? '' : ' ' . $additional_css_class ); |
| 70 |
|
| 71 |
ob_start(); |
| 72 |
?> |
| 73 |
<div class="<?php echo esc_attr( $container_class ); ?>"> |
| 74 |
<div id="<?php echo esc_attr( $sp_unique_id ); ?>" class="sp-smart-post-wrapper"> |
| 75 |
<div class="<?php echo esc_attr( $sp_profiles_wrapper_class ); ?>"> |
| 76 |
<div class="sp-social-profile-wrapper-grid-class"> |
| 77 |
<?php echo wp_kses_post( $content ); ?> |
| 78 |
</div> |
| 79 |
</div> |
| 80 |
</div> |
| 81 |
</div> |
| 82 |
<?php |
| 83 |
return ob_get_clean(); |
| 84 |
} |
| 85 |
} |
| 86 |
|