PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.0.13
Admin Columns v7.0.13
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 3 months ago AdvancedCustomFields.php 3 months ago NinjaForms.php 3 months ago WPML.php 3 months ago WPMLColumn.php 3 months ago WooCommerce.php 3 months ago
WPML.php
111 lines
1 <?php
2
3 namespace AC\ThirdParty;
4
5 use AC;
6 use AC\ListScreenRepository\Storage;
7 use AC\Registerable;
8
9 /**
10 * WPML compatibility
11 */
12 class WPML implements Registerable
13 {
14
15 private Storage $storage;
16
17 public function __construct(Storage $storage)
18 {
19 $this->storage = $storage;
20 }
21
22 public function register(): void
23 {
24 // Display correct flags on the list tables
25 add_action('ac/table/list_screen', [$this, 'replace_flags']);
26
27 // Enable the translation of the column labels
28 add_action('init', [$this, 'register_column_labels'], 300);
29
30 // Enable the WPML translation of column headings
31 add_filter('ac/column/heading/label', [$this, 'register_translated_label'], 100);
32 }
33
34 public function replace_flags(): void
35 {
36 if ( ! class_exists('SitePress', false)) {
37 return;
38 }
39
40 $settings = get_option('icl_sitepress_settings');
41
42 $post_types = $settings['custom_posts_sync_option'] ?? [];
43
44 if ( ! $post_types) {
45 return;
46 }
47
48 $post_types = (array)$post_types;
49 $post_types['post'] = 1;
50 $post_types['page'] = 1;
51
52 foreach ($post_types as $post_type => $value) {
53 if ($value) {
54 new WPMLColumn((string)$post_type);
55 }
56 }
57 }
58
59 private function is_translation_page(): bool
60 {
61 $page = $_GET['page'] ?? null;
62
63 return 'wpml-string-translation/menu/string-translation.php' === $page;
64 }
65
66 // Create translatable column labels
67 public function register_column_labels(): void
68 {
69 if ( ! $this->is_translation_page()) {
70 return;
71 }
72
73 foreach ($this->storage->find_all() as $list_screen) {
74 /**
75 * @var AC\Column $column
76 */
77 foreach ($list_screen->get_columns() as $column) {
78 $setting = $column->get_setting('label');
79
80 if ( ! $setting) {
81 continue;
82 }
83
84 $label = $setting->get_input()->get_value();
85
86 do_action(
87 'wpml_register_single_string',
88 'Admin Columns',
89 $label,
90 $label
91 );
92 }
93 }
94 }
95
96 public function register_translated_label($label)
97 {
98 if (defined('ICL_LANGUAGE_CODE')) {
99 $label = apply_filters(
100 'wpml_translate_single_string',
101 $label,
102 'Admin Columns',
103 $label,
104 constant('ICL_LANGUAGE_CODE')
105 );
106 }
107
108 return $label;
109 }
110
111 }