Initial Commit

This commit is contained in:
Rumperuu 2018-03-21 18:19:20 +00:00
parent 4c352bf02e
commit 1ab6e5f0b0
1085 changed files with 195258 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

@ -0,0 +1,199 @@
div#publicize-services-block {
display: block;
clear: both;
margin-bottom: 25px;
background-color: #fff;
padding: 25px 20px 5px 25px;
overflow: hidden;
max-width: 1200px;
}
/* Add the logos for the Publicize services */
span.pub-logos {
float: right;
display: block;
width: 130px;
height: 75px;
margin-top: -18px;
margin-right: 5px;
vertical-align: top;
}
.left, .right{
width: 50%;
float: right;
}
div#facebook { background: url( publicize-fb-2x.png ) no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
div#twitter { background: url( publicize-twitter-2x.png ) no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
div#linkedin { background: url( publicize-linkedin-2x.png )no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
div#tumblr { background: url( publicize-tumblr-2x.png ) no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
div#path { background: url( publicize-path-2x.png ) no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
div#google_plus { background: url( publicize-google-2x.png ) no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
a.publicize-profile-link, a.publicize-profile-link:visited {
text-decoration: none;
font-weight: bold;
}
a.publicize-profile-link:hover {
color: #f1831e;
}
a.publicize-add-connection, a.publicize-add-connection:visited {
text-decoration: none;
}
a.publicize-add-connection:hover {
color: #f1831e;
}
div.publicize-service-entry {
clear: both;
margin-bottom: 10px;
padding: 10px 0 25px 0;
border-bottom: 1px #eee solid;
margin-left: 40px;
overflow: hidden;
}
div.publicize-service-entry:last-of-type{
border-width: 0px;
}
div.publicize-service-left {
display: inline-block;
width: 150px;
vertical-align: top;
min-height: 35px;
}
div.publicize-service-left a{
font-size: 24px;
text-decoration: none;
}
div.publicize-service-left a:hover{
text-decoration: underline;
}
div.publicize-service-right {
display: inline-block;
text-align: left;
float: left;
padding-top:5px;
}
div.publicize-service-right ul {
margin-top: 0;
}
div.publicize-service-right li {
list-style-type: none;
font-size: 14px;
}
.pub-disconnect-button {
-webkit-border-image: none;
border-bottom-color: #CCC;
border-bottom-style: none;
border-bottom-width: 0px;
border-right-color: #CCC;
border-right-style: none;
border-right-width: 0px;
border-left-color: #CCC;
border-left-style: none;
border-left-width: 0px;
border-top-color: #CCC;
border-top-style: none;
border-top-width: 0px;
color: #CCC;
cursor: auto;
display: inline;
font-family: sans-serif;
font-size: 20px;
font-style: normal;
font-weight: normal;
height: auto;
line-height: 22px;
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin-bottom: 0px;
margin-right: 0px;
margin-left: 0px;
margin-top: 0px;
outline-color: #CCC;
outline-style: none;
outline-width: 0px;
overflow-y: visible;
padding-bottom: 0px;
padding-right: 0px;
padding-left: 0px;
padding-top: 0px;
position: static;
left: auto;
text-align: right;
text-decoration: none;
top: auto;
vertical-align: baseline;
width: auto;
z-index: auto;
}
.pub-disconnect-button:hover {
color: #f1831e;
}
table#option-profile {
padding-bottom: 8px;
}
table#option-profile td {
font-family: "Lucida Grande",Verdana,Arial,sans-serif;
vertical-align: middle;
}
table#option-profile td.radio {
padding-left: 20px;
}
table#option-profile td.thumbnail {
padding-left: 20px;
}
table#option-profile td.details {
font-weight: bold; color: #333333
}
table#option-fb-fanpage td, table#option-fanpage td {
font-family: "Lucida Grande",Verdana,Arial,sans-serif;
vertical-align: middle;
}
table#option-fb-fanpage td.thumbnail, table#option-fanpage td.thumbnail {
padding: 5px 20px 5px 20px;
}
table#option-fb-fanpage td.details, table#option-fanpage td.details {
width: 130px;
padding-left: 10px;
}
table#option-fb-fanpage td.details span.name, table#option-fanpage td.details span.name {
font-weight: bold; color: #333333;
}
table#option-fb-fanpage td.details span.category, table#option-fanpage td.details span.category {
font-size: 10px; color: #888888;
}
input.fb-options {
font-family: "Lucida Grande",Verdana,Arial,sans-serif;
font-size: 12px;
}
.pub-connection-error {
color: #ff0000;
}

View file

@ -0,0 +1 @@
div#publicize-services-block{display:block;clear:both;margin-bottom:25px;background-color:#fff;padding:25px 20px 5px 25px;overflow:hidden;max-width:1200px}span.pub-logos{float:right;display:block;width:130px;height:75px;margin-top:-18px;margin-right:5px;vertical-align:top}.left,.right{width:50%;float:right}div#facebook{background:url(publicize-fb-2x.png) 0 0/32px 32px no-repeat;padding-right:42px;padding-top:5px}div#twitter{background:url(publicize-twitter-2x.png) 0 0/32px 32px no-repeat;padding-right:42px;padding-top:5px}div#linkedin{background:url(publicize-linkedin-2x.png)no-repeat 0 0/32px 32px;padding-right:42px;padding-top:5px}div#tumblr{background:url(publicize-tumblr-2x.png) 0 0/32px 32px no-repeat;padding-right:42px;padding-top:5px}div#path{background:url(publicize-path-2x.png) 0 0/32px 32px no-repeat;padding-right:42px;padding-top:5px}div#google_plus{background:url(publicize-google-2x.png) 0 0/32px 32px no-repeat;padding-right:42px;padding-top:5px}a.publicize-profile-link,a.publicize-profile-link:visited{text-decoration:none;font-weight:700}a.publicize-profile-link:hover{color:#f1831e}a.publicize-add-connection,a.publicize-add-connection:visited{text-decoration:none}a.publicize-add-connection:hover{color:#f1831e}div.publicize-service-entry{clear:both;margin-bottom:10px;padding:10px 0 25px;border-bottom:1px #eee solid;margin-left:40px;overflow:hidden}div.publicize-service-entry:last-of-type{border-width:0}div.publicize-service-left{display:inline-block;width:150px;vertical-align:top;min-height:35px}div.publicize-service-left a{font-size:24px;text-decoration:none}div.publicize-service-left a:hover{text-decoration:underline}div.publicize-service-right{display:inline-block;text-align:left;float:left;padding-top:5px}div.publicize-service-right ul{margin-top:0}div.publicize-service-right li{list-style-type:none;font-size:14px}.pub-disconnect-button{-webkit-border-image:none;border-color:#CCC;border-style:none;border-width:0;color:#CCC;cursor:auto;display:inline;font-family:sans-serif;font-size:20px;font-style:normal;font-weight:400;height:auto;line-height:22px;list-style:none;margin:0;outline:#CCC 0;overflow-y:visible;padding:0;position:static;left:auto;text-align:right;text-decoration:none;top:auto;vertical-align:baseline;width:auto;z-index:auto}.pub-disconnect-button:hover{color:#f1831e}table#option-profile{padding-bottom:8px}table#option-profile td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-profile td.radio,table#option-profile td.thumbnail{padding-left:20px}table#option-profile td.details{font-weight:700;color:#333}table#option-fanpage td,table#option-fb-fanpage td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-fanpage td.thumbnail,table#option-fb-fanpage td.thumbnail{padding:5px 20px}table#option-fanpage td.details,table#option-fb-fanpage td.details{width:130px;padding-left:10px}table#option-fanpage td.details span.name,table#option-fb-fanpage td.details span.name{font-weight:700;color:#333}table#option-fanpage td.details span.category,table#option-fb-fanpage td.details span.category{font-size:10px;color:#888}input.fb-options{font-family:"Lucida Grande",Verdana,Arial,sans-serif;font-size:12px}.pub-connection-error{color:red}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -0,0 +1,199 @@
div#publicize-services-block {
display: block;
clear: both;
margin-bottom: 25px;
background-color: #fff;
padding: 25px 25px 5px 20px;
overflow: hidden;
max-width: 1200px;
}
/* Add the logos for the Publicize services */
span.pub-logos {
float: left;
display: block;
width: 130px;
height: 75px;
margin-top: -18px;
margin-left: 5px;
vertical-align: top;
}
.left, .right{
width: 50%;
float: left;
}
div#facebook { background: url( publicize-fb-2x.png ) no-repeat; background-size: 32px 32px; padding-left: 42px;background-position: 0px 0px;padding-top:5px; }
div#twitter { background: url( publicize-twitter-2x.png ) no-repeat; background-size: 32px 32px; padding-left: 42px;background-position: 0px 0px;padding-top:5px; }
div#linkedin { background: url( publicize-linkedin-2x.png )no-repeat; background-size: 32px 32px; padding-left: 42px;background-position: 0px 0px;padding-top:5px; }
div#tumblr { background: url( publicize-tumblr-2x.png ) no-repeat; background-size: 32px 32px; padding-left: 42px;background-position: 0px 0px;padding-top:5px; }
div#path { background: url( publicize-path-2x.png ) no-repeat; background-size: 32px 32px; padding-left: 42px;background-position: 0px 0px;padding-top:5px; }
div#google_plus { background: url( publicize-google-2x.png ) no-repeat; background-size: 32px 32px; padding-left: 42px;background-position: 0px 0px;padding-top:5px; }
a.publicize-profile-link, a.publicize-profile-link:visited {
text-decoration: none;
font-weight: bold;
}
a.publicize-profile-link:hover {
color: #f1831e;
}
a.publicize-add-connection, a.publicize-add-connection:visited {
text-decoration: none;
}
a.publicize-add-connection:hover {
color: #f1831e;
}
div.publicize-service-entry {
clear: both;
margin-bottom: 10px;
padding: 10px 0 25px 0;
border-bottom: 1px #eee solid;
margin-right: 40px;
overflow: hidden;
}
div.publicize-service-entry:last-of-type{
border-width: 0px;
}
div.publicize-service-left {
display: inline-block;
width: 150px;
vertical-align: top;
min-height: 35px;
}
div.publicize-service-left a{
font-size: 24px;
text-decoration: none;
}
div.publicize-service-left a:hover{
text-decoration: underline;
}
div.publicize-service-right {
display: inline-block;
text-align: right;
float: right;
padding-top:5px;
}
div.publicize-service-right ul {
margin-top: 0;
}
div.publicize-service-right li {
list-style-type: none;
font-size: 14px;
}
.pub-disconnect-button {
-webkit-border-image: none;
border-bottom-color: #CCC;
border-bottom-style: none;
border-bottom-width: 0px;
border-left-color: #CCC;
border-left-style: none;
border-left-width: 0px;
border-right-color: #CCC;
border-right-style: none;
border-right-width: 0px;
border-top-color: #CCC;
border-top-style: none;
border-top-width: 0px;
color: #CCC;
cursor: auto;
display: inline;
font-family: sans-serif;
font-size: 20px;
font-style: normal;
font-weight: normal;
height: auto;
line-height: 22px;
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
outline-color: #CCC;
outline-style: none;
outline-width: 0px;
overflow-y: visible;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
padding-top: 0px;
position: static;
right: auto;
text-align: left;
text-decoration: none;
top: auto;
vertical-align: baseline;
width: auto;
z-index: auto;
}
.pub-disconnect-button:hover {
color: #f1831e;
}
table#option-profile {
padding-bottom: 8px;
}
table#option-profile td {
font-family: "Lucida Grande",Verdana,Arial,sans-serif;
vertical-align: middle;
}
table#option-profile td.radio {
padding-right: 20px;
}
table#option-profile td.thumbnail {
padding-right: 20px;
}
table#option-profile td.details {
font-weight: bold; color: #333333
}
table#option-fb-fanpage td, table#option-fanpage td {
font-family: "Lucida Grande",Verdana,Arial,sans-serif;
vertical-align: middle;
}
table#option-fb-fanpage td.thumbnail, table#option-fanpage td.thumbnail {
padding: 5px 20px 5px 20px;
}
table#option-fb-fanpage td.details, table#option-fanpage td.details {
width: 130px;
padding-right: 10px;
}
table#option-fb-fanpage td.details span.name, table#option-fanpage td.details span.name {
font-weight: bold; color: #333333;
}
table#option-fb-fanpage td.details span.category, table#option-fanpage td.details span.category {
font-size: 10px; color: #888888;
}
input.fb-options {
font-family: "Lucida Grande",Verdana,Arial,sans-serif;
font-size: 12px;
}
.pub-connection-error {
color: #ff0000;
}

