WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/16/2016 01:56:13 AM (6 years ago)
Author:
westonruter
Message:

Customize: Add a user-friendly way to preview site responsiveness for desktop, tablet, and mobile.

Introduces WP_Customize_Manager::get_previewable_devices() with a customize_previewable_devices filter to change the default device and which devices are available for previewing. This is a feature that was first pioneered on WordPress.com.

Props celloexpressions, folletto, valendesigns, westonruter, welcher, adamsilverstein, michaelarestad, Fab1en.
Fixes #31195.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r36414 r36532  
    17111711            'autofocus' => array(),
    17121712            'documentTitleTmpl' => $this->get_document_title_template(),
     1713            'previewableDevices' => $this->get_previewable_devices(),
    17131714        );
    17141715
     
    17851786        </script>
    17861787        <?php
     1788    }
     1789
     1790    /**
     1791     * Returns a list of devices to allow previewing.
     1792     *
     1793     * @access public
     1794     * @since 4.5.0
     1795     *
     1796     * @return array List of devices with labels and default setting.
     1797     */
     1798    public function get_previewable_devices() {
     1799        $devices = array(
     1800            'desktop' => array(
     1801                'label' => __( 'Enter desktop preview mode' ),
     1802                'default' => true,
     1803            ),
     1804            'tablet' => array(
     1805                'label' => __( 'Enter tablet preview mode' ),
     1806            ),
     1807            'mobile' => array(
     1808                'label' => __( 'Enter mobile preview mode' ),
     1809            ),
     1810        );
     1811
     1812        /**
     1813         * Filter the available devices to allow previewing in the Customizer.
     1814         *
     1815         * @since 4.5.0
     1816         *
     1817         * @see WP_Customize_Manager::get_previewable_devices()
     1818         *
     1819         * @param array $devices List of devices with labels and default setting.
     1820         */
     1821        $devices = apply_filters( 'customize_previewable_devices', $devices );
     1822
     1823        return $devices;
    17871824    }
    17881825
Note: See TracChangeset for help on using the changeset viewer.