-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstaticweb-deploy.php
More file actions
executable file
·91 lines (77 loc) · 2.72 KB
/
staticweb-deploy.php
File metadata and controls
executable file
·91 lines (77 loc) · 2.72 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* Plugin Name: StaticWeb Deploy
* Plugin URI: https://github.com/staticweb-io/static-deploy
* Description: Generate static sites for deployment as files or S3-compatible storage.
* Version: 9.8.0
* Author: StaticWeb.io
* Author URI: https://staticweb.io
* Text Domain: staticweb-deploy
* Requires at least: 6.4
* Requires PHP: 8.2
* License URI: https://github.com/staticweb-io/static-deploy/blob/develop/LICENSE
* License: Unlicense
*/
if ( ! defined( 'ABSPATH' ) ) {
die;
}
// Only run code for admins and the CLI
// We don't directly change any behavior on the public site
if ( ! defined( 'WP_CLI' ) && ! is_admin() ) {
return;
}
define( 'STATIC_DEPLOY_VERSION', '9.8.0' );
define( 'STATIC_DEPLOY_PATH', plugin_dir_path( __FILE__ ) );
if ( ! defined( 'STATIC_DEPLOY_DEBUG' ) ) {
$static_deploy_enabled = WP_DEBUG || ( defined( 'WP_CLI' ) && WP_CLI::get_config( 'debug' ) );
define( 'STATIC_DEPLOY_DEBUG', $static_deploy_enabled );
}
if ( file_exists( STATIC_DEPLOY_PATH . 'vendor/autoload.php' ) ) {
require_once STATIC_DEPLOY_PATH . 'vendor/autoload.php';
}
if ( ! class_exists( \StaticDeploy\Controller::class )
&& file_exists( STATIC_DEPLOY_PATH . 'src/StaticDeployException.php' ) ) {
require_once STATIC_DEPLOY_PATH . 'src/StaticDeployException.php';
throw new StaticDeploy\StaticDeployException(
"Looks like you're trying to activate Static Deploy from source code" .
', without compiling it first.'
);
}
StaticDeploy\Controller::init();
/**
* Define Settings link for plugin
*
* @param string[] $links array of links
* @return string[] modified array of links
*/
function static_deploy_plugin_action_links( $links ) {
$settings_link =
'<a href="admin.php?page=static-deploy">' .
__( 'Settings', 'staticweb-deploy' ) .
'</a>';
array_unshift( $links, $settings_link );
return $links;
}
add_filter(
'plugin_action_links_' .
plugin_basename( __FILE__ ),
'static_deploy_plugin_action_links'
);
/**
* Prevent WP scripts from loading which aren't useful
* on a statically exported site
*/
function static_deploy_deregister_scripts(): void {
wp_dequeue_script( 'wp-embed' );
wp_deregister_script( 'wp-embed' );
wp_dequeue_script( 'comment-reply' );
wp_deregister_script( 'comment-reply' );
}
add_action( 'wp_footer', 'static_deploy_deregister_scripts' );
// TODO: move into own plugin for WP cleanup, don't belong in core
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
if ( defined( 'WP_CLI' ) ) {
StaticDeploy\CLI::init();
}