Plugin Directory

Changeset 2752289


Ignore:
Timestamp:
07/05/2022 10:52:46 PM (4 years ago)
Author:
tekod
Message:

l10n

Location:
fws-resize-on-demand/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • fws-resize-on-demand/trunk/fws-resize-on-demand.php

    r2696272 r2752289  
    55 * Plugin URI:  https://wordpress.org/plugins/fws-resize-on-demand
    66 * Description: On-demand image resizer for WordPress.
    7  * Version:     0.3.3
     7 * Version:     0.3.4
    88 * Author:      Miroslav Curcic
    99 * Author URI:  https://profiles.wordpress.org/tekod
     10 * Text Domain: fws-rod
     11 * Domain Path: /languages
     12 * Requires at least: 4.8
    1013 */
    1114
     
    1619define('FWS_ROD_PLUGINBASENAME', plugin_basename(__FILE__));
    1720define('FWS_ROD_DIR', __DIR__);
    18 define('FWS_ROD_VERSION', '0.3.3');
     21define('FWS_ROD_VERSION', '0.3.4');
    1922
    2023
  • fws-resize-on-demand/trunk/src/Dashboard.php

    r2636601 r2752289  
    106106        // wrapper and <h1>
    107107        echo '<div class="fws_rod">';
    108         echo '<h1>Resize on demand</h1>';
     108        echo '<h1>' . __('Resize on demand', 'fws-rod') . '</h1>';
    109109        echo '<hr>';
    110110
     
    130130            //$URL= admin_url( 'options-general.php?page='.self::$AdminPageSlug.'&tab='.esc_attr($Slug));
    131131            $Class= $CurrentTab === $Slug ? 'nav-tab nav-tab-active' : 'nav-tab';
    132             $Tabs .= '<a href="javascript:FwsRodTab(\''.$Slug.'\')" id="fws_rod_tab_'.$Slug.'" class="'.$Class.'">'.esc_html($Label).'</a>';
     132            $Tabs .= '<a href="javascript:FwsRodTab(\''.$Slug.'\')" id="fws_rod_tab_'.$Slug.'" class="'.$Class.'">'.esc_html__($Label, 'fws-rod').'</a>';
    133133        }
    134134
     
    167167
    168168            // prepare confirmation message
    169             set_transient(self::$AdminMsgTransient.'_msg', 'updated-Settings saved.');
     169            set_transient(self::$AdminMsgTransient.'_msg', 'updated-' . __('Settings saved.'));
    170170        }
    171171
     
    208208
    209209            // prepare confirmation message
    210             set_transient(self::$AdminMsgTransient.'_msg', "updated-Removed $TotalCount thumbnails.");
     210            set_transient(self::$AdminMsgTransient.'_msg', 'updated-' . sprintf(__('Removed %n thumbnails.', 'fws-rod'), $TotalCount));
    211211        }
    212212
     
    235235
    236236            // prepare confirmation message
    237             set_transient(self::$AdminMsgTransient.'_msg', 'updated-Settings saved.');
     237            set_transient(self::$AdminMsgTransient.'_msg', 'updated-' . __('Settings saved.'));
    238238        }
    239239
     
    265265
    266266        // check each size
     267        $ExistingSizes = array_keys($Meta['sizes']);
    267268        foreach ($Meta['sizes'] as $Key => $SizePack) {
    268269
     
    287288        if ($NeedUpdateMeta) {
    288289            wp_update_attachment_metadata($Attachment['post_id'], $Meta);
     290            $Removed = implode(',', array_diff($ExistingSizes, array_keys($Meta['sizes'])));
     291            $Left = implode(',', array_keys($Meta['sizes']));
     292            Services::Log("Deleted thumbnails of post #$Attachment[post_id]: [$Removed], Left: [$Left]");
    289293        }
    290294
     
    303307
    304308        if (!wp_verify_nonce($_POST[Config::$OptionName.'_nonce'], $Action)) {
    305             set_transient(self::$AdminMsgTransient.'_msg', 'error-Session expired, please try again.');
     309            set_transient(self::$AdminMsgTransient.'_msg', 'error-' . __('Session expired, please try again.', 'fws-rod'));
    306310            return false;
    307311        }
    308312        if (!isset($_POST['_wp_http_referer'])) {
    309             set_transient(self::$AdminMsgTransient.'_msg', 'error-Missing target.');
     313            set_transient(self::$AdminMsgTransient.'_msg', 'error-' . __('Missing target.', 'fws-rod'));
    310314            return false;
    311315        }
  • fws-resize-on-demand/trunk/src/Hooks.php

    r2638271 r2752289  
    66 */
    77class Hooks {
     8
     9
     10    // current image meta-data
     11    protected static $ImageMetaData;
    812
    913
     
    4953
    5054        // skip if thumbnail already exists
    51         $ImageData = wp_get_attachment_metadata($Id);
    52         if (is_array($ImageData) && isset($ImageData['sizes'][$Size])) {
     55        self::$ImageMetaData = wp_get_attachment_metadata($Id);
     56        if (is_array(self::$ImageMetaData) && isset(self::$ImageMetaData['sizes'][$Size])) {
    5357            Services::Log('Thumb already exist. Skip.');
    5458            return false;
     
    5660
    5761        // skip if $Id does not refer to a valid attachment
    58         if ($ImageData === false) {
     62        if (self::$ImageMetaData === false) {
    5963            Services::Log('Attachment data not found. Skip.');
    6064            return false;
     
    6266
    6367        // resize now
    64         return self::Resize($ImageData, $Id, $Size);
     68        return self::Resize($Id, $Size);
    6569    }
    6670
     
    8084     * Resize image.
    8185     *
    82      * @param array $ImageData
    8386     * @param int $Id
    8487     * @param string $Size
    8588     * @return array|false
    8689     */
    87     protected static function Resize($ImageData, $Id, $Size) {
     90    protected static function Resize($Id, $Size) {
    8891
    8992        $RegisteredSizes= self::GetRegisteredSizes();
     
    9194
    9295        // log event
    93         Services::Log("Resize '$ImageData[file]' to '$Size' size ($SizeData[width]x$SizeData[height])", true);
     96        Services::Log("Resize '".self::$ImageMetaData['file']."' to '$Size' size ($SizeData[width]x$SizeData[height])", true);
    9497
    9598        // first search for higher-resolution sizes to properly create "srcset"
    9699        $HighResolutionPattern = '/^' . preg_quote($Size, '/') . '@[1-9]+(\\.[0-9]+)?x$/';
    97100        foreach ($RegisteredSizes as $SubName => $SubData) {
    98             if (!isset($ImageData['sizes'][$SubName]) && preg_match($HighResolutionPattern, $SubName)) {
     101            if (!isset(self::$ImageMetaData['sizes'][$SubName]) && preg_match($HighResolutionPattern, $SubName)) {
    99102                Services::Log("Resize to higher-resolution size '$SubName'.");
    100                 self::ResizeSingleImage($ImageData, $Id, $SubName, $SubData); // resize and ignore result
     103                self::ResizeSingleImage($Id, $SubName, $SubData); // resize and ignore result
    101104            }
    102105        }
    103106
    104107        // now resize image to requested image-size
    105         return self::ResizeSingleImage($ImageData, $Id, $Size, $SizeData);
     108        return self::ResizeSingleImage($Id, $Size, $SizeData);
    106109    }
    107110
     
    110113     * Perform actual image resizing.
    111114     *
    112      * @param array $ImageData
    113115     * @param int $Id
    114116     * @param string $SizeName
     
    116118     * @return array|false
    117119     */
    118     protected static function ResizeSingleImage($ImageData, $Id, $SizeName, $SizeData) {
     120    protected static function ResizeSingleImage($Id, $SizeName, $SizeData) {
    119121
    120122        // make the new thumb
     
    131133
    132134        // save image meta, or WP can't see that the thumb exists now
    133         $ImageData['sizes'][$SizeName]= $Resized;
    134         wp_update_attachment_metadata($Id, $ImageData);
     135        self::$ImageMetaData['sizes'][$SizeName]= $Resized;
     136        wp_update_attachment_metadata($Id, self::$ImageMetaData);
    135137
    136138        // log event
    137139        Services::Log("Successfully created '$Resized[file]'.");
     140        Services::Log('ImageMetaData: '.json_encode(self::$ImageMetaData['sizes']));
    138141
    139142        // return the array for displaying the resized image
  • fws-resize-on-demand/trunk/src/templates/settings.php

    r2636601 r2752289  
    6464    }
    6565</style>
    66 <h3>Apply on-demand resizing on these image sizes:</h3>
     66<h3><?=esc_html__('Apply on-demand resizing on these image sizes:', 'fws-rod')?></h3>
    6767<form id="RodSettingsForm" action="admin-post.php" method="post">
    6868    <table>
    6969        <tr>
    7070            <td colspan="2">
    71                 <a href="javascript:FwsRodCheckAll();">Check all</a>
     71                <a href="javascript:FwsRodCheckAll();"><?=esc_html__('Check all', 'fws-rod')?></a>
    7272            </td>
    7373        </tr>
     
    8282                    $Checked= ' checked';
    8383                    $Disabled= ' disabled';
    84                     $Notice= 'This size has been enabled programmatically.';
     84                    $Notice= esc_html__('This size has been enabled programmatically.', 'fws-rod');
    8585                }
    8686                if (in_array($Key, $ForceDisableSizes)) {
    8787                    $Checked= '';
    8888                    $Disabled= ' disabled';
    89                     $Notice= 'This size has been disabled programmatically.';
     89                    $Notice= esc_html__('This size has been disabled programmatically.', 'fws-rod');
    9090                }
    9191            ?>
     
    110110    </table>
    111111    <div style="padding:1em 0 0 1em; color:gray">
    112         Total: <?php echo count($Sizes); ?> registered sizes
     112        <?=esc_html(sprintf(__('Total: %d registered sizes', 'fws-rod'), count($Sizes)))?>
    113113    </div>
    114114    <?php submit_button(); ?>
  • fws-resize-on-demand/trunk/src/templates/utils.php

    r2636601 r2752289  
    2222<div>
    2323    <form action="admin-post.php" method="post" class="utils-form">
    24         Delete all thumbnails at sizes that we handle so they can be re-created on demand.
    25         <?php submit_button('Delete', 'primary large', 'submit'); ?>
     24        <?=esc_html__('Delete all thumbnails at sizes that we handle so they can be re-created on demand.', 'fws-rod')?>
     25        <?php submit_button(__('Delete'), 'primary large', 'submit'); ?>
    2626        <input type="hidden" name="action" value="<?php echo esc_attr($ActionDel); ?>">
    2727        <?php wp_nonce_field($ActionDel, $OptionName.'_nonce', false); ?>
     
    3030
    3131    <form action="admin-post.php" method="post" class="utils-form">
    32         Enable debug logging to trace sources of image resizing.
     32        <?=esc_html__('Enable debug logging to trace sources of image resizing.', 'fws-rod')?>
    3333        <div style="padding:2em 0 0 0">
    3434            <input type="checkbox" name="fws_ROD_Logging" id="fws_ROD_Logging" value="1"<?php checked($IsLoggingEnabled); ?>>
    35             <label for="fws_ROD_Logging">Enable debug logging</label>
     35            <label for="fws_ROD_Logging"><?=esc_html__('Enable debug logging', 'fws-rod')?></label>
    3636        </div>
    37         <?php submit_button('Save choice', 'primary large', 'submit'); ?>
     37        <?php submit_button(__('Save Changes'), 'primary large', 'submit'); ?>
    3838        <input type="hidden" name="action" value="<?php echo esc_attr($ActionLog); ?>">
    3939        <?php wp_nonce_field($ActionLog, $OptionName.'_nonce', false); ?>
    4040        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr($RedirectURL); ?>">
    4141        <div style="padding: 1em 0 2em 0">
    42             Log file is located at:<br><?php echo esc_html($LogFilePath); ?>
     42            <?=esc_html__('Log file is located at:', 'fws-rod')?>
     43            <br>
     44            <?=esc_html($LogFilePath)?>
    4345        </div>
    4446    </form>
Note: See TracChangeset for help on using the changeset viewer.