forked from Eoxia/BeFlex-Sensei
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eoxia#61 [Block] add: files for the new categories list block
- Loading branch information
1 parent
976a797
commit fc0e952
Showing
5 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
inc/blocks/bfs-list-course-category/assets/json/block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"name": "beflex/list-course-category", | ||
"title": "BFS List Course Category", | ||
"description": "", | ||
"style": [ "block-bfs-list-course-category-style" ], | ||
"viewScript": [], | ||
"category": "beflex", | ||
"icon": "", | ||
"apiVersion": 2, | ||
"textdomain": "beflex", | ||
"keywords": [ | ||
"beflex", | ||
"bfs", | ||
"list-course-category" | ||
], | ||
"supports": { | ||
}, | ||
"acf": { | ||
"mode": "auto", | ||
"renderTemplate": "../../view.php" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/** | ||
* Style CSS de bfs-list-course-category | ||
*/ |
41 changes: 41 additions & 0 deletions
41
inc/blocks/bfs-list-course-category/bfs-list-course-category.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* list-course-category | ||
* | ||
* @author Eoxia <[email protected]> | ||
* @link https://developer.wordpress.org/themes/basics/theme-functions/ | ||
* @since 4.0.0 | ||
* @package beflex-child | ||
* | ||
*/ | ||
|
||
if ( ! defined( 'BFS_LIST_COURSE_CATEGORY_DIR' ) ) { | ||
define( 'BFS_LIST_COURSE_CATEGORY_DIR', dirname(__DIR__, 1) . '/bfs-list-course-category' ); | ||
} | ||
if ( ! defined( 'BFS_LIST_COURSE_CATEGORY_URL' ) ) { | ||
define( 'BFS_LIST_COURSE_CATEGORY_URL', get_template_directory_uri() . '/inc/blocks/bfs-list-course-category' ); | ||
} | ||
|
||
/** | ||
* Generate block | ||
* | ||
* @return void | ||
*/ | ||
function bfs_list_course_category_register_acf_blocks() { | ||
wp_register_style( 'block-bfs-list-course-category-style', BFS_LIST_COURSE_CATEGORY_URL . '/assets/css/style.min.css' ); | ||
register_block_type( BFS_LIST_COURSE_CATEGORY_DIR . '/assets/json/' ); | ||
} | ||
add_action( 'init', 'bfs_list_course_category_register_acf_blocks', 5 ); | ||
|
||
/** | ||
* Load Json fields | ||
* | ||
* @param array $paths Json path | ||
* | ||
* @return array $paths Json path | ||
*/ | ||
function bfs_list_course_category_load_json( $paths ) { | ||
$paths[] = BFS_LIST_COURSE_CATEGORY_DIR . '/assets/json'; | ||
return $paths; | ||
} | ||
add_filter( 'acf/settings/load_json', 'bfs_list_course_category_load_json' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* list-course-category. | ||
* | ||
* @param array $block The block settings and attributes. | ||
* @param string $content The block inner HTML (empty). | ||
* @param bool $is_preview True during backend preview render. | ||
* @param int $post_id The post ID the block is rendering content against. | ||
* This is either the post ID currently being displayed inside a query loop, | ||
* or the post ID of the post hosting this block. | ||
* @param array $context The context provided to the block by the post or its parent block. | ||
*/ | ||
|
||
// Support custom "anchor" values. | ||
$anchor = ''; | ||
if ( ! empty( $block['anchor'] ) ) { | ||
$anchor = 'id="' . esc_attr( $block['anchor'] ) . '" '; | ||
} | ||
|
||
// Create class attribute allowing for custom "className" and "align" values. | ||
$class_name = 'bfs-list-course-category'; | ||
|
||
if ( ! empty( $block['className'] ) ) { | ||
$class_name .= ' ' . $block['className']; | ||
} | ||
if ( ! empty( $block['align'] ) ) { | ||
$class_name .= ' align' . $block['align']; | ||
} | ||
|
||
// Admin classes | ||
if ( is_admin() ) : | ||
$class_name .= ' is-admin'; | ||
endif; | ||
?> | ||
|
||
<div <?php echo $anchor; ?> class="<?php echo esc_attr( $class_name ); ?>"> | ||
COucou | ||
</div> |