Make WordPress Core

Ticket #22980: 22980.diff

File 22980.diff, 2.9 KB (added by jeremyfelt, 11 years ago)
  • src/wp-admin/edit-form-advanced.php

     
    447447<div class="inside">
    448448<?php
    449449$sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';
    450 $shortlink = wp_get_shortlink($post->ID, 'post');
    451 $permalink = get_permalink( $post->ID );
    452 if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) )
    453     $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
    454450
    455451if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) {
    456452        $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
  • src/wp-admin/includes/post.php

     
    14511451                return wp_create_post_autosave( $post_data );
    14521452        }
    14531453}
     1454
     1455/**
     1456 * Append the Get Shortlink button to the sample permalink HTML.
     1457 *
     1458 * This is attached to the 'sample_permalink_html' filter. Do not call this directly in plugins or theme templates.
     1459 *
     1460 * @uses get_sample_permalink_html()
     1461 *
     1462 * @return string The HTML of the sample permalink slug editor.
     1463 */
     1464function _get_sample_permalink_html_shortlink_button( $sample_permalink_html, $post_id, $new_title, $new_slug ) {
     1465        $shortlink = wp_get_shortlink( $post_id, 'post' );
     1466        $permalink = get_permalink( $post_id );
     1467
     1468        if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url( '?page_id=' . $post_id ) ) {
     1469                $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><a href="#" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
     1470        }
     1471
     1472        return $sample_permalink_html;
     1473}
     1474 No newline at end of file
  • src/wp-includes/default-filters.php

     
    289289// This option no longer exists; tell plugins we always support auto-embedding.
    290290add_filter( 'default_option_embed_autourls', '__return_true' );
    291291
     292// Append shortlink to the slug display.
     293add_filter( 'get_sample_permalink_html', '_get_sample_permalink_html_shortlink_button', 5, 4 );
     294
    292295// Default settings for heartbeat
    293296add_filter( 'heartbeat_settings', 'wp_heartbeat_settings' );
    294297