-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.php
More file actions
68 lines (59 loc) · 1.86 KB
/
plugin.php
File metadata and controls
68 lines (59 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* Plugin Name: Findkit Blog Archive
* Description: Blog archive block powered by Findkit
* Requires at least: 6.2
* Requires PHP: 7.0
* Version: 0.1.0
* Author: Esa-Matti Suuronen <esamatti@findkit.com>
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: block-archive
*
* @package create-block
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Registers the block using the metadata loaded from the `block.json` file.
* Behind the scenes, it registers also all assets so they can be enqueued
* through the block editor in the corresponding context.
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
function findkit_blog_archive_init() {
register_block_type( __DIR__ . '/build' );
}
add_action( 'init', 'findkit_blog_archive_init' );
function findkit_get_excerpt($post_id) {
if (function_exists('the_seo_framework')) {
$desc = @the_seo_framework()->get_description($post_id);
if ($desc) {
return $desc;
}
}
return \get_the_excerpt($post_id);
}
add_filter('findkit_page_meta', function ($meta, $post) {
$meta['customFields']["excerpt"] = [
"type" => "keyword",
"value" => get_the_excerpt($post),
"value" => findkit_get_excerpt($post->ID),
];
$thumbnail = get_the_post_thumbnail_url($post, 'medium');
if ($thumbnail) {
$meta['customFields']["featuredImage"] = [
"type" => "keyword",
"value" => $thumbnail,
];
}
$author = get_the_author_meta('display_name', $post->post_author);
if ($author) {
$meta['customFields']["author"] = [
"type" => "keyword",
"value" => $author,
];
}
return $meta;
}, 10, 2);