Retire Press This and extract it to a plugin. First run.

Props kraftbj, azaozz.
See #41689.
Built from https://develop.svn.wordpress.org/trunk@41584


git-svn-id: http://core.svn.wordpress.org/trunk@41417 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2017-09-24 14:22:54 +00:00
parent 400bc41731
commit a5f8097899
24 changed files with 147 additions and 7399 deletions

View File

@ -61,14 +61,15 @@ $core_actions_post = array(
'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail',
'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'press-this-save-post',
'press-this-add-category', 'crop-image', 'generate-password', 'save-wporg-username', 'delete-plugin',
'search-plugins', 'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme',
'install-theme', 'get-post-thumbnail-html', 'get-community-events',
'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'crop-image',
'generate-password', 'save-wporg-username', 'delete-plugin', 'search-plugins',
'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme', 'install-theme',
'get-post-thumbnail-html', 'get-community-events',
);
// Deprecated
$core_actions_post[] = 'wp-fullscreen-save-post';
$core_actions_post_deprecated = array( 'wp-fullscreen-save-post', 'press-this-save-post', 'press-this-add-category' );
$core_actions_post = array_merge( $core_actions_post, $core_actions_post_deprecated );
// Register core Ajax calls.
if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) )

View File

@ -1,122 +0,0 @@
/*
Press This TinyMCE editor styles :)
*/
/**
* Links
*/
a {
color: #0073aa;
}
a:visited {
color: #0073aa;
}
a:hover,
a:focus,
a:active {
color: #00a0d2;
}
/**
* Lists
*/
ul,
ol {
margin: 0 3em 1.5em 0;
}
ul {
list-style: disc;
}
ol {
list-style: decimal;
}
li > ul,
li > ol {
margin-bottom: 0;
margin-right: 1.5em;
}
dt {
font-weight: 700;
}
dd {
margin: 0 1.5em 1.5em;
}
/**
* Media
*
* Basic image and object styles
*/
img {
max-width: 100%;
height: auto;
}
/* Makes sure embeds and iframes fit inside their containers */
embed,
iframe,
object {
max-width: 100%;
}
/**
* TinyMCE styles
*
* Pretty dang good.
*/
body {
color: #404040;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 20px;
font-weight: 400;
line-height: 1.6;
}
@media (max-width: 900px) {
body#tinymce {
padding-top: 30px !important;
}
}
@media (max-width: 640px) {
body {
font-size: 16px;
}
}
@media (max-width: 320px) {
body {
margin: 0 15px;
}
}
#tinymce b,
#tinymce strong {
/* overrides TinyMCE's !important. Woohoo. */
font-weight: 700 !important;
}
blockquote {
margin: 1em 1.5em;
color: #9ea7af;
font-size: em(25px);
font-style: italic;
}
@media (max-width: 900px) {
blockquote {
margin: 1.5em 1em;
}
}
ul,
ol {
margin: 0 .75em 1.5em 0;
}

View File

@ -1,2 +0,0 @@
/*! This file is auto-generated */
embed,iframe,img,object{max-width:100%}a,a:visited{color:#0073aa}a:active,a:focus,a:hover{color:#00a0d2}ul{list-style:disc}ol{list-style:decimal}li>ol,li>ul{margin-bottom:0;margin-right:1.5em}dt{font-weight:700}dd{margin:0 1.5em 1.5em}img{height:auto}body{color:#404040;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:20px;font-weight:400;line-height:1.6}@media (max-width:640px){body{font-size:16px}}@media (max-width:320px){body{margin:0 15px}}#tinymce b,#tinymce strong{font-weight:700!important}blockquote{margin:1em 1.5em;color:#9ea7af;font-size:em(25px);font-style:italic}@media (max-width:900px){body#tinymce{padding-top:30px!important}blockquote{margin:1.5em 1em}}ol,ul{margin:0 .75em 1.5em 0}

View File

@ -1,122 +0,0 @@
/*
Press This TinyMCE editor styles :)
*/
/**
* Links
*/
a {
color: #0073aa;
}
a:visited {
color: #0073aa;
}
a:hover,
a:focus,
a:active {
color: #00a0d2;
}
/**
* Lists
*/
ul,
ol {
margin: 0 0 1.5em 3em;
}
ul {
list-style: disc;
}
ol {
list-style: decimal;
}
li > ul,
li > ol {
margin-bottom: 0;
margin-left: 1.5em;
}
dt {
font-weight: 700;
}
dd {
margin: 0 1.5em 1.5em;
}
/**
* Media
*
* Basic image and object styles
*/
img {
max-width: 100%;
height: auto;
}
/* Makes sure embeds and iframes fit inside their containers */
embed,
iframe,
object {
max-width: 100%;
}
/**
* TinyMCE styles
*
* Pretty dang good.
*/
body {
color: #404040;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 20px;
font-weight: 400;
line-height: 1.6;
}
@media (max-width: 900px) {
body#tinymce {
padding-top: 30px !important;
}
}
@media (max-width: 640px) {
body {
font-size: 16px;
}
}
@media (max-width: 320px) {
body {
margin: 0 15px;
}
}
#tinymce b,
#tinymce strong {
/* overrides TinyMCE's !important. Woohoo. */
font-weight: 700 !important;
}
blockquote {
margin: 1em 1.5em;
color: #9ea7af;
font-size: em(25px);
font-style: italic;
}
@media (max-width: 900px) {
blockquote {
margin: 1.5em 1em;
}
}
ul,
ol {
margin: 0 0 1.5em .75em;
}

View File

