PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 2.1.6
bBlocks – Essential Gutenberg Blocks & Patterns Collection v2.1.6
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-cell / render.php

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

76 lines 2.7 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( 'bBlocksTableCell-' );
3 $wrapper_attributes = get_block_wrapper_attributes();
4 $tagName = in_array( $attributes['tagName'] ?? 'td', [ 'td', 'th' ], true ) ? $attributes['tagName'] : 'td';
5 $colSpan= $attributes['settings']['colSpan'];
6 $rowSpan= $attributes['settings']['rowSpan'];
7 $styles = $attributes['styles'];
8 $alignment = $styles['alignment'];
9 $normal = $styles['normal'];
10 $hover = $styles['hover'];
11
12 if ( ! function_exists( 'b_blocks_table_cell_isValidCSS' ) ) {
13 function b_blocks_table_cell_isValidCSS($property, $value) {
14 if ( empty( $value ) && $value !== '0' && $value !== 0 ) {
15 return '';
16 }
17 return "$property: $value;";
18 }
19
20 function b_blocks_table_cell_getBackgroundCSS( $bg, $isSolid = true, $isGradient = true, $isImage = true ) {
21 if ( ! is_array( $bg ) ) {
22 $bg = array();
23 }
24 extract( $bg );
25 $type = $type ?? 'solid';
26 $color = $color ?? '';
27 $gradient = $gradient ?? 'linear-gradient(135deg, #0040E3, #18D4FD)';
28 $image = $image ?? [];
29 $position = $position ?? 'center center';
30 $attachment = $attachment ?? '';
31 $repeat = $repeat ?? '';
32 $size = $size ?? '';
33 $overlayColor = $overlayColor ?? '';
34
35 if ( 'gradient' === $type && $isGradient ) {
36 $styles = b_blocks_table_cell_isValidCSS('background', $gradient);
37 } elseif ( 'image' === $type && $isImage ) {
38 $imgUrl = $image['url'] ?? '';
39 $styles = "background: url($imgUrl);"
40 . b_blocks_table_cell_isValidCSS('background-color', $overlayColor)
41 . b_blocks_table_cell_isValidCSS('background-position', $position)
42 . b_blocks_table_cell_isValidCSS('background-size', $size)
43 . b_blocks_table_cell_isValidCSS('background-repeat', $repeat)
44 . b_blocks_table_cell_isValidCSS('background-attachment', $attachment)
45 . b_blocks_table_cell_isValidCSS('background-repeat', $repeat)
46 . "background-blend-mode: overlay;";
47 } else {
48 $styles = $isSolid ? b_blocks_table_cell_isValidCSS('background', $color) : '';
49 }
50
51 return $styles;
52 }
53 }
54 ?>
55 <style>
56 #<?php echo esc_attr( $id ); ?> {
57 <?php
58 echo "display:table-cell;";
59 echo $alignment? "text-align:" . $alignment['desktop'] . ";": "";
60 echo b_blocks_table_cell_getBackgroundCSS($normal['bg']);
61 echo $hover['transition']? "transition: background " . $hover['transition'] . "s ease-in-out;": "";
62 ?>
63 }
64 #<?php echo esc_attr( $id ); ?>:hover {
65 <?php
66 echo b_blocks_table_cell_getBackgroundCSS($hover['bg']);
67 ?>
68 }
69
70 </style>
71
72 <<?php echo $tagName; ?> <?php echo wp_kses_post(get_block_wrapper_attributes()); ?> id='<?php echo esc_attr( $id ); ?>' colspan='<?php echo esc_attr( $colSpan ); ?>' rowspan='<?php echo esc_attr( $rowSpan ); ?>'>
73 <?php echo $content; ?>
74 </<?php echo $tagName; ?>>
75
76