View file

@ -0,0 +1,184 @@
/* jshint onevar: false, smarttabs: true */
/* global tb_show, tb_pathToImage, ajaxurl, tb_init, tb_remove */
/* global myblogsResponse, publicizeConnTestStart:true, publicizeConnTestComplete:true, publicizeConnRefreshClick:true */
var showOptionsPage;
jQuery( function( $ ) {
showOptionsPage = function( service, nonce, connection, blogId ) {
tb_show( null, null, null );
$('body').append( '<div id=\'TB_load\'><img src=\'' + tb_pathToImage + '\' /></div>' );
$('#TB_load').show();
var query = '';
if ( connection ) {
query += '&connection=' + encodeURIComponent( connection );
}
if ( 'undefined' !== typeof( blogId ) && blogId ) {
query += '&blog_id=' + Number( blogId );
}
$.post( ajaxurl, 'action=publicize_' + service + '_options_page&_wpnonce=' + nonce + query, function( response ) {
$('#TB_load').remove();
try {
var obj = jQuery.parseJSON( response );
if ( obj && 'object' === typeof( obj ) ) {
if ( obj.hasOwnProperty( 'fb_redirect' ) ) {
location.href = obj.fb_redirect + '&redirect_uri=' + encodeURIComponent( location.href );
return;
}
}
} catch (err) {
// Do nothing and move on
}
if ( response ) {
var blogID = $( 'input[name=wpas_ajax_blog_id]' ).val();
var message = $( '<div id="wpas-ajax-' + blogID + '" class="wrap"></div>' ).append( response );
message.append( '<a href="#TB_inline?thickbox&height=420&width=555&inlineId=wpas-ajax-' + blogID + '" id="wpas-click-' + blogID + '" class="new-thickbox" style="display: none;"></a>' );
$('#wpas-message').html( message );
tb_init( 'a.new-thickbox' );
$('#wpas-click-' + blogID).click();
var tb_height = parseInt( $('#TB_ajaxContent').css('height'), 10 );
var content_height = $('#thickbox-content').height();
if ( content_height < tb_height ) {
var new_height = content_height + 15;
$('#TB_ajaxContent').css( 'height', new_height );
var new_margin = parseInt( $('#TB_window').css( 'margin-top'), 10 ) + (tb_height - new_height) / 2 + 'px';
$('#TB_window').css( 'margin-top', new_margin);
}
$('.save-options').unbind('click').click( function() {
var sel = $( 'input[name=\'option\']:checked' );
var global = $( 'input[name=\'global\']:checked' );
var connection = $(this).data('connection');
var token = encodeURIComponent( sel.val() );
var id = encodeURIComponent( sel.attr( 'id' ) );
var type = encodeURIComponent( sel.attr( 'data-type' ) );
var nonce = $(this).attr('rel');
var global_conn = 'off';
var global_nonce = '';
if ( global.length ) {
global_conn = 'on';
global_nonce = global.val();
}
$.post( ajaxurl, 'action=publicize_'+ service + '_options_save&connection=' + connection + '&selected_id=' + id + '&token=' + token + '&type=' + type + '&_wpnonce=' + nonce + '&global=' + global_conn + '&global_nonce=' + global_nonce, function( /*response*/ ) {
var frameNonce;
tb_remove();
frameNonce = document.location.search.match( /frame-nonce=([^&]+)/ );
if ( /inside-newdash=1/.test( document.location.search ) && frameNonce ) {
document.location = 'options-general.php?page=sharing&inside-newdash=1&frame-nonce' + frameNonce[1];
} else {
top.location = 'options-general.php?page=sharing';
}
} );
} );
}
}, 'html' );
};
$( 'body' ).append( '<div id="wpas-message" style="display: none"></div>' );
$( '.wpas-posts' ).change( function() {
var inputs = $(this).parents( 'td:first' ).find( ':input' );
var _this = this;
var blogID = inputs.filter( '[name=wpas_ajax_blog_id]' ).val();
$( '#waiting_' + blogID ).show();
$.post( ajaxurl, inputs.serialize() + '&action=wpas_post', function( response ) { myblogsResponse.call( _this, blogID, response ); }, 'html' );
} );
$( '.options' ).unbind('click').bind( 'click', function(e) {
e.preventDefault();
e.stopPropagation();
var service = $(this).attr('class').replace( 'options ', '' );
var blogId = null;
if ( 'undefined' !== typeof( $(this).attr('id') ) ) {
blogId = parseInt( $(this).attr('id').replace( 'options-', '' ), 10 );
}
var nonce = $(this).attr('href').replace( '#nonce=', '' );
var connection = $(this).data( 'connection' );
showOptionsPage.call( this, service, nonce, connection, blogId );
});
/**
* Kicks off tests for all connections
*/
publicizeConnTestStart = function() {
$( '.pub-connection-test' )
.addClass( 'test-in-progress' );
$.post( ajaxurl, { action: 'test_publicize_conns' }, publicizeConnTestComplete );
};
publicizeConnRefreshClick = function( event ) {
event.preventDefault();
var popupURL = event.currentTarget.href;
var popupTitle = event.currentTarget.title;
// open a popup window
// when it is closed, kick off the tests again
var popupWin = window.open( popupURL, popupTitle, '' );
var popupWinTimer= window.setInterval( function() {
if ( popupWin.closed !== false ) {
window.clearInterval( popupWinTimer );
publicizeConnTestStart();
}
}, 500 );
};
publicizeConnTestComplete = function( response ) {
$( '.pub-connection-test' ).removeClass( 'test-in-progress' );
$.each( response.data, function( index, testResult ) {
// find the li for this connection
var testSelector = '#pub-connection-test-' + testResult.connectionID;
if ( testResult.connectionTestPassed ) {
$( testSelector )
.addClass( 'test-passed' )
.html( '' )
.removeClass( 'test-failed' );
} else {
$( testSelector )
.addClass( 'test-failed' )
.html( '<p><span class="pub-connection-error">' + testResult.connectionTestMessage + '</span></p>' )
.removeClass( 'test-passed' );
if ( testResult.userCanRefresh ) {
$( testSelector )
.append( '<br/>' );
$( '<a/>', {
'class' : 'pub-refresh-button button',
'title' : testResult.refreshText,
'href' : testResult.refreshURL,
'text' : testResult.refreshText,
'target' : '_refresh_' + testResult.serviceName
} )
.appendTo( testSelector )
.click( publicizeConnRefreshClick );
}
}
} );
};
$( document ).ready( function() {
// If we have at least one .pub-connection-test div present, kick off the connection test
if ( $( '.pub-connection-test' ).length ) {
publicizeConnTestStart();
}
} );
} );

View file

@ -0,0 +1 @@
div#publicize-services-block{display:block;clear:both;margin-bottom:25px;background-color:#fff;padding:25px 25px 5px 20px;overflow:hidden;max-width:1200px}span.pub-logos{float:left;display:block;width:130px;height:75px;margin-top:-18px;margin-left:5px;vertical-align:top}.left,.right{width:50%;float:left}div#facebook{background:url(publicize-fb-2x.png) 0 0/32px 32px no-repeat;padding-left:42px;padding-top:5px}div#twitter{background:url(publicize-twitter-2x.png) 0 0/32px 32px no-repeat;padding-left:42px;padding-top:5px}div#linkedin{background:url(publicize-linkedin-2x.png)no-repeat 0 0/32px 32px;padding-left:42px;padding-top:5px}div#tumblr{background:url(publicize-tumblr-2x.png) 0 0/32px 32px no-repeat;padding-left:42px;padding-top:5px}div#path{background:url(publicize-path-2x.png) 0 0/32px 32px no-repeat;padding-left:42px;padding-top:5px}div#google_plus{background:url(publicize-google-2x.png) 0 0/32px 32px no-repeat;padding-left:42px;padding-top:5px}a.publicize-profile-link,a.publicize-profile-link:visited{text-decoration:none;font-weight:700}a.publicize-profile-link:hover{color:#f1831e}a.publicize-add-connection,a.publicize-add-connection:visited{text-decoration:none}a.publicize-add-connection:hover{color:#f1831e}div.publicize-service-entry{clear:both;margin-bottom:10px;padding:10px 0 25px;border-bottom:1px #eee solid;margin-right:40px;overflow:hidden}div.publicize-service-entry:last-of-type{border-width:0}div.publicize-service-left{display:inline-block;width:150px;vertical-align:top;min-height:35px}div.publicize-service-left a{font-size:24px;text-decoration:none}div.publicize-service-left a:hover{text-decoration:underline}div.publicize-service-right{display:inline-block;text-align:right;float:right;padding-top:5px}div.publicize-service-right ul{margin-top:0}div.publicize-service-right li{list-style-type:none;font-size:14px}.pub-disconnect-button{-webkit-border-image:none;border-color:#CCC;border-style:none;border-width:0;color:#CCC;cursor:auto;display:inline;font-family:sans-serif;font-size:20px;font-style:normal;font-weight:400;height:auto;line-height:22px;list-style:none;margin:0;outline:#CCC 0;overflow-y:visible;padding:0;position:static;right:auto;text-align:left;text-decoration:none;top:auto;vertical-align:baseline;width:auto;z-index:auto}.pub-disconnect-button:hover{color:#f1831e}table#option-profile{padding-bottom:8px}table#option-profile td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-profile td.radio,table#option-profile td.thumbnail{padding-right:20px}table#option-profile td.details{font-weight:700;color:#333}table#option-fanpage td,table#option-fb-fanpage td{font-family:"Lucida Grande",Verdana,Arial,sans-serif;vertical-align:middle}table#option-fanpage td.thumbnail,table#option-fb-fanpage td.thumbnail{padding:5px 20px}table#option-fanpage td.details,table#option-fb-fanpage td.details{width:130px;padding-right:10px}table#option-fanpage td.details span.name,table#option-fb-fanpage td.details span.name{font-weight:700;color:#333}table#option-fanpage td.details span.category,table#option-fb-fanpage td.details span.category{font-size:10px;color:#888}input.fb-options{font-family:"Lucida Grande",Verdana,Arial,sans-serif;font-size:12px}.pub-connection-error{color:red}

View file

