| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- /**
- * Plugin Name: Tsu Financial Progress Block
- * Description: Example block scaffolded with Create Block tool.
- * Requires at least: 6.1
- * Requires PHP: 7.0
- * Version: 0.1.0
- * Author: The WordPress Contributors
- * License: GPL-2.0-or-later
- * License URI: https://www.gnu.org/licenses/gpl-2.0.html
- * Text Domain: tsu-financial-progress-block
- *
- * @package create-block
- */
- if ( ! defined( 'ABSPATH' ) ) {
- exit; // Exit if accessed directly.
- }
- // Register Custom Block Category
- add_filter( 'block_categories_all', function($categories) {
-
- // Set Category Slug
- $new_slug = 'tsu-category';
- // Set Category Title
- $new_title = 'To się uda';
- $has_category = false;
- foreach($categories as $category) {
- if($category === [ 'slug' => $new_slug, 'title' => $new_title]) {
- $has_category = true;
- }
- }
- if(!$has_category) {
- $categories[] = array(
- 'slug' => $new_slug,
- 'title' => $new_title
- );
- };
-
- return $categories;
- });
- /**
- * Registers the block using the metadata loaded from the `block.json` file.
- * Behind the scenes, it registers also all assets so they can be enqueued
- * through the block editor in the corresponding context.
- *
- * @see https://developer.wordpress.org/reference/functions/register_block_type/
- */
- function tsu_financial_progress_block_tsu_financial_progress_block_block_init() {
- register_block_type( __DIR__ . '/build' );
- }
- add_action( 'init', 'tsu_financial_progress_block_tsu_financial_progress_block_block_init' );
|