文件操作 - info-with-image.php
返回文件管理
返回主菜单
删除本文件
文件: /var/www/ltlcompare.com/wp-content/themes/ltl-compare/blocks/info-with-image.php
编辑文件内容
<?php use Carbon_Fields\Block; use Carbon_Fields\Field; function ltl_compare_crb_block_info_with_image() { Block::make( 'info-with-image', __( 'Info with image', DOMAIN ) ) ->add_fields( array( Field::make( 'block_preview', 'preview', __( 'Preview', DOMAIN ) ) ->set_html('<img src="'. TEMPLATE_URL .'/img/block-info-with-image.webp" alt="">'), Field::make( 'complex', 'sections', __( 'Sections', DOMAIN ) ) ->set_collapsed( true ) ->set_layout( 'tabbed-vertical' ) ->add_fields( array( Field::make( 'textarea', 'title', __( 'Title', DOMAIN ) ) ->set_rows( 2 ), Field::make( 'rich_text', 'content', __( 'Content', DOMAIN ) ), Field::make( 'text', 'btn_text', __( 'Button text', DOMAIN ) ), Field::make( 'text', 'btn_link', __( 'Button link', DOMAIN ) ), Field::make( 'checkbox', 'btn_is_blank', __( 'Open in new window', DOMAIN ) ), Field::make( 'image', 'img', __( 'Image', DOMAIN ) ), ) ) ->set_header_template( '<%= title %>' ), ) ) ->set_description( __( 'Info with image', DOMAIN ) ) ->set_keywords( array( __( 'Info with image', DOMAIN ), ) ) ->set_category( 'theme_blocks', __( 'Theme blocks', DOMAIN ) ) ->set_render_callback( function ( $fields, $attributes ) { if ( $fields['sections'] ) : ?> <div class="custom-block section custom-block-info-with-image<?php echo $attributes['className'] ?? null ? ' ' . $attributes['className'] : ''; ?>"> <?php foreach ( $fields['sections'] as $item ) : ?> <div class="info-with-image-section"> <div class="container"> <div class="info-with-image-body"> <?php if ( $item['title'] ) : ?> <h2 class="info-with-image-title"><?php echo $item['title']; ?></h2> <?php endif; ?> <?php if ( $item['content'] ) : ?> <div class="info-with-image-content"> <?php echo apply_filters( 'the_content', $item['content'] ); ?> </div> <?php endif; ?> <?php if ( $item['btn_text'] && $item['btn_link'] ) : ?> <a href="<?php echo $item['btn_link']; ?>" class="btn info-with-image-btn hidden-tablet"<?php echo $item['btn_is_blank'] ? ' target="_blank"' : ''; ?>><?php echo $item['btn_text']; ?></a> <?php endif; ?> </div> <?php if ( $item['img'] ) : ?> <div class="info-with-image-img"> <img src="<?php echo image_downsize( $item['img'], 'full' )[0]; ?>" alt="<?php echo get_post_meta( $item['img'], '_wp_attachment_image_alt', true ); ?>" > </div> <?php endif; ?> <?php if ( $item['btn_text'] && $item['btn_link'] ) : ?> <a href="<?php echo $item['btn_link']; ?>" class="btn info-with-image-btn visible-tablet"<?php echo $item['btn_is_blank'] ? ' target="_blank"' : ''; ?>><?php echo $item['btn_text']; ?></a> <?php endif; ?> </div> </div> <?php endforeach; ?> </div> <?php endif; }); } add_action( 'carbon_fields_register_fields', 'ltl_compare_crb_block_info_with_image' );
修改文件时间
将文件时间修改为当前时间的前一年
删除文件