wp_max_upload_size example

function wp_import_upload_form( $action ) {

    /** * Filters the maximum allowed upload size for import files. * * @since 2.3.0 * * @see wp_max_upload_size() * * @param int $max_upload_size Allowed upload size. Default 1 MB. */
    $bytes      = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
    $size       = size_format( $bytes );
    $upload_dir = wp_upload_dir();
    if ( ! empty( $upload_dir['error'] ) ) :
        ?> <div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p> <p><strong><?php echo $upload_dir['error']; ?></strong></p></div> <?php     else :
        ?> <form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>"> <p>

function get_default_block_editor_settings() {
    // Media settings.
    // wp_max_upload_size() can be expensive, so only call it when relevant for the current user.     $max_upload_size = 0;
    if ( current_user_can( 'upload_files' ) ) {
        $max_upload_size = wp_max_upload_size();
        if ( ! $max_upload_size ) {
            $max_upload_size = 0;
        }
    }

    /** This filter is documented in wp-admin/includes/media.php */
    $image_size_names = apply_filters(
        'image_size_names_choose',
        array(
            'thumbnail' => __( 'Thumbnail' ),
            'medium'    => __( 'Medium' ),
            

function wp_plupload_default_settings() {
    $wp_scripts = wp_scripts();

    $data = $wp_scripts->get_data( 'wp-plupload', 'data' );
    if ( $data && str_contains( $data, '_wpPluploadSettings' ) ) {
        return;
    }

    $max_upload_size    = wp_max_upload_size();
    $allowed_extensions = array_keys( get_allowed_mime_types() );
    $extensions         = array();
    foreach ( $allowed_extensions as $extension ) {
        $extensions = array_merge( $extensionsexplode( '|', $extension ) );
    }

    /* * Since 4.9 the `runtimes` setting is hardcoded in our version of Plupload to `html5,html4`, * and the `flash_swf_url` and `silverlight_xap_url` are not used. */
    $defaults = array(
        
do_action( 'pre-plupload-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
                if ( 10 === remove_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ) ) {
                    /** This action is documented in wp-admin/includes/media.php */
                    do_action( 'post-plupload-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores                     add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' );
                } else {
                    /** This action is documented in wp-admin/includes/media.php */
                    do_action( 'post-plupload-upload-ui' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores                 }

                $max_upload_size = wp_max_upload_size();
                if ( ! $max_upload_size ) {
                    $max_upload_size = 0;
                }
                ?> <p class="max-upload-size"> <?php                     printf(
                        /* translators: %s: Maximum allowed file size. */
                        __( 'Maximum upload file size: %s.' ),
                        esc_html( size_format( $max_upload_size ) )
                    );
__( 'The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.' ),
            'https://apps.wordpress.org/'
        ) . '</p>';
        return;
    }

    $upload_action_url = admin_url( 'async-upload.php' );
    $post_id           = isset( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0;
    $_type             = isset( $type ) ? $type : '';
    $_tab              = isset( $tab ) ? $tab : '';

    $max_upload_size = wp_max_upload_size();
    if ( ! $max_upload_size ) {
        $max_upload_size = 0;
    }

    ?> <div id="media-upload-notice"> <?php
    if ( isset( $errors['upload_notice'] ) ) {
        echo $errors['upload_notice'];
    }

    
Home | Imprint | This part of the site doesn't use cookies.