Habari\AdminThemesHandler::ajax_delete_block PHP Method

ajax_delete_block() public method

Called from the themes page to delete a block instance
public ajax_delete_block ( mixed $handler_vars )
$handler_vars mixed
    public function ajax_delete_block($handler_vars)
    {
        Utils::check_request_method(array('POST'));
        $this->setup_admin_theme('');
        $block_id = $_POST['block_id'];
        $block = DB::get_row('SELECT b.* FROM {blocks} b WHERE id = :block_id', array('block_id' => $block_id), 'Block');
        if ($block->delete()) {
            $msg = json_encode(_t('Deleted block "%1s" of type "%2s".', array($block->title, $block->type)));
        } else {
            $msg = json_encode(_t('Failed to delete block "%1s" of type "%2s".', array($block->title, $block->type)));
        }
        $this->prepare_block_list();
        $this->theme->active_theme = Themes::get_active_data(true);
        $this->display('block_instances');
        echo '<script type="text/javascript">
			human_msg.display_msg(' . $msg . ');
			spinner.stop();
			themeManage.change_scope();
		</script>';
    }