Exemple #1
0
 function landscape_has_footer_widgets()
 {
     if (jetpack_is_mobile('', true) && is_active_sidebar('sidebar-1')) {
         return true;
     }
     return false;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 function penscratch_has_footer_widgets()
 {
     if (has_nav_menu('social') || jetpack_is_mobile('', true) && is_active_sidebar('sidebar-1')) {
         return true;
     }
     return false;
 }
Exemple #4
0
 function panel_has_footer_widgets()
 {
     if (is_active_sidebar('footer-sidebar-1') || is_active_sidebar('footer-sidebar-2') || is_active_sidebar('footer-sidebar-3') || is_active_sidebar('sidebar-1') && jetpack_is_mobile('', true)) {
         return true;
     }
     return false;
 }
Exemple #5
0
 function oriental_infinite_scroll_has_footer_widgets()
 {
     if (function_exists('jetpack_is_mobile') && jetpack_is_mobile('', true) && is_active_sidebar('sidebar-1')) {
         return true;
     }
     return false;
 }
/**
 * 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;
}
Exemple #7
0
function jetpack_check_mobile()
{
    if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST || defined('APP_REQUEST') && APP_REQUEST) {
        return false;
    }
    if (!isset($_SERVER["HTTP_USER_AGENT"]) || isset($_COOKIE['akm_mobile']) && $_COOKIE['akm_mobile'] == 'false') {
        return false;
    }
    if (jetpack_mobile_exclude()) {
        return false;
    }
    if (1 == get_option('wp_mobile_disable')) {
        return false;
    }
    if (isset($_COOKIE['akm_mobile']) && $_COOKIE['akm_mobile'] == 'true') {
        return true;
    }
    $is_mobile = jetpack_is_mobile();
    /**
     * Filter the Mobile check results.
     *
     * @module minileven
     *
     * @since 1.8.0
     *
     * @param bool $is_mobile Is the reader on a mobile device.
     */
    return apply_filters('jetpack_check_mobile', $is_mobile);
}
Exemple #8
0
 function harmonic_infinite_scroll_has_footer_widgets()
 {
     if (jetpack_is_mobile('', true) && is_active_sidebar('sidebar-1')) {
         return true;
     }
     return false;
 }
function sorbet_infinite_scroll_footer_widgets()
{
    if (has_nav_menu('secondary') || jetpack_is_mobile() && is_active_sidebar('sidebar-1')) {
        return true;
    }
    return false;
}
Exemple #10
0
 function infinite_scroll_has_footer_widgets()
 {
     if (jetpack_is_mobile('', true) && is_active_sidebar('primary-sidebar')) {
         return true;
     }
     return false;
 }
Exemple #11
0
/**
 * 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;
}
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;
}
 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'));
     }
 }
Exemple #14
0
/**
 * Handle `footer_widgets` argument for mobile devices
 *
 * @param bool $has_widgets
 * @uses jetpack_is_mobile, is_front_page, is_active_sidebar
 * @filter infinite_scroll_has_footer_widgets
 * @return bool
 */
function twenty_twelve_has_footer_widgets($has_widgets)
{
    if (function_exists('jetpack_is_mobile') && jetpack_is_mobile()) {
        if (is_front_page() && (is_active_sidebar('sidebar-2') || is_active_sidebar('sidebar-3'))) {
            $has_widgets = true;
        } elseif (is_active_sidebar('sidebar-1')) {
            $has_widgets = true;
        }
    }
    return $has_widgets;
}
/**
 * Have we any footer widgets?
 *
 * @param bool $has_widgets
 * @uses is_active_sidebar
 * @uses jetpack_is_mobile
 * @filter infinite_scroll_has_footer_widgets
 * @return bool
 */
