21 lines
565 B
PHP
21 lines
565 B
PHP
<?php
|
|
|
|
// function update_post_thumbnail_from_block($post_id)
|
|
// {
|
|
// if (!current_user_can('edit_post', $post_id)) {
|
|
// return;
|
|
// }
|
|
|
|
|
|
// $post_content = get_post_field('post_content', $post_id);
|
|
|
|
// $first_block = parse_blocks($post_content)[0];
|
|
|
|
// if ($first_block['blockName'] === 'lhoist-blocks/search-and-find' && !empty($first_block['attrs']['coverId'])) {
|
|
// $cover_id = $first_block['attrs']['coverId'];
|
|
// set_post_thumbnail($post_id, $cover_id);
|
|
// }
|
|
// }
|
|
|
|
// add_action('save_post', 'update_post_thumbnail_from_block');
|