WordPress.org

Make WordPress Core

Ticket #22980: sample_permalink.diff

File sample_permalink.diff, 2.0 KB (added by coreygilmore, 16 months ago)
  • wp-admin/edit-form-advanced.php

    diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
    index 7d142d9..fc52137 100644
    a b wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 
    331331</div> 
    332332<div class="inside"> 
    333333<?php 
     334add_filter( 'get_sample_permalink_html', '_get_sample_permalink_html_shortlink_button', 10, 4 ); 
    334335$sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : ''; 
    335 $shortlink = wp_get_shortlink($post->ID, 'post'); 
    336 if ( !empty($shortlink) ) 
    337     $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>'; 
    338336 
    339337if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> 
    340338        <div id="edit-slug-box" class="hide-if-no-js"> 
  • wp-admin/includes/post.php

    diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
    index e4866ad..7537ecd 100644
    a b function post_preview() { 
    13071307 
    13081308        return $url; 
    13091309} 
     1310 
     1311 
     1312/** 
     1313 * Append the Get Shortlink button to the sample permalink HTML. 
     1314 * 
     1315 * This is attached to the 'sample_permalink_html' filter. Do not call this directly in plugins or theme templates. 
     1316 * 
     1317 * @uses get_sample_permalink_html() 
     1318 * 
     1319 * @return string The HTML of the sample permalink slug editor. 
     1320 */ 
     1321function _get_sample_permalink_html_shortlink_button( $sample_permalink_html, $post_id, $new_title, $new_slug ) { 
     1322        $shortlink = wp_get_shortlink($post_id, 'post'); 
     1323        if ( !empty($shortlink) ) 
     1324                $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>'; 
     1325 
     1326        return $sample_permalink_html; 
     1327}