-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtyperocket-ui.php
82 lines (68 loc) · 2.63 KB
/
typerocket-ui.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
<?php
/*
Plugin Name: TypeRocket UI
Plugin URI: https://typerocket.com/ui/
Description: This plugin provides a powerful user interface for creating post types, taxonomies, and meta boxes.
Version: 5.0.11
Requires at least: 5.5
Requires PHP: 7.4
Author: TypeRocket
Author URI: https://typerocket.com
License: GPLv3 or later
*/
defined( 'ABSPATH' ) or die( 'Nothing here to see!' );
class TypeRocketUIPlugin
{
public $path = null;
public $message = '';
public $activating = false;
public $id = 'typerocket_ui_register';
const OPTION = 'tr_registered';
public function __construct()
{
add_action('plugins_loaded', function() {
if(defined('TYPEROCKET_PLUGIN_INSTALL') || defined('TYPEROCKET_PATH')) {
add_filter('plugin_action_links',function ($actions, $plugin_file) {
if( $found = strpos(__FILE__, $plugin_file) ) {
$actions['settings'] = '<span style="color: red">Inactive Install</span>';
}
return $actions;
}, 10, 2 );
return;
}
$this->loadConfig();
require 'typerocket/init.php';
$this->path = plugin_dir_path(__FILE__);
define('TYPEROCKET_AUTO_LOADER', '__return_false');
add_filter('plugin_action_links', [$this, 'links'], 10, 2 );
add_filter('typerocket_auth_policy_check', '__return_false', 10, 2 );
add_action('typerocket_loaded', [$this, 'typerocket_loaded']);
}, 20);
}
public function typerocket_loaded()
{
TypeRocket\Register\MetaBox::new('TypeRocket UI')->setCallback(function() {
echo \TypeRocket\Template\View::new(__DIR__ . '/meta-dashboard.php')->setEngine(\TypeRocket\Template\TemplateEngine::class);
})->addScreen('dashboard')->addToRegistry();
}
public function links($actions, $plugin_file)
{
if( $found = strpos(__FILE__, $plugin_file) ) {
$url = menu_page_url($this->id, false);
$actions['settings'] = '<a href="'.$url.'" aria-label="TypeRocket UI">Settings</a>';
}
return $actions;
}
public function loadConfig()
{
define('TYPEROCKET_PLUGIN_INSTALL', __DIR__);
define('TYPEROCKET_CORE_CONFIG_PATH', __DIR__ . '/typerocket/config' );
define('TYPEROCKET_ROOT_WP', ABSPATH);
define('TYPEROCKET_APP_NAMESPACE', 'TypeRocketUIPlugin');
define('TYPEROCKET_AUTOLOAD_APP', [
'prefix' => TYPEROCKET_APP_NAMESPACE . '\\',
'folder' => __DIR__ . '/typerocket/app/',
]);
}
}
new TypeRocketUIPlugin();