Changeset 22129
- Timestamp:
- 10/07/2012 03:44:30 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ajax-actions.php
r22120 r22129 1299 1299 $title = isset($_POST['new_title'])? $_POST['new_title'] : ''; 1300 1300 $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null; 1301 wp_die( get_sample_permalink_html( $post_id, $title, $slug ) ); 1301 $screen = isset( $_POST['screen'] ) ? $_POST['screen'] : 'post'; 1302 wp_die( get_sample_permalink_html( $post_id, $title, $slug, $screen ) ); 1302 1303 } 1303 1304 -
trunk/wp-admin/includes/post.php
r22127 r22129 1048 1048 1049 1049 /** 1050 * sample permalink html 1051 * 1052 * intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor. 1050 * Returns the HTML of the sample permalink slug editor. 1053 1051 * 1054 1052 * @since 2.5.0 1055 1053 * 1056 1054 * @param int|object $id Post ID or post object. 1057 * @param string $new_title (optional) New title 1058 * @param string $new_slug (optional) New slug 1059 * @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor. 1060 */ 1061 function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { 1055 * @param string $new_title Optional. New title. 1056 * @param string $new_slug Optional. New slug. 1057 * @param string|WP_Screen $screen Optional. Screen where the editor is being shown. 1058 * @return string The HTML of the sample permalink slug editor. 1059 */ 1060 function get_sample_permalink_html( $id, $new_title = null, $new_slug = null, $screen = null ) { 1062 1061 global $wpdb; 1063 1062 $post = get_post($id); 1064 1063 1065 $context = isset( $_POST['context'] ) ? $_POST['context'] : get_current_screen()->id;1066 1064 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); 1065 1066 if ( isset( $screen ) ) 1067 $screen = convert_to_screen( $screen ); 1068 else 1069 $screen = get_current_screen(); 1067 1070 1068 1071 if ( 'publish' == get_post_status( $post ) ) { … … 1075 1078 1076 1079 if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) { 1077 if ( 'options-reading' == $ context)1080 if ( 'options-reading' == $screen->id ) 1078 1081 return ''; 1079 1082 $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n"; … … 1105 1108 $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); 1106 1109 $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink); 1107 $return = ( 'options-reading' == $ context) ? __( 'Located at' ) . "\n" : '<strong>' . __( 'Permalink:' ) . "</strong>\n";1110 $return = ( 'options-reading' == $screen->id ) ? __( 'Located at' ) . "\n" : '<strong>' . __( 'Permalink:' ) . "</strong>\n"; 1108 1111 $return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n"; 1109 1112 $return .= '‎'; // Fix bi-directional text display defect in RTL languages. 1110 1113 $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button button-small hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n"; 1111 1114 $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; 1112 if ( isset( $view_post ) && 'options-reading' != $ context)1115 if ( isset( $view_post ) && 'options-reading' != $screen->id ) 1113 1116 $return .= "<span id='view-post-btn'><a href='$view_link' class='button button-small'>$view_post</a></span>\n"; 1114 1117 -
trunk/wp-admin/js/sample-permalink.js
r22127 r22129 26 26 new_slug: new_slug, 27 27 new_title: $('#title').val(), 28 context: pagenow,28 screen: pagenow, 29 29 samplepermalinknonce: $('#samplepermalinknonce').val() 30 30 }, function(data) { -
trunk/wp-includes/script-loader.php
r22127 r22129 370 370 $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 ); 371 371 372 $scripts->add( 'sample-permalink', "/wp-admin/js/sample-permalink .js", array(), false, 1 );372 $scripts->add( 'sample-permalink', "/wp-admin/js/sample-permalink$suffix.js", array(), false, 1 ); 373 373 did_action( 'init' ) && $scripts->localize( 'sample-permalink', 'samplePermalinkL10n', array( 374 374 'ok' => __('OK'),
Note: See TracChangeset
for help on using the changeset viewer.