Skip to content

Commit

Permalink
chore: update plugin sitepress-multilingual-cms to 4.6.13
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaPipolo committed Oct 25, 2024
1 parent da580ea commit 97ed0c6
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit88c82b693cbb06834ce54e8a1610ba0c::getLoader();
return ComposerAutoloaderInit6db28b495b608840254527e283111ebb::getLoader();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit88c82b693cbb06834ce54e8a1610ba0c
class ComposerAutoloaderInit6db28b495b608840254527e283111ebb
{
private static $loader;

Expand All @@ -24,15 +24,15 @@ public static function getLoader()

require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInit88c82b693cbb06834ce54e8a1610ba0c', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit6db28b495b608840254527e283111ebb', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit88c82b693cbb06834ce54e8a1610ba0c', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit6db28b495b608840254527e283111ebb', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInit88c82b693cbb06834ce54e8a1610ba0c::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit6db28b495b608840254527e283111ebb::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
Expand All @@ -53,12 +53,12 @@ public static function getLoader()
$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit88c82b693cbb06834ce54e8a1610ba0c::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit6db28b495b608840254527e283111ebb::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire88c82b693cbb06834ce54e8a1610ba0c($fileIdentifier, $file);
composerRequire6db28b495b608840254527e283111ebb($fileIdentifier, $file);
}