@ -0,0 +1,201 @@
/* This file was automatically generated on Jan 15 2014 20:27:52 */
div#publicize-services-block {
display: block;
clear: both;
margin-bottom: 25px;
background-color: #fff;
padding: 25px 20px 5px 25px;
overflow: hidden;
max-width: 1200px;
}
/* Add the logos for the Publicize services */
span.pub-logos {
float: right;
display: block;
width: 130px;
height: 75px;
margin-top: -18px;
margin-right: 5px;
vertical-align: top;
}
.left, .right{
width: 50%;
float: right;
}
div#facebook { background: url( ../publicize-fb-2x.png ) no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
div#twitter { background: url( ../publicize-twitter-2x.png ) no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
div#linkedin { background: url( ../publicize-linkedin-2x.png )no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
div#tumblr { background: url( ../publicize-tumblr-2x.png ) no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
div#path { background: url( ../publicize-path-2x.png ) no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
div#google_plus { background: url( ../publicize-google-2x.png ) no-repeat; background-size: 32px 32px; padding-right: 42px;background-position: 0px 0px;padding-top:5px; }
a.publicize-profile-link, a.publicize-profile-link:visited {
text-decoration: none;
font-weight: bold;
}
a.publicize-profile-link:hover {
color: #f1831e;
}
a.publicize-add-connection, a.publicize-add-connection:visited {
text-decoration: none;
}
a.publicize-add-connection:hover {
color: #f1831e;
}
div.publicize-service-entry {
clear: both;
margin-bottom: 10px;
padding: 10px 0 25px 0;
border-bottom: 1px #eee solid;
margin-left: 40px;
overflow: hidden;
}
div.publicize-service-entry:last-of-type{
border-width: 0px;
}
div.publicize-service-left {
display: inline-block;
width: 150px;
vertical-align: top;
min-height: 35px;
}
div.publicize-service-left a{
font-size: 24px;
text-decoration: none;
}
div.publicize-service-left a:hover{
text-decoration: underline;
}
div.publicize-service-right {
display: inline-block;
text-align: left;
float: left;
padding-top:5px;
}
div.publicize-service-right ul {
margin-top: 0;
}
div.publicize-service-right li {
list-style-type: none;
font-size: 14px;
}
.pub-disconnect-button {
-webkit-border-image: none;
border-bottom-color: #CCC;
border-bottom-style: none;
border-bottom-width: 0px;
border-right-color: #CCC;
border-right-style: none;
border-right-width: 0px;
border-left-color: #CCC;
border-left-style: none;
border-left-width: 0px;
border-top-color: #CCC;
border-top-style: none;
border-top-width: 0px;
color: #CCC;
cursor: auto;
display: inline;
font-family: sans-serif;
font-size: 20px;
font-style: normal;
font-weight: normal;
height: auto;
line-height: 22px;
list-style-image: none;
list-style-position: outside;
list-style-type: none;
margin-bottom: 0px;
margin-right: 0px;
margin-left: 0px;
margin-top: 0px;
outline-color: #CCC;
outline-style: none;
outline-width: 0px;
overflow-y: visible;
padding-bottom: 0px;
padding-right: 0px;
padding-left: 0px;
padding-top: 0px;
position: static;
left: auto;
text-align: right;
text-decoration: none;
top: auto;
vertical-align: baseline;
width: auto;
z-index: auto;
}
.pub-disconnect-button:hover {
color: #f1831e;
}
table#option-profile {
padding-bottom: 8px;
}
table#option-profile td {
font-family: "Lucida Grande",Verdana,Arial,sans-serif;
vertical-align: middle;
}
table#option-profile td.radio {
padding-left: 20px;
}
table#option-profile td.thumbnail {
padding-left: 20px;
}
table#option-profile td.details {
font-weight: bold; color: #333333
}
table#option-fb-fanpage td, table#option-fanpage td {
font-family: "Lucida Grande",Verdana,Arial,sans-serif;
vertical-align: middle;
}
table#option-fb-fanpage td.thumbnail, table#option-fanpage td.thumbnail {
padding: 5px 20px 5px 20px;
}
table#option-fb-fanpage td.details, table#option-fanpage td.details {
width: 130px;
padding-left: 10px;
}
table#option-fb-fanpage td.details span.name, table#option-fanpage td.details span.name {
font-weight: bold; color: #333333;
}
table#option-fb-fanpage td.details span.category, table#option-fanpage td.details span.category {
font-size: 10px; color: #888888;
}
input.fb-options {
font-family: "Lucida Grande",Verdana,Arial,sans-serif;
font-size: 12px;
}
.pub-connection-error {
color: #ff0000;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

@ -0,0 +1,127 @@
<?php
if ( ! class_exists( 'Jetpack_Media_Summary' ) ) {
if ( defined('IS_WPCOM') && IS_WPCOM ) {
include WP_CONTENT_DIR . '/lib/class.wpcom-media-summary.php';
} else {
jetpack_require_lib( 'class.media-summary' );
}
}
/**
* Better OG Image Tags for Image Post Formats
*/
function enhanced_og_image( $tags ) {
if ( !is_singular() || post_password_required() )
return $tags;
global $post;
// Always favor featured images.
if ( enhanced_og_has_featured_image( $post->ID ) )
return $tags;
$summary = Jetpack_Media_Summary::get( $post->ID );
if ( 'image' != $summary['type'] )
return $tags;
$tags['og:image'] = $summary['image'];
$tags['og:image:secure_url'] = $summary['secure']['image'];
return $tags;
}
add_filter( 'jetpack_open_graph_tags', 'enhanced_og_image' );
/**
* Better OG Image Tags for Gallery Post Formats
*/
function enhanced_og_gallery( $tags ) {
if ( !is_singular() || post_password_required() )
return $tags;
global $post;
// Always favor featured images.
if ( enhanced_og_has_featured_image( $post->ID ) )
return $tags;
$summary = Jetpack_Media_Summary::get( $post->ID );
if ( 'gallery' != $summary['type'] )
return $tags;
if( !isset( $summary['images'] ) || !is_array( $summary['images'] ) || empty( $summary['images'] ) )
return $tags;
$images = $secures = array();
foreach ( $summary['images'] as $i => $image ) {
$images[] = $image['url'];
$secures[] = $summary['secure']['images'][$i]['url'];
}
$tags['og:image'] = $images;
$tags['og:image:secure_url'] = $secures;
return $tags;
}
add_filter( 'jetpack_open_graph_tags', 'enhanced_og_gallery' );
/**
* Allows VideoPress, YouTube, and Vimeo videos to play inline on Facebook
*/
function enhanced_og_video( $tags ) {
if ( !is_singular() || post_password_required() )
return $tags;
global $post;
// Always favor featured images.
if ( enhanced_og_has_featured_image( $post->ID ) )
return $tags;
$summary = Jetpack_Media_Summary::get( $post->ID );
if ( 'video' != $summary['type'] ) {
if ( $summary['count']['video'] > 0 && $summary['count']['image'] < 1 ) {
$tags['og:image'] = $summary['image'];
$tags['og:image:secure_url'] = $summary['secure']['image'];
}
return $tags;
}
$tags['og:image'] = $summary['image'];
$tags['og:image:secure_url'] = $summary['secure']['image'];
$tags['og:video:type'] = 'application/x-shockwave-flash';
$video_url = $summary['video'];
$secure_video_url = $summary['secure']['video'];
if ( preg_match( '/((youtube|vimeo)\.com|youtu.be)/', $video_url ) ) {
if ( strstr( $video_url, 'youtube' ) ) {
$id = jetpack_get_youtube_id( $video_url );
$video_url = 'http://www.youtube.com/v/' . $id . '?version=3&autohide=1';
$secure_video_url = 'https://www.youtube.com/v/' . $id . '?version=3&autohide=1';
} else if ( strstr( $video_url, 'vimeo' ) ) {
preg_match( '|vimeo\.com/(\d+)/?$|i', $video_url, $match );
$id = (int) $match[1];
$video_url = 'http://vimeo.com/moogaloop.swf?clip_id=' . $id;
$secure_video_url = 'https://vimeo.com/moogaloop.swf?clip_id=' . $id;
}
}
$tags['og:video'] = $video_url;
$tags['og:video:secure_url'] = $secure_video_url;
if ( empty( $post->post_title ) )
$tags['og:title'] = sprintf( __( 'Video on %s', 'jetpack' ), get_option( 'blogname' ) );
return $tags;
}
add_filter( 'jetpack_open_graph_tags', 'enhanced_og_video' );
function enhanced_og_has_featured_image( $post_id ) {
$featured = Jetpack_PostImages::from_thumbnail( $post_id, 200, 200 );
if ( !empty( $featured ) && count( $featured ) > 0 )
return true;
return false;
}

View file

@ -0,0 +1,741 @@
<?php
class Publicize extends Publicize_Base {
function __construct() {
parent::__construct();
add_filter( 'jetpack_xmlrpc_methods', array( $this, 'register_update_publicize_connections_xmlrpc_method' ) );
add_action( 'load-settings_page_sharing', array( $this, 'admin_page_load' ), 9 );
add_action( 'wp_ajax_publicize_tumblr_options_page', array( $this, 'options_page_tumblr' ) );
add_action( 'wp_ajax_publicize_facebook_options_page', array( $this, 'options_page_facebook' ) );
add_action( 'wp_ajax_publicize_twitter_options_page', array( $this, 'options_page_twitter' ) );
add_action( 'wp_ajax_publicize_linkedin_options_page', array( $this, 'options_page_linkedin' ) );
add_action( 'wp_ajax_publicize_path_options_page', array( $this, 'options_page_path' ) );
add_action( 'wp_ajax_publicize_google_plus_options_page', array( $this, 'options_page_google_plus' ) );
add_action( 'wp_ajax_publicize_tumblr_options_save', array( $this, 'options_save_tumblr' ) );
add_action( 'wp_ajax_publicize_facebook_options_save', array( $this, 'options_save_facebook' ) );
add_action( 'wp_ajax_publicize_twitter_options_save', array( $this, 'options_save_twitter' ) );
add_action( 'wp_ajax_publicize_linkedin_options_save', array( $this, 'options_save_linkedin' ) );
add_action( 'wp_ajax_publicize_path_options_save', array( $this, 'options_save_path' ) );
add_action( 'wp_ajax_publicize_google_plus_options_save', array( $this, 'options_save_google_plus' ) );
add_action( 'load-settings_page_sharing', array( $this, 'force_user_connection' ) );
add_filter( 'publicize_checkbox_default', array( $this, 'publicize_checkbox_default' ), 10, 4 );
add_action( 'transition_post_status', array( $this, 'save_publicized' ), 10, 3 );
add_filter( 'jetpack_twitter_cards_site_tag', array( $this, 'enhaced_twitter_cards_site_tag' ) );
add_action( 'publicize_save_meta', array( $this, 'save_publicized_twitter_account' ), 10, 4 );
add_action( 'publicize_save_meta', array( $this, 'save_publicized_facebook_account' ), 10, 4 );
add_filter( 'jetpack_sharing_twitter_via', array( $this, 'get_publicized_twitter_account' ), 10, 2 );
include_once ( JETPACK__PLUGIN_DIR . 'modules/publicize/enhanced-open-graph.php' );
}
function force_user_connection() {
global $current_user;
$user_token = Jetpack_Data::get_access_token( $current_user->ID );
$is_user_connected = $user_token && !is_wp_error( $user_token );
// If the user is already connected via Jetpack, then we're good
if ( $is_user_connected )
return;
// If they're not connected, then remove the Publicize UI and tell them they need to connect first
global $publicize_ui;
remove_action( 'pre_admin_screen_sharing', array( $publicize_ui, 'admin_page' ) );
// Do we really need `admin_styles`? With the new admin UI, it's breaking some bits.
// Jetpack::init()->admin_styles();
add_action( 'pre_admin_screen_sharing', array( $this, 'admin_page_warning' ), 1 );
}
function admin_page_warning() {
$jetpack = Jetpack::init();
$blog_name = get_bloginfo( 'blogname' );
if ( empty( $blog_name ) ) {
$blog_name = home_url( '/' );
}
?>
<div id="message" class="updated jetpack-message jp-connect">
<div class="jetpack-wrap-container">
<div class="jetpack-text-container">
<p><?php printf(
esc_html( wptexturize( __( "To use Publicize, you'll need to link your %s account to your WordPress.com account using the link below.", 'jetpack' ) ) ),
'<strong>' . esc_html( $blog_name ) . '</strong>'
); ?></p>
<p><?php echo esc_html( wptexturize( __( "If you don't have a WordPress.com account yet, you can sign up for free in just a few seconds.", 'jetpack' ) ) ); ?></p>
</div>
<div class="jetpack-install-container">
<p class="submit"><a href="<?php echo $jetpack->build_connect_url( false, menu_page_url( 'sharing', false ) ); ?>" class="button-connector" id="wpcom-connect"><?php esc_html_e( 'Link account with WordPress.com', 'jetpack' ); ?></a></p>
</div>
</div>
</div>
<?php
}
/**
* Remove a Publicize connection
*/
function disconnect( $service_name, $connection_id, $_blog_id = false, $_user_id = false, $force_delete = false ) {
Jetpack::load_xml_rpc_client();
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.deletePublicizeConnection', $connection_id );
if ( ! $xml->isError() ) {
Jetpack_Options::update_option( 'publicize_connections', $xml->getResponse() );
} else {
return false;
}
}
function receive_updated_publicize_connections( $publicize_connections ) {
Jetpack_Options::update_option( 'publicize_connections', $publicize_connections );
return true;
}
function register_update_publicize_connections_xmlrpc_method( $methods ) {
return array_merge( $methods, array(
'jetpack.updatePublicizeConnections' => array( $this, 'receive_updated_publicize_connections' ),
) );
}
function get_connections( $service_name, $_blog_id = false, $_user_id = false ) {
$connections = Jetpack_Options::get_option( 'publicize_connections' );
$connections_to_return = array();
if ( !empty( $connections ) && is_array( $connections ) ) {
if ( !empty( $connections[$service_name] ) ) {
foreach( $connections[$service_name] as $id => $connection ) {
if ( 0 == $connection['connection_data']['user_id'] || $this->user_id() == $connection['connection_data']['user_id'] ) {
$connections_to_return[$id] = $connection;
}
}
}
return $connections_to_return;
}
return false;
}
function get_connection_id( $connection ) {
return $connection['connection_data']['id'];
}
function get_connection_meta( $connection ) {
$connection['user_id'] = $connection['connection_data']['user_id']; // Allows for shared connections
return $connection;
}
function admin_page_load() {
if ( isset( $_GET['action'] ) ) {
if ( isset( $_GET['service'] ) )
$service_name = $_GET['service'];
switch ( $_GET['action'] ) {
case 'error':
add_action( 'pre_admin_screen_sharing', array( $this, 'display_connection_error' ), 9 );
break;
case 'request':
check_admin_referer( 'keyring-request', 'kr_nonce' );
check_admin_referer( "keyring-request-$service_name", 'nonce' );
$verification = Jetpack::create_nonce( 'publicize' );
$stats_options = get_option( 'stats_options' );
$wpcom_blog_id = Jetpack_Options::get_option('id');
$wpcom_blog_id = !empty( $wpcom_blog_id ) ? $wpcom_blog_id : $stats_options['blog_id'];
$user = wp_get_current_user();
$redirect = $this->api_url( $service_name, urlencode_deep( array(
'action' => 'request',
'redirect_uri' => add_query_arg( array( 'action' => 'done' ), menu_page_url( 'sharing', false ) ),
'for' => 'publicize', // required flag that says this connection is intended for publicize
'siteurl' => site_url(),
'state' => $user->ID,
'blog_id' => $wpcom_blog_id,
'secret_1' => $verification['secret_1'],
'secret_2' => $verification['secret_2'],
'eol' => $verification['eol'],
) ) );
wp_redirect( $redirect );
exit;
break;
case 'completed':
Jetpack::load_xml_rpc_client();
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.fetchPublicizeConnections' );
if ( ! $xml->isError() ) {
$response = $xml->getResponse();
Jetpack_Options::update_option( 'publicize_connections', $response );
}
break;
case 'delete':
$id = $_GET['id'];
check_admin_referer( 'keyring-request', 'kr_nonce' );
check_admin_referer( "keyring-request-$service_name", 'nonce' );
$this->disconnect( $service_name, $id );
add_action( 'admin_notices', array( $this, 'display_disconnected' ) );
break;
}
}
// Do we really need `admin_styles`? With the new admin UI, it's breaking some bits.
// Errors encountered on WordPress.com's end are passed back as a code
/*
if ( isset( $_GET['action'] ) && 'error' == $_GET['action'] ) {
// Load Jetpack's styles to handle the box
Jetpack::init()->admin_styles();
}
*/
}
function display_connection_error() {
$code = false;
if ( isset( $_GET['service'] ) ) {
$service_name = $_GET['service'];
$error = sprintf( __( 'There was a problem connecting to %s to create an authorized connection. Please try again in a moment.', 'jetpack' ), Publicize::get_service_label( $service_name ) );
} else {
if ( isset( $_GET['publicize_error'] ) ) {
$code = strtolower( $_GET['publicize_error'] );
switch ( $code ) {
case '400':
$error = __( 'An invalid request was made. This normally means that something intercepted or corrupted the request from your server to the Jetpack Server. Try again and see if it works this time.', 'jetpack' );
break;
case 'secret_mismatch':
$error = __( 'We could not verify that your server is making an authorized request. Please try again, and make sure there is nothing interfering with requests from your server to the Jetpack Server.', 'jetpack' );
break;
case 'empty_blog_id':
$error = __( 'No blog_id was included in your request. Please try disconnecting Jetpack from WordPress.com and then reconnecting it. Once you have done that, try connecting Publicize again.', 'jetpack' );
break;
case 'empty_state':
$error = sprintf( __( 'No user information was included in your request. Please make sure that your user account has connected to Jetpack. Connect your user account by going to the <a href="%s">Jetpack page</a> within wp-admin.', 'jetpack' ), Jetpack::admin_url() );
break;
default:
$error = __( 'Something which should never happen, happened. Sorry about that. If you try again, maybe it will work.', 'jetpack' );
break;
}
} else {
$error = __( 'There was a problem connecting with Publicize. Please try again in a moment.', 'jetpack' );
}
}
// Using the same formatting/style as Jetpack::admin_notices() error
?>
<div id="message" class="jetpack-message jetpack-err">
<div class="squeezer">
<h2><?php echo wp_kses( $error, array( 'a' => array( 'href' => true ), 'code' => true, 'strong' => true, 'br' => true, 'b' => true ) ); ?></h2>
<?php if ( $code ) : ?>
<p><?php printf( __( 'Error code: %s', 'jetpack' ), esc_html( stripslashes( $code ) ) ); ?></p>
<?php endif; ?>
</div>
</div>
<?php
}
function display_disconnected() {
echo "<div class='updated'>\n";
echo '<p>' . esc_html( __( 'That connection has been removed.', 'jetpack' ) ) . "</p>\n";
echo "</div>\n\n";
}
function globalization() {
if ( 'on' == $_REQUEST['global'] ) {
$id = $_REQUEST['connection'];
if ( !current_user_can( $this->GLOBAL_CAP ) )
return;
Jetpack::load_xml_rpc_client();
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.globalizePublicizeConnection', $id, 'globalize' );
if ( !$xml->isError() ) {
$response = $xml->getResponse();
Jetpack_Options::update_option( 'publicize_connections', $response );
}
}
}
/**
* Gets a URL to the public-api actions. Works like WP's admin_url
*
* @param string $service Shortname of a specific service.
* @return URL to specific public-api process
*/
// on WordPress.com this is/calls Keyring::admin_url
function api_url( $service = false, $params = array() ) {
/**
* Filters the API URL used to interact with WordPress.com.
*
* @module publicize
*
* @since 2.0.0
*
* @param string https://public-api.wordpress.com/connect/?jetpack=publicize Default Publicize API URL.
*/
$url = apply_filters( 'publicize_api_url', 'https://public-api.wordpress.com/connect/?jetpack=publicize' );
if ( $service )
$url = add_query_arg( array( 'service' => $service ), $url );
if ( count ( $params ) )
$url = add_query_arg( $params, $url );
return $url;
}
function connect_url( $service_name ) {
return add_query_arg( array(
'action' => 'request',
'service' => $service_name,
'kr_nonce' => wp_create_nonce( 'keyring-request' ),
'nonce' => wp_create_nonce( "keyring-request-$service_name" ),
), menu_page_url( 'sharing', false ) );
}
function refresh_url( $service_name ) {
return add_query_arg( array(
'action' => 'request',
'service' => $service_name,
'kr_nonce' => wp_create_nonce( 'keyring-request' ),
'refresh' => 1,
'for' => 'publicize',
'nonce' => wp_create_nonce( "keyring-request-$service_name" ),
), admin_url( 'options-general.php?page=sharing' ) );
}
function disconnect_url( $service_name, $id ) {
return add_query_arg( array (
'action' => 'delete',
'service' => $service_name,
'id' => $id,
'kr_nonce' => wp_create_nonce( 'keyring-request' ),
'nonce' => wp_create_nonce( "keyring-request-$service_name" ),
), menu_page_url( 'sharing', false ) );
}
function get_services( $filter ) {
if ( !in_array( $filter, array( 'all', 'connected' ) ) )
$filter = 'all';
$services = array(
'facebook' => array(),
'twitter' => array(),
'linkedin' => array(),
'tumblr' => array(),
'path' => array(),
'google_plus' => array(),
);
if ( 'all' == $filter ) {
return $services;
} else {
$connected_services = array();
foreach ( $services as $service => $empty ) {
$connections = $this->get_connections( $service );
if ( $connections )
$connected_services[$service] = $connections;
}
return $connected_services;
}
}
function get_connection( $service, $id, $_blog_id = false, $_user_id = false ) {
// Stub
}
function flag_post_for_publicize( $new_status, $old_status, $post ) {
// Stub only. Doesn't need to do anything on Jetpack Client
}
function test_connection( $service_name, $connection ) {
$connection_test_passed = true;
$connection_test_message = '';
$user_can_refresh = false;
$id = $this->get_connection_id( $connection );
Jetpack::load_xml_rpc_client();
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.testPublicizeConnection', $id );
if ( $xml->isError() ) {
$xml_response = $xml->getResponse();
$connection_test_message = $xml_response['faultString'];
$connection_test_passed = false;
}
// Bail if all is well
if ( $connection_test_passed ) {
return true;
}
// Set up refresh if the user can
$user_can_refresh = current_user_can( $this->GLOBAL_CAP );
if ( $user_can_refresh ) {
$nonce = wp_create_nonce( "keyring-request-" . $service_name );
$refresh_text = sprintf( _x( 'Refresh connection with %s', 'Refresh connection with {social media service}', 'jetpack' ), $this->get_service_label( $service_name ) );
$refresh_url = $this->refresh_url( $service_name );
}
$error_data = array(
'user_can_refresh' => $user_can_refresh,
'refresh_text' => $refresh_text,
'refresh_url' => $refresh_url
);
return new WP_Error( 'pub_conn_test_failed', $connection_test_message, $error_data );
}
/**
* Save a flag locally to indicate that this post has already been Publicized via the selected
* connections.
*/
function save_publicized( $new_status, $old_status, $post ) {
// Only do this when a post transitions to being published
if ( 'publish' == $new_status && 'publish' != $old_status ) {
update_post_meta( $post->ID, $this->POST_DONE . 'all', true );
}
}
/**
* Options Code
*/
function options_page_facebook() {
$connected_services = Jetpack_Options::get_option( 'publicize_connections' );
$connection = $connected_services['facebook'][$_REQUEST['connection']];
$options_to_show = ( ! empty( $connection['connection_data']['meta']['options_responses'] ) ? $connection['connection_data']['meta']['options_responses'] : false );
// Nonce check
check_admin_referer( 'options_page_facebook_' . $_REQUEST['connection'] );
$me = ( ! empty( $options_to_show[0] ) ? $options_to_show[0] : false );
$pages = ( ! empty( $options_to_show[1]['data'] ) ? $options_to_show[1]['data'] : false );
$profile_checked = true;
$page_selected = false;
if ( !empty( $connection['connection_data']['meta']['facebook_page'] ) ) {
$found = false;
if ( is_array( $pages->data ) ) {
foreach ( $pages->data as $page ) {
if ( $page->id == $connection['connection_data']['meta']['facebook_page'] ) {
$found = true;
break;
}
}
}
if ( $found ) {
$profile_checked = false;
$page_selected = $connection['connection_data']['meta']['facebook_page'];
}
}
?>
<div id="thickbox-content">
<?php
ob_start();
Publicize_UI::connected_notice( 'Facebook' );
$update_notice = ob_get_clean();
if ( ! empty( $update_notice ) )
echo $update_notice;
?>
<?php if ( !empty( $me['name'] ) ) : ?>
<p><?php printf(
esc_html__( 'Publicize to my %s:', 'jetpack' ),
'<strong>' . esc_html__( 'Facebook Wall', 'jetpack' ) . '</strong>'
); ?></p>
<table id="option-profile">
<tbody>
<tr>
<td class="radio"><input type="radio" name="option" data-type="profile" id="<?php echo esc_attr( $me['id'] ) ?>" value="" <?php checked( $profile_checked, true ); ?> /></td>
<td class="thumbnail"><label for="<?php echo esc_attr( $me['id'] ) ?>"><img src="<?php echo esc_url( $me['picture']['data']['url'] ) ?>" width="50" height="50" /></label></td>
<td class="details"><label for="<?php echo esc_attr( $me['id'] ) ?>"><?php echo esc_html( $me['name'] ) ?></label></td>
</tr>
</tbody>
</table>
<?php endif; ?>
<?php if ( $pages ) : ?>
<p><?php printf(
esc_html__( 'Publicize to my %s:', 'jetpack' ),
'<strong>' . esc_html__( 'Facebook Page', 'jetpack' ) . '</strong>'
); ?></p>
<table id="option-fb-fanpage">
<tbody>
<?php foreach ( $pages as $i => $page ) : ?>
<?php if ( ! ( $i % 2 ) ) : ?>
<tr>
<?php endif; ?>
<td class="radio"><input type="radio" name="option" data-type="page" id="<?php echo esc_attr( $page['id'] ) ?>" value="<?php echo esc_attr( $page['id'] ) ?>" <?php checked( $page_selected && $page_selected == $page['id'], true ); ?> /></td>
<td class="thumbnail"><label for="<?php echo esc_attr( $page['id'] ) ?>"><img src="<?php echo esc_url( str_replace( '_s', '_q', $page['picture']['data']['url'] ) ) ?>" width="50" height="50" /></label></td>
<td class="details">
<label for="<?php echo esc_attr( $page['id'] ) ?>">
<span class="name"><?php echo esc_html( $page['name'] ) ?></span><br/>
<span class="category"><?php echo esc_html( $page['category'] ) ?></span>
</label>
</td>
<?php if ( ( $i % 2 ) || ( $i == count( $pages ) - 1 ) ): ?>
</tr>
<?php endif; ?>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php Publicize_UI::global_checkbox( 'facebook', $_REQUEST['connection'] ); ?>
<p style="text-align: center;">
<input type="submit" value="<?php esc_attr_e( 'OK', 'jetpack' ) ?>" class="button fb-options save-options" name="save" data-connection="<?php echo esc_attr( $_REQUEST['connection'] ); ?>" rel="<?php echo wp_create_nonce('save_fb_token_' . $_REQUEST['connection'] ) ?>" />
</p><br/>
</div>
<?php
}
function options_save_facebook() {
// Nonce check
check_admin_referer( 'save_fb_token_' . $_REQUEST['connection'] );
$id = $_POST['connection'];
// Check for a numeric page ID
$page_id = $_POST['selected_id'];
if ( !ctype_digit( $page_id ) )
die( 'Security check' );
if ( isset( $_POST['selected_id'] ) && 'profile' == $_POST['type'] ) {
// Publish to User Wall/Profile
$options = array(
'facebook_page' => null,
'facebook_profile' => true
);
} else {
if ( 'page' != $_POST['type'] || !isset( $_POST['selected_id'] ) ) {
return;
}
// Publish to Page
$options = array(
'facebook_page' => $page_id,
'facebook_profile' => null
);
}
Jetpack::load_xml_rpc_client();
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.setPublicizeOptions', $id, $options );
if ( !$xml->isError() ) {
$response = $xml->getResponse();
Jetpack_Options::update_option( 'publicize_connections', $response );
}
$this->globalization();
}
function options_page_tumblr() {
// Nonce check
check_admin_referer( 'options_page_tumblr_' . $_REQUEST['connection'] );
$connected_services = Jetpack_Options::get_option( 'publicize_connections' );
$connection = $connected_services['tumblr'][$_POST['connection']];
$options_to_show = $connection['connection_data']['meta']['options_responses'];
$request = $options_to_show[0];
$blogs = $request['response']['user']['blogs'];
$blog_selected = false;
if ( !empty( $connection['connection_data']['meta']['tumblr_base_hostname'] ) ) {
foreach ( $blogs as $blog ) {
if ( $connection['connection_data']['meta']['tumblr_base_hostname'] == $this->get_basehostname( $blog['url'] ) ) {
$blog_selected = $connection['connection_data']['meta']['tumblr_base_hostname'];
break;
}
}
}
// Use their Primary blog if they haven't selected one yet
if ( !$blog_selected ) {
foreach ( $blogs as $blog ) {
if ( $blog['primary'] )
$blog_selected = $this->get_basehostname( $blog['url'] );
}
} ?>
<div id="thickbox-content">
<?php
ob_start();
Publicize_UI::connected_notice( 'Tumblr' );
$update_notice = ob_get_clean();
if ( ! empty( $update_notice ) )
echo $update_notice;
?>
<p><?php printf(
esc_html__( 'Publicize to my %s:', 'jetpack' ),
'<strong>' . esc_html__( 'Tumblr blog', 'jetpack' ) . '</strong>'
); ?></p>
<ul id="option-tumblr-blog">
<?php
foreach ( $blogs as $blog ) {
$url = $this->get_basehostname( $blog['url'] ); ?>
<li>
<input type="radio" name="option" data-type="blog" id="<?php echo esc_attr( $url ) ?>" value="<?php echo esc_attr( $url ) ?>" <?php checked( $blog_selected == $url, true ); ?> />
<label for="<?php echo esc_attr( $url ) ?>"><span class="name"><?php echo esc_html( $blog['title'] ) ?></span></label>
</li>
<?php } ?>
</ul>
<?php Publicize_UI::global_checkbox( 'tumblr', $_REQUEST['connection'] ); ?>
<p style="text-align: center;">
<input type="submit" value="<?php esc_attr_e( 'OK', 'jetpack' ) ?>" class="button tumblr-options save-options" name="save" data-connection="<?php echo esc_attr( $_REQUEST['connection'] ); ?>" rel="<?php echo wp_create_nonce( 'save_tumblr_blog_' . $_REQUEST['connection'] ) ?>" />
</p> <br />
</div>
<?php
}
function get_basehostname( $url ) {
return parse_url( $url, PHP_URL_HOST );
}
function options_save_tumblr() {
// Nonce check
check_admin_referer( 'save_tumblr_blog_' . $_REQUEST['connection'] );
$id = $_POST['connection'];
$options = array( 'tumblr_base_hostname' => $_POST['selected_id'] );
Jetpack::load_xml_rpc_client();
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.setPublicizeOptions', $id, $options );
if ( !$xml->isError() ) {
$response = $xml->getResponse();
Jetpack_Options::update_option( 'publicize_connections', $response );
}
$this->globalization();
}
function options_page_twitter() { Publicize_UI::options_page_other( 'twitter' ); }
function options_page_linkedin() { Publicize_UI::options_page_other( 'linkedin' ); }
function options_page_path() { Publicize_UI::options_page_other( 'path' ); }
function options_page_google_plus() { Publicize_UI::options_page_other( 'google_plus' ); }
function options_save_twitter() { $this->options_save_other( 'twitter' ); }
function options_save_linkedin() { $this->options_save_other( 'linkedin' ); }
function options_save_path() { $this->options_save_other( 'path' ); }
function options_save_google_plus() { $this->options_save_other( 'google_plus' ); }
function options_save_other( $service_name ) {
// Nonce check
check_admin_referer( 'save_' . $service_name . '_token_' . $_REQUEST['connection'] );
$this->globalization();
}
/**
* Already-published posts should not be Publicized by default. This filter sets checked to
* false if a post has already been published.
*/
function publicize_checkbox_default( $checked, $post_id, $name, $connection ) {
if ( 'publish' == get_post_status( $post_id ) )
return false;
return $checked;
}
/**
* If there's only one shared connection to Twitter set it as twitter:site tag.
*/
function enhaced_twitter_cards_site_tag( $tag ) {
$custom_site_tag = get_option( 'jetpack-twitter-cards-site-tag' );
if( ! empty( $custom_site_tag ) )
return $tag;
if ( ! $this->is_enabled('twitter') )
return $tag;
$connections = $this->get_connections( 'twitter' );
foreach ( $connections as $connection ) {
$connection_meta = $this->get_connection_meta( $connection );
if ( 0 == $connection_meta['connection_data']['user_id'] ) {
// If the connection is shared
return $this->get_display_name( 'twitter', $connection );
}
}
return $tag;
}
function save_publicized_twitter_account( $submit_post, $post_id, $service_name, $connection ) {
if ( 'twitter' == $service_name && $submit_post ) {
$connection_meta = $this->get_connection_meta( $connection );
$publicize_twitter_user = get_post_meta( $post_id, '_publicize_twitter_user' );
if ( empty( $publicize_twitter_user ) || 0 != $connection_meta['connection_data']['user_id'] ) {
update_post_meta( $post_id, '_publicize_twitter_user', $this->get_display_name( 'twitter', $connection ) );
}
}
}
function get_publicized_twitter_account( $account, $post_id ) {
if ( ! empty( $account ) ) {
return $account;
}
$account = get_post_meta( $post_id, '_publicize_twitter_user', true );
if ( ! empty( $account ) ) {
return $account;
}
return '';
}
/**
* Save the Publicized Facebook account when publishing a post
* Use only Personal accounts, not Facebook Pages
*/
function save_publicized_facebook_account( $submit_post, $post_id, $service_name, $connection ) {
$connection_meta = $this->get_connection_meta( $connection );
if ( 'facebook' == $service_name && isset( $connection_meta['connection_data']['meta']['facebook_profile'] ) && $submit_post ) {
$publicize_facebook_user = get_post_meta( $post_id, '_publicize_facebook_user' );
if ( empty( $publicize_facebook_user ) || 0 != $connection_meta['connection_data']['user_id'] ) {
$profile_link = $this->get_profile_link( 'facebook', $connection );
if ( false !== $profile_link ) {
update_post_meta( $post_id, '_publicize_facebook_user', $profile_link );
}
}
}
}
}

View file

@ -0,0 +1,477 @@
<?php
abstract class Publicize_Base {
/**
* Services that are currently connected to the given user
* through publicize.
*/
public $connected_services = array();
/**
* Services that are supported by publicize. They don't
* necessarily need to be connected to the current user.
*/
public $services;
/**
* key names for post meta
*/
public $ADMIN_PAGE = 'wpas';
public $POST_MESS = '_wpas_mess';
public $POST_SKIP = '_wpas_skip_'; // connection id appended to indicate that a connection should NOT be publicized to
public $POST_DONE = '_wpas_done_'; // connection id appended to indicate a connection has already been publicized to
public $USER_AUTH = 'wpas_authorize';
public $USER_OPT = 'wpas_';
public $PENDING = '_publicize_pending'; // ready for Publicize to do its thing
public $POST_SERVICE_DONE = '_publicize_done_external'; // array of external ids where we've Publicized
/**
* default pieces of the message used in constructing the
* content pushed out to other social networks
*/
public $default_prefix = '';
public $default_message = '%title%';
public $default_suffix = ' ';
/**
* What WP capability is require to create/delete global connections?
* All users with this cap can un-globalize all other global connections, and globalize any of their own
* Globalized connections cannot be unselected by users without this capability when publishing
*/
public $GLOBAL_CAP = 'edit_others_posts';
/**
* Sets up the basics of Publicize
*/
function __construct() {
$this->default_message = Publicize_Util::build_sprintf( array(
/**
* Filter the default Publicize message.
*
* @module publicize
*
* @since 2.0.0
*
* @param string $this->default_message Publicize's default message. Default is the post title.
*/
apply_filters( 'wpas_default_message', $this->default_message ),
'title',
'url',
) );
$this->default_prefix = Publicize_Util::build_sprintf( array(
/**
* Filter the message prepended to the Publicize custom message.
*
* @module publicize
*
* @since 2.0.0
*
* @param string $this->default_prefix String prepended to the Publicize custom message.
*/
apply_filters( 'wpas_default_prefix', $this->default_prefix ),
'url',
) );
$this->default_suffix = Publicize_Util::build_sprintf( array(
/**
* Filter the message appended to the Publicize custom message.
*
* @module publicize
*
* @since 2.0.0
*
* @param string $this->default_suffix String appended to the Publicize custom message.
*/
apply_filters( 'wpas_default_suffix', $this->default_suffix ),
'url',
) );
/**
* Filter the capability to change global Publicize connection options.
*
* All users with this cap can un-globalize all other global connections, and globalize any of their own
* Globalized connections cannot be unselected by users without this capability when publishing.
*
* @module publicize
*
* @since 2.2.1
*
* @param string $this->GLOBAL_CAP default capability in control of global Publicize connection options. Default to edit_others_posts.
*/
$this->GLOBAL_CAP = apply_filters( 'jetpack_publicize_global_connections_cap', $this->GLOBAL_CAP );
// stage 1 and 2 of 3-stage Publicize. Flag for Publicize on creation, save meta,
// then check meta and publicize based on that. stage 3 implemented on wpcom
add_action( 'transition_post_status', array( $this, 'flag_post_for_publicize' ), 10, 3 );
add_action( 'save_post', array( &$this, 'save_meta' ), 20, 2 );
// Connection test callback
add_action( 'wp_ajax_test_publicize_conns', array( $this, 'test_publicize_conns' ) );
}
/**
* Functions to be implemented by the extended class (publicize-wpcom or publicize-jetpack)
*/
abstract function get_connection_id( $connection );
abstract function connect_url( $service_name );
abstract function disconnect_url( $service_name, $id );
abstract function get_connection_meta( $connection );
abstract function get_services( $filter );
abstract function get_connections( $service, $_blog_id = false, $_user_id = false );
abstract function get_connection( $service, $id, $_blog_id = false, $_user_id = false );
abstract function flag_post_for_publicize( $new_status, $old_status, $post );
abstract function test_connection( $service_name, $connection );
abstract function disconnect( $service, $connection_id, $_blog_id = false, $_user_id = false, $force_delete = false );
/**
* Shared Functions
*/
/**
* Returns an external URL to the connection's profile
*/
function get_profile_link( $service_name, $c ) {
$cmeta = $this->get_connection_meta( $c );
if ( isset( $cmeta['connection_data']['meta']['link'] ) ) {
if ( 'facebook' == $service_name && 0 === strpos( parse_url( $cmeta['connection_data']['meta']['link'], PHP_URL_PATH ), '/app_scoped_user_id/' ) ) {
// App-scoped Facebook user IDs are not usable profile links
return false;
}
return $cmeta['connection_data']['meta']['link'];
} elseif ( 'facebook' == $service_name && isset( $cmeta['connection_data']['meta']['facebook_page'] ) ) {
return 'https://facebook.com/' . $cmeta['connection_data']['meta']['facebook_page'];
} elseif ( 'tumblr' == $service_name && isset( $cmeta['connection_data']['meta']['tumblr_base_hostname'] ) ) {
return 'http://' . $cmeta['connection_data']['meta']['tumblr_base_hostname'];
} elseif ( 'twitter' == $service_name ) {
return 'https://twitter.com/' . substr( $cmeta['external_display'], 1 ); // Has a leading '@'
} elseif ( 'google_plus' == $service_name && isset( $cmeta['connection_data']['meta']['google_plus_page'] ) ) {
return 'https://plus.google.com/' . $cmeta['connection_data']['meta']['google_plus_page'];
} elseif ( 'google_plus' == $service_name ) {
return 'https://plus.google.com/' . $cmeta['external_id'];
} else if ( 'linkedin' == $service_name ) {
if ( !isset( $cmeta['connection_data']['meta']['profile_url'] ) ) {
return false;
}
$profile_url_query = parse_url( $cmeta['connection_data']['meta']['profile_url'], PHP_URL_QUERY );
wp_parse_str( $profile_url_query, $profile_url_query_args );
if ( isset( $profile_url_query_args['key'] ) ) {
$id = $profile_url_query_args['key'];
} elseif ( isset( $profile_url_query_args['id'] ) ) {
$id = $profile_url_query_args['id'];
} else {
return false;
}
return esc_url_raw( add_query_arg( 'id', urlencode( $id ), 'http://www.linkedin.com/profile/view' ) );
} else {
return false; // no fallback. we just won't link it
}
}
/**
* Returns a display name for the connection
*/
function get_display_name( $service_name, $c ) {
$cmeta = $this->get_connection_meta( $c );
if ( isset( $cmeta['connection_data']['meta']['display_name'] ) ) {
return $cmeta['connection_data']['meta']['display_name'];
} elseif ( $service_name == 'tumblr' && isset( $cmeta['connection_data']['meta']['tumblr_base_hostname'] ) ) {
return $cmeta['connection_data']['meta']['tumblr_base_hostname'];
} elseif ( $service_name == 'twitter' ) {
return $cmeta['external_display'];
} else {
$connection_display = $cmeta['external_display'];
if ( empty( $connection_display ) )
$connection_display = $cmeta['external_name'];
return $connection_display;
}
}
public static function get_service_label( $service_name ) {
switch ( $service_name ) {
case 'linkedin':
return 'LinkedIn';
break;
case 'google_plus':
return 'Google+';
break;
case 'twitter':
case 'facebook':
case 'tumblr':
default:
return ucfirst( $service_name );
break;
}
}
function show_options_popup( $service_name, $c ) {
$cmeta = $this->get_connection_meta( $c );
// always show if no selection has been made for facebook
if ( 'facebook' == $service_name && empty( $cmeta['connection_data']['meta']['facebook_profile'] ) && empty( $cmeta['connection_data']['meta']['facebook_page'] ) )
return true;
// always show if no selection has been made for tumblr
if ( 'tumblr' == $service_name && empty ( $cmeta['connection_data']['meta']['tumblr_base_hostname'] ) )
return true;
// if we have the specific connection info..
if ( isset( $_GET['id'] ) ) {
if ( $cmeta['connection_data']['id'] == $_GET['id'] )
return true;
} else {
// otherwise, just show if this is the completed step / first load
if ( !empty( $_GET['action'] ) && 'completed' == $_GET['action'] && !empty( $_GET['service'] ) && $service_name == $_GET['service'] && ! in_array( $_GET['service'], array( 'facebook', 'tumblr' ) ) )
return true;
}
return false;
}
function user_id() {
global $current_user;
return $current_user->ID;
}
function blog_id() {
return get_current_blog_id();
}
/**
* Returns true if a user has a connection to a particular service, false otherwise
*/
function is_enabled( $service, $_blog_id = false, $_user_id = false ) {
if ( !$_blog_id )
$_blog_id = $this->blog_id();
if ( !$_user_id )
$_user_id = $this->user_id();
$connections = $this->get_connections( $service, $_blog_id, $_user_id );
return ( is_array( $connections ) && count( $connections ) > 0 ? true : false );
}
/**
* Fires when a post is saved, checks conditions and saves state in postmeta so that it
* can be picked up later by @see ::publicize_post()
*/
function save_meta( $post_id, $post ) {
$cron_user = null;
$submit_post = true;
if ( ! $this->post_type_is_publicizeable( $post->post_type ) )
return;
// Don't Publicize during certain contexts:
// - import
if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
$submit_post = false;
}
// - on quick edit, autosave, etc but do fire on p2, quickpress, and instapost ajax
if (
defined( 'DOING_AJAX' )
&&
DOING_AJAX
&&
!did_action( 'p2_ajax' )
&&
!did_action( 'wp_ajax_json_quickpress_post' )
&&
!did_action( 'wp_ajax_instapost_publish' )
&&
!did_action( 'wp_ajax_post_reblog' )
) {
$submit_post = false;
}
// - bulk edit
if ( isset( $_GET['bulk_edit'] ) ) {
$submit_post = false;
}
// - API/XML-RPC Test Posts
if (
(
defined( 'XMLRPC_REQUEST' )
&&
XMLRPC_REQUEST
||
defined( 'APP_REQUEST' )
&&
APP_REQUEST
)
&&
0 === strpos( $post->post_title, 'Temporary Post Used For Theme Detection' )
) {
$submit_post = false;
}
// only work with certain statuses (avoids inherits, auto drafts etc)
if ( !in_array( $post->post_status, array( 'publish', 'draft', 'future' ) ) ) {
$submit_post = false;
}
// don't publish password protected posts
if ( '' !== $post->post_password ) {
$submit_post = false;
}
// Did this request happen via wp-admin?
$from_web = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST[$this->ADMIN_PAGE] );
if ( ( $from_web || defined( 'POST_BY_EMAIL' ) ) && isset( $_POST['wpas_title'] ) ) {
if ( empty( $_POST['wpas_title'] ) ) {
delete_post_meta( $post_id, $this->POST_MESS );
} else {
update_post_meta( $post_id, $this->POST_MESS, trim( stripslashes( $_POST['wpas_title'] ) ) );
}
}
// change current user to provide context for get_services() if we're running during cron
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
$cron_user = (int) $GLOBALS['user_ID'];
wp_set_current_user( $post->post_author );
}
/**
* In this phase, we mark connections that we want to SKIP. When Publicize is actually triggered,
* it will Publicize to everything *except* those marked for skipping.
*/
foreach ( (array) $this->get_services( 'connected' ) as $service_name => $connections ) {
foreach ( $connections as $connection ) {
$connection_data = '';
if ( method_exists( $connection, 'get_meta' ) )
$connection_data = $connection->get_meta( 'connection_data' );
elseif ( ! empty( $connection['connection_data'] ) )
$connection_data = $connection['connection_data'];
/** This action is documented in modules/publicize/ui.php */
if ( false == apply_filters( 'wpas_submit_post?', $submit_post, $post_id, $service_name, $connection_data ) ) {
delete_post_meta( $post_id, $this->PENDING );
continue;
}
if ( !empty( $connection->unique_id ) )
$unique_id = $connection->unique_id;
else if ( !empty( $connection['connection_data']['token_id'] ) )
$unique_id = $connection['connection_data']['token_id'];
// This was a wp-admin request, so we need to check the state of checkboxes
if ( $from_web ) {
// delete stray service-based post meta
delete_post_meta( $post_id, $this->POST_SKIP . $service_name );
// We *unchecked* this stream from the admin page, or it's set to readonly, or it's a new addition
if ( empty( $_POST[$this->ADMIN_PAGE]['submit'][$unique_id] ) ) {
// Also make sure that the service-specific input isn't there.
// If the user connected to a new service 'in-page' then a hidden field with the service
// name is added, so we just assume they wanted to Publicize to that service.
if ( empty( $_POST[$this->ADMIN_PAGE]['submit'][$service_name] ) ) {
// Nothing seems to be checked, so we're going to mark this one to be skipped
update_post_meta( $post_id, $this->POST_SKIP . $unique_id, 1 );
continue;
} else {
// clean up any stray post meta
delete_post_meta( $post_id, $this->POST_SKIP . $unique_id );
}
} else {
// The checkbox for this connection is explicitly checked -- make sure we DON'T skip it
delete_post_meta( $post_id, $this->POST_SKIP . $unique_id );
}
}
/**
* Fires right before the post is processed for Publicize.
* Users may hook in here and do anything else they need to after meta is written,
* and before the post is processed for Publicize.
*
* @since 2.1.2
*
* @param bool $submit_post Should the post be publicized.
* @param int $post->ID Post ID.
* @param string $service_name Service name.
* @param array $connection Array of connection details.
*/
do_action( 'publicize_save_meta', $submit_post, $post_id, $service_name, $connection );
}
}
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
wp_set_current_user( $cron_user );
}
// Next up will be ::publicize_post()
}
/**
* Is a given post type Publicize-able?
*
* Not every CPT lends itself to Publicize-ation. Allow CPTs to register by adding their CPT via
* the publicize_post_types array filter.
*
* @param string $post_type The post type to check.
* $return bool True if the post type can be Publicized.
*/
function post_type_is_publicizeable( $post_type ) {
if ( 'post' == $post_type )
return true;
return post_type_supports( $post_type, 'publicize' );
}
/**
* Runs tests on all the connections and returns the results to the caller
*/
function test_publicize_conns() {
$test_results = array();
foreach ( (array) $this->get_services( 'connected' ) as $service_name => $connections ) {
foreach ( $connections as $connection ) {
$id = $this->get_connection_id( $connection );
$connection_test_passed = true;
$connection_test_message = __( 'This connection is working correctly.' , 'jetpack' );
$user_can_refresh = false;
$refresh_text = '';
$refresh_url = '';
$connection_test_result = true;
if ( method_exists( $this, 'test_connection' ) ) {
$connection_test_result = $this->test_connection( $service_name, $connection );
}
if ( is_wp_error( $connection_test_result ) ) {
$connection_test_passed = false;
$connection_test_message = $connection_test_result->get_error_message();
$error_data = $connection_test_result->get_error_data();
$user_can_refresh = $error_data['user_can_refresh'];
$refresh_text = $error_data['refresh_text'];
$refresh_url = $error_data['refresh_url'];
}
$test_results[] = array(
'connectionID' => $id,
'serviceName' => $service_name,
'connectionTestPassed' => $connection_test_passed,
'connectionTestMessage' => esc_attr( $connection_test_message ),
'userCanRefresh' => $user_can_refresh,
'refreshText' => esc_attr( $refresh_text ),
'refreshURL' => $refresh_url
);
}
}
wp_send_json_success( $test_results );
}
}