function twenty_eleven_has_footer_widgets($has_widgets)
{
    // Are any of the "Footer Area" sidebars active?
    if (is_active_sidebar('sidebar-3') || is_active_sidebar('sidebar-4') || is_active_sidebar('sidebar-5')) {
        return true;
    }
    // If we're on mobile and the Main Sidebar has widgets, it falls below the content, so we have footer widgets.
    if (function_exists('jetpack_is_mobile') && jetpack_is_mobile() && is_active_sidebar('sidebar-1')) {
        return true;
    }
    return $has_widgets;
}
 function __construct()
 {
     self::$instance = $this;
     add_action('wp_loaded', array($this, 'wp_loaded'));
     add_action('admin_init', array($this, 'add_providers'));
     //slim//add_action( 'jetpack_admin_menu', array( $this, 'jetpack_admin_menu' ) );
     add_action('admin_menu', array($this, 'admin_menu'), 20);
     if (!jetpack_is_mobile()) {
         add_action('admin_bar_menu', array($this, 'admin_bar_search'), 4);
     }
     add_filter('omnisearch_num_results', array($this, 'omnisearch_num_results'));
 }
 public static function add_image_placeholders($content)
 {
     // Don't load for feeds, previews, attachment pages, non-mobile views
     if (is_preview() || is_feed() || is_attachment() || function_exists('jetpack_is_mobile') && !jetpack_is_mobile()) {
         return $content;
     }
     // In case you want to change the placeholder image
     $placeholder_image = apply_filters('responsive_images_placeholder_image', self::get_url('images/1x1.trans.gif'));
     preg_match_all('#<img[^>]+?[\\/]?>#', $content, $images, PREG_SET_ORDER);
     if (empty($images)) {
         return $content;
     }
     foreach ($images as $image) {
         $attributes = wp_kses_hair($image[0], array('http', 'https'));
         $new_image = '<img';
         $new_image_src = '';
         foreach ($attributes as $attribute) {
             $name = $attribute['name'];
             $value = $attribute['value'];
             // Remove the width and height attributes
             if (in_array($name, array('width', 'height'))) {
                 continue;
             }
             // Move the src to a data attribute and replace with a placeholder
             if ('src' == $name) {
                 $new_image_src = html_entity_decode(urldecode($value));
                 parse_str(parse_url($new_image_src, PHP_URL_QUERY), $image_args);
                 $new_image_src = remove_query_arg('h', $new_image_src);
                 $new_image_src = remove_query_arg('w', $new_image_src);
                 $new_image .= sprintf(' data-full-src="%s"', esc_url($new_image_src));
                 if (isset($image_args['w'])) {
                     $new_image .= sprintf(' data-full-width="%s"', esc_attr($image_args['w']));
                 }
                 if (isset($image_args['h'])) {
                     $new_image .= sprintf(' data-full-height="%s"', esc_attr($image_args['h']));
                 }
                 // replace actual src with our placeholder
                 $value = $placeholder_image;
             }
             $new_image .= sprintf(' %s="%s"', $name, esc_attr($value));
         }
         $new_image .= '/>';
         $new_image .= sprintf('<noscript><img src="%s" /></noscript>', $new_image_src);
         // compat for no-js and better crawling
         $content = str_replace($image[0], $new_image, $content);
     }
     return $content;
 }
Exemple #18
0
function wp_super_cache_jetpack_cookie_check($cache_key)
{
    if (file_exists(dirname(WPCACHEHOME) . '/jetpack/class.jetpack-user-agent.php')) {
        if (function_exists("jetpack_is_mobile") == false) {
            include dirname(WPCACHEHOME) . '/jetpack/class.jetpack-user-agent.php';
        }
        if (jetpack_is_mobile()) {
            return 'mobile';
        } else {
            return 'normal';
        }
    } else {
        wp_cache_debug("wp_super_cache_jetpack_cookie_check: jetpack UA file not found.");
        return "normal";
    }
}
 /**
  * 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);
 }
function jetpack_check_mobile()
{
    if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST || defined('APP_REQUEST') && APP_REQUEST) {
        return false;
    }
    if (!isset($_SERVER["HTTP_USER_AGENT"]) || isset($_COOKIE['akm_mobile']) && $_COOKIE['akm_mobile'] == 'false') {
        return false;
    }
    if (jetpack_mobile_exclude()) {
        return false;
    }
    if (1 == get_option('wp_mobile_disable')) {
        return false;
    }
    if (isset($_COOKIE['akm_mobile']) && $_COOKIE['akm_mobile'] == 'true') {
        return true;
    }
    $is_mobile = jetpack_is_mobile();
    return apply_filters('jetpack_check_mobile', $is_mobile);
}
/**
 * Add support for Infinite Scroll.
 */
function bouquet_infinite_scroll_init()
{
    add_theme_support('infinite-scroll', array('container' => 'content', 'footer_widgets' => is_active_sidebar('sidebar-1') && jetpack_is_mobile()));
}
Exemple #22
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_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'));
     }
 }
Exemple #23
0
 public static function is_mobile()
 {
     $is_mobile = function_exists('jetpack_is_mobile') ? jetpack_is_mobile() : wp_is_mobile();
     return $is_mobile;
 }
