-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy paththree-object-viewer.php
More file actions
158 lines (128 loc) · 4.72 KB
/
three-object-viewer.php
File metadata and controls
158 lines (128 loc) · 4.72 KB
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
150
151
152
153
154
155
156
157
158
<?php
/**
* Plugin Name: Three Object Viewer
* Plugin URI: https://3ov.xyz/
* Description: A plugin for viewing 3D files with support for WebXR and Open Metaverse Interoperability GLTF Extensions.
* Version: 1.7.1
* Requires at least: 5.7
* Requires PHP: 7.1.0
* Author: antpb
* Author URI: https://antpb.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: three-object-viewer
* Domain Path: /languages
*/
namespace threeObjectViewer;
require_once 'php/Plugin.php';
use threeObjectViewer\Core\Plugin;
$main = new Plugin();
$main->init();
register_activation_hook( __FILE__, array( 'threeObjectViewer\MainOptions', 'my_plugin_activate' ) );
define('THREEOV_PLUGIN_VERSION', '1.7.1');
class MainOptions
{
public static function my_plugin_activate() {
if( ! get_option( '3ov_ai_enabled' ) ) {
update_option( '3ov_ai_enabled', true );
}
if( ! get_option( '3ov_mp_networkWorker' ) ) {
update_option( '3ov_mp_networkWorker', 'https://alchemy.sxp.digital' );
}
// if 3ov_ai_openApiKey is not set, set it to empty string
if( ! get_option( '3ov_ai_openApiKey' ) ) {
update_option( '3ov_ai_openApiKey', '' );
}
if( ! get_option( '3ov_ai_allow' ) ) {
update_option( '3ov_ai_allow', 'loggedIn' );
}
// Check and update '3ov_defaultAvatar' option
if( ! get_option( '3ov_defaultAvatar' ) ) {
update_option( '3ov_defaultAvatar', '' ); // replace 'default_value' with the value you want to set
}
update_option('3ov_plugin_version', THREEOV_PLUGIN_VERSION);
}
public static function check_plugin_update() {
// Get the last known version from options
$last_known_version = get_option('3ov_plugin_version');
// If there's no recorded version or the current version is higher than the last known version, the plugin has been updated
if (!$last_known_version || version_compare(THREEOV_PLUGIN_VERSION, $last_known_version, '>')) {
self::on_plugin_update();
}
}
public static function on_plugin_update() {
if( ! get_option( '3ov_ai_enabled' ) ) {
update_option( '3ov_ai_enabled', true );
}
if( ! get_option( '3ov_mp_networkWorker' ) ) {
update_option( '3ov_mp_networkWorker', 'https://alchemy.sxp.digital' );
}
// if 3ov_ai_openApiKey is not set, set it to empty string
if( ! get_option( '3ov_ai_openApiKey' ) ) {
update_option( '3ov_ai_openApiKey', '' );
}
if( ! get_option( '3ov_ai_allow' ) ) {
update_option( '3ov_ai_allow', 'loggedIn' );
}
if( ! get_option( '3ov_defaultAvatar' ) ) {
update_option( '3ov_defaultAvatar', '' );
}
if( ! get_option( '3ov_defaultVRM' ) ) {
update_option( '3ov_defaultVRM', '' );
}
// Update the version in options
update_option('3ov_plugin_version', THREEOV_PLUGIN_VERSION);
}
/**
* Check if pro version is installed
*/
public static function threeov_is_pro() {
if ( file_exists( __DIR__ .'/pro' )) {
return true;
} else {
return false;
}
}
}
MainOptions::check_plugin_update();
// Include three-object-block
include_once dirname( __FILE__ ) . '/blocks/three-object-block/init.php';
// Include environment
include_once dirname( __FILE__ ) . '/blocks/environment/init.php';
// Include model
include_once dirname( __FILE__ ) . '/blocks/model-block/init.php';
// Include npc
include_once dirname( __FILE__ ) . '/blocks/npc-block/init.php';
// Include sky
include_once dirname( __FILE__ ) . '/blocks/sky-block/init.php';
// Include image
include_once dirname( __FILE__ ) . '/blocks/three-image-block/init.php';
// Include image
include_once dirname( __FILE__ ) . '/blocks/three-video-block/init.php';
// Include audio
include_once dirname( __FILE__ ) . '/blocks/three-audio-block/init.php';
// Include light
include_once dirname( __FILE__ ) . '/blocks/three-light-block/init.php';
// Include portal
include_once dirname( __FILE__ ) . '/blocks/three-portal-block/init.php';
// Include html
include_once dirname( __FILE__ ) . '/blocks/three-text-block/init.php';
// Include spawn point
include_once dirname( __FILE__ ) . '/blocks/spawn-point-block/init.php';
if ( MainOptions::threeov_is_pro() ) {
// Include mirror block
include_once dirname( __FILE__ ) . '/pro/blocks/three-mirror-block/init.php';
include_once dirname( __FILE__ ) . '/pro/admin/three-object-viewer-pro-settings/init.php';
}
/**
* Include the autoloader
*/
add_action( 'plugins_loaded', function () {
if ( file_exists(__DIR__ . '/vendor/autoload.php' ) ) {
include __DIR__ . '/vendor/autoload.php';
}
}, 1 );
include_once dirname( __FILE__ ). '/inc/functions.php';
include_once dirname( __FILE__ ). '/inc/hooks.php';
include_once dirname( __FILE__ ) . '/admin/three-object-viewer-settings/init.php';
include_once dirname( __FILE__ ) . '/php/Plugin.php';