WordPress.org

Make WordPress Core

Changeset 27419


Ignore:
Timestamp:
03/05/2014 08:40:36 PM (4 years ago)
Author:
nacin
Message:

Add widget management to the customizer.

This brings in the Widget Customizer plugin: https://wordpress.org/plugins/widget-customizer/.

props westonruter, shaunandrews, michael-arestad, johnregan3, akeda, topher1kenobe, topquarky, bobbravo2, ricardocorreia. And for good measure, props westonruter.
see #27112.

Location:
trunk/src
Files:
4 added
4 edited

Legend:

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

    r26995 r27419  
    5959    'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
    6060    'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
    61     'save-user-color-scheme',
     61    'save-user-color-scheme', 'update-widget',
    6262);
    6363
  • trunk/src/wp-admin/includes/ajax-actions.php

    r27403 r27419  
    15881588}
    15891589
     1590function wp_ajax_update_widget() {
     1591    require( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
     1592    $GLOBALS['wp_customize'] = new WP_Customize_Manager;
     1593
     1594    WP_Customize_Widgets::wp_ajax_update_widget();
     1595}
     1596
    15901597function wp_ajax_upload_attachment() {
    15911598    check_ajax_referer( 'media-form' );
  • trunk/src/wp-includes/class-wp-customize-control.php

    r27398 r27419  
    815815    }
    816816}
     817
     818/**
     819 * Widget Area Customize Control Class
     820 *
     821 */
     822class WP_Widget_Area_Customize_Control extends WP_Customize_Control {
     823    public $type = 'sidebar_widgets';
     824    public $sidebar_id;
     825
     826    public function to_json() {
     827        parent::to_json();
     828        $exported_properties = array( 'sidebar_id' );
     829        foreach ( $exported_properties as $key ) {
     830            $this->json[ $key ] = $this->$key;
     831        }
     832    }
     833
     834    public function render_content() {
     835        ?>
     836        <span class="button-secondary add-new-widget" tabindex="0">
     837            <?php esc_html_e( 'Add a Widget' ); ?>
     838        </span>
     839
     840        <span class="reorder-toggle" tabindex="0">
     841            <span class="reorder"><?php esc_html_e( 'Reorder' ); ?></span>
     842            <span class="reorder-done"><?php esc_html_e( 'Done' ); ?></span>
     843        </span>
     844        <?php
     845    }
     846}
     847
     848/**
     849 * Widget Form Customize Control Class
     850 */
     851class WP_Widget_Form_Customize_Control extends WP_Customize_Control {
     852    public $type = 'widget_form';
     853    public $widget_id;
     854    public $widget_id_base;
     855    public $sidebar_id;
     856    public $is_new = false;
     857    public $width;
     858    public $height;
     859    public $is_wide = false;
     860    public $is_live_previewable = false;
     861
     862    public function to_json() {
     863        parent::to_json();
     864        $exported_properties = array( 'widget_id', 'widget_id_base', 'sidebar_id', 'width', 'height', 'is_wide', 'is_live_previewable' );
     865        foreach ( $exported_properties as $key ) {
     866            $this->json[ $key ] = $this->$key;
     867        }
     868    }
     869
     870    public function render_content() {
     871        global $wp_registered_widgets;
     872        require_once ABSPATH . '/wp-admin/includes/widgets.php';
     873
     874        $widget = $wp_registered_widgets[ $this->widget_id ];
     875        if ( ! isset( $widget['params'][0] ) ) {
     876            $widget['params'][0] = array();
     877        }
     878
     879        $args = array(
     880            'widget_id' => $widget['id'],
     881            'widget_name' => $widget['name'],
     882        );
     883
     884        $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
     885        echo WP_Customize_Widgets::get_widget_control( $args );
     886    }
     887}
     888
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r27398 r27419  
    6262        require( ABSPATH . WPINC . '/class-wp-customize-section.php' );
    6363        require( ABSPATH . WPINC . '/class-wp-customize-control.php' );
     64        require( ABSPATH . WPINC . '/class-wp-customize-widgets.php' );
     65
     66        WP_Customize_Widgets::setup(); // This should be integrated.
    6467
    6568        add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) );
Note: See TracChangeset for help on using the changeset viewer.