This repository has been archived by the owner on Jan 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wp-pwa.php
98 lines (81 loc) · 2.65 KB
/
wp-pwa.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/*
Plugin Name: WordPress PWA
Plugin URI: https://wordpress.org/plugins/wp-pwa/
Description: WordPress plugin to turn WordPress blogs into Progressive Web Apps.
Version: 1.14.3
Author: WordPress PWA
License: GPL v3
Copyright: Worona Labs SL
*/
// Define the directory seperator if it hasn't already.
if (!defined('DS')) {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
define('DS', '\\');
} else {
define('DS', '/');
}
}
// Define Frontity constants.
define('FRONTITY_VERSION', '1.14.3');
define('FRONTITY_PATH', plugin_dir_path(__FILE__));
define('FRONTITY_URL', plugin_dir_url(__FILE__));
if (!class_exists('Frontity_Compatibility')) {
require_once FRONTITY_PATH . 'includes/class-frontity-compatibility.php';
}
// Initializes Frontity.
function frontity()
{
$frontity_compatibility = new Frontity_Compatibility();
if ($frontity_compatibility->should_stop()) return;
// This global should be removed in favor of the constant FRONTITY_PATH.
$GLOBALS['wp_pwa_path'] = '/' . basename(plugin_dir_path(__FILE__));
// Require Frontity main class.
if (!class_exists('Frontity')) {
require_once FRONTITY_PATH . 'includes/class-frontity.php';
}
if (!isset($frontity)) $frontity = new Frontity();
$frontity->run();
}
function frontity_activation()
{
$frontity_compatibility = new Frontity_Compatibility();
if ($frontity_compatibility->should_stop()) return;
if (!class_exists('Frontity_Settings')) {
require_once FRONTITY_PATH . 'includes/class-frontity-settings.php';
}
$frontity_settings = new Frontity_Settings();
$frontity_settings->keep_settings_updated();
$upload = wp_upload_dir();
$upload_base = $upload['basedir'];
$frontity_dir = $upload_base . DS . 'frontity';
if (!is_dir($frontity_dir)) {
mkdir($frontity_dir, 0755);
if (is_dir($frontity_dir)) {
file_put_contents($frontity_dir . DS . 'index.php', "<?php\r\n// Silence is golden\r\n?>");
$htmlpurifier_dir = $frontity_dir . DS . 'htmlpurifier';
mkdir($htmlpurifier_dir, 0755);
if (is_dir($htmlpurifier_dir)) {
file_put_contents($htmlpurifier_dir . DS . 'index.php', "<?php\r\n// Silence is golden\r\n?>");
}
}
}
flush_rewrite_rules();
}
function frontity_deactivation()
{
delete_transient('frontity_version');
}
function frontity_uninstallation()
{
$transient_keys = get_option('image_id_transient_keys');
foreach ($transient_keys as $transient_key) {
delete_transient($transient_key);
}
delete_option('image_id_transient_keys');
delete_option('frontity_settings');
}
register_activation_hook(__FILE__, 'frontity_activation');
register_deactivation_hook(__FILE__, 'frontity_deactivation');
register_uninstall_hook(__FILE__, 'frontity_uninstallation');
frontity();