commenting now unecessayr thumbnail updater
This commit is contained in:
parent
c7f240c292
commit
048735ab72
|
|
@ -1,20 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function update_post_thumbnail_from_block($post_id)
|
// function update_post_thumbnail_from_block($post_id)
|
||||||
{
|
// {
|
||||||
if (!current_user_can('edit_post', $post_id)) {
|
// if (!current_user_can('edit_post', $post_id)) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
$post_content = get_post_field('post_content', $post_id);
|
// $post_content = get_post_field('post_content', $post_id);
|
||||||
|
|
||||||
$first_block = parse_blocks($post_content)[0];
|
// $first_block = parse_blocks($post_content)[0];
|
||||||
|
|
||||||
if ($first_block['blockName'] === 'lhoist-blocks/search-and-find' && !empty($first_block['attrs']['coverId'])) {
|
// if ($first_block['blockName'] === 'lhoist-blocks/search-and-find' && !empty($first_block['attrs']['coverId'])) {
|
||||||
$cover_id = $first_block['attrs']['coverId'];
|
// $cover_id = $first_block['attrs']['coverId'];
|
||||||
set_post_thumbnail($post_id, $cover_id);
|
// set_post_thumbnail($post_id, $cover_id);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
add_action('save_post', 'update_post_thumbnail_from_block');
|
// add_action('save_post', 'update_post_thumbnail_from_block');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user