// Mobile batcache
if (jetpack_is_mobile() && isset($_COOKIE['akm_mobile'])) {
    $batcache['unique']['mobile-force'] = $_COOKIE['akm_mobile'] == 'true' ? 'true' : 'false';
}
// the akm_mobile cookie is used to force the desktop version of the site when on a mobile device
if (Jetpack_User_Agent_Info::is_blackbeberry()) {
    $batcache['unique']['mobile'] = 'blackberry';
} elseif (Jetpack_User_Agent_Info::is_WindowsPhone7()) {
    $batcache['unique']['mobile'] = 'windows-phone7';
} elseif (Jetpack_User_Agent_Info::is_S60_OSSBrowser()) {
    $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
Exemple #25
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);
     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'));
     }
 }
 /**
  * Handle the enqueueing and localizing for scripts to be used in the Customizer.
  */
 public static function customize_controls_enqueue_scripts()
 {
     wp_enqueue_style('jetpack-customizer-css');
     wp_enqueue_script('jetpack-customizer-css');
     $content_help = __('Set a different content width for full size images.', 'jetpack');
     if (!empty($GLOBALS['content_width'])) {
         $content_help .= sprintf(__(' The default content width for the <strong>%1$s</strong> theme is %2$d pixels.', 'jetpack'), wp_get_theme()->Name, intval($GLOBALS['content_width']));
     }
     wp_localize_script('jetpack-customizer-css', '_jp_css_settings', array('useRichEditor' => !jetpack_is_mobile() && apply_filters('safecss_use_ace', true), 'areThereCssRevisions' => self::are_there_css_revisions(), 'revisionsUrl' => self::get_revisions_url(), 'cssHelpUrl' => '//en.support.wordpress.com/custom-design/editing-css/', 'l10n' => array('mode' => __('Start Fresh', 'jetpack'), 'mobile' => __('On Mobile', 'jetpack'), 'contentWidth' => $content_help, 'revisions' => _x('See full history', 'Toolbar button to see full CSS revision history', 'jetpack'), 'css_help_title' => _x('Help', 'Toolbar button to get help with custom CSS', 'jetpack'))));
 }
Exemple #27
0
function mobile_admin_bar()
{
    if (jetpack_is_mobile()) {
        ?>
	<script type="text/javascript" id='mobile-admin-bar'>
		jQuery( function( $ ) {
			var menupop = $( '#wpadminbar .ab-top-menu > li.menupop' )
				.unbind( 'mouseover' )
				.unbind( 'mouseout' )
				.click( function ( e ) {
					$( this ).toggleClass( 'hover' );
					$( '#wpadminbar .menupop' ).not( this ).removeClass( 'hover' );
				} )
				.children( 'a' )
					.click( function( e ) {
						e.preventDefault();
					} );
			$( '#wpadminbar' ).css( 'position', 'absolute' );
			$( '#ab-reblog-box' ).css( 'position', 'absolute' );
		} );
	</script>
	<?php 
    }
}
Exemple #28
0
 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;
 }
Exemple #29
0
function mobile_admin_bar()
{
    global $wp_version;
    if (jetpack_is_mobile() && 1 != version_compare($wp_version, '3.5-beta3-22631')) {
        // This fix was made unnecessary in http://core.trac.wordpress.org/changeset/22636
        ?>
	<script type="text/javascript" id='mobile-admin-bar'>
		jQuery( function( $ ) {
			var menupop = $( '#wpadminbar .ab-top-menu > li.menupop' )
				.unbind( 'mouseover' )
				.unbind( 'mouseout' )
				.click( function ( e ) {
					$( this ).toggleClass( 'hover' );
					$( '#wpadminbar .menupop' ).not( this ).removeClass( 'hover' );
				} )
				.children( 'a' )
					.click( function( e ) {
						e.preventDefault();
					} );
			$( '#wpadminbar' ).css( 'position', 'absolute' );
			$( '#ab-reblog-box' ).css( 'position', 'absolute' );
		} );
	</script>
	<?php 
    }
}
Exemple #30
0
 function enqueue_scripts()
 {
     global $post;
     wp_enqueue_style('style', get_stylesheet_uri());
     wp_enqueue_style('homeroom-css', dirname(get_stylesheet_uri()) . '/homeroom.css');
     wp_enqueue_script('small-menu', get_template_directory_uri() . '/js/small-menu.js', array('jquery'), '20120206', true);
     if (is_singular() && comments_open() && get_option('thread_comments')) {
         wp_enqueue_script('comment-reply');
     }
     // Global JS file for all additional functionality
     wp_enqueue_script('homeroom-js', get_template_directory_uri() . '/js/homeroom.js', array('jquery'), '20130101');
     // Add tag suggest script for the homepage/editor
     if (Homeroom::get_option('enable_frontend_postbox') && is_home() && is_user_logged_in() && current_user_can('publish_posts') && !get_query_var('paged')) {
         wp_enqueue_script('suggest', false, array(), false, true);
     }
     // Embedded Tweets, for non-mobile only, being careful to use the same name as the Jetpack Twitter widget
     // See https://dev.twitter.com/docs/embedded-tweets
     if (!function_exists('jetpack_is_mobile') || !jetpack_is_mobile() && Homeroom::get_option('enable_twitter_embeds')) {
         wp_enqueue_script('twitter-widgets', '//platform.twitter.com/widgets.js', false, false, true);
     }
     // Google Maps API
     if (!is_home() || is_home() && !Homeroom::get_option('no_maps_on_homepage')) {
         wp_enqueue_script('google-maps', '//maps.googleapis.com/maps/api/js?&sensor=true&key=' . Homeroom::get_option('google_maps_api_key'), array('jquery'), 1, true);
     }
 }