Wordpress get_option on multisite

If you have a plugin and you want to get its global option (ie that are stored into wp_options table, if you are into a blog, get_option retrieve value from wp_$blogid_options)  on multisite installation, you have two solution:


  1. find and replace all get_option into plugin with my_get_option defined in this manner: 
function my_get_option($key) {
if(is_multisite()) {
switch_to_blog(SITE_ID_CURRENT_SITE);
$option = get_option($key);
restore_current_blog();
return $option;
} else {
return get_option($key);
        }
           }

      2. add filters for each option you want to retrieve:

function myoption() {
        if(is_multisite()) {
switch_to_blog(SITE_ID_CURRENT_SITE);
$option = get_option($key);
restore_current_blog();
return $option;
} else {
return get_option($key);
        }
add_filter( 'pre_option_' . $key, 'myoption' );

       

Commenti

  1. Gambling 101: How to Bet at Slots Casinos in Washington State
    With that said, 경상남도 출장안마 it's one thing to know 용인 출장샵 about 평택 출장안마 gambling in 이천 출장샵 the United States 강원도 출장샵 and not to worry about losing a hand if you bet the wrong number on

    RispondiElimina

Posta un commento