Make WordPress Core


Ignore:
Timestamp:
12/15/2014 11:27:17 PM (12 years ago)
Author:
ocean90
Message:

Customizer: Add _wp_attachment_is_custom_background meta to uploaded background images.

Adds $type property to WP_Customize_Background_Image_Control (PHP) and introduces wp.customize.BackgroundControl (JS).

see #30707.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/custom-background.php

    r30657 r30885  
    6161
    6262                add_action( 'admin_menu', array( $this, 'init' ) );
     63
     64                add_action( 'wp_ajax_custom-background-add', array( $this, 'ajax_background_add' ) );
     65
     66                // Unused since 3.5.0.
    6367                add_action( 'wp_ajax_set-background-image', array( $this, 'wp_set_background_image' ) );
    6468        }
    … …  
    465469
    466470        /**
    467          * Unused since 3.5.0.
     471         * AJAX handler for adding custom background context to an attachment.
     472         *
     473         * Triggered when the user adds a new background image from the
     474         * Media Manager.
     475         *
     476         * @since 4.1.0
     477         */
     478        public function ajax_background_add() {
     479                check_ajax_referer( 'background-add', 'nonce' );
     480
     481                if ( ! current_user_can( 'edit_theme_options' ) ) {
     482                        wp_send_json_error();
     483                }
     484
     485                $attachment_id = absint( $_POST['attachment_id'] );
     486                if ( $attachment_id < 1 ) {
     487                        wp_send_json_error();
     488                }
     489
     490                update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_stylesheet() );
     491
     492                wp_send_json_success();
     493        }
     494
     495        /**
    468496         *
    469497         * @since 3.4.0
     498         * @deprecated 3.5.0
    470499         */
    471500        public function attachment_fields_to_edit( $form_fields ) {
    … …  
    474503
    475504        /**
    476          * Unused since 3.5.0.
    477505         *
    478506         * @since 3.4.0
     507         * @deprecated 3.5.0
    479508         */
    480509        public function filter_upload_tabs( $tabs ) {
    … …  
    482511        }
    483512
     513        /**
     514         *
     515         * @since 3.4.0
     516         * @deprecated 3.5.0
     517         */
    484518        public function wp_set_background_image() {
    485519                if ( ! current_user_can('edit_theme_options') || ! isset( $_POST['attachment_id'] ) ) exit;
Note: See TracChangeset for help on using the changeset viewer.