diff --git a/wp_amara_shortcode.php b/wp_amara_shortcode.php index e7fdb03..acb073d 100644 --- a/wp_amara_shortcode.php +++ b/wp_amara_shortcode.php @@ -36,11 +36,56 @@ class WP_Amara_Shortcode public function __construct() { add_shortcode( 'amara' , array(&$this, 'amara') ); } // __construct - + /** * Main plugin function */ public function amara( $atts ) { + // TODO: make a UI for this option + if (get_option('wp_amara_use_legacy', true) ) { + return $this->unisub($atts); + } + else { + wp_enqueue_script('amara-embed-js'); + //
+ // These will be prefixed by 'data-' + $data = array( + 'width' => 640, + 'height' => 480, + // TODO: replace by tutorial video + 'url' => 'http://www.youtube.com/watch?v=5CKwCfLUwj4', + ); + + $attributes = array(); + $attributes['class'] = 'amara-embed'; + foreach($data as $key => $default) { + if (isset($atts[$key])) { + $attributes['data-' . $key] = $atts[$key]; + unset($atts[$key]); + } + else { + $attributes['data-' . $key] = $default; + } + } + $result = '' . print_r($atts, true) . '';
+ }
+ return $result;
+ }
+ }
+
+ /**
+ * @deprecated
+ *
+ * Legacy implementation
+ */
+ public function unisub( $atts) {
if(isset($atts['content'])) {
$content = $this->prepare_content($atts['content']);
@@ -124,4 +169,10 @@ private function prepare_content ( $content ) {
if(class_exists('WP_Amara_Shortcode')) {
// instantiate the plugin class
$wp_amara_shortcode = new WP_Amara_Shortcode();
-}
\ No newline at end of file
+}
+
+add_action("wp_enqueue_scripts", "WP_Amara_scripts");
+
+function WP_Amara_scripts() {
+ wp_register_script( 'amara-embed-js', 'https://amara.org/embedder-iframe' , '', '', true );
+}