'Version']); $plugin_version = $plugin_data['Version']; wp_enqueue_style( 'shift-styles', plugin_dir_url(__FILE__) . 'admin/css/shift-styles.css', [], $plugin_version ); $user_id = get_current_user_id(); $columns = get_user_meta($user_id, 'shift_layout_columns', true) ?: 2; $custom_css = '#wpbody-content .metabox-holder { display: flex; flex-direction: row; flex-wrap: wrap; align-content: flex-start; justify-content: flex-start; align-items: flex-start; gap: 10px; padding: 10px; }'; // Base styles for postbox-container switch ($columns) { case 1: $custom_css .= '#dashboard-widgets .postbox-container { width: 100%!important; flex-grow: 1!important; }'; break; case 2: $custom_css .= '#dashboard-widgets .postbox-container { width: 45%!important; flex-grow: 1!important; }'; break; case 3: $custom_css .= '#dashboard-widgets .postbox-container { width: 30%!important; flex-grow: 1!important; }'; break; case 4: $custom_css .= '#dashboard-widgets .postbox-container { width: 22%!important; flex-grow: 1!important; }'; break; } // Media queries respecting column selection $custom_css .= '@media only screen and (min-width: 1200px) and (max-width: 1499px) {'; switch ($columns) { case 1: $custom_css .= '#dashboard-widgets .postbox-container { width: 100%!important; }'; break; case 2: $custom_css .= '#dashboard-widgets .postbox-container { width: 45%!important; }'; break; case 3: $custom_css .= '#dashboard-widgets .postbox-container { width: 30%!important; flex-grow: 1!important; }'; break; case 4: $custom_css .= '#dashboard-widgets .postbox-container { width: 30%!important; flex-grow: 1!important; }'; break; } $custom_css .= '}'; $custom_css .= '@media only screen and (min-width: 800px) and (max-width: 1199px) {'; switch ($columns) { case 1: $custom_css .= '#dashboard-widgets .postbox-container { width: 100%!important; }'; break; case 2: $custom_css .= '#dashboard-widgets .postbox-container { width: 45%!important; }'; break; case 3: $custom_css .= '#dashboard-widgets .postbox-container { width: 45%!important; flex-grow: 1!important; }'; break; case 4: $custom_css .= '#dashboard-widgets .postbox-container { width: 45%!important; flex-grow: 1!important; }'; break; } $custom_css .= '}'; $custom_css .= '@media only screen and (max-width: 799px) {'; switch ($columns) { case 1: case 2: case 3: case 4: $custom_css .= '#dashboard-widgets .postbox-container { width: 100%!important; }'; break; } $custom_css .= '}'; wp_add_inline_style('shift-styles', $custom_css); wp_enqueue_script( 'shift-scripts', plugin_dir_url(__FILE__) . 'admin/js/shift-scripts.js', [], $plugin_version, // Dynamic version true ); wp_localize_script('shift-scripts', 'shift_vars', [ 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('shift_save_layout'), ]); } add_action('admin_enqueue_scripts', 'shift_enqueue_scripts');