| 1 |
<?php |
| 2 |
|
| 3 |
// If this file is called directly, abort. |
| 4 |
if ( ! defined( 'WPINC' ) ) { |
| 5 |
die; |
| 6 |
} |
| 7 |
|
| 8 |
|
| 9 |
/** |
| 10 |
* Get attributes and selectors of JSON to translate |
| 11 |
* |
| 12 |
* @return array |
| 13 |
*/ |
| 14 |
function wplng_data_attr_json_to_translate() { |
| 15 |
return apply_filters( |
| 16 |
'wplng_attr_json_to_translate', |
| 17 |
array( |
| 18 |
// Theme: Divi |
| 19 |
array( |
| 20 |
'attr' => 'data-et-multi-view', |
| 21 |
'selector' => '[data-et-multi-view]', |
| 22 |
), |
| 23 |
|
| 24 |
// Theme: my-listing |
| 25 |
array( |
| 26 |
'attr' => ':choices', |
| 27 |
'selector' => 'order-filter[:choices]', |
| 28 |
), |
| 29 |
array( |
| 30 |
'attr' => ':choices', |
| 31 |
'selector' => 'checkboxes-filter[:choices]', |
| 32 |
), |
| 33 |
|
| 34 |
// Plugin: WooCommerce |
| 35 |
array( |
| 36 |
'attr' => 'data-wc-context', |
| 37 |
'selector' => '[data-wc-context]', |
| 38 |
), |
| 39 |
array( |
| 40 |
'attr' => 'data-wp-context', |
| 41 |
'selector' => '[data-wp-context]', |
| 42 |
), |
| 43 |
|
| 44 |
// Plugin: Elementor (or addon) |
| 45 |
array( |
| 46 |
'attr' => 'data-premium-element-link', |
| 47 |
'selector' => '[data-premium-element-link]', |
| 48 |
), |
| 49 |
) |
| 50 |
); |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
/** |
| 55 |
* Get attributes and selectors of texts in attribute to translate |
| 56 |
* |
| 57 |
* @return array |
| 58 |
*/ |
| 59 |
function wplng_data_attr_text_to_translate() { |
| 60 |
return apply_filters( |
| 61 |
'wplng_attr_text_to_translate', |
| 62 |
array( |
| 63 |
// Default tags |
| 64 |
array( |
| 65 |
'attr' => 'alt', |
| 66 |
'selector' => '[alt]', |
| 67 |
), |
| 68 |
array( |
| 69 |
'attr' => 'title', |
| 70 |
'selector' => '[title]', |
| 71 |
), |
| 72 |
array( |
| 73 |
'attr' => 'placeholder', |
| 74 |
'selector' => '[placeholder]', |
| 75 |
), |
| 76 |
array( |
| 77 |
'attr' => 'label', |
| 78 |
'selector' => '[label]', |
| 79 |
), |
| 80 |
array( |
| 81 |
'attr' => 'aria-label', |
| 82 |
'selector' => '[aria-label]', |
| 83 |
), |
| 84 |
array( |
| 85 |
'attr' => 'value', |
| 86 |
'selector' => '[type="submit"]', |
| 87 |
), |
| 88 |
array( |
| 89 |
'attr' => 'value', |
| 90 |
'selector' => 'input[type="button"]', |
| 91 |
), |
| 92 |
|
| 93 |
// WordPress |
| 94 |
array( |
| 95 |
'attr' => 'content', |
| 96 |
'selector' => 'meta[property="article:tag"]', |
| 97 |
), |
| 98 |
array( |
| 99 |
'attr' => 'content', |
| 100 |
'selector' => 'meta[property="article:section"]', |
| 101 |
), |
| 102 |
array( |
| 103 |
'attr' => 'content', |
| 104 |
'selector' => 'meta[name="description"]', |
| 105 |
), |
| 106 |
|
| 107 |
// Open Graph |
| 108 |
array( |
| 109 |
'attr' => 'content', |
| 110 |
'selector' => 'meta[property="og:title"]', |
| 111 |
), |
| 112 |
array( |
| 113 |
'attr' => 'content', |
| 114 |
'selector' => 'meta[property="og:description"]', |
| 115 |
), |
| 116 |
array( |
| 117 |
'attr' => 'content', |
| 118 |
'selector' => 'meta[property="og:site_name"]', |
| 119 |
), |
| 120 |
array( |
| 121 |
'attr' => 'content', |
| 122 |
'selector' => 'meta[property="og:image:alt"]', |
| 123 |
), |
| 124 |
|
| 125 |
// Dublin Core |
| 126 |
array( |
| 127 |
'attr' => 'content', |
| 128 |
'selector' => 'meta[name="dc.title"]', |
| 129 |
), |
| 130 |
array( |
| 131 |
'attr' => 'content', |
| 132 |
'selector' => 'meta[name="dc.description"]', |
| 133 |
), |
| 134 |
|
| 135 |
// Twitter |
| 136 |
array( |
| 137 |
'attr' => 'content', |
| 138 |
'selector' => 'meta[name="twitter:title"]', |
| 139 |
), |
| 140 |
array( |
| 141 |
'attr' => 'content', |
| 142 |
'selector' => 'meta[name="twitter:description"]', |
| 143 |
), |
| 144 |
array( |
| 145 |
'attr' => 'content', |
| 146 |
'selector' => 'meta[name="twitter:label1"]', |
| 147 |
), |
| 148 |
array( |
| 149 |
'attr' => 'content', |
| 150 |
'selector' => 'meta[name="twitter:data1"]', |
| 151 |
), |
| 152 |
array( |
| 153 |
'attr' => 'content', |
| 154 |
'selector' => 'meta[name="twitter:label2"]', |
| 155 |
), |
| 156 |
array( |
| 157 |
'attr' => 'content', |
| 158 |
'selector' => 'meta[name="twitter:data2"]', |
| 159 |
), |
| 160 |
array( |
| 161 |
'attr' => 'content', |
| 162 |
'selector' => 'meta[name="twitter:image:alt"]', |
| 163 |
), |
| 164 |
|
| 165 |
// Plugin: Fluent Forms tooltips |
| 166 |
array( |
| 167 |
'attr' => 'data-content', |
| 168 |
'selector' => '.ff-el-tooltip[data-content]', |
| 169 |
), |
| 170 |
|
| 171 |
// Plugin: Forminator |
| 172 |
array( |
| 173 |
'attr' => 'data-placeholder', |
| 174 |
'selector' => '[data-placeholder]', |
| 175 |
), |
| 176 |
array( |
| 177 |
'attr' => 'data-search-placeholde', |
| 178 |
'selector' => '[data-search-placeholde]', |
| 179 |
), |
| 180 |
|
| 181 |
// Plugin: Smart Slider 3 |
| 182 |
array( |
| 183 |
'attr' => 'data-title', |
| 184 |
'selector' => '[data-title]', |
| 185 |
), |
| 186 |
|
| 187 |
// Plugin: WooCommerce |
| 188 |
array( |
| 189 |
'attr' => 'data-order_button_text', |
| 190 |
'selector' => '[data-order_button_text]', |
| 191 |
), |
| 192 |
) |
| 193 |
); |
| 194 |
} |
| 195 |
|
| 196 |
|
| 197 |
/** |
| 198 |
* Get attributes and selectors of HTML in attribute to translate |
| 199 |
* |
| 200 |
* @return array |
| 201 |
*/ |
| 202 |
function wplng_data_attr_html_to_translate() { |
| 203 |
return apply_filters( |
| 204 |
'wplng_attr_html_to_translate', |
| 205 |
array( |
| 206 |
array( |
| 207 |
'attr' => 'data-sub-html', |
| 208 |
'selector' => '[data-sub-html]', |
| 209 |
), |
| 210 |
) |
| 211 |
); |
| 212 |
} |
| 213 |
|
| 214 |
|
| 215 |
/** |
| 216 |
* Get attributes and selectors of URL to translate |
| 217 |
* |
| 218 |
* @return array |
| 219 |
*/ |
| 220 |
function wplng_data_attr_url_to_translate() { |
| 221 |
return apply_filters( |
| 222 |
'wplng_attr_url_to_translate', |
| 223 |
array( |
| 224 |
array( |
| 225 |
'attr' => 'href', |
| 226 |
'selector' => 'a[href]', |
| 227 |
), |
| 228 |
array( |
| 229 |
'attr' => 'action', |
| 230 |
'selector' => 'form[action]', |
| 231 |
), |
| 232 |
array( |
| 233 |
'attr' => 'content', |
| 234 |
'selector' => 'meta[property="og:url"]', |
| 235 |
), |
| 236 |
array( |
| 237 |
'attr' => 'href', |
| 238 |
'selector' => 'link[rel="canonical"]', |
| 239 |
), |
| 240 |
array( |
| 241 |
'attr' => 'content', |
| 242 |
'selector' => 'meta[name="dc.relation"]', |
| 243 |
), |
| 244 |
array( |
| 245 |
'attr' => 'src', |
| 246 |
'selector' => 'img[src]', |
| 247 |
), |
| 248 |
array( |
| 249 |
'attr' => 'src', |
| 250 |
'selector' => 'iframe[src]', |
| 251 |
), |
| 252 |
array( |
| 253 |
'attr' => 'src', |
| 254 |
'selector' => 'video source[src]', |
| 255 |
), |
| 256 |
|
| 257 |
// Plugin: Divi Supreme |
| 258 |
array( |
| 259 |
'attr' => 'data-mfp-src', |
| 260 |
'selector' => '[data-mfp-src]', |
| 261 |
), |
| 262 |
) |
| 263 |
); |
| 264 |
} |
| 265 |
|
| 266 |
|
| 267 |
/** |
| 268 |
* GEt attributes and selector of elements where translate language ID |
| 269 |
* |
| 270 |
* @return array |
| 271 |
*/ |
| 272 |
function wplng_data_attr_lang_id_to_replace() { |
| 273 |
return apply_filters( |
| 274 |
'wplng_attr_lang_id_to_replace', |
| 275 |
array( |
| 276 |
array( |
| 277 |
'attr' => 'lang', |
| 278 |
'selector' => 'html', |
| 279 |
), |
| 280 |
array( |
| 281 |
'attr' => 'content', |
| 282 |
'selector' => 'meta[property="og:locale"]', |
| 283 |
), |
| 284 |
array( |
| 285 |
'attr' => 'content', |
| 286 |
'selector' => 'meta[name="dc.language"]', |
| 287 |
), |
| 288 |
) |
| 289 |
); |
| 290 |
} |
| 291 |
|