| 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.0 |
| 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 |
if (function_exists('bp3d_fs')) { |
| 43 |
bp3d_fs()->set_basename(true, __FILE__); |
| 44 |
} else { |
| 45 |
|
| 46 |
if (file_exists(dirname(__FILE__) . '/vendor/autoload.php')) { |
| 47 |
require_once(dirname(__FILE__) . '/vendor/autoload.php'); |
| 48 |
} |
| 49 |
if (file_exists(dirname(__FILE__) . '/inc/admin.php')) { |
| 50 |
require_once(dirname(__FILE__) . '/inc/admin.php'); |
| 51 |
} |
| 52 |
|
| 53 |
if (defined('WP_DEBUG') && WP_DEBUG === true) { |
| 54 |
define('BP3D_VERSION', time()); |
| 55 |
} else { |
| 56 |
define('BP3D_VERSION', '1.9.0'); |
| 57 |
} |
| 58 |
|
| 59 |
defined('BP3D_DIR') or define('BP3D_DIR', plugin_dir_url(__FILE__)); |
| 60 |
defined('BP3D_PATH') or define('BP3D_PATH', plugin_dir_path(__FILE__)); |
| 61 |
defined('BP3D_TEMPLATE_PATH') or define('BP3D_TEMPLATE_PATH', plugin_dir_path(__FILE__) . 'inc/Template/'); |
| 62 |
defined('BP3D__FILE__') or define('BP3D__FILE__', __FILE__); |
| 63 |
define('BP3D_IMPORT_VER', '1.0.0'); |
| 64 |
|
| 65 |
|
| 66 |
// Create a helper function for easy SDK access. |
| 67 |
function bp3d_fs() |
| 68 |
{ |
| 69 |
global $bp3d_fs; |
| 70 |
|
| 71 |
if (!isset($bp3d_fs)) { |
| 72 |
// Include Freemius SDK. |
| 73 |
// SDK is auto-loaded through composer |
| 74 |
$bp3d_fs = fs_dynamic_init(array( |
| 75 |
'id' => '8795', |
| 76 |
'slug' => '3d-viewer', |
| 77 |
'type' => 'plugin', |
| 78 |
'public_key' => 'pk_5e6ce3f226c86e3b975b59ed84d6a', |
| 79 |
'is_premium' => false, |
| 80 |
// If your plugin is a serviceware, set this option to false. |
| 81 |
'has_affiliation' => 'selected', |
| 82 |
'menu' => array( |
| 83 |
'slug' => 'edit.php?post_type=bp3d-model-viewer', |
| 84 |
'first-path' => 'edit.php?post_type=bp3d-model-viewer&page=3d-viewer', |
| 85 |
'support' => false, |
| 86 |
'affiliation' => false, |
| 87 |
'contact' => false, |
| 88 |
), |
| 89 |
)); |
| 90 |
} |
| 91 |
|
| 92 |
return $bp3d_fs; |
| 93 |
} |
| 94 |
|
| 95 |
// Init Freemius. |
| 96 |
bp3d_fs(); |
| 97 |
// Signal that SDK was initiated. |
| 98 |
do_action('bp3d_fs_loaded'); |
| 99 |
|
| 100 |
|
| 101 |
// External files Inclusion |
| 102 |
if (file_exists(BP3D_PATH . 'vendor/codestar-framework/codestar-framework.php')) { |
| 103 |
require_once BP3D_PATH . 'vendor/codestar-framework/codestar-framework.php'; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
if (!class_exists('BP3D')) { |
| 108 |
class BP3D |
| 109 |
{ |
| 110 |
protected static $instance = null; |
| 111 |
|
| 112 |
public static function get_instance() |
| 113 |
{ |
| 114 |
if (null === self::$instance) { |
| 115 |
self::$instance = new self(); |
| 116 |
} |
| 117 |
return self::$instance; |
| 118 |
} |
| 119 |
|
| 120 |
public function __construct() |
| 121 |
{ |
| 122 |
$init_file = BP3D_PATH . 'inc/Init.php'; |
| 123 |
if (file_exists($init_file)) { |
| 124 |
require_once($init_file); |
| 125 |
} |
| 126 |
if (class_exists('BP3D\\Init')) { |
| 127 |
\BP3D\Init::instance()->init(); |
| 128 |
} |
| 129 |
add_action('plugins_loaded', array($this, 'plugins_loaded')); |
| 130 |
add_action('init', [$this, 'load_plugin_textdomain']); |
| 131 |
add_filter('fs_is_update_check_enabled', '__return_false'); |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
public function load_plugin_textdomain() |
| 136 |
{ |
| 137 |
// Try the NEW slug first (for future translations from WordPress.org) |
| 138 |
$loaded = load_plugin_textdomain('3d-viewer', false, dirname(plugin_basename(__FILE__)) . '/languages'); |
| 139 |
|
| 140 |
// If that fails, fall back to the OLD domain (for existing user translations) |
| 141 |
if (!$loaded) { |
| 142 |
load_plugin_textdomain('model-viewer', false, dirname(plugin_basename(__FILE__)) . '/languages'); |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
function plugins_loaded() |
| 147 |
{ |
| 148 |
if (class_exists('BP3D\\Init')) { |
| 149 |
\BP3D\Init::register_post_type(); |
| 150 |
} |
| 151 |
} |
| 152 |
} |
| 153 |
BP3D::get_instance(); |
| 154 |
} |
| 155 |
|
| 156 |
$bpem_bootstrap = BP3D_PATH . 'vendor/bp-extension-manager/bootstrap.php'; |
| 157 |
if (file_exists($bpem_bootstrap)) { |
| 158 |
require_once $bpem_bootstrap; |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
add_action('bpem_loaded', function () { |
| 163 |
if (class_exists('\\BPEM\\Manager')) { |
| 164 |
\BPEM\Manager::boot(array( |
| 165 |
'slug' => '3d-viewer', // unique; namespaces everything |
| 166 |
'name' => '3D Viewer', |
| 167 |
'version' => (string) BP3D_VERSION, |
| 168 |
'menu_parent' => 'edit.php?post_type=bp3d-model-viewer', |
| 169 |
'freemius' => function_exists('bp3d_fs') ? bp3d_fs() : null, |
| 170 |
'max_plan_id' => 'max', |
| 171 |
'catalog_file' => __DIR__ . '/public/extensions.php', // Explicit PHP path |
| 172 |
'menu_badge' => true, |
| 173 |
'menu_badge_persist' => true, |
| 174 |
'enable_freemius_checkout' => true |
| 175 |
|
| 176 |
)); |
| 177 |
} |
| 178 |
}); |
| 179 |
|
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
|