PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / trunk
bBlocks – Essential Gutenberg Blocks & Patterns Collection vtrunk
2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 106 releases
b-blocks / build / table-row / render.php

render.php in bBlocks – Essential Gutenberg Blocks & Patterns Collection trunk, at build/table-row/render.php

62 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 $id = wp_unique_id( 'bBlocksTableRow-' );
3
4 $normalBg = $attributes['styles']['normal']['bg'];
5 $hoverBg = $attributes['styles']['hover']['bg'];
6 if ( ! function_exists( 'b_blocks_table_cell_isValidCSS' ) ) {
7 function b_blocks_table_cell_isValidCSS($property, $value) {
8 if ( empty( $value ) && $value !== '0' && $value !== 0 ) {
9 return '';
10 }
11 return "$property: $value;";
12 }
13
14 function b_blocks_table_cell_getBackgroundCSS( $bg, $isSolid = true, $isGradient = true, $isImage = true ) {
15 if ( ! is_array( $bg ) ) {
16 $bg = array();
17 }
18 extract( $bg );
19 $type = $type ?? 'solid';
20 $color = $color ?? '';
21 $gradient = $gradient ?? 'linear-gradient(135deg, #0040E3, #18D4FD)';
22 $image = $image ?? [];
23 $position = $position ?? 'center center';
24 $attachment = $attachment ?? '';
25 $repeat = $repeat ?? '';
26 $size = $size ?? '';
27 $overlayColor = $overlayColor ?? '';
28
29 if ( 'gradient' === $type && $isGradient ) {
30 $styles = b_blocks_table_cell_isValidCSS('background', $gradient);
31 } elseif ( 'image' === $type && $isImage ) {
32 $imgUrl = $image['url'] ?? '';
33 $styles = "background: url($imgUrl);"
34 . b_blocks_table_cell_isValidCSS('background-color', $overlayColor)
35 . b_blocks_table_cell_isValidCSS('background-position', $position)
36 . b_blocks_table_cell_isValidCSS('background-size', $size)
37 . b_blocks_table_cell_isValidCSS('background-repeat', $repeat)
38 . b_blocks_table_cell_isValidCSS('background-attachment', $attachment)
39 . b_blocks_table_cell_isValidCSS('background-repeat', $repeat)
40 . "background-blend-mode: overlay;";
41 } else {
42 $styles = $isSolid ? b_blocks_table_cell_isValidCSS('background', $color) : '';
43 }
44
45 return $styles;
46 }
47 }
48 ?>
49
50 <style>
51 #<?php echo esc_attr( $id ); ?> {
52 <?php echo b_blocks_table_cell_getBackgroundCSS($normalBg); ?>
53 transition: background <?php echo esc_attr( $hoverBg['transition'] ); ?>s ease-in-out;
54 }
55 #<?php echo esc_attr( $id ); ?>:hover {
56 <?php echo b_blocks_table_cell_getBackgroundCSS($hoverBg); ?>
57 }
58 </style>
59
60 <tr <?php echo get_block_wrapper_attributes(); ?> id='<?php echo esc_attr( $id ); ?>' data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>'>
61 <?php echo $content; ?>
62 </tr>