• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

timber / timber / 5690057835

pending completion
5690057835

push

github

nlemoine
Merge branch '2.x' of github.com:timber/timber into 2.x-refactor-file-models

# Conflicts:
#	src/Attachment.php
#	src/ExternalImage.php
#	src/FileSize.php
#	src/URLHelper.php

1134 of 1134 new or added lines in 55 files covered. (100.0%)

3923 of 4430 relevant lines covered (88.56%)

59.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

46.67
/src/Integration/WpmlIntegration.php
1
<?php
2

3
namespace Timber\Integration;
4

5
use WP_Post;
6
use WPML_LS_Menu_Item;
7

8
class WpmlIntegration implements IntegrationInterface
9
{
10
    public function should_init(): bool
11
    {
12
        return \function_exists('wpml_object_id_filter');
×
13
    }
14

15
    public function init(): void
16
    {
17
        \add_filter('timber/url_helper/file_system_to_url', [$this, 'file_system_to_url'], 10, 1);
×
18
        \add_filter('timber/url_helper/get_content_subdir/home_url', [$this, 'file_system_to_url'], 10, 1);
×
19
        \add_filter('timber/url_helper/url_to_file_system/path', [$this, 'file_system_to_url'], 10, 1);
×
20
        \add_filter('timber/menu/id_from_location', [$this, 'menu_object_id_filter'], 10, 1);
×
21
        \add_filter('timber/menu/item_objects', [$this, 'menu_item_objects_filter'], 10, 1);
×
22
        \add_filter('timber/image_helper/_get_file_url/home_url', [$this, 'file_system_to_url'], 10, 1);
×
23
    }
24

25
    public function file_system_to_url($url)
26
    {
27
        if (\defined('ICL_LANGUAGE_CODE')) {
60✔
28
            $url = \preg_replace('/(?<!:\/)\/' . ICL_LANGUAGE_CODE . '/', '', $url);
60✔
29
        }
30
        return $url;
60✔
31
    }
32

33
    public function menu_object_id_filter($id)
34
    {
35
        return \wpml_object_id_filter($id, 'nav_menu');
×
36
    }
37

38
    public function menu_item_objects_filter(array $items)
39
    {
40
        return \array_map(
64✔
41
            fn ($item) => ($item instanceof WPML_LS_Menu_Item ? new WP_Post($item) : $item),
64✔
42
            $items
64✔
43
        );
64✔
44
    }
45
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc