PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.1.4
Admin Columns v7.1.4
7.1.4 7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / ThirdParty / WPML.php
codepress-admin-columns / classes / ThirdParty Last commit date
MediaLibraryAssistant 2 days ago AdvancedCustomFields.php 2 days ago NinjaForms.php 2 days ago WPML.php 2 days ago WPMLColumn.php 2 days ago WooCommerce.php 2 days ago
WPML.php
113 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AC\ThirdParty;
6
7 use AC;
8 use AC\ListScreenRepository\Storage;
9 use AC\Registerable;
10
11 /**
12 * WPML compatibility
13 */
14 class WPML implements Registerable
15 {
16 private Storage $storage;
17
18 public function __construct(Storage $storage)
19 {
20 $this->storage = $storage;
21 }
22
23 public function register(): void
24 {
25 // Display correct flags on the list tables
26 add_action('ac/table/list_screen', [$this, 'replace_flags']);
27
28 // Enable the translation of the column labels
29 add_action('init', [$this, 'register_column_labels'], 300);
30
31 // Enable the WPML translation of column headings
32 add_filter('ac/column/heading/label', [$this, 'register_translated_label'], 100);
33 }
34
35 public function replace_flags(): void
36 {
37 if (! class_exists('SitePress', false)) {
38 return;
39 }
40
41 $settings = get_option('icl_sitepress_settings');
42
43 $post_types = $settings['custom_posts_sync_option'] ?? [];
44
45 if (! $post_types) {
46 return;
47 }
48
49 $post_types = (array)$post_types;
50 $post_types['post'] = 1;
51 $post_types['page'] = 1;
52
53 foreach ($post_types as $post_type => $value) {
54 if ($value) {
55 new WPMLColumn((string)$post_type);
56 }
57 }
58 }
59
60 private function is_translation_page(): bool
61 {
62 $page = $_GET['page'] ?? null;
63
64 return 'wpml-string-translation/menu/string-translation.php' === $page;
65 }
66
67 // Create translatable column labels
68 public function register_column_labels(): void
69 {
70 if (! $this->is_translation_page()) {
71 return;
72 }
73
74 foreach ($this->storage->find_all() as $list_screen) {
75 /**
76 * @var AC\Column $column
77 */
78 foreach ($list_screen->get_columns() as $column) {
79 $setting = $column->get_setting('label');
80
81 if (! $setting) {
82 continue;
83 }
84
85 $label = $setting->get_input()->get_value();
86
87 do_action(
88 'wpml_register_single_string',
89 'Admin Columns',
90 $label,
91 $label
92 );
93 }
94 }
95 }
96
97 public function register_translated_label($label)
98 {
99 if (defined('ICL_LANGUAGE_CODE')) {
100 $label = apply_filters(
101 'wpml_translate_single_string',
102 $label,
103 'Admin Columns',
104 $label,
105 constant('ICL_LANGUAGE_CODE')
106 );
107 }
108
109 return $label;
110 }
111
112 }
113