updating post cover with game background
This commit is contained in:
parent
cc73ee13dd
commit
9e38f1d13a
|
|
@ -8,7 +8,7 @@ require_once(__DIR__ . '/includes/admin.php');
|
|||
require_once(__DIR__ . '/includes/logos.php');
|
||||
require_once(__DIR__ . '/includes/api.php');
|
||||
require_once(__DIR__ . '/includes/statistics-page.php');
|
||||
// require_once(__DIR__ . '/includes/redirections.php');
|
||||
require_once(__DIR__ . '/includes/search-find.php');
|
||||
|
||||
// require_once(__DIR__ . '/includes/widget.php');
|
||||
// require_once( __DIR__ . '/includes/taxonomy.php');
|
||||
|
|
|
|||
20
includes/search-find.php
Normal file
20
includes/search-find.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?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');
|
||||
Loading…
Reference in New Issue
Block a user