Skip to content

Commit

Permalink
Add fallback solutions for WP<5.2 where ClipboardJS doesn't exist yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clorith committed May 6, 2019
1 parent a4cf9ab commit d8a050d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ module.exports = function( grunt ) {
src: [ '**/*', '!assets/*' ],
dest: 'build/',
expand: true
},
dependencies: {
cwd: 'node_modules/clipboard/dist/',
src: [ '**/*.min.js' ],
dest: 'build/assets/javascript/',
expand: true
}
},
jscs: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"devDependencies": {
"@wordpress/browserslist-config": "^2.3.0",
"autoprefixer": "^7.1.2",
"clipboard": "^2.0.4",
"grunt": "~1.0.1",
"grunt-check-dependencies": "~1.0.0",
"grunt-checktextdomain": "~1.0.1",
Expand Down
4 changes: 4 additions & 0 deletions src/includes/class-health-check.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ public function enqueues() {
}
}

if ( ! wp_script_is( 'clipboard', 'registered' ) ) {
wp_register_script( 'clipboard', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/javascript/clipboard.min.js', array(), '2.0.4' );
}

wp_enqueue_style( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/css/health-check.css', array(), HEALTH_CHECK_PLUGIN_VERSION );

wp_enqueue_script( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/javascript/health-check.js', array( 'jquery', 'wp-a11y', 'clipboard', 'wp-util' ), HEALTH_CHECK_PLUGIN_VERSION, true );
Expand Down

0 comments on commit d8a050d

Please sign in to comment.