load_script_translations

The timeline below displays how wordpress function load_script_translations has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.7

/**
 * Loads the translation data for the given script handle and text domain.
 *
 * @since 5.0.2
 *
 * @param string|false $file   Path to the translation file to load. False if there isn't one.
 * @param string       $handle Name of the script to register a translation domain to.
 * @param string       $domain The text domain.
 * @return string|false The JSON-encoded translated strings for the given script handle and text domain.
 *                      False if there are none.
 */
function load_script_translations($file, $handle, $domain)
{
    /**
     * Pre-filters script translations for the given file, script handle and text domain.
     *
     * Returning a non-null value allows to override the default logic, effectively short-circuiting the function.
     *
     * @since 5.0.2
     *
     * @param string|false|null $translations JSON-encoded translation data. Default null.
     * @param string|false      $file         Path to the translation file to load. False if there isn't one.
     * @param string            $handle       Name of the script to register a translation domain to.
     * @param string            $domain       The text domain.
     */
    $translations = apply_filters('pre_load_script_translations', null, $file, $handle, $domain);
    if (null !== $translations) {
        return $translations;
    }
    /**
     * Filters the file path for loading script translations for the given script handle and text domain.
     *
     * @since 5.0.2
     *
     * @param string|false $file   Path to the translation file to load. False if there isn't one.
     * @param string       $handle Name of the script to register a translation domain to.
     * @param string       $domain The text domain.
     */
    $file = apply_filters('load_script_translation_file', $file, $handle, $domain);
    if (!$file || !is_readable($file)) {
        return false;
    }
    $translations = file_get_contents($file);
    /**
     * Filters script translations for the given file, script handle and text domain.
     *
     * @since 5.0.2
     *
     * @param string $translations JSON-encoded translation data.
     * @param string $file         Path to the translation file that was loaded.
     * @param string $handle       Name of the script to register a translation domain to.
     * @param string $domain       The text domain.
     */
    return apply_filters('load_script_translations', $translations, $file, $handle, $domain);
}

WordPress Version: 5.3

/**
 * Loads the translation data for the given script handle and text domain.
 *
 * @since 5.0.2
 *
 * @param string|false $file   Path to the translation file to load. False if there isn't one.
 * @param string       $handle Name of the script to register a translation domain to.
 * @param string       $domain The text domain.
 * @return string|false The JSON-encoded translated strings for the given script handle and text domain. False if there are none.
 */
function load_script_translations($file, $handle, $domain)
{
    /**
     * Pre-filters script translations for the given file, script handle and text domain.
     *
     * Returning a non-null value allows to override the default logic, effectively short-circuiting the function.
     *
     * @since 5.0.2
     *
     * @param string|false|null $translations JSON-encoded translation data. Default null.
     * @param string|false      $file         Path to the translation file to load. False if there isn't one.
     * @param string            $handle       Name of the script to register a translation domain to.
     * @param string            $domain       The text domain.
     */
    $translations = apply_filters('pre_load_script_translations', null, $file, $handle, $domain);
    if (null !== $translations) {
        return $translations;
    }
    /**
     * Filters the file path for loading script translations for the given script handle and text domain.
     *
     * @since 5.0.2
     *
     * @param string|false $file   Path to the translation file to load. False if there isn't one.
     * @param string       $handle Name of the script to register a translation domain to.
     * @param string       $domain The text domain.
     */
    $file = apply_filters('load_script_translation_file', $file, $handle, $domain);
    if (!$file || !is_readable($file)) {
        return false;
    }
    $translations = file_get_contents($file);
    /**
     * Filters script translations for the given file, script handle and text domain.
     *
     * @since 5.0.2
     *
     * @param string $translations JSON-encoded translation data.
     * @param string $file         Path to the translation file that was loaded.
     * @param string $handle       Name of the script to register a translation domain to.
     * @param string $domain       The text domain.
     */
    return apply_filters('load_script_translations', $translations, $file, $handle, $domain);
}

WordPress Version: .10

/**
 * Loads the translation data for the given script handle and text domain.
 *
 * @since 5.0.2
 *
 * @param string|false $file   Path to the translation file to load. False if there isn't one.
 * @param string       $handle Name of the script to register a translation domain to.
 * @param string       $domain The text domain.
 * @return string|false The JSON-encoded translated strings for the given script handle and text domain. False if there are none.
 */
function load_script_translations($file, $handle, $domain)
{
    /**
     * Pre-filters script translations for the given file, script handle and text domain.
     *
     * Returning a non-null value allows to override the default logic, effectively short-circuiting the function.
     *
     * @since 5.0.2
     *
     * @param string|false $translations JSON-encoded translation data. Default null.
     * @param string|false $file         Path to the translation file to load. False if there isn't one.
     * @param string       $handle       Name of the script to register a translation domain to.
     * @param string       $domain       The text domain.
     */
    $translations = apply_filters('pre_load_script_translations', null, $file, $handle, $domain);
    if (null !== $translations) {
        return $translations;
    }
    /**
     * Filters the file path for loading script translations for the given script handle and text domain.
     *
     * @since 5.0.2
     *
     * @param string|false $file   Path to the translation file to load. False if there isn't one.
     * @param string       $handle Name of the script to register a translation domain to.
     * @param string       $domain The text domain.
     */
    $file = apply_filters('load_script_translation_file', $file, $handle, $domain);
    if (!$file || !is_readable($file)) {
        return false;
    }
    $translations = file_get_contents($file);
    /**
     * Filters script translations for the given file, script handle and text domain.
     *
     * @since 5.0.2
     *
     * @param string $translations JSON-encoded translation data.
     * @param string $file         Path to the translation file that was loaded.
     * @param string $handle       Name of the script to register a translation domain to.
     * @param string $domain       The text domain.
     */
    return apply_filters('load_script_translations', $translations, $file, $handle, $domain);
}