@ -1,2 +0,0 @@
/*! This file is auto-generated */
embed,iframe,img,object{max-width:100%}a,a:visited{color:#0073aa}a:active,a:focus,a:hover{color:#00a0d2}ul{list-style:disc}ol{list-style:decimal}li>ol,li>ul{margin-bottom:0;margin-left:1.5em}dt{font-weight:700}dd{margin:0 1.5em 1.5em}img{height:auto}body{color:#404040;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:20px;font-weight:400;line-height:1.6}@media (max-width:640px){body{font-size:16px}}@media (max-width:320px){body{margin:0 15px}}#tinymce b,#tinymce strong{font-weight:700!important}blockquote{margin:1em 1.5em;color:#9ea7af;font-size:em(25px);font-style:italic}@media (max-width:900px){body#tinymce{padding-top:30px!important}blockquote{margin:1.5em 1em}}ol,ul{margin:0 0 1.5em .75em}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -3188,28 +3188,6 @@ function wp_ajax_destroy_sessions() {
wp_send_json_success( array( 'message' => $message ) );
}
/**
* Ajax handler for saving a post from Press This.
*
* @since 4.2.0
*/
function wp_ajax_press_this_save_post() {
include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
$wp_press_this = new WP_Press_This();
$wp_press_this->save_post();
}
/**
* Ajax handler for creating new category from Press This.
*
* @since 4.2.0
*/
function wp_ajax_press_this_add_category() {
include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
$wp_press_this = new WP_Press_This();
$wp_press_this->add_category();
}
/**
* Ajax handler for cropping an image.
*

View File

@ -49,10 +49,13 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
$from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
if ( 'import' == $from )
if ( 'import' == $from ) {
$install_actions['activate_plugin'] = '<a class="button button-primary" href="' . wp_nonce_url( 'plugins.php?action=activate&amp;from=import&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin &amp; Run Importer' ) . '</a>';
else
} else if ( 'press-this' == $from ) {
$install_actions['activate_plugin'] = '<a class="button button-primary" href="' . wp_nonce_url( 'plugins.php?action=activate&amp;from=press-this&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin &amp; Return to Press This' ) . '</a>';
} else {
$install_actions['activate_plugin'] = '<a class="button button-primary" href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>';
}
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
$install_actions['network_activate'] = '<a class="button button-primary" href="' . wp_nonce_url( 'plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Network Activate' ) . '</a>';

File diff suppressed because it is too large Load Diff

View File

@ -719,6 +719,19 @@ $_old_files = array(
'wp-includes/js/plupload/plupload.full.min.js',
'wp-includes/js/swfupload/plugins',
'wp-includes/js/swfupload/swfupload.swf',
'wp-admin/css/press-this-editor.css',
'wp-admin/css/press-this-editor-rtl.css',
'wp-admin/css/press-this-editor-rtl.min.css',
'wp-admin/css/press-this-editor.min.css',
'wp-admin/css/press-this.css',
'wp-admin/css/press-this-rtl.css',
'wp-admin/css/press-this-rtl.min.css',
'wp-admin/css/press-this.min.css',
'wp-admin/includes/class-wp-press-this.php',
'wp-admin/js/press-this.js',
'wp-admin/js/press-this.min.js',
'wp-admin/js/bookmarklet.js',
'wp-admin/js/bookmarklet.min.js',
);
/**
@ -851,7 +864,7 @@ function update_core($from, $to) {
/*
* Import $wp_version, $required_php_version, and $required_mysql_version from the new version.
* DO NOT globalise any variables imported from `version-current.php` in this function.
* DO NOT globalise any variables imported from `version-current.php` in this function.
*
* BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8
*/

View File

@ -1,179 +0,0 @@
/**
* @summary Creates a form with a URL, title, and content based on the current opened URL and the content of the associated web page.
*
* @since 4.2.0
*
* @param {window} window The window.
* @param {document} document The document.
* @param {string} href The current opened URL.
* @param {string} pt_url The URL to post the content to.
*
* @returns {void}
*/
( function( window, document, href, pt_url ) {
var encURI = window.encodeURIComponent,
form = document.createElement( 'form' ),
head = document.getElementsByTagName( 'head' )[0],
target = '_press_this_app',
canPost = true,
windowWidth, windowHeight, selection,
metas, links, content, images, iframes, img;
if ( ! pt_url ) {
return;
}
if ( href.match( /^https?:/ ) ) {
pt_url += '&u=' + encURI( href );
// Check whether the unencoded url and the encoded url use the same protocol.
if ( href.match( /^https:/ ) && pt_url.match( /^http:/ ) ) {
canPost = false;
}
} else {
top.location.href = pt_url;
return;
}
if ( window.getSelection ) {
selection = window.getSelection() + '';
} else if ( document.getSelection ) {
selection = document.getSelection() + '';
} else if ( document.selection ) {
selection = document.selection.createRange().text || '';
}
pt_url += '&buster=' + ( new Date().getTime() );
if ( ! canPost ) {
if ( document.title ) {
pt_url += '&t=' + encURI( document.title.substr( 0, 256 ) );
}
if ( selection ) {
pt_url += '&s=' + encURI( selection.substr( 0, 512 ) );
}
}
windowWidth = window.outerWidth || document.documentElement.clientWidth || 600;
windowHeight = window.outerHeight || document.documentElement.clientHeight || 700;
windowWidth = ( windowWidth < 800 || windowWidth > 5000 ) ? 600 : ( windowWidth * 0.7 );
windowHeight = ( windowHeight < 800 || windowHeight > 3000 ) ? 700 : ( windowHeight * 0.9 );
if ( ! canPost ) {
window.open( pt_url, target, 'location,resizable,scrollbars,width=' + windowWidth + ',height=' + windowHeight );
return;
}
/**
* @summary Creates a hidden input field and sets its name and value.
*
* @since 4.2.0
*
* @param name The input field name.
* @param value The input field value.
*
* @returns {void}
*/
function add( name, value ) {
if ( typeof value === 'undefined' ) {
return;
}
var input = document.createElement( 'input' );
input.name = name;
input.value = value;
input.type = 'hidden';
form.appendChild( input );
}
metas = head.getElementsByTagName( 'meta' ) || [];
for ( var m = 0; m < metas.length; m++ ) {
if ( m > 200 ) {
break;
}
var q = metas[ m ],
q_name = q.getAttribute( 'name' ),
q_prop = q.getAttribute( 'property' ),
q_cont = q.getAttribute( 'content' );
if ( q_cont ) {
if ( q_name ) {
add( '_meta[' + q_name + ']', q_cont );
} else if ( q_prop ) {
add( '_meta[' + q_prop + ']', q_cont );
}
}
}
links = head.getElementsByTagName( 'link' ) || [];
for ( var y = 0; y < links.length; y++ ) {
if ( y >= 50 ) {
break;
}
var g = links[ y ],
g_rel = g.getAttribute( 'rel' );
if ( g_rel === 'canonical' || g_rel === 'icon' || g_rel === 'shortlink' ) {
add( '_links[' + g_rel + ']', g.getAttribute( 'href' ) );
}
}
if ( document.body.getElementsByClassName ) {
content = document.body.getElementsByClassName( 'hfeed' )[0];
}
content = document.getElementById( 'content' ) || content || document.body;
images = content.getElementsByTagName( 'img' ) || [];
for ( var n = 0; n < images.length; n++ ) {
if ( n >= 100 ) {
break;
}
img = images[ n ];
// If we know the image width and/or height, check them now and drop the "uninteresting" images.
if ( img.src.indexOf( 'avatar' ) > -1 || img.className.indexOf( 'avatar' ) > -1 ||
( img.width && img.width < 256 ) || ( img.height && img.height < 128 ) ) {
continue;
}
add( '_images[]', img.src );
}
iframes = document.body.getElementsByTagName( 'iframe' ) || [];
for ( var p = 0; p < iframes.length; p++ ) {
if ( p >= 50 ) {
break;
}
add( '_embeds[]', iframes[ p ].src );
}
if ( document.title ) {
add( 't', document.title );
}
if ( selection ) {
add( 's', selection );
}
form.setAttribute( 'method', 'POST' );
form.setAttribute( 'action', pt_url );
form.setAttribute( 'target', target );
form.setAttribute( 'style', 'display: none;' );
window.open( 'about:blank', target, 'location,resizable,scrollbars,width=' + windowWidth + ',height=' + windowHeight );
document.body.appendChild( form );
form.submit();
} )( window, document, top.location.href, window.pt_url );

