wp_content_dir example

ob_start();
        $credentials = request_filesystem_credentials( '' );
        ob_end_clean();

        if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
            $result['status']      = 'recommended';
            $result['label']       = __( 'Could not access filesystem' );
            $result['description'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
            return $result;
        }

        $wp_content = $wp_filesystem->wp_content_dir();

        if ( ! $wp_content ) {
            $result['status']      = 'critical';
            $result['label']       = __( 'Unable to locate WordPress content directory' );
            $result['description'] = sprintf(
                /* translators: %s: wp-content */
                '<p>' . __( 'The %s directory cannot be located.' ) . '</p>',
                '<code>wp-content</code>'
            );
            return $result;
        }

        

    public function check_package( $source ) {
        global $wp_filesystem$wp_version;

        $this->new_theme_data = array();

        if ( is_wp_error( $source ) ) {
            return $source;
        }

        // Check that the folder contains a valid theme.         $working_directory = str_replace( $wp_filesystem->wp_content_dir()trailingslashit( WP_CONTENT_DIR )$source );
        if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation.             return $source;
        }

        // A proper archive should have a style.css file in the single subdirectory.         if ( ! file_exists( $working_directory . 'style.css' ) ) {
            return new WP_Error(
                'incompatible_archive_theme_no_style',
                $this->strings['incompatible_archive'],
                sprintf(
                    /* translators: %s: style.css */
                    
return new WP_Error( 'fs_error', $this->strings['fs_error']$wp_filesystem->errors );
        }

        foreach ( (array) $directories as $dir ) {
            switch ( $dir ) {
                case ABSPATH:
                    if ( ! $wp_filesystem->abspath() ) {
                        return new WP_Error( 'fs_no_root_dir', $this->strings['fs_no_root_dir'] );
                    }
                    break;
                case WP_CONTENT_DIR:
                    if ( ! $wp_filesystem->wp_content_dir() ) {
                        return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
                    }
                    break;
                case WP_PLUGIN_DIR:
                    if ( ! $wp_filesystem->wp_plugins_dir() ) {
                        return new WP_Error( 'fs_no_plugins_dir', $this->strings['fs_no_plugins_dir'] );
                    }
                    break;
                case get_theme_root():
                    if ( ! $wp_filesystem->wp_themes_dir() ) {
                        return new WP_Error( 'fs_no_themes_dir', $this->strings['fs_no_themes_dir'] );
                    }
require_once ABSPATH . '/wp-admin/includes/file.php';
    }

    ob_start();
    $credentials = request_filesystem_credentials( '' );
    ob_end_clean();

    if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
        return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
    }

    if ( ! $wp_filesystem->wp_content_dir() ) {
        return new WP_Error( 'fs_no_content_dir', __( 'Unable to locate WordPress content directory (wp-content).' ) );
    }

    $temp_backup_dir = $wp_filesystem->wp_content_dir() . 'upgrade-temp-backup/';
    $dirlist         = $wp_filesystem->dirlist( $temp_backup_dir );
    $dirlist         = $dirlist ? $dirlist : array();

    foreach ( array_keys( $dirlist ) as $dir ) {
        if ( '.' === $dir || '..' === $dir ) {
            continue;
        }

        

    public function check_package( $source ) {
        global $wp_filesystem$wp_version;

        $this->new_plugin_data = array();

        if ( is_wp_error( $source ) ) {
            return $source;
        }

        $working_directory = str_replace( $wp_filesystem->wp_content_dir()trailingslashit( WP_CONTENT_DIR )$source );
        if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation.             return $source;
        }

        // Check that the folder contains at least 1 valid plugin.         $files = glob( $working_directory . '*.php' );
        if ( $files ) {
            foreach ( $files as $file ) {
                $info = get_plugin_data( $file, false, false );
                if ( ! empty( $info['Name'] ) ) {
                    $this->new_plugin_data = $info;
                    
$wp_filesystem->delete( $from, true );

        return new WP_Error( 'insane_distro', __( 'The update could not be unpacked' ) );
    }

    /* * Import $wp_version, $required_php_version, and $required_mysql_version from the new version. * DO NOT globalize any variables imported from `version-current.php` in this function. * * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8. */
    $versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php';

    if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) {
        $wp_filesystem->delete( $from, true );

        return new WP_Error(
            'copy_failed_for_version_file',
            __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' ),
            'wp-includes/version.php'
        );
    }

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