Skip to content

Commit 91aab31

Browse files
committed
add version collision detection for TypeRocket core
1 parent 33638a8 commit 91aab31

8 files changed

Lines changed: 50 additions & 47 deletions

File tree

typerocket-v6.php

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
defined( 'ABSPATH' ) or die( 'Nothing here to see!' );
1616

17-
final class OpenPlugin
17+
final class OpenPlugin6
1818
{
1919
protected $path = null;
2020
protected $message = '';
@@ -23,47 +23,50 @@ final class OpenPlugin
2323

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

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

36-
return;
37-
}
38+
return $actions;
39+
}, 10, 2 );
3840

39-
define('TYPEROCKET_PLUGIN_VERSION', '6.0.0');
40-
define('TYPEROCKET_PLUGIN_INSTALL', __DIR__);
41+
return;
42+
}
4143

42-
if(!defined('TYPEROCKET_ROOT_WP'))
43-
define('TYPEROCKET_ROOT_WP', ABSPATH);
44+
define('TYPEROCKET_PLUGIN_VERSION', '6.0.0');
45+
define('TYPEROCKET_PLUGIN_INSTALL', __DIR__);
46+
define('TYPEROCKET_PLUGIN_PRO', false);
4447

45-
$this->loadConfig();
46-
require 'typerocket/init.php';
48+
if(!defined('TYPEROCKET_ROOT_WP'))
49+
define('TYPEROCKET_ROOT_WP', ABSPATH);
4750

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

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

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

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

6972
public function links($actions, $plugin_file)
@@ -132,7 +135,7 @@ public function activation_notice()
132135

