コード例 #1
0
/**
 * Disable the infinite footer for Android devices, as it causes a browser crash
 * See http://wp.me/p2jjvm-qh
 *
 * @param array $settings
 * @uses Jetpack_User_Agent_Info
 * @filter infinite_scroll_settings
 * @return array
 */
function infinite_scroll_filter_settings($settings)
{
    $ua_info = new Jetpack_User_Agent_Info();
    if ($ua_info->is_android()) {
        $settings['footer'] = false;
    }
    return $settings;
}
コード例 #2
0
ファイル: jetpack.php プロジェクト: double360/wordpress
/**
 * Check whether or not footer widgets are present. If they are present, then a button to
 * 'Load more posts' will be displayed and IS will not be triggered unless a user manually clicks on that button.
 *
 * @param bool $has_widgets
 * @uses Jetpack_User_Agent_Info::is_ipad, jetpack_is_mobile, is_active_sidebar
 * @filter infinite_scroll_has_footer_widgets
 * @return bool
 */
function encounters_lite_has_footer_widgets($has_widgets)
{
    if ((Jetpack_User_Agent_Info::is_ipad() || function_exists('jetpack_is_mobile') && jetpack_is_mobile()) && is_active_sidebar('bottom1')) {
        $has_widgets = true;
    }
    return $has_widgets;
}
コード例 #3
0
/**
 * Check whether or not footer widgets are present. If they are present, then a button to
 * 'Load more posts' will be displayed and Infinite Scroll will not be triggered unless a user manually clicks on that button.
 *
 * @param bool $has_widgets
 * @uses Jetpack_User_Agent_Info::is_ipad, jetpack_is_mobile, is_active_sidebar
 * @filter infinite_scroll_has_footer_widgets
 * @return bool
 */
function tinyframework_has_footer_widgets($has_widgets)
{
    if ((Jetpack_User_Agent_Info::is_ipad() || function_exists('jetpack_is_mobile') && jetpack_is_mobile()) && is_active_sidebar('sidebar-1')) {
        $has_widgets = true;
    }
    return $has_widgets;
}
コード例 #4
0
ファイル: twentyfourteen.php プロジェクト: kanei/vantuch.cz
 function twentyfourteen_has_footer_widgets($has_widgets)
 {
     if (Jetpack_User_Agent_Info::is_ipad() && is_active_sidebar('sidebar-1') || jetpack_is_mobile('', true) && (is_active_sidebar('sidebar-1') || is_active_sidebar('sidebar-2')) || is_active_sidebar('sidebar-3')) {
         return true;
     }
     return $has_widgets;
 }
