diff --git a/README.md b/README.md index 5579206..1537a4c 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ After clicking "Insert Exercise", the exercise information will be translated in ![Usage Add Shortcode](http://assets.datacamp.com/img/github/datacamp-light-wordpress/usage_add_shortcode.png "Usage Add Shortcode") ```Python -[datacamp_exercise lang="python"] +[datacamp_exercise lang="python" id="test1" show-run-button=TRUE] [datacamp_sample_code] # Create a variable a, equal to 5 diff --git a/datacamp-light-wordpress.php b/datacamp-light-wordpress.php index d48a6bb..20910fc 100644 --- a/datacamp-light-wordpress.php +++ b/datacamp-light-wordpress.php @@ -20,7 +20,7 @@ public static function loadJSAndStyle(){ public static function loadJSAndStyleHook(){ wp_enqueue_style("datacamp-light-style", plugins_url('style/frontend_style.css', __FILE__)); - wp_enqueue_script("datacamp-light-library", "https://cdn.datacamp.com/datacamp-light-latest.min.js", array(), false, true); + wp_enqueue_script("datacamp-light-library", "https://cdn.datacamp.com/dcl-react.js.gz", array(), false, true); } /** @@ -72,6 +72,12 @@ private static function createDataAttribute($atts, $key) { return ""; } + private static function createAttribute($atts, $key) { + if (isset($atts[$key])) { + return $key . '="' . $atts[$key] . '"'; + } + return ""; + } public static function datacampExerciseSC($atts, $content, $tag) { return '[' . $tag . ']' @@ -80,10 +86,12 @@ public static function datacampExerciseSC($atts, $content, $tag) { . self::createDataAttribute($atts, 'height') . self::createDataAttribute($atts, 'min-height') . self::createDataAttribute($atts, 'max-height') - . '>' - . do_shortcode($content) - . '' - . '[/' . $tag . ']'; + . self::createAttribute($atts, 'id') + . self::createDataAttribute($atts, 'show-run-button') + . '>' + . do_shortcode($content) + . '' + . '[/' . $tag . ']'; } public static function pecSC($atts, $content) {