PluginProbe
3D Viewer – Turn Product Pages into Interactive 3D Experiences / trunk
3D Viewer – Turn Product Pages into Interactive 3D Experiences vtrunk
1.9.3 1.9.1 1.9.2 1.9.0 1.8.10 1.8.11 1.8.12 1.8.13 1.8.9 trunk 1.0.0 1.0.1 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 All 54 releases
3d-viewer / 3d-viewer.php

3d-viewer.php in 3D Viewer – Turn Product Pages into Interactive 3D Experiences trunk, at 3d-viewer.php

200 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 /*
5 * Plugin Name: 3D Viewer – Display Interactive 3D Models
6 * Plugin URI: https://bplugins.com/
7 * Description: Easily display interactive 3D models on the web. Supported File type .glb, .gltf,obj 3ds stl ply off 3dm fbx dae wrl 3mf amf ifc brep step iges fcstd bim
8 * Version: 1.9.3
9 * Author: bPlugins
10 * Author URI: https://bplugins.com
11 * Requires PHP: 7.4
12 * Requires at least: 6.5
13 * Tested up to: 7.0
14 * License: GPLv2 or later
15 * Text Domain: 3d-viewer
16 * Domain Path: /languages
17 */
18
19 if (!defined('ABSPATH')) {
20 exit;
21 }
22
23 /**
24 * plugin is activated, deactivate the premium build automatically.
25 */
26 if (!function_exists('bp3d_deactivate_premium_version')) {
27 function bp3d_deactivate_premium_version()
28 {
29 if (!function_exists('is_plugin_active')) {
30 require_once ABSPATH . 'wp-admin/includes/plugin.php';
31 }
32
33 $premium = '3d-viewer-premium/3d-viewer-premium.php';
34
35 if (is_plugin_active($premium)) {
36 deactivate_plugins($premium);
37 }
38 }
39 }
40 register_activation_hook(__FILE__, 'bp3d_deactivate_premium_version');
41
42 /**
43 * Flag a fresh activation so admin_init can send the user to the guided setup
44 * once. Gated on an option rather than on the absence of settings, so an
45 * update never re-triggers it.
46 */
47 if (!function_exists('bp3d_flag_onboarding_redirect')) {
48 function bp3d_flag_onboarding_redirect()
49 {
50 add_option('bp3d_onboarding_redirect', 1);
51 }
52 }
53 register_activation_hook(__FILE__, 'bp3d_flag_onboarding_redirect');
54
55 if (function_exists('bp3d_fs')) {
56 bp3d_fs()->set_basename(true, __FILE__);
57 } else {
58
59 if (file_exists(dirname(__FILE__) . '/vendor/autoload.php')) {
60 require_once(dirname(__FILE__) . '/vendor/autoload.php');
61 }
62 if (file_exists(dirname(__FILE__) . '/inc/admin.php')) {
63 require_once(dirname(__FILE__) . '/inc/admin.php');
64 }
65
66 if (defined('WP_DEBUG') && WP_DEBUG === true) {
67 define('BP3D_VERSION', time());
68 } else {
69 define('BP3D_VERSION', '1.9.3');
70 }
71
72 defined('BP3D_DIR') or define('BP3D_DIR', plugin_dir_url(__FILE__));
73 defined('BP3D_PATH') or define('BP3D_PATH', plugin_dir_path(__FILE__));
74 defined('BP3D_TEMPLATE_PATH') or define('BP3D_TEMPLATE_PATH', plugin_dir_path(__FILE__) . 'inc/Template/');
75 defined('BP3D__FILE__') or define('BP3D__FILE__', __FILE__);
76 define('BP3D_IMPORT_VER', '1.0.0');
77
78
79 // Create a helper function for easy SDK access.
80 function bp3d_fs()
81 {
82 global $bp3d_fs;
83
84 if (!isset($bp3d_fs)) {
85 // Include Freemius SDK.
86 // SDK is auto-loaded through composer
87 $bp3d_fs = fs_dynamic_init(array(
88 'id' => '8795',
89 'slug' => '3d-viewer',
90 'type' => 'plugin',
91 'public_key' => 'pk_5e6ce3f226c86e3b975b59ed84d6a',
92 'is_premium' => false,
93 // If your plugin is a serviceware, set this option to false.
94 'has_affiliation' => 'selected',
95 'menu' => array(
96 'slug' => 'edit.php?post_type=bp3d-model-viewer',
97 // Deliberately the dashboard, not the guided setup: the
98 // setup screen is not registered for Pro, and first-path
99 // has no way to branch. Free users still reach the wizard —
100 // Onboarding::maybe_redirect() picks them up from here.
101 'first-path' => 'edit.php?post_type=bp3d-model-viewer&page=3d-viewer',
102 'support' => false,
103 'affiliation' => false,
104 'contact' => false,
105 ),
106 ));
107 }
108
109 return $bp3d_fs;
110 }
111
112 // Init Freemius.
113 bp3d_fs();
114 // Signal that SDK was initiated.
115 do_action('bp3d_fs_loaded');
116
117
118 // External files Inclusion
119 if (file_exists(BP3D_PATH . 'vendor/codestar-framework/codestar-framework.php')) {
120 require_once BP3D_PATH . 'vendor/codestar-framework/codestar-framework.php';
121 }
122
123
124 if (!class_exists('BP3D')) {
125 class BP3D
126 {
127 protected static $instance = null;
128
129 public static function get_instance()
130 {
131 if (null === self::$instance) {
132 self::$instance = new self();
133 }
134 return self::$instance;
135 }
136
137 public function __construct()
138 {
139 $init_file = BP3D_PATH . 'inc/Init.php';
140 if (file_exists($init_file)) {
141 require_once($init_file);
142 }
143 if (class_exists('BP3D\\Init')) {
144 \BP3D\Init::instance()->init();
145 }
146 add_action('plugins_loaded', array($this, 'plugins_loaded'));
147 add_action('init', [$this, 'load_plugin_textdomain']);
148 add_filter('fs_is_update_check_enabled', '__return_false');
149
150 }
151
152 public function load_plugin_textdomain()
153 {
154 // Try the NEW slug first (for future translations from WordPress.org)
155 $loaded = load_plugin_textdomain('3d-viewer', false, dirname(plugin_basename(__FILE__)) . '/languages');
156
157 // If that fails, fall back to the OLD domain (for existing user translations)
158 if (!$loaded) {
159 load_plugin_textdomain('model-viewer', false, dirname(plugin_basename(__FILE__)) . '/languages');
160 }
161 }
162
163 function plugins_loaded()
164 {
165 if (class_exists('BP3D\\Init')) {
166 \BP3D\Init::register_post_type();
167 }
168 }
169 }
170 BP3D::get_instance();
171 }
172
173 $bpem_bootstrap = BP3D_PATH . 'vendor/bp-extension-manager/bootstrap.php';
174 if (file_exists($bpem_bootstrap)) {
175 require_once $bpem_bootstrap;
176 }
177
178
179 add_action('bpem_loaded', function () {
180 if (class_exists('\\BPEM\\Manager')) {
181 \BPEM\Manager::boot(array(
182 'slug' => '3d-viewer', // unique; namespaces everything
183 'name' => '3D Viewer',
184 'version' => (string) BP3D_VERSION,
185 'menu_parent' => 'edit.php?post_type=bp3d-model-viewer',
186 'freemius' => function_exists('bp3d_fs') ? bp3d_fs() : null,
187 'max_plan_id' => 'max',
188 'catalog_file' => __DIR__ . '/public/extensions.php', // Explicit PHP path
189 'menu_badge' => true,
190 'menu_badge_persist' => true,
191 'enable_freemius_checkout' => true
192
193 ));
194 }
195 });
196
197 }
198
199
200