Minor correction: Or maybe store the setting in the database and not the cookie.
Something like:
$comm->query(sprintf("INSERT INTO %st_osp_settings VALUES ('osp', 'admindash_widgets_collapsed', '', 'STRING')", DB_TABLE_PREFIX));
case 'osp_widget':
$collapse = Params::getParam('collapse');
$widget_id = Params::getParam('widgetId');
$data = osc_get_preference('admindash_widgets_collapsed', 'osclass');
$data = array_filter(explode(',', $data));
if($collapse == 1) {
$data[] = $widget_id;
} else {
if (($key = array_search($widget_id, $data)) !== false) {
unset($data[$key]);
}
}
$data = array_map('trim', array_unique(array_filter($data)));
$data = implode(',', $data);
osc_set_preference('admindash_widgets_collapsed', $data);
echo $data;
break;
default:
echo json_encode(array('error' => __('no action defined')));
break;
function osc_admin_widget_collapsed($id) {
$collapsed_widgets = explode(',', osc_get_preference('admindash_widgets_collapsed', 'osclass'));
if(in_array($id, $collapsed_widgets)) {
return true;
}
return false;
}
<i class="fa fa-caret-<?php echo (osc_admin_widget_collapsed('glance') ? 'down' : 'up'); ?> collapse" title="<?php echo osc_esc_html(__('Collapse')); ?>"></i>