View File

@ -1 +0,0 @@
(function(a,b,c,d){function e(a,c){if("undefined"!=typeof c){var d=b.createElement("input");d.name=a,d.value=c,d.type="hidden",p.appendChild(d)}}var f,g,h,i,j,k,l,m,n,o=a.encodeURIComponent,p=b.createElement("form"),q=b.getElementsByTagName("head")[0],r="_press_this_app",s=!0;if(d){if(!c.match(/^https?:/))return void(top.location.href=d);if(d+="&u="+o(c),c.match(/^https:/)&&d.match(/^http:/)&&(s=!1),a.getSelection?h=a.getSelection()+"":b.getSelection?h=b.getSelection()+"":b.selection&&(h=b.selection.createRange().text||""),d+="&buster="+(new Date).getTime(),s||(b.title&&(d+="&t="+o(b.title.substr(0,256))),h&&(d+="&s="+o(h.substr(0,512)))),f=a.outerWidth||b.documentElement.clientWidth||600,g=a.outerHeight||b.documentElement.clientHeight||700,f=f<800||f>5e3?600:.7*f,g=g<800||g>3e3?700:.9*g,!s)return void a.open(d,r,"location,resizable,scrollbars,width="+f+",height="+g);i=q.getElementsByTagName("meta")||[];for(var t=0;t<i.length&&!(t>200);t++){var u=i[t],v=u.getAttribute("name"),w=u.getAttribute("property"),x=u.getAttribute("content");x&&(v?e("_meta["+v+"]",x):w&&e("_meta["+w+"]",x))}j=q.getElementsByTagName("link")||[];for(var y=0;y<j.length&&!(y>=50);y++){var z=j[y],A=z.getAttribute("rel");"canonical"!==A&&"icon"!==A&&"shortlink"!==A||e("_links["+A+"]",z.getAttribute("href"))}b.body.getElementsByClassName&&(k=b.body.getElementsByClassName("hfeed")[0]),k=b.getElementById("content")||k||b.body,l=k.getElementsByTagName("img")||[];for(var B=0;B<l.length&&!(B>=100);B++)n=l[B],n.src.indexOf("avatar")>-1||n.className.indexOf("avatar")>-1||n.width&&n.width<256||n.height&&n.height<128||e("_images[]",n.src);m=b.body.getElementsByTagName("iframe")||[];for(var C=0;C<m.length&&!(C>=50);C++)e("_embeds[]",m[C].src);b.title&&e("t",b.title),h&&e("s",h),p.setAttribute("method","POST"),p.setAttribute("action",d),p.setAttribute("target",r),p.setAttribute("style","display: none;"),a.open("about:blank",r,"location,resizable,scrollbars,width="+f+",height="+g),b.body.appendChild(p),p.submit()}})(window,document,top.location.href,window.pt_url);

View File

