| 1 |
<?php |
| 2 |
|
| 3 |
namespace gutenify; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) || exit; |
| 6 |
|
| 7 |
class Post_Carousel { |
| 8 |
public static function init() { |
| 9 |
add_action( 'init', array( __CLASS__, 'register_block' ) ); |
| 10 |
|
| 11 |
add_filter( 'gutenify_render_block_gutenify/post-carousel', array( __CLASS__, 'render_block' ), 10, 4 ); |
| 12 |
} |
| 13 |
|
| 14 |
public static function register_block() { |
| 15 |
register_block_type( |
| 16 |
__DIR__, |
| 17 |
array( |
| 18 |
'render_callback' => array( __CLASS__, 'render_callback' ), |
| 19 |
) |
| 20 |
); |
| 21 |
} |
| 22 |
|
| 23 |
public static function render_callback( $attr, $content, $props ) { |
| 24 |
$layout = ! empty( $attr['layout'] ) ? esc_attr( $attr['layout'] ) : 1; |
| 25 |
$wrapper_attributes = get_block_wrapper_attributes( array( |
| 26 |
'class' => 'gutenify-post-carousel-' . $layout |
| 27 |
) ); |
| 28 |
|
| 29 |
$has_navigation = ! ( isset( $attr['hasNavigation']) && false === $attr['hasNavigation'] ); |
| 30 |
$has_pagination = ! ( isset( $attr['hasPagination']) && false === $attr['hasPagination'] ); |
| 31 |
|
| 32 |
$new_content = sprintf( '<div %s>', $wrapper_attributes ); |
| 33 |
$new_content .= '<div class="swiper-wrapper">'; |
| 34 |
$posts = Post_List::get_posts( $attr, $props ); |
| 35 |
$new_content .= self::display_posts( $posts, $attr, $props ); |
| 36 |
$new_content .= '</div>'; |
| 37 |
if ( $has_navigation ) { |
| 38 |
$new_content .= '<div class="navigation-wrap"> |
| 39 |
<div class="swiper-button-prev"></div> |
| 40 |
<div class="swiper-button-next"></div> |
| 41 |
</div>'; |
| 42 |
} |
| 43 |
|
| 44 |
if ( $has_pagination ) { |
| 45 |
$new_content .= '<div class="swiper-pagination"></div>'; |
| 46 |
} |
| 47 |
$new_content .= '</div>'; |
| 48 |
return $new_content; |
| 49 |
} |
| 50 |
|
| 51 |
public static function display_posts($posts, $attributes, $props) |
| 52 |
{ |
| 53 |
$constants = \gutenify\Helpers::plugin_constants(); |
| 54 |
$plugin_main_slug = $constants['plugin_main_slug']; |
| 55 |
$plugin_main_camel_case_name = $constants['plugin_main_camel_case_name']; |
| 56 |
|
| 57 |
|
| 58 |
$list_items_markup = ''; |
| 59 |
|
| 60 |
$has_image = !$attributes['displayFeaturedImage'] ? 'has-no-feature-image': ''; |
| 61 |
|
| 62 |
$default_image_url = $constants['core_base_url'] . 'assets/images/placeholder-attachment.png'; |
| 63 |
|
| 64 |
foreach ($posts as $post) { |
| 65 |
|
| 66 |
$list_class = ''; |
| 67 |
$align_self_class = ''; |
| 68 |
|
| 69 |
$list_items_markup .= '<div class="gutenify-post-carousel-item gutenify-post-carousel-item-wrapper swiper-slide ">'; |
| 70 |
$list_items_markup .= '<div class="gutenify-post-carousel-item-inner-wrapper ' . $has_image . '">'; |
| 71 |
|
| 72 |
if (!empty($attributes['displayFeaturedImage'])) { |
| 73 |
$thumbnail_url = $default_image_url; |
| 74 |
if (has_post_thumbnail($post['ID'])) { |
| 75 |
$thumbnail_url = get_the_post_thumbnail_url($post['ID']); |
| 76 |
} |
| 77 |
$list_items_markup .= sprintf( |
| 78 |
'<div class="gutenify-post-carousel-thumb"> |
| 79 |
<a class="image-hover-zoom" href="%1$s"> |
| 80 |
<img src="%2$s" /> |
| 81 |
</a> |
| 82 |
</div>', |
| 83 |
esc_url($post['postLink']), |
| 84 |
esc_url($thumbnail_url) |
| 85 |
); |
| 86 |
} |
| 87 |
|
| 88 |
$list_items_markup .= sprintf( |
| 89 |
'<div class="gutenify-post-carousel-text-content %s">', |
| 90 |
esc_attr($align_self_class) |
| 91 |
); |
| 92 |
|
| 93 |
$title = $post['title']; |
| 94 |
|
| 95 |
if (!$title) { |
| 96 |
|
| 97 |
$title = _x('(no title)', 'placeholder when a post has no title', 'gutenify'); |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
$list_items_markup .= sprintf( |
| 102 |
'<h3 class="gutenify-post-carousel-title"><a href="%1$s" rel="bookmark">%2$s</a></h3> ', |
| 103 |
$post['postLink'], |
| 104 |
$title |
| 105 |
); |
| 106 |
$meta_data = ''; |
| 107 |
if (isset($attributes['displayPostDate']) && $attributes['displayPostDate']) { |
| 108 |
$meta_data .= sprintf( |
| 109 |
'<span class="posted-on"><time datetime="%1$s" class="gutenify-posts-date">%2$s</time></span>', |
| 110 |
esc_html($post['date']), |
| 111 |
esc_html($post['dateReadable']) |
| 112 |
); |
| 113 |
|
| 114 |
} |
| 115 |
if (!empty($attributes['displayPostAuthor'])) { |
| 116 |
if (!get_the_author_meta('description') && post_type_supports(get_post_type(), 'author')) { |
| 117 |
$meta_data .= '<span class="byline">'; |
| 118 |
$meta_data .= sprintf( |
| 119 |
'%s', |
| 120 |
'<a href="' . esc_url(get_author_posts_url($post['author_id'])) . '" rel="author">' . esc_html(get_the_author_meta('display_name', $post['author_id'])) . '</a>' |
| 121 |
); |
| 122 |
$meta_data .= '</span>'; |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
if (!empty($attributes['displayPostCategories'])) { |
| 127 |
/* translators: used between list items, there is a space after the comma. */ |
| 128 |
$categories_list = get_the_category_list(__(', '), '', $post['ID']); |
| 129 |
if ($categories_list) { |
| 130 |
$meta_data .= sprintf( |
| 131 |
'<span class="cat-links">%s </span>', |
| 132 |
$categories_list // phpcs:ignore WordPress.Security.EscapeOutput |
| 133 |
); |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
if (!empty($meta_data)) { |
| 138 |
$list_items_markup .= sprintf('<div class="gutenify-post-carousel-meta">%1$s</div>', $meta_data); |
| 139 |
} |
| 140 |
|
| 141 |
if (isset($attributes['displayPostContent']) && $attributes['displayPostContent']) { |
| 142 |
|
| 143 |
$post_excerpt = $post['postExcerpt']; |
| 144 |
$trimmed_excerpt = esc_html(wp_trim_words($post_excerpt, $attributes['excerptLength'], ' … ')); |
| 145 |
$list_items_markup .= '<div class="entry-summary">'; |
| 146 |
$list_items_markup .= sprintf( |
| 147 |
'<p>%1$s</p>', |
| 148 |
esc_html($trimmed_excerpt) |
| 149 |
); |
| 150 |
|
| 151 |
if (isset($attributes['displayPostLink']) && $attributes['displayPostLink']) { |
| 152 |
|
| 153 |
$list_items_markup .= sprintf( |
| 154 |
'<a href="%1$s" class="more-link"><span class="more-button">%2$s<span class="screen-reader-text">%3$s</span></span></a>', |
| 155 |
esc_url($post['postLink']), |
| 156 |
esc_html($attributes['postLink']), |
| 157 |
esc_html($post['title']) |
| 158 |
); |
| 159 |
|
| 160 |
} |
| 161 |
|
| 162 |
$list_items_markup .= '</div>'; |
| 163 |
} |
| 164 |
|
| 165 |
$list_items_markup .= '</div></div></div>'; |
| 166 |
|
| 167 |
} |
| 168 |
|
| 169 |
return $list_items_markup; |
| 170 |
} |
| 171 |
|
| 172 |
public static function render_block( $block_content, $block, $instance, $block_id ) { |
| 173 |
|
| 174 |
|
| 175 |
$css_thread = ''; |
| 176 |
//color |
| 177 |
$css_chunk = ''; |
| 178 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['textColor'])) { |
| 179 |
$css_chunk .= 'color: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['textColor'] . ';'; |
| 180 |
} |
| 181 |
|
| 182 |
$background_color = !empty( $instance->attributes['blockAdvanceOptions']['innerBlock']['backgroundColor'] ) ? esc_attr($instance->attributes['blockAdvanceOptions']['innerBlock']['backgroundColor'] ) : ''; |
| 183 |
$background_color = ! empty( $block['attrs']['blockAdvanceOptions']['innerBlock']['backgroundColor'] ) ? esc_attr($block['attrs']['blockAdvanceOptions']['innerBlock']['backgroundColor'] ) : $background_color; |
| 184 |
|
| 185 |
if ( ! empty( $background_color ) ) { |
| 186 |
$css_chunk .= 'background-color: ' . esc_attr( $background_color ). ' ;'; |
| 187 |
} |
| 188 |
|
| 189 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['backgroundGradient'])) { |
| 190 |
$css_chunk .= 'background: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['backgroundGradient'] . ';'; |
| 191 |
} |
| 192 |
|
| 193 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['borderColor'])) { |
| 194 |
$css_chunk .= 'border-color: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['borderColor'] . ';'; |
| 195 |
} |
| 196 |
|
| 197 |
//borderWidth |
| 198 |
if ( ! empty( $block['attrs']['blockAdvanceOptions']['innerBlock']['borderWidth'] ) ) { |
| 199 |
$css_chunk .= 'border-style:solid;'; |
| 200 |
$css_chunk .= \gutenify\Style_Helpers::box_control( $block['attrs']['blockAdvanceOptions']['innerBlock']['borderWidth'], 'border-', '-width' ); |
| 201 |
} |
| 202 |
|
| 203 |
//borderWidth |
| 204 |
if ( ! empty( $block['attrs']['blockAdvanceOptions']['innerBlock']['borderRadius'] ) ) { |
| 205 |
$css_chunk .= \gutenify\Style_Helpers::border_radius_control( $block['attrs']['blockAdvanceOptions']['innerBlock']['borderRadius'] ); |
| 206 |
} |
| 207 |
|
| 208 |
if ( ! empty( $block['attrs']['blockAdvanceOptions']['innerBlock']['boxShadow'] ) ) { |
| 209 |
$css_chunk .= \gutenify\Style_Helpers::custom_box_shadow_control( $block['attrs']['blockAdvanceOptions']['innerBlock']['boxShadow'] ); |
| 210 |
} |
| 211 |
|
| 212 |
$inner_block_selector = '.' . $block_id . ' .gutenify-post-carousel-item-inner-wrapper'; |
| 213 |
|
| 214 |
$css_thread .= $inner_block_selector . '{'; |
| 215 |
$css_thread .= $css_chunk; |
| 216 |
$css_thread .= '}'; |
| 217 |
|
| 218 |
/** |
| 219 |
* Content padding |
| 220 |
*/ |
| 221 |
if ( ! empty( $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding'] ) ) { |
| 222 |
$css_thread .= Dynamic_Styles::get_spacing_with_media( '.' . $block_id . '.wp-block-gutenify-post-carousel .gutenify-post-carousel-item .gutenify-post-carousel-item-inner-wrapper .gutenify-post-carousel-text-content', $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding'], 'padding-' ); |
| 223 |
} |
| 224 |
|
| 225 |
|
| 226 |
/** |
| 227 |
* Hover |
| 228 |
*/ |
| 229 |
$css_chunk = ''; |
| 230 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['hoverTextColor'])) { |
| 231 |
$css_chunk .= 'color: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['hoverTextColor'] . ';'; |
| 232 |
} |
| 233 |
|
| 234 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBackgroundColor'])) { |
| 235 |
$css_chunk .= 'background-color: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBackgroundColor'] . ';'; |
| 236 |
} |
| 237 |
|
| 238 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBackgroundGradient'])) { |
| 239 |
$css_chunk .= 'background: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBackgroundGradient'] . ';'; |
| 240 |
} |
| 241 |
|
| 242 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBorderColor'])) { |
| 243 |
$css_chunk .= 'border-color: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBorderColor'] . ';'; |
| 244 |
} |
| 245 |
|
| 246 |
$inner_block_selector = $inner_block_selector . ':hover'; |
| 247 |
|
| 248 |
$css_thread .= $inner_block_selector . '{'; |
| 249 |
$css_thread .= $css_chunk; |
| 250 |
$css_thread .= '}'; |
| 251 |
|
| 252 |
|
| 253 |
/** |
| 254 |
* Thubmnail |
| 255 |
*/ |
| 256 |
$css_chunk = ''; |
| 257 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['thumbnailMinHeight'])) { |
| 258 |
$css_chunk .= 'height:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['thumbnailMinHeight'] . ';'; |
| 259 |
} |
| 260 |
$thumbnail_selector = '.' . $block_id . ' .gutenify-post-carousel-item-inner-wrapper .gutenify-post-carousel-thumb img'; |
| 261 |
|
| 262 |
$css_thread .= $thumbnail_selector . '{'; |
| 263 |
$css_thread .= $css_chunk; |
| 264 |
$css_thread .= '}'; |
| 265 |
|
| 266 |
$css_chunk = ''; |
| 267 |
if(!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['postTitleSize'])){ |
| 268 |
$css_chunk .= 'font-size:'. $block['attrs']['blockAdvanceOptions']['innerBlock']['postTitleSize']; |
| 269 |
} |
| 270 |
$post_title_selector = '.' . $block_id . ' .gutenify-post-carousel-title'; |
| 271 |
$css_thread .= $post_title_selector . '{'; |
| 272 |
$css_thread .= $css_chunk; |
| 273 |
$css_thread .= '}'; |
| 274 |
|
| 275 |
$handle = 'gutenify_' . str_replace( '/', '_', $block['blockName'] ) . '_' . $block_id; |
| 276 |
wp_add_inline_style( $handle, $css_thread ); |
| 277 |
|
| 278 |
return $block_content; |
| 279 |
} |
| 280 |
} |
| 281 |
|
| 282 |
Post_Carousel::init(); |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
/** |
| 287 |
* Registers all block assets so that they can be enqueued through Gutenberg in |
| 288 |
* the corresponding context. |
| 289 |
* |
| 290 |
* Passes translations to JavaScript. |
| 291 |
*/ |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
function gutenify_post_carousel_render_block($block_content, $block) |
| 296 |
{ |
| 297 |
if ((isset($block['blockName']) && 'gutenify/post-carousel' !== $block['blockName']) || is_admin()) { |
| 298 |
return $block_content; |
| 299 |
} |
| 300 |
|
| 301 |
$block_id = wp_unique_id('gtfy-'); |
| 302 |
$block_client_id = !empty($block['attrs']['blockClientId']) ? 'gutenify-section-' . esc_attr($block['attrs']['blockClientId']) : $block_id; |
| 303 |
|
| 304 |
$block_content = new WP_HTML_Tag_Processor($block_content); |
| 305 |
$block_content->next_tag(); |
| 306 |
$block_content->add_class($block_client_id); |
| 307 |
|
| 308 |
//selector |
| 309 |
// $has_image = $block['attrs'] |
| 310 |
|
| 311 |
$root_selector = '.' . $block_client_id . '.wp-block-gutenify-post-carousel'; |
| 312 |
$inner_block_selector = $root_selector . ' .gutenify-post-carousel-item-inner-wrapper'; |
| 313 |
$css = ''; |
| 314 |
|
| 315 |
$css .= $inner_block_selector . '{'; |
| 316 |
|
| 317 |
//color |
| 318 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['textColor'])) { |
| 319 |
$css .= 'color: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['textColor'] . ';'; |
| 320 |
} |
| 321 |
|
| 322 |
//background Color |
| 323 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['backgroundGradient'])) { |
| 324 |
$css .= 'background: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['backgroundGradient'] . ';'; |
| 325 |
} |
| 326 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['backgroundColor'])) { |
| 327 |
$css .= 'background-color: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['backgroundColor'] . ';'; |
| 328 |
} else { |
| 329 |
$css .= 'background-color: #f3f3f3;'; |
| 330 |
} |
| 331 |
|
| 332 |
//border color |
| 333 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['borderColor'])) { |
| 334 |
$css .= 'border-color: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['borderColor'] . ';'; |
| 335 |
} |
| 336 |
|
| 337 |
//borderWidth |
| 338 |
if ( ! empty( $block['attrs']['blockAdvanceOptions']['innerBlock']['borderWidth'] ) ) { |
| 339 |
$css .= 'border-style:solid;'; |
| 340 |
$css .= \gutenify\Style_Helpers::box_control( $block['attrs']['blockAdvanceOptions']['innerBlock']['borderWidth'], 'border-', '-width' ); |
| 341 |
} |
| 342 |
|
| 343 |
if ( ! empty( $block['attrs']['blockAdvanceOptions']['arrows']['borderRadius'] ) ) { |
| 344 |
$css .= \gutenify\Style_Helpers::border_radius_control( $block['attrs']['blockAdvanceOptions']['arrows']['borderRadius'] ); |
| 345 |
} |
| 346 |
|
| 347 |
if ( ! empty( $block['attrs']['blockAdvanceOptions']['arrows']['boxShadow'] ) ) { |
| 348 |
$css .= \gutenify\Style_Helpers::custom_box_shadow_control( $block['attrs']['blockAdvanceOptions']['arrows']['boxShadow'] ); |
| 349 |
} |
| 350 |
$css .= '}'; |
| 351 |
|
| 352 |
//thumbnail |
| 353 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['thumbnailMinHeight'])) { |
| 354 |
$css .= '.wp-block-gutenify-post-carousel .gutenify-post-carousel-item-inner-wrapper .gutenify-post-carousel-thumb img {'; |
| 355 |
$css .= 'min-height:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['thumbnailMinHeight'] . ';'; |
| 356 |
$css .= '}'; |
| 357 |
} |
| 358 |
|
| 359 |
//hover style |
| 360 |
$css .= $inner_block_selector . ':hover {'; |
| 361 |
|
| 362 |
//color |
| 363 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['hoverTextColor'])) { |
| 364 |
$css .= ' color: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['hoverTextColor'] . ';'; |
| 365 |
} |
| 366 |
|
| 367 |
//background |
| 368 |
if (!empty($block['attrs']['hoverBackgroundGradient'])) { |
| 369 |
$css .= 'background:' . $block['attrs']['hoverBackgroundGradient'] . ';'; |
| 370 |
} elseif (!empty($block['attrs']['hoverBackgroundColor'])) { |
| 371 |
$css .= 'background:' . $block['attrs']['hoverBackgroundColor'] . ';'; |
| 372 |
}elseif (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBackgroundGradient'])) { |
| 373 |
$css .= 'background: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBackgroundGradient'] . ';'; |
| 374 |
} elseif (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBackgroundColor'])) { |
| 375 |
$css .= 'background: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBackgroundColor'] . ';'; |
| 376 |
} |
| 377 |
|
| 378 |
//border color |
| 379 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBorderColor'])) { |
| 380 |
$css .= 'border-color: ' . $block['attrs']['blockAdvanceOptions']['innerBlock']['hoverBorderColor'] . ';'; |
| 381 |
} |
| 382 |
|
| 383 |
if ( ! empty( $block['attrs']['blockAdvanceOptions']['arrows']['hoverBoxShadow'] ) ) { |
| 384 |
$css .= \gutenify\Style_Helpers::custom_box_shadow_control( $block['attrs']['blockAdvanceOptions']['arrows']['hoverBoxShadow'] ); |
| 385 |
} |
| 386 |
|
| 387 |
$css .= '}'; |
| 388 |
|
| 389 |
//padding |
| 390 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding'])) { |
| 391 |
$css .= $inner_block_selector . ' .gutenify-post-carousel-text-content{'; |
| 392 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['desktop']['top'])) { |
| 393 |
$css .= 'padding-top:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['desktop']['top'] . 'px;'; |
| 394 |
} |
| 395 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['bottom'])) { |
| 396 |
$css .= 'padding-bottom:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['desktop']['bottom'] . 'px;'; |
| 397 |
} |
| 398 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['left'])) { |
| 399 |
$css .= 'padding-left:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['desktop']['left'] . 'px;'; |
| 400 |
} |
| 401 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['right'])) { |
| 402 |
$css .= 'padding-right:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['desktop']['right'] . 'px;'; |
| 403 |
} |
| 404 |
$css .= '}'; |
| 405 |
} |
| 406 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding'])) { |
| 407 |
$css .= '@media only screen and (max-width: 992px){' . $inner_block_selector . ' .gutenify-post-carousel-text-content{'; |
| 408 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['tablet']['top'])) { |
| 409 |
$css .= 'padding-top:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['tablet']['top'] . 'px;'; |
| 410 |
} |
| 411 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['tablet']['bottom'])) { |
| 412 |
$css .= 'padding-bottom:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['tablet']['bottom'] . 'px;'; |
| 413 |
} |
| 414 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['tablet']['left'])) { |
| 415 |
$css .= 'padding-left:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['tablet']['left'] . 'px;'; |
| 416 |
} |
| 417 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['tablet']['right'])) { |
| 418 |
$css .= 'padding-right:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['tablet']['right'] . 'px;'; |
| 419 |
} |
| 420 |
$css .= '}}'; |
| 421 |
} |
| 422 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding'])) { |
| 423 |
$css .= '@media only screen and (max-width: 768px){' . $inner_block_selector . ' .gutenify-post-carousel-text-content{'; |
| 424 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['mobile']['top'])) { |
| 425 |
$css .= 'padding-top:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['mobile']['top'] . 'px;'; |
| 426 |
} |
| 427 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['mobile']['bottom'])) { |
| 428 |
$css .= 'padding-bottom:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['mobile']['bottom'] . 'px;'; |
| 429 |
} |
| 430 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['mobile']['left'])) { |
| 431 |
$css .= 'padding-left:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['mobile']['left'] . 'px;'; |
| 432 |
} |
| 433 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['mobile']['right'])) { |
| 434 |
$css .= 'padding-right:' . $block['attrs']['blockAdvanceOptions']['innerBlock']['contentPadding']['mobile']['right'] . 'px;'; |
| 435 |
} |
| 436 |
$css .= '}}'; |
| 437 |
} |
| 438 |
|
| 439 |
if (!empty($block['attrs']['blockAdvanceOptions']['innerBlock']['postTitleSize'])) { |
| 440 |
$css .= $inner_block_selector . ' .gutenify-post-carousel-title { font-size: ' . esc_attr($block['attrs']['blockAdvanceOptions']['innerBlock']['postTitleSize']) . '; }'; |
| 441 |
} |
| 442 |
|
| 443 |
$handle = 'gutenify-block-inline-handle'; |
| 444 |
wp_add_inline_style('wp-block-library', $css); |
| 445 |
return $block_content->get_updated_html(); |
| 446 |
} |
| 447 |
|
| 448 |
// add_filter('render_block', 'gutenify_post_carousel_render_block', 200, 2); |
| 449 |
|