Make WordPress Core

Ticket #21085: patch-core-21085-wp_deleteMediaItem-1.diff

File patch-core-21085-wp_deleteMediaItem-1.diff, 1.7 KB (added by koke, 12 years ago)
  • wp-includes/class-wp-xmlrpc-server.php

    diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php
    index a5273f9..0eb3944 100644
    a b class wp_xmlrpc_server extends IXR_Server { 
    7575                        'wp.getCommentStatusList' => 'this:wp_getCommentStatusList',
    7676                        'wp.getMediaItem'               => 'this:wp_getMediaItem',
    7777                        'wp.getMediaLibrary'    => 'this:wp_getMediaLibrary',
     78                        'wp.deleteMediaItem'            => 'this:wp_deleteMediaItem',
    7879                        'wp.getPostFormats'     => 'this:wp_getPostFormats',
    7980                        'wp.getPostType'                => 'this:wp_getPostType',
    8081                        'wp.getPostTypes'               => 'this:wp_getPostTypes',
    class wp_xmlrpc_server extends IXR_Server { 
    30233024        }
    30243025
    30253026        /**
     3027         * Delete a media item by ID
     3028         *
     3029         * @since 3.5.0
     3030         *
     3031         * @param array $args Method parameters. Contains:
     3032         *  - blog_id
     3033         *  - username
     3034         *  - password
     3035         *  - attachment_id
     3036         * @return false if delete failed, attachment data on success.
     3037         */
     3038        function wp_deleteMediaItem( $args ) {
     3039                $this->escape( $args );
     3040
     3041                $blog_id = (int) $args[0];
     3042                $username = $args[1];
     3043                $password = $args[2];
     3044                $attachment_id = (int) $args[3];
     3045
     3046                if ( !$user = $this->login( $username, $password ) )
     3047                        return $this->error;
     3048
     3049                do_action( 'xmlrpc_call', 'wp.deleteMediaItem' );
     3050
     3051                if ( !current_user_can('upload_files') ) {
     3052                        $this->error = new IXR_Error( 401, __( 'You do not have permission to delete files.' ) );
     3053                        return $this->error;
     3054                }
     3055
     3056                if ( ! $attachment = get_post($attachment_id) )
     3057                        return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
     3058
     3059                return wp_delete_attachment( $attachment_id );
     3060        }
     3061
     3062        /**
    30263063          * Retrieves a list of post formats used by the site
    30273064          *
    30283065          * @since 3.1