💦 FULL SET: Changeset/ - HD Photos!

Changeset 2728179


Ignore:
Timestamp:
05/22/2022 10:38:06 PM (4 years ago)
Author:
BinaryMoon
Message:
  • Fix issue with new translations not saving properly.
  • Reduce duplication further (and remove the liklihood of this bug from re-appearing).
Location:
translate-words/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • translate-words/trunk/includes/administration.php

    r2665051 r2728179  
    55 * @package tww
    66 */
     7
     8/**
     9 * A temporary variable since we don't seem to be able to use function calls in
     10 * HEREDOC.
     11 */
     12$tww_translation_lines = esc_attr( TWW_TRANSLATIONS_LINES );
     13
     14/**
     15 * Define a template pattern for reuse.
     16 * This covers the new translation input fields and is used in both PHP and JS.
     17 */
     18define(
     19    'TWW_NEW_STRING_TEMPLATE',
     20<<<TEMPLATE
     21<tr valign="top">
     22<td style="white-space: nowrap">
     23    <input type="text" style="width:100%;" name="{$tww_translation_lines}[original][]" />
     24    &rarr;
     25</td>
     26<td><input type="text" style="width:100%;" name="{$tww_translation_lines}[overwrite][]" /></td>
     27<td></td>
     28</tr>
     29TEMPLATE
     30);
     31
    732
    833/**
     
    2752
    2853/**
    29  *
     54 * Enqueue Admin Scripts.
     55 *
     56 * @return void
    3057 */
    3158function tww_admin_enqueue_scripts() {
     
    4269
    4370    wp_enqueue_script(
    44         'TWW_TRANSLATIONS_JS',
     71        'TWW_TRANSLATIONS_ADMIN',
    4572        TWW_PLUGINS_DIR . 'js/main.js',
    4673        array( 'jquery' ),
    47         '1.0.0',
     74        '1.0.1',
    4875        false
     76    );
     77
     78    wp_localize_script(
     79        'TWW_TRANSLATIONS_ADMIN',
     80        'tww_properties',
     81        array(
     82            'template' => TWW_NEW_STRING_TEMPLATE,
     83        )
    4984    );
    5085
     
    100135            }
    101136        }
     137
    102138    }
    103139
     
    173209        }
    174210    }
    175 ?>
    176                 <tr valign="top">
    177                     <td style="white-space: nowrap">
    178                         <input type="text" style="width:100%;" name="<?php echo esc_attr( TWW_TRANSLATIONS_LINES ); ?>[original][]" />
    179                         &rarr;
    180                     </td>
    181                     <td>
    182                         <input type="text" style="width:100%;" name="<?php echo esc_attr( TWW_TRANSLATIONS_LINES ); ?>[overwrite][]" />
    183                     </td>
    184                     <td></td>
    185                 </tr>
     211
     212    echo TWW_NEW_STRING_TEMPLATE;
     213
     214?>
     215
    186216            </tbody>
    187217        </table>
     
    194224    </form>
    195225</div>
     226
    196227<?php
    197228
  • translate-words/trunk/js/main.js

    r2523953 r2728179  
    2323    e.preventDefault();
    2424
    25     var row = '';
    26 
    27     row += '<tr valign="top">';
    28     row += '<td style="white-space: nowrap;">';