| 1 |
<?php |
| 2 |
// Exit if accessed directly. |
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Plugin Name: Simply Static |
| 9 |
* Plugin URI: https://simplystatic.com |
| 10 |
* Description: A static site generator to create fast and secure static versions of your WordPress website. |
| 11 |
* Version: 3.8.12 |
| 12 |
* Requires at least: 6.2 |
| 13 |
* Author: Patrick Posner |
| 14 |
* Author URI: https://patrickposner.com |
| 15 |
* License: GPL-2.0+ |
| 16 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 17 |
* Text Domain: simply-static |
| 18 |
* Domain Path: /languages |
| 19 |
*/ |
| 20 |
|
| 21 |
define( 'SIMPLY_STATIC_PATH', plugin_dir_path( __FILE__ ) ); |
| 22 |
define( 'SIMPLY_STATIC_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) ); |
| 23 |
define( 'SIMPLY_STATIC_VERSION', '3.8.12' ); |
| 24 |
|
| 25 |
// Check PHP version. |
| 26 |
if ( version_compare( PHP_VERSION, '7.4', '<' ) ) { |
| 27 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 28 |
wp_die( esc_html__( 'Simply Static requires PHP 7.4 or higher.', 'simply-static' ), 'Plugin dependency check', array( 'back_link' => true ) ); |
| 29 |
} |
| 30 |
|
| 31 |
// Check WordPress version. |
| 32 |
if ( version_compare( get_bloginfo( 'version' ), '6.2', '<' ) ) { |
| 33 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 34 |
wp_die( esc_html__( 'Simply Static requires WordPress 6.2 or higher.', 'simply-static' ), 'Plugin dependency check', array( 'back_link' => true ) ); |
| 35 |
} |
| 36 |
|
| 37 |
// Run autoloader. |
| 38 |
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) && ! class_exists( 'Simply_Static\Plugin' ) ) { |
| 39 |
require __DIR__ . '/vendor/autoload.php'; |
| 40 |
} |
| 41 |
|
| 42 |
// Block incompatible Pro integrations before either plugin boots. |
| 43 |
require_once SIMPLY_STATIC_PATH . 'src/class-ss-pro-compatibility.php'; |
| 44 |
add_action( 'plugins_loaded', array( 'Simply_Static\Pro_Compatibility', 'enforce' ), 1 ); |
| 45 |
|
| 46 |
// Boot Simply Static. |
| 47 |
if ( ! function_exists( 'simply_static_run_plugin' ) ) { |
| 48 |
add_action( 'plugins_loaded', 'simply_static_run_plugin' ); |
| 49 |
|
| 50 |
/** |
| 51 |
* Run plugin |
| 52 |
* |
| 53 |
* @return void |
| 54 |
*/ |
| 55 |
function simply_static_run_plugin() { |
| 56 |
require_once SIMPLY_STATIC_PATH . 'src/class-ss-plugin.php'; |
| 57 |
|
| 58 |
Simply_Static\Plugin::instance(); |
| 59 |
|
| 60 |
$options = get_option( 'simply-static' ); |
| 61 |
|
| 62 |
if ( ! is_array( $options ) ) { |
| 63 |
$options = []; |
| 64 |
} |
| 65 |
|
| 66 |
// Server-side cron? |
| 67 |
if ( isset( $options['server_cron'] ) && true === $options['server_cron'] ) { |
| 68 |
define( 'SS_CRON', true ); |
| 69 |
} |
| 70 |
|
| 71 |
// Generate a secure unique key. |
| 72 |
if ( ! isset( $options['encryption_key'] ) ) { |
| 73 |
$options['encryption_key'] = bin2hex( random_bytes( 16 ) ); |
| 74 |
update_option( 'simply-static', $options ); |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
register_deactivation_hook( __FILE__, 'simply_static_plugin_deactivate' ); |
| 80 |
|
| 81 |
/** |
| 82 |
* Stop scheduled work on deactivation without deleting user data. |
| 83 |
* |
| 84 |
* WordPress deactivation is reversible. Generated files, logs, and page |
| 85 |
* records are removed only by the explicit uninstall flow. |
| 86 |
*/ |
| 87 |
function simply_static_plugin_deactivate() { |
| 88 |
wp_clear_scheduled_hook( 'simply_static_site_export_cron' ); |
| 89 |
wp_clear_scheduled_hook( 'wp_archive_creation_job_cron' ); |
| 90 |
do_action( 'simply_static_deactivated' ); |
| 91 |
} |
| 92 |
|