This repository has been archived by the owner. It is now read-only.

Gallery Widget #120

Merged
merged 43 commits into from Sep 19, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+920 −125
Diff settings

Always

Just for now

View
@@ -2,3 +2,7 @@ CHECK_SCOPE=changed-files
PHPCS_RULESET_FILE=phpcs.xml.dist
WPCS_BRANCH=develop
PHPCS_PHAR_URL=https://github.com/squizlabs/PHP_CodeSniffer/releases/download/2.9.0/phpcs.phar
if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.2" ]]; then
DEV_LIB_SKIP="$DEV_LIB_SKIP,phpcs"
fi
View
@@ -1,4 +1,5 @@
sudo: false
dist: precise
notifications:
email:
View
@@ -24,7 +24,8 @@
* @package WordPress
*/
define( 'WP_CORE_MEDIA_WIDGETS_MERGED', file_exists( ABSPATH . 'wp-includes/widgets/class-wp-widget-media.php' ) );
define( 'WP_CORE_MEDIA_WIDGETS_MERGED', file_exists( ABSPATH . 'wp-includes/widgets/class-wp-widget-media.php' ) );
define( 'WP_CORE_GALLERY_WIDGET_MERGED', file_exists( ABSPATH . 'wp-includes/widgets/class-wp-widget-media-gallery.php' ) );
define( 'WP_CORE_VISUAL_TEXT_WIDGET_MERGED', file_exists( ABSPATH . 'wp-admin/js/widgets/text-widgets.js' ) );
// Register WP-CLI command for generating QUnit test suite.
@@ -70,6 +71,8 @@ function wp32417_default_scripts( WP_Scripts $scripts ) {
$scripts->add( $handle, $src, array( 'media-widgets', 'media-audiovideo' ) );
}
$scripts->add( 'media-gallery-widget', plugin_dir_url( __FILE__ ) . 'wp-admin/js/widgets/media-gallery-widget.js', array( 'media-widgets' ) );
if ( ! WP_CORE_MEDIA_WIDGETS_MERGED ) {
$scripts->add_inline_script( 'customize-selective-refresh', file_get_contents( dirname( __FILE__ ) . '/wp-includes/js/customize-selective-refresh-extras.js' ) );
}
@@ -97,8 +100,14 @@ function wp32417_add_default_filters() {
*/
function wp32417_default_styles( WP_Styles $styles ) {
$handle = 'media-widgets';
$src = plugin_dir_url( __FILE__ ) . 'wp-admin/css/widgets/media-widgets.css';
if ( ! WP_CORE_MEDIA_WIDGETS_MERGED ) {
$src = plugin_dir_url( __FILE__ ) . 'wp-admin/css/widgets/media-widgets.css';
$styles->add( $handle, $src, array( 'media-views' ) );
}
$handle = 'media-gallery-widget';
if ( ! WP_CORE_GALLERY_WIDGET_MERGED ) {
$src = plugin_dir_url( __FILE__ ) . 'wp-admin/css/widgets/media-gallery-widget.css';
$styles->add( $handle, $src, array( 'media-views' ) );
}
}
@@ -133,12 +142,12 @@ function wp32417_twentyten_styles() {
* @codeCoverageIgnore
*/
function wp32417_widgets_init() {
$class_files = array(
'WP_Widget_Media' => dirname( __FILE__ ) . '/wp-includes/widgets/class-wp-widget-media.php',
'WP_Widget_Media_Image' => dirname( __FILE__ ) . '/wp-includes/widgets/class-wp-widget-media-image.php',
'WP_Widget_Media_Video' => dirname( __FILE__ ) . '/wp-includes/widgets/class-wp-widget-media-video.php',
'WP_Widget_Media_Audio' => dirname( __FILE__ ) . '/wp-includes/widgets/class-wp-widget-media-audio.php',
'WP_Widget_Media' => dirname( __FILE__ ) . '/wp-includes/widgets/class-wp-widget-media.php',
'WP_Widget_Media_Image' => dirname( __FILE__ ) . '/wp-includes/widgets/class-wp-widget-media-image.php',
'WP_Widget_Media_Video' => dirname( __FILE__ ) . '/wp-includes/widgets/class-wp-widget-media-video.php',
'WP_Widget_Media_Audio' => dirname( __FILE__ ) . '/wp-includes/widgets/class-wp-widget-media-audio.php',
'WP_Widget_Media_Gallery' => dirname( __FILE__ ) . '/wp-includes/widgets/class-wp-widget-media-gallery.php',
);
foreach ( $class_files as $class => $file ) {
if ( ! class_exists( $class ) ) {
@@ -46,6 +46,7 @@ class Media_Widgets_WP_CLI_Command extends WP_CLI_Command {
'media-image-widget',
'media-video-widget',
'media-audio-widget',
'media-gallery-widget',
);
/**
@@ -0,0 +1,38 @@
<?php
/**
* Unit tests covering WP_Widget_Media_Gallery functionality.
*
* @package WordPress
* @subpackage widgets
*/
/**
* Test wp-includes/widgets/class-wp-widget-gallery.php
*
* @group widgets
*/
class Test_WP_Widget_Media_Gallery extends WP_UnitTestCase {
/**
* Test get_instance_schema method.
*
* @covers WP_Widget_Media_Gallery::get_instance_schema()
*/
function test_get_instance_schema() {
$widget = new WP_Widget_Media_Gallery();
$schema = $widget->get_instance_schema();
$this->assertEqualSets(
array(
'title',
'ids',
'columns',
'size',
'link_type',
'orderby_random',
),
array_keys( $schema )
);
}
}
@@ -238,15 +238,13 @@ function test_enqueue_preview_scripts() {
$widget->enqueue_preview_scripts();
$this->assertTrue( wp_script_is( 'wp-mediaelement' ) );
$this->assertTrue( wp_style_is( 'wp-mediaelement' ) );
$this->assertTrue( wp_script_is( 'froogaloop' ) );
$wp_scripts = null;
$wp_styles = null;
add_filter( 'wp_video_shortcode_library', '__return_empty_string' );
$widget->enqueue_preview_scripts();
$this->assertFalse( wp_script_is( 'wp-mediaelement' ) );
$this->assertFalse( wp_style_is( 'wp-mediaelement' ) );
$this->assertTrue( wp_script_is( 'froogaloop' ) );
}
/**
@@ -386,7 +386,9 @@ function test_enqueue_admin_scripts() {
$widget->enqueue_admin_scripts();
$this->assertTrue( wp_script_is( 'media-widgets' ) );
$this->assertTrue( wp_style_is( 'media-widgets' ) );
if ( version_compare( strtok( get_bloginfo( 'version' ), '-' ), '4.8', '<=' ) ) {
$this->assertTrue( wp_style_is( 'media-widgets' ) );
}
}
/**
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.