In your plugin:
<?php
register_activation_hook(WP_PLUGIN_DIR.'/your/plugin/path/plugin.php', 'wpse_set_subdomain');
function wpse_set_subdomain() {
$siteurl = site_url();
$subdomain = substr($siteurl, 8, 3); // may need to adjust which substring to grab
update_option('wpse_subdomain', $subdomain);
}
?>
Then wherever you have conditional content:
<?php
$subdomain = get_option('wpse_subdomain');
if($subdomain == 'www') {
// www code
} else {
// other code
}
?>
As mentioned in the code comment, you may need to tweak which substring to grab by changing the numbers 8 and 3 (they’ll grab the first 3 letters starting at character 8 in the siteurl).