-
Notifications
You must be signed in to change notification settings - Fork 2
/
wp-prerender-aws-lambda.php
74 lines (59 loc) · 1.87 KB
/
wp-prerender-aws-lambda.php
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
69
70
71
72
73
74
<?php
/**
* Plugin Name: AWS Lambda Prerender
* Description: Generates HTML for client-side rendered content via AWS Lambda.
* Version: 1.6.0
* Author: Innocode
* Author URI: https://innocode.com
* Tested up to: 6.0.3
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
}
use Innocode\Prerender;
define( 'INNOCODE_PRERENDER_FILE', __FILE__ );
if (
! defined( 'AWS_LAMBDA_PRERENDER_KEY' ) ||
! defined( 'AWS_LAMBDA_PRERENDER_SECRET' ) ||
! defined( 'AWS_LAMBDA_PRERENDER_REGION' )
) {
return;
}
$GLOBALS['innocode_prerender'] = new Prerender\Plugin(
AWS_LAMBDA_PRERENDER_KEY,
AWS_LAMBDA_PRERENDER_SECRET,
AWS_LAMBDA_PRERENDER_REGION
);
if ( ! defined( 'AWS_LAMBDA_PRERENDER_FUNCTION' ) ) {
define( 'AWS_LAMBDA_PRERENDER_FUNCTION', 'prerender-production-render' );
}
$GLOBALS['innocode_prerender']
->get_lambda()
->set_function( AWS_LAMBDA_PRERENDER_FUNCTION );
if ( ! defined( 'AWS_LAMBDA_PRERENDER_DB_TABLE' ) ) {
define( 'AWS_LAMBDA_PRERENDER_DB_TABLE', 'innocode_prerender' );
}
$GLOBALS['innocode_prerender']
->get_db()
->set_table( AWS_LAMBDA_PRERENDER_DB_TABLE );
if ( ! defined( 'AWS_LAMBDA_PRERENDER_QUERY_ARG' ) ) {
define( 'AWS_LAMBDA_PRERENDER_QUERY_ARG', 'innocode_prerender' );
}
$GLOBALS['innocode_prerender']
->get_query()
->set_name( AWS_LAMBDA_PRERENDER_QUERY_ARG );
$GLOBALS['innocode_prerender']->run();
if ( ! function_exists( 'innocode_prerender' ) ) {
function innocode_prerender() : ?Prerender\Plugin {
global $innocode_prerender;
if ( is_null( $innocode_prerender ) ) {
trigger_error(
'Missing required constants',
E_USER_ERROR
);
}
return $innocode_prerender;
}
}