@ -1,899 +0,0 @@
/**
* PressThis App
*
*/
( function( $, window ) {
var PressThis = function() {
var editor, $mediaList, $mediaThumbWrap,
$window = $( window ),
$document = $( document ),
saveAlert = false,
sidebarIsOpen = false,
settings = window.wpPressThisConfig || {},
data = window.wpPressThisData || {},
smallestWidth = 128,
hasSetFocus = false,
catsCache = [],
isOffScreen = 'is-off-screen',
isHidden = 'is-hidden',
offscreenHidden = isOffScreen + ' ' + isHidden,
iOS = /iPad|iPod|iPhone/.test( window.navigator.userAgent ),
$textEditor = $( '#pressthis' ),
textEditor = $textEditor[0],
textEditorMinHeight = 600,
textLength = 0,
transitionEndEvent = ( function() {
var style = document.documentElement.style;
if ( typeof style.transition !== 'undefined' ) {
return 'transitionend';
}
if ( typeof style.WebkitTransition !== 'undefined' ) {
return 'webkitTransitionEnd';
}
return false;
}() );
/* ***************************************************************
* HELPER FUNCTIONS
*************************************************************** */
/**
* Emulates our PHP __() gettext function, powered by the strings exported in pressThisL10n.
*
* @param key string Key of the string to be translated, as found in pressThisL10n.
* @returns string Original or translated string, or empty string if no key.
*/
function __( key ) {
if ( key && window.pressThisL10n ) {
return window.pressThisL10n[key] || key;
}
return key || '';
}
/**
* Allow only HTTP or protocol relative URLs.
*
* @param url string The URL.
* @returns string Processed URL.
*/
function checkUrl( url ) {
url = $.trim( url || '' );
if ( /^(?:https?:)?\/\//.test( url ) ) {
url = wp.sanitize.stripTags( url );
return url.replace( /["\\]+/g, '' );
}
return '';
}
/**
* Show UX spinner
*/
function showSpinner() {
$( '.spinner' ).addClass( 'is-active' );
$( '.post-actions button' ).attr( 'disabled', 'disabled' );
}
/**
* Hide UX spinner
*/
function hideSpinner() {
$( '.spinner' ).removeClass( 'is-active' );
$( '.post-actions button' ).removeAttr( 'disabled' );
}
function textEditorResize( reset ) {
var pageYOffset, height;
if ( editor && ! editor.isHidden() ) {
return;
}
reset = ( reset === 'reset' ) || ( textLength && textLength > textEditor.value.length );
height = textEditor.style.height;
if ( reset ) {
pageYOffset = window.pageYOffset;
textEditor.style.height = 'auto';
textEditor.style.height = Math.max( textEditor.scrollHeight, textEditorMinHeight ) + 'px';
window.scrollTo( window.pageXOffset, pageYOffset );
} else if ( parseInt( textEditor.style.height, 10 ) < textEditor.scrollHeight ) {
textEditor.style.height = textEditor.scrollHeight + 'px';
}
textLength = textEditor.value.length;
}
function mceGetCursorOffset() {
if ( ! editor ) {
return false;
}
var node = editor.selection.getNode(),
range, view, offset;
if ( editor.wp && editor.wp.getView && ( view = editor.wp.getView( node ) ) ) {
offset = view.getBoundingClientRect();
} else {
range = editor.selection.getRng();
try {
offset = range.getClientRects()[0];
} catch( er ) {}
if ( ! offset ) {
offset = node.getBoundingClientRect();
}
}
return offset.height ? offset : false;
}
// Make sure the caret is always visible.
function mceKeyup( event ) {
var VK = window.tinymce.util.VK,
key = event.keyCode;
// Bail on special keys.
if ( key <= 47 && ! ( key === VK.SPACEBAR || key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE || key === VK.UP || key === VK.LEFT || key === VK.DOWN || key === VK.UP ) ) {
return;
// OS keys, function keys, num lock, scroll lock
} else if ( ( key >= 91 && key <= 93 ) || ( key >= 112 && key <= 123 ) || key === 144 || key === 145 ) {
return;
}
mceScroll( key );
}
function mceScroll( key ) {
var cursorTop, cursorBottom, editorBottom,
offset = mceGetCursorOffset(),
bufferTop = 50,
bufferBottom = 65,
VK = window.tinymce.util.VK;
if ( ! offset ) {
return;
}
cursorTop = offset.top + editor.iframeElement.getBoundingClientRect().top;
cursorBottom = cursorTop + offset.height;
cursorTop = cursorTop - bufferTop;
cursorBottom = cursorBottom + bufferBottom;
editorBottom = $window.height();
// Don't scroll if the node is taller than the visible part of the editor
if ( editorBottom < offset.height ) {
return;
}
if ( cursorTop < 0 && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) {
window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset );
} else if ( cursorBottom > editorBottom ) {
window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom );
}
}
/**
* Replace emoji images with chars and sanitize the text content.
*/
function getTitleText() {
var $element = $( '#title-container' );
$element.find( 'img.emoji' ).each( function() {
var $image = $( this );
$image.replaceWith( $( '<span>' ).text( $image.attr( 'alt' ) ) );
});
return wp.sanitize.sanitizeText( $element.text() );
}
/**
* Prepare the form data for saving.
*/
function prepareFormData() {
var $form = $( '#pressthis-form' ),
$input = $( '<input type="hidden" name="post_category[]" value="">' );
editor && editor.save();
$( '#post_title' ).val( getTitleText() );
// Make sure to flush out the tags with tagBox before saving
if ( window.tagBox ) {
$( 'div.tagsdiv' ).each( function() {
window.tagBox.flushTags( this, false, 1 );
} );
}
// Get selected categories
$( '.categories-select .category' ).each( function( i, element ) {
var $cat = $( element );
if ( $cat.hasClass( 'selected' ) ) {
// Have to append a node as we submit the actual form on preview
$form.append( $input.clone().val( $cat.attr( 'data-term-id' ) || '' ) );
}
});
}
/**
* Submit the post form via AJAX, and redirect to the proper screen if published vs saved as a draft.
*
* @param action string publish|draft
*/
function submitPost( action ) {
var data;
saveAlert = false;
showSpinner();
if ( 'publish' === action ) {
$( '#post_status' ).val( 'publish' );
}
prepareFormData();
data = $( '#pressthis-form' ).serialize();
$.ajax( {
type: 'post',
url: window.ajaxurl,
data: data
}).always( function() {
hideSpinner();
clearNotices();
$( '.publish-button' ).removeClass( 'is-saving' );
}).done( function( response ) {
if ( ! response.success ) {
renderError( response.data.errorMessage );
} else if ( response.data.redirect ) {
if ( window.opener && ( settings.redirInParent || response.data.force ) ) {
try {
window.opener.location.href = response.data.redirect;
window.setTimeout( function() {
window.self.close();
}, 200 );
} catch( er ) {
window.location.href = response.data.redirect;
}
} else {
window.location.href = response.data.redirect;
}
}
}).fail( function() {
renderError( __( 'serverError' ) );
});
}
/**
* Inserts the media a user has selected from the presented list inside the editor, as an image or embed, based on type
*
* @param type string img|embed
* @param src string Source URL
* @param link string Optional destination link, for images (defaults to src)
*/
function insertSelectedMedia( $element ) {
var src, link, newContent = '';
src = checkUrl( $element.attr( 'data-wp-src' ) || '' );
link = checkUrl( data.u );
if ( $element.hasClass( 'is-image' ) ) {
if ( ! link ) {
link = src;
}
newContent = '<a href="' + link + '"><img class="alignnone size-full" src="' + src + '" alt="" /></a>';
} else {
newContent = '[embed]' + src + '[/embed]';
}
if ( editor && ! editor.isHidden() ) {
if ( ! hasSetFocus ) {
editor.setContent( '<p>' + newContent + '</p>' + editor.getContent() );
} else {
editor.execCommand( 'mceInsertContent', false, newContent );
}
} else if ( window.QTags ) {
window.QTags.insertContent( newContent );
}
}
/**
* Save a new user-generated category via AJAX
*/
function saveNewCategory() {
var data,
name = $( '#new-category' ).val();
if ( ! name ) {
return;
}
data = {
action: 'press-this-add-category',
post_id: $( '#post_ID' ).val() || 0,
name: name,
new_cat_nonce: $( '#_ajax_nonce-add-category' ).val() || '',
parent: $( '#new-category-parent' ).val() || 0
};
$.post( window.ajaxurl, data, function( response ) {
if ( ! response.success ) {
renderError( response.data.errorMessage );
} else {
var $parent, $ul,
$wrap = $( 'ul.categories-select' );
$.each( response.data, function( i, newCat ) {
var $node = $( '<li>' ).append( $( '<div class="category selected" tabindex="0" role="checkbox" aria-checked="true">' )
.attr( 'data-term-id', newCat.term_id )
.text( newCat.name ) );
if ( newCat.parent ) {
if ( ! $ul || ! $ul.length ) {
$parent = $wrap.find( 'div[data-term-id="' + newCat.parent + '"]' ).parent();
$ul = $parent.find( 'ul.children:first' );
if ( ! $ul.length ) {
$ul = $( '<ul class="children">' ).appendTo( $parent );
}
}
$ul.prepend( $node );
} else {
$wrap.prepend( $node );
}
$node.focus();
} );
refreshCatsCache();
}
} );
}
/* ***************************************************************
* RENDERING FUNCTIONS
*************************************************************** */
/**
* Hide the form letting users enter a URL to be scanned, if a URL was already passed.
*/
function renderToolsVisibility() {
if ( data.hasData ) {
$( '#scanbar' ).hide();
}
}
/**
* Render error notice
*
* @param msg string Notice/error message
* @param error string error|notice CSS class for display
*/
function renderNotice( msg, error ) {
var $alerts = $( '.editor-wrapper div.alerts' ),
className = error ? 'is-error' : 'is-notice';
$alerts.append( $( '<p class="alert ' + className + '">' ).text( msg ) );
}
/**
* Render error notice
*
* @param msg string Error message
*/
function renderError( msg ) {
renderNotice( msg, true );
}
function clearNotices() {
$( 'div.alerts' ).empty();
}
/**
* Render notices on page load, if any already
*/
function renderStartupNotices() {
// Render errors sent in the data, if any
if ( data.errors ) {
$.each( data.errors, function( i, msg ) {
renderError( msg );
} );
}
}
/**
* Add an image to the list of found images.
*/
function addImg( src, displaySrc, i ) {
var $element = $mediaThumbWrap.clone().addClass( 'is-image' );
$element.attr( 'data-wp-src', src ).css( 'background-image', 'url(' + displaySrc + ')' )
.find( 'span' ).text( __( 'suggestedImgAlt' ).replace( '%d', i + 1 ) );
$mediaList.append( $element );
}
/**
* Render the detected images and embed for selection, if any
*/
function renderDetectedMedia() {
var found = 0;
$mediaList = $( 'ul.media-list' );
$mediaThumbWrap = $( '<li class="suggested-media-thumbnail" tabindex="0"><span class="screen-reader-text"></span></li>' );
if ( data._embeds ) {
$.each( data._embeds, function ( i, src ) {
var displaySrc = '',
cssClass = '',
$element = $mediaThumbWrap.clone().addClass( 'is-embed' );
src = checkUrl( src );
if ( src.indexOf( 'youtube.com/' ) > -1 ) {
displaySrc = 'https://i.ytimg.com/vi/' + src.replace( /.+v=([^&]+).*/, '$1' ) + '/hqdefault.jpg';
cssClass += ' is-video';
} else if ( src.indexOf( 'youtu.be/' ) > -1 ) {
displaySrc = 'https://i.ytimg.com/vi/' + src.replace( /\/([^\/])$/, '$1' ) + '/hqdefault.jpg';
cssClass += ' is-video';
} else if ( src.indexOf( 'dailymotion.com' ) > -1 ) {
displaySrc = src.replace( '/video/', '/thumbnail/video/' );
cssClass += ' is-video';
} else if ( src.indexOf( 'soundcloud.com' ) > -1 ) {
cssClass += ' is-audio';
} else if ( src.indexOf( 'twitter.com' ) > -1 ) {
cssClass += ' is-tweet';
} else {
cssClass += ' is-video';
}
$element.attr( 'data-wp-src', src ).find( 'span' ).text( __( 'suggestedEmbedAlt' ).replace( '%d', i + 1 ) );
if ( displaySrc ) {
$element.css( 'background-image', 'url(' + displaySrc + ')' );
}
$mediaList.append( $element );
found++;
} );
}
if ( data._images ) {
$.each( data._images, function( i, src ) {
var displaySrc, img = new Image();
src = checkUrl( src );
displaySrc = src.replace( /^(http[^\?]+)(\?.*)?$/, '$1' );
if ( src.indexOf( 'files.wordpress.com/' ) > -1 ) {
displaySrc = displaySrc.replace( /\?.*$/, '' ) + '?w=' + smallestWidth;
} else if ( src.indexOf( 'gravatar.com/' ) > -1 ) {
displaySrc = displaySrc.replace( /\?.*$/, '' ) + '?s=' + smallestWidth;
} else {
displaySrc = src;
}
img.onload = function() {
if ( ( img.width && img.width < 256 ) ||
( img.height && img.height < 128 ) ) {
return;
}
addImg( src, displaySrc, i );
};
img.src = src;
found++;
} );
}
if ( found ) {
$( '.media-list-container' ).addClass( 'has-media' );
}
}
/* ***************************************************************
* MONITORING FUNCTIONS
*************************************************************** */
/**
* Interactive navigation behavior for the options modal (post format, tags, categories)
*/
function monitorOptionsModal() {
var $postOptions = $( '.post-options' ),
$postOption = $( '.post-option' ),
$settingModal = $( '.setting-modal' ),
$modalClose = $( '.modal-close' );
$postOption.on( 'click', function() {
var index = $( this ).index(),
$targetSettingModal = $settingModal.eq( index );
$postOptions.addClass( isOffScreen )
.one( transitionEndEvent, function() {
$( this ).addClass( isHidden );
} );
$targetSettingModal.removeClass( offscreenHidden )
.one( transitionEndEvent, function() {
$( this ).find( '.modal-close' ).focus();
} );
} );
$modalClose.on( 'click', function() {
var $targetSettingModal = $( this ).parent(),
index = $targetSettingModal.index();
$postOptions.removeClass( offscreenHidden );
$targetSettingModal.addClass( isOffScreen );
if ( transitionEndEvent ) {
$targetSettingModal.one( transitionEndEvent, function() {
$( this ).addClass( isHidden );
$postOption.eq( index - 1 ).focus();
} );
} else {
setTimeout( function() {
$targetSettingModal.addClass( isHidden );
$postOption.eq( index - 1 ).focus();
}, 350 );
}
} );
}
/**
* Interactive behavior for the sidebar toggle, to show the options modals
*/
function openSidebar() {
sidebarIsOpen = true;
$( '.options' ).removeClass( 'closed' ).addClass( 'open' );
$( '.press-this-actions, #scanbar' ).addClass( isHidden );
$( '.options-panel-back' ).removeClass( isHidden );
$( '.options-panel' ).removeClass( offscreenHidden )
.one( transitionEndEvent, function() {
$( '.post-option:first' ).focus();
} );
}
function closeSidebar() {
sidebarIsOpen = false;
$( '.options' ).removeClass( 'open' ).addClass( 'closed' );
$( '.options-panel-back' ).addClass( isHidden );
$( '.press-this-actions, #scanbar' ).removeClass( isHidden );
$( '.options-panel' ).addClass( isOffScreen )
.one( transitionEndEvent, function() {
$( this ).addClass( isHidden );
// Reset to options list
$( '.post-options' ).removeClass( offscreenHidden );
$( '.setting-modal').addClass( offscreenHidden );
});
}
/**
* Interactive behavior for the post title's field placeholder
*/
function monitorPlaceholder() {
var $titleField = $( '#title-container' ),
$placeholder = $( '.post-title-placeholder' );
$titleField.on( 'focus', function() {
$placeholder.addClass( 'is-hidden' );
}).on( 'blur', function() {
if ( ! $titleField.text() && ! $titleField.html() ) {
$placeholder.removeClass( 'is-hidden' );
}
}).on( 'keyup', function() {
saveAlert = true;
}).on( 'paste', function( event ) {
var text, range,
clipboard = event.originalEvent.clipboardData || window.clipboardData;
if ( clipboard ) {
try{
text = clipboard.getData( 'Text' ) || clipboard.getData( 'text/plain' );
if ( text ) {
text = $.trim( text.replace( /\s+/g, ' ' ) );
if ( window.getSelection ) {
range = window.getSelection().getRangeAt(0);
if ( range ) {
if ( ! range.collapsed ) {
range.deleteContents();
}
range.insertNode( document.createTextNode( text ) );
}
} else if ( document.selection ) {
range = document.selection.createRange();
if ( range ) {
range.text = text;
}
}
}
} catch ( er ) {}
event.preventDefault();
}
saveAlert = true;
setTimeout( function() {
$titleField.text( getTitleText() );
}, 50 );
});
if ( $titleField.text() || $titleField.html() ) {
$placeholder.addClass('is-hidden');
}
}
function toggleCatItem( $element ) {
if ( $element.hasClass( 'selected' ) ) {
$element.removeClass( 'selected' ).attr( 'aria-checked', 'false' );
} else {
$element.addClass( 'selected' ).attr( 'aria-checked', 'true' );
}
}
function monitorCatList() {
$( '.categories-select' ).on( 'click.press-this keydown.press-this', function( event ) {
var $element = $( event.target );
if ( $element.is( 'div.category' ) ) {
if ( event.type === 'keydown' && event.keyCode !== 32 ) {
return;
}
toggleCatItem( $element );
event.preventDefault();
}
});
}
function splitButtonClose() {
$( '.split-button' ).removeClass( 'is-open' );
$( '.split-button-toggle' ).attr( 'aria-expanded', 'false' );
}
/* ***************************************************************
* PROCESSING FUNCTIONS
*************************************************************** */
/**
* Calls all the rendring related functions to happen on page load
*/
function render(){
// We're on!
renderToolsVisibility();
renderDetectedMedia();
renderStartupNotices();
if ( window.tagBox ) {
window.tagBox.init();
}
// iOS doesn't fire click events on "standard" elements without this...
if ( iOS ) {
$( document.body ).css( 'cursor', 'pointer' );
}
}
/**
* Set app events and other state monitoring related code.
*/
function monitor() {
var $splitButton = $( '.split-button' );
$document.on( 'tinymce-editor-init', function( event, ed ) {
editor = ed;
editor.on( 'nodechange', function() {
hasSetFocus = true;
});
editor.on( 'focus', function() {
splitButtonClose();
});
editor.on( 'show', function() {
setTimeout( function() {
editor.execCommand( 'wpAutoResize' );
}, 300 );
});
editor.on( 'hide', function() {
setTimeout( function() {
textEditorResize( 'reset' );
}, 100 );
});
editor.on( 'keyup', mceKeyup );
editor.on( 'undo redo', mceScroll );
}).on( 'click.press-this keypress.press-this', '.suggested-media-thumbnail', function( event ) {
if ( event.type === 'click' || event.keyCode === 13 ) {
insertSelectedMedia( $( this ) );
}
}).on( 'click.press-this', function( event ) {
if ( ! $( event.target ).closest( 'button' ).hasClass( 'split-button-toggle' ) ) {
splitButtonClose();
}
});
// Publish, Draft and Preview buttons
$( '.post-actions' ).on( 'click.press-this', function( event ) {
var location,
$target = $( event.target ),
$button = $target.closest( 'button' );
if ( $button.length ) {
if ( $button.hasClass( 'draft-button' ) ) {
$( '.publish-button' ).addClass( 'is-saving' );
submitPost( 'draft' );
} else if ( $button.hasClass( 'publish-button' ) ) {
$button.addClass( 'is-saving' );
if ( window.history.replaceState ) {
location = window.location.href;
location += ( location.indexOf( '?' ) !== -1 ) ? '&' : '?';
location += 'wp-press-this-reload=true';
window.history.replaceState( null, null, location );
}
submitPost( 'publish' );
} else if ( $button.hasClass( 'preview-button' ) ) {
prepareFormData();
window.opener && window.opener.focus();
$( '#wp-preview' ).val( 'dopreview' );
$( '#pressthis-form' ).attr( 'target', '_blank' ).submit().attr( 'target', '' );
$( '#wp-preview' ).val( '' );
} else if ( $button.hasClass( 'standard-editor-button' ) ) {
$( '.publish-button' ).addClass( 'is-saving' );
$( '#pt-force-redirect' ).val( 'true' );
submitPost( 'draft' );
} else if ( $button.hasClass( 'split-button-toggle' ) ) {
if ( $splitButton.hasClass( 'is-open' ) ) {
$splitButton.removeClass( 'is-open' );
$button.attr( 'aria-expanded', 'false' );
} else {
$splitButton.addClass( 'is-open' );
$button.attr( 'aria-expanded', 'true' );
}
}
}
});
monitorOptionsModal();
monitorPlaceholder();
monitorCatList();
$( '.options' ).on( 'click.press-this', function() {
if ( $( this ).hasClass( 'open' ) ) {
closeSidebar();
} else {
openSidebar();
}
});
// Close the sidebar when focus moves outside of it.
$( '.options-panel, .options-panel-back' ).on( 'focusout.press-this', function() {
setTimeout( function() {
var node = document.activeElement,
$node = $( node );
if ( sidebarIsOpen && node && ! $node.hasClass( 'options-panel-back' ) &&
( node.nodeName === 'BODY' ||
( ! $node.closest( '.options-panel' ).length &&
! $node.closest( '.options' ).length ) ) ) {
closeSidebar();
}
}, 50 );
});
$( '#post-formats-select input' ).on( 'change', function() {
var $this = $( this );
if ( $this.is( ':checked' ) ) {
$( '#post-option-post-format' ).text( $( 'label[for="' + $this.attr( 'id' ) + '"]' ).text() || '' );
}
} );
$window.on( 'beforeunload.press-this', function() {
if ( saveAlert || ( editor && editor.isDirty() ) ) {
return __( 'saveAlert' );
}
} ).on( 'resize.press-this', function() {
if ( ! editor || editor.isHidden() ) {
textEditorResize( 'reset' );
}
});
$( 'button.add-cat-toggle' ).on( 'click.press-this', function() {
var $this = $( this );
$this.toggleClass( 'is-toggled' );
$this.attr( 'aria-expanded', 'false' === $this.attr( 'aria-expanded' ) ? 'true' : 'false' );
$( '.setting-modal .add-category, .categories-search-wrapper' ).toggleClass( 'is-hidden' );
} );
$( 'button.add-cat-submit' ).on( 'click.press-this', saveNewCategory );
$( '.categories-search' ).on( 'keyup.press-this', function() {
var search = $( this ).val().toLowerCase() || '';
// Don't search when less thasn 3 extended ASCII chars
if ( /[\x20-\xFF]+/.test( search ) && search.length < 2 ) {
return;
}
$.each( catsCache, function( i, cat ) {
cat.node.removeClass( 'is-hidden searched-parent' );
} );
if ( search ) {
$.each( catsCache, function( i, cat ) {
if ( cat.text.indexOf( search ) === -1 ) {
cat.node.addClass( 'is-hidden' );
} else {
cat.parents.addClass( 'searched-parent' );
}
} );
}
} );
$textEditor.on( 'focus.press-this input.press-this propertychange.press-this', textEditorResize );
return true;
}
function refreshCatsCache() {
$( '.categories-select' ).find( 'li' ).each( function() {
var $this = $( this );
catsCache.push( {
node: $this,
parents: $this.parents( 'li' ),
text: $this.children( '.category' ).text().toLowerCase()
} );
} );
}
// Let's go!
$document.ready( function() {
render();
monitor();
refreshCatsCache();
});
// Expose public methods?
return {
renderNotice: renderNotice,
renderError: renderError
};
};
window.wp = window.wp || {};
window.wp.pressThis = new PressThis();
}( jQuery, window ));

