0

I'm switching a single WordPress site to a WordPress Multisite. I'm maintaining some post meta boxes with custom fields, and some front-end forms, where I maintained some features like maximum upload size for media library uploads, and restricted to some specific file types, using some third party plugins.

While switching to multisite, I noticed that the features are implemented by core per blog. I loved that. As it's functioning properly, I need to get those value from database, so that I can warn my users about the accepted file types and maximum upload limit per file in a tooltip or in an instruction field.

I know I can do this easily using $wpdb, but is there any default functions, that can facilitate me fetching the data easily?

0

Yes, you can easily grab those multisite values from database using an MU (μ) Function: get_site_option()

Getting Fields

Maximum Upload Size

The maximum upload size, per site (NOT per blog), per file can be found using:

$max_up = get_site_option('fileupload_maxk');
var_dump($max_up); //in kilobytes

Accepted File Types

The accepted file types per site (NOT per blog) can be found using:

$aft = get_site_option('upload_filetypes');
var_dump($aft); //space separated values

//values in an array :)
$aft_array = explode( ' ', $aft );
var_dump($aft);

Under the hood

The values are stored in WordPress multisite database, in sitemeta (can be wp_sitemeta) table, just like any other meta table, using a meta_id, meta_key and meta_value. But as it's site specific (NOT blog specific), so the site_id is also stored.

Why site_id? Please refer to the #3 link of References.

References:

  1. MU (μ) Functions - WordPress Codex
  2. get_site_option() - WordPress Codex - for additional $keys
  3. Wordpress: difference between site_id and blog_id? - StackOverflow

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.