return $loader;
Expand All @@ -70,7 +70,7 @@ public static function getLoader()
* @param string $file
* @return void
*/
function composerRequire88c82b693cbb06834ce54e8a1610ba0c($fileIdentifier, $file)
function composerRequire6db28b495b608840254527e283111ebb($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit88c82b693cbb06834ce54e8a1610ba0c
class ComposerStaticInit6db28b495b608840254527e283111ebb
{
public static $files = array (
'b45b351e6b6f7487d819961fef2fda77' => __DIR__ . '/..' . '/jakeasmith/http_build_url/src/http_build_url.php',
Expand Down Expand Up @@ -310,7 +310,7 @@ class ComposerStaticInit88c82b693cbb06834ce54e8a1610ba0c
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->classMap = ComposerStaticInit88c82b693cbb06834ce54e8a1610ba0c::$classMap;
$loader->classMap = ComposerStaticInit6db28b495b608840254527e283111ebb::$classMap;

}, null, ClassLoader::class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

#[AllowDynamicProperties]
class WPML_LS_Menu_Item {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,17 @@ public function render( $slot ) {
$this->assets->maybe_late_enqueue_template( $slot->template() );
$this->current_template = clone $this->templates->get_template( $slot->template() );

$sandbox = false;
if ( $slot->template_string() ) {
$this->current_template->set_template_string( $slot->template_string() );
$sandbox = true;
}

$model = $this->model_build->get( $slot, $this->current_template->get_template_data() );

if ( $model['languages'] ) {
$this->current_template->set_model( $model );
$html = $this->current_template->get_html();
$html = $this->current_template->get_html( $sandbox );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ public function set_model( $model ) {
* @throws \WPML\Core\Twig\Error\RuntimeError
* @throws \WPML\Core\Twig\Error\SyntaxError
*/
public function get_html() {
public function get_html( $sandbox = false ) {
$ret = '';
if ( $this->template_paths || $this->template_string ) {
$ret = parent::get_view();
if ( $sandbox ) {
$ret = parent::get_sandbox_view( null, null );
} else {
$ret = parent::get_view( null, null );
}
}
return $ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ abstract class WPML_Templates_Factory {
const NOTICE_GROUP = 'template_factory';
const OTGS_TWIG_CACHE_DISABLED_KEY = '_otgs_twig_cache_disabled';

/*
* List of tags and filters that are allowed in the sandbox mode.
* Specifically excluded 'include' and 'import' tags.
* Excluded the 'filter', 'reduce', 'map' filters.
*/
const SANDBOX_FUNCTIONS = [
'attribute', 'block', 'constant', 'country_names', 'country_timezones', 'currency_names', 'cycle', 'date',
'html_classes', 'language_names', 'locale_names', 'max', 'min', 'parent', 'random', 'range', 'script_names',
'source', 'template_from_string', 'timezone_names'
];
const SANDBOX_TAGS = [ 'apply', 'autoescape', 'block', 'cache', 'do', 'embed', 'flush', 'for', 'from', 'if',
'macro', 'set', 'with'
];
const SANDBOX_FILTERS = ['abs', 'batch', 'capitalize', 'column', 'convert_encoding', 'country_name',
'currency_name', 'currency_symbol', 'data_uri', 'date', 'date_modify', 'default', 'escape', 'first',
'format','format_currency', 'format_date', 'format_datetime', 'format_number', 'format_time',
'html_to_markdown', 'inky_to_html', 'inline_css', 'join', 'json_encode', 'keys', 'language_name',
'last', 'length', 'locale_name', 'lower', 'markdown_to_html', 'merge', 'nl2br', 'number_format',
'replace', 'reverse', 'round', 'sort', 'spaceless', 'striptags', 'title', 'trim', 'upper',
'url_encode', 'url_decode', 'u', 'wordwrap'
];

/** @var array */
protected $custom_filters;

Expand All @@ -28,6 +50,9 @@ abstract class WPML_Templates_Factory {
/** @var Twig_Environment */
protected $twig;

/** @var Twig_Environment */
protected $sandboxTwig;

/**
* WPML_Templates_Factory constructor.
*
Expand Down Expand Up @@ -59,6 +84,38 @@ public function show( $template = null, $model = null ) {
echo $this->get_view( $template, $model );
}

public function get_sandbox_view( $template = null, $model = null ) {
$output = '';
$this->maybe_init_sandbox_twig();

if ( null === $model ) {
$model = $this->get_model();
}
if ( null === $template ) {
$template = $this->get_template();
}

try {
$output = $this->sandboxTwig->render( $template, $model );
} catch ( RuntimeException $e ) {
if ( $this->is_caching_enabled() ) {
$this->disable_twig_cache();
$this->sandboxTwig = null;
$this->maybe_init_sandbox_twig();
$output = $this->get_sandbox_view( $template, $model );
} else {
$this->add_exception_notice( $e );
}
} catch ( Twig_Error_Syntax $e ) {
$message = 'Invalid Twig template string: ' . $e->getRawMessage() . "\n" . $template;
$this->get_wp_api()->error_log( $message );
} catch ( WPML\Core\Twig\Sandbox\SecurityNotAllowedFilterError $e ) {
$this->get_wp_api()->error_log( $e->getMessage() );
}

return $output;
}

/**
* @param ?string $template
* @param ?array<string,mixed> $model
Expand Down Expand Up @@ -99,42 +156,11 @@ public function get_view( $template = null, $model = null ) {
}

protected function maybe_init_twig() {
if ( ! $this->twig ) {
$loader = $this->get_twig_loader();

$environment_args = array();

if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
$environment_args['debug'] = true;
}

if ( $this->is_caching_enabled() ) {
$wpml_cache_directory = new WPML_Cache_Directory( $this->get_wp_api() );
$this->cache_directory = $wpml_cache_directory->get( 'twig' );

if ( $this->cache_directory ) {
$environment_args['cache'] = $this->cache_directory;
$environment_args['auto_reload'] = true;
} else {
$this->disable_twig_cache();
}
}
$this->_init_twig( false );
}

$this->twig = $this->get_wp_api()->get_twig_environment( $loader, $environment_args );
if ( $this->custom_functions && count( $this->custom_functions ) > 0 ) {
foreach ( $this->custom_functions as $custom_function ) {
$this->twig->addFunction( $custom_function );
}
}
if ( $this->custom_filters && count( $this->custom_filters ) > 0 ) {
foreach ( $this->custom_filters as $custom_filter ) {
$this->twig->addFilter( $custom_filter );
}
}
if ( Obj::propOr( false, 'debug', $environment_args ) ) {
$this->twig->addExtension( new \WPML\Core\Twig\Extension\DebugExtension() );
}
}
protected function maybe_init_sandbox_twig() {
$this->_init_twig( true );
}

abstract public function get_template();
Expand Down Expand Up @@ -204,4 +230,59 @@ protected function get_twig_loader() {

return $loader;
}


protected function _init_twig( $sandbox = false ) {
if ( ( ! $this->twig && ! $sandbox ) || ( ! $this->sandboxTwig && $sandbox ) ) {
$loader = $this->get_twig_loader();

$environment_args = array();

if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
$environment_args['debug'] = true;
}

if ( $this->is_caching_enabled() ) {
$wpml_cache_directory = new WPML_Cache_Directory( $this->get_wp_api() );
$this->cache_directory = $wpml_cache_directory->get( 'twig' );

if ( $this->cache_directory ) {
$environment_args['cache'] = $this->cache_directory;
$environment_args['auto_reload'] = true;
} else {
$this->disable_twig_cache();
}
}

$twig = $this->get_wp_api()->get_twig_environment( $loader, $environment_args );
if ( $this->custom_functions && count( $this->custom_functions ) > 0 ) {
foreach ( $this->custom_functions as $custom_function ) {
$twig->addFunction( $custom_function );
}
}
if ( $this->custom_filters && count( $this->custom_filters ) > 0 ) {
foreach ( $this->custom_filters as $custom_filter ) {
$twig->addFilter( $custom_filter );
}
}
if ( Obj::propOr( false, 'debug', $environment_args ) ) {
$twig->addExtension( new \WPML\Core\Twig\Extension\DebugExtension() );
}
if ( $sandbox && ( ! defined( 'WPML_LS_TEMPLATE_UNSAFE_MODE' ) || ! WPML_LS_TEMPLATE_UNSAFE_MODE ) ) {
$policy = new \WPML\Core\Twig\Sandbox\SecurityPolicy(
self::SANDBOX_TAGS,
self::SANDBOX_FILTERS,
[],
[],
self::SANDBOX_FUNCTIONS
);
$twig->addExtension( new \WPML\Core\Twig\Extension\SandboxExtension( $policy, true ) );
}
if ( $sandbox ) {
$this->sandboxTwig = $twig;
} else {
$this->twig = $twig;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function _process_generic_text( $source_text, &$alp_broken_links ) {
$request_match = $req_uri . '/' . $request;
}

if ( preg_match( "!^$match!", $request_match, $matches ) || preg_match( "!^$match!", urldecode( $request_match ), $matches ) ) {
if ( preg_match( "#^$match#", $request_match, $matches ) || preg_match( "#^$match#", urldecode( $request_match ), $matches ) ) {
// Got a match.

// Trim the query of everything up to the '?'.
Expand Down
2 changes: 1 addition & 1 deletion wp-content/plugins/sitepress-multilingual-cms/readme.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
=== SitePress Multilingual CMS ===
Stable tag: 4.6.12
Stable tag: 4.6.13
6 changes: 3 additions & 3 deletions wp-content/plugins/sitepress-multilingual-cms/sitepress.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/**
* Plugin Name: WPML Multilingual CMS
* Plugin URI: https://wpml.org/
* Description: WPML Multilingual CMS | <a href="https://wpml.org">Documentation</a> | <a href="https://wpml.org/version/wpml-4-6-12/">WPML 4.6.12 release notes</a>
* Description: WPML Multilingual CMS | <a href="https://wpml.org">Documentation</a> | <a href="https://wpml.org/version/wpml-4-6-13/">WPML 4.6.13 release notes</a>
* Author: OnTheGoSystems
* Author URI: http://www.onthegosystems.com/
* Version: 4.6.12
* Version: 4.6.13
* Plugin Slug: sitepress-multilingual-cms
*
* @package WPML\Core
Expand All @@ -29,7 +29,7 @@
return;
}

define( 'ICL_SITEPRESS_VERSION', '4.6.12' );
define( 'ICL_SITEPRESS_VERSION', '4.6.13' );

// Do not uncomment the following line!
// If you need to use this constant, use it in the wp-config.php file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit94c4b71bcde764d13f2979261af726e4::getLoader();
return ComposerAutoloaderInit65c4f41f6d25bd3a323807106b299e9c::getLoader();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit94c4b71bcde764d13f2979261af726e4
class ComposerAutoloaderInit65c4f41f6d25bd3a323807106b299e9c
{
private static $loader;

Expand All @@ -24,15 +24,15 @@ public static function getLoader()

require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInit94c4b71bcde764d13f2979261af726e4', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit65c4f41f6d25bd3a323807106b299e9c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit94c4b71bcde764d13f2979261af726e4', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit65c4f41f6d25bd3a323807106b299e9c', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInit94c4b71bcde764d13f2979261af726e4::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit65c4f41f6d25bd3a323807106b299e9c::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
Expand All @@ -53,12 +53,12 @@ public static function getLoader()
$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit94c4b71bcde764d13f2979261af726e4::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit65c4f41f6d25bd3a323807106b299e9c::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire94c4b71bcde764d13f2979261af726e4($fileIdentifier, $file);
composerRequire65c4f41f6d25bd3a323807106b299e9c($fileIdentifier, $file);
}

return $loader;
Expand All @@ -70,7 +70,7 @@ public static function getLoader()
* @param string $file
* @return void
*/
function composerRequire94c4b71bcde764d13f2979261af726e4($fileIdentifier, $file)
function composerRequire65c4f41f6d25bd3a323807106b299e9c($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
Loading

0 comments on commit 97ed0c6

Please sign in to comment.