View file

@ -0,0 +1,764 @@
<?php
/**
* Only user facing pieces of Publicize are found here.
*/
class Publicize_UI {
/**
* Contains an instance of class 'publicize' which loads Keyring, sets up services, etc.
*/
public $publicize;
/**
* Hooks into WordPress to display the various pieces of UI and load our assets
*/
function __construct() {
global $publicize;
$this->publicize = $publicize = new Publicize;
add_action( 'init', array( $this, 'init' ) );
}
function init() {
// Show only to users with the capability required to manage their Publicize connections.
if ( ! current_user_can( 'publish_posts' ) ) {
return;
}
// assets (css, js)
add_action( 'load-settings_page_sharing', array( &$this, 'load_assets' ) );
add_action( 'admin_head-post.php', array( &$this, 'post_page_metabox_assets' ) );
add_action( 'admin_head-post-new.php', array( &$this, 'post_page_metabox_assets' ) );
// management of publicize (sharing screen, ajax/lightbox popup, and metabox on post screen)
add_action( 'pre_admin_screen_sharing', array( &$this, 'admin_page' ) );
add_action( 'post_submitbox_misc_actions', array( &$this, 'post_page_metabox' ) );
}
/**
* If the ShareDaddy plugin is not active we need to add the sharing settings page to the menu still
*/
function sharing_menu() {
add_submenu_page( 'options-general.php', __( 'Sharing Settings', 'jetpack' ), __( 'Sharing', 'jetpack' ), 'publish_posts', 'sharing', array( &$this, 'management_page' ) );
}
/**
* Management page to load if Sharedaddy is not active so the 'pre_admin_screen_sharing' action exists.
*/
function management_page() { ?>
<div class="wrap">
<div class="icon32" id="icon-options-general"><br /></div>
<h1><?php _e( 'Sharing Settings', 'jetpack' ); ?></h1>
<?php
/** This action is documented in modules/sharedaddy/sharing.php */
do_action( 'pre_admin_screen_sharing' );
?>
</div> <?php
}
/**
* styling for the sharing screen and popups
* JS for the options and switching
*/
function load_assets() {
wp_enqueue_script(
'publicize',
plugins_url( 'assets/publicize.js', __FILE__ ),
array( 'jquery', 'thickbox' ),
'20121019'
);
if( is_rtl() ) {
wp_enqueue_style( 'publicize', plugins_url( 'assets/rtl/publicize-rtl.css', __FILE__ ), array(), '20120925' );
} else {
wp_enqueue_style( 'publicize', plugins_url( 'assets/publicize.css', __FILE__ ), array(), '20120925' );
}
add_thickbox();
}
public static function connected_notice( $service_name ) { ?>
<div class='updated'>
<p><?php
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
$platform = __( 'WordPress.com', 'jetpack' );
} else {
$platform = __( 'Jetpack', 'jetpack' );
}
printf(
__( 'You have successfully connected your %1$s account with %2$s.', '1: Service Name (Facebook, Twitter, ...), 2. WordPress.com or Jetpack', 'jetpack' ),
Publicize::get_service_label( $service_name ),
$platform
); ?></p>
</div><?php
}
public static function denied_notice() { ?>
<div class='updated'>
<p><?php _e ( "You have chosen not to connect your blog. Please click 'accept' when prompted if you wish to connect your accounts.", 'jetpack' ); ?></p>
</div><?php
}
/**
* Lists the current user's publicized accounts for the blog
* looks exactly like Publicize v1 for now, UI and functionality updates will come after the move to keyring
*/
function admin_page() {
$_blog_id = get_current_blog_id();
?>
<form action="" id="publicize-form">
<h2 id="publicize"><?php _e( 'Publicize', 'jetpack' ) ?></h2>
<?php
if ( ! empty( $_GET['action'] ) && 'deny' == $_GET['action'] ) {
$this->denied_notice();
}
?>
<p>
<?php esc_html_e( 'Connect your blog to popular social networking sites and automatically share new posts with your friends.', 'jetpack' ) ?>
<?php esc_html_e( 'You can make a connection for just yourself or for all users on your blog. Shared connections are marked with the (Shared) text.', 'jetpack' ); ?>
</p>
<?php
if ( $this->in_jetpack ) {
$doc_link = "http://jetpack.com/support/publicize/";
} else {
$doc_link = "http://en.support.wordpress.com/publicize/";
}
?>
<p>&rarr; <a href="<?php echo esc_url( $doc_link ); ?>" target="_blank"><?php esc_html_e( 'More information on using Publicize.', 'jetpack' ); ?></a></p>
<div id="publicize-services-block">
<?php
$services = $this->publicize->get_services( 'all' );
$total_num_of_services = count ( $services );
$service_num = 0;?>
<div class='left'>
<?php
foreach ( $services as $name => $service ) :
$connect_url = $this->publicize->connect_url( $name );
if ( $service_num == ( round ( ( $total_num_of_services / 2 ), 0 ) ) )
echo "</div><div class='right'>";
$service_num++;
?>
<div class="publicize-service-entry" <?php if ( $service_num > 0 ): ?>class="connected"<?php endif; ?> >
<div id="<?php echo esc_attr( $name ); ?>" class="publicize-service-left">
<a href="<?php echo esc_url( $connect_url ); ?>" id="service-link-<?php echo esc_attr( $name ); ?>" target="_top"><?php echo $this->publicize->get_service_label( $name ); ?></a>
</div>
<div class="publicize-service-right">
<?php if ( $this->publicize->is_enabled( $name ) && $connections = $this->publicize->get_connections( $name ) ) : ?>
<ul>
<?php
foreach( $connections as $c ) :
$id = $this->publicize->get_connection_id( $c );
$disconnect_url = $this->publicize->disconnect_url( $name, $id );
$cmeta = $this->publicize->get_connection_meta( $c );
$profile_link = $this->publicize->get_profile_link( $name, $c );
$connection_display = $this->publicize->get_display_name( $name, $c );
$options_nonce = wp_create_nonce( 'options_page_' . $name . '_' . $id ); ?>
<?php if ( $this->publicize->show_options_popup( $name, $c ) ): ?>
<script type="text/javascript">
jQuery(document).ready( function($) {
showOptionsPage.call(
this,
'<?php echo esc_js( $name ); ?>',
'<?php echo esc_js( $options_nonce ); ?>',
'<?php echo esc_js( $id ); ?>'
);
} );
</script>
<?php endif; ?>
<li class="publicize-connection" data-connection-id="<?php echo esc_attr( $id ); ?>">
<?php esc_html_e( 'Connected as:', 'jetpack' ); ?>
<?php
if ( !empty( $profile_link ) ) : ?>
<a class="publicize-profile-link" href="<?php echo esc_url( $profile_link ); ?>" target="_top">
<?php echo esc_html( $connection_display ); ?>
</a><?php
else :
echo esc_html( $connection_display );
endif;
?>
<?php if ( 0 == $cmeta['connection_data']['user_id'] ) : ?>
<small>(<?php esc_html_e( 'Shared', 'jetpack' ); ?>)</small>
<?php if ( current_user_can( $this->publicize->GLOBAL_CAP ) ) : ?>
<a class="pub-disconnect-button" title="<?php esc_html_e( 'Disconnect', 'jetpack' ); ?>" href="<?php echo esc_url( $disconnect_url ); ?>" target="_top">×</a>
<?php endif; ?>
<?php else : ?>
<a class="pub-disconnect-button" title="<?php esc_html_e( 'Disconnect', 'jetpack' ); ?>" href="<?php echo esc_url( $disconnect_url ); ?>" target="_top">×</a>
<?php endif; ?>
<br/>
<div class="pub-connection-test test-in-progress" id="pub-connection-test-<?php echo esc_attr( $id ); ?>" >
</div>
</li>
<?php
endforeach;
?>
</ul>
<?php endif; ?>
<?php
$connections = $this->publicize->get_connections( $name );
if ( empty ( $connections ) ) { ?>
<a id="<?php echo esc_attr( $name ); ?>" class="publicize-add-connection button" href="<?php echo esc_url( $connect_url ); ?>" target="_top"><?php echo esc_html( __( 'Connect', 'jetpack' ) ); ?></a>
<?php } else { ?>
<a id="<?php echo esc_attr( $name ); ?>" class="publicize-add-connection button add-new" href="<?php echo esc_url( $connect_url ); ?>" target="_top"><?php echo esc_html( __( 'Add New', 'jetpack' ) ); ?></a>
<?php } ?>
</div>
</div>
<?php endforeach; ?>
</div>
<script>
(function($){
$('.pub-disconnect-button').on('click', function(e){ if ( confirm( '<?php echo esc_js( __( 'Are you sure you want to stop Publicizing posts to this connection?', 'jetpack' ) ); ?>' ) ) {
return true;
} else {
e.preventDefault();
return false;
}
})
})(jQuery);
</script>
</div>
<?php wp_nonce_field( "wpas_posts_{$_blog_id}", "_wpas_posts_{$_blog_id}_nonce" ); ?>
<input type="hidden" id="wpas_ajax_blog_id" name="wpas_ajax_blog_id" value="<?php echo $_blog_id; ?>" />
</form><?php
}
public static function global_checkbox( $service_name, $id ) {
global $publicize;
if ( current_user_can( $publicize->GLOBAL_CAP ) ) : ?>
<p>
<input id="globalize_<?php echo $service_name; ?>" type="checkbox" name="global" value="<?php echo wp_create_nonce( 'publicize-globalize-' . $id ) ?>" />
<label for="globalize_<?php echo $service_name; ?>"><?php _e( 'Make this connection available to all users of this blog?', 'jetpack' ); ?></label>
</p>
<?php endif;
}
function broken_connection( $service_name, $id ) { ?>
<div id="thickbox-content">
<div class='error'>
<p><?php printf( __( 'There was a problem connecting to %s. Please disconnect and try again.', 'jetpack' ), Publicize::get_service_label( $service_name ) ); ?></p>
</div>
</div><?php
}
public static function options_page_other( $service_name ) {
// Nonce check
check_admin_referer( "options_page_{$service_name}_" . $_REQUEST['connection'] );
?>
<div id="thickbox-content">
<?php
ob_start();
Publicize_UI::connected_notice( $service_name );
$update_notice = ob_get_clean();
if ( ! empty( $update_notice ) )
echo $update_notice;
?>
<?php Publicize_UI::global_checkbox( $service_name, $_REQUEST['connection'] ); ?>
<p style="text-align: center;">
<input type="submit" value="<?php esc_attr_e( 'OK', 'jetpack' ) ?>" class="button <?php echo $service_name; ?>-options save-options" name="save" data-connection="<?php echo esc_attr( $_REQUEST['connection'] ); ?>" rel="<?php echo wp_create_nonce( 'save_'.$service_name.'_token_' . $_REQUEST['connection'] ) ?>" />
</p> <br />
</div>
<?php
}
/**
* CSS for styling the publicize message box and counter that displays on the post page.
* There is also some JavaScript for length counting and some basic display effects.
*/
function post_page_metabox_assets() {
global $post;
$user_id = empty( $post->post_author ) ? $GLOBALS['user_ID'] : $post->post_author;
$default_prefix = $this->publicize->default_prefix;
$default_prefix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_prefix ) );
$default_message = $this->publicize->default_message;
$default_message = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_message ) );
$default_suffix = $this->publicize->default_suffix;
$default_suffix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_suffix ) ); ?>
<script type="text/javascript">
jQuery( function($) {
var wpasTitleCounter = $( '#wpas-title-counter' ),
wpasTwitterCheckbox = $( '.wpas-submit-twitter' ).size(),
wpasTitle = $('#wpas-title').keyup( function() {
var length = wpasTitle.val().length;
wpasTitleCounter.text( length );
if ( wpasTwitterCheckbox && length > 140 ) {
wpasTitleCounter.addClass( 'wpas-twitter-length-limit' );
} else {
wpasTitleCounter.removeClass( 'wpas-twitter-length-limit' );
}
} ),
authClick = false;
$('#publicize-disconnected-form-show').click( function() {
$('#publicize-form').slideDown( 'fast' );
$(this).hide();
} );
$('#publicize-disconnected-form-hide').click( function() {
$('#publicize-form').slideUp( 'fast' );
$('#publicize-disconnected-form-show').show();
} );
$('#publicize-form-edit').click( function() {
$('#publicize-form').slideDown( 'fast', function() {
wpasTitle.focus();
if ( !wpasTitle.text() ) {
var url = $('#shortlink').size() ? $('#shortlink').val() : '';
var defaultMessage = $.trim( '<?php printf( $default_prefix, 'url' ); printf( $default_message, '$("#title").val()', 'url' ); printf( $default_suffix, 'url' ); ?>' );
wpasTitle.append( defaultMessage.replace( /<[^>]+>/g,'') );
var selBeg = defaultMessage.indexOf( $("#title").val() );
if ( selBeg < 0 ) {
selBeg = 0;
selEnd = 0;
} else {
selEnd = selBeg + $("#title").val().length;
}
var domObj = wpasTitle.get(0);
if ( domObj.setSelectionRange ) {
domObj.setSelectionRange( selBeg, selEnd );
} else if ( domObj.createTextRange ) {
var r = domObj.createTextRange();
r.moveStart( 'character', selBeg );
r.moveEnd( 'character', selEnd );
r.select();
}
}
wpasTitle.keyup();
} );
$('#publicize-defaults').hide();
$(this).hide();
return false;
} );
$('#publicize-form-hide').click( function() {
var newList = $.map( $('#publicize-form').slideUp( 'fast' ).find( ':checked' ), function( el ) {
return $.trim( $(el).parent( 'label' ).text() );
} );
$('#publicize-defaults').html( '<strong>' + newList.join( '</strong>, <strong>' ) + '</strong>' ).show();
$('#publicize-form-edit').show();
return false;
} );
$('.authorize-link').click( function() {
if ( authClick ) {
return false;
}
authClick = true;
$(this).after( '<img src="images/loading.gif" class="alignleft" style="margin: 0 .5em" />' );
$.ajaxSetup( { async: false } );
if ( window.wp && window.wp.autosave ) {
window.wp.autosave.server.triggerSave();
} else {
autosave();
}
return true;
} );
$( '.pub-service' ).click( function() {
var service = $(this).data( 'service' ),
fakebox = '<input id="wpas-submit-' + service + '" type="hidden" value="1" name="wpas[submit][' + service + ']" />';
$( '#add-publicize-check' ).append( fakebox );
} );
publicizeConnTestStart = function() {
$( '#pub-connection-tests' )
.removeClass( 'below-h2' )
.removeClass( 'error' )
.removeClass( 'publicize-token-refresh-message' )
.addClass( 'test-in-progress' )
.html( '' );
$.post( ajaxurl, { action: 'test_publicize_conns' }, publicizeConnTestComplete );
}
publicizeConnRefreshClick = function( event ) {
event.preventDefault();
var popupURL = event.currentTarget.href;
var popupTitle = event.currentTarget.title;
// open a popup window
// when it is closed, kick off the tests again
var popupWin = window.open( popupURL, popupTitle, '' );
var popupWinTimer= window.setInterval( function() {
if ( popupWin.closed !== false ) {
window.clearInterval( popupWinTimer );
publicizeConnTestStart();
}
}, 500 );
}
publicizeConnTestComplete = function( response ) {
var testsSelector = $( '#pub-connection-tests' );
testsSelector
.removeClass( 'test-in-progress' )
.removeClass( 'below-h2' )
.removeClass( 'error' )
.removeClass( 'publicize-token-refresh-message' )
.html( '' );
// If any of the tests failed, show some stuff
var somethingShownAlready = false;
$.each( response.data, function( index, testResult ) {
// find the li for this connection
if ( ! testResult.connectionTestPassed ) {
if ( ! somethingShownAlready ) {
testsSelector
.addClass( 'below-h2' )
.addClass( 'error' )
.addClass( 'publicize-token-refresh-message' )
.append( "<p><?php echo esc_html( __( 'Before you hit Publish, please refresh the following connection(s) to make sure we can Publicize your post:', 'jetpack' ) ); ?></p>" );
somethingShownAlready = true;
}
if ( testResult.userCanRefresh ) {
testsSelector.append( '<p/>' );
$( '<a/>', {
'class' : 'pub-refresh-button button',
'title' : testResult.refreshText,
'href' : testResult.refreshURL,
'text' : testResult.refreshText,
'target' : '_refresh_' + testResult.serviceName
} )
.appendTo( testsSelector.children().last() )
.click( publicizeConnRefreshClick );
}
}
} );
}
$( document ).ready( function() {
// If we have the #pub-connection-tests div present, kick off the connection test
if ( $( '#pub-connection-tests' ).length ) {
publicizeConnTestStart();
}
} );
} );
</script>
<style type="text/css">
#publicize {
line-height: 1.5;
}
#publicize ul {
margin: 4px 0 4px 6px;
}
#publicize li {
margin: 0;
}
#publicize textarea {
margin: 4px 0 0;
width: 100%
}
#publicize ul.not-connected {
list-style: square;
padding-left: 1em;
}
.post-new-php .authorize-link, .post-php .authorize-link {
line-height: 1.5em;
}
.post-new-php .authorize-message, .post-php .authorize-message {
margin-bottom: 0;
}
#poststuff #publicize .updated p {
margin: .5em 0;
}
.wpas-twitter-length-limit {
color: red;
}
</style><?php
}
/**
* Controls the metabox that is displayed on the post page
* Allows the user to customize the message that will be sent out to the social network, as well as pick which
* networks to publish to. Also displays the character counter and some other information.
*/
function post_page_metabox() {
global $post;
if ( ! $this->publicize->post_type_is_publicizeable( $post->post_type ) )
return;
$user_id = empty( $post->post_author ) ? $GLOBALS['user_ID'] : $post->post_author;
$services = $this->publicize->get_services( 'connected' );
$available_services = $this->publicize->get_services( 'all' );
if ( ! is_array( $available_services ) )
$available_services = array();
if ( ! is_array( $services ) )
$services = array();
$active = array(); ?>
<div id="publicize" class="misc-pub-section misc-pub-section-last">
<?php
_e( 'Publicize:', 'jetpack' );
if ( 0 < count( $services ) ) :
ob_start();
?>
<div id="publicize-form" class="hide-if-js">
<ul>
<?php
// We can set an _all flag to indicate that this post is completely done as
// far as Publicize is concerned. Jetpack uses this approach. All published posts in Jetpack
// have Publicize disabled.
$all_done = get_post_meta( $post->ID, $this->publicize->POST_DONE . 'all', true ) || ( $this->in_jetpack && 'publish' == $post->post_status );
// We don't allow Publicizing to the same external id twice, to prevent spam
$service_id_done = (array) get_post_meta( $post->ID, $this->publicize->POST_SERVICE_DONE, true );
foreach ( $services as $name => $connections ) {
foreach ( $connections as $connection ) {
$connection_data = '';
if ( method_exists( $connection, 'get_meta' ) )
$connection_data = $connection->get_meta( 'connection_data' );
elseif ( ! empty( $connection['connection_data'] ) )
$connection_data = $connection['connection_data'];
/**
* Filter whether a post should be publicized to a given service.
*
* @module publicize
*
* @since 2.0.0
*
* @param bool true Should the post be publicized to a given service? Default to true.
* @param int $post->ID Post ID.
* @param string $name Service name.
* @param array $connection_data Array of information about all Publicize details for the site.
*/
if ( ! $continue = apply_filters( 'wpas_submit_post?', true, $post->ID, $name, $connection_data ) ) {
continue;
}
if ( ! empty( $connection->unique_id ) ) {
$unique_id = $connection->unique_id;
} else if ( ! empty( $connection['connection_data']['token_id'] ) ) {
$unique_id = $connection['connection_data']['token_id'];
}
// Should we be skipping this one?
$skip = (
(
in_array( $post->post_status, array( 'publish', 'draft', 'future' ) )
&&
get_post_meta( $post->ID, $this->publicize->POST_SKIP . $unique_id, true )
)
||
(
is_array( $connection )
&&
(
( isset( $connection['meta']['external_id'] ) && ! empty( $service_id_done[ $name ][ $connection['meta']['external_id'] ] ) )
||
// Jetpack's connection data looks a little different.
( isset( $connection['external_id'] ) && ! empty( $service_id_done[ $name ][ $connection['external_id'] ] ) )
)
)
);
// Was this connections (OR, old-format service) already Publicized to?
$done = ( 1 == get_post_meta( $post->ID, $this->publicize->POST_DONE . $unique_id, true ) || 1 == get_post_meta( $post->ID, $this->publicize->POST_DONE . $name, true ) ); // New and old style flags
// If this one has already been publicized to, don't let it happen again
$disabled = '';
if ( $done )
$disabled = ' disabled="disabled"';
// If this is a global connection and this user doesn't have enough permissions to modify
// those connections, don't let them change it
$cmeta = $this->publicize->get_connection_meta( $connection );
$hidden_checkbox = false;
if ( !$done && ( 0 == $cmeta['connection_data']['user_id'] && !current_user_can( $this->publicize->GLOBAL_CAP ) ) ) {
$disabled = ' disabled="disabled"';
/**
* Filters the checkboxes for global connections with non-prilvedged users.
*
* @module publicize
*
* @since 3.7.0
*
* @param bool $checked Indicates if this connection should be enabled. Default true.
* @param int $post->ID ID of the current post
* @param string $name Name of the connection (Facebook, Twitter, etc)
* @param array $connection Array of data about the connection.
*/
$hidden_checkbox = apply_filters( 'publicize_checkbox_global_default', true, $post->ID, $name, $connection );
}
// Determine the state of the checkbox (on/off) and allow filtering
$checked = $skip != 1 || $done;
/**
* Filter the checkbox state of each Publicize connection appearing in the post editor.
*
* @module publicize
*
* @since 2.0.1
*
* @param bool $checked Should the Publicize checkbox be enabled for a given service.
* @param int $post->ID Post ID.
* @param string $name Service name.
* @param array $connection Array of connection details.
*/
$checked = apply_filters( 'publicize_checkbox_default', $checked, $post->ID, $name, $connection );
// Force the checkbox to be checked if the post was DONE, regardless of what the filter does
if ( $done ) {
$checked = true;
}
// This post has been handled, so disable everything
if ( $all_done ) {
$disabled = ' disabled="disabled"';
}
$label = sprintf(
_x( '%1$s: %2$s', 'Service: Account connected as', 'jetpack' ),
esc_html( $this->publicize->get_service_label( $name ) ),
esc_html( $this->publicize->get_display_name( $name, $connection ) )
);
if ( !$skip || $done ) {
$active[] = $label;
}
?>
<li>
<label for="wpas-submit-<?php echo esc_attr( $unique_id ); ?>">
<input type="checkbox" name="wpas[submit][<?php echo $unique_id; ?>]" id="wpas-submit-<?php echo $unique_id; ?>" class="wpas-submit-<?php echo $name; ?>" value="1" <?php
checked( true, $checked );
echo $disabled;
?> />
<?php
if ( $hidden_checkbox ) {
// Need to submit a value to force a global connection to post
echo '<input type="hidden" name="wpas[submit][' . $unique_id . ']" value="1" />';
}
echo esc_html( $label );
?>
</label>
</li>
<?php
}
}
if ( $title = get_post_meta( $post->ID, $this->publicize->POST_MESS, true ) ) {
$title = esc_html( $title );
} else {
$title = '';
}
?>
</ul>
<label for="wpas-title"><?php _e( 'Custom Message:', 'jetpack' ); ?></label>
<span id="wpas-title-counter" class="alignright hide-if-no-js">0</span>
<textarea name="wpas_title" id="wpas-title"<?php disabled( $all_done ); ?>><?php echo $title; ?></textarea>
<a href="#" class="hide-if-no-js" id="publicize-form-hide"><?php _e( 'Hide', 'jetpack' ); ?></a>
<input type="hidden" name="wpas[0]" value="1" />
</div>
<div id="pub-connection-tests"></div>
<?php // #publicize-form
$publicize_form = ob_get_clean();
else :
echo "&nbsp;" . __( 'Not Connected', 'jetpack' );
ob_start();
?>
<div id="publicize-form" class="hide-if-js">
<div id="add-publicize-check" style="display: none;"></div>
<strong><?php _e( 'Connect to', 'jetpack' ); ?>:</strong>
<ul class="not-connected">
<?php foreach ( $available_services as $service_name => $service ) : ?>
<li>
<a class="pub-service" data-service="<?php echo esc_attr( $service_name ); ?>" title="<?php echo esc_attr( sprintf( __( 'Connect and share your posts on %s', 'jetpack' ), $this->publicize->get_service_label( $service_name ) ) ); ?>" target="_blank" href="<?php echo $this->publicize->connect_url( $service_name ); ?>">
<?php echo esc_html( $this->publicize->get_service_label( $service_name ) ); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php if ( 0 < count( $services ) ) : ?>
<a href="#" class="hide-if-no-js" id="publicize-form-hide"><?php _e( 'Hide', 'jetpack' ); ?></a>
<?php else : ?>
<a href="#" class="hide-if-no-js" id="publicize-disconnected-form-hide"><?php _e( 'Hide', 'jetpack' ); ?></a>
<?php endif; ?>
</div> <?php // #publicize-form
$publicize_form = ob_get_clean();
endif;
?>
<span id="publicize-defaults"><strong><?php echo join( '</strong>, <strong>', array_map( 'esc_html', $active ) ); ?></strong></span><br />
<?php if ( 0 < count( $services ) ) : ?>
<a href="#" id="publicize-form-edit"><?php _e( 'Edit Details', 'jetpack' ); ?></a>&nbsp;<a href="<?php echo admin_url( 'options-general.php?page=sharing' ); ?>" target="_blank"><?php _e( 'Settings', 'jetpack' ); ?></a><br />
<?php else : ?>
<a href="#" id="publicize-disconnected-form-show"><?php _e( 'Show', 'jetpack' ); ?></a><br />
<?php endif; ?>
<?php
/**
* Filter the Publicize details form.
*
* @module publicize
*
* @since 2.0.0
*
* @param string $publicize_form Publicize Details form appearing above Publish button in the editor.
*/
echo apply_filters( 'publicize_form', $publicize_form );
?>
</div> <?php // #publicize
}
}