|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Settings page schema. |
| 4 | + * |
| 5 | + * @package SrbTransLatin |
| 6 | + */ |
| 7 | + |
| 8 | +declare(strict_types=1); |
| 9 | + |
| 10 | +defined( 'ABSPATH' ) || exit; |
| 11 | + |
| 12 | +$locale = \get_locale(); |
| 13 | +$disable_permalinks = \in_array( $locale, array( 'sr_RS', 'bs_BA' ), true ); |
| 14 | +$navigation_menus = \get_registered_nav_menus(); |
| 15 | +$has_navigation_menus = 0 < \count( $navigation_menus ); |
| 16 | + |
| 17 | +return array( |
| 18 | + 'page' => array( |
| 19 | + 'option_name' => \STL\Common\Settings\Settings_Schema::OPTION_NAME, |
| 20 | + 'slug' => \STL\Common\Settings\Settings_Schema::PAGE_SLUG, |
| 21 | + 'page_title' => \__( 'Latinisation', 'srbtranslatin' ), |
| 22 | + 'menu_title' => \__( 'Settings', 'default' ), |
| 23 | + 'parent_slug' => 'options-general.php', |
| 24 | + 'capability' => 'manage_options', |
| 25 | + ), |
| 26 | + 'tabs' => array( |
| 27 | + array( |
| 28 | + 'id' => 'general', |
| 29 | + 'title' => \__( 'General', 'srbtranslatin' ), |
| 30 | + 'icon' => 'dashicons-admin-generic', |
| 31 | + ), |
| 32 | + array( |
| 33 | + 'id' => 'menu', |
| 34 | + 'title' => \__( 'Menus', 'srbtranslatin' ), |
| 35 | + 'icon' => 'dashicons-menu', |
| 36 | + ), |
| 37 | + array( |
| 38 | + 'id' => 'media', |
| 39 | + 'title' => \__( 'Media', 'srbtranslatin' ), |
| 40 | + 'icon' => 'dashicons-format-image', |
| 41 | + ), |
| 42 | + array( |
| 43 | + 'id' => 'advanced', |
| 44 | + 'title' => \__( 'Advanced', 'default' ), |
| 45 | + 'icon' => 'dashicons-admin-tools', |
| 46 | + ), |
| 47 | + ), |
| 48 | + 'sections' => array( |
| 49 | + array( |
| 50 | + 'id' => 'general', |
| 51 | + 'title' => \_x( 'General settings', 'section name', 'srbtranslatin' ), |
| 52 | + 'description' => \__( 'General settings control main functionality of the plugin', 'srbtranslatin' ), |
| 53 | + 'tab' => 'general', |
| 54 | + ), |
| 55 | + array( |
| 56 | + 'id' => 'menu', |
| 57 | + 'title' => \_x( 'Navigation menu settings', 'section name', 'srbtranslatin' ), |
| 58 | + 'description' => \__( 'Menu settings control extending and tweaking the script selector in theme menus', 'srbtranslatin' ), |
| 59 | + 'tab' => 'menu', |
| 60 | + ), |
| 61 | + array( |
| 62 | + 'id' => 'media', |
| 63 | + 'title' => \_x( 'File and Media settings', 'section name', 'srbtranslatin' ), |
| 64 | + 'description' => \__( 'File and media settings control filename transliteration and media saving', 'srbtranslatin' ), |
| 65 | + 'tab' => 'media', |
| 66 | + ), |
| 67 | + array( |
| 68 | + 'id' => 'advanced', |
| 69 | + 'title' => \_x( 'Advanced settings', 'section name', 'srbtranslatin' ), |
| 70 | + 'description' => \__( 'Advanced settings control permalink and search settings', 'srbtranslatin' ), |
| 71 | + 'tab' => 'advanced', |
| 72 | + ), |
| 73 | + ), |
| 74 | + 'fields' => array( |
| 75 | + array( |
| 76 | + 'id' => 'enabled_scripts', |
| 77 | + 'type' => 'buttons_group', |
| 78 | + 'title' => \__( 'Enabled scripts', 'srbtranslatin' ), |
| 79 | + 'section' => 'general', |
| 80 | + 'extras' => array( |
| 81 | + 'default' => 'both', |
| 82 | + 'description' => \__( 'Cyrillic and Latin', 'srbtranslatin' ), |
| 83 | + 'options' => array( |
| 84 | + 'cir' => 'Ћ ' . \__( 'Cyrillic', 'srbtranslatin' ), |
| 85 | + 'lat' => 'Ć ' . \__( 'Latin', 'srbtranslatin' ), |
| 86 | + 'both' => 'Ć Ћ ' . \__( 'Both', 'srbtranslatin' ), |
| 87 | + ), |
| 88 | + ), |
| 89 | + ), |
| 90 | + array( |
| 91 | + 'id' => 'default_script', |
| 92 | + 'type' => 'select', |
| 93 | + 'title' => \__( 'Default script', 'srbtranslatin' ), |
| 94 | + 'section' => 'general', |
| 95 | + 'extras' => array( |
| 96 | + 'default' => 'cir', |
| 97 | + 'description' => \__( 'Default script used for the website if user did not select a script', 'srbtranslatin' ), |
| 98 | + 'options' => array( |
| 99 | + 'cir' => \__( 'Cyrillic', 'srbtranslatin' ), |
| 100 | + 'lat' => \__( 'Latin', 'srbtranslatin' ), |
| 101 | + ), |
| 102 | + 'conditions' => array( |
| 103 | + 'rules' => array( |
| 104 | + array( |
| 105 | + 'field' => 'enabled_scripts', |
| 106 | + 'operator' => '=', |
| 107 | + 'value' => 'both', |
| 108 | + ), |
| 109 | + ), |
| 110 | + ), |
| 111 | + ), |
| 112 | + ), |
| 113 | + array( |
| 114 | + 'id' => 'url_param', |
| 115 | + 'type' => 'text', |
| 116 | + 'title' => \__( 'URL Parameter', 'srbtranslatin' ), |
| 117 | + 'section' => 'general', |
| 118 | + 'extras' => array( |
| 119 | + 'default' => 'pismo', |
| 120 | + 'description' => \__( 'URL parameter used for script selector', 'srbtranslatin' ), |
| 121 | + ), |
| 122 | + ), |
| 123 | + array( |
| 124 | + 'id' => 'menu_warning', |
| 125 | + 'type' => 'description', |
| 126 | + 'title' => '', |
| 127 | + 'section' => 'menu', |
| 128 | + 'extras' => array( |
| 129 | + 'description' => ! $has_navigation_menus |
| 130 | + ? '<strong>' . \__( 'Options in this section are disabled because you do not have any navigation menus registered', 'srbtranslatin' ) . '</strong>' |
| 131 | + : '', |
| 132 | + 'html_attributes' => array( |
| 133 | + 'class' => 'notice inline notice-warning', |
| 134 | + ), |
| 135 | + ), |
| 136 | + ), |
| 137 | + array( |
| 138 | + 'id' => 'extend', |
| 139 | + 'type' => 'checkbox', |
| 140 | + 'title' => \__( 'Extend navigation menu', 'srbtranslatin' ), |
| 141 | + 'section' => 'menu', |
| 142 | + 'extras' => array( |
| 143 | + 'default' => true, |
| 144 | + 'description' => \__( 'Adds a script selector to the navigation menu', 'srbtranslatin' ), |
| 145 | + 'html_attributes' => array( |
| 146 | + 'disabled' => ! $has_navigation_menus, |
| 147 | + ), |
| 148 | + ), |
| 149 | + ), |
| 150 | + array( |
| 151 | + 'id' => 'extend_menu', |
| 152 | + 'type' => 'select', |
| 153 | + 'title' => \__( 'Navigation menu to extend', 'srbtranslatin' ), |
| 154 | + 'section' => 'menu', |
| 155 | + 'extras' => array( |
| 156 | + 'default' => '', |
| 157 | + 'description' => \__( 'Select the navigation menu you want to extend', 'srbtranslatin' ), |
| 158 | + 'options' => \array_merge( |
| 159 | + array( '' => \__( 'Select a menu', 'srbtranslatin' ) ), |
| 160 | + $navigation_menus, |
| 161 | + ), |
| 162 | + 'html_attributes' => array( |
| 163 | + 'disabled' => ! $has_navigation_menus, |
| 164 | + ), |
| 165 | + ), |
| 166 | + ), |
| 167 | + array( |
| 168 | + 'id' => 'selector_type', |
| 169 | + 'type' => 'select', |
| 170 | + 'title' => \__( 'Selector type', 'srbtranslatin' ), |
| 171 | + 'section' => 'menu', |
| 172 | + 'extras' => array( |
| 173 | + 'default' => 'submenu', |
| 174 | + 'description' => \__( 'Choose the type of the script selector', 'srbtranslatin' ), |
| 175 | + 'options' => array( |
| 176 | + 'submenu' => \__( 'Submenu', 'srbtranslatin' ), |
| 177 | + 'inline' => \__( 'Inline', 'srbtranslatin' ), |
| 178 | + ), |
| 179 | + 'html_attributes' => array( |
| 180 | + 'disabled' => ! $has_navigation_menus, |
| 181 | + ), |
| 182 | + ), |
| 183 | + ), |
| 184 | + array( |
| 185 | + 'id' => 'menu_title', |
| 186 | + 'type' => 'text', |
| 187 | + 'title' => \__( 'Menu item title', 'srbtranslatin' ), |
| 188 | + 'section' => 'menu', |
| 189 | + 'extras' => array( |
| 190 | + 'default' => \__( 'Script', 'srbtranslatin' ), |
| 191 | + 'description' => \__( 'Title of the menu item', 'srbtranslatin' ), |
| 192 | + 'html_attributes' => array( |
| 193 | + 'disabled' => ! $has_navigation_menus, |
| 194 | + ), |
| 195 | + ), |
| 196 | + ), |
| 197 | + array( |
| 198 | + 'id' => 'transliterate_uploads', |
| 199 | + 'type' => 'checkbox', |
| 200 | + 'title' => \__( 'Transliterate uploads', 'srbtranslatin' ), |
| 201 | + 'section' => 'media', |
| 202 | + 'extras' => array( |
| 203 | + 'default' => true, |
| 204 | + 'description' => \__( 'Transliterate filenames on upload', 'srbtranslatin' ), |
| 205 | + ), |
| 206 | + ), |
| 207 | + array( |
| 208 | + 'id' => 'separate_uploads', |
| 209 | + 'type' => 'checkbox', |
| 210 | + 'title' => \__( 'Script specific filenames', 'srbtranslatin' ), |
| 211 | + 'section' => 'media', |
| 212 | + 'extras' => array( |
| 213 | + 'default' => true, |
| 214 | + 'description' => \__( 'Check this box if you want to have separate filenames for each script', 'srbtranslatin' ), |
| 215 | + ), |
| 216 | + ), |
| 217 | + array( |
| 218 | + 'id' => 'filename_separator', |
| 219 | + 'type' => 'text', |
| 220 | + 'title' => \__( 'Filename separator', 'srbtranslatin' ), |
| 221 | + 'section' => 'media', |
| 222 | + 'extras' => array( |
| 223 | + 'default' => '-', |
| 224 | + 'description' => \__( 'Separator used for script specific filenames', 'srbtranslatin' ), |
| 225 | + 'html_attributes' => array( |
| 226 | + 'class' => 'small-text', |
| 227 | + ), |
| 228 | + ), |
| 229 | + ), |
| 230 | + array( |
| 231 | + 'id' => 'transliteration_method', |
| 232 | + 'type' => 'select', |
| 233 | + 'title' => \__( 'Transliteration method', 'srbtranslatin' ), |
| 234 | + 'section' => 'media', |
| 235 | + 'extras' => array( |
| 236 | + 'default' => 'website', |
| 237 | + 'description' => \__( 'Choose if you want to limit the script specific filenames on the entire website, or in content only', 'srbtranslatin' ), |
| 238 | + 'options' => array( |
| 239 | + 'website' => \__( 'Entire website', 'srbtranslatin' ), |
| 240 | + 'content' => \__( 'Content only', 'srbtranslatin' ), |
| 241 | + ), |
| 242 | + ), |
| 243 | + ), |
| 244 | + array( |
| 245 | + 'id' => 'fix_permalinks', |
| 246 | + 'type' => 'checkbox', |
| 247 | + 'title' => \__( 'Fix Permalinks', 'srbtranslatin' ), |
| 248 | + 'section' => 'advanced', |
| 249 | + 'extras' => array( |
| 250 | + 'default' => false, |
| 251 | + 'description' => $disable_permalinks |
| 252 | + ? \sprintf( |
| 253 | + \__( 'Fixes permalinks for cyrillic scripts. This option is currently disabled because your current locale is set to %s which will automatically change permalinks.', 'srbtranslatin' ), |
| 254 | + $locale, |
| 255 | + ) |
| 256 | + : \__( 'Fixes permalinks for cyrillic scripts', 'srbtranslatin' ), |
| 257 | + 'html_attributes' => array( |
| 258 | + 'disabled' => $disable_permalinks, |
| 259 | + ), |
| 260 | + ), |
| 261 | + ), |
| 262 | + array( |
| 263 | + 'id' => 'fix_search', |
| 264 | + 'type' => 'checkbox', |
| 265 | + 'title' => \__( 'Fix Search', 'srbtranslatin' ), |
| 266 | + 'section' => 'advanced', |
| 267 | + 'extras' => array( |
| 268 | + 'default' => true, |
| 269 | + 'description' => \__( 'Enables searching cyrillic content via latin script', 'srbtranslatin' ), |
| 270 | + ), |
| 271 | + ), |
| 272 | + array( |
| 273 | + 'id' => 'fix_ajax', |
| 274 | + 'type' => 'checkbox', |
| 275 | + 'title' => \__( 'Fix Ajax', 'srbtranslatin' ), |
| 276 | + 'section' => 'advanced', |
| 277 | + 'extras' => array( |
| 278 | + 'default' => false, |
| 279 | + 'description' => \__( 'Transliterates ajax calls', 'srbtranslatin' ), |
| 280 | + ), |
| 281 | + ), |
| 282 | + array( |
| 283 | + 'id' => 'fix_titles', |
| 284 | + 'type' => 'checkbox', |
| 285 | + 'title' => \__( 'Fix Titles', 'srbtranslatin' ), |
| 286 | + 'section' => 'advanced', |
| 287 | + 'extras' => array( |
| 288 | + 'default' => false, |
| 289 | + 'description' => \__( 'Fixes titles for cyrillic scripts', 'srbtranslatin' ), |
| 290 | + ), |
| 291 | + ), |
| 292 | + ), |
| 293 | +); |
0 commit comments