} } //Business Open/Closed if (business_open()) { $business_open = 'During Business Hours'; echo 'clientinfo.businessopen = true;'; } else { $business_open = 'Non-Business Hours'; echo 'clientinfo.businessopen = false;'; } if (nebula_option('nebula_cd_businesshours')) { echo 'ga("set", gaCustomDimensions["businessHours"], "' . $business_open . '");'; } //Relative time ("Late Morning", "Early Evening") if (nebula_option('nebula_cd_relativetime')) { $relative_time = nebula_relative_time(); $time_description = implode(' ', $relative_time['description']); $time_range = $relative_time['standard'][0] . ':00' . $relative_time['ampm'] . ' - ' . $relative_time['standard'][2] . ':59' . $relative_time['ampm']; echo 'ga("set", gaCustomDimensions["relativeTime"], "' . ucwords($time_description) . ' (' . $time_range . ')");'; } //Session ID if (nebula_option('nebula_cd_sessionid')) { $session_info = is_debug() ? 'Dbg.' : ''; $session_info .= nebula_is_option_enabled('wireframing') ? 'Wr.' : ''; if (is_client()) { $session_info .= 'Cl.'; } elseif (is_dev()) { $session_info .= 'Dv.'; } $session_info .= is_user_logged_in() ? 'Li.' : ''; $session_info .= nebula_is_bot() ? 'Bt.' : '';
function nebula_body_classes($classes) { $spaces_and_dots = array(' ', '.'); $underscores_and_hyphens = array('_', '-'); //Device $classes[] = strtolower(nebula_get_device('full')); //Device make and model $classes[] = strtolower(str_replace($spaces_and_dots, $underscores_and_hyphens, nebula_get_os('full'))); //Operating System name with version $classes[] = strtolower(str_replace($spaces_and_dots, $underscores_and_hyphens, nebula_get_os('name'))); //Operating System name $classes[] = strtolower(str_replace($spaces_and_dots, $underscores_and_hyphens, nebula_get_browser('full'))); //Browser name and version $classes[] = strtolower(str_replace($spaces_and_dots, $underscores_and_hyphens, nebula_get_browser('name'))); //Browser name $classes[] = strtolower(str_replace($spaces_and_dots, $underscores_and_hyphens, nebula_get_browser('engine'))); //Rendering engine //User Information $current_user = wp_get_current_user(); if (is_user_logged_in()) { $classes[] = 'user-' . $current_user->user_login; $user_info = get_userdata(get_current_user_id()); $classes[] = 'user-role-' . $user_info->roles[0]; } //Post Information if (!is_search() && !is_archive() && !is_front_page()) { global $post; $segments = explode('/', trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/')); $parents = get_post_ancestors($post->ID); foreach ($parents as $parent) { if (!empty($parent)) { $classes[] = 'ancestor-id-' . $parent; } } foreach ($segments as $segment) { if (!empty($segment)) { $classes[] = 'ancestor-of-' . $segment; } } foreach (get_the_category($post->ID) as $category) { $classes[] = 'cat-' . $category->cat_ID . '-id'; } } $nebula_theme_info = wp_get_theme(); $classes[] = 'nebula'; $classes[] = 'nebula_' . str_replace('.', '-', $nebula_theme_info->get('Version')); //Time of Day $classes[] = business_open() ? 'business-open' : 'business-closed'; $relative_time = nebula_relative_time('description'); foreach ($relative_time as $relative_desc) { $classes[] = 'time-' . $relative_desc; } if (date('H') >= 12) { $classes[] = 'time-pm'; } else { $classes[] = 'time-am'; } if (get_option('nebula_latitude') && get_option('nebula_longitude')) { $lat = get_option('nebula_latitude'); $lng = get_option('nebula_longitude'); $gmt = intval(get_option('gmt_offset')); $zenith = 90 + 50 / 60; //Civil twilight = 96°, Nautical twilight = 102°, Astronomical twilight = 108° $sunrise = strtotime(date_sunrise(strtotime('today'), SUNFUNCS_RET_STRING, $lat, $lng, $zenith, $gmt)); $sunset = strtotime(date_sunset(strtotime('today'), SUNFUNCS_RET_STRING, $lat, $lng, $zenith, $gmt)); if (time() >= $sunrise && time() <= $sunset) { $classes[] = 'time-daylight'; } else { $classes[] = 'time-darkness'; } if (strtotime('now') >= $sunrise - 60 * 45 && strtotime('now') <= $sunrise + 60 * 45) { //45 minutes before and after true sunrise $classes[] = 'time-sunrise'; } if (strtotime('now') >= $sunset - 60 * 45 && strtotime('now') <= $sunset + 60 * 45) { //45 minutes before and after true sunset $classes[] = 'time-sunset'; } } $classes[] = 'date-day-' . strtolower(date('l')); $classes[] = 'date-ymd-' . strtolower(date('Y-m-d')); $classes[] = 'date-month-' . strtolower(date('F')); if ($GLOBALS['http'] && is_int($GLOBALS['http'])) { $classes[] = 'error' . $GLOBALS['http']; } return $classes; }
$word_count_range = '1,000 - 1,499 words'; } elseif ($word_count < 2000) { $word_count_range = '1,500 - 1,999 words'; } else { $word_count_range = '2,000+ words'; } } echo 'ga("set", gaCustomDimensions["wordCount"], "' . $word_count_range . '");'; } } if (nebula_option('nebula_cd_businesshours')) { $business_open = business_open() ? 'During Business Hours' : 'Non-Business Hours'; echo 'ga("set", gaCustomDimensions["businessHours"], "' . $business_open . '");'; } if (nebula_option('nebula_cd_relativetime')) { $relative_time = implode(' ', nebula_relative_time()); echo 'ga("set", gaCustomDimensions["relativeTime"], "' . ucwords($relative_time) . '");'; } if (nebula_option('nebula_cd_sessionid')) { $session_info = is_debug() ? 'Dbg.' : ''; $session_info .= nebula_is_option_enabled('wireframing') ? 'Wr.' : ''; if (is_client()) { $session_info .= 'Cl.'; } elseif (is_dev()) { $session_info .= 'Dv.'; } $session_info .= is_user_logged_in() ? 'Li.' : ''; $session_info .= nebula_is_bot() ? 'Bt.' : ''; echo 'var sessionID = new Date().getTime() + ".' . $session_info . '" + Math.random().toString(36).substring(5);'; echo 'ga("set", gaCustomDimensions["sessionID"], sessionID);'; }