-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtyperocket-v6.php
149 lines (126 loc) · 5.01 KB
/
typerocket-v6.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/*
Plugin Name: TypeRocket - Antennae
Plugin URI: https://typerocket.com/
Description: TypeRocket is a framework that joins refined UI elements and modern programming architecture together.
Version: 6.0.3
Requires at least: 6.1
Requires PHP: 8.0.2
Author: TypeRocket
Author URI: https://typerocket.com/
License: GPLv3 or later
*/
namespace TypeRocket;
defined( 'ABSPATH' ) or die( 'Nothing here to see!' );
final class OpenPlugin6
{
protected $path = null;
protected $message = '';
protected $activating = false;
protected $id = 'settings_typerocket';
public function __construct()
{
add_action('plugins_loaded', [$this, 'plugins_loaded'], 13);
register_activation_hook( __FILE__, [$this, 'activation']);
}
public function plugins_loaded()
{
if(defined('TYPEROCKET_PLUGIN_INSTALL') || defined('TYPEROCKET_PATH')) {
add_filter('plugin_action_links', function($actions, $plugin_file) {
if( strpos(__FILE__, $plugin_file) ) {
$actions['settings'] = '<span style="color: red">Inactive Install</span>';
}
return $actions;
}, 10, 2 );
return;
}
define('TYPEROCKET_PLUGIN_VERSION', '6.0.3');
define('TYPEROCKET_PLUGIN_INSTALL', __DIR__);
define('TYPEROCKET_PLUGIN_PRO', false);
if(!defined('TYPEROCKET_ROOT_WP'))
define('TYPEROCKET_ROOT_WP', ABSPATH);
$this->loadConfig();
require 'typerocket/init.php';
if(typerocket_env('TYPEROCKET_UPDATES', true)) {
add_filter('http_request_host_is_external', function($value, $host) {
return $value || $host == 'typerocket.com';
}, 10, 2);
new \TypeRocket\OpenPlugin6\Updater([
'slug' => 'typerocket-v6',
'api_url' => 'https://typerocket.com/plugins/typerocket-v6/'
]);
}
$this->path = plugin_dir_path(__FILE__);
define('TYPEROCKET_AUTO_LOADER', '__return_false');
add_action('admin_notices', [$this, 'activation_notice']);
add_action('typerocket_loaded', [$this, 'typerocket_loaded']);
add_filter('plugin_action_links', [$this, 'links'], 10, 2 );
}
public function links($actions, $plugin_file)
{
if( strpos(__FILE__, $plugin_file) ) {
$url = menu_page_url($this->id, false);
$actions['settings'] = '<a href="'.$url.'" aria-label="TypeRocket Settings">Settings</a>';
$actions['pro'] = '<a target="_blank" href="https://typerocket.com/pro/" aria-label="TypeRocket Pro">Get Pro</a>';
}
return $actions;
}
public function loadConfig()
{
if( defined('TYPEROCKET_OVERRIDE_PATH') ) {
$temp_dir = TYPEROCKET_OVERRIDE_PATH;
} else {
$temp_dir = get_template_directory();
}
// maybe get config from theme
if( !defined('TYPEROCKET_CORE_CONFIG_PATH') ) {
if(file_exists( $temp_dir . '/config/galaxy.php')) {
define('TYPEROCKET_CORE_CONFIG_PATH', $temp_dir . '/config' );
}
}
// maybe get app from theme
if(!defined('TYPEROCKET_AUTOLOAD_APP')) {
if(file_exists( $temp_dir . '/app/Http/Kernel.php')) {
if(!defined('TYPEROCKET_APP_NAMESPACE') ) {
define('TYPEROCKET_APP_NAMESPACE', 'App');
}
define('TYPEROCKET_APP_ROOT_PATH', $temp_dir);
define('TYPEROCKET_ALT_PATH', $temp_dir);
define('TYPEROCKET_AUTOLOAD_APP', [
'prefix' => TYPEROCKET_APP_NAMESPACE . '\\',
'folder' => $temp_dir . '/app/',
]);
}
}
}
public function activation()
{
$this->activating = true;
flush_rewrite_rules();
set_transient( 'typerocket-admin-notice' , true );
}
public function activation_notice()
{
$page = $_GET['page'] ?? null;
if( $this->id != $page && get_transient( 'typerocket-admin-notice' ) && ! $this->activating ) {
$url = menu_page_url($this->id, false);
$alert = __("TypeRocket wants you to <a href=\"{$url}\">check your TypeRocket settings</a> to validate your installation is correct.", 'typerocket-domain')
?>
<div class="notice notice-warning is-dismissible">
<p><?php echo $alert; ?></p>
</div>
<?php
}
}
public function typerocket_loaded()
{
tr_page('settings@TypeRocket\\OpenPlugin6\\SettingsController', 'typerocket', __('TypeRocket Settings'), [
'menu' => __('TypeRocket'),
'capability' => 'activate_plugins'
]);
tr_meta_box('Upgrade To TypeRocket Pro')->setCallback(function() {
echo \TypeRocket\Template\View::new(__DIR__ . '/meta-dashboard.php')->setEngine(\TypeRocket\Template\TemplateEngine::class);
})->addScreen('dashboard');
}
}
new OpenPlugin6();