File diff suppressed because one or more lines are too long

View File

@ -63,6 +63,8 @@ if ( $action ) {
if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix
} else if ( isset($_GET['from']) && 'press-this' == $_GET['from'] ) {
wp_redirect( self_admin_url( "press-this.php") );
} else {
wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above
}

View File

@ -6,19 +6,70 @@
* @subpackage Press_This
*/
define('IFRAME_REQUEST' , true);
define( 'IFRAME_REQUEST' , true );
/** WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
wp_die(
'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
'<p>' . __( 'Sorry, you are not allowed to create posts as this user.' ) . '</p>',
403
);
function wp_load_press_this() {
$plugin_slug = 'press-this';
$plugin_file = 'press-this/press-this-plugin.php';
if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
wp_die(
__( 'Sorry, you are not allowed to create posts as this user.' ),
__( 'Cheatin&#8217; uh?' ),
403
);
} elseif ( is_plugin_active( $plugin_file ) ) {
include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' );
$wp_press_this = new WP_Press_This_Plugin();
$wp_press_this->html();
} elseif ( current_user_can( 'activate_plugins' ) ) {
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
$url = wp_nonce_url( add_query_arg( array(
'action' => 'activate',
'plugin' => $plugin_file,
'from' => 'press-this',
), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file );
$action = sprintf(
'<a href="%1$s" aria-label="%2$s">%2$s</a>',
esc_url( $url ),
__( 'Activate Press This' )
);
} else {
if ( is_main_site() ) {
$url = wp_nonce_url( add_query_arg( array(
'action' => 'install-plugin',
'plugin' => $plugin_slug,
'from' => 'press-this',
), self_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug );
$action = sprintf(
'<a href="%1$s" class="install-now" data-slug="%2$s" data-name="%2$s" aria-label="%3$s">%3$s</a>',
esc_url( $url ),
esc_attr( $plugin_slug ),
__( 'Install Now' )
);
} else {
$action = sprintf(
/* translators: URL to wp-admin/press-this.php */
__( 'Press This is not installed. Please install Press This from <a href="%s">the main site</a>.' ),
get_admin_url( get_current_network_id(), 'press-this.php' )
);
}
}
wp_die(
__( 'The Press This plugin is required.' ) . '<br />' . $action,
__( 'Install Required' ),
200
);
} else {
wp_die(
__( 'Press This is not available. Please contact your site administrator.' ),
__( 'Install Required' ),
200
);
}
}
include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
$wp_press_this = new WP_Press_This();
$wp_press_this->html();
wp_load_press_this();

