Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#17 [Blocks] add: custom category eo-blocks #24

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions assets/js/eoblocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* EO Blocks JS
*/
jQuery(document).ready(function ($){

});
2 changes: 1 addition & 1 deletion blocks/build/accordion/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "eo/accordion",
"version": "1.0.0",
"title": "Accordion",
"category": "design",
"category": "eo-blocks",
"icon": "smiley",
"description": "Display accordion block",
"example": {},
Expand Down
2 changes: 1 addition & 1 deletion blocks/build/accordion/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-primitives'), 'version' => 'a9726c820cd1a3452ab9');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-primitives'), 'version' => '5b2f42ebe8e947d88ba7');
19 changes: 18 additions & 1 deletion blocks/build/accordion/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocks/build/accordion/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blocks/build/digirisk-list-risk/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "eo/digirisk-list-risk",
"version": "1.0.0",
"title": "Digirisk List Risk",
"category": "design",
"category": "eo-blocks",
"icon": "smiley",
"description": "Displays a summary of the different risks of your Dolibarr",
"example": {},
Expand Down
2 changes: 1 addition & 1 deletion blocks/build/digirisk-list-risk/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => '9203b9b498c4b278a864');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => '68857afa441b5853d4ad');
2 changes: 1 addition & 1 deletion blocks/build/digirisk-list-risk/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocks/build/digirisk-list-risk/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blocks/build/kpi-contentment/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "eo/kpi-contentment",
"version": "1.0.0",
"title": "KPI Contentment",
"category": "design",
"category": "eo-blocks",
"icon": "smiley",
"description": "Display satisfaction KPI",
"example": {},
Expand Down
2 changes: 1 addition & 1 deletion blocks/build/kpi-contentment/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => '6d8ffcd7dd206ab32f8e');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => 'e207756ca4fac7758397');
2 changes: 1 addition & 1 deletion blocks/build/kpi-contentment/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocks/build/kpi-contentment/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blocks/src/accordion/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "eo/accordion",
"version": "1.0.0",
"title": "Accordion",
"category": "design",
"category": "eo-blocks",
"icon": "smiley",
"description": "Display accordion block",
"example": {},
Expand Down
7 changes: 7 additions & 0 deletions blocks/src/accordion/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocks/src/digirisk-list-risk/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "eo/digirisk-list-risk",
"version": "1.0.0",
"title": "Digirisk List Risk",
"category": "design",
"category": "eo-blocks",
"icon": "smiley",
"description": "Displays a summary of the different risks of your Dolibarr",
"example": {},
Expand Down
2 changes: 1 addition & 1 deletion blocks/src/kpi-contentment/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "eo/kpi-contentment",
"version": "1.0.0",
"title": "KPI Contentment",
"category": "design",
"category": "eo-blocks",
"icon": "smiley",
"description": "Display satisfaction KPI",
"example": {},
Expand Down
7 changes: 2 additions & 5 deletions eo-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@
*/
require_once EO_BLOCKS_PATH . '/includes/autoload.php';

use EoBlocks\Includes\Admin\Eoblocks_Menu;
use EoBlocks\Includes\Eoblocks_Settings;
use EoBlocks\Includes\Eoblocks_Helper;
use EoBlocks\Includes\Eoblocks;

$eoblocks_menu = new Eoblocks_Menu();
//$eoblocks_settings = new Eoblocks_Settings();
$eoblocks = new Eoblocks();

/**
* Registers the block using the metadata loaded from the `block.json` file.
Expand Down
70 changes: 70 additions & 0 deletions includes/class-eoblocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* Plugin Settings.
*
* @author Eoxia
*
* @since 1.0.0
*/

namespace EoBlocks\Includes;

use EoBlocks\Includes\Admin\Eoblocks_Menu;
use EoBlocks\Includes\Eoblocks_Settings;
use EoBlocks\Includes\Eoblocks_Helper;

if (!defined('ABSPATH')) {
exit;
}

class Eoblocks {
private static $initiated = false;
/**
* Class constructor
*
* @since 1.1.0
*/
public function __construct() {
$eoblocks_menu = new Eoblocks_Menu();
$eoblocks_settings = new Eoblocks_Settings();

if ( ! self::$initiated ) {
$this->init_hooks();
}
}

public function init_hooks() {
self::$initiated = true;

add_filter( 'block_categories_all', array( $this, 'create_block_category' ), 10, 2 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
}

/**
* Create Eoblocks block custom category
*
* @param $block_categories
* @param $editor_context
* @return mixed
*/
public function create_block_category( $block_categories, $editor_context ) {
if ( ! empty( $editor_context->post ) ) {
array_unshift(
$block_categories,
array(
'slug' => 'eo-blocks',
'title' => __( 'EO Blocks', 'eo-blocks' ),
)
);
}
return $block_categories;
}

/**
* Enqueue plugin scripts
* @return void
*/
public function enqueue_scripts() {
wp_enqueue_script( 'eo-blocks-js', EO_BLOCKS_URL . 'assets/js/eoblocks.js', array( 'jquery') );
}
}