1244
1247
/** This filter is documented in wp-admin/edit-tag-form.php */
1245
$uri = apply_filters( 'editable_slug', $uri );
1248
$uri = apply_filters( 'editable_slug', $uri, $post );
1246
1249
if ( !empty($uri) )
1248
1251
$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
1251
1254
/** This filter is documented in wp-admin/edit-tag-form.php */
1252
$permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name ) );
1255
$permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name, $post ) );
1253
1256
$post->post_status = $original_status;
1254
1257
$post->post_date = $original_date;
1255
1258
$post->post_name = $original_name;
1256
1259
unset($post->filter);
1262
* Filter the sample permalink.
1266
* @param string $permalink Sample permalink.
1267
* @param int $post_id Post ID.
1268
* @param string $title Post title.
1269
* @param string $name Post name (slug).
1270
* @param WP_Post $post Post object.
1272
return apply_filters( 'get_sample_permalink', $permalink, $post->ID, $title, $name, $post );
1276
1290
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
1293
$preview_target = '';
1278
1295
if ( current_user_can( 'read_post', $post->ID ) ) {
1279
$ptype = get_post_type_object( $post->post_type );
1280
$view_post = $ptype->labels->view_item;
1283
if ( 'publish' == get_post_status( $post ) ) {
1284
$title = __('Click to edit this part of the permalink');
1286
$title = __('Temporary permalink. Click to edit this part.');
1296
if ( 'draft' === $post->post_status ) {
1297
$draft_link = set_url_scheme( get_permalink( $post->ID ) );
1298
$view_link = get_preview_post_link( $post, array(), $draft_link );
1299
$preview_target = " target='wp-preview-{$post->ID}'";
1301
if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) {
1302
$view_link = get_permalink( $post );
1304
// Allow non-published (private, future) to be viewed at a pretty permalink.
1305
$view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, urldecode( $permalink ) );
1310
// Permalinks without a post/page name placeholder don't have anything to edit
1289
1311
if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) {
1290
$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink" tabindex="-1">' . $permalink . "</span>\n";
1312
$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
1314
if ( false !== $view_link ) {
1315
$return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $view_link . "</a>\n";
1317
$return .= '<span id="sample-permalink">' . $permalink . "</span>\n";
1320
// Encourage a pretty permalink setting
1291
1321
if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) {
1292
1322
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
1295
1325
if ( function_exists( 'mb_strlen' ) ) {
1296
if ( mb_strlen( $post_name ) > 30 ) {
1297
$post_name_abridged = mb_substr( $post_name, 0, 14 ) . '…' . mb_substr( $post_name, -14 );
1326
if ( mb_strlen( $post_name ) > 34 ) {
1327
$post_name_abridged = mb_substr( $post_name, 0, 16 ) . '…' . mb_substr( $post_name, -16 );
1299
1329
$post_name_abridged = $post_name;
1302
if ( strlen( $post_name ) > 30 ) {
1303
$post_name_abridged = substr( $post_name, 0, 14 ) . '…' . substr( $post_name, -14 );
1332
if ( strlen( $post_name ) > 34 ) {
1333
$post_name_abridged = substr( $post_name, 0, 16 ) . '…' . substr( $post_name, -16 );
1305
1335
$post_name_abridged = $post_name;
1309
$post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
1339
$post_name_html = '<span id="editable-post-name">' . $post_name_abridged . '</span>';
1310
1340
$display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) );
1311
$pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post_name, urldecode( $permalink ) );
1313
$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
1314
$return .= '<span id="sample-permalink" tabindex="-1">' . $display_link . "</span>\n";
1342
$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
1343
$return .= '<span id="sample-permalink"><a href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a></span>\n";
1315
1344
$return .= '‎'; // Fix bi-directional text display defect in RTL languages.
1316
$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";
1345
$return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="' . __( 'Edit permalink' ) . '">' . __( 'Edit' ) . "</button></span>\n";
1317
1346
$return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
1320
if ( isset( $view_post ) ) {
1321
if ( 'draft' == $post->post_status ) {
1322
$preview_link = set_url_scheme( get_permalink( $post->ID ) );
1323
/** This filter is documented in wp-admin/includes/meta-boxes.php */
1324
$preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
1325
$return .= "<span id='view-post-btn'><a href='" . esc_url( $preview_link ) . "' class='button button-small' target='wp-preview-{$post->ID}'>$view_post</a></span>\n";
1327
if ( empty( $pretty_permalink ) ) {
1328
$pretty_permalink = $permalink;
1331
$return .= "<span id='view-post-btn'><a href='" . $pretty_permalink . "' class='button button-small'>$view_post</a></span>\n";
1336
1350
* Filter the sample permalink HTML markup.
1353
* @since 4.4.0 Added `$post` parameter.
1340
* @param string $return Sample permalink HTML markup.
1341
* @param int|WP_Post $id Post object or ID.
1342
* @param string $new_title New sample permalink title.
1343
* @param string $new_slug New sample permalink slug.
1355
* @param string $return Sample permalink HTML markup.
1356
* @param int $post_id Post ID.
1357
* @param string $new_title New sample permalink title.
1358
* @param string $new_slug New sample permalink slug.
1359
* @param WP_Post $post Post object.
1345
$return = apply_filters( 'get_sample_permalink_html', $return, $id, $new_title, $new_slug );
1361
$return = apply_filters( 'get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post );
1347
1363
return $return;
1376
1392
if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
1377
$old_content_width = $content_width;
1378
$content_width = 266;
1379
if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) )
1380
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );
1382
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
1393
$size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 );
1396
* Filter the size used to display the post thumbnail image in the 'Featured Image' meta box.
1398
* Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail'
1399
* image size is registered, which differs from the 'thumbnail' image size
1400
* managed via the Settings > Media screen. See the `$size` parameter description
1401
* for more information on default values.
1405
* @param string|array $size Post thumbnail image size to display in the meta box. Accepts any valid
1406
* image size, or an array of width and height values in pixels (in that order).
1407
* If the 'post-thumbnail' size is set, default is 'post-thumbnail'. Otherwise,
1408
* default is an array with 266 as both the height and width values.
1409
* @param int $thumbnail_id Post thumbnail attachment ID.
1410
* @param WP_Post $post The post object associated with the thumbnail.
1412
$size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post );
1414
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size );
1383
1416
if ( !empty( $thumbnail_html ) ) {
1384
1417
$ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
1385
1418
$content = sprintf( $set_thumbnail_link,
1766
1792
return wp_create_post_autosave( wp_slash( $post_data ) );
1797
* Redirect to previous page.
1799
* @param int $post_id Optional. Post ID.
1801
function redirect_post($post_id = '') {
1802
if ( isset($_POST['save']) || isset($_POST['publish']) ) {
1803
$status = get_post_status( $post_id );
1805
if ( isset( $_POST['publish'] ) ) {
1806
switch ( $status ) {
1817
$message = 'draft' == $status ? 10 : 1;
1820
$location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
1821
} elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) {
1822
$location = add_query_arg( 'message', 2, wp_get_referer() );
1823
$location = explode('#', $location);
1824
$location = $location[0] . '#postcustom';
1825
} elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) {
1826
$location = add_query_arg( 'message', 3, wp_get_referer() );
1827
$location = explode('#', $location);
1828
$location = $location[0] . '#postcustom';
1830
$location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) );
1834
* Filter the post redirect destination URL.
1838
* @param string $location The destination URL.
1839
* @param int $post_id The post ID.
1841
wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
b'\\ No newline at end of file'