forked from wp-digital/wp-prerender-aws-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-prerender-aws-lambda.php
More file actions
58 lines (50 loc) · 1.79 KB
/
wp-prerender-aws-lambda.php
File metadata and controls
58 lines (50 loc) · 1.79 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
<?php
/**
* Plugin Name: WP Prerender AWS Lambda
* Description: Generates HTML for WordPress pages/posts via AWS Lambda
* Version: 0.3.0
* Author: Innocode
* Author URI: https://innocode.com
* Requires at least: 5.4.2
* Tested up to: 5.8.1
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
define( 'WP_PRERENDER_VERSION', '0.0.3' );
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
}
if ( ! function_exists( 'innocode_wp_prerender_aws_lambda_init' ) ) {
function innocode_wp_prerender_aws_lambda_init() {
if (
! defined( 'AWS_LAMBDA_WP_PRERENDER_KEY' ) ||
! defined( 'AWS_LAMBDA_WP_PRERENDER_SECRET' ) ||
! defined( 'AWS_LAMBDA_WP_PRERENDER_REGION' ) ||
! class_exists( 'Innocode\Prerender\Plugin' )
) {
return;
}
$GLOBALS['wp_prerender_aws_lambda'] = new Innocode\Prerender\Plugin(
AWS_LAMBDA_WP_PRERENDER_KEY,
AWS_LAMBDA_WP_PRERENDER_SECRET,
AWS_LAMBDA_WP_PRERENDER_REGION,
defined( 'AWS_LAMBDA_WP_PRERENDER_FUNCTION' )
? AWS_LAMBDA_WP_PRERENDER_FUNCTION
: 'wordpress-prerender'
);
$GLOBALS['wp_prerender_aws_lambda']->run();
}
}
add_action( 'init', 'innocode_wp_prerender_aws_lambda_init' );
if ( ! function_exists( 'innocode_wp_prerender_aws_lambda' ) ) {
function innocode_wp_prerender_aws_lambda() : Innocode\Prerender\Plugin {
global $wp_prerender_aws_lambda;
if ( is_null( $wp_prerender_aws_lambda ) ) {
trigger_error(
'Missing required constants or prerender disabled',
E_USER_ERROR
);
}
return $wp_prerender_aws_lambda;
}
}