WordPress.org

Make WordPress Core

Changeset 41584


Ignore:
Timestamp:
09/24/2017 02:21:42 PM (2 years ago)
Author:
azaozz
Message:

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

Props kraftbj, azaozz.
See #41689.

Location:
trunk
Files:
6 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r41570 r41584  
    494494
    495495                    // Exceptions
    496                     '!wp-admin/js/bookmarklet.*', // Minified and updated in /src with the precommit task. See uglify:bookmarklet.
    497496                    '!wp-admin/js/custom-header.js', // Why? We should minify this.
    498497                    '!wp-admin/js/farbtastic.js',
     
    540539                ext: '.min.js',
    541540                src: ['wp-includes/js/jquery/ui/*.js']
    542             },
    543             bookmarklet: {
    544                 options: {
    545                     compress: {
    546                         negate_iife: false
    547                     }
    548                 },
    549                 src: SOURCE_DIR + 'wp-admin/js/bookmarklet.js',
    550                 dest: SOURCE_DIR + 'wp-admin/js/bookmarklet.min.js'
    551541            },
    552542            masonry: {
     
    824814        'browserify',
    825815        'jshint:corejs',
    826         'uglify:bookmarklet',
    827816        'uglify:masonry',
    828817        'qunit:compiled'
  • trunk/src/wp-admin/admin-ajax.php

    r41120 r41584  
    6262    'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
    6363    'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail',
    64     'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'press-this-save-post',
    65     'press-this-add-category', 'crop-image', 'generate-password', 'save-wporg-username', 'delete-plugin',
    66     'search-plugins', 'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme',
    67     'install-theme', 'get-post-thumbnail-html', 'get-community-events',
     64    'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'crop-image',
     65    'generate-password', 'save-wporg-username', 'delete-plugin', 'search-plugins',
     66    'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme', 'install-theme',
     67    'get-post-thumbnail-html', 'get-community-events',
    6868);
    6969
    7070// Deprecated
    71 $core_actions_post[] = 'wp-fullscreen-save-post';
     71$core_actions_post_deprecated = array( 'wp-fullscreen-save-post', 'press-this-save-post', 'press-this-add-category' );
     72$core_actions_post = array_merge( $core_actions_post, $core_actions_post_deprecated );
    7273
    7374// Register core Ajax calls.
  • trunk/src/wp-admin/includes/ajax-actions.php

    r41563 r41584  
    31903190
    31913191/**
    3192  * Ajax handler for saving a post from Press This.
    3193  *
    3194  * @since 4.2.0
    3195  */
    3196 function wp_ajax_press_this_save_post() {
    3197     include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
    3198     $wp_press_this = new WP_Press_This();
    3199     $wp_press_this->save_post();
    3200 }
    3201 
    3202 /**
    3203  * Ajax handler for creating new category from Press This.
    3204  *
    3205  * @since 4.2.0
    3206  */
    3207 function wp_ajax_press_this_add_category() {
    3208     include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
    3209     $wp_press_this = new WP_Press_This();
    3210     $wp_press_this->add_category();
    3211 }
    3212 
    3213 /**
    32143192 * Ajax handler for cropping an image.
    32153193 *
  • trunk/src/wp-admin/includes/class-plugin-installer-skin.php

    r41290 r41584  
    5050        $from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
    5151
    52         if ( 'import' == $from )
     52        if ( 'import' == $from ) {
    5353            $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>';
    54         else
     54        } else if ( 'press-this' == $from ) {
     55            $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>';
     56        } else {
    5557            $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>';
     58        }
    5659
    5760        if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
  • trunk/src/wp-admin/includes/update-core.php

    r41571 r41584  
    720720'wp-includes/js/swfupload/plugins',
    721721'wp-includes/js/swfupload/swfupload.swf',
     722'wp-admin/css/press-this-editor.css',
     723'wp-admin/css/press-this-editor-rtl.css',
     724'wp-admin/css/press-this-editor-rtl.min.css',
     725'wp-admin/css/press-this-editor.min.css',
     726'wp-admin/css/press-this.css',
     727'wp-admin/css/press-this-rtl.css',
     728'wp-admin/css/press-this-rtl.min.css',
     729'wp-admin/css/press-this.min.css',
     730'wp-admin/includes/class-wp-press-this.php',
     731'wp-admin/js/press-this.js',
     732'wp-admin/js/press-this.min.js',
     733'wp-admin/js/bookmarklet.js',
     734'wp-admin/js/bookmarklet.min.js',
    722735);
    723736
     
    852865    /*
    853866     * Import $wp_version, $required_php_version, and $required_mysql_version from the new version.
    854      * DO NOT globalise any variables imported from `version-current.php` in this function. 
     867     * DO NOT globalise any variables imported from `version-current.php` in this function.
    855868     *
    856869     * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8
  • trunk/src/wp-admin/plugins.php

    r41399 r41584  
    6464            if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
    6565                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
     66            } else if ( isset($_GET['from']) && 'press-this' == $_GET['from'] ) {
     67                wp_redirect( self_admin_url( "press-this.php") );
    6668            } else {
    6769                wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above
  • trunk/src/wp-admin/press-this.php

    r38470 r41584  
    77 */
    88
    9 define('IFRAME_REQUEST' , true);
     9define( 'IFRAME_REQUEST' , true );
    1010
    1111/** WordPress Administration Bootstrap */
    1212require_once( dirname( __FILE__ ) . '/admin.php' );
    1313
    14 if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
    15     wp_die(
    16         '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
    17         '<p>' . __( 'Sorry, you are not allowed to create posts as this user.' ) . '</p>',
    18         403
    19     );
     14function wp_load_press_this() {
     15    $plugin_slug = 'press-this';
     16    $plugin_file = 'press-this/press-this-plugin.php';
     17
     18    if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
     19        wp_die(
     20            __( 'Sorry, you are not allowed to create posts as this user.' ),
     21            __( 'Cheatin&#8217; uh?' ),
     22            403
     23        );
     24    } elseif ( is_plugin_active( $plugin_file ) ) {
     25        include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' );
     26        $wp_press_this = new WP_Press_This_Plugin();
     27        $wp_press_this->html();
     28    } elseif ( current_user_can( 'activate_plugins' ) ) {
     29        if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
     30            $url = wp_nonce_url( add_query_arg( array(
     31                'action' => 'activate',
     32                'plugin' => $plugin_file,
     33                'from'   => 'press-this',
     34            ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file );
     35            $action = sprintf(
     36                '<a href="%1$s" aria-label="%2$s">%2$s</a>',
     37                esc_url( $url ),
     38                __( 'Activate Press This' )
     39            );
     40        } else {
     41            if ( is_main_site() ) {
     42                $url = wp_nonce_url( add_query_arg( array(
     43                    'action' => 'install-plugin',
     44                    'plugin' => $plugin_slug,
     45                    'from'   => 'press-this',
     46                ), self_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug );
     47                $action = sprintf(
     48                    '<a href="%1$s" class="install-now" data-slug="%2$s" data-name="%2$s" aria-label="%3$s">%3$s</a>',
     49                    esc_url( $url ),
     50                    esc_attr( $plugin_slug ),
     51                    __( 'Install Now' )
     52                );
     53            } else {
     54                $action = sprintf(
     55                    /* translators: URL to wp-admin/press-this.php */
     56                    __( 'Press This is not installed. Please install Press This from <a href="%s">the main site</a>.' ),
     57                    get_admin_url( get_current_network_id(), 'press-this.php' )
     58                );
     59            }
     60        }
     61        wp_die(
     62            __( 'The Press This plugin is required.' ) . '<br />' . $action,
     63            __( 'Install Required' ),
     64            200
     65        );
     66    } else {
     67        wp_die(
     68            __( 'Press This is not available. Please contact your site administrator.' ),
     69            __( 'Install Required' ),
     70            200
     71        );
     72    }
    2073}
    2174
    22 include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
    23 $wp_press_this = new WP_Press_This();
    24 $wp_press_this->html();
     75wp_load_press_this();
  • trunk/src/wp-admin/tools.php

    r38722 r41584  
    1212$title = __('Tools');
    1313
    14 get_current_screen()->add_help_tab( array(
    15     'id'      => 'press-this',
    16     'title'   => __('Press This'),
    17     '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>',
    18 ) );
    1914get_current_screen()->add_help_tab( array(
    2015    'id'      => 'converter',
     
    3530<div class="wrap">
    3631<h1><?php echo esc_html( $title ); ?></h1>
    37 
    38 <?php if ( current_user_can('edit_posts') ) : ?>
    39 <div class="card pressthis">
    40     <h2><?php _e('Press This') ?></h2>
    41     <p><?php _e( 'Press This is a little tool that lets you grab bits of the web and create new posts with ease.' );?></p>
    42     <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>
    43 
    44 
    45     <form>
    46         <h3><?php _e( 'Install Press This' ); ?></h3>
    47         <h4><?php _e( 'Bookmarklet' ); ?></h4>
    48         <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>
    49 
    50         <p class="pressthis-bookmarklet-wrapper">
    51             <a class="pressthis-bookmarklet" onclick="return false;" href="<?php echo htmlspecialchars( get_shortcut_link() ); ?>"><span><?php _e( 'Press This' ); ?></span></a>
    52             <button type="button" class="button pressthis-js-toggle js-show-pressthis-code-wrap" aria-expanded="false" aria-controls="pressthis-code-wrap">
    53                 <span class="dashicons dashicons-clipboard"></span>
    54                 <span class="screen-reader-text"><?php _e( 'Copy &#8220;Press This&#8221; bookmarklet code' ) ?></span>
    55             </button>
    56         </p>
    57 
    58         <div class="hidden js-pressthis-code-wrap clear" id="pressthis-code-wrap">
    59             <p id="pressthis-code-desc">
    60                 <?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.' ) ?>
    61             </p>
    62             <p>
    63                 <textarea class="js-pressthis-code" rows="5" cols="120" readonly="readonly" aria-labelledby="pressthis-code-desc"><?php echo htmlspecialchars( get_shortcut_link() ); ?></textarea>
    64             </p>
    65         </div>
    66 
    67         <h4><?php _e( 'Direct link (best for mobile)' ); ?></h4>
    68         <p><?php _e( 'Follow the link to open Press This. Then add it to your device&#8217;s bookmarks or home screen.' ); ?></p>
    69 
    70         <p>
    71             <a class="button" href="<?php echo htmlspecialchars( admin_url( 'press-this.php' ) ); ?>"><?php _e( 'Open Press This' ) ?></a>
    72         </p>
    73         <script>
    74             jQuery( document ).ready( function( $ ) {
    75                 var $showPressThisWrap = $( '.js-show-pressthis-code-wrap' );
    76                 var $pressthisCode = $( '.js-pressthis-code' );
    77 
    78                 $showPressThisWrap.on( 'click', function( event ) {
    79                     var $this = $( this );
    80 
    81                     $this.parent().next( '.js-pressthis-code-wrap' ).slideToggle( 200 );
    82                     $this.attr( 'aria-expanded', $this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
    83                 });
    84 
    85                 // Select Press This code when focusing (tabbing) or clicking the textarea.
    86                 $pressthisCode.on( 'click focus', function() {
    87                     var self = this;
    88                     setTimeout( function() { self.select(); }, 50 );
    89                 });
    90 
    91             });
    92         </script>
    93     </form>
    94 </div>
    9532<?php
    96 endif;
    97 
    9833if ( current_user_can( 'import' ) ) :
    9934$cats = get_taxonomy('category');
  • trunk/src/wp-includes/deprecated.php

    r41289 r41584  
    38883888        return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
    38893889}
     3890
     3891/**
     3892 * Retrieves the Press This bookmarklet link.
     3893 *
     3894 * @since 2.6.0
     3895 * @deprecated 4.9.0
     3896 *
     3897 */
     3898function get_shortcut_link() {
     3899    _deprecated_function( __FUNCTION__, '4.9.0' );
     3900
     3901    $link = '';
     3902
     3903    /**
     3904     * Filters the Press This bookmarklet link.
     3905     *
     3906     * @since 2.6.0
     3907     * @deprecated 4.9.0
     3908     *
     3909     * @param string $link The Press This bookmarklet link.
     3910     */
     3911    return apply_filters( 'shortcut_link', $link );
     3912}
     3913
     3914/**
     3915* Ajax handler for saving a post from Press This.
     3916*
     3917* @since 4.2.0
     3918* @deprecated 4.9.0
     3919*/
     3920function wp_ajax_press_this_save_post() {
     3921    _deprecated_function( __FUNCTION__, '4.9.0' );
     3922    if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
     3923        include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' );
     3924        $wp_press_this = new WP_Press_This_Plugin();
     3925        $wp_press_this->save_post();
     3926    } else {
     3927        wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
     3928    }
     3929}
     3930
     3931/**
     3932* Ajax handler for creating new category from Press This.
     3933*
     3934* @since 4.2.0
     3935* @deprecated 4.9.0
     3936*/
     3937function wp_ajax_press_this_add_category() {
     3938    _deprecated_function( __FUNCTION__, '4.9.0' );
     3939    if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
     3940        include( WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php' );
     3941        $wp_press_this = new WP_Press_This_Plugin();
     3942        $wp_press_this->add_category();
     3943    } else {
     3944        wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
     3945    }
     3946}
  • trunk/src/wp-includes/link-template.php

    r41236 r41584  
    28992899
    29002900/**
    2901  * Retrieves the Press This bookmarklet link.
    2902  *
    2903  * @since 2.6.0
    2904  *
    2905  * @global bool          $is_IE      Whether the browser matches an Internet Explorer user agent.
    2906  */
    2907 function get_shortcut_link() {
    2908     global $is_IE;
    2909 
    2910     include_once( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
    2911 
    2912     $link = '';
    2913 
    2914     if ( $is_IE ) {
    2915         /*
    2916          * Return the old/shorter bookmarklet code for MSIE 8 and lower,
    2917          * since they only support a max length of ~2000 characters for
    2918          * bookmark[let] URLs, which is way to small for our smarter one.
    2919          * Do update the version number so users do not get the "upgrade your
    2920          * bookmarklet" notice when using PT in those browsers.
    2921          */
    2922         $ua = $_SERVER['HTTP_USER_AGENT'];
    2923 
    2924         if ( ! empty( $ua ) && preg_match( '/\bMSIE (\d)/', $ua, $matches ) && (int) $matches[1] <= 8 ) {
    2925             $url = wp_json_encode( admin_url( 'press-this.php' ) );
    2926 
    2927             $link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,' .
    2928                 's=(e?e():(k)?k():(x?x.createRange().text:0)),f=' . $url . ',l=d.location,e=encodeURIComponent,' .
    2929                 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . WP_Press_This::VERSION . '";' .
    2930                 'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};' .
    2931                 'if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();void(0)';
    2932         }
    2933     }
    2934 
    2935     if ( empty( $link ) ) {
    2936         $src = @file_get_contents( ABSPATH . 'wp-admin/js/bookmarklet.min.js' );
    2937 
    2938         if ( $src ) {
    2939             $url = wp_json_encode( admin_url( 'press-this.php' ) . '?v=' . WP_Press_This::VERSION );
    2940             $link = 'javascript:' . str_replace( 'window.pt_url', $url, $src );
    2941         }
    2942     }
    2943 
    2944     $link = str_replace( array( "\r", "\n", "\t" ),  '', $link );
    2945 
    2946     /**
    2947      * Filters the Press This bookmarklet link.
    2948      *
    2949      * @since 2.6.0
    2950      *
    2951      * @param string $link The Press This bookmarklet link.
    2952      */
    2953     return apply_filters( 'shortcut_link', $link );
    2954 }
    2955 
    2956 /**
    29572901 * Retrieves the URL for the current site where the front end is accessible.
    29582902 *
  • trunk/src/wp-includes/script-loader.php

    r41572 r41584  
    674674        ) );
    675675
    676         $scripts->add( 'press-this', "/wp-admin/js/press-this$suffix.js", array( 'jquery', 'tags-box', 'wp-sanitize' ), false, 1 );
    677         did_action( 'init' ) && $scripts->localize( 'press-this', 'pressThisL10n', array(
    678             'newPost' => __( 'Title' ),
    679             'serverError' => __( 'Connection lost or the server is busy. Please try again later.' ),
    680             'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
    681             /* translators: %d: nth embed found in a post */
    682             'suggestedEmbedAlt' => __( 'Suggested embed #%d' ),
    683             /* translators: %d: nth image found in a post */
    684             'suggestedImgAlt' => __( 'Suggested image #%d' ),
    685         ) );
    686 
    687676        $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 );
    688677
     
    964953    $styles->add( 'customize-widgets',   "/wp-admin/css/customize-widgets$suffix.css", array( 'wp-admin', 'colors' ) );
    965954    $styles->add( 'customize-nav-menus', "/wp-admin/css/customize-nav-menus$suffix.css", array( 'wp-admin', 'colors' ) );
    966     $styles->add( 'press-this',          "/wp-admin/css/press-this$suffix.css", array( 'buttons' ) );
    967955
    968956    $styles->add( 'ie', "/wp-admin/css/ie$suffix.css" );
     
    1003991        'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus',
    1004992        'widgets', 'site-icon', 'l10n', 'install', 'wp-color-picker', 'customize-controls', 'customize-widgets', 'customize-nav-menus', 'customize-preview',
    1005         'ie', 'login', 'press-this',
     993        'ie', 'login',
    1006994        // wp-includes
    1007995        'buttons', 'admin-bar', 'wp-auth-check', 'editor-buttons', 'media-views', 'wp-pointer',
Note: See TracChangeset for help on using the changeset viewer.