✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ webm004.cluster127.gra.hosting.ovh.net ​🇻​♯➤ 6.18.42-ovh-vps-grsec-zfs+ #1 SMP 🇾​♯➤ 2026

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 54.36.91.62 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.108
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ _dyuweyrj4,_dyuweyrj4r,dl

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/docteuh/www/plugins/fusion-builder/inc//class-fusion-languages-updater-api.php
<?php
/**
 * Custom API implementation to automatically update languages for ThemeFusion products.
 *
 * @since 2.1
 * @package fusion-builder
 */

/**
 * Custom API client.
 *
 * @since 2.1
 * @example new Fusion_Languages_Updater( 'plugin', 'fusion-builder', '2.0.2', 'el' );
 */
class Fusion_Languages_Updater_API {

	/**
	 * Plugin or theme?
	 *
	 * @access private
	 * @since 2.1
	 * @var string
	 */
	private $type;

	/**
	 * The slug.
	 *
	 * @access private
	 * @since 2.1
	 * @var string
	 */
	private $slug;

	/**
	 * The language code.
	 *
	 * @access private
	 * @since 2.1
	 * @var string
	 */
	private $lang;

	/**
	 * The version.
	 *
	 * @access private
	 * @since 2.1
	 * @var string
	 */
	private $ver;

	/**
	 * The API response. Decoded from JSON to an array.
	 *
	 * @access private
	 * @since 2.1
	 * @var array
	 */
	private $vendor_api;

	/**
	 * The API URL.
	 *
	 * @access private
	 * @since 2.1
	 * @var string
	 */
	private $api_url = 'https://raw.githubusercontent.com/Theme-Fusion/Localization-l10n/master';

	/**
	 * Constructor.
	 *
	 * @access public
	 * @since 2.1
	 * @param string $type Can be "plugin" or "theme".
	 * @param string $slug The plugin - or theme - slug.
	 * @param string $ver  The version.
	 * @param string $lang The language.
	 */
	public function __construct( $type = 'plugin', $slug = '', $ver = '', $lang = '' ) {

		// Get option.
		$option = get_option( 'fusion_options' );
		if ( isset( $option['enable_language_updates'] ) && ( 0 === $option['enable_language_updates'] || '0' === $option['enable_language_updates'] ) ) {
			return;
		}

		// Assign object properties.
		$this->type = $type;
		$this->slug = $slug;
		$this->lang = $lang;
		$this->ver  = $ver;

		// If no language was defined, get the current language.
		if ( '' === $this->lang ) {
			$this->lang = get_user_locale();
		}

		// Early exit for en_US.
		if ( 'en_US' === $this->lang ) {
			return;
		}

		// Get the custom API response.
		$this->vendor_api = $this->get_vendor_api();

		// Change the hook for themes/plugins.
		$hook = ( 'theme' === $type ) ? 'site_transient_update_themes' : 'site_transient_update_plugins';

		// Add the filter.
		add_filter( $hook, [ $this, 'modify_api_response' ] );
	}

	/**
	 * Modify the transient based on our API response and the context of this object.
	 *
	 * @access public
	 * @since 2.1
	 * @param object $results The WP API response.
	 * @return object
	 */
	public function modify_api_response( $results ) {

		// Sanity check.
		if ( ! is_object( $results ) || ! $this->should_update() ) {
			return $results;
		}

		// Make sure the translations property is defined in the object.
		if ( ! isset( $results->translations ) || ! is_array( $results->translations ) ) {
			$results->translations = [];
		}

		// Set the translations from our custom API.
		$results->translations[] = [
			'type'       => $this->type,
			'slug'       => $this->slug,
			'language'   => $this->lang,
			'version'    => $this->ver,
			'updated'    => $this->get_updated(),
			'package'    => $this->get_package(),
			'autoupdate' => true,
		];
		return $results;
	}

	/**
	 * Figure out if there's an updated language file or not.
	 *
	 * @access private
	 * @since 2.1
	 * @return bool
	 */
	private function should_update() {

		// Get the translation.
		$translation = $this->get_item_from_api();

		// Only proceed with these checks if translation was found in the API.
		if ( $translation ) {

			// Build the translation path for our checks.
			$translation_path  = WP_LANG_DIR;
			$translation_path .= ( 'theme' === $this->type ) ? '/themes/' : '/plugins/';
			$translation_path .= $this->slug . '-' . $this->lang . '.mo';

			// If translation file does not exist then we should download it.
			if ( ! file_exists( $translation_path ) ) {
				return true;
			}

			// If the existing translation file is older than the one on the API, then we should update it.
			if ( filemtime( $translation_path ) < strtotime( $this->get_updated() ) ) {
				return true;
			}
		}

		// Fallback to false.
		return false;
	}

