Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 13 additions & 5 deletions datacamp-light-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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 . ']'
Expand All @@ -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)
. '</div>'
. '[/' . $tag . ']';
. self::createAttribute($atts, 'id')
. self::createDataAttribute($atts, 'show-run-button')
. '>'
. do_shortcode($content)
. '</div>'
. '[/' . $tag . ']';
}

public static function pecSC($atts, $content) {
Expand Down