文件操作 - info-with-table.php
返回文件管理
返回主菜单
删除本文件
文件: /var/www/ltlcompare.com/wp-content/themes/ltl-compare/blocks/info-with-table.php
编辑文件内容
<?php use Carbon_Fields\Block; use Carbon_Fields\Field; function ltl_compare_crb_block_info_with_table() { Block::make( 'info-with-table', __( 'Info with table', DOMAIN ) ) ->add_fields( array( Field::make( 'block_preview', 'preview', __( 'Preview', DOMAIN ) ) ->set_html('<img src="'. TEMPLATE_URL .'/img/block-info-with-table.webp" alt="">'), Field::make( 'textarea', 'title', __( 'Title', DOMAIN ) ) ->set_rows( 2 ), Field::make( 'rich_text', 'content', __( 'Content', DOMAIN ) ), Field::make( 'complex', 'table', __( 'Table' ) ) ->set_collapsed( true ) ->set_layout( 'tabbed-vertical' ) ->add_fields( array( Field::make( 'text', 'th', __( 'th', DOMAIN ) ) ->set_default_value( '-' ), Field::make( 'complex', 'tds', __( 'Row' ) ) ->set_collapsed( true ) ->set_layout( 'tabbed-horizontal' ) ->add_fields( array( Field::make( 'text', 'td', __( 'td', DOMAIN ) ), ) ) ->set_header_template( '<%= td %>' ) ->setup_labels( array( 'plural_name' => 'td', 'singular_name' => 'td' ) ), ) ) ->set_header_template( '<%= th %>' ) ->setup_labels( array( 'plural_name' => 'tr', 'singular_name' => 'tr' ) ), ) ) ->set_description( __( 'Info with table', DOMAIN ) ) ->set_keywords( array( __( 'Info with table', DOMAIN ), ) ) ->set_category( 'theme_blocks', __( 'Theme blocks', DOMAIN ) ) ->set_render_callback( function ( $fields, $attributes ) { if ( $fields['title'] || $fields['content'] || $fields['table'] ) : ?> <div class="custom-block section custom-block-info-with-table<?php echo $attributes['className'] ?? null ? ' ' . $attributes['className'] : ''; ?>"> <div class="container"> <?php if ( $fields['title'] ) : ?> <h2 class="section-title"><?php echo $fields['title']; ?></h2> <?php endif; ?> <?php if ( $fields['content'] || $fields['table'] ) : ?> <div class="info-with-table-main"> <?php if ( $fields['content'] ) : ?> <div class="info-with-table-content content-text"> <?php echo apply_filters( 'the_content', $fields['content'] ); ?> </div> <?php endif; ?> <?php if ( $fields['table'] ) : $thead = array_shift( $fields['table'] ) ?? array(); $ths = $thead['tds'] ?? array(); $is_thead = false; foreach( $ths as $item ){ if( $item['td'] ?? null ) { $is_thead = true; } } ?> <div class="info-with-table-body"> <div class="table-wrapp"> <table> <?php if ( $is_thead ) : ?> <thead> <tr> <th><?php echo $thead['th'] === '-' ? '' : $thead['th']; ?></th> <?php foreach ( $thead['tds'] as $item ) : ?> <td><?php echo $item['td']; ?></td> <?php endforeach; ?> </tr> </thead> <?php endif; ?> <?php if ( $fields['table'] ) : ?> <tbody> <?php foreach ( $fields['table'] as $tr ) : ?> <tr> <th><?php echo $tr['th'] === '-' ? '' : $tr['th']; ?></th> <?php foreach ( $tr['tds'] as $item ) : ?> <td><?php echo $item['td']; ?></td> <?php endforeach; ?> </tr> <?php endforeach; ?> </tbody> <?php endif; ?> </table> </div> </div> <?php endif; ?> </div> <?php endif; ?> </div> </div> <?php endif; }); } add_action( 'carbon_fields_register_fields', 'ltl_compare_crb_block_info_with_table' );
修改文件时间
将文件时间修改为当前时间的前一年
删除文件