View File

@ -11,11 +11,6 @@ require_once( dirname( __FILE__ ) . '/admin.php' );
$title = __('Tools');
get_current_screen()->add_help_tab( array(
'id' => 'press-this',
'title' => __('Press This'),
'content' => '<p>' . __('Press This is a bookmarklet that makes it easy to blog about something you come across on the web. You can use it to just grab a link, or to post an excerpt. Press This will even allow you to choose from images included on the page and use them in your post. Just drag the Press This link on this screen to your bookmarks bar in your browser, and you&#8217;ll be on your way to easier content creation. Clicking on it while on another website opens a popup window with all these options.') . '</p>',
) );
get_current_screen()->add_help_tab( array(
'id' => 'converter',
'title' => __('Categories and Tags Converter'),
@ -34,67 +29,7 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap">
<h1><?php echo esc_html( $title ); ?></h1>
<?php if ( current_user_can('edit_posts') ) : ?>
<div class="card pressthis">
<h2><?php _e('Press This') ?></h2>
<p><?php _e( 'Press This is a little tool that lets you grab bits of the web and create new posts with ease.' );?></p>
<p><?php _e( 'Use Press This to clip text, images and videos from any web page. Then edit and add more straight from Press This before you save or publish it in a post on your site.' ); ?></p>
<form>
<h3><?php _e( 'Install Press This' ); ?></h3>
<h4><?php _e( 'Bookmarklet' ); ?></h4>
<p><?php _e( 'Drag the bookmarklet below to your bookmarks bar. Then, when you&#8217;re on a page you want to share, simply &#8220;press&#8221; it.' ); ?></p>
<p class="pressthis-bookmarklet-wrapper">
<a class="pressthis-bookmarklet" onclick="return false;" href="<?php echo htmlspecialchars( get_shortcut_link() ); ?>"><span><?php _e( 'Press This' ); ?></span></a>
<button type="button" class="button pressthis-js-toggle js-show-pressthis-code-wrap" aria-expanded="false" aria-controls="pressthis-code-wrap">
<span class="dashicons dashicons-clipboard"></span>
<span class="screen-reader-text"><?php _e( 'Copy &#8220;Press This&#8221; bookmarklet code' ) ?></span>
</button>
</p>
<div class="hidden js-pressthis-code-wrap clear" id="pressthis-code-wrap">
<p id="pressthis-code-desc">
<?php _e( 'If you can&#8217;t drag the bookmarklet to your bookmarks, copy the following code and create a new bookmark. Paste the code into the new bookmark&#8217;s URL field.' ) ?>
</p>
<p>
<textarea class="js-pressthis-code" rows="5" cols="120" readonly="readonly" aria-labelledby="pressthis-code-desc"><?php echo htmlspecialchars( get_shortcut_link() ); ?></textarea>
</p>
</div>
<h4><?php _e( 'Direct link (best for mobile)' ); ?></h4>
<p><?php _e( 'Follow the link to open Press This. Then add it to your device&#8217;s bookmarks or home screen.' ); ?></p>
<p>
<a class="button" href="<?php echo htmlspecialchars( admin_url( 'press-this.php' ) ); ?>"><?php _e( 'Open Press This' ) ?></a>
</p>
<script>
jQuery( document ).ready( function( $ ) {
var $showPressThisWrap = $( '.js-show-pressthis-code-wrap' );
var $pressthisCode = $( '.js-pressthis-code' );
$showPressThisWrap.on( 'click', function( event ) {
var $this = $( this );
$this.parent().next( '.js-pressthis-code-wrap' ).slideToggle( 200 );
$this.attr( 'aria-expanded', $this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
});
// Select Press This code when focusing (tabbing) or clicking the textarea.
$pressthisCode.on( 'click focus', function() {
var self = this;
setTimeout( function() { self.select(); }, 50 );
});
});
</script>
</form>
</div>
<?php
endif;
if ( current_user_can( 'import' ) ) :
$cats = get_taxonomy('category');
$tags = get_taxonomy('post_tag');

View File

@ -3887,3 +3887,60 @@ function _sort_nav_menu_items( $a, $b ) {
else
return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
}
/**
* Retrieves the Press This bookmarklet link.
*
* @since 2.6.0
* @deprecated 4.9.0
*
*/
function get_shortcut_link() {
_deprecated_function( __FUNCTION__, '4.9.0' );
$link = '';
/**
* Filters the Press This bookmarklet link.
*
* @since 2.6.0
* @deprecated 4.9.0
*
* @param string $link The Press This bookmarklet link.
*/
return apply_filters( 'shortcut_link', $link );
}
/**
* Ajax handler for saving a post from Press This.
*
* @since 4.2.0
* @deprecated 4.9.0
*/
function wp_ajax_press_this_save_post() {
_deprecated_function( __FUNCTION__, '4.9.0' );
if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' );
$wp_press_this = new WP_Press_This_Plugin();
$wp_press_this->save_post();
} else {
wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
}
}
/**
* Ajax handler for creating new category from Press This.
*
* @since 4.2.0
* @deprecated 4.9.0
*/
function wp_ajax_press_this_add_category() {
_deprecated_function( __FUNCTION__, '4.9.0' );
if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' );
$wp_press_this = new WP_Press_This_Plugin();
$wp_press_this->add_category();
} else {
wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
}
}

View File

@ -2897,62 +2897,6 @@ function the_comments_pagination( $args = array() ) {
echo get_the_comments_pagination( $args );
}
/**
* Retrieves the Press This bookmarklet link.
*
* @since 2.6.0
*
* @global bool $is_IE Whether the browser matches an Internet Explorer user agent.
*/
function get_shortcut_link() {
global $is_IE;
include_once( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
$link = '';
if ( $is_IE ) {
/*
* Return the old/shorter bookmarklet code for MSIE 8 and lower,
* since they only support a max length of ~2000 characters for
* bookmark[let] URLs, which is way to small for our smarter one.
* Do update the version number so users do not get the "upgrade your
* bookmarklet" notice when using PT in those browsers.
*/
$ua = $_SERVER['HTTP_USER_AGENT'];
if ( ! empty( $ua ) && preg_match( '/\bMSIE (\d)/', $ua, $matches ) && (int) $matches[1] <= 8 ) {
$url = wp_json_encode( admin_url( 'press-this.php' ) );
$link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,' .
's=(e?e():(k)?k():(x?x.createRange().text:0)),f=' . $url . ',l=d.location,e=encodeURIComponent,' .
'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . WP_Press_This::VERSION . '";' .
'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};' .
'if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();void(0)';
}
}
if ( empty( $link ) ) {
$src = @file_get_contents( ABSPATH . 'wp-admin/js/bookmarklet.min.js' );
if ( $src ) {
$url = wp_json_encode( admin_url( 'press-this.php' ) . '?v=' . WP_Press_This::VERSION );
$link = 'javascript:' . str_replace( 'window.pt_url', $url, $src );
}
}
$link = str_replace( array( "\r", "\n", "\t" ), '', $link );
/**
* Filters the Press This bookmarklet link.
*
* @since 2.6.0
*
* @param string $link The Press This bookmarklet link.
*/
return apply_filters( 'shortcut_link', $link );
}
/**
* Retrieves the URL for the current site where the front end is accessible.
*

View File

@ -673,17 +673,6 @@ function wp_default_scripts( &$scripts ) {
'permalinkSaved' => __( 'Permalink saved' ),
) );
$scripts->add( 'press-this', "/wp-admin/js/press-this$suffix.js", array( 'jquery', 'tags-box', 'wp-sanitize' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'press-this', 'pressThisL10n', array(
'newPost' => __( 'Title' ),
'serverError' => __( 'Connection lost or the server is busy. Please try again later.' ),
'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
/* translators: %d: nth embed found in a post */
'suggestedEmbedAlt' => __( 'Suggested embed #%d' ),
/* translators: %d: nth image found in a post */
'suggestedImgAlt' => __( 'Suggested image #%d' ),
) );
$scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 );
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
@ -963,7 +952,6 @@ function wp_default_styles( &$styles ) {
$styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie', 'imgareaselect' ) );
$styles->add( 'customize-widgets', "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) );
$styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) );
$styles->add( 'press-this', "/wp-admin/css/press-this$suffix.css", array( 'buttons' ) );
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css" );
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
@ -1002,7 +990,7 @@ function wp_default_styles( &$styles ) {
// wp-admin
'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus',
'widgets', 'site-icon', 'l10n', 'install', 'wp-color-picker', 'customize-controls', 'customize-widgets', 'customize-nav-menus', 'customize-preview',
'ie', 'login', 'press-this',
'ie', 'login',
// wp-includes
'buttons', 'admin-bar', 'wp-auth-check', 'editor-buttons', 'media-views', 'wp-pointer',
'wp-jquery-ui-dialog',

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41583';
$wp_version = '4.9-alpha-41584';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.