From 507c0b844dc18588a34185794e8ff3cef10690e7 Mon Sep 17 00:00:00 2001 From: "Oliver Kohl D.Sc" Date: Tue, 2 Feb 2021 23:46:18 +0100 Subject: [PATCH 1/5] Added id attribute --- datacamp-light-wordpress.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/datacamp-light-wordpress.php b/datacamp-light-wordpress.php index d48a6bb..a53bca5 100644 --- a/datacamp-light-wordpress.php +++ b/datacamp-light-wordpress.php @@ -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,6 +86,7 @@ public static function datacampExerciseSC($atts, $content, $tag) { . self::createDataAttribute($atts, 'height') . self::createDataAttribute($atts, 'min-height') . self::createDataAttribute($atts, 'max-height') + . self::createAttribute($atts, 'id') . '>' . do_shortcode($content) . '' From 73cc295c3408905fce0fa7607a272e6f750f6a7a Mon Sep 17 00:00:00 2001 From: "Oliver Kohl D.Sc" Date: Wed, 3 Feb 2021 00:14:33 +0100 Subject: [PATCH 2/5] Changed URL to the 'correct one' There seem to be: https://cdn.datacamp.com/dcl-react.js.gz https://cdn.datacamp.com/datacamp-light-latest.min.js https://cdn.datacamp.com/dcl-react-dev.js.gz --- datacamp-light-wordpress.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datacamp-light-wordpress.php b/datacamp-light-wordpress.php index a53bca5..a85cfc4 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); } /** From d7b6c4187ad49cfee9ebbb5e1386dca565624827 Mon Sep 17 00:00:00 2001 From: "Oliver Kohl D.Sc" Date: Thu, 4 Feb 2021 08:02:50 +0100 Subject: [PATCH 3/5] Added "Run" button --- datacamp-light-wordpress.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/datacamp-light-wordpress.php b/datacamp-light-wordpress.php index a85cfc4..20910fc 100644 --- a/datacamp-light-wordpress.php +++ b/datacamp-light-wordpress.php @@ -87,10 +87,11 @@ public static function datacampExerciseSC($atts, $content, $tag) { . self::createDataAttribute($atts, 'min-height') . self::createDataAttribute($atts, 'max-height') . self::createAttribute($atts, 'id') - . '>' - . do_shortcode($content) - . '' - . '[/' . $tag . ']'; + . self::createDataAttribute($atts, 'show-run-button') + . '>' + . do_shortcode($content) + . '' + . '[/' . $tag . ']'; } public static function pecSC($atts, $content) { From 3c085ba03869836d12498fe862f14bf55a9d58e2 Mon Sep 17 00:00:00 2001 From: "Oliver Kohl D.Sc" Date: Thu, 4 Feb 2021 08:04:30 +0100 Subject: [PATCH 4/5] Updated example to contain id field & a run button --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 688fbeb3aa9dcb131bd1c318931e24c0f81bc14e Mon Sep 17 00:00:00 2001 From: "Oliver Kohl D.Sc" Date: Thu, 4 Feb 2021 08:04:36 +0100 Subject: [PATCH 5/5] Updated example to contain id field & a run button