Ejemplo n.º 1
0
/**
 * Add theme support for Infinite Scroll.
 * See: http://jetpack.me/support/infinite-scroll/
 */
function breathe_infinite_scroll_setup()
{
    $footer = 'main';
    $is_tablet = class_exists('Jetpack_User_Agent_Info') ? Jetpack_User_Agent_Info::is_tablet() : false;
    if ($is_tablet) {
        // don't show the infinite scroll footer on tablet devices (infinite scroll will still work)
        $footer = false;
    }
    add_theme_support('infinite-scroll', array('container' => 'content', 'footer' => $footer));
}
 /**
  * Eliminates widows in strings by replace the breaking space that appears before the last word with a non-breaking space.
  *
  * This function is defined on WordPress.com and can be a common source of frustration for VIP devs.
  * Now they can be frustrated in their local environments as well :)
  *
  * @param string $str Optional. String to operate on.
  * @return string
  * @link http://www.shauninman.com/post/heap/2006/08/22/widont_wordpress_plugin Typesetting widows
  */
 function widont($str = '')
 {
     // Don't apply on non-tablet mobile devices so the browsers can fit to the viewport properly.
     if (function_exists('jetpack_is_mobile') && jetpack_is_mobile() && class_exists('Jetpack_User_Agent_Info') && !Jetpack_User_Agent_Info::is_tablet()) {
         return $str;
     }
     // We're dealing with whitespace from here out, let's not have any false positives. :)
     $str = trim($str);
     // If string contains three or fewer words, don't join.
     if (count(preg_split('#\\s+#', $str)) <= 3) {
         return $str;
     }
     // Don't join if words exceed a certain length: minimum 10 characters, default 15 characters, filterable via `widont_max_word_length`.
     $widont_max_word_length = max(10, absint(apply_filters('widont_max_word_length', 15)));
     $regex = '#\\s+([^\\s]{1,' . $widont_max_word_length . '})\\s+([^\\s]{1,' . $widont_max_word_length . '})$#';
     return preg_replace($regex, ' $1&nbsp;$2', $str);
 }
Ejemplo n.º 3
0
    $batcache['unique']['mobile'] = 'dumb';
} elseif (in_array(jetpack_is_mobile('smart', true), array('iphone', 'ipod'))) {
    $batcache['unique']['mobile'] = 'iphone';
} elseif (jetpack_is_mobile('smart')) {
    $batcache['unique']['mobile'] = 'smart';
} elseif (jetpack_is_mobile('dumb')) {
    $batcache['unique']['mobile'] = 'dumb';
}
// iPad
if (Jetpack_User_Agent_Info::is_ipad()) {
    if (false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari')) {
        $batcache['unique']['ipad'] = 'ipad-safari';
    } else {
        $batcache['unique']['ipad'] = 'ipad';
    }
} elseif (Jetpack_User_Agent_Info::is_tablet()) {
    // Tablets
    // Should be treated differently from mobile and iPad
    $batcache['unique']['tablet'] = 'tablet';
}
// UppSite / MySiteApp
if (isset($_SERVER['HTTP_USER_AGENT']) && false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mysiteapp') || isset($_COOKIE['uppsite_theme_select'])) {
    $batcache['max_age'] = 0;
}
// disable batcache
// Chrome Frame
if (isset($_SERVER['HTTP_USER_AGENT']) && false !== strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chromeframe')) {
    $batcache['unique']['chromeframe'] = true;
}
// Liveblog
if (preg_match('%__liveblog_\\d+/\\d+/\\d+|/liveblog/\\d+/\\d+/?$%', $_SERVER['REQUEST_URI'])) {
Ejemplo n.º 4
0
 public static function is_tablet()
 {
     $is_tablet = class_exists('Jetpack_User_Agent_Info') ? Jetpack_User_Agent_Info::is_tablet() : false;
     return $is_tablet;
 }