age collapsing has-emoji"> d01d7cf85d first commit 4 年之前 link-template.php d01d7cf85d first commit 4 年之前 load.php d01d7cf85d first commit 4 年之前 locale.php d01d7cf85d first commit 4 年之前 media-template.php d01d7cf85d first commit 4 年之前 media.php d01d7cf85d first commit 4 年之前 meta.php d01d7cf85d first commit 4 年之前 ms-blogs.php d01d7cf85d first commit 4 年之前 ms-default-constants.php d01d7cf85d first commit 4 年之前 ms-default-filters.php d01d7cf85d first commit 4 年之前 ms-deprecated.php d01d7cf85d first commit 4 年之前 ms-files.php d01d7cf85d first commit 4 年之前 ms-functions.php d01d7cf85d first commit 4 年之前 ms-load.php d01d7cf85d first commit 4 年之前 ms-network.php d01d7cf85d first commit 4 年之前 ms-settings.php d01d7cf85d first commit 4 年之前 ms-site.php d01d7cf85d first commit 4 年之前 nav-menu-template.php d01d7cf85d first commit 4 年之前 nav-menu.php d01d7cf85d first commit 4 年之前 option.php d01d7cf85d first commit 4 年之前 pluggable-deprecated.php d01d7cf85d first commit 4 年之前 pluggable.php d01d7cf85d first commit 4 年之前 plugin.php d01d7cf85d first commit 4 年之前 post-formats.php d01d7cf85d first commit 4 年之前 post-template.php d01d7cf85d first commit 4 年之前 post-thumbnail-template.php d01d7cf85d first commit 4 年之前 post.php d01d7cf85d first commit 4 年之前 query.php d01d7cf85d first commit 4 年之前 registration-functions.php d01d7cf85d first commit 4 年之前 registration.php d01d7cf85d first commit 4 年之前 rest-api.php d01d7cf85d first commit 4 年之前 revision.php d01d7cf85d first commit 4 年之前 rewrite.php d01d7cf85d first commit 4 年之前 robots-template.php d01d7cf85d first commit 4 年之前 rss-functions.php d01d7cf85d first commit 4 年之前 rss.php d01d7cf85d first commit 4 年之前 script-loader.php d01d7cf85d first commit 4 年之前 session.php d01d7cf85d first commit 4 年之前 shortcodes.php d01d7cf85d first commit 4 年之前 sitemaps.php d01d7cf85d first commit 4 年之前 spl-autoload-compat.php d01d7cf85d first commit 4 年之前 taxonomy.php d01d7cf85d first commit 4 年之前 template-canvas.php d01d7cf85d first commit 4 年之前 template-loader.php d01d7cf85d first commit 4 年之前 template.php d01d7cf85d first commit 4 年之前 theme-i18n.json d01d7cf85d first commit 4 年之前 theme-templates.php d01d7cf85d first commit 4 年之前 theme.json d01d7cf85d first commit 4 年之前 theme.php d01d7cf85d first commit 4 年之前 update.php d01d7cf85d first commit 4 年之前 user.php d01d7cf85d first commit 4 年之前 vars.php d01d7cf85d first commit 4 年之前 version.php d01d7cf85d first commit 4 年之前 widgets.php d01d7cf85d first commit 4 年之前 wlwmanifest.xml d01d7cf85d first commit 4 年之前 wp-db.php d01d7cf85d first commit 4 年之前 wp-diff.php d01d7cf85d first commit 4 年之前 tum/whitesports - Gogs: Simplico Git Service

暫無描述

