Make WordPress Core


Ignore:
Timestamp:
03/21/2016 09:58:02 PM (9 years ago)
Author:
westonruter
Message:

Customize: Require opt-in for selective refresh of widgets.

  • Introduces customize-selective-refresh-widgets theme support feature and adds to themes.
  • Introduces customize_selective_refresh arg for WP_Widget::$widget_options and adds to all core widgets.
  • Remove selective_refresh from being a component that can be removed via customize_loaded_components filter.
  • Add WP_Customize_Widgets::get_selective_refreshable_widgets() and WP_Customize_Widgets::is_widget_selective_refreshable().
  • Fix default selector for Partial instances.
  • Implement and improve Masronry sidebar refresh logic in Twenty Thirteen and Twenty Fourteen, including preservation of initial widget position after refresh.
  • Re-initialize ME.js when refreshing Twenty_Fourteen_Ephemera_Widget.

See #27355.
Fixes #35855.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfourteen/inc/widgets.php

    r32116 r37040  
    3535            'classname'   => 'widget_twentyfourteen_ephemera',
    3636            'description' => __( 'Use this widget to list your recent Aside, Quote, Video, Audio, Image, Gallery, and Link posts.', 'twentyfourteen' ),
     37            'customize_selective_refresh' => true,
    3738        ) );
     39
     40        if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) {
     41            add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
     42        }
     43    }
     44
     45    /**
     46     * Enqueue scripts.
     47     *
     48     * @since Twenty Fourteen 1.7
     49     */
     50    public function enqueue_scripts() {
     51        /** This filter is documented in wp-includes/media.php */
     52        $audio_library = apply_filters( 'wp_audio_shortcode_library', 'mediaelement' );
     53        /** This filter is documented in wp-includes/media.php */
     54        $video_library = apply_filters( 'wp_video_shortcode_library', 'mediaelement' );
     55        if ( in_array( 'mediaelement', array( $video_library, $audio_library ), true ) ) {
     56            wp_enqueue_style( 'wp-mediaelement' );
     57            wp_enqueue_script( 'wp-mediaelement' );
     58        }
    3859    }
    3960
Note: See TracChangeset for help on using the changeset viewer.