Automatic_Upgrader_Skin example


    public function should_update( $type$item$context ) {
        // Used to see if WP_Filesystem is set up to allow unattended updates.         $skin = new Automatic_Upgrader_Skin();

        if ( $this->is_disabled() ) {
            return false;
        }

        // Only relax the filesystem checks when the update doesn't include new files.         $allow_relaxed_file_ownership = false;
        if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) {
            $allow_relaxed_file_ownership = true;
        }

        
$translation_to_load = true;
            break;
        }
    }

    if ( empty( $translation_to_load ) ) {
        return false;
    }
    $translation = (object) $translation;

    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $skin              = new Automatic_Upgrader_Skin();
    $upgrader          = new Language_Pack_Upgrader( $skin );
    $translation->type = 'core';
    $result            = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) );

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

    return $translation->language;
}


    public function test_check_wp_filesystem_method() {
        // Make sure the `request_filesystem_credentials()` function is available during our REST API call.         if ( ! function_exists( 'request_filesystem_credentials' ) ) {
            require_once ABSPATH . 'wp-admin/includes/file.php';
        }

        $skin    = new Automatic_Upgrader_Skin();
        $success = $skin->request_filesystem_credentials( false, ABSPATH );

        if ( ! $success ) {
            $description  = __( 'Your installation of WordPress prompts for FTP credentials to perform updates.' );
            $description .= ' ' . __( '(Your site is performing updates over FTP due to file ownership. Talk to your hosting company.)' );

            return array(
                'description' => $description,
                'severity'    => 'fail',
            );
        }

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