media-upload.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * Manage media uploaded file.
  4. *
  5. * There are many filters in here for media. Plugins can extend functionality
  6. * by hooking into the filters.
  7. *
  8. * @package WordPress
  9. * @subpackage Administration
  10. */
  11. if ( ! isset( $_GET['inline'] ) ) {
  12. define( 'IFRAME_REQUEST', true );
  13. }
  14. /** Load WordPress Administration Bootstrap */
  15. require_once __DIR__ . '/admin.php';
  16. if ( ! current_user_can( 'upload_files' ) ) {
  17. wp_die( __( 'Sorry, you are not allowed to upload files.' ), 403 );
  18. }
  19. wp_enqueue_script( 'plupload-handlers' );
  20. wp_enqueue_script( 'image-edit' );
  21. wp_enqueue_script( 'set-post-thumbnail' );
  22. wp_enqueue_style( 'imgareaselect' );
  23. wp_enqueue_script( 'media-gallery' );
  24. header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
  25. // IDs should be integers.
  26. $ID = isset( $ID ) ? (int) $ID : 0; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
  27. $post_id = isset( $post_id ) ? (int) $post_id : 0;
  28. // Require an ID for the edit screen.
  29. if ( isset( $action ) && 'edit' === $action && ! $ID ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName
  30. wp_die(
  31. '<h1>' . __( 'Something went wrong.' ) . '</h1>' .
  32. '<p>' . __( 'Invalid item ID.' ) . '</p>',
  33. 403
  34. );
  35. }
  36. if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post', $_REQUEST['post_id'] ) ) {
  37. wp_die(
  38. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  39. '<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
  40. 403
  41. );
  42. }
  43. // Upload type: image, video, file, ...?
  44. if ( isset( $_GET['type'] ) ) {
  45. $type = (string) $_GET['type'];
  46. } else {
  47. /**
  48. * Filters the default media upload type in the legacy (pre-3.5.0) media popup.
  49. *
  50. * @since 2.5.0
  51. *
  52. * @param string $type The default media upload type. Possible values include
  53. * 'image', 'audio', 'video', 'file', etc. Default 'file'.
  54. */
  55. $type = apply_filters( 'media_upload_default_type', 'file' );
  56. }
  57. // Tab: gallery, library, or type-specific.
  58. if ( isset( $_GET['tab'] ) ) {
  59. $tab = (string) $_GET['tab'];
  60. } else {
  61. /**
  62. * Filters the default tab in the legacy (pre-3.5.0) media popup.
  63. *
  64. * @since 2.5.0
  65. *
  66. * @param string $tab The default media popup tab. Default 'type' (From Computer).
  67. */
  68. $tab = apply_filters( 'media_upload_default_tab', 'type' );
  69. }
  70. $body_id = 'media-upload';
  71. // Let the action code decide how to handle the request.
  72. if ( 'type' === $tab || 'type_url' === $tab || ! array_key_exists( $tab, media_upload_tabs() ) ) {
  73. /**
  74. * Fires inside specific upload-type views in the legacy (pre-3.5.0)
  75. * media popup based on the current tab.
  76. *
  77. * The dynamic portion of the hook name, `$type`, refers to the specific
  78. * media upload type.
  79. *
  80. * The hook only fires if the current `$tab` is 'type' (From Computer),
  81. * 'type_url' (From URL), or, if the tab does not exist (i.e., has not
  82. * been registered via the {@see 'media_upload_tabs'} filter.
  83. *
  84. * Possible hook names include:
  85. *
  86. * - `media_upload_audio`
  87. * - `media_upload_file`
  88. * - `media_upload_image`
  89. * - `media_upload_video`
  90. *
  91. * @since 2.5.0
  92. */
  93. do_action( "media_upload_{$type}" );
  94. } else {
  95. /**
  96. * Fires inside limited and specific upload-tab views in the legacy
  97. * (pre-3.5.0) media popup.
  98. *
  99. * The dynamic portion of the hook name, `$tab`, refers to the specific
  100. * media upload tab. Possible values include 'library' (Media Library),
  101. * or any custom tab registered via the {@see 'media_upload_tabs'} filter.
  102. *
  103. * @since 2.5.0
  104. */
  105. do_action( "media_upload_{$tab}" );
  106. }