Plugin Directory

Changeset 3468054


Ignore:
Timestamp:
02/23/2026 09:47:05 PM (2 weeks ago)
Author:
callahancodes
Message:

/trunk folder structure changed to mirror development

Location:
three-importer/trunk
Files:
20 added
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • three-importer/trunk/readme.txt

    r3463653 r3468054  
    55Requires at least: 5.0
    66Tested up to:      6.9
    7 Stable tag:        1.0.3
     7Stable tag:        1.0.4
    88License:           GPL-2.0-or-later
    99License URI:       https://www.gnu.org/licenses/gpl-2.0.html
  • three-importer/trunk/three-importer.php

    r3463653 r3468054  
    33 * Plugin Name:       Three Importer
    44 * Description:       Create custom Three.js scenes via Block, Shortcode, or your own script.
    5  * Version:           1.0.3
     5 * Version:           1.0.4
    66 * Requires at least: 6.7
    77 * Requires PHP:      7.4
     
    1515 */
    1616
    17 // exit if directly accessed
    1817if ( ! defined( 'ABSPATH' ) ) {
    1918    exit;
     
    2221// register TI block
    2322function 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}" );
    3431    }
    3532}
     
    3936function ti3d_shortcodes_scene_init( $atts, $content = null ) {
    4037
    41     // deny if block/[ti3d_sceneinject] is already being used
     38    // lock | deny if block/[ti3d_sceneinject] is already being used
    4239    if ( defined( 'TI3D_MODE_MANUAL' ) || defined( 'TI3D_MODE_BLOCK_ACTIVE' ) ) {
    4340        return '';
     
    144141function ti3d_shortcodes_sceneinject_init($atts = []) {
    145142
    146     // deny if block/[ti3d_scene] is already being used
     143    // lock | deny if block/[ti3d_scene] is already being used
    147144    if ( defined( 'TI3D_MODE_AUTOMATED' ) || defined( 'TI3D_MODE_BLOCK_ACTIVE' ) ) {
    148145        return '';
     
    181178    wp_enqueue_script(
    182179        'three-sceneinject',
    183         plugin_dir_url(__FILE__) . 'three-importer/sceneinject.js',
     180        plugin_dir_url(__FILE__) . 'build/three-importer/sceneinject.js',
    184181        [],
    185         filemtime(plugin_dir_path(__FILE__) . 'three-importer/sceneinject.js'),
     182        filemtime(plugin_dir_path(__FILE__) . 'build/three-importer/sceneinject.js'),
    186183        true
    187184    );
    188185
    189     // inject data into the browser before script runs
     186    // inject PHP data into the browser as a global variable before the script runs
    190187    $json_modules = wp_json_encode( array_values( $requested_modules ) );
    191188    wp_add_inline_script(
     
    203200function ti3d_enqueue_assets() {
    204201
    205     // exit early if we aren't on a single post/page
     202    // exit early if we aren't on a single post or page.
    206203    global $post;
    207204    if ( ! is_singular() || ! is_a( $post, 'WP_Post' ) ) return;
    208205
    209     // check vars
    210206    $content = $post->post_content;
    211207    $has_block = has_block( 'ti-blocks/three-importer', $content );
     
    213209    $has_inject_shortcode = has_shortcode( $content, 'ti3d_sceneinject' );
    214210   
    215     // check if a shortcode claimed the page
     211    // lock | check if a shortcode claimed the page before the block logic runs
    216212    if ( $has_block && ( defined('TI3D_MODE_MANUAL') || defined('TI3D_MODE_AUTOMATED') ) ) {
    217213        return;
    218214    }
    219215       
    220     // load required assets only when a block/shortcode is detected
     216    // load required assets only when a block or shortcode is detected
    221217    if ( ( $has_block || $has_scene_shortcode ) && ! defined( 'TI3D_MODE_MANUAL' ) ) {
    222218       
    223219        if (!defined('TI3D_MODE_BLOCK_ACTIVE')) define('TI3D_MODE_BLOCK_ACTIVE', true);
    224220
    225         $index_asset_path = __DIR__ . '/three-importer/index.asset.php';
     221        $index_asset_path = __DIR__ . '/build/three-importer/index.asset.php';
    226222        $index_asset = file_exists( $index_asset_path )
    227223            ? require $index_asset_path
     
    230226        wp_enqueue_script(
    231227            'threeimporter',
    232             plugins_url( 'three-importer/view.js', __FILE__ ),
     228            plugins_url( 'build/three-importer/view.js', __FILE__ ),
    233229            $index_asset['dependencies'],
    234230            $index_asset['version'],
     
    245241    }
    246242
    247     // enqueue css
     243    // enqueue css for block/shortcodes
    248244    if ( $has_block || $has_scene_shortcode || $has_inject_shortcode ) {
    249245        wp_enqueue_style(
    250246            'threeimporter-style',
    251             plugins_url( 'three-importer/style-index.css', __FILE__ ),
     247            plugins_url( 'build/three-importer/style-index.css', __FILE__ ),
    252248            array(),
    253249            '0.1.0'
     
    259255// editor warning enqueue
    260256function 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';
    262258   
    263259    if ( file_exists( $file_path ) ) {
    264260        wp_enqueue_script(
    265261            'ti3d-editor-warnings',
    266             plugin_dir_url(__FILE__) . 'three-importer/warning.js',
     262            plugin_dir_url(__FILE__) . 'build/three-importer/warning.js',
    267263            array('wp-data', 'wp-editor', 'wp-notices', 'wp-core-data', 'wp-dom-ready'),
    268264            filemtime( $file_path ),
Note: See TracChangeset for help on using the changeset viewer.