Compare commits

...

2 Commits

Author SHA1 Message Date
Antoine M
6a22947e10 UPDATE Update allowed blocks in content box editor to include audio player block
All checks were successful
continuous-integration/drone/push Build is passing
2025-10-29 18:01:57 +01:00
Antoine M
e2b7c36434 FEATURE Add block type filtering for audio player based on user capabilities and update block metadata 2025-10-29 18:01:35 +01:00
11 changed files with 71 additions and 18 deletions

View File

@ -107,3 +107,46 @@ function create_block_audio_player_block_init()
}
}
add_action('init', 'create_block_audio_player_block_init');
/* ############## DISALLOW BLOCKS ############## */
/**
* Désactive le bloc audio natif pour les utilisateurs non administrateurs pour éviter toute confusio
*
*/
function carhop_blocks_disallow_block_types($allowed_block_types, $block_editor_context)
{
$disallowed_blocks = array(
'core/audio',
);
// Get all registered blocks if $allowed_block_types is not already set.
if (! is_array($allowed_block_types) || empty($allowed_block_types)) {
$registered_blocks = WP_Block_Type_Registry::get_instance()->get_all_registered();
$allowed_block_types = array_keys($registered_blocks);
}
// Create a new array for the allowed blocks.
$filtered_blocks = array();
// Loop through each block in the allowed blocks list.
foreach ($allowed_block_types as $block) {
// Check if the block is not in the disallowed blocks list.
if (! in_array($block, $disallowed_blocks, true)) {
// If it's not disallowed, add it to the filtered list.
$filtered_blocks[] = $block;
}
}
// Return the filtered list of allowed blocks
return $filtered_blocks;
}
add_filter('allowed_block_types_all', 'carhop_blocks_disallow_block_types', 10, 2);

View File

@ -3,10 +3,13 @@
"apiVersion": 3,
"name": "carhop-blocks/audio-player",
"version": "0.1.0",
"title": "Player audio",
"title": "Lecteur audio",
"category": "carhop-blocks",
"icon": "format-audio",
"description": "Lecteur audio pour la mise en forme d'éléments de contenu",
"icon": {
"src": "format-audio",
"foreground": "#136f63"
},
"description": "Lecteur audio pour intégrer un fichier audio dans votre contenu",
"example": {},
"attributes": {
"audioUrl": {
@ -19,7 +22,7 @@
},
"title": {
"type": "string",
"default": "Titre du bloc"
"default": "Titre du bloc audio"
},
"description": {
"type": "string",

View File

@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '6ac76ce8fc2124b02c68');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '522d2588811a43dfc829');

View File

@ -8,7 +8,7 @@
\*************************************/
/***/ ((module) => {
module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"carhop-blocks/audio-player","version":"0.1.0","title":"Player audio","category":"carhop-blocks","icon":"format-audio","description":"Lecteur audio pour la mise en forme d\'éléments de contenu","example":{},"attributes":{"audioUrl":{"type":"string","default":""},"audioId":{"type":"number","default":0},"title":{"type":"string","default":"Titre du bloc"},"description":{"type":"string","default":""},"caption":{"type":"string","default":""}},"supports":{"html":false},"keywords":["audio","player","lecteur audio"],"textdomain":"carhop-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","viewScript":"file:./view.js"}');
module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"carhop-blocks/audio-player","version":"0.1.0","title":"Lecteur audio","category":"carhop-blocks","icon":{"src":"format-audio","foreground":"#136f63"},"description":"Lecteur audio pour intégrer un fichier audio dans votre contenu","example":{},"attributes":{"audioUrl":{"type":"string","default":""},"audioId":{"type":"number","default":0},"title":{"type":"string","default":"Titre du bloc audio"},"description":{"type":"string","default":""},"caption":{"type":"string","default":""}},"supports":{"html":false},"keywords":["audio","player","lecteur audio"],"textdomain":"carhop-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","viewScript":"file:./view.js"}');
/***/ }),

File diff suppressed because one or more lines are too long

View File

@ -6,10 +6,13 @@ return array(
'apiVersion' => 3,
'name' => 'carhop-blocks/audio-player',
'version' => '0.1.0',
'title' => 'Player audio',
'title' => 'Lecteur audio',
'category' => 'carhop-blocks',
'icon' => 'format-audio',
'description' => 'Lecteur audio pour la mise en forme d\'éléments de contenu',
'icon' => array(
'src' => 'format-audio',
'foreground' => '#136f63'
),
'description' => 'Lecteur audio pour intégrer un fichier audio dans votre contenu',
'example' => array(
),
@ -24,7 +27,7 @@ return array(
),
'title' => array(
'type' => 'string',
'default' => 'Titre du bloc'
'default' => 'Titre du bloc audio'
),
'description' => array(
'type' => 'string',

View File

@ -3,10 +3,13 @@
"apiVersion": 3,
"name": "carhop-blocks/audio-player",
"version": "0.1.0",
"title": "Player audio",
"title": "Lecteur audio",
"category": "carhop-blocks",
"icon": "format-audio",
"description": "Lecteur audio pour la mise en forme d'éléments de contenu",
"icon": {
"src": "format-audio",
"foreground": "#136f63"
},
"description": "Lecteur audio pour intégrer un fichier audio dans votre contenu",
"example": {},
"attributes": {
"audioUrl": {
@ -19,7 +22,7 @@
},
"title": {
"type": "string",
"default": "Titre du bloc"
"default": "Titre du bloc audio"
},
"description": {
"type": "string",

View File

@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => 'f7e30d5a7b812b309f74');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => 'a8f0730623540f7c6416');

View File

@ -203,7 +203,7 @@ function Edit({
template: [["core/paragraph", {
placeholder: "Ajouter ici le texte"
}]],
allowedBlocks: ["core/heading", "core/paragraph", "core/group", "core/list", "core/button", "core/image", "core/buttons", "core/columns", "core/post-title", "core/embed", "core/quote", "core/pullquote", "core/media-text", "carhop-blocks/heading", "carhop-blocks/decorative-shapes", "acf/statistics-datas", "carhop-blocks/scroll-story-block", "carhop-blocks/cta-group", "ninja-forms/form", "carhop-blocks/localisation-map", "gravityforms/form", "dynamiques-blocks/sitemap", "mailpoet/subscription-form-block", "shortcode"]
allowedBlocks: ["core/heading", "core/paragraph", "core/group", "core/list", "core/button", "core/image", "core/buttons", "core/columns", "core/post-title", "core/embed", "core/quote", "core/pullquote", "core/media-text", "carhop-blocks/heading", "carhop-blocks/decorative-shapes", "acf/statistics-datas", "carhop-blocks/scroll-story-block", "carhop-blocks/cta-group", "carhop-blocks/audio-player", "ninja-forms/form", "carhop-blocks/localisation-map", "gravityforms/form", "dynamiques-blocks/sitemap", "mailpoet/subscription-form-block", "shortcode"]
})
})
})]

File diff suppressed because one or more lines are too long

View File

@ -170,6 +170,7 @@ export default function Edit({ attributes, setAttributes, ...props }) {
"acf/statistics-datas",
"carhop-blocks/scroll-story-block",
"carhop-blocks/cta-group",
"carhop-blocks/audio-player",
"ninja-forms/form",
"carhop-blocks/localisation-map",
"gravityforms/form",