PressThis v2, first run. Props michael-arestad, stephdau, marcelomazza, DrewAPicture, iseulde, afercia, kraftbj, rachelbaker, AramZS, dd32. See #31373.

git-svn-id: https://develop.svn.wordpress.org/trunk@31534 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2015-02-25 01:49:26 +00:00
parent f1bb5c2fd7
commit 2e3afd2760
16 changed files with 4643 additions and 1311 deletions
+47 -16
View File
@@ -2594,23 +2594,54 @@ function paginate_comments_links($args = array()) {
* @return string The Press This bookmarklet link URL.
*/
function get_shortcut_link() {
// In case of breaking changes, version this. #WP20071
$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='" . admin_url('press-this.php') . "',
l=d.location,
e=encodeURIComponent,
u=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=4';
a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};
if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();
void(0)";
global $is_IE, $wp_version;
$link = str_replace(array("\r", "\n", "\t"), '', $link);
$bookmarklet_version = 5;
$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 ) {
$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='" . admin_url('press-this.php') . "',
l=d.location,
e=encodeURIComponent,
u=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=" . $bookmarklet_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 ) ) {
$suffix = '.min';
$develop_src = false !== strpos( $wp_version, '-src' );
if ( $develop_src || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) {
$suffix = '';
}
$url = admin_url( 'press-this.php' ) . '?v=' . $bookmarklet_version;
$link = 'javascript:' . file_get_contents( ABSPATH . "wp-admin/js/bookmarklet$suffix.js" );
$link = str_replace( 'window.pt_url', wp_json_encode( $url ), $link );
}
$link = str_replace( array( "\r", "\n", "\t" ), '', $link );
/**
* Filter the Press This bookmarklet link.
+41 -3
View File
@@ -439,7 +439,12 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), false, 1 );
$scripts->add( 'tags-box', "/wp-admin/js/tags-box$suffix.js", array( 'jquery', 'suggest' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'tags-box', 'tagsBoxL10n', array(
'tagDelimiter' => _x( ',', 'tag delimiter' ),
) );
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'post', 'postL10n', array(
'ok' => __('OK'),
'cancel' => __('Cancel'),
@@ -461,11 +466,43 @@ function wp_default_scripts( &$scripts ) {
'password' => __('Password Protected'),
'privatelyPublished' => __('Privately Published'),
'published' => __('Published'),
'comma' => _x( ',', 'tag delimiter' ),
'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'),
'savingText' => __('Saving Draft&#8230;'),
) );
$scripts->add( 'press-this', "/wp-admin/js/press-this$suffix.js", array( 'jquery', 'tags-box' ), false, 1 );
did_action( 'init' ) && $scripts->localize( 'press-this', 'pressThisL10n', array(
/**
* press_this_source_string: string displayed before the source attribution string, defaults to "Source:".
*
* @since 4.2
* @see https://github.com/MichaelArestad/Press-This/issues/25
*
* @param string $string Internationalized source string
*
* @return string Source string
*/
'source' => apply_filters( 'press_this_source_string', __( 'Source:' ) ),
/**
* press_this_source_link: HTML link format for the source attribution, can control target, class, etc
*
* @since 4.2
* @see https://github.com/MichaelArestad/Press-This/issues/25
*
* @param string $link_format Internationalized link format, %1$s is link href, %2$s is link text
*
* @return string Link markup
*/
'sourceLink' => apply_filters( 'press_this_source_link', __( '<a href="%1$s">%2$s</a>' ) ),
'newPost' => __( 'Title' ),
'unexpectedError' => __( 'Sorry, but an unexpected error occurred.' ),
'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
'allMediaHeading' => __( 'Suggested media' ),
'suggestedEmbedAlt' => __( 'Suggested embed #%d' ),
'suggestedImgAlt' => __( 'Suggested image #%d' ),
) );
$scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery' ), false, 1 );
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
@@ -633,8 +670,9 @@ function wp_default_styles( &$styles ) {
$styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" );
$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( 'ie', "/wp-admin/css/ie$suffix.css" );
$styles->add( 'press-this', "/wp-admin/css/press-this$suffix.css", array( 'open-sans' ) );
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css" );
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
// Common dependencies