Skip to content

Commit fd2af4f

Browse files
committed
add version collision detection for TypeRocket core
1 parent c009fd7 commit fd2af4f

File tree

1 file changed

+36
-32
lines changed

1 file changed

+36
-32
lines changed

typerocket-v5.php

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,51 @@ final class TypeRocketPlugin
2121

2222
public function __construct()
2323
{
24-
add_action('plugins_loaded', function() {
25-
if(defined('TYPEROCKET_PLUGIN_INSTALL') || defined('TYPEROCKET_PATH')) {
26-
add_filter('plugin_action_links',function ($actions, $plugin_file) {
27-
if( $found = strpos(__FILE__, $plugin_file) ) {
28-
$actions['settings'] = '<span style="color: red">Inactive Install</span>';
29-
}
24+
add_action('plugins_loaded', [$this, 'plugins_loaded'], 15);
25+
register_activation_hook( __FILE__, [$this, 'activation']);
26+
}
3027

31-
return $actions;
32-
}, 10, 2 );
28+
public function plugins_loaded()
29+
{
30+
if(defined('TYPEROCKET_PLUGIN_INSTALL') || defined('TYPEROCKET_PATH')) {
31+
add_filter('plugin_action_links', function($actions, $plugin_file) {
32+
if( strpos(__FILE__, $plugin_file) ) {
33+
$actions['settings'] = '<span style="color: red">Inactive Install</span>';
34+
}
3335

34-
return;
35-
}
36+
return $actions;
37+
}, 10, 2 );
3638

37-
define('TYPEROCKET_PLUGIN_VERSION', '5.1.16');
38-
define('TYPEROCKET_PLUGIN_INSTALL', __DIR__);
39+
return;
40+
}
3941

40-
if(!defined('TYPEROCKET_ROOT_WP'))
41-
define('TYPEROCKET_ROOT_WP', ABSPATH);
42+
define('TYPEROCKET_PLUGIN_VERSION', '5.1.16');
43+
define('TYPEROCKET_PLUGIN_INSTALL', __DIR__);
44+
define('TYPEROCKET_PLUGIN_PRO', false);
4245

43-
$this->loadConfig();
44-
require 'typerocket/init.php';
46+
if(!defined('TYPEROCKET_ROOT_WP')) {
47+
define('TYPEROCKET_ROOT_WP', ABSPATH);
48+
}
4549

46-
if(typerocket_env('TYPEROCKET_UPDATES', true)) {
47-
add_filter('http_request_host_is_external', function($value, $host) {
48-
return $value || $host == 'typerocket.com';
49-
}, 10, 2);
50+
$this->loadConfig();
51+
require 'typerocket/init.php';
5052

51-
new \TypeRocketPlugin\Updater([
52-
'slug' => 'typerocket-v5',
53-
'api_url' => 'https://typerocket.com/plugins/typerocket-v5/'
54-
]);
55-
}
53+
if(typerocket_env('TYPEROCKET_UPDATES', true)) {
54+
add_filter('http_request_host_is_external', function($value, $host) {
55+
return $value || $host == 'typerocket.com';
56+
}, 10, 2);
5657

57-
$this->path = plugin_dir_path(__FILE__);
58-
define('TYPEROCKET_AUTO_LOADER', '__return_false');
59-
add_action('admin_notices', [$this, 'activation_notice']);
60-
add_action('typerocket_loaded', [$this, 'typerocket_loaded']);
61-
add_filter('plugin_action_links', [$this, 'links'], 10, 2 );
62-
}, 15);
58+
new \TypeRocketPlugin\Updater([
59+
'slug' => 'typerocket-v5',
60+
'api_url' => 'https://typerocket.com/plugins/typerocket-v5/'
61+
]);
62+
}
6363

64-
register_activation_hook( __FILE__, [$this, 'activation']);
64+
$this->path = plugin_dir_path(__FILE__);
65+
define('TYPEROCKET_AUTO_LOADER', '__return_false');
66+
add_action('admin_notices', [$this, 'activation_notice']);
67+
add_action('typerocket_loaded', [$this, 'typerocket_loaded']);
68+
add_filter('plugin_action_links', [$this, 'links'], 10, 2 );
6569
}
6670

6771
public function links($actions, $plugin_file)

0 commit comments

Comments
 (0)