-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfreespoke-search.php
More file actions
59 lines (54 loc) · 2.06 KB
/
freespoke-search.php
File metadata and controls
59 lines (54 loc) · 2.06 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
<?php
/**
* Plugin Name: Freespoke Search
* Plugin URI: https://freespoke.com/widgets
* Description: Embed the Freespoke Search Widget and automatically publish your content to Freespoke's search index
* Version: 1.2.0
* Author: Freespoke
* Author URI: https://freespoke.com
* License: MIT
* Requires PHP: 8.1
* Text Domain: freespoke-widget
*
* Widget Usage: [freespoke_search client_id="YOUR_CLIENT_ID" theme="light" placeholder="Search..."]
* Publisher: Configure credentials in Tools → Freespoke Publisher to enable auto-publishing
*/
if (!defined('ABSPATH')) {
exit;
}
if (version_compare(PHP_VERSION, '8.1', '<')) {
add_action('admin_notices', static function () {
echo '<div class="notice notice-error"><p>';
echo esc_html(sprintf('Freespoke Search requires PHP 8.1 or later. You are running PHP %s.', PHP_VERSION));
echo '</p></div>';
});
return;
}
require_once __DIR__ . '/vendor/autoload.php';
// Read optional wp-config.php constants into overrides.
// Using constant() with string names avoids IDE errors for conditionally-defined constants.
$overrides = [];
foreach ([
'client_id' => 'FREESPOKE_CLIENT_ID',
'client_secret' => 'FREESPOKE_CLIENT_SECRET',
'token_url' => 'FREESPOKE_TOKEN_URL',
'api_key' => 'FREESPOKE_PUBLISHER_API_KEY',
'publisher_url' => 'FREESPOKE_PUBLISHER_URL',
'notice_emails' => 'FREESPOKE_NOTICE_EMAILS',
'post_types' => 'FREESPOKE_POST_TYPES',
'include_pages' => 'FREESPOKE_INCLUDE_PAGES',
'content_meta_fields' => 'FREESPOKE_CONTENT_META_FIELDS',
] as $key => $constName) {
if (defined($constName)) {
$overrides[$key] = constant($constName);
}
}
Freespoke\Wordpress\Plugin::init([
'plugin_file' => __FILE__,
'plugin_dir' => plugin_dir_path(__FILE__),
'plugin_url' => plugin_dir_url(__FILE__),
'base_url' => 'https://freespoke.com',
'js_bundle' => '/widgets/freespoke-search/static/widget-bundle.v1.js',
'css_bundle' => '',
'overrides' => $overrides,
]);