/** * Screen option value. * * @since 141111 First documented version. * * @param \WP_Screen $screen A screen object instance. * @param string $option The screen option to get. * @param int $user_id A specific user ID. Defaults to `NULL`. * A `NULL` value indicates the current user. * * @return mixed The screen option value; only if not empty; and only it has a valid data type. * If empty, or not the same data type as the default value; returns the default value. */ public function screenOption(\WP_Screen $screen, $option, $user_id = null) { $user_id = $this->issetOr($user_id, (int) get_current_user_id(), 'integer'); $value = get_user_meta($user_id, $screen->get_option($option, 'option'), true); $default_value = $screen->get_option($option, 'default'); if (!$value || gettype($value) !== gettype($default_value)) { $value = $default_value; } return $value; }