diff options
Diffstat (limited to 'plugins/jetpack/modules')
109 files changed, 2614 insertions, 1239 deletions
diff --git a/plugins/jetpack/modules/after-the-deadline.php b/plugins/jetpack/modules/after-the-deadline.php index 31feef26..b187de35 100644 --- a/plugins/jetpack/modules/after-the-deadline.php +++ b/plugins/jetpack/modules/after-the-deadline.php @@ -2,7 +2,7 @@ /** * Module Name: Spelling and Grammar * Module Description: Improve your spelling, style, and grammar with the <a href="http://www.afterthedeadline.com/">After the Deadline</a> Proofreading service. - * Sort Order: 7 + * Sort Order: 6 * First Introduced: 1.1 */ diff --git a/plugins/jetpack/modules/carousel.php b/plugins/jetpack/modules/carousel.php index 4afe419f..2637f43d 100644 --- a/plugins/jetpack/modules/carousel.php +++ b/plugins/jetpack/modules/carousel.php @@ -2,9 +2,9 @@ /** * Module Name: Carousel - * Module Description: Transform your standard image galleries into an immersize full-screen experience. - * Sort Order: 13 - * First Introduced: 1.4 + * Module Description: Transform your standard image galleries into an immersive full-screen experience. + * Sort Order: 4 + * First Introduced: 1.5 */ include dirname( __FILE__ ) . '/carousel/jetpack-carousel.php'; diff --git a/plugins/jetpack/modules/carousel/images/carousel-sprite-2x.png b/plugins/jetpack/modules/carousel/images/carousel-sprite-2x.png Binary files differindex db5f1029..f3630a11 100644 --- a/plugins/jetpack/modules/carousel/images/carousel-sprite-2x.png +++ b/plugins/jetpack/modules/carousel/images/carousel-sprite-2x.png diff --git a/plugins/jetpack/modules/carousel/images/carousel-sprite.png b/plugins/jetpack/modules/carousel/images/carousel-sprite.png Binary files differindex f941bf9b..65df60e8 100644 --- a/plugins/jetpack/modules/carousel/images/carousel-sprite.png +++ b/plugins/jetpack/modules/carousel/images/carousel-sprite.png diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel.css b/plugins/jetpack/modules/carousel/jetpack-carousel.css index 28cda5c7..aa2b1d0f 100644 --- a/plugins/jetpack/modules/carousel/jetpack-carousel.css +++ b/plugins/jetpack/modules/carousel/jetpack-carousel.css @@ -6,11 +6,6 @@ background: #000; } -div.jp-carousel-buttons a.jp-carousel-permalink { - background: url(./images/carousel-link.png) no-repeat; - background-size: 12px 32px; -} - div.jp-carousel-fadeaway { background: -moz-linear-gradient(bottom, rgba(0,0,0,0.5), rgba(0,0,0,0)); background: -webkit-gradient(linear, left bottom, left top, from(rgba(0,0,0,0.5)), to(rgba(0,0,0,0))); @@ -27,20 +22,11 @@ div.jp-carousel-fadeaway { background-size: 200px 126px; } -div.jp-carousel-buttons a.jp-carousel-permalink { - background-position: 2px 6px; - margin-right:0; -} - -div.jp-carousel-buttons a.jp-carousel-permalink:hover { - background-position: 2px -14px; -} - -@media only screen and (-webkit-min-device-pixel-ratio: 1.5) { - div.jp-carousel-buttons a.jp-carousel-permalink { - background-image: url(./images/carousel-link-2x.png); - background-position: 2px 6px; - } +@media +only screen and (-webkit-min-device-pixel-ratio: 1.5), +only screen and (-o-min-device-pixel-ratio: 3/2), +only screen and (min--moz-device-pixel-ratio: 1.5), +only screen and (min-device-pixel-ratio: 1.5) { .jp-carousel-next-button span, .jp-carousel-previous-button span { background-image: url(./images/arrows-2x.png); @@ -132,17 +118,19 @@ div.jp-carousel-buttons a.jp-carousel-permalink:hover { } .jp-carousel-buttons { - margin:0 0 15px 0; - padding-bottom:15px; + margin:-18px -20px 15px; + padding:8px 10px; border-bottom:1px solid #222; + background: #222; + text-align: center; } div.jp-carousel-buttons a { border: none !important; color: #999; - font: normal 13px/1.2em "Helvetica Neue", sans-serif !important; + font: normal 11px/1.2em "Helvetica Neue", sans-serif !important; letter-spacing: 0 !important; - padding: 5px 2px 5px 20px !important; + padding: 5px 2px 5px 0; text-decoration: none !important; text-shadow: none !important; vertical-align: baseline !important; @@ -184,8 +172,10 @@ div.jp-carousel-buttons a:hover { .jp-carousel-slide img { display: block; - width: 100%; - height: 100%; + width: 100% !important; + height: 100% !important; + max-width: 100% !important; + max-height: 100% !important; background: none !important; border: none !important; padding: 0 !important; @@ -253,29 +243,31 @@ div.jp-carousel-buttons a:hover { div.jp-carousel-buttons a.jp-carousel-like, div.jp-carousel-buttons a.jp-carousel-reblog, +div.jp-carousel-buttons a.jp-carousel-commentlink, a.jp-carousel-image-download { - background: url(./images/carousel-sprite.png?3) no-repeat; - background-size: 16px 120px; + background: url(./images/carousel-sprite.png?4) no-repeat; + background-size: 16px 160px; } -div.jp-carousel-buttons a.jp-carousel-reblog { - margin:0 5px 0 -5px !important; +div.jp-carousel-buttons a.jp-carousel-reblog, +div.jp-carousel-buttons a.jp-carousel-commentlink { + margin:0 14px 0 0 !important; } div.jp-carousel-buttons a.jp-carousel-reblog.reblogged, div.jp-carousel-buttons a.jp-carousel-like.liked { - background-color: #222; + background-color: #303030; padding-right: 8px !important; - border-radius: 3px; - border-radius:3px; - -webkit-border-radius:3px; - -moz-border-radius:3px; - -ms-border-radius:3px; - -o-border-radius:3px; + border-radius: 2px; + border-radius:2px; + -webkit-border-radius:2px; + -moz-border-radius:2px; + -ms-border-radius:2px; + -o-border-radius:2px; } div.jp-carousel-buttons a.jp-carousel-reblog.reblogged { - margin:0 5px 0 0 !important; + margin:0 2px 0 -12px !important; } @@ -286,6 +278,11 @@ div.jp-carousel-buttons a.jp-carousel-reblog.reblogged:hover { color: #999; } +div.jp-carousel-buttons a.jp-carousel-commentlink { + background-position: 0px -116px; + padding-left: 19px !important; +} + div.jp-carousel-buttons a.jp-carousel-reblog.reblogged:hover { cursor: default; } @@ -311,8 +308,9 @@ only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { div.jp-carousel-buttons a.jp-carousel-like, div.jp-carousel-buttons a.jp-carousel-reblog, + div.jp-carousel-buttons a.jp-carousel-commentlink, a.jp-carousel-image-download { - background-image: url(./images/carousel-sprite-2x.png?3); + background-image: url(./images/carousel-sprite-2x.png?4); } } @@ -492,12 +490,13 @@ h1:before, h1:after { /** Meta Box Start **/ .jp-carousel-image-meta { background: #111; - padding: 18px 20px; + border: 1px solid #222; color: #fff; font-size: 13px; font: 12px/1.4 "Helvetica Neue", sans-serif !important; + overflow: hidden; + padding: 18px 20px; width: 209px !important; - border: 1px solid #222; } .jp-carousel-image-meta li, @@ -878,7 +877,8 @@ textarea#jp-carousel-comment-form-comment-field:focus::-webkit-input-placeholder } .jp-carousel-light .jp-carousel-buttons { - border-bottom-color: #dfdfdf; + border-bottom-color: #f0f0f0; + background: #f5f5f5; } .jp-carousel-light div.jp-carousel-buttons a:hover { @@ -898,6 +898,10 @@ textarea#jp-carousel-comment-form-comment-field:focus::-webkit-input-placeholder color: #fff; } +.jp-carousel-light div.jp-carousel-buttons a.jp-carousel-commentlink { + background-position: 0px -136px; +} + .jp-carousel-light div.jp-carousel-buttons a.jp-carousel-like, .jp-carousel-light div.jp-carousel-buttons a.jp-carousel-like:hover { background-position: 5px -15px; diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel.js b/plugins/jetpack/modules/carousel/jetpack-carousel.js index d58fa10c..5760811e 100644 --- a/plugins/jetpack/modules/carousel/jetpack-carousel.js +++ b/plugins/jetpack/modules/carousel/jetpack-carousel.js @@ -62,7 +62,8 @@ jQuery(document).ready(function($) { 'left' : 0 }); - buttons = $('<div class="jp-carousel-buttons">' + buttons + '</div>'); + buttons = '<a class="jp-carousel-commentlink" href="#">' + jetpackCarouselStrings.comment + '</a>'; + buttons = $('<div class="jp-carousel-buttons">' + buttons + '</div>'); caption = $('<h2></h2>'); photo_info = $('<div class="jp-carousel-photo-info"></div>').append(caption); @@ -238,6 +239,13 @@ jQuery(document).ready(function($) { if ( target.is(gallery) || target.parents().add(target).is(close_hint) ) { container.jp_carousel('close'); + } else if ( target.hasClass('jp-carousel-commentlink') ) { + e.preventDefault(); + e.stopPropagation(); + $(window).unbind('keydown', keyListener); + container.animate({scrollTop: parseInt(info.position()['top'], 10)}, 'fast'); + $('#jp-carousel-comment-form-submit-and-info-wrapper').slideDown('fast'); + $('#jp-carousel-comment-form-comment-field').focus(); } else if ( target.parents('#jp-carousel-comment-form-container').length ) { var textarea = $('#jp-carousel-comment-form-comment-field') .blur(function(){ @@ -546,33 +554,31 @@ jQuery(document).ready(function($) { previous[method]({left:-previous.width() + (screenPadding * 0.75) }).show(); next[method]({left:gallery.width() - (screenPadding * 0.75) }).show(); - setTimeout( function() { - document.location.href = document.location.href.replace(/#.*/, '') + '#jp-carousel-' + current.data('attachment-id'); - gallery.jp_carousel('resetButtons', current); - container.trigger('jp_carousel.selectSlide', [current]); + document.location.href = document.location.href.replace(/#.*/, '') + '#jp-carousel-' + current.data('attachment-id'); + gallery.jp_carousel('resetButtons', current); + container.trigger('jp_carousel.selectSlide', [current]); - $( 'div.jp-carousel-image-meta', 'div.jp-carousel-wrap' ).html(''); - - gallery.jp_carousel('getTitleDesc', { title: current.data('title'), desc: current.data('desc') } ); - gallery.jp_carousel('getMeta', current.data('image-meta')); - gallery.jp_carousel('getFullSizeLink', current); - gallery.jp_carousel('getMap', current.data('image-meta')); - gallery.jp_carousel('testCommentsOpened', current.data('comments-opened')); - gallery.jp_carousel('getComments', {'attachment_id': current.data('attachment-id'), 'offset': 0, 'clear': true}); - - $('#jp-carousel-comment-post-results').slideUp(); - - // $('<div />').html(sometext).text() is a trick to go to HTML to plain text (including HTML emntities decode, etc) - if ( current.data('caption') ) { - if ( $('<div />').html(current.data('caption')).text() == $('<div />').html(current.data('title')).text() ) - $('.jp-carousel-titleanddesc-title').fadeOut('fast').empty(); - if ( $('<div />').html(current.data('caption')).text() == $('<div />').html(current.data('desc')).text() ) - $('.jp-carousel-titleanddesc-desc').fadeOut('fast').empty(); - caption.html( current.data('caption') ).fadeIn('slow'); - } else { - caption.fadeOut('fast').empty(); - } - }, 600 ); + $( 'div.jp-carousel-image-meta', 'div.jp-carousel-wrap' ).html(''); + + gallery.jp_carousel('getTitleDesc', { title: current.data('title'), desc: current.data('desc') } ); + gallery.jp_carousel('getMeta', current.data('image-meta')); + gallery.jp_carousel('getFullSizeLink', current); + gallery.jp_carousel('getMap', current.data('image-meta')); + gallery.jp_carousel('testCommentsOpened', current.data('comments-opened')); + gallery.jp_carousel('getComments', {'attachment_id': current.data('attachment-id'), 'offset': 0, 'clear': true}); + + $('#jp-carousel-comment-post-results').slideUp(); + + // $('<div />').html(sometext).text() is a trick to go to HTML to plain text (including HTML emntities decode, etc) + if ( current.data('caption') ) { + if ( $('<div />').html(current.data('caption')).text() == $('<div />').html(current.data('title')).text() ) + $('.jp-carousel-titleanddesc-title').fadeOut('fast').empty(); + if ( $('<div />').html(current.data('caption')).text() == $('<div />').html(current.data('desc')).text() ) + $('.jp-carousel-titleanddesc-desc').fadeOut('fast').empty(); + caption.html( current.data('caption') ).fadeIn('slow'); + } else { + caption.fadeOut('fast').empty(); + } }, @@ -681,8 +687,9 @@ jQuery(document).ready(function($) { }, texturize : function(text) { - text = text.replace("'", '’').replace(''', '’').replace(/[\u2019]/, '’'); - text = text.replace('"', '”').replace('"', '”').replace('"', '”').replace(/[\u201D]/, '”'); + text = text.replace(/'/g, '’').replace(/'/g, '’').replace(/[\u2019]/g, '’'); + text = text.replace(/"/g, '”').replace(/"/g, '”').replace(/"/g, '”').replace(/[\u201D]/g, '”'); + text = text.replace(/([\w]+)=&#[\d]+;(.+?)&#[\d]+;/g, '$1="$2"'); // untexturize allowed HTML tags params double-quotes return $.trim(text); }, @@ -705,7 +712,9 @@ jQuery(document).ready(function($) { src = gallery.jp_carousel('selectBestImageSize', { orig_file : src, orig_width : orig_size.width, + orig_height : orig_size.height, max_width : max.width, + max_height : max.height, medium_file : medium_file, large_file : large_file }); @@ -783,18 +792,22 @@ jQuery(document).ready(function($) { var medium_size = args.medium_file.replace(/^https?:\/\/.+-([\d]+x[\d]+)\..+$/, '$1'), medium_size_parts = (medium_size != args.medium_file) ? medium_size.split('x') : [args.orig_width, 0], medium_width = parseInt( medium_size_parts[0], 10 ), + medium_height = parseInt( medium_size_parts[1], 10 ), large_size = args.large_file.replace(/^https?:\/\/.+-([\d]+x[\d]+)\..+$/, '$1'), large_size_parts = (large_size != args.large_file) ? large_size.split('x') : [args.orig_width, 0], - large_width = parseInt( large_size_parts[0], 10 ); + large_width = parseInt( large_size_parts[0], 10 ), + large_height = parseInt( large_size_parts[1], 10 ); // Give devices with a higher devicePixelRatio higher-res images (Retina display = 2, Android phones = 1.5, etc) - if ('undefined' != typeof window.devicePixelRatio && window.devicePixelRatio > 1) - args.max_width = args.max_width * window.devicePixelRatio; + if ('undefined' != typeof window.devicePixelRatio && window.devicePixelRatio > 1) { + args.max_width = args.max_width * window.devicePixelRatio; + args.max_height = args.max_height * window.devicePixelRatio; + } - if ( medium_width >= args.max_width ) + if ( medium_width >= args.max_width || medium_height >= args.max_height ) return args.medium_file; - if ( large_width >= args.max_width ) + if ( large_width >= args.max_width || large_height >= args.max_height ) return args.large_file; return args.orig_file; @@ -926,6 +939,8 @@ jQuery(document).ready(function($) { $ul.append( '<li><h5>' + jetpackCarouselStrings[key] + '</h5>' + val + '</li>' ); }); + $( 'div.jp-carousel-image-meta', 'div.jp-carousel-wrap' ) + .append( $( buttons ) ); $( 'div.jp-carousel-image-meta', 'div.jp-carousel-wrap' ) .append( $ul ); @@ -977,8 +992,10 @@ jQuery(document).ready(function($) { testCommentsOpened: function( opened ) { if ( 1 == parseInt( opened, 10 ) ) { + $('.jp-carousel-buttons').fadeIn('fast'); commentForm.fadeIn('fast'); } else { + $('.jp-carousel-buttons').fadeOut('fast'); commentForm.fadeOut('fast'); } }, @@ -1115,6 +1132,8 @@ jQuery(document).ready(function($) { // register the event listener for staring the gallery $( document.body ).on( 'click', 'div.gallery', function(e) { + if ( $(e.target).parent().hasClass('gallery-caption') ) + return; e.preventDefault(); $(this).jp_carousel('open', {start_index: $(this).find('.gallery-item').index($(e.target).parents('.gallery-item'))}); }); diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel.php b/plugins/jetpack/modules/carousel/jetpack-carousel.php index 2fa59f6f..3d48681b 100644 --- a/plugins/jetpack/modules/carousel/jetpack-carousel.php +++ b/plugins/jetpack/modules/carousel/jetpack-carousel.php @@ -105,9 +105,10 @@ class Jetpack_Carousel { 'display_exif' => $this->test_1or0_option( get_option( 'carousel_display_exif' ), true ), 'display_geo' => $this->test_1or0_option( get_option( 'carousel_display_geo' ), true ), 'background_color' => $this->carousel_background_color_sanitize( get_option( 'carousel_background_color' ) ), + 'comment' => __( 'Comment', 'jetpack' ), 'post_comment' => __( 'Post Comment', 'jetpack' ), 'loading_comments' => __( 'Loading Comments...', 'jetpack' ), - 'download_original' => __( 'View full size <span class="photo-size">{0}<span class="photo-size-times">×</span>{1}</span>', 'jetpack' ), + 'download_original' => sprintf( __( 'View full size <span class="photo-size">%1$s<span class="photo-size-times">×</span>%2$s</span>', 'jetpack' ), '{0}', '{1}' ), 'no_comment_text' => __( 'Please be sure to submit some text with your comment.', 'jetpack' ), 'no_comment_email' => __( 'Please provide an email address to comment.', 'jetpack' ), 'no_comment_author' => __( 'Please provide your name to comment.', 'jetpack' ), diff --git a/plugins/jetpack/modules/comments/comments.php b/plugins/jetpack/modules/comments/comments.php index 965769d6..d33ad240 100644 --- a/plugins/jetpack/modules/comments/comments.php +++ b/plugins/jetpack/modules/comments/comments.php @@ -224,7 +224,8 @@ class Jetpack_Comments extends Highlander_Comments_Base { ?> <script type="text/javascript"> - var comm_par = document.getElementById( 'comment_parent' ).value, + var comm_par_el = document.getElementById( 'comment_parent' ), + comm_par = (comm_par_el && comm_par_el.value) ? comm_par_el.value : '', frame = document.getElementById( 'jetpack_remote_comment' ), tellFrameNewParent; @@ -236,42 +237,48 @@ class Jetpack_Comments extends Highlander_Comments_Base { } }; - addComment._Jetpack_moveForm = addComment.moveForm; + <?php if ( get_option( 'thread_comments' ) && get_option( 'thread_comments_depth' ) ) : ?> - addComment.moveForm = function( commId, parentId, respondId, postId ) { - var returnValue = addComment._Jetpack_moveForm( commId, parentId, respondId, postId ), cancelClick, cancel; + if ( 'undefined' !== typeof addComment ) { + addComment._Jetpack_moveForm = addComment.moveForm; - if ( false === returnValue ) { - cancel = document.getElementById( 'cancel-comment-reply-link' ); - cancelClick = cancel.onclick; - cancel.onclick = function() { - var cancelReturn = cancelClick.call( this ); - if ( false !== cancelReturn ) { - return cancelReturn; - } + addComment.moveForm = function( commId, parentId, respondId, postId ) { + var returnValue = addComment._Jetpack_moveForm( commId, parentId, respondId, postId ), cancelClick, cancel; - if ( !comm_par ) { - return cancelReturn; - } + if ( false === returnValue ) { + cancel = document.getElementById( 'cancel-comment-reply-link' ); + cancelClick = cancel.onclick; + cancel.onclick = function() { + var cancelReturn = cancelClick.call( this ); + if ( false !== cancelReturn ) { + return cancelReturn; + } - comm_par = 0; + if ( !comm_par ) { + return cancelReturn; + } - tellFrameNewParent(); + comm_par = 0; - return cancelReturn; - }; - } + tellFrameNewParent(); - if ( comm_par == parentId ) { - return returnValue; - } + return cancelReturn; + }; + } - comm_par = parentId; + if ( comm_par == parentId ) { + return returnValue; + } - tellFrameNewParent(); + comm_par = parentId; - return returnValue; - }; + tellFrameNewParent(); + + return returnValue; + }; + } + + <?php endif; ?> if ( window.postMessage ) { if ( document.addEventListener ) { diff --git a/plugins/jetpack/modules/contact-form.php b/plugins/jetpack/modules/contact-form.php index ac44d0d3..d53fc4c9 100644 --- a/plugins/jetpack/modules/contact-form.php +++ b/plugins/jetpack/modules/contact-form.php @@ -2,7 +2,7 @@ /** * Module Name: Contact Form * Module Description: Easily insert a contact form any where on your site. - * Sort Order: 6 + * Sort Order: 9 * First Introduced: 1.3 */ diff --git a/plugins/jetpack/modules/contact-form/admin.php b/plugins/jetpack/modules/contact-form/admin.php index 9ac40f9e..b5fcadd9 100644 --- a/plugins/jetpack/modules/contact-form/admin.php +++ b/plugins/jetpack/modules/contact-form/admin.php @@ -42,7 +42,10 @@ color: #D98500; #icon-edit { background-position: -432px -5px; } -#icon-edit, #icon-post { background: url("<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-menu-big.png") no-repeat !important; } +#icon-edit, #icon-post { background: url("<?php echo GRUNION_PLUGIN_URL; ?>images/grunion-menu-big.png") no-repeat !important; } +@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { + #icon-edit, #icon-post { background: url("<?php echo GRUNION_PLUGIN_URL; ?>images/grunion-menu-big-2x.png") no-repeat !important; background-size: 30px 31px !important; } +} </style> <?php diff --git a/plugins/jetpack/modules/contact-form/grunion-contact-form.php b/plugins/jetpack/modules/contact-form/grunion-contact-form.php index af81871a..bbf2ba54 100644 --- a/plugins/jetpack/modules/contact-form/grunion-contact-form.php +++ b/plugins/jetpack/modules/contact-form/grunion-contact-form.php @@ -677,7 +677,7 @@ function contact_form_init() { 'not_found' => __( 'No feedback found', 'jetpack' ), 'not_found_in_trash' => __( 'No feedback found', 'jetpack' ) ), - 'menu_icon' => GRUNION_PLUGIN_URL . '/images/grunion-menu.png', + 'menu_icon' => GRUNION_PLUGIN_URL . 'images/grunion-menu.png', 'show_ui' => TRUE, 'show_in_admin_bar' => FALSE, 'public' => FALSE, @@ -719,7 +719,7 @@ function grunion_media_button( ) { $plugin_url = esc_url( GRUNION_PLUGIN_URL ); $site_url = admin_url( "/admin-ajax.php?post_id=$iframe_post_id&grunion=form-builder&action=grunion_form_builder&TB_iframe=true&width=768" ); - echo '<a href="' . $site_url . '&id=add_form" class="thickbox" title="' . $title . '"><img src="' . $plugin_url . '/images/grunion-form.png" alt="' . $title . '" width="13" height="12" /></a>'; + echo '<a href="' . $site_url . '&id=add_form" class="thickbox" title="' . $title . '"><div class="grunion-menu-button" alt="' . $title . '"></div></a>'; } @@ -741,8 +741,37 @@ function menu_alter() { echo ' <style> #menu-posts-feedback .wp-menu-image img { display: none; } - #adminmenu .menu-icon-feedback:hover div.wp-menu-image, #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image, #adminmenu .menu-icon-feedback.current div.wp-menu-image { background: url("' .GRUNION_PLUGIN_URL . '/images/grunion-menu-hover.png") no-repeat 6px 7px !important; } - #adminmenu .menu-icon-feedback div.wp-menu-image, #adminmenu .menu-icon-feedback div.wp-menu-image, #adminmenu .menu-icon-feedback div.wp-menu-image { background: url("' . GRUNION_PLUGIN_URL . '/images/grunion-menu.png") no-repeat 6px 7px !important; } + #adminmenu .menu-icon-feedback:hover div.wp-menu-image, + #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image, + #adminmenu .menu-icon-feedback.current div.wp-menu-image { + background: url("' .GRUNION_PLUGIN_URL . 'images/grunion-menu-hover.png") no-repeat 6px 7px; + } + #adminmenu .menu-icon-feedback div.wp-menu-image { + background: url("' . GRUNION_PLUGIN_URL . 'images/grunion-menu.png") no-repeat 6px 7px; + } + .grunion-menu-button { + background: url("' . GRUNION_PLUGIN_URL . 'images/grunion-form.png") no-repeat; + width: 13px; + height: 12px; + display: inline-block; + } + @media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { + #adminmenu .menu-icon-feedback:hover div.wp-menu-image, + #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image, + #adminmenu .menu-icon-feedback.current div.wp-menu-image { + background: url("' .GRUNION_PLUGIN_URL . 'images/grunion-menu-hover-2x.png") no-repeat 6px 7px; + background-size: 15px 16px; + } + #adminmenu .menu-icon-feedback div.wp-menu-image { + background: url("' . GRUNION_PLUGIN_URL . 'images/grunion-menu-2x.png") no-repeat 6px 7px; + background-size: 15px 16px; + } + .grunion-menu-button { + background-image: url("' . GRUNION_PLUGIN_URL . 'images/grunion-form-2x.png"); + background-size: 13px 12px; + vertical-align: bottom; + } + } </style>'; } diff --git a/plugins/jetpack/modules/contact-form/grunion-form-view.php b/plugins/jetpack/modules/contact-form/grunion-form-view.php index 26577bb9..836369a8 100644 --- a/plugins/jetpack/modules/contact-form/grunion-form-view.php +++ b/plugins/jetpack/modules/contact-form/grunion-form-view.php @@ -104,6 +104,12 @@ wp_localize_script( 'grunion', 'GrunionFB_i18n', array( .fb-settings input[type='text'], .fb-settings textarea { background-image: none !important; } .fb-success { position: absolute; top: -3px; right: 100px; padding: 6px 23px 4px 23px; background: #FFFFE0; font-weight: normal; border: 1px solid #E6DB55; color: #333; -moz-border-radius:4px; border-radius:4px; -webkit-border-radius:4px; } .right { float: right; } + @media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { + .fb-remove { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-field-2x.png') no-repeat; background-size: 20px 23px; } + .fb-remove:hover { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-field-hover-2x.png') no-repeat; background-size: 20px 23px; } + .fb-remove-option { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-option-2x.png') no-repeat; background-size: 20px 23px; } + .fb-remove-option:hover { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-option-hover-2x.png') no-repeat; background-size: 20px 23px; } + } </style> </head> diff --git a/plugins/jetpack/modules/contact-form/images/blank-screen-akismet.png b/plugins/jetpack/modules/contact-form/images/blank-screen-akismet.png Binary files differindex 3d3f13d6..9efcd478 100644 --- a/plugins/jetpack/modules/contact-form/images/blank-screen-akismet.png +++ b/plugins/jetpack/modules/contact-form/images/blank-screen-akismet.png diff --git a/plugins/jetpack/modules/contact-form/images/blank-screen-button.png b/plugins/jetpack/modules/contact-form/images/blank-screen-button.png Binary files differindex ab03ed10..7e3127a3 100644 --- a/plugins/jetpack/modules/contact-form/images/blank-screen-button.png +++ b/plugins/jetpack/modules/contact-form/images/blank-screen-button.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-form-2x.png b/plugins/jetpack/modules/contact-form/images/grunion-form-2x.png Binary files differnew file mode 100644 index 00000000..824d85a3 --- /dev/null +++ b/plugins/jetpack/modules/contact-form/images/grunion-form-2x.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-form.png b/plugins/jetpack/modules/contact-form/images/grunion-form.png Binary files differindex 75bd6253..6f7d9ad3 100644 --- a/plugins/jetpack/modules/contact-form/images/grunion-form.png +++ b/plugins/jetpack/modules/contact-form/images/grunion-form.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-menu-2x.png b/plugins/jetpack/modules/contact-form/images/grunion-menu-2x.png Binary files differnew file mode 100644 index 00000000..04fd8be5 --- /dev/null +++ b/plugins/jetpack/modules/contact-form/images/grunion-menu-2x.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-menu-big-2x.png b/plugins/jetpack/modules/contact-form/images/grunion-menu-big-2x.png Binary files differnew file mode 100644 index 00000000..960bbb6a --- /dev/null +++ b/plugins/jetpack/modules/contact-form/images/grunion-menu-big-2x.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-menu-big.png b/plugins/jetpack/modules/contact-form/images/grunion-menu-big.png Binary files differindex 56ce4f42..603ce56a 100644 --- a/plugins/jetpack/modules/contact-form/images/grunion-menu-big.png +++ b/plugins/jetpack/modules/contact-form/images/grunion-menu-big.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-menu-hover-2x.png b/plugins/jetpack/modules/contact-form/images/grunion-menu-hover-2x.png Binary files differnew file mode 100644 index 00000000..f4656a98 --- /dev/null +++ b/plugins/jetpack/modules/contact-form/images/grunion-menu-hover-2x.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-menu-hover.png b/plugins/jetpack/modules/contact-form/images/grunion-menu-hover.png Binary files differindex e876e0e5..3b83433a 100644 --- a/plugins/jetpack/modules/contact-form/images/grunion-menu-hover.png +++ b/plugins/jetpack/modules/contact-form/images/grunion-menu-hover.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-menu.png b/plugins/jetpack/modules/contact-form/images/grunion-menu.png Binary files differindex d4e005f4..6054e237 100644 --- a/plugins/jetpack/modules/contact-form/images/grunion-menu.png +++ b/plugins/jetpack/modules/contact-form/images/grunion-menu.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-remove-field-2x.png b/plugins/jetpack/modules/contact-form/images/grunion-remove-field-2x.png Binary files differnew file mode 100644 index 00000000..49553746 --- /dev/null +++ b/plugins/jetpack/modules/contact-form/images/grunion-remove-field-2x.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-remove-field-hover-2x.png b/plugins/jetpack/modules/contact-form/images/grunion-remove-field-hover-2x.png Binary files differnew file mode 100644 index 00000000..561382fa --- /dev/null +++ b/plugins/jetpack/modules/contact-form/images/grunion-remove-field-hover-2x.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-remove-option-2x.png b/plugins/jetpack/modules/contact-form/images/grunion-remove-option-2x.png Binary files differnew file mode 100644 index 00000000..061114b0 --- /dev/null +++ b/plugins/jetpack/modules/contact-form/images/grunion-remove-option-2x.png diff --git a/plugins/jetpack/modules/contact-form/images/grunion-remove-option-hover-2x.png b/plugins/jetpack/modules/contact-form/images/grunion-remove-option-hover-2x.png Binary files differnew file mode 100644 index 00000000..210de1b3 --- /dev/null +++ b/plugins/jetpack/modules/contact-form/images/grunion-remove-option-hover-2x.png diff --git a/plugins/jetpack/modules/contact-form/js/grunion.js b/plugins/jetpack/modules/contact-form/js/grunion.js index 040710bf..4fe391bf 100644 --- a/plugins/jetpack/modules/contact-form/js/grunion.js +++ b/plugins/jetpack/modules/contact-form/js/grunion.js @@ -387,12 +387,16 @@ FB.ContactForm = function() { jQuery( '#content', window.parent.document ).val( currentCode.replace( regexp, response ) ); } } else { - if (isVisual) { - win.tinyMCE.activeEditor.execCommand('mceInsertContent', false, response); - } else { - // looks like the visual editor is disabled, - // update the contents of the post directly - jQuery( '#content', window.parent.document ).val( currentCode + response ); + try { + win.send_to_editor( response ); + } catch ( e ) { + if (isVisual) { + win.tinyMCE.activeEditor.execCommand('mceInsertContent', false, response); + } else { + // looks like the visual editor is disabled, + // update the contents of the post directly + jQuery( '#content', window.parent.document ).val( currentCode + response ); + } } } hidePopup(); diff --git a/plugins/jetpack/modules/contact-form/readme.txt b/plugins/jetpack/modules/contact-form/readme.txt index ff4958f1..4285dec9 100644 --- a/plugins/jetpack/modules/contact-form/readme.txt +++ b/plugins/jetpack/modules/contact-form/readme.txt @@ -74,6 +74,7 @@ Just make the title of your post "Contact Mary" or put "Hey, drop John a line wi * Support forms with no email address * Don't include *** SPAM *** in the subject line of unspammed items * Fix form processing when there is more than one form on a page (Koff) +* Retina images added = 2.3 = * Fix for Chrome going 'oh snap' when inserting a new contact form diff --git a/plugins/jetpack/modules/module-info.php b/plugins/jetpack/modules/module-info.php index 4e0ca64c..d1038208 100644 --- a/plugins/jetpack/modules/module-info.php +++ b/plugins/jetpack/modules/module-info.php @@ -19,7 +19,7 @@ function vaultpress_jetpack_more_info() { <div class="jp-info-img"> <a href="<?php echo $vaultpress_url?>"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/vaultpress.png' ) ?>" alt="<?php esc_attr_e( 'VaultPress', 'jetpack' ) ?>" width="300" height="155" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/vaultpress.png' ) ?>" alt="<?php esc_attr_e( 'VaultPress', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -50,7 +50,7 @@ add_filter( 'jetpack_learn_more_button_vaultpress', 'vaultpress_jetpack_load_mor function grofiles_more_info() { ?> <div class="jp-info-img"> <a href="http://blog.gravatar.com/2010/10/06/gravatar-hovercards-on-wordpress-com/"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/hovercard.png' ) ?>" alt="<?php esc_attr_e( 'Gravatar Hovercard', 'jetpack' ) ?>" width="320" height="165" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/hovercards.png' ) ?>" alt="<?php esc_attr_e( 'Gravatar Hovercard', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -65,7 +65,7 @@ add_action( 'jetpack_module_more_info_gravatar-hovercards', 'grofiles_more_info' function grofiles_more_info_connected() { ?> <div class="jp-info-img"> <a href="http://blog.gravatar.com/2010/10/06/gravatar-hovercards-on-wordpress-com/"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/hovercard.png' ) ?>" alt="<?php esc_attr_e( 'Gravatar Hovercard', 'jetpack' ) ?>" width="320" height="165" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/hovercards.png' ) ?>" alt="<?php esc_attr_e( 'Gravatar Hovercard', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -87,7 +87,7 @@ add_filter( 'jetpack_learn_more_button_gravatar-hovercards', 'grofiles_load_more function jetpack_shortcodes_more_info() { ?> <div class="jp-info-img"> <a href="http://en.support.wordpress.com/shortcodes/"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/shortcodes.png' ) ?>" alt="<?php esc_attr_e( 'Shortcode Embeds', 'jetpack' ) ?>" width="300" height="135" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/shortcodes.png' ) ?>" alt="<?php esc_attr_e( 'Shortcode Embeds', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -100,7 +100,7 @@ add_action( 'jetpack_module_more_info_shortcodes', 'jetpack_shortcodes_more_info function jetpack_shortcodes_more_info_connected() { ?> <div class="jp-info-img"> <a href="http://en.support.wordpress.com/shortcodes/"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/shortcodes.png' ) ?>" alt="<?php esc_attr_e( 'Shortcode Embeds', 'jetpack' ) ?>" width="300" height="135" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/shortcodes.png' ) ?>" alt="<?php esc_attr_e( 'Shortcode Embeds', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -147,7 +147,7 @@ add_filter( 'jetpack_learn_more_button_shortcodes', 'jetpack_shortcodes_load_mor function wpme_more_info() { ?> <div class="jp-info-img"> <a href="http://wp.me/sf2B5-shorten"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/shortlinks.gif' ) ?>" alt="<?php esc_attr_e( 'WP.me Shortlinks', 'jetpack' ) ?>" width="300" height="154" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/shortlinks.png' ) ?>" alt="<?php esc_attr_e( 'WP.me Shortlinks', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -161,7 +161,7 @@ add_action( 'jetpack_module_more_info_shortlinks', 'wpme_more_info' ); function wpme_more_info_connected() { ?> <div class="jp-info-img"> <a href="http://wp.me/sf2B5-shorten"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/shortlinks.gif' ) ?>" alt="<?php esc_attr_e( 'WP.me Shortlinks', 'jetpack' ) ?>" width="300" height="154" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/shortlinks.png' ) ?>" alt="<?php esc_attr_e( 'WP.me Shortlinks', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -182,7 +182,7 @@ add_filter( 'jetpack_learn_more_button_shortlinks', 'wpme_load_more_link' ); function stats_more_info() { ?> <div class="jp-info-img"> <a href="http://en.support.wordpress.com/stats/"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/stats.gif' ) ?>" alt="<?php esc_attr_e( 'WordPress.com Stats', 'jetpack' ) ?>" width="300" height="144" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/stats.png' ) ?>" alt="<?php esc_attr_e( 'WordPress.com Stats', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -195,7 +195,7 @@ add_action( 'jetpack_module_more_info_stats', 'stats_more_info' ); function stats_more_info_connected() { ?> <div class="jp-info-img"> <a href="http://en.support.wordpress.com/stats/"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/stats.gif' ) ?>" alt="<?php esc_attr_e( 'WordPress.com Stats', 'jetpack' ) ?>" width="300" height="144" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/stats.png' ) ?>" alt="<?php esc_attr_e( 'WordPress.com Stats', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -216,7 +216,7 @@ add_filter( 'jetpack_learn_more_button_stats', 'stats_load_more_link' ); function latex_more_info() { ?> <div class="jp-info-img"> <a href="http://support.wordpress.com/latex/"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/latex.gif' ) ?>" alt="<?php esc_attr_e( 'LaTeX', 'jetpack' ) ?>" width="300" height="155" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/beautifulmath.png' ) ?>" alt="<?php esc_attr_e( 'LaTeX', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -231,7 +231,7 @@ add_action( 'jetpack_module_more_info_latex', 'latex_more_info' ); function latex_more_info_connected() { ?> <div class="jp-info-img"> <a href="http://support.wordpress.com/latex/"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/latex.gif' ) ?>" alt="<?php esc_attr_e( 'LaTeX', 'jetpack' ) ?>" width="300" height="155" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/beautifulmath.png' ) ?>" alt="<?php esc_attr_e( 'LaTeX', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -252,7 +252,7 @@ add_filter( 'jetpack_learn_more_button_latex', 'latex_load_more_link' ); function sharedaddy_more_info() { ?> <div class="jp-info-img"> <a href="http://en.support.wordpress.com/sharing/"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/sharedaddy.gif' ) ?>" alt="<?php esc_attr_e( 'Sharing', 'jetpack' ) ?>" width="300" height="155" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/sharing.png' ) ?>" alt="<?php esc_attr_e( 'Sharing', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> <h4><?php esc_html_e( 'Sharing' , 'jetpack' ); ?></h4> @@ -303,7 +303,7 @@ add_filter( 'jetpack_learn_more_button_sharedaddy', 'sharedaddy_load_more_link' function jpatd_more_info() { ?> <div class="jp-info-img"> <a href="http://en.support.wordpress.com/proofreading/"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/after-the-deadline.gif' ) ?>" alt="<?php esc_attr_e( 'Spelling and Grammar', 'jetpack' ) ?>" width="300" height="155" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/spelling.png' ) ?>" alt="<?php esc_attr_e( 'Spelling and Grammar', 'jetpack' ) ?>" width="300" height="150" /> </a> </div> @@ -324,15 +324,13 @@ add_filter( 'jetpack_learn_more_button_after-the-deadline', 'jpatd_load_more_lin // RSS Links Widget, Image Widget, Twitter Widget function jetpack_widgets_more_info() { ?> <div class="jp-info-img"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/widgets.png' ) ?>" alt="<?php esc_attr_e( 'Widgets Screenshot', 'jetpack' ) ?>" width="320" height="119" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/widgets.png' ) ?>" alt="<?php esc_attr_e( 'Widgets Screenshot', 'jetpack' ) ?>" width="300" height="150" /> </div> <h4><?php esc_html_e( 'Extra Sidebar Widgets' , 'jetpack' ); ?></h4> <p><strong><?php esc_html_e( 'The RSS Links Widget ', 'jetpack' ); ?></strong> <?php esc_html_e( "allows you to add links to your blog’s post and comment RSS feeds in your sidebar. This makes it easy for your readers to stay updated when you post new content or receive new comments.", 'jetpack' ) ?></p> - <p><strong><?php esc_html_e( 'The Twitter Widget ', 'jetpack' ); ?></strong> <?php esc_html_e( "shows your latest tweets within a sidebar on your theme. It’s an easy way to add more activity to your site. There are also a number of customization options.", 'jetpack' ) ?></p> - <p><strong><?php esc_html_e( 'The Facebook Like Box Widget ', 'jetpack' ); ?></strong> <?php esc_html_e( "shows your Facebook Like Box within a sidebar on your theme. It’s a great way to let your readers show their support.", 'jetpack' ) ?></p> - <p><strong><?php esc_html_e( 'The Image Widget ', 'jetpack' ); ?></strong><?php esc_html_e( "allows you to easily add images to widget areas in your theme. It’s an easy way to add more visual interest to your site.", 'jetpack' ) ?></p> + <p><strong><?php esc_html_e( 'The Twitter Widget ', 'jetpack' ); ?></strong> <?php esc_html_e( "shows your latest tweets within a sidebar on your theme. It’s an easy way to add more activity to your site. There are also a number of customization options.", 'jetpack' ) ?> <strong><?php esc_html_e( 'The Facebook Like Box Widget ', 'jetpack' ); ?></strong> <?php esc_html_e( "shows your Facebook Like Box within a sidebar on your theme. It’s a great way to let your readers show their support.", 'jetpack' ) ?> <strong><?php esc_html_e( 'The Image Widget ', 'jetpack' ); ?></strong><?php esc_html_e( "allows you to easily add images to widget areas in your theme. It’s an easy way to add more visual interest to your site.", 'jetpack' ) ?></p> <?php } @@ -340,7 +338,7 @@ add_action( 'jetpack_module_more_info_widgets', 'jetpack_widgets_more_info' ); function jetpack_widgets_more_info_connected() { ?> <div class="jp-info-img"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/widgets.png' ) ?>" alt="<?php esc_attr_e( 'Widgets Screenshot', 'jetpack' ) ?>" width="320" height="119" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/widgets.png' ) ?>" alt="<?php esc_attr_e( 'Widgets Screenshot', 'jetpack' ) ?>" width="300" height="150" /> </div> <h4><?php esc_html_e( 'Extra Sidebar Widgets' , 'jetpack' ); ?></h4> @@ -363,7 +361,7 @@ add_filter( 'jetpack_learn_more_button_widgets', 'jetpack_widgets_load_more_link // Subscriptions function jetpack_subscriptions_more_info() { ?> <div class="jp-info-img"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/subscriptions.png' ) ?>" alt="<?php esc_attr_e( 'Subsriptions Screenshot', 'jetpack' ) ?>" width="320" height="119" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/subscriptions.png' ) ?>" alt="<?php esc_attr_e( 'Subsriptions Screenshot', 'jetpack' ) ?>" width="300" height="150" /> </div> <h4><?php esc_html_e( 'Subscriptions' , 'jetpack' ); ?></h4> @@ -410,7 +408,7 @@ function jetpack_contact_form_learn_more_button() { function jetpack_contact_form_more_info() { echo '<div class="jp-info-img">'; echo '<a href="http://support.wordpress.com/contact-form/">'; - echo '<img class="jp-info-img" src="' . plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/contact-form.jpg' ) . '" alt="' . esc_attr__( 'Contact Form', 'jetpack' ) . '" width="194" height="148" />'; + echo '<img class="jp-info-img" src="' . plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/contactform.png' ) . '" alt="' . esc_attr__( 'Contact Form', 'jetpack' ) . '" width="300" height="150" />'; echo '</a>'; echo '</div>'; @@ -437,7 +435,7 @@ function jetpack_comments_learn_more_button() { function jetpack_comments_more_info() { ?> <div class="jp-info-img"> - <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/comments.png' ) ?>" alt="<?php esc_attr_e( 'Jetpack Comments Screenshot', 'jetpack' ) ?>" width="320" height="205" /> + <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/comments.png' ) ?>" alt="<?php esc_attr_e( 'Jetpack Comments Screenshot', 'jetpack' ) ?>" width="300" height="150" /> </div> <h4><?php esc_html_e( 'Jetpack Comments', 'jetpack' ); ?></h4> @@ -473,9 +471,7 @@ function jetpack_carousel_more_info() { <h4><?php esc_html_e( 'Carousel', 'jetpack' ); ?></h4> - <p> - With Carousel active, any standard WordPress galleries you have embedded in posts or pages will launch a gorgeous full-screen photo browsing experience with comments and EXIF metadata. - </p> + <p><?php esc_html_e( 'With Carousel active, any standard WordPress galleries you have embedded in posts or pages will launch a gorgeous full-screen photo browsing experience with comments and EXIF metadata.', 'jetpack' ); ?></p> <?php } diff --git a/plugins/jetpack/modules/sharedaddy.php b/plugins/jetpack/modules/sharedaddy.php index 45eeb0c8..fa7b36a1 100644 --- a/plugins/jetpack/modules/sharedaddy.php +++ b/plugins/jetpack/modules/sharedaddy.php @@ -2,7 +2,7 @@ /** * Module Name: Sharing * Module Description: The most super duper sharing tool on the interwebs. Share content with Facebook, Twitter, and many more. - * Sort Order: 4 + * Sort Order: 5 * First Introduced: 1.1 * Major Changes In: 1.2 */ diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing.css b/plugins/jetpack/modules/sharedaddy/admin-sharing.css index 80c4fb89..fd0e3d43 100644 --- a/plugins/jetpack/modules/sharedaddy/admin-sharing.css +++ b/plugins/jetpack/modules/sharedaddy/admin-sharing.css @@ -57,7 +57,7 @@ -moz-border-radius: 6px; -webkit-border-radius: 6px; padding: 5px 10px 5px 24px; - margin-right: 10px; + margin-right: 5px !important; cursor: move; } @@ -70,21 +70,78 @@ .preview { float: left !important; + width: 98%; } +.services ul.preview li, .services ul.archive li { + border: none; +} + + +.services ul li#facebook, #available-services .preview-facebook div.option-smart-off{background: #FFF url(images/facebook.png) no-repeat 4px 5px;} +.services ul li#twitter, #available-services .preview-twitter div.option-smart-off{background: #FFF url(images/twitter.png?1) no-repeat 4px 5px;} +.services ul li#wordpress, #available-services .preview-wordpress{background: #FFF url(images/wordpress.png) no-repeat 4px 5px;} +.services ul li#digg, #available-services .preview-digg div.option-smart-off{background: #FFF url(images/digg.png) no-repeat 4px 5px;} +.services ul li#reddit, #available-services .preview-reddit div.option-smart-off{background: #FFF url(images/reddit.png) no-repeat 4px 5px;} +.services ul li#stumbleupon, #available-services .preview-stumbleupon div.option-smart-off{background: #FFF url(images/stumbleupon.png) no-repeat 4px 5px;} +.services ul li#email, #available-services .preview-email{background: #FFF url(images/email.png) no-repeat 4px 5px; padding-right: 10px;} +.services ul li#print, #available-services .preview-print{background: #FFF url(images/print.png) no-repeat 4px 5px; padding-right: 10px;} +.services ul li#press-this, #available-services .preview-press-this{background: #FFF url(images/wordpress.png) no-repeat 4px 5px; padding-right: 10px;} +.services ul li#linkedin, #available-services .preview-linkedin div.option-smart-off{background: #FFF url(images/linkedin.png) no-repeat 4px 5px;} +.services ul li#tumblr,#available-services .preview-tumblr{background: #FFF url(images/tumblr.png) no-repeat 4px 5px; padding-right: 10px;} +.services ul li#google-plus-1,#available-services .preview-google-plus-1{background: #FFF url(images/googleplus1.png) no-repeat 4px 5px; padding-right: 10px;} +.services ul li#pinterest,#available-services .preview-pinterest{background: #FFF url(images/pinterest.png) no-repeat 4px 5px; padding-right: 10px;} +.services ul li.share-custom, #available-services .preview-custom{background: #FFF url(images/custom.png) no-repeat 4px 5px; no-repeat 4px 5px; padding-right: 10px;} + + + +@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { + + .services ul li#facebook, #available-services .preview-facebook div.option-smart-off{background: #FFF url(images/facebook@2x.png) no-repeat 4px 5px;} + .services ul li#twitter, #available-services .preview-twitter div.option-smart-off{background: #FFF url(images/twitter@2x.png?1) no-repeat 4px 5px;} + .services ul li#wordpress, #available-services .preview-wordpress{background: #FFF url(images/wordpress@2x.png?1) no-repeat 4px 5px;} + .services ul li#digg, #available-services .preview-digg div.option-smart-off{background: #FFF url(images/digg@2x.png) no-repeat 4px 5px;} + .services ul li#reddit, #available-services .preview-reddit div.option-smart-off{background: #FFF url(images/reddit@2x.png) no-repeat 4px 5px;} + .services ul li#stumbleupon, #available-services .preview-stumbleupon div.option-smart-off{background: #FFF url(images/stumbleupon@2x.png) no-repeat 4px 5px;} + .services ul li#email, #available-services .preview-email{background: #FFF url(images/email@2x.png) no-repeat 4px 5px; padding-right: 10px;} + .services ul li#print, #available-services .preview-print{background: #FFF url(images/print@2x.png) no-repeat 4px 5px; padding-right: 10px;} + .services ul li#press-this, #available-services .preview-press-this{background: #FFF url(images/wordpress@2x.png) no-repeat 4px 5px; padding-right: 10px;} + .services ul li#linkedin, #available-services .preview-linkedin div.option-smart-off{background: #FFF url(images/linkedin@2x.png) no-repeat 4px 5px;} + .services ul li#tumblr,#available-services .preview-tumblr{background: #FFF url(images/tumblr@2x.png) no-repeat 4px 5px; padding-right: 10px;} + .services ul li#google-plus-1,#available-services .preview-google-plus-1{background: #FFF url(images/googleplus1@2x.png) no-repeat 4px 5px; padding-right: 10px;} + .services ul li#pinterest,#available-services .preview-pinterest{background: #FFF url(images/pinterest@2x.png) no-repeat 4px 5px; padding-right: 10px;} + .services ul li.share-custom, #available-services .preview-custom{background: #FFF url(images/custom@2x.png) no-repeat 4px 5px; no-repeat 4px 5px; padding-right: 10px;} + + .services ul li#facebook, #available-services .preview-facebook div.option-smart-off, + .services ul li#twitter, #available-services .preview-twitter div.option-smart-off, + .services ul li#wordpress, #available-services .preview-wordpress, + .services ul li#digg, #available-services .preview-digg div.option-smart-off, + .services ul li#reddit, #available-services .preview-reddit div.option-smart-off, + .services ul li#stumbleupon, #available-services .preview-stumbleupon div.option-smart-off, + .services ul li#email, #available-services .preview-email, + .services ul li#print, #available-services .preview-print, + .services ul li#press-this, #available-services .preview-press-this, + .services ul li#linkedin, #available-services .preview-linkedin div.option-smart-off, + .services ul li#tumblr,#available-services .preview-tumblr, + .services ul li#google-plus-1,#available-services .preview-google-plus-1, + .services ul li#pinterest,#available-services .preview-pinterest, + .services ul li.share-custom, #available-services .preview-custom{ + background-size: 16px 16px; + } + + + + + + + + + + + + +} -.services ul li#facebook, .preview-facebook div.option-smart-off{background: #FFF url(images/facebook.png) no-repeat 4px 5px;} -.services ul li#twitter, .preview-twitter div.option-smart-off{background: #FFF url(images/twitter.png) no-repeat 4px 5px;} -.services ul li#wordpress, .preview-wordpress{background: #FFF url(images/wordpress.png) no-repeat 4px 5px;} -.services ul li#digg, .preview-digg div.option-smart-off{background: #FFF url(images/digg.png) no-repeat 4px 5px;} -.services ul li#reddit, .preview-reddit div.option-smart-off{background: #FFF url(images/reddit.png) no-repeat 4px 5px;} -.services ul li#stumbleupon, .preview-stumbleupon div.option-smart-off{background: #FFF url(images/stumbleupon.png) no-repeat 4px 5px;} -.services ul li#email, .preview-email{background: #FFF url(images/email.png) no-repeat 4px 5px; padding-right: 10px;} -.services ul li#print, .preview-print{background: #FFF url(images/print.png) no-repeat 4px 5px; padding-right: 10px;} -.services ul li#press-this, .preview-press-this{background: #FFF url(images/wordpress.png) no-repeat 4px 5px; padding-right: 10px;} -.services ul li#linkedin, .preview-linkedin div.option-smart-off{background: #FFF url(images/linkedin.png) no-repeat 4px 5px;} -.services ul li#google-plus-1,.preview-google-plus-1{background: #FFF url(images/googleplus1.png) no-repeat 4px 5px; padding-right: 10px;} -.services ul li.share-custom, .preview-custom{background: #FFF url(images/custom.png) no-repeat 4px 5px; no-repeat 4px 5px; padding-right: 10px;} /****************************************************************************/ @@ -96,77 +153,81 @@ cursor: default; } -.preview li.preview-digg, .preview li.preview-reddit, .preview li.preview-stumbleupon, .preview li.preview-facebook, .preview li.preview-twitter, .preview li.preview-linkedin { +.preview li.preview-digg, +.preview li.preview-reddit, +.preview li.preview-stumbleupon, +.preview li.preview-facebook, +.preview li.preview-twitter, +.preview li.preview-linkedin, +.preview li.preview-tumblr { padding: 0; } -.preview-digg .option-smart-off, .preview-reddit .option-smart-off, .preview-stumbleupon .option-smart-off, .preview-facebook .option-smart-off, .preview-twitter .option-smart-off, .preview-linkedin .option-smart-off { - background-position: 0px 5px !important; - padding: 5px 0px 5px 20px; -} - .preview-digg .option-smart-on { background: #FFF url(images/smart-digg.png) no-repeat top left; width:76px; height:17px; - margin-top: 5px; + margin-top: 2px; } .preview-reddit .option-smart-on { background: #FFF url(images/smart-reddit.png) no-repeat top left; width:104px; height:21px; - margin-top: 3px; } .preview-stumbleupon .option-smart-on { background: #FFF url(images/smart-stumbleupon.png) no-repeat top left; width: 74px; height: 18px; - margin-top: 4px; + margin-top: 1px; } -.preview-facebook .option-smart-like { +.preview-facebook .option-smart-on { background: #FFF url(images/smart-like.png) no-repeat top left; width:50px; height:20px; - margin-top: 3px; -} - -.preview-facebook .option-smart-on { - background: #FFF url(images/smart-facebook.png) no-repeat top left; - width:60px; - height:18px; - margin-top: 4px; } .preview-twitter .option-smart-on { - background: #FFF url(images/smart-twitter.png) no-repeat top left; + background: #FFF url(images/smart-twitter.png?1) no-repeat top left; width:92px; height:20px; - margin-top: 3px; } .preview-linkedin .option-smart-on { background: #FFF url(images/linkedin-smart.png) no-repeat top center; width:99px; height:22px; - margin-top: 3px; + margin-top: 1px; } .preview-google-plus-1 .option-smart-on { + background: #FFF url(images/smart-googleplus1.png) no-repeat top left; max-width: 70px; - width: 15px; - height: 15px; - margin-top: 4px; + width: 60px; + height: 20px; +} + +.preview-tumblr .option-smart-on { + background: #FFF url(images/smart-tumblr.png) no-repeat top left; + width: 62px; + height: 20px; +} + +.preview-pinterest .option-smart-on { + background: #FFF url(images/smart-pinterest.png) no-repeat top left; + width: 58px; + height: 20px; } +div.sharedaddy .preview-google-plus-1 .no-text { width: 60px; } + .services .preview li.share-custom { border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px; background:url("images/sharing-hidden.png") no-repeat scroll 0px center #FFFFFF; - border: 1px solid #D8D8D8; float: left; line-height: 22px; padding: 0 8px 0 21px; @@ -217,38 +278,11 @@ .clearing{ clear: both; } - -.options-toggle{ -} - #available-services .options-toggle { - display: none; - } - .services ul li.options{ - padding-right: 0px; - } - .options .options-left{ float: left; } - .options .options-toggle{ - float: left; - width: 24px; - height: 26px; - margin-top:-6px; - margin-left: 5px; - margin-bottom:-5px; - } - - html>body .options .options-toggle{ - float: right; - } - - .options-open .options-toggle{ - margin-top:-5px; - } - .input label{ font-size: 11px; line-height: 16px; @@ -262,11 +296,6 @@ margin-top:4px; } - - .services ul li.options-open .advanced-form{ - display: block; - } - .utility{ float: right; padding-top:10px; @@ -322,18 +351,12 @@ .sharing-hidden ul { - background: #fff url('images/share-bg.png') repeat-y center center; margin: 0 !important; } .services .sharing-hidden li { margin: 0px 10px 0px 10px; background-color: transparent; - width: 100px; -} - -.sharing-hidden .preview-digg, .sharing-hidden .preview-reddit, .sharing-hidden .preview-stumbleupon, .sharing-hidden .preview-facebook, .sharing-hidden .preview-twitter, .sharing-hidden .preview-linkedin, .sharing-hidden .preview-google-plus-1 { - width: 120px !important; } .sharing-hidden li.share-end { @@ -351,3 +374,19 @@ border: 0; padding: 4px 6px 0 0; } + +#services-config a.remove { + background: #ddd; + color: #fff; + padding: 0px 4px 2px; + border-radius: 15px; + -moz-border-radius: 15px; + -webkit-border-radius: 15px; + text-decoration: none; + font-weight: bold; + font-size: 10px; +} + +#services-config a.remove:hover { + background: #f00; +} diff --git a/plugins/jetpack/modules/sharedaddy/admin-sharing.js b/plugins/jetpack/modules/sharedaddy/admin-sharing.js index 4a93eab8..a11d469f 100644 --- a/plugins/jetpack/modules/sharedaddy/admin-sharing.js +++ b/plugins/jetpack/modules/sharedaddy/admin-sharing.js @@ -3,12 +3,11 @@ function enable_share_button() { $( '.preview a.sharing-anchor' ).unbind( 'mouseenter mouseenter' ).hover( function() { if ( $( this ).data( 'hasappeared' ) !== true ) { - var item = $( this ).parents( 'li:first' ).find( '.inner' ); - var original = $( this ).parents( '.share-custom' ); + var item = $( '.sharing-hidden .inner' ); + var original = $( this ).parents( 'li' ); // Create a timer to make the area appear if the mouse hovers for a period var timer = setTimeout( function() { - $( item ).css( { left: $( original ).position().left + 'px', top: $( original ).position().top + $( original ).height() + 3 + 'px' @@ -77,6 +76,7 @@ function update_preview() { var item; + var button_style = $( '#button_style' ).val(); // Clear the live preview $( '#live-preview ul.preview li' ).remove(); @@ -89,41 +89,45 @@ $( 'ul.services-enabled li' ).each( function() { if ( $( this ).hasClass( 'service' ) ) { var service = $( this ).attr( 'id' ); - - $( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive .preview-' + service ).clone() ); + $( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive li.preview-' + service ).clone() ); } } ); - // Add any preview items + // Add any hidden items if ( $( '#save-enabled-shares input[name=hidden]' ).val() != '' ) { // Add share button - $( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive .share-custom' ).clone() ); - $( '#live-preview ul.preview li.share-custom ul li' ).remove(); + $( '#live-preview ul.preview' ).append( $( '#live-preview ul.archive .share-more' ).parent().clone() ); + + $( '.sharing-hidden ul li' ).remove(); - // Add rest of the items + // Add hidden items into the inner panel $( 'ul.services-hidden li' ).each( function( pos, item ) { if ( $( this ).hasClass( 'service' ) ) { var service = $( this ).attr( 'id' ); - - $( '#live-preview ul.preview li.share-custom ul' ).append( $( '#live-preview ul.archive .preview-' + service ).clone() ); - - if ( pos % 2 == 1 ) - $( '#live-preview ul.preview li.share-custom ul' ).append( '<li class="share-end"></div>' ); + $( '.sharing-hidden .inner ul' ).append( $( '#live-preview ul.archive .preview-' + service ).clone() ); } } ); enable_share_button(); } + + $( '#live-preview div.sharedaddy' ).removeClass( 'sd-social-icon' ); + $( '#live-preview li.advanced' ).removeClass( 'no-icon' ); // Button style - if ( $( 'select[name=button_style]' ).val() == 'icon' ) - $( '#live-preview ul.preview .option' ).html( ' ' ); // Remove the text - else if ( $( 'select[name=button_style]' ).val() == 'text' ) { - $( '#live-preview ul.preview li.advanced' ).each( function() { - if ( $( this ).find( '.option' ).hasClass( 'option-smart-on' ) === false && $( this ).find( '.option' ).hasClass( 'option-smart-like' ) === false ) - $( this ).attr( 'class', 'advanced preview-item' ); + if ( 'icon' == button_style ) { + $( '#live-preview ul.preview div span' ).html( ' ' ).parent().addClass( 'no-text' ); // Remove text label + $( '#live-preview div.sharedaddy' ).addClass( 'sd-social-icon' ); + } else if ( 'official' == button_style ) { + $( '#live-preview ul.preview .advanced' ).each( function( i ) { + if ( !$( this ).hasClass( 'preview-press-this' ) && !$( this ).hasClass( 'preview-email' ) && !$( this ).hasClass( 'preview-print' ) && !$( this ).hasClass( 'share-custom' ) ) { + $( this ).find( '.option a span' ).html( '' ).parent().removeClass( 'sd-button' ).parent().attr( 'class', 'option option-smart-on' ); + } } ); - } + } else if ( 'text' == button_style ) { + $( '#live-preview li.advanced' ).addClass( 'no-icon' ); + } + } function sharing_option_changed() { @@ -142,8 +146,6 @@ // Update the DOM using a bit of cut/paste technology $( item ).parents( 'li:first' ).replaceWith( button ); - - init_handlers(); } $( '#live-preview ul.archive li.preview-' + $( item ).parents( 'form' ).find( 'input[name=service]' ).val() ).replaceWith( preview ); @@ -164,10 +166,6 @@ function save_services() { $( '#enabled-services h3 img' ).show(); - // Update the display to reflect the changes - $( '#enabled-services li' ).addClass( 'options' ); - $( '#available-services li' ).removeClass( 'options' ); - // Toggle various dividers/help texts if ( $( '#enabled-services ul.services-enabled li.service' ).length > 0 ) { $( '#drag-instructions' ).hide(); @@ -264,18 +262,7 @@ $( '.advanced-form' ).hide(); } } ); - - // Advanced options toggle - $( '.options-toggle' ).live( 'click', function() { - var was_visible = $( this ).parents( 'li:first' ).find( '.advanced-form' ).is( ':visible' ); - - // Hide everything - $( '.advanced-form' ).slideUp( 200 ); - - if ( !was_visible ) - $( this ).parents( 'li:first' ).find( '.advanced-form' ).slideDown( 200 ); - } ); - + // Live preview 'hidden' button $( '.preview-hidden a' ).click( function() { $( this ).parent().find( '.preview' ).toggle(); @@ -287,7 +274,7 @@ beforeSubmit: function() { $( '#new-service-form .error' ).hide(); $( '#new-service-form img' ).show(); - $( '#new-service-form input[type=submit]' ).attr( 'disabled', true ); + $( '#new-service-form input[type=submit]' ).prop( 'disabled', true ); }, success: function( response ) { $( '#new-service-form img' ).hide(); @@ -295,31 +282,24 @@ if ( response == '1' ) { $( '#new-service-form .inerror' ).removeClass( 'inerror' ).addClass( 'error' ); $( '#new-service-form .error' ).show(); - $( '#new-service-form input[type=submit]' ).attr( 'disabled', false ); + $( '#new-service-form input[type=submit]' ).prop( 'disabled', false ); } else { - document.location.reload(); + document.location = document.location.href.replace( /&create_new_service=true/i, '' ); } } } ); function init_handlers() { - // Hook up all advanced options - $( '.advanced-form form input[type=checkbox]' ).unbind( 'click' ).click( sharing_option_changed ); - $( '.advanced-form form select' ).unbind( 'change' ).change( sharing_option_changed ); - $( '.advanced-form form input[type=submit]' ).unbind( 'click' ).click( sharing_option_changed ); - - $( '.advanced-form form a.remove' ).unbind( 'click' ).click( function() { - var form = $( this ).parents( 'form' ); + $( '#services-config a.remove' ).unbind( 'click' ).click( function() { + var form = $( this ).parent().next(); - form.find( 'input[name=action]' ).val( 'sharing_delete_service' ); - // Loading icon $( this ).parents( 'li:first' ).css( 'backgroundImage', 'url("' + sharing_loading_icon + '")' ); // Save - $( this ).parents( 'form' ).ajaxSubmit( function( response ) { + form.ajaxSubmit( function( response ) { // Remove the item form.parents( 'li:first' ).fadeOut( function() { $( this ).remove(); @@ -333,13 +313,13 @@ } ); } - $( 'select[name=button_style]' ).change( function() { + $( '#button_style' ).change( function() { update_preview(); return true; - } ); + } ).change(); $( 'input[name=sharing_label]' ).blur( function() { - $('#live-preview ul.preview li.sharing-label').html( $( '<div/>' ).text( $( this ).val() ).html() ); + $('#live-preview h3.sd-title').html( $( '<div/>' ).text( $( this ).val() ).html() ); } ); init_handlers(); diff --git a/plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.png b/plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.png Binary files differnew file mode 100644 index 00000000..8c5858c0 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/after-the-deadline@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/comments@2x.png b/plugins/jetpack/modules/sharedaddy/images/comments@2x.png Binary files differnew file mode 100644 index 00000000..7558243c --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/comments@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/contact-form@2x.png b/plugins/jetpack/modules/sharedaddy/images/contact-form@2x.png Binary files differnew file mode 100644 index 00000000..504450fd --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/contact-form@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/custom@2x.png b/plugins/jetpack/modules/sharedaddy/images/custom@2x.png Binary files differnew file mode 100644 index 00000000..57521606 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/custom@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/digg@2x.png b/plugins/jetpack/modules/sharedaddy/images/digg@2x.png Binary files differnew file mode 100644 index 00000000..db79f166 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/digg@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/divider@2x.png b/plugins/jetpack/modules/sharedaddy/images/divider@2x.png Binary files differnew file mode 100644 index 00000000..1c985389 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/divider@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/draggy@2x.png b/plugins/jetpack/modules/sharedaddy/images/draggy@2x.png Binary files differnew file mode 100644 index 00000000..03c3ee91 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/draggy@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/email.png b/plugins/jetpack/modules/sharedaddy/images/email.png Binary files differindex 2ea4d7b0..e7f69f6d 100644 --- a/plugins/jetpack/modules/sharedaddy/images/email.png +++ b/plugins/jetpack/modules/sharedaddy/images/email.png diff --git a/plugins/jetpack/modules/sharedaddy/images/email@2x.png b/plugins/jetpack/modules/sharedaddy/images/email@2x.png Binary files differnew file mode 100644 index 00000000..13f658c2 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/email@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/ember.png b/plugins/jetpack/modules/sharedaddy/images/ember.png Binary files differindex 1a285a2a..4ab956e0 100644 --- a/plugins/jetpack/modules/sharedaddy/images/ember.png +++ b/plugins/jetpack/modules/sharedaddy/images/ember.png diff --git a/plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.png b/plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.png Binary files differnew file mode 100644 index 00000000..59912d76 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/enhanced-distribution@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/facebook@2x.png b/plugins/jetpack/modules/sharedaddy/images/facebook@2x.png Binary files differnew file mode 100644 index 00000000..a88a52f6 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/facebook@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/googleplus1.png b/plugins/jetpack/modules/sharedaddy/images/googleplus1.png Binary files differindex 22cb1df8..5f0a05e5 100644 --- a/plugins/jetpack/modules/sharedaddy/images/googleplus1.png +++ b/plugins/jetpack/modules/sharedaddy/images/googleplus1.png diff --git a/plugins/jetpack/modules/sharedaddy/images/googleplus1@2x.png b/plugins/jetpack/modules/sharedaddy/images/googleplus1@2x.png Binary files differnew file mode 100644 index 00000000..26054392 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/googleplus1@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.png Binary files differnew file mode 100644 index 00000000..92816042 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal.png diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.png Binary files differnew file mode 100644 index 00000000..f8402fb6 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-horizontal@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.png Binary files differnew file mode 100644 index 00000000..4a09a2d1 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount.png diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.png Binary files differnew file mode 100644 index 00000000..f995d57a --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-nocount@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png Binary files differindex a828ad6f..92816042 100644 --- a/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png +++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart.png diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.png Binary files differnew file mode 100644 index 00000000..f8402fb6 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-smart@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.png Binary files differnew file mode 100644 index 00000000..c5edb5e2 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical.png diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.png Binary files differnew file mode 100644 index 00000000..06dcf8bc --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/linkedin-vertical@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin.png b/plugins/jetpack/modules/sharedaddy/images/linkedin.png Binary files differindex 0d727c2c..79e3570c 100644 --- a/plugins/jetpack/modules/sharedaddy/images/linkedin.png +++ b/plugins/jetpack/modules/sharedaddy/images/linkedin.png diff --git a/plugins/jetpack/modules/sharedaddy/images/linkedin@2x.png b/plugins/jetpack/modules/sharedaddy/images/linkedin@2x.png Binary files differnew file mode 100644 index 00000000..b626250b --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/linkedin@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/more.png b/plugins/jetpack/modules/sharedaddy/images/more.png Binary files differnew file mode 100644 index 00000000..efe3bc7c --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/more.png diff --git a/plugins/jetpack/modules/sharedaddy/images/more@2x.png b/plugins/jetpack/modules/sharedaddy/images/more@2x.png Binary files differnew file mode 100644 index 00000000..a55e8e79 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/more@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/pinterest.png b/plugins/jetpack/modules/sharedaddy/images/pinterest.png Binary files differnew file mode 100644 index 00000000..cd5e6940 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/pinterest.png diff --git a/plugins/jetpack/modules/sharedaddy/images/pinterest@2x.png b/plugins/jetpack/modules/sharedaddy/images/pinterest@2x.png Binary files differnew file mode 100644 index 00000000..5efebd91 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/pinterest@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/print.png b/plugins/jetpack/modules/sharedaddy/images/print.png Binary files differindex 19a245fa..5f4c53ba 100644 --- a/plugins/jetpack/modules/sharedaddy/images/print.png +++ b/plugins/jetpack/modules/sharedaddy/images/print.png diff --git a/plugins/jetpack/modules/sharedaddy/images/print@2x.png b/plugins/jetpack/modules/sharedaddy/images/print@2x.png Binary files differnew file mode 100644 index 00000000..7fa0c2a2 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/print@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/reddit@2x.png b/plugins/jetpack/modules/sharedaddy/images/reddit@2x.png Binary files differnew file mode 100644 index 00000000..03d005ae --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/reddit@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/rss@2x.png b/plugins/jetpack/modules/sharedaddy/images/rss@2x.png Binary files differnew file mode 100644 index 00000000..812b9098 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/rss@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/share-bg.png b/plugins/jetpack/modules/sharedaddy/images/share-bg.png Binary files differindex f74ed039..bfd196ff 100644 --- a/plugins/jetpack/modules/sharedaddy/images/share-bg.png +++ b/plugins/jetpack/modules/sharedaddy/images/share-bg.png diff --git a/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png Binary files differindex 96072621..c87f825e 100644 --- a/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png +++ b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden.png diff --git a/plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.png b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.png Binary files differnew file mode 100644 index 00000000..c8129fbc --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/sharing-hidden@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-digg.png b/plugins/jetpack/modules/sharedaddy/images/smart-digg.png Binary files differindex ce654de4..8753421c 100644 --- a/plugins/jetpack/modules/sharedaddy/images/smart-digg.png +++ b/plugins/jetpack/modules/sharedaddy/images/smart-digg.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.png Binary files differnew file mode 100644 index 00000000..1a76fd5e --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-digg@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.png Binary files differnew file mode 100644 index 00000000..7fa8606c --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-facebook@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1.png b/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1.png Binary files differnew file mode 100644 index 00000000..ba593f5a --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1@2x.png Binary files differnew file mode 100644 index 00000000..0bb999a4 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-googleplus1@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-like.png b/plugins/jetpack/modules/sharedaddy/images/smart-like.png Binary files differindex 98cfc345..e1ac8263 100644 --- a/plugins/jetpack/modules/sharedaddy/images/smart-like.png +++ b/plugins/jetpack/modules/sharedaddy/images/smart-like.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-like@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-like@2x.png Binary files differnew file mode 100644 index 00000000..4b99fa57 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-like@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-pinterest.png b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest.png Binary files differnew file mode 100644 index 00000000..16138cfc --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.png Binary files differnew file mode 100644 index 00000000..aab464d6 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-pinterest@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png b/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png Binary files differindex 4788a507..a8c4c6e6 100644 --- a/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png +++ b/plugins/jetpack/modules/sharedaddy/images/smart-reddit.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.png Binary files differnew file mode 100644 index 00000000..5b1fa3eb --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-reddit@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png Binary files differindex 8851447c..922d84b9 100644 --- a/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png +++ b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.png Binary files differnew file mode 100644 index 00000000..82f3b88c --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-stumbleupon@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-tumblr.png b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr.png Binary files differnew file mode 100644 index 00000000..ca902bdc --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.png Binary files differnew file mode 100644 index 00000000..e5b39877 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-tumblr@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png b/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png Binary files differindex e14da3e8..a5537328 100644 --- a/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png +++ b/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png Binary files differnew file mode 100644 index 00000000..fcf26f40 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png b/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png Binary files differindex af4e9564..5b4858f7 100644 --- a/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png +++ b/plugins/jetpack/modules/sharedaddy/images/stumbleupon.png diff --git a/plugins/jetpack/modules/sharedaddy/images/stumbleupon@2x.png b/plugins/jetpack/modules/sharedaddy/images/stumbleupon@2x.png Binary files differnew file mode 100644 index 00000000..8e05201d --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/stumbleupon@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/tumblr.png b/plugins/jetpack/modules/sharedaddy/images/tumblr.png Binary files differnew file mode 100644 index 00000000..cc4775c6 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/tumblr.png diff --git a/plugins/jetpack/modules/sharedaddy/images/tumblr@2x.png b/plugins/jetpack/modules/sharedaddy/images/tumblr@2x.png Binary files differnew file mode 100644 index 00000000..31ee7847 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/tumblr@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/twitter.png b/plugins/jetpack/modules/sharedaddy/images/twitter.png Binary files differindex 1734a8a4..ec41046e 100644 --- a/plugins/jetpack/modules/sharedaddy/images/twitter.png +++ b/plugins/jetpack/modules/sharedaddy/images/twitter.png diff --git a/plugins/jetpack/modules/sharedaddy/images/twitter@2x.png b/plugins/jetpack/modules/sharedaddy/images/twitter@2x.png Binary files differnew file mode 100644 index 00000000..cd4a0967 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/twitter@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/images/wordpress.png b/plugins/jetpack/modules/sharedaddy/images/wordpress.png Binary files differindex 6b560450..c07bdb72 100644 --- a/plugins/jetpack/modules/sharedaddy/images/wordpress.png +++ b/plugins/jetpack/modules/sharedaddy/images/wordpress.png diff --git a/plugins/jetpack/modules/sharedaddy/images/wordpress@2x.png b/plugins/jetpack/modules/sharedaddy/images/wordpress@2x.png Binary files differnew file mode 100644 index 00000000..563b5cbc --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/images/wordpress@2x.png diff --git a/plugins/jetpack/modules/sharedaddy/recaptchalib.php b/plugins/jetpack/modules/sharedaddy/recaptchalib.php new file mode 100644 index 00000000..a9716772 --- /dev/null +++ b/plugins/jetpack/modules/sharedaddy/recaptchalib.php @@ -0,0 +1,277 @@ +<?php +/* + * This is a PHP library that handles calling reCAPTCHA. + * - Documentation and latest version + * http://recaptcha.net/plugins/php/ + * - Get a reCAPTCHA API Key + * https://www.google.com/recaptcha/admin/create + * - Discussion group + * http://groups.google.com/group/recaptcha + * + * Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net + * AUTHORS: + * Mike Crawford + * Ben Maurer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * The reCAPTCHA server URL's + */ +define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api"); +define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api"); +define("RECAPTCHA_VERIFY_SERVER", "www.google.com"); + +/** + * Encodes the given data into a query string format + * @param $data - array of string elements to be encoded + * @return string - encoded request + */ +function _recaptcha_qsencode ($data) { + $req = ""; + foreach ( $data as $key => $value ) + $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; + + // Cut the last '&' + $req=substr($req,0,strlen($req)-1); + return $req; +} + + + +/** + * Submits an HTTP POST to a reCAPTCHA server + * @param string $host + * @param string $path + * @param array $data + * @param int port + * @return array response + */ +function _recaptcha_http_post($host, $path, $data, $port = 80) { + + $req = _recaptcha_qsencode ($data); + + $http_request = "POST $path HTTP/1.0\r\n"; + $http_request .= "Host: $host\r\n"; + $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; + $http_request .= "Content-Length: " . strlen($req) . "\r\n"; + $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; + $http_request .= "\r\n"; + $http_request .= $req; + + $response = ''; + if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { + die ('Could not open socket'); + } + + fwrite($fs, $http_request); + + while ( !feof($fs) ) + $response .= fgets($fs, 1160); // One TCP-IP packet + fclose($fs); + $response = explode("\r\n\r\n", $response, 2); + + return $response; +} + + + +/** + * Gets the challenge HTML (javascript and non-javascript version). + * This is called from the browser, and the resulting reCAPTCHA HTML widget + * is embedded within the HTML form it was called from. + * @param string $pubkey A public key for reCAPTCHA + * @param string $error The error given by reCAPTCHA (optional, default is null) + * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false) + + * @return string - The HTML to be embedded in the user's form. + */ +function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) +{ + if ($pubkey == null || $pubkey == '') { + die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>"); + } + + if ($use_ssl) { + $server = RECAPTCHA_API_SECURE_SERVER; + } else { + $server = RECAPTCHA_API_SERVER; + } + + $errorpart = ""; + if ($error) { + $errorpart = "&error=" . $error; + } + return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script> + + <noscript> + <iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/> + <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> + <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> + </noscript>'; +} + + + + +/** + * A ReCaptchaResponse is returned from recaptcha_check_answer() + */ +class ReCaptchaResponse { + var $is_valid; + var $error; +} + + +/** + * Calls an HTTP POST function to verify if the user's guess was correct + * @param string $privkey + * @param string $remoteip + * @param string $challenge + * @param string $response + * @param array $extra_params an array of extra variables to post to the server + * @return ReCaptchaResponse + */ +function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array()) +{ + if ($privkey == null || $privkey == '') { + die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>"); + } + + if ($remoteip == null || $remoteip == '') { + die ("For security reasons, you must pass the remote ip to reCAPTCHA"); + } + + + + //discard spam submissions + if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { + $recaptcha_response = new ReCaptchaResponse(); + $recaptcha_response->is_valid = false; + $recaptcha_response->error = 'incorrect-captcha-sol'; + return $recaptcha_response; + } + + $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", + array ( + 'privatekey' => $privkey, + 'remoteip' => $remoteip, + 'challenge' => $challenge, + 'response' => $response + ) + $extra_params + ); + + $answers = explode ("\n", $response [1]); + $recaptcha_response = new ReCaptchaResponse(); + + if (trim ($answers [0]) == 'true') { + $recaptcha_response->is_valid = true; + } + else { + $recaptcha_response->is_valid = false; + $recaptcha_response->error = $answers [1]; + } + return $recaptcha_response; + +} + +/** + * gets a URL where the user can sign up for reCAPTCHA. If your application + * has a configuration page where you enter a key, you should provide a link + * using this function. + * @param string $domain The domain where the page is hosted + * @param string $appname The name of your application + */ +function recaptcha_get_signup_url ($domain = null, $appname = null) { + return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname)); +} + +function _recaptcha_aes_pad($val) { + $block_size = 16; + $numpad = $block_size - (strlen ($val) % $block_size); + return str_pad($val, strlen ($val) + $numpad, chr($numpad)); +} + +/* Mailhide related code */ + +function _recaptcha_aes_encrypt($val,$ky) { + if (! function_exists ("mcrypt_encrypt")) { + die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); + } + $mode=MCRYPT_MODE_CBC; + $enc=MCRYPT_RIJNDAEL_128; + $val=_recaptcha_aes_pad($val); + return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); +} + + +function _recaptcha_mailhide_urlbase64 ($x) { + return strtr(base64_encode ($x), '+/', '-_'); +} + +/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */ +function recaptcha_mailhide_url($pubkey, $privkey, $email) { + if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) { + die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . + "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>"); + } + + + $ky = pack('H*', $privkey); + $cryptmail = _recaptcha_aes_encrypt ($email, $ky); + + return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); +} + +/** + * gets the parts of the email to expose to the user. + * eg, given johndoe@example,com return ["john", "example.com"]. + * the email is then displayed as john...@example.com + */ +function _recaptcha_mailhide_email_parts ($email) { + $arr = preg_split("/@/", $email ); + + if (strlen ($arr[0]) <= 4) { + $arr[0] = substr ($arr[0], 0, 1); + } else if (strlen ($arr[0]) <= 6) { + $arr[0] = substr ($arr[0], 0, 3); + } else { + $arr[0] = substr ($arr[0], 0, 4); + } + return $arr; +} + +/** + * Gets html to display an email address given a public an private key. + * to get a key, go to: + * + * http://www.google.com/recaptcha/mailhide/apikey + */ +function recaptcha_mailhide_html($pubkey, $privkey, $email) { + $emailparts = _recaptcha_mailhide_email_parts ($email); + $url = recaptcha_mailhide_url ($pubkey, $privkey, $email); + + return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) . + "' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]); + +} + + +?>
\ No newline at end of file diff --git a/plugins/jetpack/modules/sharedaddy/sharedaddy.php b/plugins/jetpack/modules/sharedaddy/sharedaddy.php index a7146019..727005e7 100644 --- a/plugins/jetpack/modules/sharedaddy/sharedaddy.php +++ b/plugins/jetpack/modules/sharedaddy/sharedaddy.php @@ -2,7 +2,7 @@ /* Plugin Name: Sharedaddy Description: The most super duper sharing tool on the interwebs. -Version: 0.2.12 +Version: 0.3.1 Author: Automattic, Inc. Author URI: http://automattic.com/ Plugin URI: http://en.blog.wordpress.com/2010/08/24/more-ways-to-share/ @@ -42,17 +42,19 @@ function sharing_meta_box_save( $post_id ) { return $post_id; // Record sharing disable - if ( current_user_can( 'edit_post', $post_id ) ) { - if ( isset( $_POST['sharing_status_hidden'] ) ) { - if ( !isset( $_POST['enable_post_sharing'] ) ) { - update_post_meta( $post_id, 'sharing_disabled', 1 ); - } else { - delete_post_meta( $post_id, 'sharing_disabled' ); + if ( isset( $_POST['post_type'] ) && ( 'post' == $_POST['post_type'] || 'page' == $_POST['post_type'] ) ) { + if ( current_user_can( 'edit_post', $post_id ) ) { + if ( isset( $_POST['sharing_status_hidden'] ) ) { + if ( !isset( $_POST['enable_post_sharing'] ) ) { + update_post_meta( $post_id, 'sharing_disabled', 1 ); + } else { + delete_post_meta( $post_id, 'sharing_disabled' ); + } } } } - - return $post_id; + + return $post_id; } function sharing_meta_box_protected( $protected, $meta_key, $meta_type ) { @@ -99,28 +101,52 @@ function sharing_disable_js() { return false; } +if ( !function_exists( 'sharing_register_post_for_share_counts' ) ) { + function sharing_register_post_for_share_counts() {} +} + function sharing_global_resources() { $disable = get_option( 'sharedaddy_disable_resources' ); ?> <tr valign="top"> <th scope="row"><label for="disable_css"><?php _e( 'Disable CSS and JS', 'jetpack' ); ?></label></th> <td> - <input id="disable_css" type="checkbox" name="disable_resourcse" <?php if ( $disable == 1 ) echo ' checked="checked"'; ?>/> <small><em><?php _e( 'Advanced. If this option is checked, you must include these files in your theme manually for the sharing links to work.', 'jetpack' ); ?></em></small> + <input id="disable_css" type="checkbox" name="disable_resources" <?php if ( $disable == 1 ) echo ' checked="checked"'; ?>/> <small><em><?php _e( 'Advanced. If this option is checked, you must include these files in your theme manually for the sharing links to work.', 'jetpack' ); ?></em></small> </td> </tr> <?php } -function shareing_global_resources_save() { - update_option( 'sharedaddy_disable_resources', isset( $_POST['disable_resourcse'] ) ? 1 : 0 ); +function sharing_global_resources_save() { + update_option( 'sharedaddy_disable_resources', isset( $_POST['disable_resources'] ) ? 1 : 0 ); +} + +function sharing_email_dialog() { + echo '<div class="recaptcha" id="sharing_recaptcha"></div><input type="hidden" name="recaptcha_public_key" id="recaptcha_public_key" value="'.(defined( 'RECAPTCHA_PUBLIC_KEY' ) ? esc_attr( RECAPTCHA_PUBLIC_KEY ) : '').'" />'; +} + +function sharing_email_check( $true, $post, $data ) { + require_once plugin_dir_path( __FILE__ ).'recaptchalib.php'; + + $recaptcha_result = recaptcha_check_answer( RECAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $data["recaptcha_challenge_field"], $data["recaptcha_response_field"] ); + + return $recaptcha_result->is_valid; } -add_action( 'init', 'sharing_init' ); -add_action( 'admin_init', 'sharing_add_meta_box' ); -add_action( 'save_post', 'sharing_meta_box_save' ); -add_action( 'sharing_email_send_post', 'sharing_email_send_post' ); -add_action( 'sharing_global_options', 'sharing_global_resources' ); -add_action( 'sharing_admin_update', 'shareing_global_resources_save' ); -add_filter( 'sharing_services', 'sharing_restrict_to_single' ); -add_action( 'plugin_action_links_'.basename( dirname( __FILE__ ) ).'/'.basename( __FILE__ ), 'sharing_plugin_settings', 10, 4 ); -add_filter( 'plugin_row_meta', 'sharing_add_plugin_settings', 10, 2 ); +// Only run if PHP5 +if ( version_compare( phpversion(), '5.0', '>=' ) ) { + add_action( 'init', 'sharing_init' ); + add_action( 'admin_init', 'sharing_add_meta_box' ); + add_action( 'save_post', 'sharing_meta_box_save' ); + add_action( 'sharing_email_send_post', 'sharing_email_send_post' ); + add_action( 'sharing_global_options', 'sharing_global_resources' ); + add_action( 'sharing_admin_update', 'sharing_global_resources_save' ); + add_filter( 'sharing_services', 'sharing_restrict_to_single' ); + add_action( 'plugin_action_links_'.basename( dirname( __FILE__ ) ).'/'.basename( __FILE__ ), 'sharing_plugin_settings', 10, 4 ); + add_filter( 'plugin_row_meta', 'sharing_add_plugin_settings', 10, 2 ); + + if ( defined( 'RECAPTCHA_PRIVATE_KEY' ) ) { + add_action( 'sharing_email_dialog', 'sharing_email_dialog' ); + add_filter( 'sharing_email_check', 'sharing_email_check', 10, 3 ); + } +} diff --git a/plugins/jetpack/modules/sharedaddy/sharing-service.php b/plugins/jetpack/modules/sharedaddy/sharing-service.php index 1b765cb6..82d7293d 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing-service.php +++ b/plugins/jetpack/modules/sharedaddy/sharing-service.php @@ -2,7 +2,7 @@ include_once dirname( __FILE__ ).'/sharing-sources.php'; -define( 'WP_SHARING_PLUGIN_VERSION', '0.3' ); +define( 'WP_SHARING_PLUGIN_VERSION', '0.3.1' ); class Sharing_Service { private $global = false; @@ -46,7 +46,9 @@ class Sharing_Service { 'stumbleupon' => 'Share_Stumbleupon', 'twitter' => 'Share_Twitter', 'press-this' => 'Share_PressThis', - 'google-plus-1' => 'Share_GooglePlus1' + 'google-plus-1' => 'Share_GooglePlus1', + 'tumblr' => 'Share_Tumblr', + 'pinterest' => 'Share_Pinterest', ); // Add any custom services in @@ -88,22 +90,16 @@ class Sharing_Service { } public function delete_service( $service_id ) { - $service = $this->get_service( $service_id ); - - if ( $service ) { - $options = get_option( 'sharing-options' ); - if ( isset( $options[$service_id] ) ) - unset( $options[$service_id] ); - - $key = array_search( $service_id, $options['global']['custom'] ); - if ( $key !== false ) - unset( $options['global']['custom'][$key] ); - - update_option( 'sharing-options', $options ); - return true; - } + $options = get_option( 'sharing-options' ); + if ( isset( $options[$service_id] ) ) + unset( $options[$service_id] ); - return false; + $key = array_search( $service_id, $options['global']['custom'] ); + if ( $key !== false ) + unset( $options['global']['custom'][$key] ); + + update_option( 'sharing-options', $options ); + return true; } public function set_blog_services( array $visible, array $hidden ) { @@ -166,6 +162,10 @@ class Sharing_Service { $blog = apply_filters( 'sharing_services_enabled', $blog ); + // Add CSS for NASCAR + if ( count( $blog['visible'] ) || count( $blog['hidden'] ) ) + add_filter( 'post_flair_block_css', 'post_flair_service_enabled_sharing' ); + // Convenience for checking if a service is present $blog['all'] = array_flip( array_merge( array_keys( $blog['visible'] ), array_keys( $blog['hidden'] ) ) ); return $blog; @@ -187,7 +187,7 @@ class Sharing_Service { $options = get_option( 'sharing-options' ); // No options yet - if ( ! is_array( $options ) ) + if ( !is_array( $options ) ) $options = array(); // Defaults @@ -202,25 +202,17 @@ class Sharing_Service { $options['global'] = apply_filters( 'sharing_default_global', $options['global'] ); // Validate options and set from our data - if ( isset( $data['button_style'] ) && in_array( $data['button_style'], array( 'icon-text', 'icon', 'text' ) ) ) + if ( isset( $data['button_style'] ) && in_array( $data['button_style'], array( 'icon-text', 'icon', 'text', 'official' ) ) ) $options['global']['button_style'] = $data['button_style']; - if ( isset( $data['sharing_label'] ) ) { - $new_label = trim( wp_kses( stripslashes( $data['sharing_label'] ), array() ) ); - - if ( 0 === strcmp( $new_label, $options['global']['sharing_label'] ) ) { - $options['global']['sharing_label'] = FALSE; - } else { - $options['global']['sharing_label'] = $new_label; - } - } + if ( isset( $data['sharing_label'] ) ) + $options['global']['sharing_label'] = trim( wp_kses( stripslashes( $data['sharing_label'] ), array() ) ); if ( isset( $data['open_links'] ) && in_array( $data['open_links'], array( 'new', 'same' ) ) ) $options['global']['open_links'] = $data['open_links']; $shows = array_values( get_post_types( array( 'public' => true ) ) ); $shows[] = 'index'; - if ( isset( $data['show'] ) ) { if ( is_scalar( $data['show'] ) ) { switch ( $data['show'] ) { @@ -291,22 +283,25 @@ class Sharing_Service { } // Soon to come to a .org plugin near you! - public function get_total( $service_name = false, $post_id = false ) { + public function get_total( $service_name = false, $post_id = false, $_blog_id = false ) { global $wpdb, $blog_id; + if ( !$_blog_id ) { + $_blog_id = $blog_id; + } if ( $service_name == false ) { if ( $post_id > 0 ) { // total number of shares for this post - return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d", $blog_id, $post_id ) ); + return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d", $_blog_id, $post_id ) ); } else { // total number of shares for this blog - return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d", $blog_id ) ); + return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d", $_blog_id ) ); } } if ( $post_id > 0 ) - return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s", $blog_id, $post_id, $service_name ) ); + return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s", $_blog_id, $post_id, $service_name ) ); else - return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s", $blog_id, $service_name ) ); + return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s", $_blog_id, $service_name ) ); } public function get_services_total( $post_id = false ) { @@ -398,10 +393,11 @@ function sharing_add_header() { foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) AS $service ) { $service->display_header(); } - + if ( count( $enabled['all'] ) > 0 ) - wp_enqueue_style( 'sharedaddy', plugin_dir_url( __FILE__ ) .'sharing.css' ); + wp_enqueue_style( 'sharedaddy', plugin_dir_url( __FILE__ ) .'sharing.css', array(), WP_SHARING_PLUGIN_VERSION ); } +add_action( 'wp_head', 'sharing_add_header', 1 ); function sharing_process_requests() { global $post; @@ -416,6 +412,7 @@ function sharing_process_requests() { } } } +add_action( 'template_redirect', 'sharing_process_requests' ); function sharing_display( $text = '' ) { global $post, $wp_current_filter; @@ -427,7 +424,7 @@ function sharing_display( $text = '' ) { if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) { return $text; } - + $sharer = new Sharing_Service(); $global = $sharer->get_global_options(); @@ -448,7 +445,11 @@ function sharing_display( $text = '' ) { if ( !empty( $switched_status ) ) $show = false; - + + // Allow to be used on P2 ajax requests for latest posts. + if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['action'] ) && 'get_latest_posts' == $_REQUEST['action'] ) + $show = true; + $sharing_content = ''; if ( $show ) { @@ -460,29 +461,27 @@ function sharing_display( $text = '' ) { $dir = get_option( 'text_direction' ); // Wrapper - $sharing_content .= '<div class="snap_nopreview sharing robots-nocontent">'; - $sharing_content .= '<ul>'; + $sharing_content .= '<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-' . $global['button_style'] . ' sd-sharing">'; + if ( $global['sharing_label'] != '' ) + $sharing_content .= '<h3 class="sd-title">' . $global['sharing_label'] . '</h3>'; + $sharing_content .= '<div class="sd-content"><ul>'; // Visible items $visible = ''; - foreach ( $enabled['visible'] AS $id => $service ) { + foreach ( $enabled['visible'] as $id => $service ) { // Individual HTML for sharing service - $visible .= '<li class="share-'.$service->get_class().' share-regular">'; - $visible .= $service->get_display( $post ); - $visible .= '</li>'; + $visible .= '<li class="share-' . $service->get_class() . '">' . $service->get_display( $post ) . '</li>'; } $parts = array(); - - if ( FALSE === $global['sharing_label'] ) { - $parts[] = '<li class="sharing_label">' . __( 'Share this:', 'jetpack' ) . '</li>'; - } elseif ( '' != $global['sharing_label'] ) { - $parts[] = '<li class="sharing_label">' . esc_html( $global['sharing_label'] ) . '</li>'; - } - $parts[] = $visible; - if ( count( $enabled['hidden'] ) > 0 ) - $parts[] = '<li class="share-custom"><a href="#" class="sharing-anchor">'._x( 'Share', 'dropdown button', 'jetpack' ).'</a></li>'; + if ( count( $enabled['hidden'] ) > 0 ) { + if ( count( $enabled['visible'] ) > 0 ) + $expand = __( 'More', 'jetpack' ); + else + $expand = __( 'Share', 'jetpack' ); + $parts[] = '<li><a href="#" class="sharing-anchor sd-button share-more"><span>'.$expand.'</span></a></li>'; + } if ( $dir == 'rtl' ) $parts = array_reverse( $parts ); @@ -504,7 +503,7 @@ function sharing_display( $text = '' ) { $sharing_content .= '<ul>'; $count = 1; - foreach ( $enabled['hidden'] AS $id => $service ) { + foreach ( $enabled['hidden'] as $id => $service ) { // Individual HTML for sharing service $sharing_content .= '<li class="share-'.$service->get_class().'">'; $sharing_content .= $service->get_display( $post ); @@ -520,10 +519,10 @@ function sharing_display( $text = '' ) { $sharing_content .= '<li class="share-end"></li></ul></div></div>'; } - $sharing_content .= '<div class="sharing-clear"></div></div>'; + $sharing_content .= '<div class="sharing-clear"></div></div></div></div>'; // Register our JS - wp_register_script( 'sharing-js', plugin_dir_url( __FILE__ ).'sharing.js', array( 'jquery' ), '0.1' ); + wp_register_script( 'sharing-js', plugin_dir_url( __FILE__ ).'sharing.js', array( 'jquery' ), '20120131' ); add_action( 'wp_footer', 'sharing_add_footer' ); } } @@ -533,8 +532,3 @@ function sharing_display( $text = '' ) { add_filter( 'the_content', 'sharing_display', 19 ); add_filter( 'the_excerpt', 'sharing_display', 19 ); - -// Register our CSS -add_action( 'wp_head', 'sharing_add_header', 1 ); - -add_action( 'template_redirect', 'sharing_process_requests' ); diff --git a/plugins/jetpack/modules/sharedaddy/sharing-sources.php b/plugins/jetpack/modules/sharedaddy/sharing-sources.php index 2734d820..bd8b2eb9 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing-sources.php +++ b/plugins/jetpack/modules/sharedaddy/sharing-sources.php @@ -2,6 +2,7 @@ abstract class Sharing_Source { public $button_style; + public $smart; protected $open_links; protected $id; @@ -13,6 +14,9 @@ abstract class Sharing_Source { if ( isset( $settings['open_links'] ) ) $this->open_links = $settings['open_links']; + + if ( isset( $settings['smart'] ) ) + $this->smart = $settings['smart']; } public function get_id() { @@ -27,8 +31,8 @@ abstract class Sharing_Source { return false; } - public function get_link( $url, $text, $title, $query = '' ) { - $klasses = array( 'share-'.$this->get_class() ); + public function get_link( $url, $text, $title, $query = '', $id = false ) { + $klasses = array( 'share-'.$this->get_class(), 'sd-button' ); if ( $this->button_style == 'icon' || $this->button_style == 'icon-text' ) $klasses[] = 'share-icon'; @@ -48,7 +52,15 @@ abstract class Sharing_Source { if ( $this->button_style == 'text' ) $klasses[] = 'no-icon'; - return sprintf( '<a rel="nofollow" class="%s" href="%s"%s title="%s">%s</a>', implode( ' ', $klasses ), $url, ( $this->open_links == 'new' ) ? ' target="_blank"' : '', $title, $text ); + return sprintf( + '<a rel="nofollow" class="%s" href="%s"%s title="%s"%s><span>%s</span></a>', + implode( ' ', $klasses ), + $url, + ( $this->open_links == 'new' ) ? ' target="_blank"' : '', + $title, + ( $id ? ' id="' . esc_attr( $id ) . '"' : '' ), + $text + ); } abstract public function get_name(); @@ -65,14 +77,32 @@ abstract class Sharing_Source { } public function display_preview() { - echo '<div class="option">'; + $text = ' '; + if ( !$this->smart ) + if ( $this->button_style != 'icon' ) + $text = $this->get_name(); - if ( $this->button_style == 'text' || $this->button_style == 'icon-text' ) - echo $this->get_name(); - else - echo ' '; + $klasses = array( 'share-'.$this->get_class(), 'sd-button' ); + + if ( $this->button_style == 'icon' || $this->button_style == 'icon-text' ) + $klasses[] = 'share-icon'; + + if ( $this->button_style == 'icon' ) + $klasses[] = 'no-text'; - echo '</div>'; + if ( $this->button_style == 'text' ) + $klasses[] = 'no-icon'; + + $link = sprintf( + '<a rel="nofollow" class="%s" href="javascript:void(0);return false;" title="%s"><span>%s</span></a>', + implode( ' ', $klasses ), + $this->get_name(), + $text + ); + ?> + <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>"> + <?php echo $link; ?> + </div><?php } public function get_total( $post = false ) { @@ -85,7 +115,7 @@ abstract class Sharing_Source { return (int) $wpdb->get_var( $wpdb->prepare( "SELECT SUM( count ) FROM sharing_stats WHERE blog_id = %d AND share_service = %s", $blog_id, $name ) ); } - //get total shares for a post + // get total shares for a post return (int) $wpdb->get_var( $wpdb->prepare( "SELECT count FROM sharing_stats WHERE blog_id = %d AND post_id = %d AND share_service = %s", $blog_id, $post->ID, $name ) ); } @@ -109,6 +139,31 @@ abstract class Sharing_Source { public function process_request( $post, array $post_data ) { do_action( 'sharing_bump_stats', array( 'service' => $this, 'post' => $post ) ); } + + public function js_dialog( $name, $params = array() ) { + $defaults = array( + 'menubar' => 1, + 'resizable' => 1, + 'width' => 600, + 'height' => 400, + ); + $params = array_merge( $defaults, $params ); + $opts = array(); + foreach( $params as $key => $val ) { + $opts[] = "$key=$val"; + } + $opts = implode( ',', $opts ); + ?> + <script type="text/javascript" charset="utf-8"> + jQuery(document).ready(function(){ + jQuery( '.share-<?php echo $name; ?>' ).click(function(){ + window.open( jQuery(this).attr( 'href' ), 'wpcom<?php echo $name; ?>', '<?php echo $opts; ?>' ); + return false; + }); + }); + </script> + <?php + } } abstract class Sharing_Advanced_Source extends Sharing_Source { @@ -123,6 +178,16 @@ abstract class Sharing_Advanced_Source extends Sharing_Source { class Share_Email extends Sharing_Source { + var $shortname = 'email'; + public function __construct( $id, array $settings ) { + parent::__construct( $id, $settings ); + + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; + } + public function get_name() { return __( 'Email', 'jetpack' ); } @@ -162,7 +227,7 @@ class Share_Email extends Sharing_Source { do_action( 'sharing_email_send_post', $data ); } - // Return a positive regardless of whether the user is subscribed or not + // Return a positive regardless of whether the user is subscribed or not if ( $ajax ) { ?> <div class="response"> @@ -196,13 +261,12 @@ class Share_Email extends Sharing_Source { /** * Outputs the hidden email dialog */ - public function display_footer() { global $current_user; $visible = $status = false; ?> - <div id="sharing_email" style="<?php if ( $visible === false ) echo 'display: none;'; ?>"> + <div id="sharing_email" style="display: none;"> <form action="" method="post"> <label for="target_email"><?php _e( 'Send to Email Address', 'jetpack' ) ?></label> <input type="text" name="target_email" id="target_email" value="" /> @@ -220,9 +284,9 @@ class Share_Email extends Sharing_Source { <?php endif; ?> - <?php do_action( 'sharing_email_dialog', 'sharedaddy' ); ?> + <?php do_action( 'sharing_email_dialog', 'jetpack' ); ?> - <img style="float: right; display: none" class="loading" src="<?php echo plugin_dir_url( __FILE__ ); ?>images/loading.gif" alt="loading" width="16" height="16" /> + <img style="float: right; display: none" class="loading" src="<?php echo plugin_dir_url( __FILE__ ) . 'images/loading.gif'; ?>" alt="loading" width="16" height="16" /> <input type="submit" value="<?php _e( 'Send Email', 'jetpack' ); ?>" class="sharing_send" /> <a href="#cancel" class="sharing_cancel"><?php _e( 'Cancel', 'jetpack' ); ?></a> @@ -243,51 +307,90 @@ class Share_Email extends Sharing_Source { } } -class Share_Twitter extends Sharing_Advanced_Source { - private $smart = true; - +class Share_Twitter extends Sharing_Source { + var $shortname = 'twitter'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); - if ( isset( $settings['smart'] ) ) - $this->smart = $settings['smart']; + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; } public function get_name() { return __( 'Twitter', 'jetpack' ); } + function sharing_twitter_via( $post ) { + return ''; + + // Default 'via' is always us. + $via = preg_replace( '/(https?:\/\/)|(\.)|(\/)/i', '', home_url() ); + + // Allow themes to customize the via + return apply_filters( 'sharing_twitter_via', $via, $post->ID ); + } + public function get_display( $post ) { - if ( $this->smart == 'smart' ) - return '<div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=' . rawurlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&counturl=' . rawurlencode( str_replace( 'https://', 'http://', get_permalink( $post->ID ) ) ) . '&count=horizontal&text=' . rawurlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ) . ': " style="width:97px; height:20px;"></iframe></div>'; - else - return $this->get_link( get_permalink( $post->ID ), _x( 'Twitter', 'share to', 'jetpack' ), __( 'Click to share on Twitter', 'jetpack' ), 'share=twitter' ); - } + $via = $this->sharing_twitter_via( $post ); + + if ( $via ) { + $via = sprintf( '&via=%1$s', rawurlencode( $via ) ); + } else { + $via = ''; + } + if ( $this->smart ) { + return '<div class="twitter_button"><iframe allowtransparency="true" frameborder="0" scrolling="no" src="' . esc_url( 'http://platform.twitter.com/widgets/tweet_button.html?url=' . rawurlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&counturl=' . rawurlencode( str_replace( 'https://', 'http://', get_permalink( $post->ID ) ) ) . '&count=horizontal&text=' . rawurlencode( $post->post_title . ':' ) . $via ) . '" style="width:101px; height:20px;"></iframe></div>'; + } else { + if ( 'icon-text' == $this->button_style || 'text' == $this->button_style ) + sharing_register_post_for_share_counts( $post->ID ); + return $this->get_link( get_permalink( $post->ID ), _x( 'Twitter', 'share to', 'jetpack' ), __( 'Click to share on Twitter', 'jetpack' ), 'share=twitter', 'sharing-twitter-' . $post->ID ); + } + } public function process_request( $post, array $post_data ) { - $post_title = apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ); + $post_title = $post->post_title; $post_link = apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ); + + if ( function_exists( 'mb_stripos' ) ) { + $strlen = 'mb_strlen'; + $substr = 'mb_substr'; + } else { + $strlen = 'strlen'; + $substr = 'substr'; + } - $twitter_url = ''; - if ( function_exists( 'mb_stripos' ) ) - $mb = true; - else - $mb = false; - - if ( ( $mb && ( mb_strlen( $post_title ) + 1 + mb_strlen( $post_link ) ) > 140 ) || ( !$mb && ( strlen( $post_title ) + 1 + strlen( $post_link ) ) > 140 ) ) { - if ( $mb ) { - $twitter_url = 'http://twitter.com/?status=' . rawurlencode( ( mb_substr( $post_title, 0, (140 - mb_strlen ( $post_link ) - 4 ) ) ) . '... ' . $post_link ); - } else { - $twitter_url = 'http://twitter.com/?status=' . rawurlencode( ( substr( $post_title, 0, (140 - strlen ( $post_link ) - 4 ) ) ) . '... ' . $post_link ); - } + $via = $this->sharing_twitter_via( $post ); + if ( $via ) { + $related = false; + $sig = " via @$via"; + } else { + $via = false; + $related = false; + $sig = ''; } - else { - $twitter_url = 'http://twitter.com/?status=' . rawurlencode( $post_title . ' ' . $post_link ); + + $suffix_length = $strlen( " {$post_link}{$sig}" ); + + // $sig is handled by twitter in their 'via' argument. + // $post_link is handled by twitter in their 'url' argument. + if ( 140 < $strlen( $post_title ) + $suffix_length ) { + // The -1 is for "\xE2\x80\xA6", a UTF-8 ellipsis. + $text = $substr( $post_title, 0, 140 - $suffix_length - 1 ) . "\xE2\x80\xA6"; + } else { + $text = $post_title; } - + // Record stats parent::process_request( $post, $post_data ); + $url = $post_link; + $twitter_url = add_query_arg( + urlencode_deep( compact( 'via', 'related', 'text', 'url' ) ), + sprintf( '%s://twitter.com/intent/tweet', ( is_ssl() ? 'https' : 'http' ) ) + ); + // Redirect to Twitter wp_redirect( $twitter_url ); die(); @@ -296,56 +399,21 @@ class Share_Twitter extends Sharing_Advanced_Source { public function has_custom_button_style() { return $this->smart; } - - public function display_preview() { -?> - <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>"> - <?php - if ( !$this->smart ) { - if ( $this->button_style == 'text' || $this->button_style == 'icon-text' ) - echo $this->get_name(); - else - echo ' '; - } - ?> - </div> -<?php - } - public function update_options( array $data ) { - $this->smart = false; - - if ( isset( $data['smart'] ) ) - $this->smart = true; - } - - public function get_options() { - return array( - 'smart' => $this->smart - ); - } - - public function display_options() { -?> - <div class="input"> - <label> - <input name="smart" type="checkbox"<?php if ( $this->smart ) echo ' checked="checked"'; ?>/> - - <?php _e( 'Use smart button', 'jetpack' ); ?> - </label> - </div> -<?php + public function display_footer() { + $this->js_dialog( $this->shortname, array( 'height' => 350 ) ); } } -class Share_Stumbleupon extends Sharing_Advanced_Source { - private $smart = false; - +class Share_Stumbleupon extends Sharing_Source { + var $shortname = 'stumbleupon'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); - if ( isset( $settings['smart'] ) ) - $this->smart = $settings['smart']; + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; } public function get_name() { @@ -357,29 +425,14 @@ class Share_Stumbleupon extends Sharing_Advanced_Source { } public function get_display( $post ) { - if ( $this->smart == 'smart' ) - return '<div class="stumbleupon_button"><iframe src="http://www.stumbleupon.com/badge/embed/1/?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ) . '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:74px; height: 18px;" allowTransparency="true"></iframe></div>'; + if ( $this->smart ) + return '<div class="stumbleupon_button"><iframe src="http://www.stumbleupon.com/badge/embed/1/?url=' . urlencode( get_permalink( $post->ID ) ) . '&title=' . urlencode( $post->post_title ) . '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:74px; height: 18px;" allowTransparency="true"></iframe></div>'; else return $this->get_link( get_permalink( $post->ID ), _x( 'StumbleUpon', 'share to', 'jetpack' ), __( 'Click to share on StumbleUpon', 'jetpack' ), 'share=stumbleupon' ); - } - - public function display_preview() { -?> - <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>"> - <?php - if ( !$this->smart ) { - if ( $this->button_style == 'text' || $this->button_style == 'icon-text' ) - echo $this->get_name(); - else - echo ' '; - } - ?> - </div> -<?php } public function process_request( $post, array $post_data ) { - $stumbleupon_url = 'http://www.stumbleupon.com/submit?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ); + $stumbleupon_url = 'http://www.stumbleupon.com/submit?url=' . urlencode( get_permalink( $post->ID ) ) . '&title=' . urlencode( $post->post_title ); // Record stats parent::process_request( $post, $post_data ); @@ -388,41 +441,17 @@ class Share_Stumbleupon extends Sharing_Advanced_Source { wp_redirect( $stumbleupon_url ); die(); } - - public function update_options( array $data ) { - $this->smart = false; - - if ( isset( $data['smart'] ) ) - $this->smart = true; - } - - public function get_options() { - return array( - 'smart' => $this->smart - ); - } - - public function display_options() { -?> - <div class="input"> - <label> - <input name="smart" type="checkbox"<?php if ( $this->smart ) echo ' checked="checked"'; ?>/> - - <?php _e( 'Use smart button', 'jetpack' ); ?> - </label> - </div> -<?php - } } -class Share_Reddit extends Sharing_Advanced_Source { - private $smart = false; - +class Share_Reddit extends Sharing_Source { + var $shortname = 'reddit'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); - if ( isset( $settings['smart'] ) ) - $this->smart = $settings['smart']; + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; } public function get_name() { @@ -430,58 +459,14 @@ class Share_Reddit extends Sharing_Advanced_Source { } public function get_display( $post ) { - if ( $this->smart == 'smart' ) - return '<div class="reddit_button"><iframe src="http://www.reddit.com/static/button/button1.html?width=120&url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . rawurlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ) . '" height="22" width="120" scrolling="no" frameborder="0"></iframe></div>'; + if ( $this->smart ) + return '<div class="reddit_button"><iframe src="http://www.reddit.com/static/button/button1.html?width=120&url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . rawurlencode( $post->post_title ) . '" height="22" width="120" scrolling="no" frameborder="0"></iframe></div>'; else return $this->get_link( get_permalink( $post->ID ), __( 'Reddit', 'share to', 'jetpack' ), __( 'Click to share on Reddit', 'jetpack' ), 'share=reddit' ); } - public function update_options( array $data ) { - $this->smart = false; - - if ( isset( $data['smart'] ) ) - $this->smart = true; - } - - public function has_custom_button_style() { - return $this->smart; - } - - public function get_options() { - return array( - 'smart' => $this->smart - ); - } - - public function display_options() { -?> - <div class="input"> - <label> - <input name="smart" type="checkbox"<?php if ( $this->smart ) echo ' checked="checked"'; ?>/> - - <?php _e( 'Use smart button', 'jetpack' ); ?> - </label> - </div> -<?php - } - - public function display_preview() { -?> - <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>"> - <?php - if ( !$this->smart ) { - if ( $this->button_style == 'text' || $this->button_style == 'icon-text' ) - echo $this->get_name(); - else - echo ' '; - } - ?> - </div> -<?php - } - public function process_request( $post, array $post_data ) { - $reddit_url = 'http://reddit.com/submit?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ); + $reddit_url = 'http://reddit.com/submit?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( $post->post_title ); // Record stats parent::process_request( $post, $post_data ); @@ -492,14 +477,15 @@ class Share_Reddit extends Sharing_Advanced_Source { } } -class Share_Digg extends Sharing_Advanced_Source { - private $smart = false; - +class Share_Digg extends Sharing_Source { + var $shortname = 'digg'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); - if ( isset( $settings['smart'] ) ) - $this->smart = $settings['smart']; + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; } public function get_name() { @@ -512,15 +498,15 @@ class Share_Digg extends Sharing_Advanced_Source { public function get_display( $post ) { if ( $this->smart ) { - $url = $this->get_link( 'http://digg.com/submit?url='. urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ), 'Digg', __( 'Click to Digg this post', 'jetpack' ) ); + $url = $this->get_link( 'http://digg.com/submit?url='. urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( $post->post_title ), 'Digg', __( 'Click to Digg this post' ) ); return '<div class="digg_button">' . str_replace( 'class="', 'class="DiggThisButton DiggCompact ', $url ) . '</div>'; + } else { + return $this->get_link( get_permalink( $post->ID ), _x( 'Digg', 'share to', 'jetpack' ), __( 'Click to Digg this post' ), 'share=digg' ); } - else - return $this->get_link( get_permalink( $post->ID ), _x( 'Digg', 'share to', 'jetpack' ), __( 'Click to Digg this post', 'jetpack' ), 'share=digg' ); } public function process_request( $post, array $post_data ) { - $digg_url = 'http://digg.com/submit?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ); + $digg_url = 'http://digg.com/submit?url=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&title=' . urlencode( $post->post_title ); // Record stats parent::process_request( $post, $post_data ); @@ -545,56 +531,17 @@ class Share_Digg extends Sharing_Advanced_Source { <?php } } - - public function update_options( array $data ) { - $this->smart = false; - - if ( isset( $data['smart'] ) ) - $this->smart = true; - } - - public function get_options() { - return array( - 'smart' => $this->smart - ); - } - - public function display_options() { -?> - <div class="input"> - <label> - <input name="smart" type="checkbox"<?php if ( $this->smart ) echo ' checked="checked"'; ?>/> - - <?php _e( 'Use smart button', 'jetpack' ); ?> - </label> - </div> -<?php - } - - public function display_preview() { -?> - <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>"> - <?php - if ( !$this->smart ) { - if ( $this->button_style == 'text' || $this->button_style == 'icon-text' ) - echo $this->get_name(); - else - echo ' '; - } - ?> - </div> -<?php - } } -class Share_LinkedIn extends Sharing_Advanced_Source { - private $smart = true; - +class Share_LinkedIn extends Sharing_Source { + var $shortname = 'linkedin'; public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); - if ( isset( $settings['smart'] ) ) - $this->smart = (bool) $settings['smart']; + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; } public function get_name() { @@ -602,37 +549,28 @@ class Share_LinkedIn extends Sharing_Advanced_Source { } public function has_custom_button_style() { - return (bool) $this->smart; - } - - public function display_header() { + return $this->smart; } - + public function get_display( $post ) { - static $added_linkedin_js = false; - $proto = ( is_ssl() ) ? 'https://' : 'http://'; $permalink = get_permalink( $post->ID ); $display = ''; - if( $this->smart ) { - - // So we don't spit out the linkedin js for each post on index pages - if( ! $added_linkedin_js ) { - $display .= sprintf( '<script type="text/javascript" src="%splatform.linkedin.com/in.js"></script>', $proto ); - $added_linkedin_js = true; - } - + if ( $this->smart ) $display .= sprintf( '<div class="linkedin_button"><script type="in/share" data-url="%s" data-counter="right"></script></div>', esc_url( $permalink ) ); - - } else { - - $display = $this->get_link( $permalink, _x( 'LinkedIn', 'share to', 'jetpack' ), __( 'Click to share on LinkedIn', 'jetpack' ), 'share=linkedin' ); - - } + else + $display = $this->get_link( $permalink, _x( 'LinkedIn', 'share to', 'jetpack' ), __( 'Click to share on LinkedIn', 'jetpack' ), 'share=linkedin', 'sharing-linkedin-' . $post->ID ); + + if ( 'icon-text' == $this->button_style || 'text' == $this->button_style ) + sharing_register_post_for_share_counts( $post->ID ); + return $display; } public function process_request( $post, array $post_data ) { + + setup_postdata( $post ); + $post_link = apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ); // http://www.linkedin.com/shareArticle?mini=true&url={articleUrl}&title={articleTitle}&summary={articleSummary}&source={articleSource} @@ -641,7 +579,7 @@ class Share_LinkedIn extends Sharing_Advanced_Source { if( strlen( $encoded_title ) > 200 ) $encoded_title = substr( $encoded_title, 0, 197 ) . '...'; - $encoded_summary = rawurlencode( get_the_excerpt() ); + $encoded_summary = rawurlencode( strip_tags( get_the_excerpt() ) ); if( strlen( $encoded_summary ) > 256 ) $encoded_summary = substr( $encoded_summary, 0, 253 ) . '...'; @@ -664,43 +602,16 @@ class Share_LinkedIn extends Sharing_Advanced_Source { die(); } - public function update_options( array $data ) { - $this->smart = false; - - if ( isset( $data['smart'] ) ) - $this->smart = true; - } - - public function get_options() { - return array( - 'smart' => $this->smart - ); - } - - public function display_options() { - ?><div class="input"> - <label> - <input name="smart" type="checkbox"<?php checked( $this->smart ); ?>/> - <?php _e( 'Use smart button', 'jetpack' ); ?> - </label> - </div><?php - } - - public function display_preview() { - ?> - <div class="option option-smart-<?php echo $this->smart ? 'on' : 'off'; ?>"> - <?php - if ( ! $this->smart ) { - if ( $this->button_style == 'text' || $this->button_style == 'icon-text' ) - echo $this->get_name(); - else - echo ' '; - } ?> - </div><?php + public function display_footer() { + if ( !$this->smart ) + $this->js_dialog( $this->shortname, array( 'width' => 580, 'height' => 450 ) ); + else + echo '<script type="text/javascript" src="//platform.linkedin.com/in.js"></script>'; } } -class Share_Facebook extends Sharing_Advanced_Source { +class Share_Facebook extends Sharing_Source { + var $shortname = 'facebook'; private $share_type = 'default'; public function __construct( $id, array $settings ) { @@ -708,54 +619,46 @@ class Share_Facebook extends Sharing_Advanced_Source { if ( isset( $settings['share_type'] ) ) $this->share_type = $settings['share_type']; + + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; } public function get_name() { return __( 'Facebook', 'jetpack' ); } - - public function has_custom_button_style() { - return $this->share_type != 'default'; - } public function display_header() { - if ( $this->share_type == 'share' ) { - // Set the open graph description, otherwise Facebook may pick up some random text from the page - global $post; - - if ( $post && $post->ID > 0 ) - echo '<meta property="og:description" content="'.esc_attr( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ).'" />'; - } } - + function guess_locale_from_lang( $lang ) { if ( 'en' == $lang || 'en_US' == $lang || !$lang ) { return 'en_US'; } - + if ( !class_exists( 'GP_Locales' ) ) { require JETPACK__PLUGIN_DIR . 'locales.php'; } - + // Jetpack: get_locale() returns 'it_IT'; $locale = GP_Locales::by_field( 'wp_locale', $lang ); - + if ( !$locale || empty( $locale->facebook_locale ) ) { return false; } - + return $locale->facebook_locale; } public function get_display( $post ) { - if ( $this->share_type == 'share' ) { - return '<div class="facebook_button"><a name="fb_share" rel="nofollow" type="button" share_url="' . apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) . '" href="http://www.facebook.com/sharer.php?u=' . rawurlencode( get_permalink( $post->ID ) ) . '&t=' . rawurlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ) . '">'.__( 'Share' , 'jetpack' ).'</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></div>'; - } else if ( $this->share_type == 'like' ) { + if ( $this->smart ) { $url = 'http://www.facebook.com/plugins/like.php?href=' . rawurlencode( get_permalink( $post->ID ) ) . '&layout=button_count&show_faces=false&action=like&colorscheme=light&height=21'; // Default widths to suit English $inner_w = 90; - + // Locale-specific widths/overrides $widths = array( 'bg_BG' => 120, @@ -770,14 +673,13 @@ class Share_Facebook extends Sharing_Advanced_Source { ); $widths = apply_filters( 'sharing_facebook_like_widths', $widths ); - - // Fix the button to the blogs locale and then adjust the width + $locale = $this->guess_locale_from_lang( get_locale() ); if ( $locale ) { if ( 'en_US' != $locale ) { $url .= '&locale=' . $locale; } - + if ( isset( $widths[$locale] ) ) { $inner_w = $widths[$locale]; } @@ -786,64 +688,14 @@ class Share_Facebook extends Sharing_Advanced_Source { $url .= '&width='.$inner_w; return '<div class="like_button"><iframe src="'.$url.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.( $inner_w + 6 ).'px; height:21px;" allowTransparency="true"></iframe></div>'; } - - return $this->get_link( get_permalink( $post->ID ), _x( 'Facebook', 'share to', 'jetpack' ), __( 'Share on Facebook', 'jetpack' ), 'share=facebook' ); - } - - - public function update_options( array $data ) { - $this->share_type = 'default'; - - if ( isset( $data['share_type'] ) && in_array( $data['share_type'], array( 'default', 'like', 'share' ) ) ) - $this->share_type = $data['share_type']; - } - - public function get_options() { - return array( - 'share_type' => $this->share_type - ); - } - - public function display_options() { -?> - <div class="input"> - <label> - <select name="share_type"> - <option value="default"<?php if ( $this->share_type == 'default' ) echo ' selected="selected"'; ?>><?php _e( 'Default button', 'jetpack' ); ?></option> - <option value="share"<?php if ( $this->share_type == 'share' ) echo ' selected="selected"'; ?>><?php _e( 'Share button', 'jetpack' ); ?></option> - <option value="like"<?php if ( $this->share_type == 'like' ) echo ' selected="selected"'; ?>><?php _e( 'Like button', 'jetpack' ); ?></option> - </select> - </label> - </div> -<?php + + if ( 'icon-text' == $this->button_style || 'text' == $this->button_style ) + sharing_register_post_for_share_counts( $post->ID ); + return $this->get_link( get_permalink( $post->ID ), _x( 'Facebook', 'share to', 'jetpack' ), __( 'Share on Facebook', 'jetpack' ), 'share=facebook', 'sharing-facebook-' . $post->ID ); } - public function display_preview() { -?> - <div class="option option-smart-<?php - - if ( $this->share_type == 'share' ) { - echo ( 'on">' ); - echo ' '; - } - elseif ( $this->share_type == 'like' ) { - echo ( 'like">' ); - echo ' '; - } - else { - echo ( 'off">' ); - if ( $this->button_style == 'text' || $this->button_style == 'icon-text' ) - echo $this->get_name(); - else - echo ' '; - } - ?> - </div> -<?php - } - public function process_request( $post, array $post_data ) { - $fb_url = 'http://www.facebook.com/sharer.php?u=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&t=' . urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ); + $fb_url = 'http://www.facebook.com/sharer.php?u=' . urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&t=' . urlencode( $post->post_title ); // Record stats parent::process_request( $post, $post_data ); @@ -852,9 +704,23 @@ class Share_Facebook extends Sharing_Advanced_Source { wp_redirect( $fb_url ); die(); } + + public function display_footer() { + $this->js_dialog( $this->shortname ); + } } class Share_Print extends Sharing_Source { + var $shortname = 'print'; + public function __construct( $id, array $settings ) { + parent::__construct( $id, $settings ); + + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; + } + public function get_name() { return __( 'Print', 'jetpack' ); } @@ -865,6 +731,16 @@ class Share_Print extends Sharing_Source { } class Share_PressThis extends Sharing_Source { + var $shortname = 'pressthis'; + public function __construct( $id, array $settings ) { + parent::__construct( $id, $settings ); + + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; + } + public function get_name() { return __( 'Press This', 'jetpack' ); } @@ -874,13 +750,13 @@ class Share_PressThis extends Sharing_Source { $blogs = get_blogs_of_user( $current_user->ID ); if ( empty( $blogs ) ) { - wp_safe_redirect( get_permalink( $post->ID ) ); + wp_safe_redirect( get_permalink( $post->ID ) ); die(); } $blog = current( $blogs ); - $url = $blog->siteurl.'/wp-admin/press-this.php?u='.urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ).'&t='.urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ).'&v=4'; + $url = $blog->siteurl.'/wp-admin/press-this.php?u='.urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ).'&t='.urlencode( $post->post_title ).'&v=4'; if ( isset( $_GET['sel'] ) ) $url .= '&s='.urlencode( $_GET['sel'] ); @@ -898,28 +774,42 @@ class Share_PressThis extends Sharing_Source { } } -class Share_GooglePlus1 extends Sharing_Source { +class Share_GooglePlus1 extends Sharing_Source { + var $shortname = 'googleplus1'; private $state = false; + + public function __construct( $id, array $settings ) { + parent::__construct( $id, $settings ); + + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; + } public function get_name() { return __( 'Google +1', 'jetpack' ); } public function get_display( $post ) { - return '<div class="googleplus1_button"><div class="g-plusone" data-size="medium" data-callback="sharing_plusone" data-href="' . esc_attr( get_permalink( $post->ID ) ) . '"></div></div>'; - } + // Smart or not, return the G+ button + return '<div class="googleplus1_button"><g:plusone size="medium" callback="sharing_plusone" href="' . esc_attr( get_permalink( $post->ID ) ) . '"></g:plusone></div>'; + } public function display_preview() { -?> - <div class="option option-smart-on"></div> -<?php + ?> + <div class="option option-smart-on"> + <a href="javascript:void(0);return false;" class="share-<?php echo $this->shortname; ?>"> + <span></span> + </a> + </div><?php } public function get_state() { return $this->state; } - public function process_request( $post, array $post_data ) { + public function process_request( $post, array $post_data ) { if ( isset( $post_data['state'] ) ) { $this->state = $post_data['state']; @@ -964,6 +854,8 @@ class Share_Custom extends Sharing_Advanced_Source { private $name; private $icon; private $url; + public $smart = true; + var $shortname; public function get_class() { return 'custom'; @@ -971,9 +863,13 @@ class Share_Custom extends Sharing_Advanced_Source { public function __construct( $id, array $settings ) { parent::__construct( $id, $settings ); + + $opts = $this->get_options(); - if ( isset( $settings['name'] ) ) + if ( isset( $settings['name'] ) ) { $this->name = $settings['name']; + $this->shortname = preg_replace( '/[^a-z0-9]*/', '', $settings['name'] ); + } if ( isset( $settings['icon'] ) ) $this->icon = $settings['icon']; @@ -988,14 +884,14 @@ class Share_Custom extends Sharing_Advanced_Source { public function get_display( $post ) { $str = $this->get_link( get_permalink( $post->ID ), esc_html( $this->name ), __( 'Click to share', 'jetpack' ), 'share='.$this->id ); - return str_replace( 'class="', 'style="background:url(' . esc_url( $this->icon ) . ') no-repeat center left;" class="', $str ); + return str_replace( '<span>', '<span style="background-image:url(' . esc_url( $this->icon ) . ');">', $str ); } public function process_request( $post, array $post_data ) { - $url = $this->url; + $url = str_replace( '&', '&', $this->url ); $url = str_replace( '%post_url%', urlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ), $url ); $url = str_replace( '%post_full_url%', urlencode( get_permalink( $post->ID ) ), $url ); - $url = str_replace( '%post_title%', urlencode( apply_filters( 'sharing_post_title', $post->post_title, $post->ID, $this->id ) ), $url ); + $url = str_replace( '%post_title%', urlencode( $post->post_title ), $url ); if ( strpos( $url, '%post_tags%' ) !== false ) { $tags = get_the_tags( $post->ID ); @@ -1054,7 +950,7 @@ class Share_Custom extends Sharing_Advanced_Source { <tr> <th scope="row"></th> <td> - <input class="button-secondary" type="submit"value="<?php _e( 'Save', 'jetpack' ); ?>" /> + <input class="button-secondary" type="submit" value="<?php _e( 'Save', 'jetpack' ); ?>" /> <a href="#" class="remove"><small><?php _e( 'Remove Service', 'jetpack' ); ?></small></a> </td> </tr> @@ -1086,4 +982,163 @@ class Share_Custom extends Sharing_Advanced_Source { 'url' => $this->url, ); } + + public function display_preview() { + $opts = $this->get_options(); + + $text = ' '; + if ( !$this->smart ) + if ( $this->button_style != 'icon' ) + $text = $this->get_name(); + + $klasses = array( 'share-'.$this->shortname ); + + if ( $this->button_style == 'icon' || $this->button_style == 'icon-text' ) + $klasses[] = 'share-icon'; + + if ( $this->button_style == 'icon' ) { + $text = ''; + $klasses[] = 'no-text'; + } + + if ( $this->button_style == 'text' ) + $klasses[] = 'no-icon'; + + $link = sprintf( + '<a rel="nofollow" class="%s" href="javascript:void(0);return false;" title="%s"><span style="background-image:url(%s) !important;background-position:left center;background-repeat:no-repeat;">%s</span></a>', + implode( ' ', $klasses ), + $this->get_name(), + esc_url( $opts['icon'] ), + $text + ); + ?> + <div class="option option-smart-off"> + <?php echo $link ; ?> + </div><?php + } +} + + +class Share_Tumblr extends Sharing_Source { + var $shortname = 'tumblr'; + public function __construct( $id, array $settings ) { + parent::__construct( $id, $settings ); + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; + } + + public function get_name() { + return __( 'Tumblr', 'jetpack' ); + } + + public function get_display( $post ) { + if ( $this->smart ) + return '<a href="http://www.tumblr.com/share" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:62px; height:20px; background:url(\'http://platform.tumblr.com/v1/share_2.png\') top left no-repeat transparent;">Share on Tumblr</a>'; + else + return $this->get_link( get_permalink( $post->ID ), _x( 'Tumblr', 'share to', 'jetpack' ), __( 'Click to share on Tumblr', 'jetpack' ), 'share=tumblr' ); + } + + public function process_request( $post, array $post_data ) { + // Record stats + parent::process_request( $post, $post_data ); + + // Redirect to Tumblr's sharing endpoint (a la their bookmarklet) + $url = 'http://www.tumblr.com/share?v=3&u=' . rawurlencode( get_permalink( $post->ID ) ) . '&t=' . rawurlencode( $post->post_title ) . '&s='; + wp_redirect( $url ); + die(); + } + // http://www.tumblr.com/share?v=3&u=URL&t=TITLE&s= + public function display_footer() { + if ( $this->smart ) { + ?><script type="text/javascript" src="http://platform.tumblr.com/v1/share.js"></script><?php + } else { + $this->js_dialog( $this->shortname, array( 'width' => 450, 'height' => 450 ) ); + } + } +} + +class Share_Pinterest extends Sharing_Source { + var $shortname = 'pinterest'; + + public function __construct( $id, array $settings ) { + parent::__construct( $id, $settings ); + + if ( 'official' == $this->button_style ) + $this->smart = true; + else + $this->smart = false; + } + + public function get_name() { + return __( 'Pinterest', 'jetpack' ); + } + + public function get_post_image( $content ) { + $image = ''; + + if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) { + $thumb_id = get_post_thumbnail_id(); + $thumb = wp_get_attachment_image_src( $thumb_id ); + $image = remove_query_arg( array('w', 'h'), $thumb[0] ); + } else if ( preg_match_all('/<img (.+?)>/', $content, $matches) ) { + foreach ( $matches[1] as $attrs ) { + $media = $img = array(); + foreach ( wp_kses_hair( $attrs, array( 'http', 'https' ) ) as $attr ) + $img[$attr['name']] = $attr['value']; + if ( !isset( $img['src'] ) || 0 !== strpos( $img['src'], 'http' ) ) { + continue; + } + else { + $image = $img['src']; + break; + } + } + } + + return $image; + } + + public function get_display( $post ) { + if ( $this->smart ) + return '<div class="pinterest_button"><a href="http://pinterest.com/pin/create/button/?url='. rawurlencode( apply_filters( 'sharing_permalink', get_permalink( $post->ID ), $post->ID, $this->id ) ) . '&description=' . rawurlencode( esc_attr( $post->post_title ) ) . '&media=' . rawurlencode( esc_url( $this->get_post_image( $post->post_content ) ) ) . '" class="pin-it-button" count-layout="horizontal"> '. __( 'Pin It', 'sharedaddy') .'</a></div>'; + else + return $this->get_link( get_permalink( $post->ID ), _x( 'Pinterest', 'share to', 'jetpack' ), __( 'Click to share on Pinterest', 'jetpack' ), 'share=pinterest' ); + } + + public function process_request( $post, array $post_data ) { + $pinterest_url = 'http://pinterest.com/pin/create/button/?url=' . rawurlencode( get_permalink( $post->ID ) ) . '&description=' . rawurlencode( esc_attr( $post->post_title ) ) . '&media=' . rawurlencode( esc_url( $this->get_post_image( $post->post_content ) ) ); + + // Record stats + parent::process_request( $post, $post_data ); + + // Redirect to Pinterest + wp_redirect( $pinterest_url ); + die(); + } + + public function display_footer() { + if ( !$this->smart ) { + $this->js_dialog( $this->shortname, array( 'width' => 650, 'height' => 280 ) ); + } else { +?> + <script type="text/javascript"> + function pinterest_async_load() { + var s = document.createElement("script"); + s.type = "text/javascript"; + s.async = true; + s.src = window.location.protocol + "//assets.pinterest.com/js/pinit.js"; + var x = document.getElementsByTagName("script")[0]; + x.parentNode.insertBefore(s, x); + } + jQuery(document).on('ready post-load', function() { + pinterest_async_load(); + }); + </script> +<?php + } + } + + } diff --git a/plugins/jetpack/modules/sharedaddy/sharing.css b/plugins/jetpack/modules/sharedaddy/sharing.css index e5874f29..fb45c924 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing.css +++ b/plugins/jetpack/modules/sharedaddy/sharing.css @@ -1,271 +1,485 @@ -.sharing { - padding: 0 0 10px 0; +div.sharedaddy ul, +div.sharedaddy li { + margin: 0; + padding: 0; + list-style: none; + border: none; + background: none; } -.sharing_label { - line-height: 24px; - padding: 10px 10px 0 0; - float: left; +div.sharedaddy, +#content div.sharedaddy, +#main div.sharedaddy { + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; + font-size: 12px; + clear: both; +} + +div.sharedaddy, +div.sharedaddy div { + -webkit-border-radius: 0 !important; + -moz-border-radius: 0 !important; + border-radius: 0 !important; +} + +div.sharedaddy h3, +#content div.sharedaddy h3, +#main div.sharedaddy h3, +#primary div.sharedaddy h3 { + font-size: 12px; + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; + margin: 3px 0; + padding: 0; + text-transform: none; + letter-spacing: 0; + line-height: 1; font-weight: bold; + width: 15.625%; /* 100px / 640px */ float: left; + position: static; + background: none; + border: none; } -.sharing ul, .sharing-hidden ul { - list-style: none outside none !important; - padding: 0 !important; +.rtl div.sharedaddy h3, +.rtl #content div.sharedaddy h3, +.rtl #main div.sharedaddy h3, +.rtl #primary div.sharedaddy h3 { + float: right; + text-align: right; +} + +div.sharedaddy ul, +div.sharedaddy li { margin: 0 !important; - float: left; - text-indent: 0 !important; + padding: 0 !important; + text-indent: 0; } -.sharing li, .sharing-hidden li { - display: list-item !important; - list-style: none outside none !important; - float: left; - padding: 10px 0 0 0 !important; - margin: 0 10px 0 0 !important; - background: none !important; +div.sharedaddy li::before { + content: ""; } -.sharing li div, .sharing-hidden li div { +div.sharedaddy div.sharing-clear { margin: 0 !important; + padding: 0 !important; +} + +div.sharedaddy div.pd-rating { + margin: 0; + min-height: 23px; } -.sharing li:before, .sharing-hidden li:before { - content: none !important; +div.sharedaddy a, +div.sharedaddy a:link, +div.sharedaddy a:visited { + font-style: normal; } +/* ClearFix trick */ -.sharing li a, .sharing-hidden li a { - padding: 0px 0 0 20px; - line-height: 24px; +div.sharedaddy:before, +div.sharedaddy:after, +div.sharedaddy .sd-block:before, +div.sharedaddy .sd-block:after, +div.sharedaddy ul:before, +div.sharedaddy ul:after { + content: "\0020"; display: block; + height: 0; + overflow: hidden; } -.sharing li.share-regular a, .sharing-hidden li a, .sharing li.share-regular a:hover, .sharing-hidden li a:hover { - border: none !important; +div.sharedaddy:after, +div.sharedaddy .sd-block:after, +div.sharedaddy ul:after { + clear: both; } -.share-custom a.sharing-anchor{ - color: #666; - font-size:11px; - font-family: arial, tahoma, verdana, sans-serif; - text-decoration: none; +div.sharedaddy, +div.sharedaddy .sd-block, +div.sharedaddy ul { + zoom: 1; } -.sharing li.share-custom{ +/* =Base Styles +-------------------------------------------------------------- */ + +div.sharedaddy div.sd-block { + border-top: 1px solid #ddd; + border-top: 1px solid rgba(0,0,0,.13); + padding: 10px 0 5px; + margin: 0; + width: 100% !important; } -.sharing-hidden a{ - color: #666; +div.sharedaddy.sharedaddy-dark .sd-block { + border-top-color: #222; + border-top-color: rgba(50,50,50,.5); +} + +div.sharedaddy .sd-content { + width: 82.125%; /* 530px / 640px */ + float: right; + margin: 0; } -.sharing a.share-twitter,.sharing-hidden a.share-twitter { background: url('images/twitter.png') no-repeat center left; } -.sharing a.share-facebook,.sharing-hidden a.share-facebook { background: url('images/facebook.png') no-repeat center left; } -.sharing a.share-email,.sharing-hidden a.share-email { background: url('images/email.png') no-repeat center left; } -.sharing a.share-digg,.sharing-hidden a.share-digg { background: url('images/digg.png') no-repeat center left; } -.sharing a.share-stumbleupon,.sharing-hidden a.share-stumbleupon { background: url('images/stumbleupon.png') no-repeat center left; } -.sharing a.share-reddit,.sharing-hidden a.share-reddit { background: url('images/reddit.png') no-repeat center left; } -.sharing a.share-print,.sharing-hidden a.share-print { background: url('images/print.png') no-repeat center left; } -.sharing a.share-press-this,.sharing-hidden a.share-press-this { background: url('images/wordpress.png') no-repeat center left; } -.sharing a.share-linkedin,.sharing-hidden a.share-linkedin { background: url('images/linkedin.png') no-repeat center left; } -.sharing a.share-google-plus-1,.sharing-hidden a.share-google-plus-1 { background: url('images/googleplus1.png') no-repeat center left; } - -.sharing div.twitter_button { padding: 4px 0; } -.sharing div.reddit_button { padding: 4px 0 0 0; } -.sharing div.stumbleupon_button { padding: 4px; } -.sharing div.digg_button { font-size: 0px; padding: 0 0 0 0; } -.sharing div.facebook_button { font-size: 0px; padding: 5px 0; height: 18px;} -.sharing div.like_button { font-size: 0px; padding: 4px 0; height: 18px;} -.sharing div.linkedin_button { padding-top: 4px; line-height: 16px; } -.sharing div.googleplus1_button { padding-top: 4px; line-height: 16px; } - -.sharing-hidden li { - width: 130px; -} - -.sharing-hidden div.twitter_button { padding: 0; } -.sharing-hidden div.reddit_button { padding: 0; } -.sharing-hidden div.stumbleupon_button { padding: 0; } -.sharing-hidden div.digg_button { font-size: 0px; padding: 0; } -.sharing-hidden div.facebook_button { font-size: 0px; padding: 0;} -.sharing-hidden div.like_button { font-size: 0px; padding: 0;} -.sharing-hidden div.linkedin_button { padding: 0; } -.sharing-hidden div.googleplus1_button { padding: 0; } - - -.sharing div.facebook_button a, .sharing-hidden.facebook_button a { - line-height: none; +div.sharedaddy .sd-content ul { + margin: 0; +} + +div.sharedaddy .sd-content li { + float: left; + margin: 0 5px 5px 0 !important; + display: block; +} + +.rtl div.sharedaddy .sd-content { + float: right; +} + +.rtl div.sharedaddy .sd-content li { + float: right; + margin: 0 0 5px 5px !important; +} + +/* Base Button .sd-button */ + +div.sharedaddy a.sd-button { + margin: 0; padding: 0; + display: inline-block; + background: #efefef; + background: -moz-linear-gradient(top, #f7f7f7 0%, #efefef 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f7f7), color-stop(100%,#efefef)); + background: -webkit-linear-gradient(top, #f7f7f7 0%,#efefef 100%); + background: -o-linear-gradient(top, #f7f7f7 0%,#efefef 100%); + background: -ms-linear-gradient(top, #f7f7f7 0%,#efefef 100%); + background: linear-gradient(top, #f7f7f7 0%,#efefef 100%); + border-radius: 3px; + border: 1px solid #ddd !important; + box-shadow: inset 0 1px 0 #fff; + color: #000 !important; + text-decoration: none; + line-height: 1; + font-size: 12px; + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; + font-weight: normal; } -#sharing_email { - background-color: #fff; - padding: 15px; - width: 312px; - position: absolute; - border: 2px solid #6e6e6e; - z-index: 1001; - text-align: left; +div.sharedaddy a.sd-button:hover { + color: #000; + text-shadow: 0 1px 0 #fff; + border-color: #ccc; + background: #eee; + background: -moz-linear-gradient(top, #efefef 0%, #eee 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#efefef), color-stop(100%,#eee)); + background: -webkit-linear-gradient(top, #efefef 0%,#eee 100%); + background: -o-linear-gradient(top, #efefef 0%,#eee 100%); + background: -ms-linear-gradient(top, #efefef 0%,#eee 100%); + background: linear-gradient(top, #efefef 0%,#eee 100%); } -#sharing_email .errors { - color: #fff; - background-color: #771a09; - font-size: 11px; - padding: 5px 8px; - line-height: 11px; - margin: 10px 0 0 0; +div.sharedaddy a.sd-button:active { + background-color: #efefef; + box-shadow: inset 0 -1px 0 #fff; + border-color: #ddd; } -#sharing_email label { - font-size: 11px; - color: #333; - font-weight: bold; +a.sd-button > span { + padding: 4px 8px; display: block; - padding: 0 0 4px 0; - text-align: left; + opacity: .8; + line-height: 1; + text-shadow: none; } -#sharing_email input[type="text"] { - width: 100%; - margin-bottom: 12px; +a.sd-button:hover span { + opacity: 1; } -#sharing_email .sharing_send { +.sd-button span.share-count { + font-size: 90%; + color: #666; + margin-left: 5px; } -#sharing_email .sharing_cancel { - padding: 0 0 0 10px; - font-size: 11px; +.rtl .sd-button span.share-count { + margin-right: 5px; } -#sharing_email .recaptcha { - width: 312px; - height: 123px; - margin: 10px 0 14px 0; +/* Button Style Options */ + +.sd-social-icon-text a.sd-button > span, +a.sd-button > span { + padding: 3px 5px 3px 23px; + background-position: 2px center; + background-repeat: no-repeat; +} + +.sd-social-icon a.sd-button > span { + padding: 3px; + width: 16px; + height: 16px; + text-indent: -9999px; + background-position: center center; + background-repeat: no-repeat; } -#sharing_background { - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - background-color: black; - z-index: 1000; +.sd-social-text a.sd-button > span { + background: none !important; + padding-left: 5px } -.sharing-hidden { - padding: 10px 0 0 0; +.sd-social-official li { + height: 21px; } -.sharing-hidden .inner { - border: 2px solid #6e6e6e; - padding: 15px 0 15px 0; - background: #fff; - position: absolute; - top: 0; - left: 0; - margin: 0px !important; - width: 300px; - z-index: 1000; +div.sharedaddy .no-text { + width: 21px; + height: 21px; } -.sharing-hidden ul { - background: white url('images/share-bg.png') repeat-y center center; - margin: 0 !important; +div.sharedaddy .no-text a { + text-decoration: none; } -.sharing-hidden li { - padding-left:10px !important; - padding-right:10px !important; - padding-top:0px !important; - margin: 0 !important; - margin-bottom:10px !important; +div.sharedaddy .no-icon a span, div.sharedaddy li.no-icon div a span { + padding-left: 5px; + background-image: none; } -.sharing-hidden li a { - padding-right: 20px; - font-size: 11px; - line-height: 16px; - display: block; - text-decoration: none !important; - border-bottom: 0px !important; +.rtl .sd-social-icon-text a.sd-button > span, +.rtl a.sd-button > span { + padding: 3px 23px 3px 5px; + background-position: 98% center; +} +.rtl .sd-social-text a.sd-button > span { + padding-left: 0; + padding-right: 5px } -.sharing-hidden li a.no-text{ - width: 16px; - height:16px; +.rtl div.sharedaddy .no-icon a span, .rtl div.sharedaddy li.no-icon div a span { + padding-left: 0; + padding-right: 5px } -.sharing li a.no-text{ - width: 16px; - height: 16px; - margin-top: 4px; - padding: 0px !important; +/* Icons */ + +li.share-facebook a.sd-button > span { + background-image: url('images/facebook.png'); } -.sharing li a.no-icon { - background: none !important; - padding-left: 0 !important; +li.share-tumblr a.sd-button > span { + background-image: url('images/tumblr.png'); } -.sharing li.share-end, .sharing-hidden li.share-end { - clear: both; - height: 0; - padding: 0px !important; - margin: 0px !important; - width: 0; - visibility: hidden; - float: none; +li.share-twitter a.sd-button > span { + background-image: url('images/twitter.png?1'); } -.sharing .sharing-anchor { - border-radius: 3px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border: 1px solid #d8d8d8; - float: left; - line-height: 20px; - padding: 0 8px 0 21px; - background: #fff url('images/sharing-hidden.png') no-repeat 0px center; - font-weight: normal; +li.share-linkedin a.sd-button > span { + background-image: url('images/linkedin.png'); } -.sharing-clear { - clear: left; +li.share-press-this a.sd-button > span { + background-image: url('images/wordpress.png'); } -.response { +li.share-digg a.sd-button > span { + background-image: url('images/digg.png'); } -.response-title { - font-size: 12px; - line-height: 18px; - font-weight: bold; +li.share-stumbleupon a.sd-button > span { + background-image: url('images/stumbleupon.png'); } -.response-sub { - font-size: 11px; - line-height: 24px; +li.share-reddit a.sd-button > span { + background-image: url('images/reddit.png'); } -.response-close .sharing_cancel { - padding: 0px !important; +li.share-pinterest a.sd-button > span { + background-image: url('images/pinterest.png'); } -li.share-email, li.share-custom a.sharing-anchor { - display: none !important; +li.share-email a.sd-button > span { + background-image: url('images/email.png'); } -li.share-service-visible { - display: list-item !important; +li.share-print a.sd-button > span { + background-image: url('images/print.png'); } -li.share-custom a.sharing-anchor.share-service-visible { - display: inline !important; +a.sd-button.share-more span { + background-image: url('images/more.png'); +} + +@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { + + li.share-facebook a.sd-button > span { + background-image: url('images/facebook@2x.png'); + background-size: 16px 16px; + } + + li.share-tumblr a.sd-button > span { + background-image: url('images/tumblr@2x.png'); + background-size: 16px 16px; + } + + li.share-twitter a.sd-button > span { + background-image: url('images/twitter@2x.png?1'); + background-size: 16px 16px; + } + + li.share-linkedin a.sd-button > span { + background-image: url('images/linkedin@2x.png'); + background-size: 16px 16px; + } + + li.share-press-this a.sd-button > span { + background-image: url('images/wordpress@2x.png'); + background-size: 16px 16px; + } + + li.share-digg a.sd-button > span { + background-image: url('images/digg@2x.png?1'); + background-size: 16px 16px; + } + + li.share-stumbleupon a.sd-button > span { + background-image: url('images/stumbleupon@2x.png'); + background-size: 16px 16px; + } + + li.share-reddit a.sd-button > span { + background-image: url('images/reddit@2x.png'); + background-size: 16px 16px; + } + + li.share-pinterest a.sd-button > span { + background-image: url('images/pinterest@2x.png'); + background-size: 16px 16px; + } + + li.share-email a.sd-button > span { + background-image: url('images/email@2x.png?1'); + background-size: 16px 16px; + } + + li.share-print a.sd-button > span { + background-image: url('images/print@2x.png'); + background-size: 16px 16px; + } + + a.sd-button.share-more span { + background-image: url('images/more@2x.png?1'); + background-size: 16px 16px; + } + +} + + +/* Special case for non-smart implementations of Google+ button */ + +div.sharedaddy .sd-content ul li.share-google-plus-1 { + line-height: 90%; + margin-bottom: 2px !important; + min-height: 20px; +} + +div.sharedaddy .sd-social-official .sd-content ul li.share-google-plus-1 { + padding-top: 0; +} + +/* More pannel */ + +div.sharedaddy .sharing-hidden .inner { + max-width: 250px; + padding: 15px 15px 10px; + position: absolute; + margin-left: -100px; + z-index: 1001; + background-color: #fff; + border: 1px solid #ccc; + -moz-border-radius: 3px !important; + -webkit-border-radius: 3px !important; + border-radius: 3px !important; + -moz-box-shadow: 0px 2px 8px #ccc; + -webkit-box-shadow: 0px 2px 8px #ccc; + box-shadow: 0px 2px 8px #ccc; + -webkit-box-shadow: 0px 2px 8px rgba(0, 0, 0, .2); + -moz-box-shadow: 0px 2px 8px rgba(0, 0, 0, .2); + box-shadow: 0px 2px 8px rgba(0, 0, 0, .2); +} + +.rtl div.sharedaddy .sharing-hidden .inner { + margin-left: 0; + margin-right: -100px; +} + +div.sharedaddy.sharedaddy-dark .sharing-hidden .inner { + border-color: #222; +} + +div.sd-content a.sd-button > span { + line-height: 1.5em; +} + +#sharing_email { + background-color: #FFFFFF; + border: 1px solid #CCCCCC; + border-radius: 3px 3px 3px 3px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); + margin-left: -120px; + padding: 15px; + position: absolute; + text-align: left; + width: 312px; + z-index: 1001; +} + +div.sharedaddy.sharedaddy-dark #sharing_email { + border-color: #FFFFFF; +} + +#sharing_email .errors { + background-color: #771A09; + color: #FFFFFF; + font-size: 11px; + line-height: 11px; + margin: 10px 0 0; + padding: 5px 8px; +} + +#sharing_email label { + color: #333333; + display: block; + font-size: 11px; + font-weight: bold; + padding: 0 0 4px; + text-align: left; + text-shadow: none; +} + +#sharing_email input[type="text"] { + background: none repeat scroll 0 0 #FFFFFF; + border: 1px solid #CCCCCC; + color: #333333; + margin-bottom: 12px; + width: 98.5%; +} + +#sharing_email .sharing_cancel { + font-size: 11px; + padding: 0 0 0 10px; + text-shadow: none; +} + +#sharing_email .recaptcha { + height: 123px; + margin: 10px 0 14px; + width: 312px; } /* =RTL @@ -276,3 +490,14 @@ body.rtl .sharing ul { body.rtl .sharing li { margin: 0 0 0 10px !important; } +.rtl #sharing_email { + margin-left: 0; + margin-right: -120px; + text-align: right; +} +.rtl #sharing_email .sharing_cancel { + padding: 0 10px 0 0; +} +.rtl #sharing_email label { + text-align: right; +}
\ No newline at end of file diff --git a/plugins/jetpack/modules/sharedaddy/sharing.js b/plugins/jetpack/modules/sharedaddy/sharing.js index 9a288457..a6c29494 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing.js +++ b/plugins/jetpack/modules/sharedaddy/sharing.js @@ -1,22 +1,64 @@ +var WPCOMSharing = { + get_counts : function( url ) { + if ( jQuery( '#sharing-facebook-' + WPCOM_sharing_counts[ url ] ).length ) + jQuery.getScript( 'https://graph.facebook.com/' + encodeURIComponent( url ) + '?callback=WPCOMSharing.update_facebook_count' ); + if ( jQuery( '#sharing-twitter-' + WPCOM_sharing_counts[ url ] ).length ) + jQuery.getScript( 'http://urls.api.twitter.com/1/urls/count.json?callback=WPCOMSharing.update_twitter_count&url=' + encodeURIComponent( url ) ); + if ( jQuery( '#sharing-linkedin-' + WPCOM_sharing_counts[ url ] ).length ) + jQuery.getScript( 'http://www.linkedin.com/countserv/count/share?format=jsonp&callback=WPCOMSharing.update_linkedin_count&url=' + encodeURIComponent( url ) ); + }, + update_facebook_count : function( data ) { + if ( 'undefined' != typeof data.shares && ( data.shares * 1 ) > 0 ) { + WPCOMSharing.inject_share_count( 'sharing-facebook-' + WPCOM_sharing_counts[ data.id ], data.shares ); + } + }, + update_twitter_count : function( data ) { + if ( 'undefined' != typeof data.count && ( data.count * 1 ) > 0 ) { + WPCOMSharing.inject_share_count( 'sharing-twitter-' + WPCOM_sharing_counts[ data.url ], data.count ); + } + }, + update_linkedin_count : function( data ) { + if ( 'undefined' != typeof data.count && ( data.count * 1 ) > 0 ) { + WPCOMSharing.inject_share_count( 'sharing-linkedin-' + WPCOM_sharing_counts[ data.url ], data.count ); + } + }, + inject_share_count : function( dom_id, count ) { + jQuery( '#' + dom_id + ' span' ).append( '<span class="share-count">' + WPCOMSharing.format_count( count ) + '</span>' ); + }, + format_count : function( count ) { + if ( count < 1000 ) + return count; + if ( count >= 1000 && count < 10000 ) + return String( count ).substring( 0, 1 ) + 'K+'; + return '10K+'; + } +}; + (function($){ - $.fn.extend( { + $.fn.extend( { share_is_email: function( value ) { - return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test( this.val() ); + return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test( this.val() ); + } + } ); + + if ( 'undefined' != typeof WPCOM_sharing_counts ) { + for ( var url in WPCOM_sharing_counts ) { + WPCOMSharing.get_counts( url ); } - } ); + } $( document ).on( 'ready post-load', function() { - var $more_sharing_buttons = $( '.sharing a.sharing-anchor' ); + var $more_sharing_buttons = $( '.sharedaddy a.sharing-anchor' ); $more_sharing_buttons.click( function() { return false; } ); - $( '.sharing a' ).each( function() { + $( '.sharedaddy a' ).each( function() { if ( $( this ).attr( 'href' ) && $( this ).attr( 'href' ).indexOf( 'share=' ) != -1 ) $( this ).attr( 'href', $( this ).attr( 'href' ) + '&nb=1' ); } ); - + // Show hidden buttons // Touchscreen device: use click. @@ -29,14 +71,14 @@ // We're in the middle of some other event's animation return; } - + if ( true === $more_sharing_pane.data( 'justSlid' ) ) { // We just finished some other event's animation - don't process click event so that slow-to-react-clickers don't get confused return; } - + $( '#sharing_email' ).slideUp( 200 ); - + $more_sharing_pane.css( { left: $more_sharing_button.position().left + 'px', top: $more_sharing_button.position().top + $more_sharing_button.height() + 3 + 'px' @@ -53,7 +95,7 @@ // Create a timer to make the area appear if the mouse hovers for a period var timer = setTimeout( function() { $( '#sharing_email' ).slideUp( 200 ); - + $more_sharing_pane.data( 'justSlid', true ); $more_sharing_pane.css( { left: $more_sharing_button.position().left + 'px', @@ -61,7 +103,7 @@ } ).slideDown( 200, function() { // Mark the item as have being appeared by the hover $more_sharing_button.data( 'hasoriginal', true ).data( 'hasitem', false ); - + // Remove all special handlers $more_sharing_pane.mouseleave( handler_item_leave ).mouseenter( handler_item_enter ); $more_sharing_button.mouseleave( handler_original_leave ).mouseenter( handler_original_enter ); @@ -69,36 +111,36 @@ $more_sharing_pane.data( 'justSlid', false ); }, 300 ); } ); - + // The following handlers take care of the mouseenter/mouseleave for the share button and the share area - if both are left then we close the share area var handler_item_leave = function() { $more_sharing_button.data( 'hasitem', false ); - + if ( $more_sharing_button.data( 'hasoriginal' ) === false ) { var timer = setTimeout( close_it, 800 ); $more_sharing_button.data( 'timer2', timer ); } }; - + var handler_item_enter = function() { $more_sharing_button.data( 'hasitem', true ); clearTimeout( $more_sharing_button.data( 'timer2' ) ); - } - + } + var handler_original_leave = function() { $more_sharing_button.data( 'hasoriginal', false ); - + if ( $more_sharing_button.data( 'hasitem' ) === false ) { var timer = setTimeout( close_it, 800 ); $more_sharing_button.data( 'timer2', timer ); } }; - + var handler_original_enter = function() { $more_sharing_button.data( 'hasoriginal', true ); clearTimeout( $more_sharing_button.data( 'timer2' ) ); }; - + var close_it = function() { $more_sharing_pane.data( 'justSlid', true ); $more_sharing_pane.slideUp( 200, function() { @@ -106,14 +148,14 @@ $more_sharing_pane.data( 'justSlid', false ); }, 300 ); } ); - + // Clear all hooks $more_sharing_button.unbind( 'mouseleave', handler_original_leave ).unbind( 'mouseenter', handler_original_enter ); $more_sharing_pane.unbind( 'mouseleave', handler_item_leave ).unbind( 'mouseenter', handler_item_leave ); return false; }; }, 200 ); - + // Remember the timer so we can detect it on the mouseout $more_sharing_button.data( 'timer', timer ); } @@ -125,17 +167,17 @@ $more_sharing_buttons.data( 'timer', false ); } ); } - + // Add click functionality - $( '.sharing ul' ).each( function( item ) { + $( '.sharedaddy ul' ).each( function( item ) { printUrl = function ( uniqueId, urlToPrint ) { $( 'body:first' ).append( '<iframe style="position:fixed;top:100;left:100;height:1px;width:1px;border:none;" id="printFrame-' + uniqueId + '" name="printFrame-' + uniqueId + '" src="' + urlToPrint + '" onload="frames[\'printFrame-' + uniqueId + '\'].focus();frames[\'printFrame-' + uniqueId + '\'].print();"></iframe>' ) }; - + // Print button - $( this ).find( '.share-print a' ).click( function() { + $( this ).find( 'a.share-print' ).click( function() { ref = $( this ).attr( 'href' ); - + var do_print = function() { if ( ref.indexOf( '#print' ) == -1 ) { uid = new Date().getTime(); @@ -144,7 +186,7 @@ else print(); } - + // Is the button in a dropdown? if ( $( this ).parents( '.sharing-hidden' ).length > 0 ) { $( this ).parents( '.inner' ).slideUp( 0, function() { @@ -156,11 +198,11 @@ return false; } ); - + // Press This button - $( this ).find( '.share-press-this a' ).click( function() { + $( this ).find( 'a.share-press-this' ).click( function() { var s = ''; - + if ( window.getSelection ) s = window.getSelection(); else if( document.getSelection ) @@ -171,32 +213,39 @@ if ( s ) $( this ).attr( 'href', $( this ).attr( 'href' ) + '&sel=' + encodeURI( s ) ); - if ( !window.open( $( this ).attr( 'href' ), 't', 'toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570' ) ) + if ( !window.open( $( this ).attr( 'href' ), 't', 'toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570' ) ) document.location.href = $( this ).attr( 'href' ); return false; } ); // Email button - $( this ).find( '.share-email a' ).click( function() { + $( this ).find( 'a.share-email' ).click( function() { var url = $( this ).attr( 'href' ); - + if ( $( '#sharing_email' ).is( ':visible' ) ) $( '#sharing_email' ).slideUp( 200 ); else { - $( '.sharing .inner' ).slideUp(); + $( '.sharedaddy .inner' ).slideUp(); $( '#sharing_email .response' ).remove(); $( '#sharing_email form' ).show(); $( '#sharing_email form input[type=submit]' ).removeAttr( 'disabled' ); $( '#sharing_email form a.sharing_cancel' ).show(); + + var key = ''; + if ( $( '#recaptcha_public_key' ).length > 0 ) + key = $( '#recaptcha_public_key' ).val(); + + // Update the recaptcha + Recaptcha.create( key, 'sharing_recaptcha' ); // Show dialog $( '#sharing_email' ).css( { left: $( this ).offset().left + 'px', top: $( this ).offset().top + $( this ).height() + 'px' } ).slideDown( 200 ); - + // Hook up other buttons $( '#sharing_email a.sharing_cancel' ).unbind( 'click' ).click( function() { $( '#sharing_email .errors' ).hide(); @@ -204,25 +253,25 @@ $( '#sharing_background' ).fadeOut(); return false; } ); - + // Submit validation $( '#sharing_email input[type=submit]' ).unbind( 'click' ).click( function() { var form = $( this ).parents( 'form' ); - + // Disable buttons + enable loading icon - $( this ).attr( 'disabled', 'disabled' ); + $( this ).prop( 'disabled', true ); form.find( 'a.sharing_cancel' ).hide(); form.find( 'img.loading' ).show(); - + $( '#sharing_email .errors' ).hide(); $( '#sharing_email .error' ).removeClass( 'error' ); - + if ( $( '#sharing_email input[name=source_email]' ).share_is_email() == false ) $( '#sharing_email input[name=source_email]' ).addClass( 'error' ); - + if ( $( '#sharing_email input[name=target_email]' ).share_is_email() == false ) $( '#sharing_email input[name=target_email]' ).addClass( 'error' ); - + if ( $( '#sharing_email .error' ).length == 0 ) { // AJAX send the form $.ajax( { @@ -236,6 +285,7 @@ $( '#sharing_email .errors-' + response ).show(); form.find( 'input[type=submit]' ).removeAttr( 'disabled' ); form.find( 'a.sharing_cancel' ).show(); + Recaptcha.reload(); } else { $( '#sharing_email form' ).hide(); @@ -248,10 +298,10 @@ } } } ); - + return false; } - + form.find( 'img.loading' ).hide(); form.find( 'input[type=submit]' ).removeAttr( 'disabled' ); form.find( 'a.sharing_cancel' ).show(); @@ -260,11 +310,42 @@ return false; } ); } - + return false; } ); } ); - + $( 'li.share-email, li.share-custom a.sharing-anchor' ).addClass( 'share-service-visible' ); } ); })( jQuery ); + +// Recaptcha code +var RecaptchaTemplates={};RecaptchaTemplates.VertHtml='<table id="recaptcha_table" class="recaptchatable" > <tr> <td colspan="6" class=\'recaptcha_r1_c1\'></td> </tr> <tr> <td class=\'recaptcha_r2_c1\'></td> <td colspan="4" class=\'recaptcha_image_cell\'><div id="recaptcha_image"></div></td> <td class=\'recaptcha_r2_c2\'></td> </tr> <tr> <td rowspan="6" class=\'recaptcha_r3_c1\'></td> <td colspan="4" class=\'recaptcha_r3_c2\'></td> <td rowspan="6" class=\'recaptcha_r3_c3\'></td> </tr> <tr> <td rowspan="3" class=\'recaptcha_r4_c1\' height="49"> <div class="recaptcha_input_area"> <label for="recaptcha_response_field" class="recaptcha_input_area_text"><span id="recaptcha_instructions_image" class="recaptcha_only_if_image recaptcha_only_if_no_incorrect_sol"></span><span id="recaptcha_instructions_audio" class="recaptcha_only_if_no_incorrect_sol recaptcha_only_if_audio"></span><span id="recaptcha_instructions_error" class="recaptcha_only_if_incorrect_sol"></span></label><br/> <input name="recaptcha_response_field" id="recaptcha_response_field" type="text" /> </div> </td> <td rowspan="4" class=\'recaptcha_r4_c2\'></td> <td><a id=\'recaptcha_reload_btn\'><img id=\'recaptcha_reload\' width="25" height="17" /></a></td> <td rowspan="4" class=\'recaptcha_r4_c4\'></td> </tr> <tr> <td><a id=\'recaptcha_switch_audio_btn\' class="recaptcha_only_if_image"><img id=\'recaptcha_switch_audio\' width="25" height="16" alt="" /></a><a id=\'recaptcha_switch_img_btn\' class="recaptcha_only_if_audio"><img id=\'recaptcha_switch_img\' width="25" height="16" alt=""/></a></td> </tr> <tr> <td><a id=\'recaptcha_whatsthis_btn\'><img id=\'recaptcha_whatsthis\' width="25" height="16" /></a></td> </tr> <tr> <td class=\'recaptcha_r7_c1\'></td> <td class=\'recaptcha_r8_c1\'></td> </tr> </table> ';RecaptchaTemplates.CleanCss=".recaptchatable td img{display:block}.recaptchatable .recaptcha_image_cell center img{height:57px}.recaptchatable .recaptcha_image_cell center{height:57px}.recaptchatable .recaptcha_image_cell{background-color:white;height:57px;padding:7px!important}.recaptchatable,#recaptcha_area tr,#recaptcha_area td,#recaptcha_area th{margin:0!important;border:0!important;border-collapse:collapse!important;vertical-align:middle!important}.recaptchatable *{margin:0;padding:0;border:0;color:black;position:static;top:auto;left:auto;right:auto;bottom:auto;text-align:left!important}.recaptchatable #recaptcha_image{margin:auto;border:1px solid #dfdfdf!important}.recaptchatable a img{border:0}.recaptchatable a,.recaptchatable a:hover{-moz-outline:none;border:0!important;padding:0!important;text-decoration:none;color:blue;background:none!important;font-weight:normal}.recaptcha_input_area{position:relative!important;background:none!important}.recaptchatable label.recaptcha_input_area_text{border:1px solid #dfdfdf!important;margin:0!important;padding:0!important;position:static!important;top:auto!important;left:auto!important;right:auto!important;bottom:auto!important}.recaptcha_theme_red label.recaptcha_input_area_text,.recaptcha_theme_white label.recaptcha_input_area_text{color:black!important}.recaptcha_theme_blackglass label.recaptcha_input_area_text{color:white!important}.recaptchatable #recaptcha_response_field{font-size:11pt}.recaptcha_theme_blackglass #recaptcha_response_field,.recaptcha_theme_white #recaptcha_response_field{border:1px solid gray}.recaptcha_theme_red #recaptcha_response_field{border:1px solid #cca940}.recaptcha_audio_cant_hear_link{font-size:7pt;color:black}.recaptchatable{line-height:1em;border:1px solid #dfdfdf!important}.recaptcha_error_text{color:red}";RecaptchaTemplates.CleanHtml='<table id="recaptcha_table" class="recaptchatable"> <tr height="73"> <td class=\'recaptcha_image_cell\' width="302"><center><div id="recaptcha_image"></div></center></td> <td style="padding: 10px 7px 7px 7px;"> <a id=\'recaptcha_reload_btn\'><img id=\'recaptcha_reload\' width="25" height="18" alt="" /></a> <a id=\'recaptcha_switch_audio_btn\' class="recaptcha_only_if_image"><img id=\'recaptcha_switch_audio\' width="25" height="15" alt="" /></a><a id=\'recaptcha_switch_img_btn\' class="recaptcha_only_if_audio"><img id=\'recaptcha_switch_img\' width="25" height="15" alt=""/></a> <a id=\'recaptcha_whatsthis_btn\'><img id=\'recaptcha_whatsthis\' width="25" height="16" /></a> </td> <td style="padding: 18px 7px 18px 7px;"> <img id=\'recaptcha_logo\' alt="" width="71" height="36" /> </td> </tr> <tr> <td style="padding-left: 7px;"> <div class="recaptcha_input_area" style="padding-top: 2px; padding-bottom: 7px;"> <input style="border: 1px solid #3c3c3c; width: 302px;" name="recaptcha_response_field" id="recaptcha_response_field" type="text" /> </div> </td> <td></td> <td style="padding: 4px 7px 12px 7px;"> <img id="recaptcha_tagline" width="71" height="17" /> </td> </tr> </table> ';RecaptchaTemplates.ContextHtml='<table id="recaptcha_table" class="recaptchatable"> <tr> <td colspan="6" class=\'recaptcha_r1_c1\'></td> </tr> <tr> <td class=\'recaptcha_r2_c1\'></td> <td colspan="4" class=\'recaptcha_image_cell\'><div id="recaptcha_image"></div></td> <td class=\'recaptcha_r2_c2\'></td> </tr> <tr> <td rowspan="6" class=\'recaptcha_r3_c1\'></td> <td colspan="4" class=\'recaptcha_r3_c2\'></td> <td rowspan="6" class=\'recaptcha_r3_c3\'></td> </tr> <tr> <td rowspan="3" class=\'recaptcha_r4_c1\' height="49"> <div class="recaptcha_input_area"> <label for="recaptcha_response_field" class="recaptcha_input_area_text"><span id="recaptcha_instructions_context" class="recaptcha_only_if_image recaptcha_only_if_no_incorrect_sol"></span><span id="recaptcha_instructions_audio" class="recaptcha_only_if_no_incorrect_sol recaptcha_only_if_audio"></span><span id="recaptcha_instructions_error" class="recaptcha_only_if_incorrect_sol"></span></label><br/> <input name="recaptcha_response_field" id="recaptcha_response_field" type="text" /> </div> </td> <td rowspan="4" class=\'recaptcha_r4_c2\'></td> <td><a id=\'recaptcha_reload_btn\'><img id=\'recaptcha_reload\' width="25" height="17" /></a></td> <td rowspan="4" class=\'recaptcha_r4_c4\'></td> </tr> <tr> <td><a id=\'recaptcha_switch_audio_btn\' class="recaptcha_only_if_image"><img id=\'recaptcha_switch_audio\' width="25" height="16" alt="" /></a><a id=\'recaptcha_switch_img_btn\' class="recaptcha_only_if_audio"><img id=\'recaptcha_switch_img\' width="25" height="16" alt=""/></a></td> </tr> <tr> <td><a id=\'recaptcha_whatsthis_btn\'><img id=\'recaptcha_whatsthis\' width="25" height="16" /></a></td> </tr> <tr> <td class=\'recaptcha_r7_c1\'></td> <td class=\'recaptcha_r8_c1\'></td> </tr> </table> ';RecaptchaTemplates.VertCss=".recaptchatable td img{display:block}.recaptchatable .recaptcha_r1_c1{background:url(IMGROOT/sprite.png) 0 -63px no-repeat;width:318px;height:9px}.recaptchatable .recaptcha_r2_c1{background:url(IMGROOT/sprite.png) -18px 0 no-repeat;width:9px;height:57px}.recaptchatable .recaptcha_r2_c2{background:url(IMGROOT/sprite.png) -27px 0 no-repeat;width:9px;height:57px}.recaptchatable .recaptcha_r3_c1{background:url(IMGROOT/sprite.png) 0 0 no-repeat;width:9px;height:63px}.recaptchatable .recaptcha_r3_c2{background:url(IMGROOT/sprite.png) -18px -57px no-repeat;width:300px;height:6px}.recaptchatable .recaptcha_r3_c3{background:url(IMGROOT/sprite.png) -9px 0 no-repeat;width:9px;height:63px}.recaptchatable .recaptcha_r4_c1{background:url(IMGROOT/sprite.png) -43px 0 no-repeat;width:171px;height:49px}.recaptchatable .recaptcha_r4_c2{background:url(IMGROOT/sprite.png) -36px 0 no-repeat;width:7px;height:57px}.recaptchatable .recaptcha_r4_c4{background:url(IMGROOT/sprite.png) -214px 0 no-repeat;width:97px;height:57px}.recaptchatable .recaptcha_r7_c1{background:url(IMGROOT/sprite.png) -43px -49px no-repeat;width:171px;height:8px}.recaptchatable .recaptcha_r8_c1{background:url(IMGROOT/sprite.png) -43px -49px no-repeat;width:25px;height:8px}.recaptchatable .recaptcha_image_cell center img{height:57px}.recaptchatable .recaptcha_image_cell center{height:57px}.recaptchatable .recaptcha_image_cell{background-color:white;height:57px}#recaptcha_area,#recaptcha_table{width:318px!important}.recaptchatable,#recaptcha_area tr,#recaptcha_area td,#recaptcha_area th{margin:0!important;border:0!important;padding:0!important;border-collapse:collapse!important;vertical-align:middle!important}.recaptchatable *{margin:0;padding:0;border:0;font-family:helvetica,sans-serif;font-size:8pt;color:black;position:static;top:auto;left:auto;right:auto;bottom:auto;text-align:left!important}.recaptchatable #recaptcha_image{margin:auto}.recaptchatable img{border:0!important;margin:0!important;padding:0!important}.recaptchatable a,.recaptchatable a:hover{-moz-outline:none;border:0!important;padding:0!important;text-decoration:none;color:blue;background:none!important;font-weight:normal}.recaptcha_input_area{position:relative!important;width:146px!important;height:45px!important;margin-left:20px!important;margin-right:5px!important;margin-top:4px!important;background:none!important}.recaptchatable label.recaptcha_input_area_text{margin:0!important;padding:0!important;position:static!important;top:auto!important;left:auto!important;right:auto!important;bottom:auto!important;background:none!important;height:auto!important;width:auto!important}.recaptcha_theme_red label.recaptcha_input_area_text,.recaptcha_theme_white label.recaptcha_input_area_text{color:black!important}.recaptcha_theme_blackglass label.recaptcha_input_area_text{color:white!important}.recaptchatable #recaptcha_response_field{width:145px!important;position:absolute!important;bottom:7px!important;padding:0!important;margin:0!important;font-size:10pt}.recaptcha_theme_blackglass #recaptcha_response_field,.recaptcha_theme_white #recaptcha_response_field{border:1px solid gray}.recaptcha_theme_red #recaptcha_response_field{border:1px solid #cca940}.recaptcha_audio_cant_hear_link{font-size:7pt;color:black}.recaptchatable{line-height:1em}#recaptcha_instructions_error{color:red!important}";var RecaptchaStr_en={visual_challenge:"Get a visual challenge",audio_challenge:"Get an audio challenge",refresh_btn:"Get a new challenge",instructions_visual:"Type the two words:",instructions_context:"Type the words in the boxes:",instructions_audio:"Type what you hear:",help_btn:"Help",play_again:"Play sound again",cant_hear_this:"Download sound as MP3",incorrect_try_again:"Incorrect. Try again."},RecaptchaStr_de={visual_challenge:"Visuelle Aufgabe generieren",audio_challenge:"Audio-Aufgabe generieren", +refresh_btn:"Neue Aufgabe generieren",instructions_visual:"Gib die 2 W\u00f6rter ein:",instructions_context:"",instructions_audio:"Gib die 8 Ziffern ein:",help_btn:"Hilfe",incorrect_try_again:"Falsch. Nochmals versuchen!"},RecaptchaStr_es={visual_challenge:"Obt\u00e9n un reto visual",audio_challenge:"Obt\u00e9n un reto audible",refresh_btn:"Obt\u00e9n un nuevo reto",instructions_visual:"Escribe las 2 palabras:",instructions_context:"",instructions_audio:"Escribe los 8 n\u00fameros:",help_btn:"Ayuda", +incorrect_try_again:"Incorrecto. Otro intento."},RecaptchaStr_fr={visual_challenge:"D\u00e9fi visuel",audio_challenge:"D\u00e9fi audio",refresh_btn:"Nouveau d\u00e9fi",instructions_visual:"Entrez les deux mots:",instructions_context:"",instructions_audio:"Entrez les huit chiffres:",help_btn:"Aide",incorrect_try_again:"Incorrect."},RecaptchaStr_nl={visual_challenge:"Test me via een afbeelding",audio_challenge:"Test me via een geluidsfragment",refresh_btn:"Nieuwe uitdaging",instructions_visual:"Type de twee woorden:", +instructions_context:"",instructions_audio:"Type de acht cijfers:",help_btn:"Help",incorrect_try_again:"Foute invoer."},RecaptchaStr_pt={visual_challenge:"Obter um desafio visual",audio_challenge:"Obter um desafio sonoro",refresh_btn:"Obter um novo desafio",instructions_visual:"Escreva as 2 palavras:",instructions_context:"",instructions_audio:"Escreva os 8 numeros:",help_btn:"Ajuda",incorrect_try_again:"Incorrecto. Tenta outra vez."},RecaptchaStr_ru={visual_challenge:"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443", +audio_challenge:"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0437\u0432\u0443\u043a\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443",refresh_btn:"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443",instructions_visual:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0434\u0432\u0430 \u0441\u043b\u043e\u0432\u0430:",instructions_context:"",instructions_audio:"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432\u043e\u0441\u0435\u043c\u044c \u0447\u0438\u0441\u0435\u043b:", +help_btn:"\u041f\u043e\u043c\u043e\u0449\u044c",incorrect_try_again:"\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e."},RecaptchaStr_tr={visual_challenge:"G\u00f6rsel deneme",audio_challenge:"\u0130\u015fitsel deneme",refresh_btn:"Yeni deneme",instructions_visual:"\u0130ki kelimeyi yaz\u0131n:",instructions_context:"",instructions_audio:"Sekiz numaray\u0131 yaz\u0131n:",help_btn:"Yard\u0131m (\u0130ngilizce)",incorrect_try_again:"Yanl\u0131\u015f. Bir daha deneyin."},RecaptchaStr_it= +{visual_challenge:"Modalit\u00e0 visiva",audio_challenge:"Modalit\u00e0 auditiva",refresh_btn:"Chiedi due nuove parole",instructions_visual:"Scrivi le due parole:",instructions_context:"",instructions_audio:"Trascrivi ci\u00f2 che senti:",help_btn:"Aiuto",incorrect_try_again:"Scorretto. Riprova."},RecaptchaLangMap={en:RecaptchaStr_en,de:RecaptchaStr_de,es:RecaptchaStr_es,fr:RecaptchaStr_fr,nl:RecaptchaStr_nl,pt:RecaptchaStr_pt,ru:RecaptchaStr_ru,tr:RecaptchaStr_tr,it:RecaptchaStr_it};var RecaptchaStr=RecaptchaStr_en,RecaptchaOptions,RecaptchaDefaultOptions={tabindex:0,theme:"red",callback:null,lang:"en",custom_theme_widget:null,custom_translations:null,includeContext:false},Recaptcha={widget:null,timer_id:-1,style_set:false,theme:null,type:"image",ajax_verify_cb:null,$:function(a){return typeof a=="string"?document.getElementById(a):a},create:function(a,b,c){Recaptcha.destroy();if(b)Recaptcha.widget=Recaptcha.$(b);Recaptcha._init_options(c);Recaptcha._call_challenge(a)},destroy:function(){var a= +Recaptcha.$("recaptcha_challenge_field");a&&a.parentNode.removeChild(a);Recaptcha.timer_id!=-1&&clearInterval(Recaptcha.timer_id);Recaptcha.timer_id=-1;if(a=Recaptcha.$("recaptcha_image"))a.innerHTML="";if(Recaptcha.widget){if(Recaptcha.theme!="custom")Recaptcha.widget.innerHTML="";else Recaptcha.widget.style.display="none";Recaptcha.widget=null}},focus_response_field:function(){var a=Recaptcha.$;a=a("recaptcha_response_field");a.focus()},get_challenge:function(){if(typeof RecaptchaState=="undefined")return null; +return RecaptchaState.challenge},get_response:function(){var a=Recaptcha.$;a=a("recaptcha_response_field");if(!a)return null;return a.value},ajax_verify:function(a){Recaptcha.ajax_verify_cb=a;a=Recaptcha._get_api_server()+"/ajaxverify?c="+encodeURIComponent(Recaptcha.get_challenge())+"&response="+encodeURIComponent(Recaptcha.get_response());Recaptcha._add_script(a)},_ajax_verify_callback:function(a){Recaptcha.ajax_verify_cb(a)},_get_api_server:function(){var a=window.location.protocol,b;b=typeof _RecaptchaOverrideApiServer!= +"undefined"?_RecaptchaOverrideApiServer:"www.google.com/recaptcha/api";return a+"//"+b},_call_challenge:function(a){a=Recaptcha._get_api_server()+"/challenge?k="+a+"&ajax=1&cachestop="+Math.random();if(typeof RecaptchaOptions.extra_challenge_params!="undefined")a+="&"+RecaptchaOptions.extra_challenge_params;if(RecaptchaOptions.includeContext)a+="&includeContext=1";Recaptcha._add_script(a)},_add_script:function(a){var b=document.createElement("script");b.type="text/javascript";b.src=a;Recaptcha._get_script_area().appendChild(b)}, +_get_script_area:function(){var a=document.getElementsByTagName("head");return a=!a||a.length<1?document.body:a[0]},_hash_merge:function(a){var b={};for(var c in a)for(var d in a[c])b[d]=a[c][d];if(b.theme=="context")b.includeContext=true;return b},_init_options:function(a){RecaptchaOptions=Recaptcha._hash_merge([RecaptchaDefaultOptions,a||{}])},challenge_callback:function(){Recaptcha._reset_timer();RecaptchaStr=Recaptcha._hash_merge([RecaptchaStr_en,RecaptchaLangMap[RecaptchaOptions.lang]||{},RecaptchaOptions.custom_translations|| +{}]);window.addEventListener&&window.addEventListener("unload",function(){Recaptcha.destroy()},false);Recaptcha._is_ie()&&window.attachEvent&&window.attachEvent("onbeforeunload",function(){});if(navigator.userAgent.indexOf("KHTML")>0){var a=document.createElement("iframe");a.src="about:blank";a.style.height="0px";a.style.width="0px";a.style.visibility="hidden";a.style.border="none";var b=document.createTextNode("This frame prevents back/forward cache problems in Safari.");a.appendChild(b);document.body.appendChild(a)}Recaptcha._finish_widget()}, +_add_css:function(a){var b=document.createElement("style");b.type="text/css";if(b.styleSheet)if(navigator.appVersion.indexOf("MSIE 5")!=-1)document.write("<style type='text/css'>"+a+"</style>");else b.styleSheet.cssText=a;else if(navigator.appVersion.indexOf("MSIE 5")!=-1)document.write("<style type='text/css'>"+a+"</style>");else{a=document.createTextNode(a);b.appendChild(a)}Recaptcha._get_script_area().appendChild(b)},_set_style:function(a){if(!Recaptcha.style_set){Recaptcha.style_set=true;Recaptcha._add_css(a+ +"\n\n.recaptcha_is_showing_audio .recaptcha_only_if_image,.recaptcha_isnot_showing_audio .recaptcha_only_if_audio,.recaptcha_had_incorrect_sol .recaptcha_only_if_no_incorrect_sol,.recaptcha_nothad_incorrect_sol .recaptcha_only_if_incorrect_sol{display:none !important}")}},_init_builtin_theme:function(){var a=Recaptcha.$,b=RecaptchaStr,c=RecaptchaState,d,e;c=c.server;if(c[c.length-1]=="/")c=c.substring(0,c.length-1);var f=c+"/img/"+Recaptcha.theme;if(Recaptcha.theme=="clean"){c=RecaptchaTemplates.CleanCss; +d=RecaptchaTemplates.CleanHtml;e="png"}else{if(Recaptcha.theme=="context"){c=RecaptchaTemplates.VertCss;d=RecaptchaTemplates.ContextHtml}else{c=RecaptchaTemplates.VertCss;d=RecaptchaTemplates.VertHtml}e="gif"}c=c.replace(/IMGROOT/g,f);Recaptcha._set_style(c);Recaptcha.widget.innerHTML="<div id='recaptcha_area'>"+d+"</div>";a("recaptcha_reload").src=f+"/refresh."+e;a("recaptcha_switch_audio").src=f+"/audio."+e;a("recaptcha_switch_img").src=f+"/text."+e;a("recaptcha_whatsthis").src=f+"/help."+e;if(Recaptcha.theme== +"clean"){a("recaptcha_logo").src=f+"/logo."+e;a("recaptcha_tagline").src=f+"/tagline."+e}a("recaptcha_reload").alt=b.refresh_btn;a("recaptcha_switch_audio").alt=b.audio_challenge;a("recaptcha_switch_img").alt=b.visual_challenge;a("recaptcha_whatsthis").alt=b.help_btn;a("recaptcha_reload_btn").href="javascript:Recaptcha.reload ();";a("recaptcha_reload_btn").title=b.refresh_btn;a("recaptcha_switch_audio_btn").href="javascript:Recaptcha.switch_type('audio');";a("recaptcha_switch_audio_btn").title=b.audio_challenge; +a("recaptcha_switch_img_btn").href="javascript:Recaptcha.switch_type('image');";a("recaptcha_switch_img_btn").title=b.visual_challenge;a("recaptcha_whatsthis_btn").href=Recaptcha._get_help_link();a("recaptcha_whatsthis_btn").target="_blank";a("recaptcha_whatsthis_btn").title=b.help_btn;a("recaptcha_whatsthis_btn").onclick=function(){Recaptcha.showhelp();return false};a("recaptcha_table").className="recaptchatable recaptcha_theme_"+Recaptcha.theme;a("recaptcha_instructions_image")&&a("recaptcha_instructions_image").appendChild(document.createTextNode(b.instructions_visual)); +a("recaptcha_instructions_context")&&a("recaptcha_instructions_context").appendChild(document.createTextNode(b.instructions_context));a("recaptcha_instructions_audio")&&a("recaptcha_instructions_audio").appendChild(document.createTextNode(b.instructions_audio));a("recaptcha_instructions_error")&&a("recaptcha_instructions_error").appendChild(document.createTextNode(b.incorrect_try_again))},_finish_widget:function(){var a=Recaptcha.$,b=RecaptchaState,c=RecaptchaOptions,d=c.theme;switch(d){case "red":case "white":case "blackglass":case "clean":case "custom":case "context":break; +default:d="red";break}if(!Recaptcha.theme)Recaptcha.theme=d;Recaptcha.theme!="custom"?Recaptcha._init_builtin_theme():Recaptcha._set_style("");d=document.createElement("span");d.id="recaptcha_challenge_field_holder";d.style.display="none";a("recaptcha_response_field").parentNode.insertBefore(d,a("recaptcha_response_field"));a("recaptcha_response_field").setAttribute("autocomplete","off");a("recaptcha_image").style.width="300px";a("recaptcha_image").style.height="57px";Recaptcha.should_focus=false; +Recaptcha._set_challenge(b.challenge,"image");if(c.tabindex){a("recaptcha_response_field").tabIndex=c.tabindex;if(Recaptcha.theme!="custom"){a("recaptcha_whatsthis_btn").tabIndex=c.tabindex;a("recaptcha_switch_img_btn").tabIndex=c.tabindex;a("recaptcha_switch_audio_btn").tabIndex=c.tabindex;a("recaptcha_reload_btn").tabIndex=c.tabindex}}if(Recaptcha.widget)Recaptcha.widget.style.display="";c.callback&&c.callback()},switch_type:function(a){var b=Recaptcha;b.type=a;b.reload(b.type=="audio"?"a":"v")}, +reload:function(a){var b=Recaptcha,c=RecaptchaState;if(typeof a=="undefined")a="r";c=c.server+"reload?c="+c.challenge+"&k="+c.site+"&reason="+a+"&type="+b.type+"&lang="+RecaptchaOptions.lang;if(RecaptchaOptions.includeContext)c+="&includeContext=1";if(typeof RecaptchaOptions.extra_challenge_params!="undefined")c+="&"+RecaptchaOptions.extra_challenge_params;if(b.type=="audio")c+=RecaptchaOptions.audio_beta_12_08?"&audio_beta_12_08=1":"&new_audio_default=1";b.should_focus=a!="t";b._add_script(c)},finish_reload:function(a, +b){RecaptchaState.is_incorrect=false;Recaptcha._set_challenge(a,b)},_set_challenge:function(a,b){var c=Recaptcha,d=RecaptchaState,e=c.$;d.challenge=a;c.type=b;e("recaptcha_challenge_field_holder").innerHTML="<input type='hidden' name='recaptcha_challenge_field' id='recaptcha_challenge_field' value='"+d.challenge+"'/>";if(b=="audio")e("recaptcha_image").innerHTML=Recaptcha.getAudioCaptchaHtml();else if(b=="image"){var f=d.server+"image?c="+d.challenge;e("recaptcha_image").innerHTML="<img style='display:block;' height='57' width='300' src='"+ +f+"'/>"}Recaptcha._css_toggle("recaptcha_had_incorrect_sol","recaptcha_nothad_incorrect_sol",d.is_incorrect);Recaptcha._css_toggle("recaptcha_is_showing_audio","recaptcha_isnot_showing_audio",b=="audio");c._clear_input();c.should_focus&&c.focus_response_field();c._reset_timer()},_reset_timer:function(){var a=RecaptchaState;clearInterval(Recaptcha.timer_id);Recaptcha.timer_id=setInterval("Recaptcha.reload('t');",(a.timeout-300)*1E3)},showhelp:function(){window.open(Recaptcha._get_help_link(),"recaptcha_popup", +"width=460,height=570,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes")},_clear_input:function(){var a=Recaptcha.$("recaptcha_response_field");a.value=""},_displayerror:function(a){var b=Recaptcha.$;b("recaptcha_image").innerHTML="";b("recaptcha_image").appendChild(document.createTextNode(a))},reloaderror:function(a){Recaptcha._displayerror(a)},_is_ie:function(){return navigator.userAgent.indexOf("MSIE")>0&&!window.opera},_css_toggle:function(a,b,c){var d=Recaptcha.widget; +if(!d)d=document.body;var e=d.className;e=e.replace(RegExp("(^|\\s+)"+a+"(\\s+|$)")," ");e=e.replace(RegExp("(^|\\s+)"+b+"(\\s+|$)")," ");e+=" "+(c?a:b);d.className=e},_get_help_link:function(){var a=RecaptchaOptions.lang;return"http://recaptcha.net/popuphelp/"+(a=="en"?"":a+".html")},playAgain:function(){var a=Recaptcha.$;a("recaptcha_image").innerHTML=Recaptcha.getAudioCaptchaHtml()},getAudioCaptchaHtml:function(){var a=Recaptcha,b=RecaptchaState,c=b.server+"image?c="+b.challenge;if(c.indexOf("https://")== +0)c="http://"+c.substring(8);b=b.server+"/img/audiocaptcha.swf?v2";a=a._is_ie()?'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="audiocaptcha" width="0" height="0" codebase="https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><param name="movie" value="'+b+'" /><param name="quality" value="high" /><param name="bgcolor" value="#869ca7" /><param name="allowScriptAccess" value="always" /></object><br/>':'<embed src="'+b+'" quality="high" bgcolor="#869ca7" width="0" height="0" name="audiocaptcha" align="middle" play="true" loop="false" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed> '; +c=(Recaptcha.checkFlashVer()?'<br/><a class="recaptcha_audio_cant_hear_link" href="#" onclick="Recaptcha.playAgain(); return false;">'+RecaptchaStr.play_again+"</a>":"")+'<br/><a class="recaptcha_audio_cant_hear_link" target="_blank" href="'+c+'">'+RecaptchaStr.cant_hear_this+"</a>";return a+c},gethttpwavurl:function(){var a=RecaptchaState;if(Recaptcha.type=="audio"){a=a.server+"image?c="+a.challenge;if(a.indexOf("https://")==0)a="http://"+a.substring(8);return a}return""},checkFlashVer:function(){var a= +navigator.appVersion.indexOf("MSIE")!=-1?true:false,b=navigator.appVersion.toLowerCase().indexOf("win")!=-1?true:false,c=navigator.userAgent.indexOf("Opera")!=-1?true:false,d=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){a=navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"";a=navigator.plugins["Shockwave Flash"+a].description;a=a.split(" ");a=a[2].split(".");d=a[0]}}else if(a&&b&&!c)try{var e=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"), +f=e.GetVariable("$version");d=f.split(" ")[1].split(",")[0]}catch(g){}return d>=9},getlang:function(){return RecaptchaOptions.lang}}; diff --git a/plugins/jetpack/modules/sharedaddy/sharing.php b/plugins/jetpack/modules/sharedaddy/sharing.php index 48f30767..3dd6f8d4 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing.php +++ b/plugins/jetpack/modules/sharedaddy/sharing.php @@ -9,19 +9,24 @@ class Sharing_Admin { require_once WP_SHARING_PLUGIN_DIR.'sharing-service.php'; - add_action( 'admin_init', array( $this, 'admin_init' ) ); - add_action( 'admin_menu', array( $this, 'subscription_menu' ) ); + add_action( 'admin_init', array( &$this, 'admin_init' ) ); + add_action( 'admin_menu', array( &$this, 'subscription_menu' ) ); + + // Insert our CSS and JS + add_action( 'load-settings_page_sharing', array( &$this, 'sharing_head' ) ); // Catch AJAX - add_action( 'wp_ajax_sharing_save_services', array( $this, 'ajax_save_services' ) ); - add_action( 'wp_ajax_sharing_save_options', array( $this, 'ajax_save_options' ) ); - add_action( 'wp_ajax_sharing_new_service', array( $this, 'ajax_new_service' ) ); - add_action( 'wp_ajax_sharing_delete_service', array( $this, 'ajax_delete_service' ) ); + add_action( 'wp_ajax_sharing_save_services', array( &$this, 'ajax_save_services' ) ); + add_action( 'wp_ajax_sharing_save_options', array( &$this, 'ajax_save_options' ) ); + add_action( 'wp_ajax_sharing_new_service', array( &$this, 'ajax_new_service' ) ); + add_action( 'wp_ajax_sharing_delete_service', array( &$this, 'ajax_delete_service' ) ); } public function sharing_head() { - wp_enqueue_script( 'sharing-js', WP_SHARING_PLUGIN_URL.'admin-sharing.js', array( 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-form' ), 1 ); - wp_enqueue_style( 'sharing', WP_SHARING_PLUGIN_URL.'admin-sharing.css', false, WP_SHARING_PLUGIN_VERSION ); + wp_enqueue_script( 'sharing-js', WP_SHARING_PLUGIN_URL.'admin-sharing.js', array( 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-form' ), 2 ); + wp_enqueue_style( 'sharing-admin', WP_SHARING_PLUGIN_URL.'admin-sharing.css', false, WP_SHARING_PLUGIN_VERSION ); + wp_enqueue_style( 'sharing', WP_SHARING_PLUGIN_URL.'sharing.css', false, WP_SHARING_PLUGIN_VERSION ); + wp_enqueue_script( 'sharing-js-fe', WP_SHARING_PLUGIN_URL . 'sharing.js', array( ), 2 ); add_thickbox(); } @@ -43,10 +48,7 @@ class Sharing_Admin { } public function subscription_menu( $user ) { - $hook = add_submenu_page( 'options-general.php', __( 'Sharing Settings', 'jetpack' ), __( 'Sharing', 'jetpack' ), 'manage_options', 'sharing', array( $this, 'management_page' ) ); - - // Insert our CSS and JS - add_action( "load-$hook", array( $this, 'sharing_head' ) ); + add_submenu_page( 'options-general.php', __( 'Sharing Settings', 'jetpack' ), __( 'Sharing', 'jetpack' ), 'publish_posts', 'sharing', array( &$this, 'management_page' ) ); } public function ajax_save_services() { @@ -102,35 +104,38 @@ class Sharing_Admin { } public function output_preview( $service ) { - $klasses = array( 'advanced', 'preview-item'); + $klasses = array( 'advanced', 'preview-item' ); - if ( $service->button_style != 'text' || $service->has_custom_button_style() ) { + if ( + 'googleplus1' == $service->shortname + || + $service->button_style != 'text' + || + $service->has_custom_button_style() + ) { $klasses[] = 'preview-'.$service->get_class(); + $klasses[] = 'share-'.$service->get_class(); - if ( $service->get_class() != $service->get_id() ) + if ( $service->get_class() != $service->get_id() ) $klasses[] = 'preview-'.$service->get_id(); } echo '<li class="'.implode( ' ', $klasses ).'">'; - $service->display_preview(); + echo $service->display_preview(); echo '</li>'; } public function output_service( $id, $service, $show_dropdown = false ) { ?> - <li class="service advanced<?php if ( $show_dropdown ) echo ' options'; ?> share-<?php echo $service->get_class(); ?>" id="<?php echo $service->get_id(); ?>"> - <span class="options-left"><?php echo esc_html( $service->get_name() ); ?></span><?php if ( $service->has_advanced_options() ) : ?><span class="options-toggle" style="background: url(<?php echo admin_url( '/images/menu-bits.gif' ); ?>) no-repeat 0px -110px;"> </span> - <br style="clear:both;" /> - <div class="advanced-form"> - <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>"> - <?php $service->display_options(); ?> - - <input type="hidden" name="action" value="sharing_save_options" /> - <input type="hidden" name="service" value="<?php echo esc_attr( $id ); ?>" /> - - <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options_'.$id );?>" /> - </form> - </div> + <li class="service advanced share-<?php echo $service->get_class(); ?>" id="<?php echo $service->get_id(); ?>"> + <span class="options-left"><?php echo esc_html( $service->get_name() ); ?></span> + <?php if ( 0 === strpos( $service->get_id(), 'custom-' ) || $service->has_advanced_options() ) : ?> + <span class="close"><a href="#" class="remove">×</a></span> + <form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>"> + <input type="hidden" name="action" value="sharing_delete_service" /> + <input type="hidden" name="service" value="<?php echo esc_attr( $id ); ?>" /> + <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options_'.$id );?>" /> + </form> <?php endif; ?> </li> <?php @@ -157,6 +162,13 @@ class Sharing_Admin { <div class="icon32" id="icon-options-general"><br /></div> <h2><?php _e( 'Sharing Settings', 'jetpack' ); ?></h2> + <?php do_action( 'pre_admin_screen_sharing' ) ?> + + <?php if ( current_user_can( 'manage_options' ) ) : ?> + + <h3><?php _e( 'Sharing Buttons' ) ?></h3> + <p><?php _e( 'Add sharing buttons to your blog and allow your visitors to share posts with their friends.' ) ?></p> + <div id="services-config"> <table id="available-services"> <tr> @@ -192,7 +204,7 @@ class Sharing_Admin { <h2 id="drag-instructions" <?php if ( count( $enabled['visible'] ) > 0 ) echo ' style="display: none"'; ?>><?php _e( 'Drag and drop available services here', 'jetpack' ); ?></h2> <ul class="services-enabled"> - <?php foreach ( $enabled['visible'] AS $id => $service ) : ?> + <?php foreach ( $enabled['visible'] as $id => $service ) : ?> <?php $this->output_service( $id, $service, true ); ?> <?php endforeach; ?> @@ -203,7 +215,7 @@ class Sharing_Admin { <p><?php _e( 'Services dragged here will be hidden behind a share button.', 'jetpack' ); ?></p> <ul class="services-hidden"> - <?php foreach ( $enabled['hidden'] AS $id => $service ) : ?> + <?php foreach ( $enabled['hidden'] as $id => $service ) : ?> <?php $this->output_service( $id, $service, true ); ?> <?php endforeach; ?> <li class="end-fix"></li> @@ -218,71 +230,56 @@ class Sharing_Admin { <h3><?php _e( 'Live Preview', 'jetpack' ); ?></h3> </td> <td class="services"> - <h2<?php if ( count( $enabled['all'] ) > 0 ) echo ' style="display: none"'; ?>><?php _e( 'Sharing is off. Please add services above to enable', 'jetpack' ); ?></h2> - - <ul class="preview"> + <h2<?php if ( count( $enabled['all'] ) > 0 ) echo ' style="display: none"'; ?>><?php _e( 'Sharing is off. Add services above to enable.', 'jetpack' ); ?></h2> + <div class="sharedaddy sd-sharing-enabled"> <?php if ( count( $enabled['all'] ) > 0 ) : ?> - <li class="sharing-label"><?php echo esc_html( $global['sharing_label'] ); ?></li> + <h3 class="sd-title"><?php echo esc_html( $global['sharing_label'] ); ?></h3> <?php endif; ?> - - <?php foreach ( $enabled['visible'] AS $id => $service ) : ?> - <?php $this->output_preview( $service ); ?> - <?php endforeach; ?> - - <?php if ( count( $enabled['hidden'] ) > 0 ) : ?> - <li class="share-custom"> - <a href="#" class="sharing-anchor"><?php _ex( 'Share', 'dropdown button', 'jetpack' ); ?></a> - + <div class="sd-content"> + <ul class="preview"> + <?php foreach ( $enabled['visible'] as $id => $service ) : ?> + <?php $this->output_preview( $service ); ?> + <?php endforeach; ?> + + <?php if ( count( $enabled['hidden'] ) > 0 ) : ?> + <li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li> + <?php endif; ?> + </ul> + + <?php if ( count( $enabled['hidden'] ) > 0 ) : ?> <div class="sharing-hidden"> - <div class="inner" style="display: none;"> + <div class="inner" style="display: none; <?php echo count( $enabled['hidden'] ) == 1 ? 'width:150px;' : ''; ?>"> + <?php if ( count( $enabled['hidden'] ) == 1 ) : ?> + <ul style="background-image:none;"> + <?php else: ?> <ul> - <?php - $count = 1; - - foreach ( $enabled['hidden'] AS $id => $service ) { - $this->output_preview( $service ); - - if ( ( $count % 2 ) == 0 ) - echo '<li class="share-end"></li>'; - - $count++; - } - ?> - <li class="share-end"></li> - </ul> + <?php endif; ?> + + <?php foreach ( $enabled['hidden'] as $id => $service ) { + $this->output_preview( $service ); + }?> + </ul> </div> </div> - </li> - <?php endif; ?> - </ul> + <?php endif; ?> - <ul class="archive" style="display: none"> - <li class="sharing-label"><?php echo esc_html( $global['sharing_label'] ); ?></li> + <ul class="archive" style="display:none;"> + <?php + foreach ( $sharer->get_all_services_blog() as $id => $service ) : + if ( isset( $enabled['visible'][$id] ) ) + $service = $enabled['visible'][$id]; + elseif ( isset( $enabled['hidden'][$id] ) ) + $service = $enabled['hidden'][$id]; - <?php foreach ( $sharer->get_all_services_blog() AS $id => $service ) : ?> - <?php - if ( isset( $enabled['visible'][$id] ) ) - $service = $enabled['visible'][$id]; - elseif ( isset( $enabled['hidden'][$id] ) ) - $service = $enabled['hidden'][$id]; - - $service->button_style = 'icon-text'; // The archive needs the full text, which is removed in JS later - $this->output_preview( $service ); - ?> - <?php endforeach; ?> - - <li class="share-custom"> - <a href="#" class="sharing-anchor"><?php _ex( 'Share', 'dropdown button', 'jetpack' ); ?></a> - - <div class="sharing-hidden"> - <div class="inner" style="display: none;"> - <ul> - <li/> - </ul> - </div> - </div> - </li> - </ul> + $service->button_style = 'icon-text'; // The archive needs the full text, which is removed in JS later + $service->smart = false; + $this->output_preview( $service ); + endforeach; ?> + <li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li> + </ul> + <div class="sharing-clear"></div> + </div> + </div> <br class="clearing" /> </td> </tr> @@ -300,19 +297,20 @@ class Sharing_Admin { <table class="form-table"> <tbody> <tr valign="top"> - <th scope="row"><label><?php _e( 'Default button style', 'jetpack' ); ?></label></th> + <th scope="row"><label><?php _e( 'Button style', 'jetpack' ); ?></label></th> <td> - <select name="button_style"> + <select name="button_style" id="button_style"> <option<?php if ( $global['button_style'] == 'icon-text' ) echo ' selected="selected"';?> value="icon-text"><?php _e( 'Icon + text', 'jetpack' ); ?></option> <option<?php if ( $global['button_style'] == 'icon' ) echo ' selected="selected"';?> value="icon"><?php _e( 'Icon only', 'jetpack' ); ?></option> <option<?php if ( $global['button_style'] == 'text' ) echo ' selected="selected"';?> value="text"><?php _e( 'Text only', 'jetpack' ); ?></option> + <option<?php if ( $global['button_style'] == 'official' ) echo ' selected="selected"';?> value="official"><?php _e( 'Official buttons', 'jetpack' ); ?></option> </select> </td> </tr> <tr valign="top"> <th scope="row"><label><?php _e( 'Sharing label', 'jetpack' ); ?></label></th> <td> - <input type="text" name="sharing_label" value="<?php echo ( FALSE === $global['sharing_label'] ) ? __( 'Share this:', 'jetpack' ) : $global['sharing_label']; ?>" /> + <input type="text" name="sharing_label" value="<?php echo esc_attr( $global['sharing_label'] ); ?>" /> </td> </tr> <tr valign="top"> @@ -325,7 +323,7 @@ class Sharing_Admin { </td> </tr> <tr valign="top"> - <th scope="row"><label><?php _e( 'Show sharing buttons on', 'jetpack' ); ?></label></th> + <th scope="row"><label><?php _e( 'Show buttons on', 'jetpack' ); ?></label></th> <td> <?php $br = false; @@ -360,13 +358,13 @@ class Sharing_Admin { <tr valign="top"> <th scope="row" width="100"><label><?php _e( 'Service name', 'jetpack' ); ?></label></th> <td> - <input type="text" name="sharing_name" size="40" /> + <input type="text" name="sharing_name" id="new_sharing_name" size="40" /> </td> </tr> <tr valign="top"> <th scope="row" width="100"><label><?php _e( 'Sharing URL', 'jetpack' ); ?></label></th> <td> - <input type="text" name="sharing_url" size="40" /> + <input type="text" name="sharing_url" id="new_sharing_url" size="40" /> <p><?php _e( 'You can add the following variables to your service sharing URL:', 'jetpack' ); ?><br/> <code>%post_title%</code>, <code>%post_url%</code>, <code>%post_full_url%</code>, <code>%post_excerpt%</code>, <code>%post_full_url%</code>, <code>%post_tags%</code></p> @@ -375,14 +373,14 @@ class Sharing_Admin { <tr valign="top"> <th scope="row" width="100"><label><?php _e( 'Icon URL', 'jetpack' ); ?></label></th> <td> - <input type="text" name="sharing_icon" size="40" /> + <input type="text" name="sharing_icon" id="new_sharing_icon" size="40" /> <p><?php _e( 'Enter the URL of a 16x16px icon you want to use for this service.', 'jetpack' ); ?></p> </td> </tr> <tr valign="top" width="100"> <th scope="row"></th> <td> - <input type="submit" class="button-secondary" value="<?php _e( 'Create Share', 'jetpack' ); ?>" /> + <input type="submit" class="button-primary" value="<?php _e( 'Create Share Button', 'jetpack' ); ?>" /> <img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" /> </td> </tr> @@ -391,6 +389,8 @@ class Sharing_Admin { </tbody> </table> + <?php do_action( 'post_admin_screen_sharing' ) ?> + <div class="inerror" style="display: none; margin-top: 15px"> <p><?php _e( 'An error occurred creating your new sharing service - please check you gave valid details.', 'jetpack' ); ?></p> </div> @@ -399,10 +399,24 @@ class Sharing_Admin { <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-new_service' );?>" /> </form> </div> + + + <?php endif; ?> + + </div> <script type="text/javascript"> var sharing_loading_icon = '<?php echo esc_js( admin_url( "/images/loading.gif" ) ); ?>'; + <?php if ( isset( $_GET['create_new_service'] ) && 'true' == $_GET['create_new_service'] ) : ?> + jQuery(document).ready(function() { + // Prefill new service box and then open it + jQuery( '#new_sharing_name' ).val( '<?php echo esc_js( $_GET['name'] ); ?>' ); + jQuery( '#new_sharing_url' ).val( '<?php echo esc_js( $_GET['url'] ); ?>' ); + jQuery( '#new_sharing_icon' ).val( '<?php echo esc_js( $_GET['icon'] ); ?>' ); + jQuery( '#add-a-new-service' ).click(); + }); + <?php endif; ?> </script> <?php } diff --git a/plugins/jetpack/modules/shortcodes/audio.php b/plugins/jetpack/modules/shortcodes/audio.php index 55e8b984..7b507a5f 100644 --- a/plugins/jetpack/modules/shortcodes/audio.php +++ b/plugins/jetpack/modules/shortcodes/audio.php @@ -80,7 +80,7 @@ class AudioShortcode { $sound_file = $data[0]; $sound_files = explode( ',', $sound_file ); $sound_files = array_map( 'trim', $sound_files ); - $sound_files = array_map( array( $this, 'unbreak_spacey_url' ), $sound_files ); + $sound_files = array_map( array( $this, 'rawurlencode_spaces' ), $sound_files ); $sound_files = array_map( 'esc_url_raw', $sound_files ); // Ensure each is a valid URL $num_files = count( $sound_files ); $sound_types = array( @@ -104,7 +104,7 @@ class AudioShortcode { // (runtime options overwrite default options) foreach ( $ap_options as $key => $default ) { if ( isset( $options[$key] ) ) { - if ( preg_match( '/^0x[a-f0-9]{6}$/i', $default ) && !preg_match( '/^0x[a-f0-9]{6}$/i', $options[$key] ) ) { + if ( preg_match( '/^(0x)?[a-f0-9]{6}$/i', $default ) && !preg_match( '/^(0x)?[a-f0-9]{6}$/i', $options[$key] ) ) { // Default is a hex color, but input is not $options[$key] = $default; } @@ -121,8 +121,8 @@ class AudioShortcode { $flash_vars = esc_attr( $flash_vars ); // extract some of the options to insert into the markup - if ( isset( $options['bgcolor'] ) && preg_match( '/^0x[a-f0-9]{6}$/i', $options['bgcolor'] ) ) { - $bgcolor = preg_replace( '/^0x/', '#', $options['bgcolor'] ); + if ( isset( $options['bgcolor'] ) && preg_match( '/^(0x)?[a-f0-9]{6}$/i', $options['bgcolor'] ) ) { + $bgcolor = preg_replace( '/^(0x)?/', '#', $options['bgcolor'] ); $bgcolor = esc_attr( $bgcolor ); } else { $bgcolor = '#FFFFFF'; @@ -236,8 +236,14 @@ CONTROLS; 'jetpack_static_url', 'http://en.wordpress.com/wp-content/plugins/audio-player/player.swf' ); - // process regular flash player, inserting HTML5 tags into object as fallback - if ( $all_mp3 ) { + // all the fancy javascript is causing Google Reader to break, just include flash in GReader + // override html5 audio code w/ just not supported code + if ( is_feed() ) { + $html5_audio = $not_supported; + } + + if ( $all_mp3 ) { + // process regular flash player, inserting HTML5 tags into object as fallback $audio_tags = <<<FLASH <object id='wp-as-{$post->ID}_{$ap_playerID}-flash' type='application/x-shockwave-flash' data='$swfurl' width='$width' height='24'> <param name='movie' value='$swfurl' /> @@ -288,9 +294,10 @@ FLASH; SCRIPT; // add the special javascript, if needed - if ( 0 < $num_good ) { + if ( 0 < $num_good && ! is_feed() ) { $audio_tags .= $script; } + return "<span style='text-align:left;display:block;'><p>$audio_tags</p></span>"; } @@ -344,7 +351,7 @@ SCRIPT; * @param string $url * @return string */ - function unbreak_spacey_url( $url ) { + function rawurlencode_spaces( $url ) { return str_replace( ' ', rawurlencode( ' ' ), $url ); } } diff --git a/plugins/jetpack/modules/shortcodes/googlemaps.php b/plugins/jetpack/modules/shortcodes/googlemaps.php index b7ee9c30..8ced50ea 100644 --- a/plugins/jetpack/modules/shortcodes/googlemaps.php +++ b/plugins/jetpack/modules/shortcodes/googlemaps.php @@ -3,7 +3,7 @@ /* * Google maps iframe - transforms code that looks like that: * <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=bg&geocode=&q=%D0%9C%D0%BB%D0%B0%D0%B4%D0%BE%D1%81%D1%82+1,+%D0%A1%D0%BE%D1%84%D0%B8%D1%8F,+%D0%91%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D0%B8%D1%8F&sll=37.0625,-95.677068&sspn=40.545434,79.013672&ie=UTF8&hq=&hnear=%D0%9C%D0%BB%D0%B0%D0%B4%D0%BE%D1%81%D1%82+1&ll=42.654446,23.372061&spn=0.036864,0.077162&t=h&z=14&output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&source=embed&hl=bg&geocode=&q=%D0%9C%D0%BB%D0%B0%D0%B4%D0%BE%D1%81%D1%82+1,+%D0%A1%D0%BE%D1%84%D0%B8%D1%8F,+%D0%91%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D0%B8%D1%8F&sll=37.0625,-95.677068&sspn=40.545434,79.013672&ie=UTF8&hq=&hnear=%D0%9C%D0%BB%D0%B0%D0%B4%D0%BE%D1%81%D1%82+1&ll=42.654446,23.372061&spn=0.036864,0.077162&t=h&z=14" style="color:#0000FF;text-align:left">Вижте по-голяма карта</a></small> - * into the [googlemaps http://...] shortcode format + * into the [googlemaps http://...] shortcode format */ function jetpack_googlemaps_embed_to_short_code( $content ) { if ( false === strpos( $content, 'maps.google.' ) && false === strpos( $content, 'google.com/maps' ) ) @@ -65,7 +65,8 @@ function jetpack_googlemaps_shortcode( $atts ) { $url = ''; foreach ( (array) $arg as $key => $value ) { if ( 'w' == $key ) { - $width = (int) $value; + $percent = ( '%' == substr( $value, -1 ) ) ? '%' : ''; + $width = (int) $value . $percent; } elseif ( 'h' == $key ) { $height = (int) $value; } else { diff --git a/plugins/jetpack/modules/shortcodes/polldaddy.php b/plugins/jetpack/modules/shortcodes/polldaddy.php index 63b2f66d..bcb30f81 100644 --- a/plugins/jetpack/modules/shortcodes/polldaddy.php +++ b/plugins/jetpack/modules/shortcodes/polldaddy.php @@ -1,167 +1,398 @@ <?php -/* - polldaddy.com - [polldaddy poll="139742"] - */ +if ( !class_exists( 'PolldaddyShortcode' ) ) { + /** +* Class wrapper for polldaddy shortcodes +*/ +class PolldaddyShortcode { -if ( !function_exists( 'polldaddy_shortcode_handler' ) ) { + static $add_script = false; + static $scripts = false; - function polldaddy_shortcode_handler_set_data() { - $resource = wp_remote_get( 'http://polldaddy.com/xml/keywords.xml' ); - $body = wp_remote_retrieve_body( $resource ); - $keywords_xml = simplexml_load_string ( $body ); - $keywords = array(); - $keywords['generated'] = time(); - - foreach ( $keywords_xml->keyword as $keyword_xml ){ - $keywords[] = array( 'keyword' => (string) $keyword_xml, 'url' => (string) $keyword_xml['url'] ); - } - wp_cache_set( 'pd-keywords', $keywords, 'site-options', 864000 ); - - return $keywords; + /** + * Add all the actions & resgister the shortcode + */ + function __construct() { + if ( defined( 'GLOBAL_TAGS' ) == false ) + add_shortcode( 'polldaddy', array( $this, 'polldaddy_shortcode' ) ); + add_action( 'wp_enqueue_scripts', array( $this, 'check_infinite' ) ); + add_action( 'infinite_scroll_render', array( $this, 'polldaddy_shortcode_infinite' ), 11 ); } - - function polldaddy_add_rating_js() { - wp_print_scripts( 'polldaddy-rating-js' ); - } - - function polldaddy_shortcode_handler( $atts, $content = null ) { + + /** + * Shortcode for polldadddy + * [polldaddy poll|survey|rating="123456"] + * + * */ + function polldaddy_shortcode( $atts ) { global $post; + global $content_width; - extract( shortcode_atts( array( + extract( shortcode_atts( array( 'survey' => null, - 'link_text' => 'View Survey', + 'link_text' => 'Take Our Survey', 'poll' => 'empty', 'rating' => 'empty', 'unique_id' => null, + 'item_id' => null, 'title' => null, 'permalink' => null, 'cb' => 0, - 'type' => null, + 'type' => 'button', 'body' => '', 'button' => '', - 'text_color' => 'FFFFFF', - 'back_color' => '000000', + 'text_color' => '000000', + 'back_color' => 'FFFFFF', 'align' => '', - 'style' => '' + 'style' => '', + 'width' => $content_width, + 'height' => floor( $content_width * 3 / 4 ), + 'delay' => 100, + 'visit' => 'single', + 'domain' => '', + 'id' => '' ), $atts ) ); + + if ( ! is_array( $atts ) ) { + return '<!-- Polldaddy shortcode passed invalid attributes -->'; + } + + $inline = false; + $no_script = false; + $infinite_scroll = false; + + if ( is_home() && current_theme_supports( 'infinite-scroll' ) ) + $infinite_scroll = true; + + if ( defined( 'PADPRESS_LOADED' ) ) + $inline = true; + + if ( function_exists( 'get_option' ) && get_option( 'polldaddy_load_poll_inline' ) ) + $inline = true; - $survey = esc_attr( str_replace( "'", "", $survey ) ); - $link_text = esc_attr( $link_text ); + if ( is_feed() || ( defined( 'DOING_AJAX' ) && !$infinite_scroll ) ) + $no_script = false; - if ( null != $survey ) { + self::$add_script = $infinite_scroll; + + if ( intval( $rating ) > 0 && !$no_script ) { //rating embed + + if ( empty( $unique_id ) ) + $unique_id = is_page() ? 'wp-page-'.$post->ID : 'wp-post-'.$post->ID; + + if ( empty( $item_id ) ) + $item_id = is_page() ? '_page_'.$post->ID : '_post_'.$post->ID; - // This is the new survey embed - if ( $type != null ) { - $title = preg_replace( '/&(\w*);/', '&$1;', esc_js( esc_attr( $title ) ) ); - $type = preg_replace( '/&(\w*);/', '&$1;', esc_js( esc_attr( $type ) ) ); - $body = preg_replace( '/&(\w*);/', '&$1;', esc_js( esc_attr( $body ) ) ); - $button = preg_replace( '/&(\w*);/', '&$1;', esc_js( esc_attr( $button ) ) ); - $text_color = preg_replace( '/&(\w*);/', '&$1;', esc_js( esc_attr( $text_color ) ) ); - $back_color = preg_replace( '/&(\w*);/', '&$1;', esc_js( esc_attr( $back_color ) ) ); - $align = preg_replace( '/&(\w*);/', '&$1;', esc_js( esc_attr( $align ) ) ); - $style = preg_replace( '/&(\w*);/', '&$1;', esc_js( esc_attr( $style ) ) ); + if ( empty( $title ) ) + $title = apply_filters( 'wp_title', $post->post_title, '', '' ); - return " - <script type='text/javascript' src='http://i0.poll.fm/survey.js' charset='UTF-8'></script> - <noscript><a href='http://polldaddy.com/s/$survey'>$title</a></noscript> - <script type='text/javascript'> - polldaddy.add( { - title: '$title', - type: '$type', - body: '$body', - button: '$button', - text_color: '$text_color', - back_color: '$back_color', - align: '$align', - style: '$style', - id: '$survey' - } ); - </script> - "; + if ( empty( $permalink ) ) + $permalink = get_permalink( $post->ID ); + + $rating = intval( $rating ); + $unique_id = wp_strip_all_tags( $unique_id ); + $item_id = wp_strip_all_tags( $item_id ); + $item_id = preg_replace( '/[^_a-z0-9]/i', '', $item_id ); - } else { - return " - <script language='javascript' type='text/javascript'> - var PDF_surveyID = '$survey'; - var PDF_openText = '$link_text'; - </script> - <script type='text/javascript' language='javascript' src='http://www.polldaddy.com/s.js'></script> - <noscript><a href='http://surveys.polldaddy.com/s/$survey/'>$link_text</a></noscript> - - "; + $settings = json_encode( array( + 'id' => $rating, + 'unique_id' => $unique_id, + 'title' => rawurlencode( trim( $title ) ), + 'permalink' => esc_url( $permalink ), + 'item_id' => $item_id + ) ); + + $item_id = esc_js( $item_id ); + + if ( $inline ) { + return <<<SCRIPT +<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div> +<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!-- +PDRTJS_settings_{$rating}{$item_id}={$settings}; +//--><!]]></script> +<script type="text/javascript" charset="UTF-8" src="http://i.polldaddy.com/ratings/rating.js"></script> +SCRIPT; } - } - - $poll = (int) $poll; - $rating = (int) $rating; - $cb = (int) $cb; + else { + if ( self::$scripts === false ) + self::$scripts = array(); + + $data = array( 'id' => $rating, 'item_id' => $item_id, 'settings' => $settings ); + + self::$scripts['rating'][] = $data; + + add_action( 'wp_footer', array( $this, 'generate_scripts' ) ); + + $data = esc_attr( json_encode( $data ) ); + + if ( $infinite_scroll ) + return <<<CONTAINER +<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}" data-settings="{$data}"></div> +CONTAINER; + else + return <<<CONTAINER +<div class="pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div> +CONTAINER; + } + } + elseif ( intval( $poll ) > 0 ) { //poll embed + + $poll = intval( $poll ); + $poll_url = sprintf( 'http://polldaddy.com/poll/%d', $poll ); + $poll_js = sprintf( '%s.polldaddy.com/p/%d.js', ( is_ssl() ? 'https://secure' : 'http://static' ), $poll ); + $poll_link = sprintf( '<a href="%s">Take Our Poll</a>', $poll_url ); - if ( $rating > 0 ) { - if ( null != $unique_id ) { - $unique_id = wp_specialchars( $unique_id ); - } else { - $unique_id = is_page() ? 'wp-page-' : 'wp-post-'; - $unique_id .= $post->ID; + if ( $no_script ) + return $poll_link; + else { + if ( $type == 'slider' && !$inline ) { + + if( !in_array( $visit, array( 'single', 'multiple' ) ) ) + $visit = 'single'; + + $settings = json_encode( array( + 'type' => 'slider', + 'embed' => 'poll', + 'delay' => intval( $delay ), + 'visit' => $visit, + 'id' => intval( $poll ) + ) ); + + return <<<SCRIPT +<script type="text/javascript" charset="UTF-8" src="http://i0.poll.fm/survey.js"></script> +<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!-- +polldaddy.add( {$settings} ); +//--><!]]></script> +<noscript>{$poll_link}</noscript> +SCRIPT; + } + else { + $cb = ( $cb == 1 ? '?cb='.mktime() : false ); + $margins = ''; + $float = ''; + + if ( in_array( $align, array( 'right', 'left' ) ) ) { + $float = sprintf( 'float: %s;', $align ); + + if ( $align == 'left') + $margins = 'margin: 0px 10px 0px 0px;'; + elseif ( $align == 'right' ) + $margins = 'margin: 0px 0px 0px 10px'; + } + + if ( $cb === false && !$inline ) { + if ( self::$scripts === false ) + self::$scripts = array(); + + $data = array( 'url' => $poll_js ); + + self::$scripts['poll'][] = $data; + + add_action( 'wp_footer', array( $this, 'generate_scripts' ) ); + + $data = esc_attr( json_encode( $data ) ); + + return <<<CONTAINER +<a name="pd_a_{$poll}"></a> +<div class="PDS_Poll" id="PDI_container{$poll}" data-settings="{$data}" style="display:inline-block;{$float}{$margins}"></div> +<div id="PD_superContainer"></div> +<noscript>{$poll_link}</noscript> +CONTAINER; + } + else { + if ( $inline ) + $cb = ''; + + return <<<CONTAINER +<a name="pd_a_{$poll}"></a> +<div class="PDS_Poll" id="PDI_container{$poll}" style="display:inline-block;{$float}{$margins}"></div> +<div id="PD_superContainer"></div> +<script type="text/javascript" charset="UTF-8" src="{$poll_js}{$cb}"></script> +<noscript>{$poll_link}</noscript> +CONTAINER; + } + } } + } + elseif ( !empty( $survey ) ) { //survey embed - if ( null != $title ) - $title = wp_specialchars( $title ); - else - $title = urlencode( $post->post_title ); + if ( in_array( $type, array( 'iframe', 'button', 'banner', 'slider' ) ) ) { + + if ( empty( $title ) ) { + $title = 'Take Our Survey'; + if( !empty( $link_text ) ) + $title = $link_text; + } + + $survey = preg_replace( '/[^a-f0-9]/i', '', $survey ); + $survey_url = esc_url( "http://polldaddy.com/s/{$survey}" ); + $survey_link = sprintf( '<a href="%s">%s</a>', $survey_url, esc_html( $title ) ); + + if ( $no_script || $inline || $infinite_scroll ) + return $survey_link; + + if ( $type == 'iframe' ) { + if ( $height != 'auto' ) { + if ( isset( $content_width ) && is_numeric( $width ) && $width > $content_width ) + $width = $content_width; + + if ( !$width ) + $width = '100%'; + else + $width = (int) $width; + + if ( !$height ) + $height = '600'; + else + $height = (int) $height; + + return <<<CONTAINER +<iframe src="{$survey_url}?iframe=1" frameborder="0" width="{$width}" height="{$height}" scrolling="auto" allowtransparency="true" marginheight="0" marginwidth="0">{$survey_link}</iframe> +CONTAINER; + } + elseif ( !empty( $domain ) && !empty( $id ) ) { + + $auto_src = esc_url( "http://{$domain}.polldaddy.com/s/{$id}" ); + $auto_src = parse_url( $auto_src ); + + if ( !is_array( $auto_src ) || count( $auto_src ) == 0 ) + return '<!-- no polldaddy output -->'; + + if ( !isset( $auto_src['host'] ) || !isset( $auto_src['path'] ) ) + return '<!-- no polldaddy output -->'; + + $domain = $auto_src['host'].'/s/'; + $id = str_ireplace( '/s/', '', $auto_src['path'] ); + + $settings = json_encode( array( + 'type' => $type, + 'auto' => true, + 'domain' => $domain, + 'id' => $id + ) ); + } + } + else { + $text_color = preg_replace( '/[^a-f0-9]/i', '', $text_color ); + $back_color = preg_replace( '/[^a-f0-9]/i', '', $back_color ); + + if ( !in_array( $align, array( 'right', 'left', 'top-left', 'top-right', 'middle-left', 'middle-right', 'bottom-left', 'bottom-right' ) ) ) + $align = ''; + + if ( !in_array( $style, array( 'inline', 'side', 'corner', 'rounded', 'square' ) ) ) + $style = ''; + + $title = wp_strip_all_tags( $title ); + $body = wp_strip_all_tags( $body ); + $button = wp_strip_all_tags( $button ); + + $settings = json_encode( array_filter( array( + 'title' => $title, + 'type' => $type, + 'body' => $body, + 'button' => $button, + 'text_color' => $text_color, + 'back_color' => $back_color, + 'align' => $align, + 'style' => $style, + 'id' => $survey + ) ) ); + } + return <<<CONTAINER +<script type="text/javascript" charset="UTF-8" src="http://i0.poll.fm/survey.js"></script> +<script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!-- +polldaddy.add( {$settings} ); +//--><!]]></script> +<noscript>{$survey_link}</noscript> +CONTAINER; + } + } + else + return '<!-- no polldaddy output -->'; + } - if ( null != $permalink ) - $permalink = clean_url( $permalink ); - else - $permalink = urlencode( get_permalink( $post->ID ) ); + function generate_scripts() { + $script = ''; + + if ( is_array( self::$scripts ) ) { + if ( isset( self::$scripts['rating'] ) ) { + $script = "<script type='text/javascript' charset='UTF-8' id='polldaddyRatings'><!--//--><![CDATA[//><!--\n"; + foreach( self::$scripts['rating'] as $rating ) { + $script .= "PDRTJS_settings_{$rating['id']}{$rating['item_id']}={$rating['settings']}; if ( typeof PDRTJS_RATING !== 'undefined' ){if ( typeof PDRTJS_{$rating['id']}{$rating['item_id']} == 'undefined' ){PDRTJS_{$rating['id']}{$rating['item_id']} = new PDRTJS_RATING( PDRTJS_settings_{$rating['id']}{$rating['item_id']} );}}"; + } + $script .= "\n//--><!]]></script><script type='text/javascript' charset='UTF-8' src='http://i.polldaddy.com/ratings/rating.js'></script>"; - wp_register_script( 'polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js' ); - add_filter( 'wp_footer', 'polldaddy_add_rating_js' ); + } - return '<div id="pd_rating_holder_' . $rating . '"></div> - <script language="javascript"> - PDRTJS_settings_' . $rating . ' = { - "id" : "' . $rating . '", - "unique_id" : "' . $unique_id . '", - "title" : "' . $title . '", - "permalink" : "' . $permalink . '" - }; - </script>'; - } elseif ( $poll > 0 ) { - $cb = ( $cb == 1 ? '?cb=' . mktime() : '' ); - $keywords = wp_cache_get( 'pd-keywords', 'site-options' ); - if ( ! $keywords || $keywords['generated'] <= ( time() - 300 ) ) { - if ( ! wp_cache_get( 'pd-keywords-fetching', 'site-options' ) ) { - wp_cache_set( 'pd-keywords-fetching', 1, 'site-options', 30 ); - $keywords = polldaddy_shortcode_handler_set_data(); + if ( isset( self::$scripts['poll'] ) ) { + foreach( self::$scripts['poll'] as $poll ) { + $script .= "<script type='text/javascript' charset='UTF-8' src='{$poll['url']}'></script>"; } } - - if ( !$keywords ) - $keywords = array(); - - $mod = ( $poll % ( count( $keywords ) - 1 ) ); - - return '<a name="pd_a_' . $poll . '"></a><div class="PDS_Poll" id="PDI_container' . $poll . '" style="display:inline-block;"></div><script type="text/javascript" language="javascript" charset="utf-8" src="http://static.polldaddy.com/p/' . $poll . '.js' . $cb . '"></script> - <noscript> - <a href="http://answers.polldaddy.com/poll/' . $poll . '/">View This Poll</a><br/><span style="font-size:10px;"><a href="' . $keywords[ $mod ][ 'url' ] . '">' . $keywords[ $mod ][ 'keyword' ] . '</a></span> - </noscript>'; } - - return '<!-- no polldaddy output -->'; + + self::$scripts = false; + echo $script; } + + /** + * If the theme uses infinite scroll, include jquery at the start + */ + function check_infinite() { + if ( current_theme_supports( 'infinite-scroll' ) ) { + wp_enqueue_script( 'jquery' ); + } + } + + /** + * Dynamically load the .js, if needed + * + * This hooks in late (priority 11) to infinite_scroll_render to determine + * a posteriori if a shortcode has been called. + */ + function polldaddy_shortcode_infinite() { + // only try to load if a shortcode has been called and theme supports infinite scroll + if( self::$add_script ) { + $script_url = json_encode( esc_url_raw( plugins_url( 'js/polldaddy-shortcode.js', __FILE__ ) ) ); + + // if the script hasn't been loaded, load it + // if the script loads successfully, fire an 'as-script-load' event + echo <<<SCRIPT + <script type='text/javascript'> + //<![CDATA[ + if ( typeof window.polldaddyshortcode === 'undefined' ) { + var wp_pd_js = document.createElement( 'script' ); + wp_pd_js.type = 'text/javascript'; + wp_pd_js.src = $script_url; + wp_pd_js.async = true; + wp_pd_js.onload = function() { + jQuery( document.body ).trigger( 'pd-script-load' ); + }; + document.getElementsByTagName( 'head' )[0].appendChild( wp_pd_js ); + } else { + jQuery( document.body ).trigger( 'pd-script-load' ); + } + //]]> + </script> +SCRIPT; - add_shortcode( 'polldaddy', 'polldaddy_shortcode_handler' ); - - // http://answers.polldaddy.com/poll/1562975/?view=results&msg=voted + } + } +} + +// kick it all off +new PolldaddyShortcode(); + +if ( !function_exists( 'polldaddy_link' ) ) { + // http://polldaddy.com/poll/1562975/?view=results&msg=voted function polldaddy_link( $content ) { - return preg_replace( '!(?:\n|\A)http://answers.polldaddy.com/poll/([0-9]+?)/(.+)?(?:\n|\Z)!i', "\n<script type='text/javascript' language='javascript' charset='utf-8' src='http://s3.polldaddy.com/p/$1.js'></script><noscript> <a href='http://answers.polldaddy.com/poll/$1/'>View Poll</a></noscript>\n", $content ); + return preg_replace( '!(?:\n|\A)http://polldaddy.com/poll/([0-9]+?)/(.+)?(?:\n|\Z)!i', "\n<script type='text/javascript' language='javascript' charset='utf-8' src='http://static.polldaddy.com/p/$1.js'></script><noscript> <a href='http://polldaddy.com/poll/$1/'>View Poll</a></noscript>\n", $content ); } // higher priority because we need it before auto-link and autop get to it add_filter( 'the_content', 'polldaddy_link', 1 ); add_filter( 'the_content_rss', 'polldaddy_link', 1 ); add_filter( 'comment_text', 'polldaddy_link', 1 ); - +} + }
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/youtube.php b/plugins/jetpack/modules/shortcodes/youtube.php index 8417a82e..ebf989f0 100644 --- a/plugins/jetpack/modules/shortcodes/youtube.php +++ b/plugins/jetpack/modules/shortcodes/youtube.php @@ -94,7 +94,7 @@ add_filter('pre_kses', 'youtube_embed_to_short_code'); * @return string The content with embeds instead of URLs */ function youtube_link( $content ) { - return preg_replace_callback( '!(?:\n|\A)http://(?:www\.)?(?:youtube.com/(?:v/|watch[/\#?])|youtu\.be/)[^\s]+?(?:\n|\Z)!i', 'youtube_link_callback', $content ); + return preg_replace_callback( '!(?:\n|\A)http://(?:www\.)?(?:youtube.com/(?:v/|playlist|watch[/\#?])|youtu\.be/)[^\s]+?(?:\n|\Z)!i', 'youtube_link_callback', $content ); } /** @@ -114,7 +114,7 @@ function youtube_link_callback( $matches ) { function youtube_sanitize_url( $url ) { $url = trim( $url, ' "' ); $url = trim( $url ); - $url = str_replace( array( 'youtu.be/', '/v/', '#!v=', '&', '&' ), array( 'youtu.be/?v=', '/?v=', '?v=', '&', '&' ), $url ); + $url = str_replace( array( 'youtu.be/', '/v/', '#!v=', '&', '&', 'playlist' ), array( 'youtu.be/?v=', '/?v=', '?v=', '&', '&', 'videoseries' ), $url ); // Replace any extra question marks with ampersands - the result of a URL like "http://www.youtube.com/v/9FhMMmqzbD8?fs=1&hl=en_US" being passed in. $query_string_start = strpos( $url, "?" ); @@ -128,6 +128,7 @@ function youtube_sanitize_url( $url ) { /* * url can be: + * http://www.youtube.com/embed/videoseries?list=PL94269DA08231042B&hl=en_US * http://www.youtube.com/watch#!v=H2Ncxw1xfck * http://www.youtube.com/watch?v=H2Ncxw1xfck * http://www.youtube.com/watch?v=H2Ncxw1xfck&w=320&h=240&fmt=1&rel=0&showsearch=1&hd=0 @@ -145,10 +146,13 @@ function get_youtube_id( $url ) { parse_str( $url['query'], $qargs ); - if ( ! isset( $qargs['v'] ) ) + if ( ! isset( $qargs['v'] ) && ! isset( $qargs['list'] ) ) return false; - $id = preg_replace( '|[^_a-z0-9-]|i', '', $qargs['v'] ); + $id = preg_replace( '|[^_a-z0-9-]|i', '', $qargs['list'] ); + + if ( empty( $id ) ) + $id = preg_replace( '|[^_a-z0-9-]|i', '', $qargs['v'] ); return $id; } @@ -241,7 +245,12 @@ function youtube_id( $url ) { } } - $html = "<span class='embed-youtube' style='$alignmentcss display: block;'><iframe class='youtube-player' type='text/html' width='$w' height='$h' src='" . esc_url( "http://www.youtube.com/embed/$id?version=3&rel=$rel&fs=1$fmt&showsearch=$search&showinfo=$info&iv_load_policy=$iv$start$hd&wmode=$wmode" ) . "' frameborder='0'></iframe></span>"; + if ( ( isset( $url['path'] ) && '/videoseries' == $url['path'] ) || isset( $qargs['list'] ) ) { + $html = "<span class='embed-youtube' style='$alignmentcss display: block;'><iframe class='youtube-player' type='text/html' width='$w' height='$h' src='" . esc_url( "http://www.youtube.com/embed/videoseries?list=$id&hl=en_US" ) . "' frameborder='0'></iframe></span>"; + } else { + $html = "<span class='embed-youtube' style='$alignmentcss display: block;'><iframe class='youtube-player' type='text/html' width='$w' height='$h' src='" . esc_url( "http://www.youtube.com/embed/$id?version=3&rel=$rel&fs=1$fmt&showsearch=$search&showinfo=$info&iv_load_policy=$iv$start$hd&wmode=$wmode" ) . "' frameborder='0'></iframe></span>"; + } + $html = apply_filters( 'video_embed_html', $html ); return $html; @@ -262,7 +271,7 @@ function wpcom_youtube_embed_crazy_url( $matches, $attr, $url ) { } function wpcom_youtube_embed_crazy_url_init() { - wp_embed_register_handler( 'wpcom_youtube_embed_crazy_url', '#http://(?:www\.)?(?:youtube.com/(?:v/|watch[/\#?])|youtu\.be/).*#i', 'wpcom_youtube_embed_crazy_url' ); + wp_embed_register_handler( 'wpcom_youtube_embed_crazy_url', '#http://(?:www\.)?(?:youtube.com/(?:v/|playlist|watch[/\#?])|youtu\.be/).*#i', 'wpcom_youtube_embed_crazy_url' ); } add_action( 'init', 'wpcom_youtube_embed_crazy_url_init' ); diff --git a/plugins/jetpack/modules/stats.php b/plugins/jetpack/modules/stats.php index 32e01189..32c6cf2c 100644 --- a/plugins/jetpack/modules/stats.php +++ b/plugins/jetpack/modules/stats.php @@ -64,7 +64,7 @@ function stats_ignore_db_version( $version ) { if ( is_admin() && isset( $_GET['page'] ) && $_GET['page'] == 'stats' && - isset( $_GET['chart'] ) && $_GET['chart'] == 'admin-bar-hours' + isset( $_GET['chart'] ) && strpos($_GET['chart'], 'admin-bar-hours') === 0 ) { global $wp_db_version; return $wp_db_version; @@ -328,8 +328,13 @@ function stats_reports_page() { // Loading message // No JS fallback message ?> +<style type="text/css"> +@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) { + img.wpcom-loading-64 { width: 32px; height: 32px; } +} +</style> <div id="stats-loading-wrap" class="wrap"> -<p class="hide-if-no-js"><img alt="<?php esc_attr_e( 'Loading…', 'jetpack' ); ?>" src="<?php echo esc_url( "$http://" . STATS_DASHBOARD_SERVER . "/i/loading/$color-64.gif" ); ?>" /></p> +<p class="hide-if-no-js"><img class="wpcom-loading-64" alt="<?php esc_attr_e( 'Loading…', 'jetpack' ); ?>" src="<?php echo esc_url( "$http://" . STATS_DASHBOARD_SERVER . "/i/loading/$color-64.gif" ); ?>" /></p> <p class="hide-if-js"><?php esc_html_e( 'Your Site Stats work better with Javascript enabled.', 'jetpack' ); ?><br /> <a href="<?php echo esc_url( $nojs_url ); ?>"><?php esc_html_e( 'View Site Stats without Javascript', 'jetpack' ); ?></a>.</p> </div> @@ -551,9 +556,29 @@ function stats_admin_bar_head() { ?> <style type='text/css'> -#wpadminbar .quicklinks li#wp-admin-bar-stats {height:28px} -#wpadminbar .quicklinks li#wp-admin-bar-stats a {height:28px;padding:0} -#wpadminbar .quicklinks li#wp-admin-bar-stats a img {padding:4px 11px} +#wpadminbar .quicklinks li#wp-admin-bar-stats { + height: 28px; +} +#wpadminbar .quicklinks li#wp-admin-bar-stats a { + height: 28px; + padding: 0; +} +#wpadminbar .quicklinks li#wp-admin-bar-stats a div { + height: 28px; + width: 95px; + overflow: hidden; + margin: 0 10px; +} +#wpadminbar .quicklinks li#wp-admin-bar-stats a:hover div { + width: auto; + margin: 0 8px 0 10px; +} +#wpadminbar .quicklinks li#wp-admin-bar-stats a img { + height: 24px; + padding: 2px 0; + max-width: none; + border: none; +} </style> <?php } @@ -563,11 +588,12 @@ function stats_admin_bar_menu( &$wp_admin_bar ) { $url = add_query_arg( 'page', 'stats', admin_url( 'admin.php' ) ); // no menu_page_url() blog-side. - $img_src = add_query_arg( array( 'noheader'=>'', 'proxy'=>'', 'chart'=>'admin-bar-hours', 'height'=>20, 'hours'=>48 ), $url ); + $img_src = esc_attr( add_query_arg( array( 'noheader'=>'', 'proxy'=>'', 'chart'=>'admin-bar-hours-scale' ), $url ) ); + $img_src_2x = esc_attr( add_query_arg( array( 'noheader'=>'', 'proxy'=>'', 'chart'=>'admin-bar-hours-scale-2x' ), $url ) ); $title = __( 'Views over 48 hours. Click for more Site Stats.', 'jetpack' ); - $menu = array( 'id' => 'stats', 'title' => "<img style='width:95px;height:20px' src='$img_src' alt='$title' title='$title' />", 'href' => $url ); + $menu = array( 'id' => 'stats', 'title' => "<div><script type='text/javascript'>var src;if(typeof(window.devicePixelRatio)=='undefined'||window.devicePixelRatio<2){src='$img_src';}else{src='$img_src_2x';}document.write('<img src=\''+src+'\' alt=\'$alt\' title=\'$title\' />');</script></div>", 'href' => $url ); $wp_admin_bar->add_menu( $menu ); } diff --git a/plugins/jetpack/modules/vaultpress.php b/plugins/jetpack/modules/vaultpress.php index 7df1913a..a9b809c2 100644 --- a/plugins/jetpack/modules/vaultpress.php +++ b/plugins/jetpack/modules/vaultpress.php @@ -3,7 +3,7 @@ * Module Name: VaultPress * Module Description: Realtime backup and security scanning for your WordPress site. * First Introduced: 0:1.2 - * Sort Order: 5 + * Sort Order: 7 * Deactivate: false * Free: false */ diff --git a/plugins/jetpack/modules/widgets.php b/plugins/jetpack/modules/widgets.php index 43793864..3d9c2f8b 100644 --- a/plugins/jetpack/modules/widgets.php +++ b/plugins/jetpack/modules/widgets.php @@ -2,7 +2,7 @@ /** * Module Name: Extra Sidebar Widgets * Module Description: Easily add images, Twitter updates, and your site's RSS links to your theme's sidebar. - * Sort Order: 9 + * Sort Order: 13 * First Introduced: 1.2 */ @@ -23,11 +23,12 @@ function jetpack_widgets_configuration_load() { wp_safe_redirect( admin_url( 'widgets.php' ) ); exit; } - -jetpack_load_widgets(); - -add_action( 'widgets_init', 'facebook_likebox_widget_init' ); -function facebook_likebox_widget_init() { +function jetpack_register_widgets() { register_widget( 'WPCOM_Widget_Facebook_LikeBox' ); + register_widget( 'Jetpack_Gravatar_Profile_Widget' ); } + +jetpack_load_widgets(); + +add_action( 'widgets_init', 'jetpack_register_widgets' ); diff --git a/plugins/jetpack/modules/widgets/facebook-likebox.php b/plugins/jetpack/modules/widgets/facebook-likebox.php index ebf6e9b5..64d03f8a 100644 --- a/plugins/jetpack/modules/widgets/facebook-likebox.php +++ b/plugins/jetpack/modules/widgets/facebook-likebox.php @@ -10,7 +10,9 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { private $default_height = 432; private $default_width = 200; private $max_width = 400; - private $min_width = 100; + private $min_width = 0; + private $max_height = 999; + private $min_height = 100; private $default_colorscheme = 'light'; private $allowed_colorschemes = array( 'light', 'dark' ); @@ -24,7 +26,12 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { $like_args = $this->normalize_facebook_args( $instance['like_args'] ); - if( empty( $like_args['href'] ) || ! $this->is_valid_facebook_url( $like_args['href'] ) ) { + if ( empty( $like_args['href'] ) || ! $this->is_valid_facebook_url( $like_args['href'] ) ) { + if ( current_user_can('edit_theme_options') ) { + echo $before_widget; + echo '<p>' . sprintf( __( 'It looks like your Facebook URL is incorrectly configured. Please check it in your <a href="%s">widget settings</a>.' ), admin_url( 'widgets.php' ) ) . '</p>'; + echo $after_widget; + } echo '<!-- Invalid Facebook Page URL -->'; return; } @@ -32,24 +39,15 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { $title = apply_filters( 'widget_title', $instance['title'] ); $page_url = ( is_ssl() ) ? str_replace( 'http://', 'https://', $like_args['href'] ) : $like_args['href']; - - // Calculate the height based on the features enabled - if( $like_args['show_faces'] && $like_args['stream'] ) { - $like_args['height'] = 580; - } else if( ! $like_args['show_faces'] && ! $like_args['stream'] ) { - $like_args['height'] = 110; - } else { - $like_args['height'] = 432; - } - + $like_args['show_faces'] = (bool) $like_args['show_faces'] ? 'true' : 'false'; $like_args['stream'] = (bool) $like_args['stream'] ? 'true' : 'false'; - $like_args['force_wall'] = (bool) $like_args['force_wall'] ? 'true' : 'false'; + $like_args['force_wall'] = (bool) $like_args['force_wall'] ? 'true' : 'false'; $like_args['header'] = (bool) $like_args['header'] ? 'true' : 'false'; $like_bg_colour = ( 'dark' == $like_args['colorscheme'] ) ? '#000' : '#fff'; $locale = $this->get_locale(); - if( $locale && 'en_US' != $locale ) + if ( $locale && 'en_US' != $locale ) $like_args['locale'] = $locale; $like_args = urlencode_deep( $like_args ); @@ -57,13 +55,13 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { echo $before_widget; - if( ! empty( $title ) ) : + if ( ! empty( $title ) ) : echo $before_title; - ?><a href="<?php echo esc_url( $page_url ); ?>"><?php esc_html_e( $title , 'jetpack' ); ?></a><?php + ?><a href="<?php echo esc_url( $page_url ); ?>"><?php echo esc_html( $title ); ?></a><?php echo $after_title; endif; - ?><iframe src="<?php echo esc_url( $like_url ); ?>" scrolling="no" frameborder="0" style="border: none; overflow: hidden; width: <?php esc_html_e( $like_args['width'] , 'jetpack' ); ?>px; height: <?php esc_html_e( $like_args['height'] , 'jetpack' ); ?>px; background: <?php esc_html_e( $like_bg_colour , 'jetpack' ); ?>"></iframe><?php + ?><iframe src="<?php echo esc_url( $like_url ); ?>" scrolling="no" frameborder="0" style="border: none; overflow: hidden;<?php echo 0 != $like_args['width'] ? ' width: ' . (int) $like_args['width'] . 'px; ' : ''; ?> height: <?php echo (int) $like_args['height']; ?>px; background: <?php echo esc_attr( $like_bg_colour ); ?>"></iframe><?php echo $after_widget; @@ -122,7 +120,14 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { <p> <label for="<?php echo $this->get_field_id( 'width' ); ?>"> <?php _e( 'Width', 'jetpack' ); ?> - <input type="text" maxlength="3" name="<?php echo $this->get_field_name( 'width' ); ?>" id="<?php echo $this->get_field_id( 'width' ); ?>" value="<?php echo esc_attr( $like_args['width'] ); ?>" style="width: 30px; text-align: center;" /> + <input type="text" maxlength="3" name="<?php echo $this->get_field_name( 'width' ); ?>" id="<?php echo $this->get_field_id( 'width' ); ?>" value="<?php echo esc_attr( $like_args['width'] ); ?>" style="width: 30px; text-align: center;" />px + </label> + </p> + + <p> + <label for="<?php echo $this->get_field_id( 'height' ); ?>"> + <?php _e( 'Height', 'jetpack' ); ?> + <input type="text" maxlength="3" name="<?php echo $this->get_field_name( 'height' ); ?>" id="<?php echo $this->get_field_id( 'height' ); ?>" value="<?php echo esc_attr( $like_args['height'] ); ?>" style="width: 30px; text-align: center;" />px </label> </p> @@ -194,10 +199,24 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { } $args['width'] = $this->normalize_int_value( (int) $args['width'], $this->default_width, $this->max_width, $this->min_width ); + $args['height'] = $this->normalize_int_value( (int) $args['height'], $this->default_height, $this->max_height, $this->min_height ); $args['colorscheme'] = $this->normalize_text_value( $args['colorscheme'], $this->default_colorscheme, $this->allowed_colorschemes ); $args['show_faces'] = (bool) $args['show_faces']; $args['stream'] = (bool) $args['stream']; $args['force_wall'] = (bool) $args['force_wall']; + + // The height used to be dependent on other widget settings + // If the user changes those settings but doesn't customize the height, + // let's intelligently assign a new height. + if ( in_array( $args['height'], array( 580, 110, 432 ) ) ) { + if( $args['show_faces'] && $args['stream'] ) { + $args['height'] = 580; + } else if( ! $args['show_faces'] && ! $args['stream'] ) { + $args['height'] = 110; + } else { + $args['height'] = 432; + } + } return $args; } @@ -209,7 +228,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { function normalize_int_value( $value, $default = 0, $max = 0, $min = 0 ) { $value = (int) $value; - if( ! $value || $max < $value || $min > $value ) + if ( $max < $value || $min > $value ) $value = $default; return (int) $value; @@ -218,7 +237,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { function normalize_text_value( $value, $default = '', $allowed = array() ) { $allowed = (array) $allowed; - if( empty( $value ) || ( ! empty( $allowed ) && ! in_array( $value, $allowed ) ) ) + if ( empty( $value ) || ( ! empty( $allowed ) && ! in_array( $value, $allowed ) ) ) $value = $default; return $value; diff --git a/plugins/jetpack/modules/widgets/gravatar-profile.css b/plugins/jetpack/modules/widgets/gravatar-profile.css new file mode 100644 index 00000000..230a3b16 --- /dev/null +++ b/plugins/jetpack/modules/widgets/gravatar-profile.css @@ -0,0 +1,36 @@ +.widget-grofile { +} + .widget-grofile h4 { + margin: 1em 0 1.2em; + /*font-size: 1.2em;*/ + } + .widget-grofile ul.grofile-urls { + margin-left: 0; + overflow: hidden; + } + .widget-grofile ul.grofile-accounts li { + list-style: none; + display: inline; + } + + .widget-grofile ul.grofile-accounts li::before { + content: "" !important; /* Kubrick :( */ + } + .widget-grofile .grofile-accounts-logo { + background-image: url('http://0.gravatar.com/images/grav-share-sprite.png'); + background-repeat: no-repeat; + /*background-position: -16px -16px;*/ + width: 16px; /* So we don't show the topmost logo */ + height: 16px; /* So we don't show the topmost logo */ + float: left; + margin-right: 8px; + margin-bottom: 8px; + } + .rtl .widget-grofile .grofile-accounts-logo { + margin-left: 8px; + margin-right: 0; + } + + .grofile-thumbnail { + width: 100%; + } diff --git a/plugins/jetpack/modules/widgets/gravatar-profile.php b/plugins/jetpack/modules/widgets/gravatar-profile.php new file mode 100644 index 00000000..c33e6996 --- /dev/null +++ b/plugins/jetpack/modules/widgets/gravatar-profile.php @@ -0,0 +1,284 @@ +<?php +/** + * Display a widgetized version of your Gravatar Profile + * http://blog.gravatar.com/2010/03/26/gravatar-profiles/ + */ +class Jetpack_Gravatar_Profile_Widget extends WP_Widget { + + function __construct() { + parent::__construct( 'grofile', __( 'Gravatar Profile', 'jetpack' ), array( + 'classname' => 'widget-grofile grofile', + 'description' => __( 'Display a mini version of your Gravatar Profile', 'jetpack' ) + ) ); + + if ( is_admin() ) { + add_action( 'admin_footer-widgets.php', array( $this, 'admin_script' ) ); + } + } + + function widget( $args, $instance ) { + $title = apply_filters( 'widget_title', $instance['title'] ); + + if ( !$instance['email'] ) { + if ( current_user_can( 'edit_theme_options' ) ) { + echo $args['before_widget']; + if ( ! empty( $title ) ) + echo $args['before_title'] . $title . $args['after_title']; + echo '<p>' . sprintf( __( 'You need to select what to show in this <a href="%s">Gravatar Profile widget</a>.' ), admin_url( 'widgets.php' ) ) . '</p>'; + echo $args['after_widget']; + } + return; + } + + echo $args['before_widget']; + if ( ! empty( $title ) ) + echo $args['before_title'] . $title . $args['after_title']; + + $profile = $this->get_profile( $instance['email'] ); + + if( ! empty( $profile ) ) { + $gravatar_url = add_query_arg( 's', 500, $profile['thumbnailUrl'] ); // the default grav returned by grofiles is super small + + wp_enqueue_style( + 'gravatar-profile-widget', + plugins_url( 'gravatar-profile.css', __FILE__ ), + array(), + '20120711' + ); + + ?> + <img src="<?php echo esc_url( $gravatar_url ); ?>" class="grofile-thumbnail no-grav" /> + <div class="grofile-meta"> + <h4><a href="<?php echo esc_url( $profile['profileUrl'] ); ?>"><?php echo esc_html( $profile['displayName'] ); ?></a></h4> + <p><?php echo esc_html( wp_kses( $profile['aboutMe'], array() ) ); ?></p> + </div> + + <?php + + if( $instance['show_personal_links'] ) + $this->display_personal_links( (array) $profile['urls'] ); + + if( $instance['show_account_links'] ) + $this->display_accounts( (array) $profile['accounts'] ); + + ?> + + <h4><a href="<?php echo esc_url( $profile['profileUrl'] ); ?>" class="grofile-full-link"><?php esc_html_e( 'View Full Profile →' ); ?></a></h4> + + <?php + + do_action( 'jetpack_stats_extra', 'widgets', 'grofile' ); + + } else { + if ( current_user_can( 'edit_theme_options' ) ) { + echo '<p>' . esc_html__( 'Error loading profile', 'jetpack' ) . '</p>'; + } + } + + echo $args['after_widget']; + } + + function display_personal_links( $personal_links = array() ) { + if ( empty( $personal_links ) ) + return; + ?> + + <h4><?php esc_html_e( 'Personal Links', 'jetpack' ); ?></h4> + <ul class="grofile-urls grofile-links"> + + <?php foreach( $personal_links as $personal_link ) : ?> + <li> + <a href="<?php echo esc_url( $personal_link['value'] ); ?>"> + <?php echo esc_html( $personal_link['title'] ); ?> + </a> + </li> + <?php endforeach; ?> + </ul> + + <?php + } + + function display_accounts( $accounts = array() ) { + if ( empty( $accounts ) ) + return; + ?> + + <h4><?php esc_html_e( 'Verified Services', 'jetpack' ); ?></h4> + <ul class="grofile-urls grofile-accounts"> + + <?php foreach( $accounts as $account ) : + if( $account['verified'] != 'true' ) + continue; + + $sanitized_service_name = $this->get_sanitized_service_name( $account['shortname'] ); + ?> + + <li> + <a href="<?php echo esc_url( $account['url'] ); ?>" title="<?php echo sprintf( _x( '%1$s on %2$s', '1: User Name, 2: Service Name (Facebook, Twitter, ...)', 'jetpack' ), esc_html( $account['display'] ), esc_html( $sanitized_service_name ) ); ?>"> + <span class="grofile-accounts-logo grofile-accounts-<?php echo esc_attr( $account['shortname'] ); ?> accounts_<?php echo esc_attr( $account['shortname'] ); ?>"></span> + </a> + </li> + + <?php endforeach; ?> + </ul> + + <?php + } + + function form( $instance ) { + + $title = isset( $instance['title'] ) ? $instance['title'] : ''; + $email = isset( $instance['email'] ) ? $instance['email'] : ''; + $email_user = isset( $instance['email_user'] ) ? $instance['email_user'] : get_current_user_id(); + $show_personal_links = isset( $instance['show_personal_links'] ) ? (bool) $instance['show_personal_links'] : ''; + $show_account_links = isset( $instance['show_account_links'] ) ? (bool) $instance['show_account_links'] : ''; + + ?> + <p> + <label for="<?php echo $this->get_field_id( 'title' ); ?>"> + <?php esc_html_e( 'Title', 'jetpack' ); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> + </label> + </p> + + <p> + <label for="<?php echo $this->get_field_id( 'email_user' ); ?>"> + <?php esc_html_e( 'Select a user or pick "custom" and enter a custom email address.', 'jetpack' ); ?> + <br /> + + <?php wp_dropdown_users( array( + 'show_option_none' => __( 'Custom', 'jetpack' ), + 'selected' => $email_user, + 'name' => $this->get_field_name( 'email_user' ), + 'id' => $this->get_field_id( 'email_user' ), + 'class' => 'gravatar-profile-user-select', + ) );?> + </label> + </p> + + <p class="gprofile-email-container <?php echo empty( $email_user ) || $email_user == -1 ? '' : 'hidden'; ?>"> + <label for="<?php echo $this->get_field_id( 'email' ); ?>"><?php esc_html_e( 'Custom Email Address', 'jetpack' ); ?> + <input class="widefat" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name( 'email' ); ?>" type="text" value="<?php echo esc_attr( $email ); ?>" /> + </label> + </p> + + <p> + <label for="<?php echo $this->get_field_id( 'show_personal_links' ); ?>"> + <input type="checkbox" name="<?php echo $this->get_field_name( 'show_personal_links' ); ?>" id="<?php echo $this->get_field_id( 'show_personal_links' ); ?>" <?php checked( $show_personal_links ); ?> /> + <?php esc_html_e( 'Show Personal Links', 'jetpack' ); ?> + <br /> + <small><?php esc_html_e( 'Links to your websites, blogs, or any other sites that help describe who you are.', 'jetpack' ); ?></small> + </label> + </p> + + <p> + <label for="<?php echo $this->get_field_id( 'show_account_links' ); ?>"> + <input type="checkbox" name="<?php echo $this->get_field_name( 'show_account_links' ); ?>" id="<?php echo $this->get_field_id( 'show_account_links' ); ?>" <?php checked( $show_account_links ); ?> /> + <?php esc_html_e( 'Show Account Links', 'jetpack' ); ?> + <br /> + <small><?php esc_html_e( 'Links to services that you use across the web.', 'jetpack' ); ?></small> + </label> + </p> + + <p><a href="<?php echo admin_url( 'profile.php' ); ?>" target="_blank" title="<?php esc_attr_e( 'Opens in new window', 'jetpack' ); ?>"><?php esc_html_e( 'Edit Your Profile', 'jetpack' )?></a> | <a href="http://gravatar.com" target="_blank" title="<?php esc_attr_e( 'Opens in new window', 'jetpack' ); ?>"><?php esc_html_e( "What's a Gravatar?", 'jetpack' ); ?></a></p> + + <?php + } + + function admin_script() { + ?> + <script> + jQuery( function( $ ) { + $( '.wrap' ).on( 'change', '.gravatar-profile-user-select', function() { + var $input = $(this).closest('.widget-inside').find('.gprofile-email-container'); + if ( '-1' === this.value.toLowerCase() ) { + $input.show(); + } else { + $input.hide(); + } + }); + } ); + </script> + <?php + } + + function update( $new_instance, $old_instance ) { + + $instance = array(); + + $instance['title'] = isset( $new_instance['title'] ) ? wp_kses( $new_instance['title'], array() ) : ''; + $instance['email'] = isset( $new_instance['email'] ) ? wp_kses( $new_instance['email'], array() ) : ''; + $instance['email_user'] = isset( $new_instance['email_user'] ) ? intval( $new_instance['email_user'] ) : -1; + $instance['show_personal_links'] = isset( $new_instance['show_personal_links'] ) ? (bool) $new_instance['show_personal_links'] : false; + $instance['show_account_links'] = isset( $new_instance['show_account_links'] ) ? (bool) $new_instance['show_account_links'] : false; + + if ( $instance['email_user'] > 0 ) { + $user = get_userdata( $instance['email_user'] ); + $instance['email'] = $user->user_email; + } + + return $instance; + } + + private function get_profile( $email ) { + $hashed_email = md5( strtolower( trim( $email ) ) ); + $cache_key = 'widget-grofile-' . $hashed_email; + + if( ! $profile = get_transient( $cache_key, 'widget' ) ) { + + $profile_url = esc_url_raw( sprintf( '%s.gravatar.com/%s.php', ( is_ssl() ? 'https://secure' : 'http://www' ), $hashed_email ), array( 'http', 'https' ) ); + + $expire = 300; + $response = wp_remote_get( $profile_url, array( 'User-Agent' => 'WordPress.com Gravatar Profile Widget' ) ); + $response_code = wp_remote_retrieve_response_code( $response ); + if ( 200 == $response_code ) { + $profile = wp_remote_retrieve_body( $response ); + $profile = unserialize( $profile ); + + if ( is_array( $profile ) && ! empty( $profile['entry'] ) && is_array( $profile['entry'] ) ) { + $expire = 900; // cache for 15 minutes + $profile = $profile['entry'][0]; + } else { + $profile = array(); + } + + } else { + $expire = + $profile = array(); + set_transient( $cache_key . '-response-code', $response_code, $expire ); + } + + set_transient( $cache_key, $profile, $expire ); + } + return $profile; + } + + private function get_sanitized_service_name( $shortname ) { + // Some services have stylized or mixed cap names *cough* WP *cough* + switch( $shortname ) { + case 'friendfeed': + return 'FriendFeed'; + case 'linkedin': + return 'LinkedIn'; + case 'yahoo': + return 'Yahoo!'; + case 'youtube': + return 'YouTube'; + case 'wordpress': + return 'WordPress'; + case 'tripit': + return 'TripIt'; + case 'myspace': + return 'MySpace'; + case 'foursquare': + return 'foursquare'; + case 'google': + return 'Google+'; + default: + // Others don't + $shortname = ucwords( $shortname ); + } + return $shortname; + } +} + +// END |