'CTBlock', 'title' => 'Countdown Time', ] ], $categories ); } // Categories function onInit() { wp_register_script( 'ctb-countdown-time-script', plugins_url( 'dist/script.js', __FILE__ ), [ 'react', 'react-dom' ], CTB_PLUGIN_VERSION, true ); // Frontend Script wp_register_style( 'ctb-countdown-time-style', plugins_url( 'dist/style.css', __FILE__ ), [], CTB_PLUGIN_VERSION ); // Style wp_register_style( 'ctb-countdown-time-editor-style', plugins_url( 'dist/editor.css', __FILE__ ), [ 'ctb-countdown-time-style' ], CTB_PLUGIN_VERSION ); // Backend Style register_block_type( __DIR__, [ 'editor_style' => 'ctb-countdown-time-editor-style', 'render_callback' => [$this, 'render'] ] ); // Register Block wp_set_script_translations( 'ctb-countdown-time-editor-script', 'countdown-time', plugin_dir_path( __FILE__ ) . '/languages' ); // Translate } function render( $attributes ){ extract( $attributes ); // Enqueue assets where has block wp_enqueue_script( 'ctb-countdown-time-script' ); wp_enqueue_style( 'ctb-countdown-time-style' ); $className = $className ?? ''; $blockClassName = "wp-block-ctb-countdown-time $className align$align"; ob_start(); ?>