Yêu cầu của công việc là kế thừa lại một Flex Block của tagDiv Composer. Tùy chỉnh lại query bài viết theo nhu cầu riêng.

Kế thừa tagDiv Flex Block
<?php
defined( 'ABSPATH' ) || exit;
add_action( 'tdc_init', function () {
new td_api_featured_plugin();
}, 11 );
add_filter( 'td_data_source_blocks_query_args', function ( $args, $atts ) {
if ( is_array( $atts ) && isset( $atts['block_type'] ) && 'td_flex_block_featured' == $atts['block_type'] ) {
$args['block_featured'] = 1;
}
return $args;
}, 10, 2 );
class td_api_featured_plugin {
var $plugin_url = '';
var $plugin_path = '';
function __construct() {
$this->plugin_url = Font_Project()->get_base_url() . '/custom/td-block'; // path used for elements like images, css, etc which are available on end user
$this->plugin_path = Font_Project()->get_base_dir() . '/custom/td-block'; // used for internal (server side) files
// frontend css
add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_style( 'td-block-featured-style', $this->plugin_url . '/css/style.css' );
} );
//hook used to add or modify items via Api
add_action( 'tdc_loaded', function () { //add the api code inside this function
$defaults = td_api_module::get_by_id( 'td_module_flex_1' );
// Add a new module
td_api_module::add( 'td_module_flex_featured',
wp_parse_args( array(
'file' => $this->plugin_path . '/modules/td_module_flex_custom.php',
'text' => __( 'Module Flex Featured', Font_Project_Constants::TEXT_DOMAIN ),
'used_on_blocks' => array( 'td_module_flex_featured' ),
), $defaults )
);
$defaults = td_api_block::get_by_id( 'td_flex_block_1' );
// Add a new block
td_api_block::add( 'td_flex_block_featured',
wp_parse_args( array(
'file' => $this->plugin_path . '/shortcodes/td_flex_block_custom.php',
"name" => __( 'Flex Block Featured', Font_Project_Constants::TEXT_DOMAIN ),
"base" => 'td_flex_block_featured',
"class" => 'td_flex_block_featured'
), $defaults )
);
} );
}
}