PluginProbe
Polylang / trunk
Polylang vtrunk
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / src / Switcher / Fields / Widget.php

Widget.php in Polylang trunk, at src/Switcher/Fields/Widget.php

108 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Polylang
4 */
5
6 namespace WP_Syntex\Polylang\Switcher\Fields;
7
8 defined( 'ABSPATH' ) || exit;
9
10 /**
11 * Class that holds the setting field data when in a "widget".
12 *
13 * @since 3.9
14 *
15 * @phpstan-import-type FieldsData from Abstract_Fields
16 */
17 class Widget extends Abstract_Fields {
18 /**
19 * Returns setting field data available for the language switcher.
20 *
21 * @since 3.9
22 *
23 * @return array[]
24 *
25 * @phpstan-return FieldsData
26 */
27 public static function get(): array {
28 return array(
29 'layout' => array(
30 'label' => __( 'Layout', 'polylang' ),
31 'choices' => array(
32 'horizontal' => _x( 'Horizontal', 'layout', 'polylang' ),
33 'vertical' => _x( 'Vertical', 'layout', 'polylang' ),
34 'dropdown' => __( 'Dropdown', 'polylang' ),
35 'select' => __( 'Selector', 'polylang' ),
36 ),
37 'section' => __( 'Display', 'polylang' ),
38 ),
39 'alignment' => array(
40 'label' => __( 'Alignment', 'polylang' ),
41 'choices' => array(
42 'left' => _x( 'Left', 'alignment', 'polylang' ),
43 'center' => _x( 'Center', 'alignment', 'polylang' ),
44 'right' => _x( 'Right', 'alignment', 'polylang' ),
45 'stretched' => _x( 'Stretched', 'alignment', 'polylang' ),
46 ),
47 ),
48 'show_labels' => array(
49 'label' => __( 'Labels', 'polylang' ),
50 'choices' => array(
51 '' => _x( 'None', 'Labels', 'polylang' ),
52 'names' => __( 'Language names', 'polylang' ),
53 'codes' => __( 'Language codes', 'polylang' ),
54 ),
55 'hide_if' => array(
56 'layout' => 'select',
57 ),
58 ),
59 'show_flags' => array(
60 'label' => __( 'Display flags', 'polylang' ),
61 'hide_if' => array(
62 'layout' => 'select',
63 ),
64 'section' => __( 'Flags Settings', 'polylang' ),
65 ),
66 'flag_aspect_ratio' => array(
67 'label' => __( 'Aspect', 'polylang' ),
68 'choices' => array(
69 '3:2' => __( 'Landscape (3:2)', 'polylang' ),
70 '1:1' => __( 'Square (1:1)', 'polylang' ),
71 ),
72 'hide_if' => array(
73 'layout' => 'select',
74 'show_flags' => false,
75 ),
76 ),
77 'force_home' => array(
78 'label' => __( 'Force link to front page', 'polylang' ),
79 'section' => __( 'Behavior', 'polylang' ),
80 ),
81 'hide_current' => array(
82 'label' => __( 'Hide the current language', 'polylang' ),
83 ),
84 'hide_if_no_translation' => array(
85 'label' => __( 'Hide languages with no translation', 'polylang' ),
86 ),
87 );
88 }
89
90 /**
91 * Adds some legacy keys that we want to keep in the database alongside the new ones in case of plugin rollback.
92 * Must not be called before `Abstract_Fields::filter()`.
93 *
94 * This would be useful in case a user rollbacks to a version < 3.9.
95 * Backward compatibility with Polylang < 3.9.
96 *
97 * @since 3.9
98 *
99 * @param array $settings Switcher settings.
100 * @return array
101 */
102 public static function add_legacy_settings( array $settings ): array {
103 $settings['dropdown'] = isset( $settings['layout'] ) && 'select' === $settings['layout'] ? 1 : 0;
104 $settings['show_names'] = ! empty( $settings['show_labels'] ) ? 1 : 0;
105 return $settings;
106 }
107 }
108