コード例 #5
0
function wpcom_vip_disable_lazyload_on_mobile($enabled)
{
    if (function_exists('jetpack_is_mobile') && jetpack_is_mobile()) {
        $enabled = false;
    }
    if (class_exists('Jetpack_User_Agent_Info') && Jetpack_User_Agent_Info::is_ipad()) {
        $enabled = false;
    }
    return $enabled;
}
コード例 #6
0
ファイル: jetpack.php プロジェクト: kokothecoder/p2-breathe
/**
 * 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));
}
コード例 #7
0
 static function init()
 {
     add_action('switch_theme', array(__CLASS__, 'reset'));
     add_action('wp_restore_post_revision', array(__CLASS__, 'restore_revision'), 10, 2);
     // Save revisions for posts of type safecss.
     add_filter('revision_redirect', array(__CLASS__, 'revision_redirect'));
     // Override the edit link, the default link causes a redirect loop
     add_filter('get_edit_post_link', array(__CLASS__, 'revision_post_link'), 10, 3);
     // Overwrite the content width global variable if one is set in the custom css
     add_action('template_redirect', array(__CLASS__, 'set_content_width'));
     add_action('admin_init', array(__CLASS__, 'set_content_width'));
     if (!is_admin()) {
         add_filter('stylesheet_uri', array(__CLASS__, 'style_filter'));
     }
     define('SAFECSS_USE_ACE', !jetpack_is_mobile() && !Jetpack_User_Agent_Info::is_ipad() && apply_filters('safecss_use_ace', true));
     // Register safecss as a custom post_type
     // Explicit capability definitions are largely unnecessary because the posts are manipulated in code via an options page, managing CSS revisions does check the capabilities, so let's ensure that the proper caps are checked.
     register_post_type('safecss', array('supports' => array('revisions'), 'label' => 'Custom CSS', 'can_export' => false, 'rewrite' => false, 'capabilities' => array('edit_post' => 'edit_theme_options', 'read_post' => 'read', 'delete_post' => 'edit_theme_options', 'edit_posts' => 'edit_theme_options', 'edit_others_posts' => 'edit_theme_options', 'publish_posts' => 'edit_theme_options', 'read_private_posts' => 'read')));
     // Short-circuit WP if this is a CSS stylesheet request
     if (isset($_GET['custom-css'])) {
         header('Content-Type: text/css', true, 200);
         header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
         // 1 year
         Jetpack_Custom_CSS::print_css();
         exit;
     }
     add_action('admin_enqueue_scripts', array('Jetpack_Custom_CSS', 'enqueue_scripts'));
     if (isset($_GET['page']) && 'editcss' == $_GET['page'] && is_admin()) {
         // Do migration routine if necessary
         Jetpack_Custom_CSS::upgrade();
         do_action('safecss_migrate_post');
     }
     add_action('wp_head', array('Jetpack_Custom_CSS', 'link_tag'), 101);
     add_filter('jetpack_content_width', array('Jetpack_Custom_CSS', 'jetpack_content_width'));
     add_filter('editor_max_image_size', array('Jetpack_Custom_CSS', 'editor_max_image_size'), 10, 3);
     if (!current_user_can('switch_themes') && !is_super_admin()) {
         return;
     }
     add_action('admin_menu', array('Jetpack_Custom_CSS', 'menu'));
     if (isset($_POST['safecss']) && false == strstr($_SERVER['REQUEST_URI'], 'options.php')) {
         check_admin_referer('safecss');
         $save_result = self::save(array('css' => stripslashes($_POST['safecss']), 'is_preview' => isset($_POST['action']) && $_POST['action'] == 'preview', 'preprocessor' => isset($_POST['custom_css_preprocessor']) ? $_POST['custom_css_preprocessor'] : '', 'add_to_existing' => isset($_POST['add_to_existing']) ? $_POST['add_to_existing'] == 'true' : true, 'content_width' => isset($_POST['custom_content_width']) ? $_POST['custom_content_width'] : false));
         if ($_POST['action'] == 'preview') {
             wp_safe_redirect(add_query_arg('csspreview', 'true', get_option('home')));
             exit;
         }
         if ($save_result) {
             add_action('admin_notices', array('Jetpack_Custom_CSS', 'saved_message'));
         }
     }
     // Modify all internal links so that preview state persists
     if (Jetpack_Custom_CSS::is_preview()) {
         ob_start(array('Jetpack_Custom_CSS', 'buffer'));
     }
 }
コード例 #8
0
 /**
  * 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);
 }
コード例 #9
0
function jetpack_is_mobile($kind = 'any', $return_matched_agent = false)
{
    static $kinds = array('smart' => false, 'dumb' => false, 'any' => false);
    static $first_run = true;
    static $matched_agent = '';
    $ua_info = new Jetpack_User_Agent_Info();
    if (empty($_SERVER['HTTP_USER_AGENT']) || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'ipad')) {
        return false;
    }
    if ($ua_info->is_android_tablet() && $ua_info->is_kindle_touch() === false) {
        return false;
    }
    if ($ua_info->is_blackberry_tablet()) {
        return false;
    }
    if ($first_run) {
        $first_run = false;
        //checks for iPhoneTier devices & RichCSS devices
        if ($ua_info->isTierIphone() || $ua_info->isTierRichCSS()) {
            $kinds['smart'] = true;
            $matched_agent = $ua_info->matched_agent;
        }
        if (!$kinds['smart']) {
            // if smart, we are not dumb so no need to check
            $dumb_agents = $ua_info->dumb_agents;
            $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
            foreach ($dumb_agents as $dumb_agent) {
                if (false !== strpos($agent, $dumb_agent)) {
                    $kinds['dumb'] = true;
                    $matched_agent = $dumb_agent;
                    break;
                }
            }
            if (!$kinds['dumb']) {
                if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) {
                    $kinds['dumb'] = true;
                    $matched_agent = 'http_x_wap_profile';
                } elseif (isset($_SERVER['HTTP_ACCEPT']) && (preg_match('/wap\\.|\\.wap/i', $_SERVER['HTTP_ACCEPT']) || false !== strpos(strtolower($_SERVER['HTTP_ACCEPT']), 'application/vnd.wap.xhtml+xml'))) {
                    $kinds['dumb'] = true;
                    $matched_agent = 'vnd.wap.xhtml+xml';
                }
            }
        }
        if ($kinds['dumb'] || $kinds['smart']) {
            $kinds['any'] = true;
        }
    }
    if ($return_matched_agent) {
        return $matched_agent;
    }
    return $kinds[$kind];
}
コード例 #10
0
ファイル: custom-css.php プロジェクト: pcuervo/wp-carnival
 static function init()
 {
     add_action('switch_theme', array(__CLASS__, 'reset'));
     add_action('wp_restore_post_revision', array(__CLASS__, 'restore_revision'), 10, 2);
     // Save revisions for posts of type safecss.
     add_action('load-revision.php', array(__CLASS__, 'add_revision_redirect'));
     // Override the edit link, the default link causes a redirect loop
     add_filter('get_edit_post_link', array(__CLASS__, 'revision_post_link'), 10, 3);
     // Overwrite the content width global variable if one is set in the custom css
     add_action('template_redirect', array(__CLASS__, 'set_content_width'));
     add_action('admin_init', array(__CLASS__, 'set_content_width'));
     if (!is_admin()) {
         add_filter('stylesheet_uri', array(__CLASS__, 'style_filter'));
     }
     define('SAFECSS_USE_ACE', !jetpack_is_mobile() && !Jetpack_User_Agent_Info::is_ipad() && apply_filters('safecss_use_ace', true));
     // Register safecss as a custom post_type
     // Explicit capability definitions are largely unnecessary because the posts are manipulated in code via an options page, managing CSS revisions does check the capabilities, so let's ensure that the proper caps are checked.
     register_post_type('safecss', array('supports' => array('revisions'), 'label' => 'Custom CSS', 'can_export' => false, 'rewrite' => false, 'capabilities' => array('edit_post' => 'edit_theme_options', 'read_post' => 'read', 'delete_post' => 'edit_theme_options', 'edit_posts' => 'edit_theme_options', 'edit_others_posts' => 'edit_theme_options', 'publish_posts' => 'edit_theme_options', 'read_private_posts' => 'read')));
     // Short-circuit WP if this is a CSS stylesheet request
     if (isset($_GET['custom-css'])) {
         header('Content-Type: text/css', true, 200);
         header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
         // 1 year
         Jetpack_Custom_CSS::print_css();
         exit;
     }
     add_action('admin_enqueue_scripts', array('Jetpack_Custom_CSS', 'enqueue_scripts'));
     if (isset($_GET['page']) && 'editcss' == $_GET['page'] && is_admin()) {
         // Do migration routine if necessary
         Jetpack_Custom_CSS::upgrade();
         /**
          * Allows additional work when migrating safecss from wp_options to wp_post.
          *
          * @module custom-css
          *
          * @since 1.7.0
          */
         do_action('safecss_migrate_post');
     }
     /**
      * Never embed the style in the head on wpcom.
      * Yes, this filter should be added to an unsynced file on wpcom, but
      * there is no good syntactically-correct location to put it yet.
      * @link https://github.com/Automattic/jetpack/commit/a1be114e9179f64d147124727a58e2cf76c7e5a1#commitcomment-7763921
      */
     if (defined('IS_WPCOM') && IS_WPCOM) {
         add_filter('safecss_embed_style', '__return_false');
     } else {
         add_filter('safecss_embed_style', array('Jetpack_Custom_CSS', 'should_we_inline_custom_css'), 10, 2);
     }
     add_action('wp_head', array('Jetpack_Custom_CSS', 'link_tag'), 101);
     add_filter('jetpack_content_width', array('Jetpack_Custom_CSS', 'jetpack_content_width'));
     add_filter('editor_max_image_size', array('Jetpack_Custom_CSS', 'editor_max_image_size'), 10, 3);
     if (!current_user_can('switch_themes') && !is_super_admin()) {
         return;
     }
     add_action('admin_menu', array('Jetpack_Custom_CSS', 'menu'));
     if (isset($_POST['safecss']) && false == strstr($_SERVER['REQUEST_URI'], 'options.php')) {
         check_admin_referer('safecss');
         $save_result = self::save(array('css' => stripslashes($_POST['safecss']), 'is_preview' => isset($_POST['action']) && $_POST['action'] == 'preview', 'preprocessor' => isset($_POST['custom_css_preprocessor']) ? $_POST['custom_css_preprocessor'] : '', 'add_to_existing' => isset($_POST['add_to_existing']) ? $_POST['add_to_existing'] == 'true' : true, 'content_width' => isset($_POST['custom_content_width']) ? $_POST['custom_content_width'] : false));
         if ($_POST['action'] == 'preview') {
             wp_safe_redirect(add_query_arg('csspreview', 'true', get_option('home')));
             exit;
         }
         if ($save_result) {
             add_action('admin_notices', array('Jetpack_Custom_CSS', 'saved_message'));
         }
     }
     // Prevent content filters running on CSS when restoring revisions
     if (isset($_REQUEST['action']) && 'restore' === $_REQUEST['action'] && false !== strstr($_SERVER['REQUEST_URI'], 'revision.php')) {
         $parent_post = get_post(wp_get_post_parent_id(intval($_REQUEST['revision'])));
         if ($parent_post && !is_wp_error($parent_post) && 'safecss' === $parent_post->post_type) {
             // Remove wp_filter_post_kses, this causes CSS escaping issues
             remove_filter('content_save_pre', 'wp_filter_post_kses');
             remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
             remove_all_filters('content_save_pre');
         }
     }
     // Modify all internal links so that preview state persists
     if (Jetpack_Custom_CSS::is_preview()) {
         ob_start(array('Jetpack_Custom_CSS', 'buffer'));
     }
 }
