diff --git a/programs/wordpressplugin/readme.txt b/programs/wordpressplugin/readme.txt index 78a7c340..9ef68dd9 100644 --- a/programs/wordpressplugin/readme.txt +++ b/programs/wordpressplugin/readme.txt @@ -2,7 +2,7 @@ Contributors: Tobias Hintze Tags: ODF, open document, WebODF Requires at least: 3.2 -Tested up to: 3.4.2 +Tested up to: 3.5.1 Stable tag: 1.0 @@ -37,3 +37,7 @@ no screenshots available (yet) * first version hacked together. += 0.2 = + +* made it work with recent 3.5.1 (which changed API around attachment-fields) + diff --git a/programs/wordpressplugin/webodf-viewer.php b/programs/wordpressplugin/webodf-viewer.php index 52ded0f2..fbdfe063 100644 --- a/programs/wordpressplugin/webodf-viewer.php +++ b/programs/wordpressplugin/webodf-viewer.php @@ -2,8 +2,8 @@ /* Plugin Name: WebODF Viewer -Version: 0.1 -Plugin URI: http://kogmbh.com/webodf/wordpress/ +Version: 0.2 +Plugin URI: http://webodf.org/ Description: Embed ODF in Wordpress Author: Tobias Hintze Author URI: http://kogmbh.com @@ -113,22 +113,35 @@ function mime_type_icon($icon_uri, $mime_type, $post_id) { add_filter( 'wp_mime_type_icon', 'mime_type_icon', 10, 3); function webodf_media_send_to_editor($html, $send_id, $attachment) { - // if this POST did not came from our "special button", just call super() - if ($_POST["send"][$send_id] != 'Insert WebODF Viewer') { - return media_send_to_editor($html); + $pid = $attachment['id']; + + $post = get_post($pid, ARRAY_A); + if (preg_match('/^application\/vnd\.oasis\.opendocument/', $post['post_mime_type'])) { + // place shortcode + preg_match('/^http:\/\/[^\/]*(\/.*)$/', $attachment['url'], $matches); + $document_url = $matches[1]; + return "[webodf_viewer ".$document_url."]"; } - // place shortcode - return "[webodf_viewer ".$attachment['webodf_document_url']."]"; + return $html; } add_filter( 'media_send_to_editor', 'webodf_media_send_to_editor', 10, 3); +/* + TODO: introduce a smart switch on [post | attachment] scope + to skip webodf-embedding... (user might to simply link + some documents) + For now: always use webodf for embedding, if this plugin + is enabled. + function field_filter($fields, $post_object) { + if ($post_object->post_parent > 0) { + // inside a post + $use_webodf = get_post_meta($post_object['post_parent'], 'use_webodf'); + } if (preg_match('/^application\/vnd\.oasis\.opendocument\.(text|presentation|spreadsheet)/', $post_object->post_mime_type)) { - $webodf_button_code = "ID]' value='Insert WebODF Viewer'/>"; // insert document path preg_match('/^http:\/\/[^\/]*(\/.*)$/', $post_object->guid, $matches); @@ -137,16 +150,46 @@ function field_filter($fields, $post_object) { "input" => "text", "value" => $matches[1] ); - - // insert our "special button" - $fields["webodf_insert_submit"] = array( - "tr" => "