wp_plupload_default_settings

Prints default Plupload arguments.

Description

wp_plupload_default_settings(); 

Usage

  1. if ( !function_exists( 'wp_plupload_default_settings' ) ) { 
  2. require_once ABSPATH . WPINC . '/media.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_plupload_default_settings(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/media.php  
  1. function wp_plupload_default_settings() { 
  2. $wp_scripts =wp_scripts); 
  3.  
  4. $data = $wp_scripts->get_data( 'wp-plupload', 'data' ); 
  5. if ( $data && false !== strpos( $data, '_wpPluploadSettings' ) ) 
  6. return; 
  7.  
  8. $max_upload_size = wp_max_upload_size(); 
  9. $allowed_extensions = array_keys( get_allowed_mime_types() ); 
  10. $extensions = array(); 
  11. foreach ( $allowed_extensions as $extension ) { 
  12. $extensions = array_merge( $extensions, explode( '|', $extension ) ); 
  13.  
  14. $defaults = array( 
  15. 'runtimes' => 'html5, flash, silverlight, html4',  
  16. 'file_data_name' => 'async-upload', // key passed to $_FILE. 
  17. 'url' => admin_url( 'async-upload.php', 'relative' ),  
  18. 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),  
  19. 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),  
  20. 'filters' => array( 
  21. 'max_file_size' => $max_upload_size . 'b',  
  22. 'mime_types' => array( array( 'extensions' => implode( ', ', $extensions ) ) ),  
  23. ),  
  24. ); 
  25.  
  26. // Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos 
  27. // when enabled. See #29602. 
  28. if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false && 
  29. strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) { 
  30.  
  31. $defaults['multi_selection'] = false; 
  32.  
  33. /** 
  34. * Filters the Plupload default settings. 
  35. * @since 3.4.0 
  36. * @param array $defaults Default Plupload settings array. 
  37. */ 
  38. $defaults = apply_filters( 'plupload_default_settings', $defaults ); 
  39.  
  40. $params = array( 
  41. 'action' => 'upload-attachment',  
  42. ); 
  43.  
  44. /** 
  45. * Filters the Plupload default parameters. 
  46. * @since 3.4.0 
  47. * @param array $params Default Plupload parameters array. 
  48. */ 
  49. $params = apply_filters( 'plupload_default_params', $params ); 
  50. $params['_wpnonce'] = wp_create_nonce( 'media-form' ); 
  51. $defaults['multipart_params'] = $params; 
  52.  
  53. $settings = array( 
  54. 'defaults' => $defaults,  
  55. 'browser' => array( 
  56. 'mobile' => wp_is_mobile(),  
  57. 'supported' => _device_can_upload(),  
  58. ),  
  59. 'limitExceeded' => is_multisite() && ! is_upload_space_available() 
  60. ); 
  61.  
  62. $script = 'var _wpPluploadSettings = ' . wp_json_encode( $settings ) . ';'; 
  63.  
  64. if ( $data ) 
  65. $script = "$data\n$script"; 
  66.  
  67. $wp_scripts->add_data( 'wp-plupload', 'data', $script );