コード例 #11
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'])) {
コード例 #12
0
 /**
  * Was the current request made by a known bot?
  *
  * @return boolean
  */
 static function is_bot()
 {
     static $is_bot = null;
     if (is_null($is_bot)) {
         $is_bot = Jetpack_User_Agent_Info::is_bot_user_agent($_SERVER['HTTP_USER_AGENT']);
     }
     return $is_bot;
 }
コード例 #13
0
ファイル: custom-css.php プロジェクト: lu-inc/growingminds
 static function init()
 {
     add_action('switch_theme', array(__CLASS__, 'reset'));
     add_action('wp_restore_post_revision', array(__CLASS__, 'restore_revision'), 10, 2);
     // Save revisions for posts of type safecss.
     add_filter('revision_redirect', array(__CLASS__, 'revision_redirect'));
     // Override the edit link, the default link causes a redirect loop
     add_filter('get_edit_post_link', array(__CLASS__, 'revision_post_link'), 10, 3);
     if (!is_admin()) {
         add_filter('stylesheet_uri', array(__CLASS__, 'style_filter'));
     }
     define('SAFECSS_USE_ACE', !jetpack_is_mobile() && !Jetpack_User_Agent_Info::is_ipad() && apply_filters('safecss_use_ace', true));
     // Register safecss as a custom post_type
     // Explicit capability definitions are largely unnecessary because the posts are manipulated in code via an options page, managing CSS revisions does check the capabilities, so let's ensure that the proper caps are checked.
     register_post_type('safecss', array('supports' => array('revisions'), 'label' => 'Custom CSS', 'can_export' => false, 'rewrite' => false, 'capabilities' => array('edit_post' => 'edit_theme_options', 'read_post' => 'read', 'delete_post' => 'edit_theme_options', 'edit_posts' => 'edit_theme_options', 'edit_others_posts' => 'edit_theme_options', 'publish_posts' => 'edit_theme_options', 'read_private_posts' => 'read')));
     // Short-circuit WP if this is a CSS stylesheet request
     if (isset($_GET['custom-css'])) {
         header('Content-Type: text/css', true, 200);
         header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
         // 1 year
         Jetpack_Custom_CSS::print_css();
         exit;
     }
     if (isset($_GET['page']) && 'editcss' == $_GET['page'] && is_admin()) {
         // Do migration routine if necessary
         Jetpack_Custom_CSS::upgrade();
         do_action('safecss_migrate_post');
     }
     add_action('wp_head', array('Jetpack_Custom_CSS', 'link_tag'), 101);
     if (!current_user_can('switch_themes') && !is_super_admin()) {
         return;
     }
     add_action('admin_menu', array('Jetpack_Custom_CSS', 'menu'));
     if (isset($_POST['safecss']) && false == strstr($_SERVER['REQUEST_URI'], 'options.php')) {
         check_admin_referer('safecss');
         // Remove wp_filter_post_kses, this causes CSS escaping issues
         remove_filter('content_save_pre', 'wp_filter_post_kses');
         remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
         remove_all_filters('content_save_pre');
         do_action('safecss_save_pre');
         $warnings = array();
         safecss_class();
         $csstidy = new csstidy();
         $csstidy->optimise = new safecss($csstidy);
         $csstidy->set_cfg('remove_bslash', false);
         $csstidy->set_cfg('compress_colors', false);
         $csstidy->set_cfg('compress_font-weight', false);
         $csstidy->set_cfg('optimise_shorthands', 0);
         $csstidy->set_cfg('remove_last_;', false);
         $csstidy->set_cfg('case_properties', false);
         $csstidy->set_cfg('discard_invalid_properties', true);
         $csstidy->set_cfg('css_level', 'CSS3.0');
         $csstidy->set_cfg('preserve_css', true);
         $csstidy->set_cfg('template', dirname(__FILE__) . '/csstidy/wordpress-standard.tpl');
         $css = $orig = stripslashes($_POST['safecss']);
         $css = preg_replace('/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $prev = $css);
         if ($css != $prev) {
             $warnings[] = 'preg_replace found stuff';
         }
         // Some people put weird stuff in their CSS, KSES tends to be greedy
         $css = str_replace('<=', '&lt;=', $css);
         // Why KSES instead of strip_tags?  Who knows?
         $css = wp_kses_split($prev = $css, array(), array());
         $css = str_replace('&gt;', '>', $css);
         // kses replaces lone '>' with &gt;
         // Why both KSES and strip_tags?  Because we just added some '>'.
         $css = strip_tags($css);
         if ($css != $prev) {
             $warnings[] = 'kses found stuff';
         }
         // if we're not using a preprocessor
         if (!isset($_POST['custom_css_preprocessor']) || empty($_POST['custom_css_preprocessor'])) {
             do_action('safecss_parse_pre', $csstidy, $css);
             $csstidy->parse($css);
             do_action('safecss_parse_post', $csstidy, $warnings);
             $css = $csstidy->print->plain();
         }
         if (isset($_POST['custom_content_width']) && intval($_POST['custom_content_width']) > 0) {
             $custom_content_width = intval($_POST['custom_content_width']);
         } else {
             $custom_content_width = false;
         }
         if ($_POST['add_to_existing'] == 'true') {
             $add_to_existing = 'yes';
         } else {
             $add_to_existing = 'no';
         }
         $preprocessor = isset($_POST['custom_css_preprocessor']) ? $_POST['custom_css_preprocessor'] : '';
         if ($_POST['action'] == 'preview' || Jetpack_Custom_CSS::is_freetrial()) {
             // Save the CSS
             $safecss_revision_id = Jetpack_Custom_CSS::save_revision($css, true, $preprocessor);
             // Cache Buster
             update_option('safecss_preview_rev', intval(get_option('safecss_preview_rev')) + 1);
             update_metadata('post', $safecss_revision_id, 'custom_css_add', $add_to_existing);
             update_metadata('post', $safecss_revision_id, 'content_width', $custom_content_width);
             update_metadata('post', $safecss_revision_id, 'custom_css_preprocessor', $preprocessor);
             if ($_POST['action'] == 'preview') {
                 wp_safe_redirect(add_query_arg('csspreview', 'true', get_option('home')));
                 exit;
             }
             do_action('safecss_save_preview_post');
         }
         // Save the CSS
         $safecss_post_id = Jetpack_Custom_CSS::save_revision($css, false, $preprocessor);
         $safecss_post_revision = Jetpack_Custom_CSS::get_current_revision();
         update_option('safecss_rev', intval(get_option('safecss_rev')) + 1);
         update_post_meta($safecss_post_id, 'custom_css_add', $add_to_existing);
         update_post_meta($safecss_post_id, 'content_width', $custom_content_width);
         update_post_meta($safecss_post_id, 'custom_css_preprocessor', $preprocessor);
         update_metadata('post', $safecss_post_revision['ID'], 'custom_css_add', $add_to_existing);
         update_metadata('post', $safecss_post_revision['ID'], 'content_width', $custom_content_width);
         update_metadata('post', $safecss_post_revision['ID'], 'custom_css_preprocessor', $preprocessor);
         add_action('admin_notices', array('Jetpack_Custom_CSS', 'saved_message'));
     }
     // Modify all internal links so that preview state persists
     if (Jetpack_Custom_CSS::is_preview()) {
         ob_start(array('Jetpack_Custom_CSS', 'buffer'));
     }
 }
コード例 #14
0
ファイル: functions-init.php プロジェクト: srolland/dev
 function postmedia_js_object()
 {
     $postmedia_js = array();
     //$options = postmedia_theme_option();
     $postmedia_js['Urls'] = array('home_url' => home_url(), 'stylesheet_directory_uri' => get_stylesheet_directory_uri(), 'ajaxurl' => home_url('/wp-admin/admin-ajax.php'));
     $postmedia_js['Properties'] = array('domain' => '', 'userAgents' => array('mozilla', 'msie', 'webkit', 'ipad'), 'mobileAgents' => array('iphone', 'ipod', 'android'), 'isMobile' => (bool) (string) jetpack_is_mobile(), 'isIpad' => (bool) (string) Jetpack_User_Agent_Info::is_ipad(), 'isModal' => false);
     /**
      * Ad Code
      */
     global $post;
     /**
      * AdMapper++
      */
     global $postmedia_ad_mapper;
     $ad_slug = '';
     $ad_keys = array('nk' => 'print', 'pr' => 'habsio', 'ck' => 'news');
     /**
      * Determine whether or not it's an index page
      */
     if (is_single() || is_author()) {
         $is_index = false;
     } else {
         $is_index = true;
     }
     if (is_home()) {
         $is_home = true;
     } else {
         $is_home = false;
     }
     if (!is_404()) {
         if (is_singular() || is_author()) {
             if (is_author()) {
                 $ad_keys['page'] = 'index';
                 $ad_keys['author'] = get_the_author_meta('user_nicename');
                 $ad_keys['ck'] = 'author';
                 $ad_keys['sck'] = array($ad_keys['author']);
                 //$ad_keys['imp'] = $ad_keys['sck'][count( $ad_keys['sck'] ) - 1];
             } elseif (is_page()) {
                 $ad_keys['page'] = 'index';
                 $ad_keys['author'] = get_the_author_meta('user_nicename');
                 $ad_keys['ck'] = $postmedia_ad_mapper->page_key;
                 $ad_keys['sck'] = array($ad_keys['author']);
                 //$ad_keys['imp'] = $ad_keys['sck'][count( $ad_keys['sck'] ) - 1];
             } else {
                 // Post
                 $ad_keys['page'] = 'story';
                 $ad_keys['aid'] = get_the_ID();
                 $ad_keys['author'] = get_the_author_meta('user_nicename', $post->post_author);
                 if ('video' == get_post_type($post->ID)) {
                     $ad_keys['page'] = 'video';
                     $ad_keys['ck'] = 'video';
                 }
                 // can't use list pluck because we don't want an associative array
                 $ad_keys['cinf'] = array();
                 if ($tags = get_the_tags()) {
                     foreach ($tags as $tag) {
                         $ad_keys['cinf'][] = $tag->slug;
                     }
                 }
                 // Get IAB tags
                 //$iabs = inform_iabs( get_the_ID(), 0, true );
                 if (!empty($iabs)) {
                     $ad_keys['ciab'] = array();
                     foreach ($iabs as $iab) {
                         $ad_keys['ciab'][] = sanitize_title($iab['label']);
                     }
                     $postmedia_js['Tracking'] = array('iabs' => $iabs, 'tags' => inform_tags(get_the_ID(), 0, true));
                 }
             }
         } else {
             // Index page of some sort
             $ad_keys['page'] = 'index';
             if (is_front_page()) {
                 $ad_keys['ck'] = 'index';
             } else {
                 if (is_category()) {
                     /*
                     $category_mapping = $postmedia_ad_mapper->get_category_map();
                     						$ad_keys['ck'] = array_shift( $category_mapping );
                     						if ( ! empty( $category_mapping ) ) {
                     							$ad_keys['sck'] = $category_mapping;
                     						}
                     */
                 } elseif (is_tag()) {
                     $ad_keys['ck'] = 'tag';
                     $ad_keys['tag'] = get_query_var('tag');
                 }
             }
             if (empty($ad_keys['sck'])) {
                 $ad_keys['imp'] = is_tag() ? $ad_keys['tag'] : $ad_keys['ck'];
             } else {
                 $sck_len = count($ad_keys['sck']);
                 $ad_keys['imp'] = $ad_keys['sck'][$sck_len - 1];
             }
         }
     } else {
         /**
          * 404
          */
         $ad_keys['ck'] = 'error';
         $ad_keys['page'] = 'index';
     }
     $sck = empty($ad_keys['sck']) ? null : $ad_keys['sck'];
     $ad_config_site = true === $is_home ? 'ccn_ind.com' : $postmedia_ad_mapper->get_ad_site($ad_keys['ck'], $sck);
     $postmedia_js['adConfig'] = array('site' => 'mg_habsio.com', 'msite' => 'mg_habsio.m', 'networkId' => 3081, 'keys' => $ad_keys);
     if (is_tag()) {
         $postmedia_js['adConfig']['zone'] = 'tag';
     } else {
         $postmedia_js['adConfig']['zone'] = $ad_keys['ck'];
         if (isset($ad_keys['sck'])) {
             foreach ($ad_keys['sck'] as $sck) {
                 $postmedia_js['adConfig']['zone'] .= '/' . $sck;
             }
         }
     }
     $postmedia_js['adConfig']['keys'] = $this->sort_ad_keys($postmedia_js['adConfig']['keys']);
     if (!is_front_page()) {
         $postmedia_js['adConfig']['zone'] .= '/' . $ad_keys['page'];
     }
     $postmedia_js['Facebook'] = array('pageId' => 'facebook_page_id', 'appId' => 'facebook_app_id');
     if (is_singular() && current_user_can('edit_posts')) {
         $postmedia_js['debug'] = array('post_meta' => get_post_meta(get_the_ID()));
     }
     return $postmedia_js;
 }
コード例 #15
0
function mf_page_redirect_to_app_stores()
{
    if (!is_page('app') && function_exists('jetpack_is_mobile')) {
        return;
    }
    $redirect_to = '';
    if (Jetpack_User_Agent_Info::is_iphone_or_ipod()) {
        $redirect_to = 'https://itunes.apple.com/us/app/maker-faire-the-official-app/id641794889';
    } elseif (Jetpack_User_Agent_Info::is_android()) {
        $redirect_to = 'https://play.google.com/store/apps/details?id=com.xomodigital.makerfaire';
    }
    if (!empty($redirect_to)) {
        wp_redirect($redirect_to, 301);
        // Permanent redirect
        exit;
    }
}
コード例 #16
0
ファイル: o2.php プロジェクト: thecancerus/o2
 public static function is_tablet()
 {
     $is_tablet = class_exists('Jetpack_User_Agent_Info') ? Jetpack_User_Agent_Info::is_tablet() : false;
     return $is_tablet;
 }