133136
public function typerocket_loaded()
134137
{
135-
tr_page('settings@TypeRocket\\OpenPlugin\\SettingsController', 'typerocket', __('TypeRocket Settings'), [
138+
tr_page('settings@TypeRocket\\OpenPlugin6\\SettingsController', 'typerocket', __('TypeRocket Settings'), [
136139
'menu' => __('TypeRocket'),
137140
'capability' => 'activate_plugins'
138141
]);
@@ -143,4 +146,4 @@ public function typerocket_loaded()
143146
}
144147
}
145148

146-
new OpenPlugin();
149+
new OpenPlugin6();

typerocket/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"helpers.php"
3333
],
3434
"psr-4": {
35-
"TypeRocket\\OpenPlugin\\": "plugin/"
35+
"TypeRocket\\OpenPlugin6\\": "plugin/"
3636
}
3737
},
3838
"scripts": {

typerocket/plugin/SettingsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace TypeRocket\OpenPlugin;
2+
namespace TypeRocket\OpenPlugin6;
33

44
use TypeRocket\Controllers\Controller;
55
use TypeRocket\Template\TemplateEngine;

typerocket/plugin/Updater.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace TypeRocket\OpenPlugin;
2+
namespace TypeRocket\OpenPlugin6;
33

44
final class Updater
55
{

typerocket/vendor/composer/autoload_classmap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,8 +1224,8 @@
12241224
'TypeRocket\\Models\\WPTerm' => $vendorDir . '/typerocket/core/src/Models/WPTerm.php',
12251225
'TypeRocket\\Models\\WPTermTaxonomy' => $vendorDir . '/typerocket/core/src/Models/WPTermTaxonomy.php',
12261226
'TypeRocket\\Models\\WPUser' => $vendorDir . '/typerocket/core/src/Models/WPUser.php',
1227-
'TypeRocket\\OpenPlugin\\SettingsController' => $baseDir . '/plugin/SettingsController.php',
1228-
'TypeRocket\\OpenPlugin\\Updater' => $baseDir . '/plugin/Updater.php',
1227+
'TypeRocket\\OpenPlugin6\\SettingsController' => $baseDir . '/plugin/SettingsController.php',
1228+
'TypeRocket\\OpenPlugin6\\Updater' => $baseDir . '/plugin/Updater.php',
12291229
'TypeRocket\\Register\\MetaBox' => $vendorDir . '/typerocket/core/src/Register/MetaBox.php',
12301230
'TypeRocket\\Register\\Page' => $vendorDir . '/typerocket/core/src/Register/Page.php',
12311231
'TypeRocket\\Register\\PostType' => $vendorDir . '/typerocket/core/src/Register/PostType.php',

typerocket/vendor/composer/autoload_psr4.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$baseDir = dirname($vendorDir);
77

88
return array(
9-
'TypeRocket\\OpenPlugin\\' => array($baseDir . '/plugin'),
9+
'TypeRocket\\OpenPlugin6\\' => array($baseDir . '/plugin'),
1010
'TypeRocket\\' => array($vendorDir . '/typerocket/core/src'),
1111
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
1212
'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'),

typerocket/vendor/composer/autoload_static.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ComposerStaticInit1ea299e54fdefaef41f855b3138bc6c1
2020
public static $prefixLengthsPsr4 = array (
2121
'T' =>
2222
array (
23-
'TypeRocket\\OpenPlugin\\' => 22,
23+
'TypeRocket\\OpenPlugin6\\' => 23,
2424
'TypeRocket\\' => 11,
2525
),
2626
'S' =>
@@ -46,7 +46,7 @@ class ComposerStaticInit1ea299e54fdefaef41f855b3138bc6c1
4646
);
4747

4848
public static $prefixDirsPsr4 = array (
49-
'TypeRocket\\OpenPlugin\\' =>
49+
'TypeRocket\\OpenPlugin6\\' =>
5050
array (
5151
0 => __DIR__ . '/../..' . '/plugin',
5252
),
@@ -1319,8 +1319,8 @@ class ComposerStaticInit1ea299e54fdefaef41f855b3138bc6c1
13191319
'TypeRocket\\Models\\WPTerm' => __DIR__ . '/..' . '/typerocket/core/src/Models/WPTerm.php',
13201320
'TypeRocket\\Models\\WPTermTaxonomy' => __DIR__ . '/..' . '/typerocket/core/src/Models/WPTermTaxonomy.php',
13211321
'TypeRocket\\Models\\WPUser' => __DIR__ . '/..' . '/typerocket/core/src/Models/WPUser.php',
1322-
'TypeRocket\\OpenPlugin\\SettingsController' => __DIR__ . '/../..' . '/plugin/SettingsController.php',
1323-
'TypeRocket\\OpenPlugin\\Updater' => __DIR__ . '/../..' . '/plugin/Updater.php',
1322+
'TypeRocket\\OpenPlugin6\\SettingsController' => __DIR__ . '/../..' . '/plugin/SettingsController.php',
1323+
'TypeRocket\\OpenPlugin6\\Updater' => __DIR__ . '/../..' . '/plugin/Updater.php',
13241324
'TypeRocket\\Register\\MetaBox' => __DIR__ . '/..' . '/typerocket/core/src/Register/MetaBox.php',
13251325
'TypeRocket\\Register\\Page' => __DIR__ . '/..' . '/typerocket/core/src/Register/Page.php',
13261326
'TypeRocket\\Register\\PostType' => __DIR__ . '/..' . '/typerocket/core/src/Register/PostType.php',

typerocket/vendor/composer/installed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => 'typerocket/typerocket',
44
'pretty_version' => 'dev-main',
55
'version' => 'dev-main',
6-
'reference' => 'c009fd7bf68bdafac89f9b0f4960d89db3b9bbbc',
6+
'reference' => '33638a82fe718d39973ee87bb68f6630affc45bb',
77
'type' => 'library',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -352,7 +352,7 @@
352352
'typerocket/typerocket' => array(
353353
'pretty_version' => 'dev-main',
354354
'version' => 'dev-main',
355-
'reference' => 'c009fd7bf68bdafac89f9b0f4960d89db3b9bbbc',
355+
'reference' => '33638a82fe718d39973ee87bb68f6630affc45bb',
356356
'type' => 'library',
357357
'install_path' => __DIR__ . '/../../',
358358
'aliases' => array(),

0 commit comments

Comments
 (0)