WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (21 months ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-advanced.php

    r42228 r42343  
    88
    99// don't load directly
    10 if ( !defined('ABSPATH') )
    11     die('-1');
     10if ( ! defined( 'ABSPATH' ) ) {
     11    die( '-1' );
     12}
    1213
    1314/**
     
    2122    add_action( 'admin_footer', '_admin_notice_post_locked' );
    2223} else {
    23     $check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) );
    24 
    25     if ( count( $check_users ) > 1 )
     24    $check_users = get_users(
     25        array(
     26            'fields' => 'ID',
     27            'number' => 2,
     28        )
     29    );
     30
     31    if ( count( $check_users ) > 1 ) {
    2632        add_action( 'admin_footer', '_admin_notice_post_locked' );
     33    }
    2734
    2835    unset( $check_users );
    2936}
    3037
    31 wp_enqueue_script('post');
     38wp_enqueue_script( 'post' );
    3239$_wp_editor_expand = $_content_editor_dfw = false;
    3340
     
    4552    apply_filters( 'wp_editor_expand', true, $post_type ) ) {
    4653
    47     wp_enqueue_script('editor-expand');
     54    wp_enqueue_script( 'editor-expand' );
    4855    $_content_editor_dfw = true;
    49     $_wp_editor_expand = ( get_user_setting( 'editor_expand', 'on' ) === 'on' );
    50 }
    51 
    52 if ( wp_is_mobile() )
     56    $_wp_editor_expand   = ( get_user_setting( 'editor_expand', 'on' ) === 'on' );
     57}
     58
     59if ( wp_is_mobile() ) {
    5360    wp_enqueue_script( 'jquery-touch-punch' );
     61}
    5462
    5563/**
    5664 * Post ID global
     65 *
    5766 * @name $post_ID
    5867 * @var int
    5968 */
    60 $post_ID = isset($post_ID) ? (int) $post_ID : 0;
    61 $user_ID = isset($user_ID) ? (int) $user_ID : 0;
    62 $action = isset($action) ? $action : '';
     69$post_ID = isset( $post_ID ) ? (int) $post_ID : 0;
     70$user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
     71$action  = isset( $action ) ? $action : '';
    6372
    6473if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) {
     
    104113
    105114    // Preview post link.
    106     $preview_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
     115    $preview_post_link_html = sprintf(
     116        ' <a target="_blank" href="%1$s">%2$s</a>',
    107117        esc_url( $preview_url ),
    108118        __( 'Preview post' )
     
    110120
    111121    // Scheduled post preview link.
    112     $scheduled_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
     122    $scheduled_post_link_html = sprintf(
     123        ' <a target="_blank" href="%1$s">%2$s</a>',
    113124        esc_url( $permalink ),
    114125        __( 'Preview post' )
     
    116127
    117128    // View post link.
    118     $view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
     129    $view_post_link_html = sprintf(
     130        ' <a href="%1$s">%2$s</a>',
    119131        esc_url( $permalink ),
    120132        __( 'View post' )
     
    122134
    123135    // Preview page link.
    124     $preview_page_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
     136    $preview_page_link_html = sprintf(
     137        ' <a target="_blank" href="%1$s">%2$s</a>',
    125138        esc_url( $preview_url ),
    126139        __( 'Preview page' )
     
    128141
    129142    // Scheduled page preview link.
    130     $scheduled_page_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
     143    $scheduled_page_link_html = sprintf(
     144        ' <a target="_blank" href="%1$s">%2$s</a>',
    131145        esc_url( $permalink ),
    132146        __( 'Preview page' )
     
    134148
    135149    // View page link.
    136     $view_page_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
     150    $view_page_link_html = sprintf(
     151        ' <a href="%1$s">%2$s</a>',
    137152        esc_url( $permalink ),
    138153        __( 'View page' )
     
    145160
    146161$messages['post'] = array(
    147     0 => '', // Unused. Messages start at index 1.
    148     1 => __( 'Post updated.' ) . $view_post_link_html,
    149     2 => __( 'Custom field updated.' ),
    150     3 => __( 'Custom field deleted.' ),
    151     4 => __( 'Post updated.' ),
     162    0  => '', // Unused. Messages start at index 1.
     163    1  => __( 'Post updated.' ) . $view_post_link_html,
     164    2  => __( 'Custom field updated.' ),
     165    3  => __( 'Custom field deleted.' ),
     166    4  => __( 'Post updated.' ),
    152167    /* translators: %s: date and time of the revision */
    153     5 => isset($_GET['revision']) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    154     6 => __( 'Post published.' ) . $view_post_link_html,
    155     7 => __( 'Post saved.' ),
    156     8 => __( 'Post submitted.' ) . $preview_post_link_html,
    157     9 => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
     168    5  => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
     169    6  => __( 'Post published.' ) . $view_post_link_html,
     170    7  => __( 'Post saved.' ),
     171    8  => __( 'Post submitted.' ) . $preview_post_link_html,
     172    9  => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
    158173    10 => __( 'Post draft updated.' ) . $preview_post_link_html,
    159174);
    160175$messages['page'] = array(
    161     0 => '', // Unused. Messages start at index 1.
    162     1 => __( 'Page updated.' ) . $view_page_link_html,
    163     2 => __( 'Custom field updated.' ),
    164     3 => __( 'Custom field deleted.' ),
    165     4 => __( 'Page updated.' ),
     176    0  => '', // Unused. Messages start at index 1.
     177    1  => __( 'Page updated.' ) . $view_page_link_html,
     178    2  => __( 'Custom field updated.' ),
     179    3  => __( 'Custom field deleted.' ),
     180    4  => __( 'Page updated.' ),
    166181    /* translators: %s: date and time of the revision */
    167     5 => isset($_GET['revision']) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    168     6 => __( 'Page published.' ) . $view_page_link_html,
    169     7 => __( 'Page saved.' ),
    170     8 => __( 'Page submitted.' ) . $preview_page_link_html,
    171     9 => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
     182    5  => isset( $_GET['revision'] ) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
     183    6  => __( 'Page published.' ) . $view_page_link_html,
     184    7  => __( 'Page saved.' ),
     185    8  => __( 'Page submitted.' ) . $preview_page_link_html,
     186    9  => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
    172187    10 => __( 'Page draft updated.' ) . $preview_page_link_html,
    173188);
     
    184199
    185200$message = false;
    186 if ( isset($_GET['message']) ) {
     201if ( isset( $_GET['message'] ) ) {
    187202    $_GET['message'] = absint( $_GET['message'] );
    188     if ( isset($messages[$post_type][$_GET['message']]) )
    189         $message = $messages[$post_type][$_GET['message']];
    190     elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) )
    191         $message = $messages['post'][$_GET['message']];
    192 }
    193 
    194 $notice = false;
     203    if ( isset( $messages[ $post_type ][ $_GET['message'] ] ) ) {
     204        $message = $messages[ $post_type ][ $_GET['message'] ];
     205    } elseif ( ! isset( $messages[ $post_type ] ) && isset( $messages['post'][ $_GET['message'] ] ) ) {
     206        $message = $messages['post'][ $_GET['message'] ];
     207    }
     208}
     209
     210$notice     = false;
    195211$form_extra = '';
    196212if ( 'auto-draft' == $post->post_status ) {
    197     if ( 'edit' == $action )
     213    if ( 'edit' == $action ) {
    198214        $post->post_title = '';
    199     $autosave = false;
     215    }
     216    $autosave    = false;
    200217    $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
    201218} else {
     
    203220}
    204221
    205 $form_action = 'editpost';
     222$form_action  = 'editpost';
    206223$nonce_action = 'update-post_' . $post_ID;
    207 $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";
     224$form_extra  .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />";
    208225
    209226// Detect if there exists an autosave newer than the post and if that autosave is different than the post
     
    216233    }
    217234    // If this autosave isn't different from the current post, begone.
    218     if ( ! $notice )
     235    if ( ! $notice ) {
    219236        wp_delete_post_revision( $autosave->ID );
    220     unset($autosave_field, $_autosave_field);
    221 }
    222 
    223 $post_type_object = get_post_type_object($post_type);
     237    }
     238    unset( $autosave_field, $_autosave_field );
     239}
     240
     241$post_type_object = get_post_type_object( $post_type );
    224242
    225243// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
     
    228246
    229247$publish_callback_args = null;
    230 if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
     248if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' != $post->post_status ) {
    231249    $revisions = wp_get_post_revisions( $post_ID );
    232250
     
    234252    if ( count( $revisions ) > 1 ) {
    235253        reset( $revisions ); // Reset pointer for key()
    236         $publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) );
    237         add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
     254        $publish_callback_args = array(
     255            'revisions_count' => count( $revisions ),
     256            'revision_id'     => key( $revisions ),
     257        );
     258        add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core' );
    238259    }
    239260}
     
    242263    wp_enqueue_script( 'image-edit' );
    243264    wp_enqueue_style( 'imgareaselect' );
    244     add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
     265    add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core' );
    245266    add_action( 'edit_form_after_title', 'edit_form_image_editor' );
    246267
     
    252273}
    253274
    254 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )
     275if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) {
    255276    add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' );
     277}
    256278
    257279// all taxonomies
    258280foreach ( get_object_taxonomies( $post ) as $tax_name ) {
    259281    $taxonomy = get_taxonomy( $tax_name );
    260     if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb )
     282    if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) {
    261283        continue;
     284    }
    262285
    263286    $label = $taxonomy->labels->name;
    264287
    265     if ( ! is_taxonomy_hierarchical( $tax_name ) )
     288    if ( ! is_taxonomy_hierarchical( $tax_name ) ) {
    266289        $tax_meta_box_id = 'tagsdiv-' . $tax_name;
    267     else
     290    } else {
    268291        $tax_meta_box_id = $tax_name . 'div';
     292    }
    269293
    270294    add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array( 'taxonomy' => $tax_name ) );
     
    275299}
    276300
    277 if ( $thumbnail_support && current_user_can( 'upload_files' ) )
    278     add_meta_box('postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low');
    279 
    280 if ( post_type_supports($post_type, 'excerpt') )
    281     add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core');
    282 
    283 if ( post_type_supports($post_type, 'trackbacks') )
    284     add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', null, 'normal', 'core');
    285 
    286 if ( post_type_supports($post_type, 'custom-fields') )
    287     add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', null, 'normal', 'core');
     301if ( $thumbnail_support && current_user_can( 'upload_files' ) ) {
     302    add_meta_box( 'postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low' );
     303}
     304
     305if ( post_type_supports( $post_type, 'excerpt' ) ) {
     306    add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'post_excerpt_meta_box', null, 'normal', 'core' );
     307}
     308
     309if ( post_type_supports( $post_type, 'trackbacks' ) ) {
     310    add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'post_trackback_meta_box', null, 'normal', 'core' );
     311}
     312
     313if ( post_type_supports( $post_type, 'custom-fields' ) ) {
     314    add_meta_box( 'postcustom', __( 'Custom Fields' ), 'post_custom_meta_box', null, 'normal', 'core' );
     315}
    288316
    289317/**
     
    317345}
    318346
    319 if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) )
    320     add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core');
     347if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
     348    add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core' );
     349}
    321350
    322351if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) {
     
    362391do_action( 'do_meta_boxes', $post_type, 'side', $post );
    363392
    364 add_screen_option('layout_columns', array('max' => 2, 'default' => 2) );
     393add_screen_option(
     394    'layout_columns', array(
     395        'max'     => 2,
     396        'default' => 2,
     397    )
     398);
    365399
    366400if ( 'post' == $post_type ) {
    367     $customize_display = '<p>' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.') . '</p>';
    368 
    369     get_current_screen()->add_help_tab( array(
    370         'id'      => 'customize-display',
    371         'title'   => __('Customizing This Display'),
    372         'content' => $customize_display,
    373     ) );
    374 
    375     $title_and_editor  = '<p>' . __('<strong>Title</strong> &mdash; Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.') . '</p>';
     401    $customize_display = '<p>' . __( 'The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.' ) . '</p>';
     402
     403    get_current_screen()->add_help_tab(
     404        array(
     405            'id'      => 'customize-display',
     406            'title'   => __( 'Customizing This Display' ),
     407            'content' => $customize_display,
     408        )
     409    );
     410
     411    $title_and_editor  = '<p>' . __( '<strong>Title</strong> &mdash; Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.' ) . '</p>';
    376412    $title_and_editor .= '<p>' . __( '<strong>Post editor</strong> &mdash; Enter the text for your post. There are two modes of editing: Visual and Text. Choose the mode by clicking on the appropriate tab.' ) . '</p>';
    377413    $title_and_editor .= '<p>' . __( 'Visual mode gives you an editor that is similar to a word processor. Click the Toolbar Toggle button to get a second row of controls.' ) . '</p>';
     
    381417    $title_and_editor .= '<p>' . __( 'Keyboard users: When you&#8217;re working in the visual editor, you can use <kbd>Alt + F10</kbd> to access the toolbar.' ) . '</p>';
    382418
    383     get_current_screen()->add_help_tab( array(
    384         'id'      => 'title-post-editor',
    385         'title'   => __('Title and Post Editor'),
    386         'content' => $title_and_editor,
    387     ) );
     419    get_current_screen()->add_help_tab(
     420        array(
     421            'id'      => 'title-post-editor',
     422            'title'   => __( 'Title and Post Editor' ),
     423            'content' => $title_and_editor,
     424        )
     425    );
    388426
    389427    get_current_screen()->set_help_sidebar(
    390             '<p>' . sprintf(__('You can also create posts with the <a href="%s">Press This bookmarklet</a>.'), 'tools.php') . '</p>' .
    391             '<p><strong>' . __('For more information:') . '</strong></p>' .
    392             '<p>' . __('<a href="https://codex.wordpress.org/Posts_Add_New_Screen">Documentation on Writing and Editing Posts</a>') . '</p>' .
    393             '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
     428        '<p>' . sprintf( __( 'You can also create posts with the <a href="%s">Press This bookmarklet</a>.' ), 'tools.php' ) . '</p>' .
     429            '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
     430            '<p>' . __( '<a href="https://codex.wordpress.org/Posts_Add_New_Screen">Documentation on Writing and Editing Posts</a>' ) . '</p>' .
     431            '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    394432    );
    395433} elseif ( 'page' == $post_type ) {
    396     $about_pages = '<p>' . __('Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the &#8220;Parent&#8221; of the other, creating a group of pages.') . '</p>' .
    397         '<p>' . __('Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.') . '</p>';
    398 
    399     get_current_screen()->add_help_tab( array(
    400         'id'      => 'about-pages',
    401         'title'   => __('About Pages'),
    402         'content' => $about_pages,
    403     ) );
     434    $about_pages = '<p>' . __( 'Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the &#8220;Parent&#8221; of the other, creating a group of pages.' ) . '</p>' .
     435        '<p>' . __( 'Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.' ) . '</p>';
     436
     437    get_current_screen()->add_help_tab(
     438        array(
     439            'id'      => 'about-pages',
     440            'title'   => __( 'About Pages' ),
     441            'content' => $about_pages,
     442        )
     443    );
    404444
    405445    get_current_screen()->set_help_sidebar(
    406             '<p><strong>' . __('For more information:') . '</strong></p>' .
    407             '<p>' . __('<a href="https://codex.wordpress.org/Pages_Add_New_Screen">Documentation on Adding New Pages</a>') . '</p>' .
    408             '<p>' . __('<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages">Documentation on Editing Pages</a>') . '</p>' .
    409             '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
     446        '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
     447            '<p>' . __( '<a href="https://codex.wordpress.org/Pages_Add_New_Screen">Documentation on Adding New Pages</a>' ) . '</p>' .
     448            '<p>' . __( '<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages">Documentation on Editing Pages</a>' ) . '</p>' .
     449            '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    410450    );
    411451} elseif ( 'attachment' == $post_type ) {
    412     get_current_screen()->add_help_tab( array(
    413         'id'      => 'overview',
    414         'title'   => __('Overview'),
    415         'content' =>
    416             '<p>' . __('This screen allows you to edit four fields for metadata in a file within the media library.') . '</p>' .
    417             '<p>' . __('For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.') . '</p>' .
    418             '<p>' . __('Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.') . '</p>' .
    419             '<p>' . __('Remember to click Update Media to save metadata entered or changed.') . '</p>'
    420     ) );
     452    get_current_screen()->add_help_tab(
     453        array(
     454            'id'      => 'overview',
     455            'title'   => __( 'Overview' ),
     456            'content' =>
     457                '<p>' . __( 'This screen allows you to edit four fields for metadata in a file within the media library.' ) . '</p>' .
     458                '<p>' . __( 'For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.' ) . '</p>' .
     459                '<p>' . __( 'Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.' ) . '</p>' .
     460                '<p>' . __( 'Remember to click Update Media to save metadata entered or changed.' ) . '</p>',
     461        )
     462    );
    421463
    422464    get_current_screen()->set_help_sidebar(
    423     '<p><strong>' . __('For more information:') . '</strong></p>' .
    424     '<p>' . __('<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>') . '</p>' .
    425     '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
     465        '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
     466        '<p>' . __( '<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>' ) . '</p>' .
     467        '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    426468    );
    427469}
    428470
    429471if ( 'post' == $post_type || 'page' == $post_type ) {
    430     $inserting_media = '<p>' . __( 'You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your page or post. To create an image gallery, select the images to add and click the &#8220;Create a new gallery&#8221; button.' ) . '</p>';
     472    $inserting_media  = '<p>' . __( 'You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your page or post. To create an image gallery, select the images to add and click the &#8220;Create a new gallery&#8221; button.' ) . '</p>';
    431473    $inserting_media .= '<p>' . __( 'You can also embed media from many popular websites including Twitter, YouTube, Flickr and others by pasting the media URL on its own line into the content of your post/page. Please refer to the Codex to <a href="https://codex.wordpress.org/Embeds">learn more about embeds</a>.' ) . '</p>';
    432474
    433     get_current_screen()->add_help_tab( array(
    434         'id'        => 'inserting-media',
    435         'title'     => __( 'Inserting Media' ),
    436         'content'   => $inserting_media,
    437     ) );
     475    get_current_screen()->add_help_tab(
     476        array(
     477            'id'      => 'inserting-media',
     478            'title'   => __( 'Inserting Media' ),
     479            'content' => $inserting_media,
     480        )
     481    );
    438482}
    439483
    440484if ( 'post' == $post_type ) {
    441     $publish_box = '<p>' . __('Several boxes on this screen contain settings for how your content will be published, including:') . '</p>';
     485    $publish_box  = '<p>' . __( 'Several boxes on this screen contain settings for how your content will be published, including:' ) . '</p>';
    442486    $publish_box .= '<ul><li>' .
    443487        __( '<strong>Publish</strong> &mdash; You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). The Password protected option allows you to set an arbitrary password for each post. The Private option hides the post from everyone except editors and administrators. Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.' ) .
     
    455499    $publish_box .= '</ul>';
    456500
    457     get_current_screen()->add_help_tab( array(
    458         'id'      => 'publish-box',
    459         'title'   => __('Publish Settings'),
    460         'content' => $publish_box,
    461     ) );
    462 
    463     $discussion_settings  = '<p>' . __('<strong>Send Trackbacks</strong> &mdash; Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.') . '</p>';
    464     $discussion_settings .= '<p>' . __('<strong>Discussion</strong> &mdash; You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.') . '</p>';
    465 
    466     get_current_screen()->add_help_tab( array(
    467         'id'      => 'discussion-settings',
    468         'title'   => __('Discussion Settings'),
    469         'content' => $discussion_settings,
    470     ) );
     501    get_current_screen()->add_help_tab(
     502        array(
     503            'id'      => 'publish-box',
     504            'title'   => __( 'Publish Settings' ),
     505            'content' => $publish_box,
     506        )
     507    );
     508
     509    $discussion_settings  = '<p>' . __( '<strong>Send Trackbacks</strong> &mdash; Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.' ) . '</p>';
     510    $discussion_settings .= '<p>' . __( '<strong>Discussion</strong> &mdash; You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.' ) . '</p>';
     511
     512    get_current_screen()->add_help_tab(
     513        array(
     514            'id'      => 'discussion-settings',
     515            'title'   => __( 'Discussion Settings' ),
     516            'content' => $discussion_settings,
     517        )
     518    );
    471519} elseif ( 'page' == $post_type ) {
    472     $page_attributes = '<p>' . __('<strong>Parent</strong> &mdash; You can arrange your pages in hierarchies. For example, you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how many levels you can nest pages.') . '</p>' .
    473         '<p>' . __('<strong>Template</strong> &mdash; Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them in this dropdown menu.') . '</p>' .
    474         '<p>' . __('<strong>Order</strong> &mdash; Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '</p>';
    475 
    476     get_current_screen()->add_help_tab( array(
    477         'id' => 'page-attributes',
    478         'title' => __('Page Attributes'),
    479         'content' => $page_attributes,
    480     ) );
     520    $page_attributes = '<p>' . __( '<strong>Parent</strong> &mdash; You can arrange your pages in hierarchies. For example, you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how many levels you can nest pages.' ) . '</p>' .
     521        '<p>' . __( '<strong>Template</strong> &mdash; Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them in this dropdown menu.' ) . '</p>' .
     522        '<p>' . __( '<strong>Order</strong> &mdash; Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.' ) . '</p>';
     523
     524    get_current_screen()->add_help_tab(
     525        array(
     526            'id'      => 'page-attributes',
     527            'title'   => __( 'Page Attributes' ),
     528            'content' => $page_attributes,
     529        )
     530    );
    481531}
    482532
     
    485535
    486536<div class="wrap">
    487 <h1 class="wp-heading-inline"><?php
     537<h1 class="wp-heading-inline">
     538<?php
    488539echo esc_html( $title );
    489 ?></h1>
     540?>
     541</h1>
    490542
    491543<?php
     
    498550
    499551<?php if ( $notice ) : ?>
    500 <div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice ?></p></div>
     552<div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice; ?></p></div>
    501553<?php endif; ?>
    502554<?php if ( $message ) : ?>
     
    508560    </p>
    509561</div>
    510 <form name="post" action="post.php" method="post" id="post"<?php
     562<form name="post" action="post.php" method="post" id="post"
     563<?php
    511564/**
    512565 * Fires inside the post editor form tag.
     
    519572
    520573$referer = wp_get_referer();
    521 ?>>
    522 <?php wp_nonce_field($nonce_action); ?>
    523 <input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
    524 <input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ) ?>" />
    525 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ) ?>" />
     574?>
     575>
     576<?php wp_nonce_field( $nonce_action ); ?>
     577<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID; ?>" />
     578<input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ); ?>" />
     579<input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ); ?>" />
    526580<input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
    527 <input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ) ?>" />
    528 <input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status) ?>" />
     581<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
     582<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ); ?>" />
    529583<input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
    530584<?php if ( ! empty( $active_post_lock ) ) { ?>
     
    532586<?php
    533587}
    534 if ( 'draft' != get_post_status( $post ) )
    535     wp_original_referer_field(true, 'previous');
     588if ( 'draft' != get_post_status( $post ) ) {
     589    wp_original_referer_field( true, 'previous' );
     590}
    536591
    537592echo $form_extra;
     
    551606 * @param WP_Post $post Post object.
    552607 */
    553 do_action( 'edit_form_top', $post ); ?>
     608do_action( 'edit_form_top', $post );
     609?>
    554610
    555611<div id="poststuff">
     
    557613<div id="post-body-content">
    558614
    559 <?php if ( post_type_supports($post_type, 'title') ) { ?>
     615<?php if ( post_type_supports( $post_type, 'title' ) ) { ?>
    560616<div id="titlediv">
    561617<div id="titlewrap">
     
    587643<?php
    588644if ( $viewable ) :
    589 $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';
    590 
    591 // As of 4.4, the Get Shortlink button is hidden by default.
    592 if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
    593     $shortlink = wp_get_shortlink($post->ID, 'post');
    594 
    595     if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) ) {
    596         $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
    597     }
    598 }
    599 
    600 if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) {
    601     $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
    602 ?>
     645    $sample_permalink_html = $post_type_object->public ? get_sample_permalink_html( $post->ID ) : '';
     646
     647    // As of 4.4, the Get Shortlink button is hidden by default.
     648    if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
     649        $shortlink = wp_get_shortlink( $post->ID, 'post' );
     650
     651        if ( ! empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url( '?page_id=' . $post->ID ) ) {
     652            $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
     653        }
     654    }
     655
     656    if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
     657        $has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
     658    ?>
    603659    <div id="edit-slug-box" class="hide-if-no-js">
    604660    <?php
    605         if ( $has_sample_permalink )
    606             echo $sample_permalink_html;
     661    if ( $has_sample_permalink ) {
     662        echo $sample_permalink_html;
     663    }
    607664    ?>
    608665    </div>
    609 <?php
    610 }
     666    <?php
     667    }
    611668endif;
    612669?>
     
    627684do_action( 'edit_form_after_title', $post );
    628685
    629 if ( post_type_supports($post_type, 'editor') ) {
     686if ( post_type_supports( $post_type, 'editor' ) ) {
    630687    $_wp_editor_expand_class = '';
    631688    if ( $_wp_editor_expand ) {
     
    635692<div id="postdivrich" class="postarea<?php echo $_wp_editor_expand_class; ?>">
    636693
    637 <?php wp_editor( $post->post_content, 'content', array(
    638     '_content_editor_dfw' => $_content_editor_dfw,
    639     'drag_drop_upload' => true,
    640     'tabfocus_elements' => 'content-html,save-post',
    641     'editor_height' => 300,
    642     'tinymce' => array(
    643         'resize' => false,
    644         'wp_autoresize_on' => $_wp_editor_expand,
    645         'add_unload_trigger' => false,
    646         'wp_keep_scroll_position' => ! $is_IE,
    647     ),
    648 ) ); ?>
     694<?php
     695wp_editor(
     696    $post->post_content, 'content', array(
     697        '_content_editor_dfw' => $_content_editor_dfw,
     698        'drag_drop_upload'    => true,
     699        'tabfocus_elements'   => 'content-html,save-post',
     700        'editor_height'       => 300,
     701        'tinymce'             => array(
     702            'resize'                  => false,
     703            'wp_autoresize_on'        => $_wp_editor_expand,
     704            'add_unload_trigger'      => false,
     705            'wp_keep_scroll_position' => ! $is_IE,
     706        ),
     707    )
     708);
     709?>
    649710<table id="post-status-info"><tbody><tr>
    650711    <td id="wp-word-count" class="hide-if-no-js"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td>
     
    652713    <span class="autosave-message">&nbsp;</span>
    653714<?php
    654     if ( 'auto-draft' != $post->post_status ) {
    655         echo '<span id="last-edit">';
    656         if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) {
    657             /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */
    658             printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
    659         } else {
    660             /* translators: 1: Post edited date, 2: Post edited time */
    661             printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
    662         }
    663         echo '</span>';
    664     } ?>
     715if ( 'auto-draft' != $post->post_status ) {
     716    echo '<span id="last-edit">';
     717    if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) {
     718        /* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */
     719        printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
     720    } else {
     721        /* translators: 1: Post edited date, 2: Post edited time */
     722        printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
     723    }
     724    echo '</span>';
     725}
     726    ?>
    665727    </td>
    666728    <td id="content-resize-handle" class="hide-if-no-js"><br /></td>
     
    668730
    669731</div>
    670 <?php }
     732<?php
     733}
    671734/**
    672735 * Fires after the content editor.
     
    694757     */
    695758    do_action( 'submitpage_box', $post );
    696 }
    697 else {
     759} else {
    698760    /**
    699761     * Fires before meta boxes with 'side' context are output for all post types other than 'page'.
     
    709771
    710772
    711 do_meta_boxes($post_type, 'side', $post);
     773do_meta_boxes( $post_type, 'side', $post );
    712774
    713775?>
     
    716778<?php
    717779
    718 do_meta_boxes(null, 'normal', $post);
     780do_meta_boxes( null, 'normal', $post );
    719781
    720782if ( 'page' == $post_type ) {
     
    727789     */
    728790    do_action( 'edit_page_form', $post );
    729 }
    730 else {
     791} else {
    731792    /**
    732793     * Fires after 'normal' context meta boxes have been output for all post types other than 'page'.
     
    740801
    741802
    742 do_meta_boxes(null, 'advanced', $post);
     803do_meta_boxes( null, 'advanced', $post );
    743804
    744805?>
     
    762823
    763824<?php
    764 if ( post_type_supports( $post_type, 'comments' ) )
     825if ( post_type_supports( $post_type, 'comments' ) ) {
    765826    wp_comment_reply();
     827}
    766828?>
    767829
Note: See TracChangeset for help on using the changeset viewer.