Skip to content

Commit

Permalink
don't show wp_block widget for non-admin users (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesros161 authored Mar 15, 2024
1 parent 12d543f commit 34b73cf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions components/class-boldgrid-components-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ protected function add_widget_configs() {
$widgets = $GLOBALS['wp_widget_factory']->widgets;

foreach( $widgets as $classname => $widget ) {
/*
* If the user is not an admin, skip the 'block'
* widget because it allows the users to add
* arbitrary HTML and JavaScript.
*/
if ( ! current_user_can( 'manage_options' ) && 'block' === $widget->id_base ) {
continue;
}

if ( ! in_array( $widget->id_base, $this->config['skipped_widgets'] ) ) {
$name = 'wp_' . $widget->id_base;
$widget_config = $this->create_widget_config( $widget, $classname );
Expand Down

0 comments on commit 34b73cf

Please sign in to comment.