find_folder example

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'] );
                    }
                    break;
                default:
                    if ( ! $wp_filesystem->find_folder( $dir ) ) {
                        return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder']esc_html( basename( $dir ) ) ) );
                    }
                    break;
            }
        }
        return true;
    }

    /** * Downloads a package. * * @since 2.8.0 * @since 5.2.0 Added the `$check_signatures` parameter. * @since 5.5.0 Added the `$hook_extra` parameter. * * @param string $package The URI of the package. If this is the full path to an * existing local file, it will be returned untouched. * @param bool $check_signatures Whether to validate file signatures. Default false. * @param array $hook_extra Extra arguments to pass to the filter hooks. Default empty array. * @return string|WP_Error The full path to the downloaded package file, or a WP_Error object. */

    public $options = array();

    /** * Returns the path on the remote filesystem of ABSPATH. * * @since 2.7.0 * * @return string The location of the remote path. */
    public function abspath() {
        $folder = $this->find_folder( ABSPATH );

        /* * Perhaps the FTP folder is rooted at the WordPress install. * Check for wp-includes folder in root. Could have some false positives, but rare. */
        if ( ! $folder && $this->is_dir( '/' . WPINC ) ) {
            $folder = '/';
        }

        return $folder;
    }

    


        $results = array();

        $this->update_count   = count( $language_updates );
        $this->update_current = 0;

        /* * The filesystem's mkdir() is not recursive. Make sure WP_LANG_DIR exists, * as we then may need to create a /plugins or /themes directory inside of it. */
        $remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR );
        if ( ! $wp_filesystem->exists( $remote_destination ) ) {
            if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
                return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed']$remote_destination );
            }
        }

        $language_updates_results = array();

        foreach ( $language_updates as $language_update ) {

            $this->skin->language_update = $language_update;

            

        // Check if the language directory exists first.         if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) {
            // If it's within the ABSPATH we can handle it here, otherwise they're out of luck.             $wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR );
            clearstatcache(); // For FTP, need to clear the stat cache.         }

        if ( @is_dir( $lang_dir ) ) {
            $wp_lang_dir = $wp_filesystem->find_folder( $lang_dir );

            if ( $wp_lang_dir ) {
                $result = copy_dir( $from . $distro . 'wp-content/languages/', $wp_lang_dir );

                if ( is_wp_error( $result ) ) {
                    $result = new WP_Error(
                        $result->get_error_code() . '_languages',
                        $result->get_error_message(),
                        substr( $result->get_error_data()strlen( $wp_lang_dir ) )
                    );
                }
            }
Home | Imprint | This part of the site doesn't use cookies.