This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vendi-cache.php
96 lines (82 loc) · 3.03 KB
/
vendi-cache.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
<?php
/*
Plugin Name: Vendi Cache
Description: Disk-based page and post cache. (Formerly Wordfence Falcon Cache)
Plugin URI: https://www.vendiadvertising.com/
Author: Vendi Advertising (Chris Haas)
Version: 1.2.1
Author URI: https://www.vendiadvertising.com/
Text Domain: vendi-cache
Domain Path: /languages
Stable tag: 1.2.1
*/
if( defined( 'WP_INSTALLING' ) && WP_INSTALLING )
{
return;
}
//Shortcuts to the root of the plugin for various formats
define( 'VENDI_CACHE_FILE', __FILE__ );
define( 'VENDI_CACHE_URL', plugin_dir_url( __FILE__ ) );
//For launch we can't support MU however we're not going to remove the code for it.
define( 'VENDI_CACHE_SUPPORT_MU', false );
define( 'VENDI_CACHE_VERSION', '1.2.1' );
define( 'VENDI_CACHE_OPTION_KEY_FOR_ACTIVATION', 'vendiWordPressCachingActivated' );
define( 'VENDI_CACHE_OPTION_KEY_FOR_VERSION', 'vendi_cache_version' );
define( 'VENDI_CACHE_OPTION_KEY_ACTIVATION_ERROR', 'vendi_cache_plugin_act_error' );
define( 'VENDI_CACHE_ACTION_NAME_CACHE_CLEAR', 'vendi_cache_cache_clear');
define( 'VENDI_CACHE_PLUGIN_PAGE_SLUG', 'vendi-cache' );
//If you want to change the folder that items are cache to. Only lowercase letters and underscores are allowed.
//If an invalid pattern is detected it will be cleansed and possibly reverted back to vendi_cache.
if( ! defined( 'VENDI_CACHE_FOLDER_NAME' ) )
{
define( 'VENDI_CACHE_FOLDER_NAME', 'vendi_cache');
}
//If you want to (for some reason) white-label this
if( ! defined( 'VENDI_CACHE_PLUGIN_NAME' ) )
{
define( 'VENDI_CACHE_PLUGIN_NAME', 'Vendi Cache' );
}
//This code is original to WF and I'm pretty sure it allows a
//plugin to be hosted in a shared location on a server instead
//of installing it on every single site.
global $wp_plugin_paths;
foreach( $wp_plugin_paths as $dir => $realdir )
{
if( 0 === strpos( __FILE__, $realdir ) )
{
define( 'VENDI_CACHE_FCPATH', $dir . '/' . basename( __FILE__ ) );
define( 'VENDI_CACHE_PATH', trailingslashit( $dir ) );
break;
}
}
if( ! defined( 'VENDI_CACHE_FCPATH' ) )
{
define( 'VENDI_CACHE_FCPATH', __FILE__ );
define( 'VENDI_CACHE_PATH', trailingslashit( dirname( VENDI_CACHE_FCPATH ) ) );
}
//Composer autoload for logging
if( is_file( VENDI_CACHE_PATH . 'vendor/autoload.php' ) )
{
require_once VENDI_CACHE_PATH . 'vendor/autoload.php';
}
if( 1 != get_option( VENDI_CACHE_OPTION_KEY_FOR_ACTIVATION ) )
{
add_action(
'activated_plugin',
function()
{
cache_settings::get_instance()->update_option_for_instance( VENDI_CACHE_OPTION_KEY_ACTIVATION_ERROR, ob_get_contents() );
}
);
}
add_action(
'plugins_loaded',
function()
{
load_plugin_textdomain( 'vendi-cache', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
);
//Load both the legacy code as well as the new code
require_once VENDI_CACHE_PATH . '/autoload.php';
//Init
\Vendi\Cache\Legacy\wordfence::install_actions();