wp_is_writable example

static $temp = '';
    if ( defined( 'WP_TEMP_DIR' ) ) {
        return trailingslashit( WP_TEMP_DIR );
    }

    if ( $temp ) {
        return trailingslashit( $temp );
    }

    if ( function_exists( 'sys_get_temp_dir' ) ) {
        $temp = sys_get_temp_dir();
        if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) {
            return trailingslashit( $temp );
        }
    }

    $temp = ini_get( 'upload_tmp_dir' );
    if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) {
        return trailingslashit( $temp );
    }

    $temp = WP_CONTENT_DIR . '/';
    if ( is_dir( $temp ) && wp_is_writable( $temp ) ) {
        
'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
                    'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
                ),
                'DB_COLLATE'          => array(
                    'label' => 'DB_COLLATE',
                    'value' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : __( 'Undefined' ) ),
                    'debug' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : 'undefined' ),
                ),
            ),
        );

        $is_writable_abspath            = wp_is_writable( ABSPATH );
        $is_writable_wp_content_dir     = wp_is_writable( WP_CONTENT_DIR );
        $is_writable_upload_dir         = wp_is_writable( $upload_dir['basedir'] );
        $is_writable_wp_plugin_dir      = wp_is_writable( WP_PLUGIN_DIR );
        $is_writable_template_directory = wp_is_writable( get_theme_root( get_template() ) );

        $info['wp-filesystem'] = array(
            'label'       => __( 'Filesystem Permissions' ),
            'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ),
            'fields'      => array(
                'wordpress'  => array(
                    'label' => __( 'The main WordPress directory' ),
                    
// If we are streaming to a file but no filename was given drop it in the WP temp dir         // and pick its name using the basename of the $url.         if ( $parsed_args['stream'] ) {
            if ( empty( $parsed_args['filename'] ) ) {
                $parsed_args['filename'] = get_temp_dir() . basename( $url );
            }

            // Force some settings if we are streaming to a file and check for existence             // and perms of destination directory.             $parsed_args['blocking'] = true;
            if ( ! wp_is_writable( dirname( $parsed_args['filename'] ) ) ) {
                $response = new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
                /** This action is documented in wp-includes/class-wp-http.php */
                do_action( 'http_api_debug', $response, 'response', 'WpOrg\Requests\Requests', $parsed_args$url );
                return $response;
            }
        }

        if ( is_null( $parsed_args['headers'] ) ) {
            $parsed_args['headers'] = array();
        }

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