Woodmart主题中的html block兼容Stackable插件

这篇文章是让Woodmart主题中的html block兼容Stackable插件,Woodmart主题中的html block默认是不支持古腾堡的,更别提古腾堡插件Stackable。

将下面的代码放到主题functions.php里

让html block支持古腾堡:

// 让html block支持古腾堡
add_filter('register_post_type_args', function($args, $post_type) {
$supported_post_types = array("cms_block");
if (in_array($post_type, $supported_post_types)) {
$args['show_in_rest'] = true;
}
return $args;
}, 10, 2);
// 让html block支持古腾堡
add_filter('register_post_type_args', function($args, $post_type) {
    $supported_post_types = array("cms_block");
    if (in_array($post_type, $supported_post_types)) {
        $args['show_in_rest'] = true;
    }
    return $args;
}, 10, 2);
// 让html block支持古腾堡 add_filter('register_post_type_args', function($args, $post_type) { $supported_post_types = array("cms_block"); if (in_array($post_type, $supported_post_types)) { $args['show_in_rest'] = true; } return $args; }, 10, 2);

让html block兼容Stackable插件:

// html block加载stackable样式
add_filter("wpml_object_id",function($id,$cms_block){
$post = get_post( $id );
if ( ! $post || $post->post_type != 'cms_block' || ! $id || $cms_block != 'cms_block') {
return;
}
// 兼容Stackable
Stackable_Init::register_frontend_assets();
wp_enqueue_style( 'ugb-style-css' );
wp_enqueue_style( 'ugb-style-css-nodep' );
wp_enqueue_script( 'ugb-block-frontend-js' );
do_action( 'stackable_block_enqueue_frontend_assets' );
return $id;
},8,2);
// html block加载stackable样式
add_filter("wpml_object_id",function($id,$cms_block){
  $post = get_post( $id );
  if ( ! $post || $post->post_type != 'cms_block' || ! $id || $cms_block != 'cms_block') {
    return;
  }
  // 兼容Stackable
  Stackable_Init::register_frontend_assets();
  wp_enqueue_style( 'ugb-style-css' );
  wp_enqueue_style( 'ugb-style-css-nodep' );
  wp_enqueue_script( 'ugb-block-frontend-js' );
  do_action( 'stackable_block_enqueue_frontend_assets' );
  return $id;
},8,2);
// html block加载stackable样式 add_filter("wpml_object_id",function($id,$cms_block){ $post = get_post( $id ); if ( ! $post || $post->post_type != 'cms_block' || ! $id || $cms_block != 'cms_block') { return; } // 兼容Stackable Stackable_Init::register_frontend_assets(); wp_enqueue_style( 'ugb-style-css' ); wp_enqueue_style( 'ugb-style-css-nodep' ); wp_enqueue_script( 'ugb-block-frontend-js' ); do_action( 'stackable_block_enqueue_frontend_assets' ); return $id; },8,2);
© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
The God only arranges a happy ending. If it is not happy, it means that it is not the final result.
上天只会安排的快乐的结局。如果不快乐,说明还不是最后结局
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片快捷回复

    暂无评论内容