' ).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 = $( '
' . __( 'Sorry, you are not allowed to create posts as this user.' ) . '
',
- 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’ 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(
+ '' . __('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’ll be on your way to easier content creation. Clicking on it while on another website opens a popup window with all these options.') . '
',
-) );
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' );
?>
-
-
-
$_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.' ) ) );
+ }
+}
diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php
index f16b8f58df..b541cf473c 100644
--- a/src/wp-includes/link-template.php
+++ b/src/wp-includes/link-template.php
@@ -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.
*
diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
index ba82655d47..c85822c807 100644
--- a/src/wp-includes/script-loader.php
+++ b/src/wp-includes/script-loader.php
@@ -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',