Changeset 3468054
- Timestamp:
- 02/23/2026 09:47:05 PM (2 weeks ago)
- Location:
- three-importer/trunk
- Files:
-
- 20 added
- 2 deleted
- 2 edited
-
blocks-manifest.php (deleted)
-
build (added)
-
build/blocks-manifest.php (added)
-
build/three-importer (added)
-
build/three-importer/block.json (added)
-
build/three-importer/index-rtl.css (added)
-
build/three-importer/index.asset.php (added)
-
build/three-importer/index.css (added)
-
build/three-importer/index.js (added)
-
build/three-importer/render.php (added)
-
build/three-importer/sceneinject.asset.php (added)
-
build/three-importer/sceneinject.js (added)
-
build/three-importer/style-index-rtl.css (added)
-
build/three-importer/style-index.css (added)
-
build/three-importer/view.asset.php (added)
-
build/three-importer/view.js (added)
-
build/three-importer/warning.asset.php (added)
-
build/three-importer/warning.js (added)
-
public (added)
-
public/Open_Sans_Condensed_Bold.json (added)
-
public/threejs-icon.svg (added)
-
readme.txt (modified) (1 diff)
-
three-importer (deleted)
-
three-importer.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
three-importer/trunk/readme.txt
r3463653 r3468054 5 5 Requires at least: 5.0 6 6 Tested up to: 6.9 7 Stable tag: 1.0. 37 Stable tag: 1.0.4 8 8 License: GPL-2.0-or-later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
three-importer/trunk/three-importer.php
r3463653 r3468054 3 3 * Plugin Name: Three Importer 4 4 * Description: Create custom Three.js scenes via Block, Shortcode, or your own script. 5 * Version: 1.0. 35 * Version: 1.0.4 6 6 * Requires at least: 6.7 7 7 * Requires PHP: 7.4 … … 15 15 */ 16 16 17 // exit if directly accessed18 17 if ( ! defined( 'ABSPATH' ) ) { 19 18 exit; … … 22 21 // register TI block 23 22 function ti3d_block_init() { 24 $manifest_path = __DIR__ . '/blocks-manifest.php'; 25 $block_dir = __DIR__ . '/three-importer'; 26 27 // use the manifest if it exists 28 if ( function_exists( 'wp_register_block_types_from_metadata_collection' ) && file_exists( $manifest_path ) ) { 29 wp_register_block_types_from_metadata_collection( $manifest_path, __DIR__ ); 30 } 31 // direct registration (fallback if manifest fails or is missing) 32 elseif ( file_exists( $block_dir . '/block.json' ) ) { 33 register_block_type( $block_dir ); 23 if ( function_exists( 'wp_register_block_types_from_metadata_collection' ) ) { 24 wp_register_block_types_from_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' ); 25 return; 26 } 27 28 $manifest_data = require __DIR__ . '/build/blocks-manifest.php'; 29 foreach ( array_keys( $manifest_data ) as $block_type ) { 30 register_block_type( __DIR__ . "/build/{$block_type}" ); 34 31 } 35 32 } … … 39 36 function ti3d_shortcodes_scene_init( $atts, $content = null ) { 40 37 41 // deny if block/[ti3d_sceneinject] is already being used38 // lock | deny if block/[ti3d_sceneinject] is already being used 42 39 if ( defined( 'TI3D_MODE_MANUAL' ) || defined( 'TI3D_MODE_BLOCK_ACTIVE' ) ) { 43 40 return ''; … … 144 141 function ti3d_shortcodes_sceneinject_init($atts = []) { 145 142 146 // deny if block/[ti3d_scene] is already being used143 // lock | deny if block/[ti3d_scene] is already being used 147 144 if ( defined( 'TI3D_MODE_AUTOMATED' ) || defined( 'TI3D_MODE_BLOCK_ACTIVE' ) ) { 148 145 return ''; … … 181 178 wp_enqueue_script( 182 179 'three-sceneinject', 183 plugin_dir_url(__FILE__) . ' three-importer/sceneinject.js',180 plugin_dir_url(__FILE__) . 'build/three-importer/sceneinject.js', 184 181 [], 185 filemtime(plugin_dir_path(__FILE__) . ' three-importer/sceneinject.js'),182 filemtime(plugin_dir_path(__FILE__) . 'build/three-importer/sceneinject.js'), 186 183 true 187 184 ); 188 185 189 // inject data into the browser before script runs186 // inject PHP data into the browser as a global variable before the script runs 190 187 $json_modules = wp_json_encode( array_values( $requested_modules ) ); 191 188 wp_add_inline_script( … … 203 200 function ti3d_enqueue_assets() { 204 201 205 // exit early if we aren't on a single post /page202 // exit early if we aren't on a single post or page. 206 203 global $post; 207 204 if ( ! is_singular() || ! is_a( $post, 'WP_Post' ) ) return; 208 205 209 // check vars210 206 $content = $post->post_content; 211 207 $has_block = has_block( 'ti-blocks/three-importer', $content ); … … 213 209 $has_inject_shortcode = has_shortcode( $content, 'ti3d_sceneinject' ); 214 210 215 // check if a shortcode claimed the page211 // lock | check if a shortcode claimed the page before the block logic runs 216 212 if ( $has_block && ( defined('TI3D_MODE_MANUAL') || defined('TI3D_MODE_AUTOMATED') ) ) { 217 213 return; 218 214 } 219 215 220 // load required assets only when a block /shortcode is detected216 // load required assets only when a block or shortcode is detected 221 217 if ( ( $has_block || $has_scene_shortcode ) && ! defined( 'TI3D_MODE_MANUAL' ) ) { 222 218 223 219 if (!defined('TI3D_MODE_BLOCK_ACTIVE')) define('TI3D_MODE_BLOCK_ACTIVE', true); 224 220 225 $index_asset_path = __DIR__ . '/ three-importer/index.asset.php';221 $index_asset_path = __DIR__ . '/build/three-importer/index.asset.php'; 226 222 $index_asset = file_exists( $index_asset_path ) 227 223 ? require $index_asset_path … … 230 226 wp_enqueue_script( 231 227 'threeimporter', 232 plugins_url( ' three-importer/view.js', __FILE__ ),228 plugins_url( 'build/three-importer/view.js', __FILE__ ), 233 229 $index_asset['dependencies'], 234 230 $index_asset['version'], … … 245 241 } 246 242 247 // enqueue css 243 // enqueue css for block/shortcodes 248 244 if ( $has_block || $has_scene_shortcode || $has_inject_shortcode ) { 249 245 wp_enqueue_style( 250 246 'threeimporter-style', 251 plugins_url( ' three-importer/style-index.css', __FILE__ ),247 plugins_url( 'build/three-importer/style-index.css', __FILE__ ), 252 248 array(), 253 249 '0.1.0' … … 259 255 // editor warning enqueue 260 256 function ti3d_enqueue_editor_warnings() { 261 $file_path = plugin_dir_path(__FILE__) . ' three-importer/warning.js';257 $file_path = plugin_dir_path(__FILE__) . 'build/three-importer/warning.js'; 262 258 263 259 if ( file_exists( $file_path ) ) { 264 260 wp_enqueue_script( 265 261 'ti3d-editor-warnings', 266 plugin_dir_url(__FILE__) . ' three-importer/warning.js',262 plugin_dir_url(__FILE__) . 'build/three-importer/warning.js', 267 263 array('wp-data', 'wp-editor', 'wp-notices', 'wp-core-data', 'wp-dom-ready'), 268 264 filemtime( $file_path ),
Note: See TracChangeset
for help on using the changeset viewer.