| 1 |
<?php |
| 2 |
|
| 3 |
// If this file is called directly, abort. |
| 4 |
if ( ! defined( 'WPINC' ) ) { |
| 5 |
die; |
| 6 |
} |
| 7 |
|
| 8 |
|
| 9 |
/** |
| 10 |
* Print HTML Option page : wpLingua Dictionary |
| 11 |
* |
| 12 |
* @return void |
| 13 |
*/ |
| 14 |
function wplng_option_page_dictionary() { |
| 15 |
|
| 16 |
$entries_json = wplng_dictionary_get_entries_json(); |
| 17 |
$wplng_dictionary_updated_data = get_transient( 'wplng_dictionary_updated_data' ); |
| 18 |
|
| 19 |
delete_transient( 'wplng_dictionary_updated_data' ); |
| 20 |
|
| 21 |
?> |
| 22 |
|
| 23 |
<div class="wrap"> |
| 24 |
|
| 25 |
<header id="wplng-option-page-header"> |
| 26 |
<h1 class="wplng-option-page-title"><span class="dashicons dashicons-translation"></span> <?php esc_html_e( 'wpLingua - Dictionary rules', 'wplingua' ); ?></h1> |
| 27 |
<?php echo wplng_option_page_settings_menu(); ?> |
| 28 |
</header> |
| 29 |
|
| 30 |
<hr class="wp-header-end"> |
| 31 |
|
| 32 |
<form id="wplng-option-dictionary-form" method="post" action="options.php"> |
| 33 |
<?php |
| 34 |
settings_fields( 'wplng_dictionary' ); |
| 35 |
do_settings_sections( 'wplng_dictionary' ); |
| 36 |
?> |
| 37 |
<table class="form-table wplng-form-table"> |
| 38 |
|
| 39 |
<?php |
| 40 |
|
| 41 |
$style_section_entries_all = ''; |
| 42 |
|
| 43 |
if ( false !== $wplng_dictionary_updated_data ) { |
| 44 |
$style_section_entries_all = 'display: none;'; |
| 45 |
wplng_option_page_dictionary_update_translations_html( |
| 46 |
$wplng_dictionary_updated_data |
| 47 |
); |
| 48 |
} |
| 49 |
?> |
| 50 |
|
| 51 |
<tr class="wplng-beta-hidden" style="display: none;"> |
| 52 |
<th scope="row"><span class="dashicons dashicons-printer"></span> <?php esc_html_e( 'Debug', 'wplingua' ); ?></th> |
| 53 |
<td> |
| 54 |
<fieldset> |
| 55 |
<textarea name="wplng_dictionary_entries" id="wplng_dictionary_entries"><?php echo esc_textarea( $entries_json ); ?></textarea> |
| 56 |
</fieldset> |
| 57 |
</td> |
| 58 |
</tr> |
| 59 |
|
| 60 |
<tr id="wplng-section-entries-all" style="<?php echo esc_attr( $style_section_entries_all ); ?>"> |
| 61 |
<th scope="row"><span class="dashicons dashicons-book"></span> <?php esc_html_e( 'Dictionary entries', 'wplingua' ); ?></th> |
| 62 |
<td> |
| 63 |
<fieldset> |
| 64 |
|
| 65 |
<p><strong><?php esc_html_e( 'Translation rules by dictionary: ', 'wplingua' ); ?></strong></p> |
| 66 |
|
| 67 |
<p><?php esc_html_e( 'The dictionary allows you to define translation rules that apply when generating machine translations. You can specify words or sets of words that should never be translated, or define how they should be translated for each language.', 'wplingua' ); ?></p> |
| 68 |
|
| 69 |
<hr> |
| 70 |
|
| 71 |
<?php wplng_option_page_dictionary_entries_html(); ?> |
| 72 |
|
| 73 |
<a href="javascript:void(0);" class="button button-primary" id="wplng-new-rule-button"> |
| 74 |
<?php esc_html_e( 'Add a dictionary entry', 'wplingua' ); ?> |
| 75 |
</a> |
| 76 |
|
| 77 |
</fieldset> |
| 78 |
</td> |
| 79 |
</tr> |
| 80 |
|
| 81 |
<tr id="wplng-section-entry-new" style="display: none;"> |
| 82 |
<th scope="row"><span class="dashicons dashicons-welcome-add-page"></span> <?php esc_html_e( 'Add an entry', 'wplingua' ); ?></th> |
| 83 |
<td class="wplng-flex-container"> |
| 84 |
<div id="wplng-dictionary-entry-new"> |
| 85 |
<?php wplng_option_page_dictionary_new_entry_html(); ?> |
| 86 |
</div> |
| 87 |
</td> |
| 88 |
</tr> |
| 89 |
|
| 90 |
<tr id="wplng-section-entry-edit" style="display: none;"> |
| 91 |
<th scope="row"><span class="dashicons dashicons-welcome-write-blog"></span> <?php esc_html_e( 'Edit the entry', 'wplingua' ); ?></th> |
| 92 |
<td class="wplng-flex-container"> |
| 93 |
<div id="wplng-dictionary-entry-edit"> |
| 94 |
<?php wplng_option_page_dictionary_edit_entry_html(); ?> |
| 95 |
</div> |
| 96 |
</td> |
| 97 |
</tr> |
| 98 |
</table> |
| 99 |
|
| 100 |
<?php submit_button(); ?> |
| 101 |
|
| 102 |
</form> |
| 103 |
</div> |
| 104 |
<?php |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
/** |
| 109 |
* Print HTML subsection of Option page : wpLingua Dictionary - Update translations |
| 110 |
* |
| 111 |
* Displays the list of translations impacted by the latest dictionary rule |
| 112 |
* changes, along with the controls used to launch, ignore, or track the |
| 113 |
* progress of the AJAX update queue. |
| 114 |
* |
| 115 |
* @param array $translations_to_update List of items with 'post_id', 'source' and 'impacted_languages' ('all' or an array of language IDs). |
| 116 |
* @return void |
| 117 |
*/ |
| 118 |
function wplng_option_page_dictionary_update_translations_html( $translations_to_update ) { |
| 119 |
|
| 120 |
/** |
| 121 |
* HTML Buttons |
| 122 |
*/ |
| 123 |
|
| 124 |
$html_buttons = '<div class="wplng-flex-row wplng-dictionary-update-subsection-launch">'; |
| 125 |
|
| 126 |
$html_buttons .= '<div class="wplng-flex-item">'; |
| 127 |
$html_buttons .= '<a'; |
| 128 |
$html_buttons .= ' href="javascript:void(0);"'; |
| 129 |
$html_buttons .= ' class="button wplng-dictionary-update-button-ignore"'; |
| 130 |
$html_buttons .= '>'; |
| 131 |
$html_buttons .= esc_html__( 'Ignore', 'wplingua' ); |
| 132 |
$html_buttons .= '</a>'; |
| 133 |
$html_buttons .= '</div>'; // End .wplng-flex-item |
| 134 |
|
| 135 |
$html_buttons .= '<div class="wplng-flex-item">'; |
| 136 |
$html_buttons .= '<a'; |
| 137 |
$html_buttons .= ' href="javascript:void(0);"'; |
| 138 |
$html_buttons .= ' class="button button-primary wplng-dictionary-update-button-start"'; |
| 139 |
$html_buttons .= '>'; |
| 140 |
$html_buttons .= esc_html__( 'Update translations', 'wplingua' ); |
| 141 |
$html_buttons .= '</a>'; |
| 142 |
$html_buttons .= '</div>'; // End .wplng-flex-item |
| 143 |
|
| 144 |
$html_buttons .= '</div>'; // End .wplng-flex-row |
| 145 |
|
| 146 |
/** |
| 147 |
* HTML Section |
| 148 |
*/ |
| 149 |
|
| 150 |
$html = '<tr id="wplng-section-dictionary-update-translations">'; |
| 151 |
|
| 152 |
$html .= '<th scope="row">'; |
| 153 |
$html .= '<span class="dashicons dashicons-update"></span> '; |
| 154 |
$html .= esc_html( 'Update translations', 'wplingua' ); |
| 155 |
$html .= '</th>'; // End .row |
| 156 |
|
| 157 |
$html .= '<td class="wplng-flex-container">'; |
| 158 |
$html .= '<fieldset>'; |
| 159 |
$html .= '<label>'; |
| 160 |
$html .= '<strong>' . esc_html( 'Translations Affected by Dictionary Changes', 'wplingua' ) . '</strong>'; |
| 161 |
$html .= '</label>'; |
| 162 |
$html .= '<p>'; |
| 163 |
$html .= esc_html( 'Some translations have been identified as needing to be updated following the latest changes to the dictionary rules.', 'wplingua' ); |
| 164 |
$html .= '</p>'; |
| 165 |
|
| 166 |
$html .= '<hr>'; |
| 167 |
|
| 168 |
/** |
| 169 |
* Subsection info before process |
| 170 |
*/ |
| 171 |
|
| 172 |
$html .= '<div class="wplng-dictionary-update-subsection-info">'; |
| 173 |
$html .= '<p>'; |
| 174 |
$html .= esc_html( |
| 175 |
sprintf( |
| 176 |
__( 'Number of translations to update: %d', 'wplingua' ), |
| 177 |
count( $translations_to_update ) |
| 178 |
) |
| 179 |
); |
| 180 |
$html .= '</p>'; |
| 181 |
$html .= '</div>'; // End .wplng-dictionary-update-subsection-info |
| 182 |
|
| 183 |
/** |
| 184 |
* Subsection info in process |
| 185 |
*/ |
| 186 |
|
| 187 |
$progression_info = '<span class="wplng-count-processed">0</span>'; |
| 188 |
$progression_info .= ' / ' . count( $translations_to_update ); |
| 189 |
// $progression_info .= ' - <span class="wplng-count-percent">0 %</span>'; |
| 190 |
|
| 191 |
$html .= '<div class="wplng-dictionary-update-subsection-info-progress" style="display: none;">'; |
| 192 |
$html .= '<p>'; |
| 193 |
$html .= esc_html__( 'Translations are currently being updated.', 'wplingua' ); |
| 194 |
$html .= '</p>'; |
| 195 |
$html .= '<p>'; |
| 196 |
$html .= sprintf( |
| 197 |
__( 'Number of translations updated: %1$s', 'wplingua' ), |
| 198 |
$progression_info |
| 199 |
); |
| 200 |
$html .= '</p>'; |
| 201 |
$html .= '</div>'; // End .wplng-dictionary-update-subsection-info |
| 202 |
|
| 203 |
/** |
| 204 |
* Subsection info before process |
| 205 |
*/ |
| 206 |
|
| 207 |
$html .= '<div class="wplng-dictionary-update-subsection-info-end" style="display: none;">'; |
| 208 |
$html .= '<p>'; |
| 209 |
$html .= esc_html__( 'End of translations update.', 'wplingua' ); |
| 210 |
$html .= '</p>'; |
| 211 |
$html .= '<a'; |
| 212 |
$html .= ' href="javascript:void(0);"'; |
| 213 |
$html .= ' class="button button-primary wplng-dictionary-update-button-end"'; |
| 214 |
$html .= '>'; |
| 215 |
$html .= esc_html__( 'Back to the dictionary', 'wplingua' ); |
| 216 |
$html .= '</a>'; |
| 217 |
$html .= '</div>'; // End .wplng-dictionary-update-subsection-info |
| 218 |
|
| 219 |
$html .= $html_buttons; |
| 220 |
|
| 221 |
$html .= '<hr>'; |
| 222 |
$html .= '<p>'; |
| 223 |
$html .= '<strong>' . esc_html( 'Translations to update: ', 'wplingua' ) . '</strong>'; |
| 224 |
$html .= '</p>'; |
| 225 |
|
| 226 |
foreach ( $translations_to_update as $key => $translation_to_update ) { |
| 227 |
|
| 228 |
if ( ! isset( $translation_to_update['post_id'] ) |
| 229 |
|| ! isset( $translation_to_update['source'] ) |
| 230 |
|| ! isset( $translation_to_update['impacted_languages'] ) |
| 231 |
|| ( $translation_to_update['impacted_languages'] !== 'all' |
| 232 |
&& ! is_array( $translation_to_update['impacted_languages'] ) |
| 233 |
) |
| 234 |
) { |
| 235 |
continue; |
| 236 |
} |
| 237 |
|
| 238 |
// Write 'all' as a plain string so jQuery's .data() returns the string 'all' |
| 239 |
// (jQuery only auto-parses values starting with '{' or '['). |
| 240 |
// Arrays are JSON-encoded so jQuery parses them back into JS arrays. |
| 241 |
$impacted_languages_attr = 'all'; |
| 242 |
if ( $translation_to_update['impacted_languages'] !== 'all' ) { |
| 243 |
$impacted_languages_attr = wp_json_encode( $translation_to_update['impacted_languages'] ); |
| 244 |
} |
| 245 |
|
| 246 |
$check = wplng_encryption_encrypt( $translation_to_update['post_id'] . '-' . $impacted_languages_attr ); |
| 247 |
|
| 248 |
$html .= '<div'; |
| 249 |
$html .= ' class="wplng-dictionary-text-to-update-entry"'; |
| 250 |
$html .= ' data-post-id="' . esc_attr( $translation_to_update['post_id'] ) . '"'; |
| 251 |
$html .= ' data-impacted-languages="' . esc_attr( $impacted_languages_attr ) . '"'; |
| 252 |
$html .= ' data-check="' . esc_attr( $check ) . '"'; |
| 253 |
$html .= '>'; |
| 254 |
|
| 255 |
// $html .= '<span class="wplng-dictionary-update-state dashicons dashicons-yes-alt"></span>'; |
| 256 |
$html .= '<span class="wplng-dictionary-update-state dashicons"></span>'; |
| 257 |
|
| 258 |
$html .= '<strong>'; |
| 259 |
$html .= ' | ' . esc_html__( 'ID: ', 'wplingua' ) . esc_html( $translation_to_update['post_id'] ); |
| 260 |
$html .= '</strong>'; |
| 261 |
|
| 262 |
$html .= '<hr>'; |
| 263 |
|
| 264 |
// Truncate source at the last word boundary before 200 characters. |
| 265 |
$source_display = $translation_to_update['source']; |
| 266 |
if ( mb_strlen( $source_display ) > 200 ) { |
| 267 |
$source_display = mb_substr( $source_display, 0, 200 ); |
| 268 |
$last_space = mb_strrpos( $source_display, ' ' ); |
| 269 |
if ( false !== $last_space ) { |
| 270 |
$source_display = mb_substr( $source_display, 0, $last_space ); |
| 271 |
} |
| 272 |
$source_display .= '…'; |
| 273 |
} |
| 274 |
$html .= '<p class="wplng-dictionary-text-to-update">'; |
| 275 |
$html .= esc_html( $source_display ); |
| 276 |
$html .= '</p>'; |
| 277 |
|
| 278 |
$html .= '</div>'; // End .wplng-dictionary-text-to-update-entry |
| 279 |
} |
| 280 |
|
| 281 |
$html .= '</fieldset>'; |
| 282 |
$html .= '</td>'; |
| 283 |
$html .= '</tr>'; |
| 284 |
|
| 285 |
echo $html; |
| 286 |
} |
| 287 |
|
| 288 |
|
| 289 |
/** |
| 290 |
* Print HTML subsection of Option page : wpLingua Dictionary - Entries |
| 291 |
* |
| 292 |
* @return void |
| 293 |
*/ |
| 294 |
function wplng_option_page_dictionary_entries_html() { |
| 295 |
|
| 296 |
$dictionary_entries = wplng_dictionary_get_entries(); |
| 297 |
|
| 298 |
if ( empty( $dictionary_entries ) ) { |
| 299 |
return ''; |
| 300 |
} |
| 301 |
|
| 302 |
$language_website = wplng_get_language_website(); |
| 303 |
$language_website_html = '<img'; |
| 304 |
$language_website_html .= ' src="' . esc_url( $language_website['flag'] ) . '"'; |
| 305 |
$language_website_html .= ' alt="' . esc_attr( $language_website['name'] ) . '"'; |
| 306 |
$language_website_html .= ' class="wplng-flag"'; |
| 307 |
$language_website_html .= '>'; |
| 308 |
|
| 309 |
$html = '<label><strong>'; |
| 310 |
$html .= esc_html__( 'All dictionary entries: ', 'wplingua' ); |
| 311 |
$html .= '</strong></label>'; |
| 312 |
$html .= '<br>'; |
| 313 |
$html .= '<div id="wplng-dictionary-entries">'; |
| 314 |
|
| 315 |
foreach ( $dictionary_entries as $rule_number => $entry ) { |
| 316 |
|
| 317 |
$html .= '<div'; |
| 318 |
$html .= ' class="wplng-dictionary-entry"'; |
| 319 |
$html .= ' wplng-rule="' . esc_attr( $rule_number ) . '"'; |
| 320 |
$html .= '>'; |
| 321 |
|
| 322 |
$html .= '<div class="wplng-rule-header">'; |
| 323 |
|
| 324 |
$html .= '<div class="wplng-rule-name">'; |
| 325 |
$html .= esc_html__( 'Rule N°', 'wplingua' ); |
| 326 |
$html .= esc_html( $rule_number + 1 ); |
| 327 |
$html .= '</div>'; // ENd .wplng-rule-name |
| 328 |
|
| 329 |
$html .= '<div class="wplng-rule-action">'; |
| 330 |
$html .= '<a'; |
| 331 |
$html .= ' href="javascript:void(0);"'; |
| 332 |
$html .= ' class="wplng-rule-link-edit"'; |
| 333 |
$html .= ' wplng-rule="' . esc_attr( $rule_number ) . '"'; |
| 334 |
$html .= '>'; |
| 335 |
$html .= esc_html__( 'Edit', 'wplingua' ); |
| 336 |
$html .= '</a> '; |
| 337 |
$html .= '<a'; |
| 338 |
$html .= ' href="javascript:void(0);"'; |
| 339 |
$html .= ' class="wplng-rule-link-remove"'; |
| 340 |
$html .= ' wplng-rule="' . esc_attr( $rule_number ) . '"'; |
| 341 |
$html .= '>'; |
| 342 |
$html .= esc_html__( 'Remove', 'wplingua' ); |
| 343 |
$html .= '</a>'; |
| 344 |
$html .= '</div>'; // .wplng-rule-action |
| 345 |
|
| 346 |
$html .= '</div>'; // End .wplng-rule-header |
| 347 |
|
| 348 |
$html .= '<hr>'; |
| 349 |
|
| 350 |
if ( isset( $entry['rules'] ) ) { |
| 351 |
|
| 352 |
$html .= '<strong>'; |
| 353 |
$html .= $language_website_html; |
| 354 |
$html .= esc_html__( 'Always translate: ', 'wplingua' ); |
| 355 |
$html .= '</strong>'; |
| 356 |
$html .= esc_html( $entry['source'] ); |
| 357 |
|
| 358 |
foreach ( $entry['rules'] as $language_id => $rule ) { |
| 359 |
|
| 360 |
$language = wplng_get_language_by_id( $language_id ); |
| 361 |
|
| 362 |
$html .= '<hr>'; |
| 363 |
$html .= '<strong>'; |
| 364 |
$html .= '<img'; |
| 365 |
$html .= ' src="' . esc_url( $language['flag'] ) . '"'; |
| 366 |
$html .= ' alt="' . esc_attr( $language['name'] ) . '"'; |
| 367 |
$html .= ' class="wplng-flag"'; |
| 368 |
$html .= '>'; |
| 369 |
$html .= esc_html( $language['name'] ); |
| 370 |
$html .= esc_html__( ' - By: ', 'wplingua' ); |
| 371 |
$html .= '</strong>'; |
| 372 |
$html .= esc_html( $rule ); |
| 373 |
} |
| 374 |
} else { |
| 375 |
$html .= '<strong>'; |
| 376 |
$html .= esc_html__( 'Never translate: ', 'wplingua' ); |
| 377 |
$html .= '</strong>'; |
| 378 |
$html .= esc_html( $entry['source'] ); |
| 379 |
} |
| 380 |
|
| 381 |
$html .= '</div>'; // End .wplng-dictionary-entry |
| 382 |
} |
| 383 |
|
| 384 |
$html .= '</div>'; // End #wplng-dictionary-entries |
| 385 |
|
| 386 |
echo $html; |
| 387 |
} |
| 388 |
|
| 389 |
|
| 390 |
/** |
| 391 |
* Print HTML subsection of Option page : wpLingua Dictionary - New entry |
| 392 |
* |
| 393 |
* @return void |
| 394 |
*/ |
| 395 |
function wplng_option_page_dictionary_new_entry_html() { |
| 396 |
|
| 397 |
$html = ''; |
| 398 |
|
| 399 |
/** |
| 400 |
* Input : Source |
| 401 |
*/ |
| 402 |
|
| 403 |
$language_website = wplng_get_language_website(); |
| 404 |
$language_website_html = '<img'; |
| 405 |
$language_website_html .= ' src="' . esc_url( $language_website['flag'] ) . '"'; |
| 406 |
$language_website_html .= ' alt="' . esc_attr( $language_website['name'] ) . '"'; |
| 407 |
$language_website_html .= ' class="wplng-flag"'; |
| 408 |
$language_website_html .= '>'; |
| 409 |
|
| 410 |
$html .= '<fieldset>'; |
| 411 |
$html .= '<label for="wplng-new-source">'; |
| 412 |
$html .= '<strong>'; |
| 413 |
$html .= $language_website_html; |
| 414 |
$html .= esc_html__( 'Source text: ', 'wplingua' ); |
| 415 |
$html .= '</strong>'; |
| 416 |
$html .= '</label>'; |
| 417 |
$html .= '<br>'; |
| 418 |
$html .= '<textarea'; |
| 419 |
$html .= ' name="wplng-new-source"'; |
| 420 |
$html .= ' id="wplng-new-source"'; |
| 421 |
$html .= ' class="wplng-adaptive-textarea"'; |
| 422 |
$html .= ' maxlength="256"'; |
| 423 |
$html .= '>'; |
| 424 |
$html .= '</textarea>'; |
| 425 |
$html .= '</fieldset>'; |
| 426 |
|
| 427 |
/** |
| 428 |
* Input : Never translate |
| 429 |
*/ |
| 430 |
|
| 431 |
$html .= '<fieldset>'; |
| 432 |
$html .= '<input'; |
| 433 |
$html .= ' type="checkbox"'; |
| 434 |
$html .= ' id="wplng-new-never-translate"'; |
| 435 |
$html .= ' name="wplng-new-never-translate"'; |
| 436 |
$html .= '>'; |
| 437 |
$html .= '<label for="wplng-new-never-translate"> '; |
| 438 |
$html .= esc_html__( 'Never translate', 'wplingua' ); |
| 439 |
$html .= '</label>'; |
| 440 |
$html .= '</fieldset>'; |
| 441 |
|
| 442 |
$language_target = wplng_get_languages_target(); |
| 443 |
|
| 444 |
$html .= '<div id="wplng-new-rules">'; |
| 445 |
foreach ( $language_target as $language ) { |
| 446 |
|
| 447 |
$name = 'wplng-new-always-translate-' . $language['id']; |
| 448 |
|
| 449 |
$html .= '<div class="wplng-new-rule" wplng-rule="' . esc_html( $language['id'] ) . '">'; |
| 450 |
$html .= '<hr>'; |
| 451 |
$html .= '<fieldset>'; |
| 452 |
$html .= '<label for="' . esc_attr( $name ) . '">'; |
| 453 |
$html .= '<strong>'; |
| 454 |
$html .= '<img'; |
| 455 |
$html .= ' src="' . esc_url( $language['flag'] ) . '"'; |
| 456 |
$html .= ' alt="' . esc_attr( $language['name'] ) . '"'; |
| 457 |
$html .= ' class="wplng-flag"'; |
| 458 |
$html .= '>'; |
| 459 |
$html .= esc_html( $language['name'] ); |
| 460 |
$html .= esc_html__( ' - Always translate by: ', 'wplingua' ); |
| 461 |
$html .= '</strong>'; |
| 462 |
$html .= '</label>'; |
| 463 |
|
| 464 |
$html .= '<br>'; |
| 465 |
|
| 466 |
$html .= '<textarea'; |
| 467 |
$html .= ' name="' . esc_attr( $name ) . '"'; |
| 468 |
$html .= ' id="' . esc_attr( $name ) . '"'; |
| 469 |
$html .= ' class="wplng-adaptive-textarea"'; |
| 470 |
$html .= ' maxlength="256"'; |
| 471 |
$html .= '>'; |
| 472 |
$html .= '</textarea>'; |
| 473 |
|
| 474 |
$html .= '</fieldset>'; |
| 475 |
$html .= '</div>'; |
| 476 |
|
| 477 |
} |
| 478 |
$html .= '</div>'; // End #wplng-new-rules |
| 479 |
|
| 480 |
$html .= '<div id="wplng-new-action-section" class="wplng-flex-row">'; |
| 481 |
|
| 482 |
$html .= '<div class="wplng-flex-item">'; |
| 483 |
$html .= '<a'; |
| 484 |
$html .= ' href="javascript:void(0);"'; |
| 485 |
$html .= ' id="wplng-new-cancel-button"'; |
| 486 |
$html .= ' class="button "'; |
| 487 |
$html .= '>'; |
| 488 |
$html .= esc_html__( 'Cancel', 'wplingua' ); |
| 489 |
$html .= '</a>'; |
| 490 |
$html .= '</div>'; // End .wplng-flex-item |
| 491 |
|
| 492 |
$html .= '<div class="wplng-flex-item">'; |
| 493 |
$html .= '<a'; |
| 494 |
$html .= ' href="javascript:void(0);"'; |
| 495 |
$html .= ' id="wplng-new-add-button"'; |
| 496 |
$html .= ' class="button button-primary"'; |
| 497 |
$html .= '>'; |
| 498 |
$html .= esc_html__( 'Save new entry', 'wplingua' ); |
| 499 |
$html .= '</a>'; |
| 500 |
$html .= '</div>'; // End .wplng-flex-item |
| 501 |
|
| 502 |
$html .= '</div>'; // End #wplng-new-action-section |
| 503 |
|
| 504 |
echo $html; |
| 505 |
} |
| 506 |
|
| 507 |
|
| 508 |
/** |
| 509 |
* Print HTML subsection of Option page : wpLingua Dictionary - Edit entry |
| 510 |
* |
| 511 |
* @return void |
| 512 |
*/ |
| 513 |
function wplng_option_page_dictionary_edit_entry_html() { |
| 514 |
|
| 515 |
$html = ''; |
| 516 |
|
| 517 |
/** |
| 518 |
* Input : Source |
| 519 |
*/ |
| 520 |
|
| 521 |
$language_website = wplng_get_language_website(); |
| 522 |
$language_website_html = '<img'; |
| 523 |
$language_website_html .= ' src="' . esc_url( $language_website['flag'] ) . '"'; |
| 524 |
$language_website_html .= ' alt="' . esc_attr( $language_website['name'] ) . '"'; |
| 525 |
$language_website_html .= ' class="wplng-flag"'; |
| 526 |
$language_website_html .= '>'; |
| 527 |
|
| 528 |
$html .= '<fieldset>'; |
| 529 |
$html .= '<label for="wplng-edit-source">'; |
| 530 |
$html .= '<strong>'; |
| 531 |
$html .= $language_website_html; |
| 532 |
$html .= esc_html__( 'Source text: ', 'wplingua' ); |
| 533 |
$html .= '</strong>'; |
| 534 |
$html .= '</label>'; |
| 535 |
$html .= '<br>'; |
| 536 |
$html .= '<textarea'; |
| 537 |
$html .= ' name="wplng-edit-source"'; |
| 538 |
$html .= ' id="wplng-edit-source"'; |
| 539 |
$html .= ' class="wplng-adaptive-textarea"'; |
| 540 |
$html .= ' maxlength="256"'; |
| 541 |
$html .= '>'; |
| 542 |
$html .= '</textarea>'; |
| 543 |
$html .= '</fieldset>'; |
| 544 |
|
| 545 |
/** |
| 546 |
* Input : Never translate |
| 547 |
*/ |
| 548 |
|
| 549 |
$html .= '<fieldset>'; |
| 550 |
$html .= '<input'; |
| 551 |
$html .= ' type="checkbox"'; |
| 552 |
$html .= ' id="wplng-edit-never-translate"'; |
| 553 |
$html .= ' name="wplng-edit-never-translate"'; |
| 554 |
$html .= '>'; |
| 555 |
$html .= '<label for="wplng-edit-never-translate"> '; |
| 556 |
$html .= esc_html__( 'Never translate', 'wplingua' ); |
| 557 |
$html .= '</label>'; |
| 558 |
$html .= '</fieldset>'; |
| 559 |
|
| 560 |
$language_target = wplng_get_languages_target(); |
| 561 |
|
| 562 |
$html .= '<div id="wplng-edit-rules">'; |
| 563 |
foreach ( $language_target as $language ) { |
| 564 |
|
| 565 |
$name = 'wplng-edit-always-translate-' . $language['id']; |
| 566 |
|
| 567 |
$html .= '<div class="wplng-edit-rule" wplng-rule="' . esc_html( $language['id'] ) . '">'; |
| 568 |
$html .= '<hr>'; |
| 569 |
$html .= '<fieldset>'; |
| 570 |
$html .= '<label for="' . esc_attr( $name ) . '">'; |
| 571 |
$html .= '<strong>'; |
| 572 |
$html .= '<img'; |
| 573 |
$html .= ' src="' . esc_url( $language['flag'] ) . '"'; |
| 574 |
$html .= ' alt="' . esc_attr( $language['name'] ) . '"'; |
| 575 |
$html .= ' class="wplng-flag"'; |
| 576 |
$html .= '>'; |
| 577 |
$html .= esc_html( $language['name'] ); |
| 578 |
$html .= esc_html__( ' - Always translate by: ', 'wplingua' ); |
| 579 |
$html .= '</strong>'; |
| 580 |
$html .= '</label>'; |
| 581 |
|
| 582 |
$html .= '<br>'; |
| 583 |
|
| 584 |
$html .= '<textarea'; |
| 585 |
$html .= ' name="' . esc_attr( $name ) . '"'; |
| 586 |
$html .= ' id="' . esc_attr( $name ) . '"'; |
| 587 |
$html .= ' class="wplng-adaptive-textarea"'; |
| 588 |
$html .= ' maxlength="256"'; |
| 589 |
$html .= '>'; |
| 590 |
$html .= '</textarea>'; |
| 591 |
|
| 592 |
$html .= '</fieldset>'; |
| 593 |
$html .= '</div>'; |
| 594 |
|
| 595 |
} |
| 596 |
$html .= '</div>'; |
| 597 |
|
| 598 |
$html .= '<div id="wplng-edit-action-section" class="wplng-flex-row">'; |
| 599 |
|
| 600 |
$html .= '<div class="wplng-flex-item">'; |
| 601 |
$html .= '<a'; |
| 602 |
$html .= ' href="javascript:void(0);"'; |
| 603 |
$html .= ' id="wplng-edit-cancel-button"'; |
| 604 |
$html .= ' class="button "'; |
| 605 |
$html .= '>'; |
| 606 |
$html .= esc_html__( 'Cancel', 'wplingua' ); |
| 607 |
$html .= '</a>'; |
| 608 |
$html .= '</div>'; // End .wplng-flex-item |
| 609 |
|
| 610 |
$html .= '<div class="wplng-flex-item">'; |
| 611 |
$html .= '<a'; |
| 612 |
$html .= ' href="javascript:void(0);"'; |
| 613 |
$html .= ' id="wplng-edit-save-button"'; |
| 614 |
$html .= ' class="button button-primary"'; |
| 615 |
$html .= '>'; |
| 616 |
$html .= esc_html__( 'Save edited entry', 'wplingua' ); |
| 617 |
$html .= '</a>'; |
| 618 |
$html .= '</div>'; // End .wplng-flex-item |
| 619 |
|
| 620 |
$html .= '</div>'; // End #wplng-edit-action-section |
| 621 |
|
| 622 |
echo $html; |
| 623 |
} |
| 624 |
|