new text editor block that contains core blocks as inner blocks and prevents them from being used at top level
This commit is contained in:
@@ -15,6 +15,7 @@ class Dynamic
|
||||
add_filter('acf/load_field/name=fontawesome_regular', [ $this, 'load_fontawesome_regular_icons' ]);
|
||||
add_filter('acf/load_field/name=fontawesome_solid', [ $this, 'load_fontawesome_solid_icons' ]);
|
||||
add_filter('acf/load_field/name=fontawesome_brands', [ $this, 'load_fontawesome_brand_icons' ]);
|
||||
add_action('acf/input/admin_footer', [$this, 'colour_ui'] );
|
||||
}
|
||||
|
||||
public function load_colours( $field )
|
||||
@@ -98,5 +99,43 @@ class Dynamic
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
public function colour_ui()
|
||||
{ ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
console.log("Script loaded from sage/app/ACF/Dynamic.php");
|
||||
|
||||
(function($) {
|
||||
|
||||
function my_custom_escaping_method( original_value){
|
||||
return original_value;
|
||||
}
|
||||
|
||||
acf.add_filter('select2_escape_markup', function( escaped_value, original_value, $select, settings, field, instance ){
|
||||
console.log(field.data('name'));
|
||||
|
||||
const whitelist = [
|
||||
'colour',
|
||||
'bg_colour',
|
||||
'angle_colour',
|
||||
'fontawesome_brands',
|
||||
];
|
||||
|
||||
// do something to the original_value to override the default escaping, then return it.
|
||||
// this value should still have some kind of escaping for security, but you may wish to allow specific HTML.
|
||||
if (whitelist.includes(field.data( 'name' ))) {
|
||||
return my_custom_escaping_method( original_value );
|
||||
}
|
||||
|
||||
// return
|
||||
return escaped_value;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
|
||||
<?php }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin;
|
||||
use Blocks\Content;
|
||||
use Blocks\Editor;
|
||||
|
||||
class Blocks
|
||||
{
|
||||
@@ -146,9 +146,9 @@ class Blocks
|
||||
'core/social-links',
|
||||
];
|
||||
|
||||
$Content = new Content\Content();
|
||||
$Editor = new Editor\Editor();
|
||||
|
||||
$blacklist = array_diff($blacklist, $Content->inner_blocks());
|
||||
$blacklist = array_diff($blacklist, $Editor->inner_blocks());
|
||||
|
||||
return array_values( array_diff( $blocks, $blacklist ) );
|
||||
}
|
||||
|
||||
@@ -46,6 +46,16 @@ add_filter('admin_head', function () {
|
||||
])->toHtml();
|
||||
});
|
||||
|
||||
add_action( 'enqueue_block_editor_assets', function(){
|
||||
wp_enqueue_script(
|
||||
'restrict-core-blocks',
|
||||
Vite::asset('resources/js/admin/block-restrictions.js'),
|
||||
array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-blocks', 'wp-hooks' ),
|
||||
'v1.0.0',
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Use the generated theme.json file.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user