=== Uploadify Integration === Contributors: Mike Allen Website: http://anchorwave.com/ Tags: shortcode, upload, uploader, uploading, uploadify, flash uploader, file uploader Requires at least: 3.0 Tested up to: 3.2.0 Stable tag: 0.9.0 Uploadify Integartion allows you to insert a jQuery uploadify uploader into your forms. == Description == Uploadify Integration is an attempt to ease the very common task of including an upload field within a custom post type, options page, or user profile page. = Features = * Provides a shortcode to integrate the Uploadify uploader. * Shortcode generator in options page * Automatically saves to post meta, user meta, or as an option depending on the metaType selected by the shortcode. = Intended Audience = Uploadify Integration is intended to be a tool for developers needing to include an uploader within a form. Because uploaded files can only be retrieved through code, this plugin may not be useful to anyone without knowledge of PHP. = Important Notes = Please check out the `Installation` and `Other Notes` tabs to see important details on how to use Uploadify Integration. You will not be able to use this plugin without reading those pages. = Feedback = Please let me know how you would like this plugin to be improved, either by posting on the forum, or by email: mikeleonardallen@gmail.com == Installation == 1. Download and unpack plugin files to **/wp-content/plugins/AwUploadify** 2. Activate the plugin through the 'Plugins' menu in WordPress 3. Go to the *Options/Uploadify Integration* page in *Site Admin* and change the plugins options as you wish. 4. Place the `[uploadify]` shortcode in your content. = Usage = Embed the `[uploadify]` shortcode to include the uploader in a page or post. See the shortcode generator in the settings page to modify the default settings. = Options = * **inputName** : The key that will be used to save the meta data. Defualt = 'files' * **metaType** : What to associate the uploaded files with. Default = 'post' * **uploadMode** : Allow multiple uploads or replace the previous upload. Default = 'single' * **fileSizeLimit** : Restriction on allowed file size in MB. (uploadify was modified a little here to allow the human friendly MB setting) * **fileTypeExts** : Restrict allowed file types. Default is '*.*' * **fileTypeDesc** : Used in conjunction with `fileTypeExts` to tell the user what types of files should be uploaded. * **buttonText** : Text to display on upload button. Default is 'Upload File' = Retrieving Files = Files are stored as post meta, user meta, or option meta stored under the inputName specified with the shortcode. For example, with the shortcode: `[uploadify inputName=images metaType=post]` The information for retrieving the files is retrieved like so: $images = get_post_meta( $post_id, 'images', true ); Now images will contain an array of post ids. Those posts contain information about the files uploaded. There are two functions provided to retrieve path and url information given a post id. Those are: `AwFileHandler::getFilePath($post_id);` and `AwFileHandler::getFileUrl($post_id);` For example, to print out the above images: while( $post_id = array_shift( $images ) ) { $url = AwFileHandler::getFileUrl( $post_id ); echo sprintf( '', $url ); } == Frequently Asked Questions == None at this time. == Screenshots == None. == Changelog == = 0.9 (August 28 2011) = * Beta release. == Upgrade Notice == None == Non-Standard Usage == If the shortcode is placed in content that does not pass through `the_content` filter, then use `do_shortcode('[uploadify]')` to include the uploader. JavaScript and CSS are loaded only if the `[uploadify]` shortcode is detected within the page content. If you use the shortcode in a place other than in a page, then you must manually load the JavaScript and CSS using the function `AwUploadify::_enqueueScripts()`. For example if you want to include the shortcode within the meta box of a custom post type: add_filter( 'admin_init', 'YourCustomPostTypeClass::enqueueScripts' ); // And now within your custom post type class... public static function enqueueScripts() { if ( ! self::isYourPostType() ) return; AwUploadify::_enqueueScripts(); } public function isYourPostType() { // TODO. Is this your post type? } And your meta box code might look like: add_action( 'admin_menu', 'YourCustomPostTypeClass::addMetaBox' ); // ALso within your custom post type class public static function addMetaBox() { add_meta_box( 'chestnut-project-meta-box', 'Your Meta Box Header', 'YourCustomPostTypeClass::showMetaBox', 'your_custom_post_type', 'normal', 'high' ); } public static function showMetaBox() { echo do_shortcode( '[uploadify]' ); } == Extending/Customization == = Meta Type = By default Uploadify Integration can save to post, user, or option meta. Custom meta types are added with the `get_file_meta_handler` filter. add_filter( 'get_file_meta_handler', 'my_custom_meta_handler', 10, 3 ); function my_custom_meta_handler( $handler, $meta_name ) { if ( $meta_name != "MY_CUSTOM_META_TYPE" ) return $handler; $handler = new MyCustomMetaHandler(); return $handler; } Where `MyCustomMetaHandler` must extend AwFileMetaHandler and include the following methods: * **getMetaType()** - Returns a meta type name. Corresponds to AwFileMetaTypeTaxonomy terms. * **getMeta( $parent_id, $key )** - Returns data saved under $parent_id with $key * **updateMeta( $parent_id, $key, $files )** - Update a record with the current files * **getParentId()** - Used to determine parent of the data you are saving * **checkOwner( $user_id )** - Verify $user_id is allowed to save/update this item ** Note: You must also add your term to the AwFileMetaTypeTaxonomy. Check out AwFileMetaHandlerPost.php, AwFileMetaHandlerOption.php, and AwFileMetaHandlerUser.php under AwUploadify/classes/FileMetaHandler/ to see how those were implemented. = CSS = To override the default css use the `get_uploadify_css_url` filter. add_filter( 'get_uploadify_css_url', 'my_custom_uploadify_css_url' ); function my_custom_uploadify_css_url() { return "MY_CUSTOM_UPLOADIFY_CSS_URL"; } More to come...