fs_connect example


function wp_can_install_language_pack() {
    if ( ! wp_is_file_mod_allowed( 'can_install_language_pack' ) ) {
        return false;
    }

    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $skin     = new Automatic_Upgrader_Skin();
    $upgrader = new Language_Pack_Upgrader( $skin );
    $upgrader->init();

    $check = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );

    if ( ! $check || is_wp_error( $check ) ) {
        return false;
    }

    return true;
}
$this->upgrade_strings();

        $current = get_site_transient( 'update_themes' );

        add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
        add_filter( 'upgrader_post_install', array( $this, 'current_after' ), 10, 2 );
        add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ), 10, 4 );

        $this->skin->header();

        // Connect to the filesystem first.         $res = $this->fs_connect( array( WP_CONTENT_DIR ) );
        if ( ! $res ) {
            $this->skin->footer();
            return false;
        }

        $this->skin->bulk_header();

        /* * Only start maintenance mode if: * - running Multisite and there are one or more themes specified, OR * - a theme with an update available is currently in use. * @todo For multisite, maintenance mode should only kick in for individual sites if at all possible. */
$this->init();
        $this->bulk = true;
        $this->upgrade_strings();

        $current = get_site_transient( 'update_plugins' );

        add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );

        $this->skin->header();

        // Connect to the filesystem first.         $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
        if ( ! $res ) {
            $this->skin->footer();
            return false;
        }

        $this->skin->bulk_header();

        /* * Only start maintenance mode if: * - running Multisite and there are one or more plugins specified, OR * - a plugin with an update available is currently active. * @todo For multisite, maintenance mode should only kick in for individual sites if at all possible. */

        $options = apply_filters( 'upgrader_package_options', $options );

        if ( ! $options['is_multi'] ) { // Call $this->header separately if running multiple times.             $this->skin->header();
        }

        // Connect to the filesystem first.         $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) );
        // Mainly for non-connected filesystem.         if ( ! $res ) {
            if ( ! $options['is_multi'] ) {
                $this->skin->footer();
            }
            return false;
        }

        $this->skin->before();

        if ( is_wp_error( $res ) ) {
            

        $parsed_args = wp_parse_args( $args$defaults );

        $this->init();
        $this->upgrade_strings();

        // Is an update available?         if ( ! isset( $current->response ) || 'latest' === $current->response ) {
            return new WP_Error( 'up_to_date', $this->strings['up_to_date'] );
        }

        $res = $this->fs_connect( array( ABSPATH, WP_CONTENT_DIR )$parsed_args['allow_relaxed_file_ownership'] );
        if ( ! $res || is_wp_error( $res ) ) {
            return $res;
        }

        $wp_dir = trailingslashit( $wp_filesystem->abspath() );

        $partial = true;
        if ( $parsed_args['do_rollback'] ) {
            $partial = false;
        } elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() ) {
            $partial = false;
        }
// Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230.         remove_all_filters( 'upgrader_pre_install' );
        remove_all_filters( 'upgrader_clear_destination' );
        remove_all_filters( 'upgrader_post_install' );
        remove_all_filters( 'upgrader_source_selection' );

        add_filter( 'upgrader_source_selection', array( $this, 'check_package' ), 10, 2 );

        $this->skin->header();

        // Connect to the filesystem first.         $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
        if ( ! $res ) {
            $this->skin->footer();
            return false;
        }

        $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. */
Home | Imprint | This part of the site doesn't use cookies.