	/**
	 * Get the vendor API response.
	 *
	 * @access private
	 * @since 2.1
	 * @return array|false Returns the array, or false on failure.
	 */
	private function get_vendor_api() {

		// Try to get the response from cache.
		$transient_name = 'fusion_l10n_api_' . sanitize_key( $this->slug );
		$results        = get_site_transient( $transient_name );

		// If the cache is not populated or expired, get the data.
		if ( ! $results ) {
			$api_url = "{$this->api_url}/api-{$this->slug}.json";

			// Get the server response.
			$response = wp_remote_get( $api_url );

			// Make sure the response was OK and we have a body.
			if ( ! is_wp_error( $response ) && isset( $response['body'] ) ) {

				// JSON-decode the response's body.
				$results = json_decode( $response['body'], true );

				// Set cache for a day.
				set_site_transient( $transient_name, $results, DAY_IN_SECONDS );
			}
		}

		// Sanity check: If results is an array return them.
		if ( is_array( $results ) ) {
			return $results;
		}

		// Fallback to returning false.
		return false;
	}

	/**
	 * Get the item we need from the API.
	 *
	 * @access private
	 * @since 2.1
	 * @return array|false
	 */
	private function get_item_from_api() {
		$result = false;

		// Sanity check.
		if ( is_array( $this->vendor_api ) && isset( $this->vendor_api['translations'] ) && is_array( $this->vendor_api['translations'] ) ) {

			// Loop results.
			foreach ( $this->vendor_api['translations'] as $translation ) {

				// Check if item exists for the language and version specified.
				if ( isset( $translation['language'] ) && $this->lang === $translation['language'] && isset( $translation['version'] ) && $this->ver === $translation['version'] ) {
					$result = $translation;
					break;
				}
			}
		}

		// Return the result (falls-back to false if none was found).
		return $result;
	}

	/**
	 * Get the "updated" argument.
	 *
	 * @access private
	 * @since 2.1
	 * @return string|false Datetime or false on fail.
	 */
	private function get_updated() {
		$translation = $this->get_item_from_api();
		return ( $translation && isset( $translation['updated'] ) ) ? $translation['updated'] : false;
	}

	/**
	 * Get the "package" argument.
	 *
	 * @access private
	 * @since 2.1
	 * @return string URL.
	 */
	private function get_package() {
		$translation = $this->get_item_from_api();
		if ( $translation && isset( $translation['package'] ) ) {
			return $translation['package'];
		}

		// Fallback.
		return "{$this->api_url}/{$this->slug}/{$this->slug}-{$this->lang}.zip";
	}
}


Current_dir [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
27 Aug 2026 4.59 AM
docteuh / users
0755
admin-screens
--
26 Aug 2026 4.27 AM
docteuh / users
0755
critical-css
--
26 Aug 2026 4.27 AM
docteuh / users
0755
helpers
--
26 Aug 2026 4.27 AM
docteuh / users
0755
i18n
--
26 Aug 2026 4.27 AM
docteuh / users
0755
importer
--
26 Aug 2026 4.27 AM
docteuh / users
0755
lib
--
26 Aug 2026 4.27 AM
docteuh / users
0755
options
--
26 Aug 2026 4.27 AM
docteuh / users
0755
templates
--
26 Aug 2026 4.27 AM
docteuh / users
0755
woocommerce
--
26 Aug 2026 4.27 AM
docteuh / users
0755
bootstrap-compat.php
1.404 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
bootstrap.php
4.005 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-access-control.php
18.099 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-clone-posts.php
6.39 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-demo-import.php
9.663 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-layout-conditions.php
8.299 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-nav-walker.php
62.024 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-off-canvas-admin.php
6.993 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-off-canvas-front-end.php
34.571 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-off-canvas-table.php
11.708 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-off-canvas.php
8.525 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-studio-admin.php
15.814 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-studio-remove.php
3.5 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-studio.php
10.903 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-awb-woo-filters.php
20.748 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-builder-admin.php
29.584 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-builder-dynamic-css.php
7.231 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-builder-element-helper.php
13.69 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-builder-gutenberg.php
15.266 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-builder-library-table.php
15.083 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-builder-library.php
73.326 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-builder-options-panel.php
6.718 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-builder-options.php
5.465 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-builder-redux.php
1.899 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-builder-woocommerce.php
6.141 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-column-element.php
121.79 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-component.php
5.263 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-custom-icons-table.php
10.904 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-dummy-post.php
3.055 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-dynamic-data-callbacks.php
54.171 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-dynamic-data.php
78.321 KB
20 Nov 2023 7.14 PM
docteuh / users
0644
class-fusion-element.php
15.557 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-elements-dynamic-css.php
1.495 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-builder-table.php
14.449 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-builder.php
28.184 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-db-entries.php
2.205 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-db-fields.php
2.8 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-db-forms.php
7.889 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-db-install.php
7.239 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-db-items.php
4.778 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-db-privacy.php
15.198 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-db-submissions.php
1.75 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-db.php
2.374 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-export-single-form.php
3.647 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-list-table.php
11.473 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-submit.php
39.319 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-form-widget.php
4.028 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-hubspot.php
52.925 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-languages-updater-api.php
6.472 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-mailchimp.php
36.697 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-row-element.php
6.404 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-template-builder-table.php
12.915 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-template-builder.php
106.724 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-woo-component.php
12.091 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
class-fusion-woo-products-component.php
24.309 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
helpers.php
97.462 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
shortcodes.php
12.617 KB
20 Nov 2023 7.12 PM
docteuh / users
0644
templates.php
2.423 KB
20 Nov 2023 7.12 PM
docteuh / users
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF