WordPress.org

Make WordPress Core

Ticket #20819: 20819.4.patch

File 20819.4.patch, 2.8 KB (added by SergeyBiryukov, 6 years ago)
  • wp-admin/custom-background.php

     
    7474                add_action("load-$page", array(&$this, 'handle_upload'), 49);
    7575                add_filter( 'attachment_fields_to_edit', array( $this, 'attachment_fields_to_edit' ), 10, 2 );
    7676                add_filter( 'media_upload_tabs', array( $this, 'filter_upload_tabs' ) );
     77                add_filter( 'media_upload_mime_type_links', array( $this, 'filter_upload_mime_type_links' ) );
    7778
    7879                if ( $this->admin_header_callback )
    7980                        add_action("admin_head-$page", $this->admin_header_callback, 51);
     
    388389                $this->updated = true;
    389390        }
    390391
     392        /**
     393         * Replace default attachment actions with "Set as background" link.
     394         *
     395         * @since 3.4.0
     396         */
    391397        function attachment_fields_to_edit( $form_fields, $post ) {
    392398                if ( isset( $_REQUEST['context'] ) && $_REQUEST['context'] == 'custom-background' ) {
    393399                        $form_fields = array( 'image-size' => $form_fields['image-size'] );
     
    398404                return $form_fields;
    399405        }
    400406
     407        /**
     408         * Leave only "Media Library" tab in the uploader window.
     409         *
     410         * @since 3.4.0
     411         */
    401412        function filter_upload_tabs ( $tabs ){
    402413                if ( isset( $_REQUEST['context'] ) && $_REQUEST['context'] == 'custom-background' )
    403414                        return array( 'library' => __('Media Library') );
     
    405416                return $tabs;
    406417        }
    407418
     419        /**
     420         * Hide MIME type links. Only image files can be set as background.
     421         *
     422         * @since 3.4.0
     423         */
     424        function filter_upload_mime_type_links( $type_links ) {
     425                if ( isset( $_REQUEST['context'] ) && $_REQUEST['context'] == 'custom-background' )
     426                        return array();
     427
     428                return $type_links;
     429        }
     430
    408431        public function wp_set_background_image() {
    409432                if ( ! current_user_can('edit_theme_options') || ! isset( $_POST['attachment_id'] ) ) exit;
    410433                $attachment_id = absint($_POST['attachment_id']);
  • wp-admin/custom-header.php

     
    9696
    9797                add_filter( 'attachment_fields_to_edit', array( $this, 'attachment_fields_to_edit' ), 10, 2 );
    9898                add_filter( 'media_upload_tabs', array( $this, 'filter_upload_tabs' ) );
    99                 add_filter( 'media_upload_mime_type_links', '__return_empty_array' );
     99                add_filter( 'media_upload_mime_type_links', array( $this, 'filter_upload_mime_type_links' ) );
    100100        }
    101101
    102102        /**
     
    10001000                return $tabs;
    10011001        }
    10021002
     1003        /**
     1004         * Hide MIME type links. Only image files can be set as header.
     1005         *
     1006         * @since 3.4.0
     1007         */
     1008        function filter_upload_mime_type_links( $type_links ) {
     1009                if ( isset( $_REQUEST['context'] ) && $_REQUEST['context'] == 'custom-header' )
     1010                        return array();
     1011
     1012                return $type_links;
     1013        }
     1014
    10031015}