WordPress.org

Make WordPress Core

Ticket #11198: 11198.patch

File 11198.patch, 8.7 KB (added by Simek, 9 years ago)
  • wp-admin/includes/post.php

     
    3434        if (!empty ( $post_data['post_author_override'] ) ) {
    3535                $post_data['post_author'] = (int) $post_data['post_author_override'];
    3636        } else {
    37                 if (!empty ( $post_data['post_author'] ) ) {
     37                if (!empty ( $post_data['post_author'] ) )
    3838                        $post_data['post_author'] = (int) $post_data['post_author'];
    39                 } else {
     39                else
    4040                        $post_data['post_author'] = (int) $post_data['user_ID'];
    41                 }
    4241        }
    4342
    4443        if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) {
    4544                if ( 'page' == $post_data['post_type'] ) {
    46                         if ( !current_user_can( 'edit_others_pages' ) ) {
     45                        if ( !current_user_can( 'edit_others_pages' ) )
    4746                                return new WP_Error( 'edit_others_pages', $update ?
    4847                                        __( 'You are not allowed to edit pages as this user.' ) :
    4948                                        __( 'You are not allowed to create pages as this user.' )
    5049                                );
    51                         }
    5250                } else {
    53                         if ( !current_user_can( 'edit_others_posts' ) ) {
     51                        if ( !current_user_can( 'edit_others_posts' ) )
    5452                                return new WP_Error( 'edit_others_posts', $update ?
    5553                                        __( 'You are not allowed to edit posts as this user.' ) :
    5654                                        __( 'You are not allowed to post as this user.' )
    5755                                );
    58                         }
    5956                }
    6057        }
    6158
     
    8279                $publish_cap = 'publish_posts';
    8380                $edit_cap = 'edit_published_posts';
    8481        }
     82
    8583        if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $publish_cap )) )
    8684                if ( $previous_status != 'publish' || !current_user_can( $edit_cap ) )
    8785                        $post_data['post_status'] = 'pending';
     
    204202
    205203        if ( current_user_can( 'edit_others_posts' ) ) {
    206204                if ( !empty($post_data['sticky']) )
    207                         stick_post($post_ID);
     205                        stick_post( $post_ID );
    208206                else
    209                         unstick_post($post_ID);
     207                        unstick_post( $post_ID );
    210208        }
    211209
    212210        return $post_ID;
     
    218216 * Updates all bulk edited posts/pages, adding (but not removing) tags and
    219217 * categories. Skips pages when they would be their own parent or child.
    220218 *
    221  * @since unknown
     219 * @since 2.7.0
    222220 *
     221 * @param unknown_type $post_data
     222 *
    223223 * @return array
    224224 */
    225225function bulk_edit_posts( $post_data = null ) {
     
    366366/**
    367367 * {@internal Missing Short Description}}
    368368 *
    369  * @since unknown
     369 * @since 2.5.0
    370370 *
    371371 * @return unknown
    372372 */
     
    736736                if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) {
    737737                        $attachment['post_parent'] = $post_ID;
    738738                        // Escape data pulled from DB.
    739                         $attachment = add_magic_quotes( $attachment);
    740                         wp_update_post( $attachment);
     739                        $attachment = add_magic_quotes( $attachment );
     740                        wp_update_post( $attachment );
    741741                }
    742742
    743743                $post_search[$i] = $anchor;
     
    749749        $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] );
    750750
    751751        // Escape data pulled from DB.
    752         $post = add_magic_quotes( $post);
     752        $post = add_magic_quotes( $post );
    753753
    754         return wp_update_post( $post);
     754        return wp_update_post( $post );
    755755}
    756756
    757757function _fix_attachment_links_replace_cb($match) {
     
    779779/**
    780780 * {@internal Missing Short Description}}
    781781 *
    782  * @since unknown
     782 * @since 2.5.0
    783783 *
    784784 * @param unknown_type $type
    785785 * @return unknown
     
    793793/**
    794794 * {@internal Missing Short Description}}
    795795 *
    796  * @since unknown
     796 * @since 2.5.0
    797797 *
    798798 * @param unknown_type $q
    799  * @return unknown
     799 * @return array
    800800 */
    801801function wp_edit_posts_query( $q = false ) {
    802802        if ( false === $q )
     
    881881 * @since unknown
    882882 *
    883883 * @param unknown_type $q
    884  * @return unknown
     884 * @return array
    885885 */
    886886function wp_edit_attachments_query( $q = false ) {
    887887        if ( false === $q )
    888888                $q = $_GET;
    889889
    890         $q['m']   = isset( $q['m'] ) ? (int) $q['m'] : 0;
     890        $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0;
    891891        $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
    892892        $q['post_type'] = 'attachment';
    893893        $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'inherit';
     894
    894895        $media_per_page = get_user_option('upload_per_page');
    895896        if ( empty($media_per_page) )
    896897                $media_per_page = 20;
     
    914915 *
    915916 * @param unknown_type $id
    916917 * @param unknown_type $page
     918 *
     919 * @uses get_user_option()
     920 *
    917921 * @return unknown
    918922 */
    919923function postbox_classes( $id, $page ) {
     
    922926        $current_user = wp_get_current_user();
    923927        if ( $closed = get_user_option('closedpostboxes_'.$page, 0, false ) ) {
    924928                if ( !is_array( $closed ) ) return '';
    925                 return in_array( $id, $closed )? 'closed' : '';
     929                        return in_array( $id, $closed )? 'closed' : '';
    926930        } else {
    927931                return '';
    928932        }
     
    936940 * @param unknown_type $id
    937941 * @param unknown_type $title
    938942 * @param unknown_type $name
    939  * @return unknown
     943 * @return array
    940944 */
    941 function get_sample_permalink($id, $title = null, $name = null) {
     945function get_sample_permalink( $id, $title = null, $name = null ) {
    942946        $post = &get_post($id);
    943         if (!$post->ID) {
     947        if ( !$post->ID )
    944948                return array('', '');
    945         }
     949
    946950        $original_status = $post->post_status;
    947951        $original_date = $post->post_date;
    948952        $original_name = $post->post_name;
    949953
    950954        // Hack: get_permalink would return ugly permalink for
    951955        // drafts, so we will fake, that our post is published
    952         if (in_array($post->post_status, array('draft', 'pending'))) {
     956        if ( in_array( $post->post_status, array('draft', 'pending') ) ) {
    953957                $post->post_status = 'publish';
    954958                $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID);
    955959        }
     
    958962
    959963        // If the user wants to set a new name -- override the current one
    960964        // Note: if empty name is supplied -- use the title instead, see #6072
    961         if (!is_null($name)) {
     965        if ( !is_null($name) )
    962966                $post->post_name = sanitize_title($name? $name : $title, $post->ID);
    963         }
    964967
    965968        $post->filter = 'sample';
    966969
     
    972975                $uri = untrailingslashit($uri);
    973976                $uri = strrev( stristr( strrev( $uri ), '/' ) );
    974977                $uri = untrailingslashit($uri);
    975                 if ( !empty($uri) )
     978                if ( !empty( $uri ) )
    976979                        $uri .='/';
    977980                $permalink = str_replace('%pagename%', "${uri}%pagename%", $permalink);
    978981        }
     
    994997 * @param unknown_type $id
    995998 * @param unknown_type $new_title
    996999 * @param unknown_type $new_slug
    997  * @return unknown
     1000 * @return string html
    9981001 */
    9991002function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
    10001003        $post = &get_post($id);
     
    10201023        }
    10211024
    10221025        if ( function_exists('mb_strlen') ) {
    1023                 if ( mb_strlen($post_name) > 30 ) {
     1026                if ( mb_strlen($post_name) > 30 )
    10241027                        $post_name_abridged = mb_substr($post_name, 0, 14). '…' . mb_substr($post_name, -14);
    1025                 } else {
     1028                else
    10261029                        $post_name_abridged = $post_name;
    1027                 }
    10281030        } else {
    1029                 if ( strlen($post_name) > 30 ) {
     1031                if ( strlen($post_name) > 30 )
    10301032                        $post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14);
    1031                 } else {
     1033                else
    10321034                        $post_name_abridged = $post_name;
    1033                 }
    10341035        }
    10351036
    10361037        $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
     
    11201121 * Outputs the notice message to say that someone else is editing this post at the moment.
    11211122 *
    11221123 * @since 2.8.5
     1124 *
    11231125 * @return none
    11241126 */
    11251127function _admin_notice_post_locked() {
     
    11511153 *
    11521154 * @uses _wp_translate_postdata()
    11531155 * @uses _wp_post_revision_fields()
     1156 *
     1157 * @return unknown
    11541158 */
    11551159function wp_create_post_autosave( $post_id ) {
    11561160        $translated = _wp_translate_postdata( true );
     
    11771181 * Save draft or manually autosave for showing preview.
    11781182 *
    11791183 * @package WordPress
    1180  * @since 2.7
     1184 * @since 2.7.0
    11811185 *
    11821186 * @uses wp_write_post()
    11831187 * @uses edit_post()
     
    12381242 * Adds the TinyMCE editor used on the Write and Edit screens.
    12391243 *
    12401244 * @package WordPress
    1241  * @since 2.7
     1245 * @since 2.7.0
    12421246 *
    12431247 * TinyMCE is loaded separately from other Javascript by using wp-tinymce.php. It outputs concatenated
    12441248 * and optionaly pre-compressed version of the core and all default plugins. Additional plugins are loaded
     
    14201424        // You can modify initArray to add, remove, change elements of the config before tinyMCE.init
    14211425        // Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init".
    14221426        // Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0.
    1423         if ( $teeny ) {
     1427        if ( $teeny )
    14241428                $initArray = apply_filters('teeny_mce_before_init', $initArray);
    1425         } else {
     1429        else
    14261430                $initArray = apply_filters('tiny_mce_before_init', $initArray);
    1427         }
    14281431
    14291432        if ( empty($initArray['theme_advanced_buttons3']) && !empty($initArray['theme_advanced_buttons4']) ) {
    14301433                $initArray['theme_advanced_buttons3'] = $initArray['theme_advanced_buttons4'];